@puddle-code/cli 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -13
- package/dist/index.js +24 -3
- package/dist/public/assets/Dashboard-D0B3Kact.js +1 -0
- package/dist/public/assets/{EditorTabClose-fAutR9L2.js → EditorTabClose-DH-LS9Zv.js} +1 -1
- package/dist/public/assets/LazyTerminal-SW0c7j8t.js +2 -0
- package/dist/public/assets/{ModelRefcount-MJz59mka.js → ModelRefcount-BO6Mp87O.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-DGqg_4uR.js → PaneEditorBody-_zHVXavR.js} +2 -2
- package/dist/public/assets/SettingsDialog-DvUCRTKI.js +1 -0
- package/dist/public/assets/Terminal-MrMvzcuc.js +117 -0
- package/dist/public/assets/Workspace-CNchP0lE.js +7 -0
- package/dist/public/assets/{buffer-store-bK5Xpj6d.js → buffer-store-5mtYW1Xq.js} +2 -2
- package/dist/public/assets/context-menu-7ErbVngu.js +1 -0
- package/dist/public/assets/{cssMode-DfLbNQ92.js → cssMode-DgxyyatT.js} +1 -1
- package/dist/public/assets/editor-context-CJ-O2xj0.js +1 -0
- package/dist/public/assets/{editor-sync-Cc36ZLyi.js → editor-sync-CCVhpCCj.js} +1 -1
- package/dist/public/assets/hotkeys-BJ9IivRE.js +73 -0
- package/dist/public/assets/{htmlMode-Decw-wtn.js → htmlMode-CsnCJ5rN.js} +1 -1
- package/dist/public/assets/index-D9bGlq8g.js +10 -0
- package/dist/public/assets/{jsonMode-vNCk8wN_.js → jsonMode-Bm5_kMyH.js} +1 -1
- package/dist/public/assets/session-seed-CXqY3vWw.js +1 -0
- package/dist/public/assets/ssh-mode-nM399PS5.js +1 -0
- package/dist/public/assets/{tsMode-XcRZTbul.js → tsMode-D76dymM5.js} +1 -1
- package/dist/public/index.html +3 -4
- package/package.json +1 -1
- package/dist/public/assets/Dashboard-CaIw594e.js +0 -1
- package/dist/public/assets/LazyTerminal-Cv4MivyB.js +0 -2
- package/dist/public/assets/SettingsDialog-Ck6AFRjw.js +0 -1
- package/dist/public/assets/Terminal-BtsgoMqj.js +0 -117
- package/dist/public/assets/Workspace-BaIcmmwi.js +0 -7
- package/dist/public/assets/api-BJeOJuGe.js +0 -73
- package/dist/public/assets/context-menu-CLWmCX87.js +0 -1
- package/dist/public/assets/editor-context-Cz5G4UVr.js +0 -1
- package/dist/public/assets/hotkeys-BrRVXikm.js +0 -1
- package/dist/public/assets/index-IEQHp8h9.js +0 -10
- package/dist/public/assets/session-seed-mKf0bRzJ.js +0 -1
- package/dist/public/assets/ssh-mode-DFHbi7WV.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,22 +7,12 @@ Past releases: see docs/changelogs/.
|
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
|
|
10
|
-
## [0.0.
|
|
11
|
-
|
|
12
|
-
### Changed
|
|
13
|
-
|
|
14
|
-
- Protocol 14.0: a forced-upgrade major with no schema change beyond 13.1's additive login `hint` (the 6.0/8.0/…/13.0 pattern). The fixed login flows are daemon-side behaviour a client cannot detect or route around — a 13.x daemon still runs the subcommand logins (codex's empty panel included) and never verifies a login's clean exit — so every connected daemon auto-upgrades at its next handshake.
|
|
10
|
+
## [0.0.33] — 2026-08-07
|
|
15
11
|
|
|
16
12
|
### Added
|
|
17
13
|
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
### Changed
|
|
21
|
-
|
|
22
|
-
- Account renaming is discoverable: a pencil beside the account name in Settings → Accounts starts the edit (the name was already an inline-editable field, but nothing said so until it was hovered).
|
|
23
|
-
- The account login dialogue is near-fullscreen: the login is the agent's first-run TUI now, so it gets a real terminal's canvas rather than the 28rem box sized for the old subcommand flows.
|
|
14
|
+
- "App shortcuts in terminals" (a switch atop Settings → Hotkeys, per profile like the bindings it governs; protocol 14.2, default on): chords bound to puddle actions — ⌃⇥/⌃⇧⇥ tab cycling, ⌘K, sidebar toggles — now work while a terminal is focused, instead of being eaten by xterm and sent to the agent. Turn it off to hand those keys back to terminal apps; terminal-owned keys (⌃A, ⌃`) go to the terminal either way.
|
|
24
15
|
|
|
25
16
|
### Fixed
|
|
26
17
|
|
|
27
|
-
-
|
|
28
|
-
- Switching (or creating) a profile now lands on that profile's dashboard. The picker replaced the router without touching the address, so the previous profile's project URL was still current when the router came back — and a project route binds the workspace to the project's OWNING profile, so a brand-new profile appeared to have inherited the old profile's projects, sessions, and layout wholesale.
|
|
18
|
+
- Auto-theming agents (e.g. Claude Code with `theme: auto`) no longer come up dark under a light puddle theme: they sample the terminal background at spawn, usually before any viewer has attached, so the browser-side answer to their OSC 10/11 colour query arrived for nobody. The daemon now answers those queries itself, from the colours the client reports over the WS on connect and on every theme switch (protocol 14.1, additive — against an older daemon the viewer-side answering remains). A running agent that already sampled keeps its choice until its next start/resume.
|
package/dist/index.js
CHANGED
|
@@ -4184,7 +4184,7 @@ import { readFileSync } from "node:fs";
|
|
|
4184
4184
|
import { dirname, join as join2 } from "node:path";
|
|
4185
4185
|
import { fileURLToPath } from "node:url";
|
|
4186
4186
|
function cliVersion() {
|
|
4187
|
-
if (true) return "0.0.
|
|
4187
|
+
if (true) return "0.0.33";
|
|
4188
4188
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
4189
4189
|
for (const candidate of [
|
|
4190
4190
|
join2(here, "..", "..", "package.json"),
|
|
@@ -4469,7 +4469,7 @@ function openBrowser(url2, platform = process.platform) {
|
|
|
4469
4469
|
import { join as join6 } from "node:path";
|
|
4470
4470
|
|
|
4471
4471
|
// ../shared/src/protocol.ts
|
|
4472
|
-
var PROTOCOL_VERSION = { major: 14, minor:
|
|
4472
|
+
var PROTOCOL_VERSION = { major: 14, minor: 2 };
|
|
4473
4473
|
|
|
4474
4474
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
4475
4475
|
var external_exports = {};
|
|
@@ -19124,6 +19124,14 @@ var profileSettingsSchema = external_exports.looseObject({
|
|
|
19124
19124
|
* PTY spawn. Off pauses the whole feature; stored maps are kept untouched.
|
|
19125
19125
|
*/
|
|
19126
19126
|
captureSessionEnv: external_exports.boolean().default(true),
|
|
19127
|
+
/**
|
|
19128
|
+
* App shortcuts win over a focused terminal (SPEC §11, 14.2): chords bound
|
|
19129
|
+
* to registered actions — ⌃⇥ tab cycling, ⌘K — reach the app instead of
|
|
19130
|
+
* being eaten by xterm and sent to the PTY. Off, the terminal receives
|
|
19131
|
+
* every key it handles. Per profile: which keys your muscle memory owns is
|
|
19132
|
+
* a fact about you, not about the browser you happen to be in.
|
|
19133
|
+
*/
|
|
19134
|
+
terminalAppShortcuts: external_exports.boolean().default(true),
|
|
19127
19135
|
/**
|
|
19128
19136
|
* Launch-text templates (SPEC §4). A key that is ABSENT falls back to the
|
|
19129
19137
|
* daemon's built-in default; an EMPTY string is an intentional empty preamble.
|
|
@@ -19901,7 +19909,20 @@ var wsClientMessageSchema = external_exports.discriminatedUnion("t", [
|
|
|
19901
19909
|
external_exports.object({ t: external_exports.literal("spawn-shell"), session: external_exports.string() }),
|
|
19902
19910
|
/** Terminate a shell PTY (never the agent term); viewers learn via `exit`. */
|
|
19903
19911
|
external_exports.object({ t: external_exports.literal("kill-shell"), session: external_exports.string(), term: termId }),
|
|
19904
|
-
external_exports.object({ t: external_exports.literal("subscribe-status") })
|
|
19912
|
+
external_exports.object({ t: external_exports.literal("subscribe-status") }),
|
|
19913
|
+
/**
|
|
19914
|
+
* The client's resolved terminal colours (14.1): the DAEMON answers agents'
|
|
19915
|
+
* OSC 10/11 dynamic-colour queries from the last pair any client reported —
|
|
19916
|
+
* an auto-theming agent (e.g. Claude Code) queries at spawn, usually before
|
|
19917
|
+
* a viewer has attached, so a viewer-side answer misses it and the agent
|
|
19918
|
+
* falls back to dark whatever the app's theme. Sent after auth on every
|
|
19919
|
+
* connect and again on theme switches.
|
|
19920
|
+
*/
|
|
19921
|
+
external_exports.object({
|
|
19922
|
+
t: external_exports.literal("theme"),
|
|
19923
|
+
fg: external_exports.string().regex(/^#[0-9a-fA-F]{6}$/),
|
|
19924
|
+
bg: external_exports.string().regex(/^#[0-9a-fA-F]{6}$/)
|
|
19925
|
+
})
|
|
19905
19926
|
]);
|
|
19906
19927
|
|
|
19907
19928
|
// src/lib/net.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{C as r,_ as i,f as a}from"./hotkeys-BJ9IivRE.js";import{a as o,g as s,i as c,n as l,o as u,t as d}from"./dialog-B43iKmfK.js";import{a as f,c as p,i as m,o as h,s as g,t as _}from"./LazyTerminal-SW0c7j8t.js";import{t as v}from"./utils-B6KiDbIe.js";import{A as y,M as b,c as x,j as S,k as C,n as w,r as T,t as E}from"./context-menu-7ErbVngu.js";import{r as D}from"./dist-i-QevsUb.js";import{On as O,Ot as k,St as A,ct as j,dn as M,en as N,gn as P,it as F,on as I,ot as L,rn as R,st as z,tn as B}from"./index-D9bGlq8g.js";var V=e(t(),1),H=n(),U=!1;function W(){let[e,t]=(0,V.useState)(U),[n,i]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!e)return;let t=!1;return j.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{U=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&j.killShell(r,n),a()):(U=!0,t(!0))},onExit:a}}function G({term:e,onExit:t}){return(0,H.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,H.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,H.jsx)(_,{stream:`home`,term:e,onExit:t})})})}var K=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function q({projectId:e}){let t=P(e),n=(0,V.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),K.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function J({icon:e,label:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,H.jsx)(e,{className:`size-4`})})}function Y({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:i,onDragEnd:a,onDragOver:h}){let _=B(),[y,C]=(0,V.useState)(!1),[D,k]=(0,V.useState)(e.name),[A,j]=(0,V.useState)(z(e)),M=t=>_.mutate({id:e.id,archived:t},{onError:e=>m(e)}),N=()=>{k(e.name),j(z(e)),C(!0)},P=()=>{let t=D.trim(),n=L(A);if(!t){C(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==z(e)?{abbrev:n}:{}};if(Object.keys(r).length===0){C(!1);return}_.mutate({id:e.id,...r},{onSuccess:()=>C(!1),onError:e=>m(e)})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(E,{children:[(0,H.jsx)(x,{asChild:!0,children:(0,H.jsxs)(`div`,{draggable:n,onDragStart:i,onDragEnd:a,onDragOver:h,className:v(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,H.jsxs)(O,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,H.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(q,{projectId:e.id})})]}),(0,H.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,H.jsx)(J,{icon:b,label:`Reopen project`,onClick:()=>M(!1)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{icon:f,label:`Edit project`,onClick:N}),(0,H.jsx)(J,{icon:S,label:`Archive project`,onClick:()=>M(!0)})]})})]})}),(0,H.jsx)(w,{children:e.archived?(0,H.jsxs)(T,{onSelect:()=>M(!1),children:[(0,H.jsx)(b,{}),` Reopen`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(T,{onSelect:N,children:[(0,H.jsx)(f,{}),` Edit`]}),(0,H.jsxs)(T,{onSelect:()=>M(!0),children:[(0,H.jsx)(S,{}),` Archive`]})]})})]}),(0,H.jsx)(d,{open:y,onOpenChange:C,children:(0,H.jsxs)(l,{children:[(0,H.jsx)(o,{children:(0,H.jsx)(u,{children:`Edit project`})}),(0,H.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(g,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,H.jsx)(p,{id:`project-name-${e.id}`,value:D,onChange:e=>k(e.target.value),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(g,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,H.jsx)(p,{id:`project-abbrev-${e.id}`,maxLength:5,value:A,onChange:e=>j(L(e.target.value)),className:`w-24 uppercase`}),(0,H.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(g,{className:`text-fg-muted`,children:`Path`}),(0,H.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,H.jsxs)(c,{children:[(0,H.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>C(!1),children:`Cancel`}),(0,H.jsx)(s,{type:`submit`,disabled:!D.trim()||_.isPending,children:`Save`})]})]})]})})]})}function X({icon:e,label:t,hint:n,onClick:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,H.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function Z(){let e=i(),t=I(e??void 0),n=M(),r=R(e??void 0),o=N(e??``),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),p=W(),m=a(`palette.toggle`),g=e=>n.data?.find(t=>t.id===e)?.path,_=t.data??[],b=r.data?.projectOrder??[],x=C(_.filter(e=>!e.archived),b),w=_.filter(e=>e.archived),T=(e,t)=>{e!==t&&o.mutate({projectOrder:y(x.map(e=>e.id),e,t)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[_.length===0&&(0,H.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,H.jsx)(h,{className:`size-8 text-fg-muted`}),(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,m,`.`]})]}),(0,H.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[x.map(e=>(0,H.jsx)(Y,{project:e,repoPath:g(e.repo_id),draggable:!0,dragging:l===e.id,onDragStart:()=>u(e.id),onDragEnd:()=>u(null),onDragOver:t=>{t.preventDefault(),l&&l!==e.id&&T(l,e.id)}},e.id)),(0,H.jsx)(X,{icon:k,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>c(!0)}),(0,H.jsx)(X,{icon:A,label:p.open?`Close terminal`:`Open terminal`,hint:p.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:p.toggle})]}),w.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,H.jsx)(D,{className:v(`size-3 transition-transform`,d&&`rotate-90`)}),(0,H.jsx)(S,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Archived`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:w.length})]}),d&&(0,H.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:w.map(e=>(0,H.jsx)(Y,{project:e,repoPath:g(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),p.open&&(0,H.jsx)(G,{term:p.term,onExit:p.onExit}),e!==null&&(0,H.jsx)(F,{profileId:e,open:s,onOpenChange:c})]})}export{Z as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-5mtYW1Xq.js";import{s as h,t as g}from"./editor-sync-CCVhpCCj.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=m(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(r,e),[r]),()=>p(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:d,label:f,onClose:p}){let m=b(e,t,d)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>m?x(!0):p();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${f}`,children:(0,y.jsx)(a,{className:`size-3`})}),(0,y.jsx)(u,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,f,`?`]}),(0,y.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{h(e,t,d),g(e,t,d),x(!1),p()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-MrMvzcuc.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/hotkeys-BJ9IivRE.js","assets/utils-B6KiDbIe.js","assets/index-D9bGlq8g.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-ChpBP8Zc.css","assets/ssh-mode-nM399PS5.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{B as i}from"./hotkeys-BJ9IivRE.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{A as o,C as s,O as c,w as l,x as u}from"./dialog-B43iKmfK.js";import{t as d}from"./utils-B6KiDbIe.js";import{t as f}from"./createLucideIcon-DyMAgLa3.js";var p=e(t(),1),m=[`top`,`right`,`bottom`,`left`],h=Math.min,g=Math.max,_=Math.round,v=Math.floor,y=e=>({x:e,y:e}),b={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function x(e,t,n){return g(e,h(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}function D(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function O(e){return T(D(e))}function k(e,t,n){n===void 0&&(n=!1);let r=w(e),i=O(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=R(o)),[o,R(o)]}function A(e){let t=R(e);return[j(e),t,j(t)]}function j(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var M=[`left`,`right`],N=[`right`,`left`],P=[`top`,`bottom`],F=[`bottom`,`top`];function I(e,t,n){switch(e){case`top`:case`bottom`:return n?t?N:M:t?M:N;case`left`:case`right`:return t?P:F;default:return[]}}function L(e,t,n,r){let i=w(e),a=I(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(j)))),a}function R(e){let t=C(e);return b[t]+e.slice(t.length)}function z(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ee(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:z(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function te(e,t,n){let{reference:r,floating:i}=e,a=D(t),o=O(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=w(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function ne(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=ee(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var re=50,ie=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ne},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=te(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<re&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=te(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ae=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=ee(u),f={x:n,y:r},p=O(i),m=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[m]+a.reference[p]-f[p]-a.floating[m],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=D?D[b]:0;(!k||!await(o.isElement==null?void 0:o.isElement(D)))&&(k=s.floating[b]||a.floating[m]);let A=C/2-T/2,j=k/2-g[m]/2-1,M=h(d[v],j),N=h(d[y],j),P=k-g[m]-N,F=k/2-g[m]/2+A,I=x(M,F,P),L=!c.arrow&&w(i)!=null&&F!==I&&a.reference[m]/2-(F<M?M:N)-g[m]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),oe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=S(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=C(r),_=D(o),v=C(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[R(o)]:A(o)),x=p!==`none`;!d&&x&&b.push(...L(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),E=[],O=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=k(r,a,y);E.push(T[e[0]],T[e[1]])}if(O=[...O,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==D(t))||O.every(e=>D(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:O},reset:{placement:t}};let n=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=O.filter(e=>{if(x){let t=D(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ce(e){return m.some(t=>e[t]>=0)}var le=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=se(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ce(e)}}}case`escaped`:{let e=se(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ce(e)}}}default:return{}}}}},ue=new Set([`left`,`top`]);async function de(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=D(n)===`y`,l=ue.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var fe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await de(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},pe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=D(i),p=T(f),m=u[p],h=u[f],g=(e,t)=>x(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},me=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=D(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ue.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},he=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=S(e,t),c=await i.detectOverflow(t,s),l=C(n),u=w(n),d=D(n)===`y`,{width:f,height:p}=r.floating,m,_;l===`top`||l===`bottom`?(m=l,_=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(_=l,m=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=h(p-c[m],v),x=h(f-c[_],y),T=t.middlewareData.shift,E=!T,O=b,k=x;T!=null&&T.enabled.x&&(k=y),T!=null&&T.enabled.y&&(O=v),E&&!u&&(d?k=f-2*g(c.left,c.right):O=p-2*g(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:O});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function ge(){return typeof window<`u`}function V(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return ge()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return ge()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return ge()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ve(e){return!ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function ye(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function be(e){return/^(table|td|th)$/.test(V(e))}function xe(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Se=/transform|translate|scale|rotate|perspective|filter/,Ce=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,we;function Te(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!De()&&(K(t.backdropFilter)||K(t.filter))||Se.test(t.willChange||``)||Ce.test(t.contain||``)}function Ee(e){let t=Y(e);for(;G(t)&&!q(t);){if(Te(t))return t;if(xe(t))return null;t=Y(t)}return null}function De(){return we??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),we}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function Oe(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ve(e)&&e.host||U(e);return ve(t)?t.host:t}function ke(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&ye(t)?t:ke(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ke(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=Ae(a);return t.concat(a,a.visualViewport||[],ye(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function Ae(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function je(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=_(n)!==a||_(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Me(e){return W(e)?e:e.contextElement}function Z(e){let t=Me(e);if(!G(t))return y(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=je(t),o=(a?_(n.width):n.width)/r,s=(a?_(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ne=y(0);function Pe(e){let t=H(e);return!De()||!t.visualViewport?Ne:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fe(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Me(e),o=y(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Fe(a,n,r)?Pe(a):y(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=Ae(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=Ae(n)}}return B({width:u,height:d,x:c,y:l})}function Ie(e,t){let n=Oe(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Le(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ie(e,n),y:n.top+t.scrollTop}}function Re(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?xe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=y(1),u=y(0),d=G(r);if((d||!a)&&((V(r)!==`body`||ye(o))&&(c=Oe(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Le(o,c):y(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ze(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Be(e){let t=Oe(e),n=e.ownerDocument.body,r=g(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=g(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Ie(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=g(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Ve=25;function He(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!De()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Ie(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Ve&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Ue(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function We(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=He(e,n,t);else if(t===`document`)r=Be(U(e));else if(W(t))r=Ue(t,n);else{let n=Pe(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function Ge(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Te(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function Ke(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?xe(t)?[]:Ge(t,this._c):[].concat(n),r],o=We(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=We(t,a[e],i);s=g(n.top,s),c=h(n.right,c),l=h(n.bottom,l),u=g(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function qe(e){let{width:t,height:n}=je(e);return{width:t,height:n}}function Je(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=y(0);if((r||!a)&&((V(t)!==`body`||ye(i))&&(s=Oe(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Ie(i));let l=i&&!r&&!a?Le(i,s):y(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Ye(e){return J(e).position===`static`}function Xe(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Ze(e,t){let n=H(e);if(xe(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Ye(t))return t;t=Y(t)}return n}let r=Xe(e,t);for(;r&&be(r)&&Ye(r);)r=Xe(r,t);return r&&q(r)&&Ye(r)&&!Te(r)?n:r||Ee(e)||n}var Qe=async function(e){let t=this.getOffsetParent||Ze,n=this.getDimensions,r=await n(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $e(e){return J(e).direction===`rtl`}var et={convertOffsetParentRelativeRectToViewportRelativeRect:Re,getDocumentElement:U,getClippingRect:Ke,getOffsetParent:Ze,getElementRects:Qe,getClientRects:ze,getDimensions:qe,getScale:Z,isElement:W,isRTL:$e};function tt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=v(d),_=v(a.clientWidth-(u+f)),y=v(a.clientHeight-(d+p)),b=v(u),x={rootMargin:-m+`px `+-_+`px `+-y+`px `+-b+`px`,threshold:g(0,h(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!tt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function rt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Me(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?nt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!tt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var it=fe,at=pe,ot=oe,st=he,ct=le,lt=ae,ut=me,dt=(e,t,n)=>{let r=new Map,i=n??{},a={...et,...i.platform,_c:r};return ie(e,t,{...i,platform:a})},ft=e(n(),1),pt=typeof document<`u`?p.useLayoutEffect:function(){};function mt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!mt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!mt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ht(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gt(e,t){let n=ht(e);return Math.round(t*n)/n}function _t(e){let t=p.useRef(e);return pt(()=>{t.current=e}),t}function vt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=p.useState(r);mt(f,r)||m(r);let[h,g]=p.useState(null),[_,v]=p.useState(null),y=p.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=p.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=p.useRef(null),w=p.useRef(null),T=p.useRef(u),E=c!=null,D=_t(c),O=_t(i),k=_t(l),A=p.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),dt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!mt(T.current,t)&&(T.current=t,ft.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);pt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=p.useRef(!1);pt(()=>(j.current=!0,()=>{j.current=!1}),[]),pt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=p.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=p.useMemo(()=>({reference:x,floating:S}),[x,S]),P=p.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=gt(N.floating,u.x),r=gt(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ht(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return p.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var yt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:lt({element:r.current,padding:i}).fn(n):r?lt({element:r,padding:i}).fn(n):{}}}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>({fn:ut(e).fn,options:[e,t]}),Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=r(),Dt=`Arrow`,Ot=p.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(l.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ot.displayName=Dt;var kt=Ot;function At(e){let[t,n]=p.useState(void 0);return u(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var jt=`Popper`,[Mt,Nt]=c(jt),[Pt,Ft]=Mt(jt),It=e=>{let{__scopePopper:t,children:n}=e,[r,i]=p.useState(null),[a,o]=p.useState(void 0);return(0,$.jsx)(Pt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};It.displayName=jt;var Lt=`PopperAnchor`,Rt=p.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Ft(Lt,n),s=p.useRef(null),c=a.onAnchorChange,u=o(t,p.useCallback(e=>{s.current=e,e&&c(e)},[c])),d=p.useRef(null);p.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&c(d.current)});let f=a.placementState&&Jt(a.placementState),m=f?.[0],h=f?.[1];return r?null:(0,$.jsx)(l.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:u})});Rt.displayName=Lt;var zt=`PopperContent`,[Bt,Vt]=Mt(zt),Ht=p.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:c=0,arrowPadding:d=0,avoidCollisions:f=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=Ft(zt,n),[S,C]=p.useState(null),w=o(t,C),[T,E]=p.useState(null),D=At(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(m)?m:[m],N=M.length>0,P={padding:j,boundary:M.filter(Kt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=vt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>rt(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[bt({mainAxis:i+k,alignmentAxis:c}),f&&xt({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?St():void 0,...P}),f&&Ct({...P}),wt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Et({element:T,padding:d}),qt({arrowWidth:O,arrowHeight:k}),_&&Tt({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;u(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[B,te]=Jt(L),ne=s(y);u(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=p.useState();return u(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Bt,{scope:n,placedSide:B,placedAlign:te,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(l.div,{"data-side":B,"data-align":te,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Ht.displayName=zt;var Ut=`PopperArrow`,Wt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Gt=p.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Vt(Ut,n),a=Wt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(kt,{...r,ref:t,style:{...r.style,display:`block`}})})});Gt.displayName=Ut;function Kt(e){return e!==null}var qt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Jt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Jt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Yt=It,Xt=Rt,Zt=Ht,Qt=Gt,$t=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,en=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,tn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,nn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function rn({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:d(`flex h-8 w-full px-2.5`,$t,e),...n})}function an({className:e,...t}){return(0,$.jsx)(`textarea`,{className:d(`flex min-h-16 w-full px-2.5 py-2`,$t,e),...t})}var on=`Label`,sn=p.forwardRef((e,t)=>(0,$.jsx)(l.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));sn.displayName=on;var cn=sn;function ln({className:e,...t}){return(0,$.jsx)(cn,{className:d(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var un=f(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),dn=f(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function fn(e){i.error(pn(e),{id:`err:${pn(e)}`})}function pn(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}function mn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,p.useState)(!1),[f,m]=(0,p.useState)(0),h=e=>{n(e.value),r?.(e),u(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(rn,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),m(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),m(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[f]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:d(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>m(t),className:d(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===f,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var hn=(0,p.lazy)(()=>a(()=>import(`./Terminal-MrMvzcuc.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),gn=null;async function _n(){gn=(await a(()=>import(`./Terminal-MrMvzcuc.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).Terminal}function vn(e){return gn?(0,$.jsx)(gn,{...e}):(0,$.jsx)(p.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(hn,{...e})})}export{Yt as _,dn as a,rn as c,nn as d,tn as f,Zt as g,Qt as h,fn as i,an as l,Xt as m,_n as n,un as o,en as p,mn as r,ln as s,vn as t,$t as u,Nt as v,At as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-5mtYW1Xq.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(r(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{_ as r,c as i,f as a}from"./hotkeys-BrRVXikm.js";import{D as o,E as s,O as c,S as l,T as u,a as d,b as f,d as p,f as m,g as h,m as g,n as _,o as v,u as y,w as b}from"./editor-context-Cz5G4UVr.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{S,r as C,t as ee}from"./api-BJeOJuGe.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{F as ne,J as re,M as ie,N as ae,P as oe,Y as se,a as ce,q as le}from"./index-IEQHp8h9.js";import{i as ue,r as de}from"./editor.api2-4X9Vh9Zw.js";import{a as w,c as fe,d as pe,f as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,t as T,u as xe}from"./buffer-store-bK5Xpj6d.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke}from"./editor-sync-Cc36ZLyi.js";import{r as Ae}from"./buffer-logic-BrpRsL1b.js";var je=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),E=e(t(),1),D=n();function Me({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o}){let s=se(),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),l=(0,E.useRef)(o);l.current=o;let u=(0,E.useRef)(null),d=()=>{let e=u.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),u.current=null},f=(0,E.useRef)(d);return f.current=d,(0,E.useEffect)(()=>()=>f.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(me,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:xe,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{u.current=e,e.onDidDispose(()=>{u.current=null}),e.getModifiedEditor().addCommand(ue.CtrlCmd|de.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}var Ne=new Map,Pe=new Map;function Fe(e){for(let t of Pe.get(e)??[])t()}function Ie(e,t){Ne.set(e,t),Fe(e)}function Le(e){Ne.delete(e)&&Fe(e)}function Re(e){return Ne.get(e)??null}function ze(e,t){let n=Pe.get(e);return n||(n=new Set,Pe.set(e,n)),n.add(t),()=>n.delete(t)}function Be(e){return!e}function Ve(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=ue.CtrlCmd:e===`ctrl`?r|=ue.WinCtrl:e===`alt`?r|=ue.Alt:e===`shift`&&(r|=ue.Shift);let i=de[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function He(e,t){let n=Ve(i(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Ve(i(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>re({editorWordWrap:Be(le().editorWordWrap)})})}function Ue(e,t,n,r,i){let a=i?.passive===!0,o=T(e,t,r),l=c(e,t,{root:r,live:i?.live}),u=s(e,r),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(!1),_=(0,E.useRef)(!1),v=(0,E.useRef)(null),y=(0,E.useRef)(null),b=(0,E.useRef)(n);b.current=n;let x=(0,E.useRef)(!1),C=(0,E.useCallback)((e,t)=>{y.current?.cancel(),x.current=!0;try{ve(o,e,t)}finally{x.current=!1}},[o]),te=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ge(o,e),[o]),()=>ye(o)),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>De(o,e),[o]),()=>Se(o)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ze(o,e),[o]),()=>Re(o));(0,E.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let i=fe(o)!==void 0,a=_e(e,t,n.content,n.mtime_ms,r);f(a),!i&&Te(e,t,r).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Ae(a,e.content)&&m(!0):S(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Ae(a,e.content)&&m(!0)}}}))})},[l.data,o,e,t,r]),(0,E.useEffect)(()=>{if(!d||a)return;let n=Ce(e,t,r);y.current=n;let i=d.onDidChangeContent(()=>{x.current||(n(d.getValue(),fe(o)??0),Ee(e,t,r))});return()=>{n.flush(),i.dispose(),y.current=null}},[d,o,e,t,r,a]),(0,E.useEffect)(()=>{!d||!ne.savedElsewhere||ye(o)||l.refetch().then(e=>{ye(o)||(e.data&&e.data.content!==null&&C(e.data.content,e.data.mtime_ms),we(o))})},[ne.savedElsewhere,d,o]),(0,E.useEffect)(()=>{let e=l.data;!d||!e||e.content===null||!ye(o)&&e.mtime_ms!==fe(o)&&C(e.content,e.mtime_ms)},[l.data,d,o]);let ie=(0,E.useCallback)((n,i)=>{he(o,n,i),y.current?.cancel(),ke(e,t,r),Oe(e,t,i,r),m(!1),Le(o)},[o,e,t,r]),ae=(0,E.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&C(n.data.content,n.data.mtime_ms),ke(e,t,r),m(!1),Le(o)})},[o,e,t,C]),oe=(0,E.useCallback)((e,n)=>{u.mutate({path:t,content:e},{onSuccess:e=>ie(n,e.mtime_ms),onError:e=>S.error(e instanceof Error?e.message:`Overwrite failed`)})},[u,t,ie]),se=(0,E.useCallback)(()=>{if(!d||!ye(o))return;let e=d.getValue(),n=d.getAlternativeVersionId(),r=Re(o)?.mtimeMs??fe(o);u.mutate({path:t,content:e,expected_mtime_ms:r},{onSuccess:e=>ie(n,e.mtime_ms),onError:t=>{t instanceof ee&&t.status===409&&t.code===`stale_file`?(l.refetch().then(e=>{e.data&&e.data.content!==null&&Ie(o,{content:e.data.content,mtimeMs:e.data.mtime_ms})}),S.error(`File changed on disk (probably the agent)`,{description:`Nothing was written — your unsaved version is intact.`,duration:1/0,action:{label:`Reload`,onClick:()=>ae()},cancel:{label:`Overwrite`,onClick:()=>oe(e,n)}})):S.error(t instanceof Error?t.message:`Save failed`)}})},[d,o,u,t,ie,ae,oe]),ce=(0,E.useRef)(se);ce.current=se,(0,E.useEffect)(()=>g(h(e,t,r),()=>ce.current()),[e,t,r]);let le=(0,E.useCallback)(()=>{let n=v.current,i=b.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),ue=(0,E.useCallback)(e=>{v.current=e,He(e,{onSave:()=>ce.current()}),le()},[le]);(0,E.useEffect)(()=>{le()},[n,d,le]);let de=(0,E.useCallback)(()=>{ae()},[ae]),w=(0,E.useCallback)(()=>{d&&oe(d.getValue(),d.getAlternativeVersionId())},[d,oe]),pe,me=null;l.data?.binary?pe=`binary`:l.error?l.error instanceof ee&&l.error.status===413?pe=`too-large`:(pe=`error`,me=l.error instanceof Error?l.error.message:`Failed to load file`):pe=d?`ready`:`loading`;let be=te&&ne.savedElsewhere?`saved-elsewhere`:te&&ne.dirtyElsewhere?`dirty-elsewhere`:null;return{status:pe,errorMessage:me,model:d,dirty:te,restoredNotice:p,discardRestore:de,peerBadge:be,conflict:re,takeDisk:ae,keepMine:w,save:se,onMount:ue}}function We({message:e,session:t,path:n,root:r,download:i}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),i&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void f(t,n,r).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(je,{className:`size-4`}),`Download`]})]})}function Ge({session:e,path:t,reveal:n,root:r}){let i=se(),a=Ue(e,t,n,r),o=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,D.jsx)(We,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,D.jsx)(We,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,D.jsx)(We,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});if(a.conflict&&a.model)return(0,D.jsx)(Me,{session:e,path:t,conflict:a.conflict,model:a.model,onTakeDisk:a.takeDisk,onKeepMine:a.keepMine,onSave:a.save});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,D.jsx)(pe,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function O({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ke(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(be(e),()=>{n.current?.(),w(e)}),[e])}function qe(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Je({session:e,refName:t,path:n,content:r}){let i=se(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(pe,{path:qe(`puddle-view`,e,t,n),defaultValue:r,theme:xe,loading:(0,D.jsx)(O,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ye({session:e,against:t,path:n,root:r}){let i=u(e,t,n,{root:r});return i.isPending?(0,D.jsx)(O,{children:`…`}):i.error?(0,D.jsx)(O,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,D.jsx)(O,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(Je,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Xe({session:e,against:t,path:n,basePath:r,root:i}){let a=se(),o=Ue(e,n,null,i),s=u(e,t,r,{root:i}),c=(0,E.useRef)(null);Ke(T(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,E.useRef)(o.save);l.current=o.save;let d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),f=s.error instanceof ee&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,D.jsx)(O,{children:`Binary file`}):o.status===`too-large`?(0,D.jsx)(O,{children:`File too large to show`}):o.status===`error`?(0,D.jsx)(O,{children:o.errorMessage??`Failed to load file`}):f?(0,D.jsx)(Ge,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,D.jsx)(O,{children:`…`}):s.error?(0,D.jsx)(O,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,D.jsx)(me,{modifiedModelPath:o.model.uri.toString(),originalModelPath:qe(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:xe,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(O,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(ue.CtrlCmd|de.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:d,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ze({session:e,path:t,root:n}){return Ke(T(e,t,n)),(0,D.jsx)(Ge,{session:e,path:t,reveal:null,root:n})}function Qe({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,D.jsx)(Ze,{session:e,path:n.path,root:r});case`deleted`:return(0,D.jsx)(Ye,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,D.jsx)(Xe,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function $e({session:e,sha:t,path:n}){let r=u(e,t,n);return r.isPending?(0,D.jsx)(O,{children:`…`}):r.error?(0,D.jsx)(O,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,D.jsx)(O,{children:`Binary file`}):(0,D.jsx)(Je,{session:e,refName:t,path:n,content:r.data.content??``})}function et({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=se(),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),c.current=null},[]),(0,D.jsx)(me,{originalModelPath:qe(`puddle-hist-orig`,e,t,n),modifiedModelPath:qe(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:xe,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(O,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:s.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function tt({session:e,sha:t,path:n,basePath:r}){let i=u(e,`${t}^`,r),a=u(e,t,n);return i.error instanceof ee&&i.error.status===404?(0,D.jsx)($e,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,D.jsx)(O,{children:`…`}):i.error?(0,D.jsx)(O,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,D.jsx)(O,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,D.jsx)(O,{children:`Binary file`}):(0,D.jsx)(et,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function nt({session:e,sha:t,entry:n,isRootCommit:r}){switch(m(n.status,r)){case`added`:return(0,D.jsx)($e,{session:e,sha:t,path:n.path});case`deleted`:return(0,D.jsx)(Ye,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(tt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function rt({session:e,sha:t,path:n,root:r}){let i=b(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(nt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function it({session:e,path:t,root:n}){let r=o(e,{root:n});if(r.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load diff`});let i=r.data.entries.find(e=>e.path===t);return i?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Qe,{session:e,against:r.data.against,entry:i,root:n})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var at=800;function ot({name:e}){let t=se(),n=r(),i=p(n,e),o=a(`editor.save`),s=(0,E.useRef)(null),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=ce(t=>{y(n,e,t).catch(e=>S.error(e instanceof Error?e.message:`Draft not saved`))},at);return c.current=t,()=>{t.flush(),c.current=null}},[n,e]),n===null)return null;if(i.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load the draft`});if(i.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let u=()=>{let t=s.current;t&&(c.current?.flush(),v({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(pe,{path:`puddle-untitled://${n}/${e}`,defaultValue:i.data.content,theme:xe,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{s.current=t,d(e,t.getValue()),He(t,{onSave:u})},onChange:t=>{let n=t??``;d(e,n),c.current?.(n)},options:{automaticLayout:!0,fontFamily:l,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function st(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ct(e){if(Array.isArray(e))return e}function lt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ut(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{B as r,_ as i,c as a,f as o,x as s,y as c}from"./hotkeys-BJ9IivRE.js";import{D as l,E as u,O as d,S as f,T as p,a as m,b as h,d as g,f as _,g as v,m as y,n as b,o as x,u as S,w as C}from"./editor-context-CJ-O2xj0.js";import{t as ee}from"./preload-helper-Czpn1I53.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{F as ne,J as re,M as ie,N as ae,P as oe,Y as se,a as ce,q as le}from"./index-D9bGlq8g.js";import{i as ue,r as de}from"./editor.api2-4X9Vh9Zw.js";import{a as w,c as fe,d as pe,f as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,t as T,u as xe}from"./buffer-store-5mtYW1Xq.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke}from"./editor-sync-CCVhpCCj.js";import{r as Ae}from"./buffer-logic-BrpRsL1b.js";var je=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),E=e(t(),1),D=n();function Me({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o}){let s=se(),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),l=(0,E.useRef)(o);l.current=o;let u=(0,E.useRef)(null),d=()=>{let e=u.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),u.current=null},f=(0,E.useRef)(d);return f.current=d,(0,E.useEffect)(()=>()=>f.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(me,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:xe,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{u.current=e,e.onDidDispose(()=>{u.current=null}),e.getModifiedEditor().addCommand(ue.CtrlCmd|de.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}var Ne=new Map,Pe=new Map;function Fe(e){for(let t of Pe.get(e)??[])t()}function Ie(e,t){Ne.set(e,t),Fe(e)}function Le(e){Ne.delete(e)&&Fe(e)}function Re(e){return Ne.get(e)??null}function ze(e,t){let n=Pe.get(e);return n||(n=new Set,Pe.set(e,n)),n.add(t),()=>n.delete(t)}function Be(e){return!e}function Ve(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=ue.CtrlCmd:e===`ctrl`?r|=ue.WinCtrl:e===`alt`?r|=ue.Alt:e===`shift`&&(r|=ue.Shift);let i=de[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function He(e,t){let n=Ve(a(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Ve(a(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>re({editorWordWrap:Be(le().editorWordWrap)})})}function Ue(e,t,n,i,a){let o=a?.passive===!0,s=T(e,t,i),l=d(e,t,{root:i,live:a?.live}),f=u(e,i),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1),_=(0,E.useRef)(!1),b=(0,E.useRef)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(n);S.current=n;let C=(0,E.useRef)(!1),ee=(0,E.useCallback)((e,t)=>{x.current?.cancel(),C.current=!0;try{ve(s,e,t)}finally{C.current=!1}},[s]),te=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ge(s,e),[s]),()=>ye(s)),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>De(s,e),[s]),()=>Se(s)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ze(s,e),[s]),()=>Re(s));(0,E.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let a=fe(s)!==void 0,o=_e(e,t,n.content,n.mtime_ms,i);m(o),!a&&Te(e,t,i).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Ae(o,e.content)&&g(!0):r(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Ae(o,e.content)&&g(!0)}}}))})},[l.data,s,e,t,i]),(0,E.useEffect)(()=>{if(!p||o)return;let n=Ce(e,t,i);x.current=n;let r=p.onDidChangeContent(()=>{C.current||(n(p.getValue(),fe(s)??0),Ee(e,t,i))});return()=>{n.flush(),r.dispose(),x.current=null}},[p,s,e,t,i,o]),(0,E.useEffect)(()=>{!p||!ne.savedElsewhere||ye(s)||l.refetch().then(e=>{ye(s)||(e.data&&e.data.content!==null&&ee(e.data.content,e.data.mtime_ms),we(s))})},[ne.savedElsewhere,p,s]),(0,E.useEffect)(()=>{let e=l.data;!p||!e||e.content===null||!ye(s)&&e.mtime_ms!==fe(s)&&ee(e.content,e.mtime_ms)},[l.data,p,s]);let ie=(0,E.useCallback)((n,r)=>{he(s,n,r),x.current?.cancel(),ke(e,t,i),Oe(e,t,r,i),g(!1),Le(s)},[s,e,t,i]),ae=(0,E.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&ee(n.data.content,n.data.mtime_ms),ke(e,t,i),g(!1),Le(s)})},[s,e,t,ee]),oe=(0,E.useCallback)((e,n)=>{f.mutate({path:t,content:e},{onSuccess:e=>ie(n,e.mtime_ms),onError:e=>r.error(e instanceof Error?e.message:`Overwrite failed`)})},[f,t,ie]),se=(0,E.useCallback)(()=>{if(!p||!ye(s))return;let e=p.getValue(),n=p.getAlternativeVersionId(),i=Re(s)?.mtimeMs??fe(s);f.mutate({path:t,content:e,expected_mtime_ms:i},{onSuccess:e=>ie(n,e.mtime_ms),onError:t=>{t instanceof c&&t.status===409&&t.code===`stale_file`?(l.refetch().then(e=>{e.data&&e.data.content!==null&&Ie(s,{content:e.data.content,mtimeMs:e.data.mtime_ms})}),r.error(`File changed on disk (probably the agent)`,{description:`Nothing was written — your unsaved version is intact.`,duration:1/0,action:{label:`Reload`,onClick:()=>ae()},cancel:{label:`Overwrite`,onClick:()=>oe(e,n)}})):r.error(t instanceof Error?t.message:`Save failed`)}})},[p,s,f,t,ie,ae,oe]),ce=(0,E.useRef)(se);ce.current=se,(0,E.useEffect)(()=>y(v(e,t,i),()=>ce.current()),[e,t,i]);let le=(0,E.useCallback)(()=>{let n=b.current,r=S.current;i===void 0&&(!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus()))},[e,t,i]),ue=(0,E.useCallback)(e=>{b.current=e,He(e,{onSave:()=>ce.current()}),le()},[le]);(0,E.useEffect)(()=>{le()},[n,p,le]);let de=(0,E.useCallback)(()=>{ae()},[ae]),w=(0,E.useCallback)(()=>{p&&oe(p.getValue(),p.getAlternativeVersionId())},[p,oe]),pe,me=null;l.data?.binary?pe=`binary`:l.error?l.error instanceof c&&l.error.status===413?pe=`too-large`:(pe=`error`,me=l.error instanceof Error?l.error.message:`Failed to load file`):pe=p?`ready`:`loading`;let be=te&&ne.savedElsewhere?`saved-elsewhere`:te&&ne.dirtyElsewhere?`dirty-elsewhere`:null;return{status:pe,errorMessage:me,model:p,dirty:te,restoredNotice:h,discardRestore:de,peerBadge:be,conflict:re,takeDisk:ae,keepMine:w,save:se,onMount:ue}}function We({message:e,session:t,path:n,root:i,download:a}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),a&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void h(t,n,i).catch(e=>r.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(je,{className:`size-4`}),`Download`]})]})}function Ge({session:e,path:t,reveal:n,root:r}){let i=se(),a=Ue(e,t,n,r),o=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,D.jsx)(We,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,D.jsx)(We,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,D.jsx)(We,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});if(a.conflict&&a.model)return(0,D.jsx)(Me,{session:e,path:t,conflict:a.conflict,model:a.model,onTakeDisk:a.takeDisk,onKeepMine:a.keepMine,onSave:a.save});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,D.jsx)(pe,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function O({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ke(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(be(e),()=>{n.current?.(),w(e)}),[e])}function qe(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Je({session:e,refName:t,path:n,content:r}){let i=se(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(pe,{path:qe(`puddle-view`,e,t,n),defaultValue:r,theme:xe,loading:(0,D.jsx)(O,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ye({session:e,against:t,path:n,root:r}){let i=p(e,t,n,{root:r});return i.isPending?(0,D.jsx)(O,{children:`…`}):i.error?(0,D.jsx)(O,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,D.jsx)(O,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(Je,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Xe({session:e,against:t,path:n,basePath:r,root:i}){let a=se(),o=Ue(e,n,null,i),s=p(e,t,r,{root:i}),l=(0,E.useRef)(null);Ke(T(e,n),()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),l.current=null});let u=(0,E.useRef)(o.save);u.current=o.save;let d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),f=s.error instanceof c&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,D.jsx)(O,{children:`Binary file`}):o.status===`too-large`?(0,D.jsx)(O,{children:`File too large to show`}):o.status===`error`?(0,D.jsx)(O,{children:o.errorMessage??`Failed to load file`}):f?(0,D.jsx)(Ge,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,D.jsx)(O,{children:`…`}):s.error?(0,D.jsx)(O,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,D.jsx)(me,{modifiedModelPath:o.model.uri.toString(),originalModelPath:qe(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:xe,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(O,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null}),e.getModifiedEditor().addCommand(ue.CtrlCmd|de.KeyS,()=>u.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:d,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ze({session:e,path:t,root:n}){return Ke(T(e,t,n)),(0,D.jsx)(Ge,{session:e,path:t,reveal:null,root:n})}function Qe({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,D.jsx)(Ze,{session:e,path:n.path,root:r});case`deleted`:return(0,D.jsx)(Ye,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,D.jsx)(Xe,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function $e({session:e,sha:t,path:n}){let r=p(e,t,n);return r.isPending?(0,D.jsx)(O,{children:`…`}):r.error?(0,D.jsx)(O,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,D.jsx)(O,{children:`Binary file`}):(0,D.jsx)(Je,{session:e,refName:t,path:n,content:r.data.content??``})}function et({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=se(),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),c.current=null},[]),(0,D.jsx)(me,{originalModelPath:qe(`puddle-hist-orig`,e,t,n),modifiedModelPath:qe(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:xe,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(O,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:s.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function tt({session:e,sha:t,path:n,basePath:r}){let i=p(e,`${t}^`,r),a=p(e,t,n);return i.error instanceof c&&i.error.status===404?(0,D.jsx)($e,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,D.jsx)(O,{children:`…`}):i.error?(0,D.jsx)(O,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,D.jsx)(O,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,D.jsx)(O,{children:`Binary file`}):(0,D.jsx)(et,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function nt({session:e,sha:t,entry:n,isRootCommit:r}){switch(_(n.status,r)){case`added`:return(0,D.jsx)($e,{session:e,sha:t,path:n.path});case`deleted`:return(0,D.jsx)(Ye,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(tt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function rt({session:e,sha:t,path:n,root:r}){let i=C(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(nt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function it({session:e,path:t,root:n}){let r=l(e,{root:n});if(r.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load diff`});let i=r.data.entries.find(e=>e.path===t);return i?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Qe,{session:e,against:r.data.against,entry:i,root:n})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var at=800;function ot({name:e}){let t=se(),n=i(),a=g(n,e),s=o(`editor.save`),c=(0,E.useRef)(null),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=ce(t=>{S(n,e,t).catch(e=>r.error(e instanceof Error?e.message:`Draft not saved`))},at);return l.current=t,()=>{t.flush(),l.current=null}},[n,e]),n===null)return null;if(a.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load the draft`});if(a.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let d=()=>{let t=c.current;t&&(l.current?.flush(),x({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,s,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(pe,{path:`puddle-untitled://${n}/${e}`,defaultValue:a.data.content,theme:xe,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{c.current=t,m(e,t.getValue()),He(t,{onSave:d})},onChange:t=>{let n=t??``;m(e,n),l.current?.(n)},options:{automaticLayout:!0,fontFamily:u,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function st(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ct(e){if(Array.isArray(e))return e}function lt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ut(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dt(e,t){return ct(e)||lt(e,t)||ft(e,t)||ut()}function ft(e,t){if(e){if(typeof e==`string`)return st(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?st(e,t):void 0}}var pt=Object.entries,mt=Object.setPrototypeOf,ht=Object.isFrozen,gt=Object.getPrototypeOf,_t=Object.getOwnPropertyDescriptor,vt=Object.freeze,yt=Object.seal,bt=Object.create,xt=typeof Reflect<`u`&&Reflect,St=xt.apply,Ct=xt.construct;vt||=function(e){return e},yt||=function(e){return e},St||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Ct||=function(e){return new e(...[...arguments].slice(1))};var wt=Wt(Array.prototype.forEach),Tt=Wt(Array.prototype.lastIndexOf),Et=Wt(Array.prototype.pop),Dt=Wt(Array.prototype.push),Ot=Wt(Array.prototype.splice),kt=Array.isArray,At=Wt(String.prototype.toLowerCase),jt=Wt(String.prototype.toString),Mt=Wt(String.prototype.match),Nt=Wt(String.prototype.replace),Pt=Wt(String.prototype.indexOf),Ft=Wt(String.prototype.trim),It=Wt(Number.prototype.toString),Lt=Wt(Boolean.prototype.toString),Rt=typeof BigInt>`u`?null:Wt(BigInt.prototype.toString),zt=typeof Symbol>`u`?null:Wt(Symbol.prototype.toString),Bt=Wt(Object.prototype.hasOwnProperty),Vt=Wt(Object.prototype.toString),Ht=Wt(RegExp.prototype.test),Ut=Gt(TypeError);function Wt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return St(e,t,n)}}function Gt(e){return function(){return Ct(e,[...arguments])}}function k(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:At;if(mt&&mt(e,null),!kt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ht(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Kt(e){for(let t=0;t<e.length;t++)Bt(e,t)||(e[t]=null);return e}function qt(e){let t=bt(null);for(let r of pt(e)){var n=dt(r,2);let i=n[0],a=n[1];Bt(e,i)&&(kt(a)?t[i]=Kt(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=qt(a):t[i]=a)}return t}function Jt(e){switch(typeof e){case`string`:return e;case`number`:return It(e);case`boolean`:return Lt(e);case`bigint`:return Rt?Rt(e):`0`;case`symbol`:return zt?zt(e):`Symbol()`;case`undefined`:return Vt(e);case`function`:case`object`:{if(e===null)return Vt(e);let t=e,n=Yt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Vt(e)}return Vt(e)}default:return Vt(e)}}function Yt(e,t){for(;e!==null;){let n=_t(e,t);if(n){if(n.get)return Wt(n.get);if(typeof n.value==`function`)return Wt(n.value)}e=gt(e)}function n(){return null}return n}function Xt(e){try{return Ht(e,``),!0}catch{return!1}}var Zt=vt(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Qt=vt(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),$t=vt([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),en=vt([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),tn=vt(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),nn=vt([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),rn=vt([`#text`]),an=vt(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),on=vt(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),sn=vt(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),cn=vt([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),ln=yt(/{{[\w\W]*|^[\w\W]*}}/g),un=yt(/<%[\w\W]*|^[\w\W]*%>/g),dn=yt(/\${[\w\W]*/g),fn=yt(/^data-[\-\w.\u00B7-\uFFFF]+$/),pn=yt(/^aria-[\-\w]+$/),mn=yt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),hn=yt(/^(?:\w+script|data):/i),gn=yt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_n=yt(/^html$/i),vn=yt(/^[a-z][.\w]*(-[.\w]+)+$/i),yn=yt(/<[/\w!]/g),bn=yt(/<[/\w]/g),xn=yt(/<\/no(script|embed|frames)/i),Sn=yt(/\/>/i),Cn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wn=function(){return typeof window>`u`?null:window},Tn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},En=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Dn=function(e,t,n,r){return Bt(e,t)&&kt(e[t])?k(r.base?qt(r.base):{},e[t],r.transform):n};function On(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wn(),t=e=>On(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==Cn.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Yt(d,`cloneNode`),p=Yt(d,`remove`),m=Yt(d,`nextSibling`),h=Yt(d,`childNodes`),g=Yt(d,`parentNode`),_=Yt(d,`shadowRoot`),v=Yt(d,`attributes`),y=o&&o.prototype?Yt(o.prototype,`nodeType`):null,b=o&&o.prototype?Yt(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,ee=!1,te=0,ne=function(){if(te>0)throw Ut(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},re=function(e){ne(),te++;try{return x.createHTML(e)}finally{te--}},ie=function(e){ne(),te++;try{return x.createScriptURL(e)}finally{te--}},ae=function(){return ee||=(C=Tn(u,i),!0),C},oe=n,se=oe.implementation,ce=oe.createNodeIterator,le=oe.createDocumentFragment,ue=oe.getElementsByTagName,de=r.importNode,w=En();t.isSupported=typeof pt==`function`&&typeof g==`function`&&se&&se.createHTMLDocument!==void 0;let fe=ln,pe=un,me=dn,he=fn,ge=pn,_e=hn,ve=gn,ye=vn,be=mn,T=null,xe=k({},[...Zt,...Qt,...$t,...tn,...rn]),Se=null,Ce=k({},[...an,...on,...sn,...cn]),we=Object.seal(bt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ee=null,De=Object.seal(bt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Oe=!0,ke=!0,Ae=!1,je=!0,E=!1,D=!0,Me=!1,Ne=!1,Pe=null,Fe=null,Ie=!1,Le=!1,Re=!1,ze=!1,Be=!0,Ve=!1,He=`user-content-`,Ue=!0,We=!1,Ge={},O=null,Ke=k({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),qe=null,Je=k({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ye=null,Xe=k({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ze=`http://www.w3.org/1998/Math/MathML`,Qe=`http://www.w3.org/2000/svg`,$e=`http://www.w3.org/1999/xhtml`,et=$e,tt=!1,nt=null,rt=k({},[Ze,Qe,$e],jt),it=vt([`mi`,`mo`,`mn`,`ms`,`mtext`]),at=k({},it),ot=vt([`annotation-xml`]),st=k({},ot),ct=k({},[`title`,`style`,`font`,`a`,`script`]),lt=null,ut=[`application/xhtml+xml`,`text/html`],dt=null,ft=null,mt=n.createElement(`form`),ht=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ft&&ft===e)return;(!e||typeof e!=`object`)&&(e={}),e=qt(e),lt=ut.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,dt=lt===`application/xhtml+xml`?jt:At,T=Dn(e,`ALLOWED_TAGS`,xe,{transform:dt}),Se=Dn(e,`ALLOWED_ATTR`,Ce,{transform:dt}),nt=Dn(e,`ALLOWED_NAMESPACES`,rt,{transform:jt}),Ye=Dn(e,`ADD_URI_SAFE_ATTR`,Xe,{transform:dt,base:Xe}),qe=Dn(e,`ADD_DATA_URI_TAGS`,Je,{transform:dt,base:Je}),O=Dn(e,`FORBID_CONTENTS`,Ke,{transform:dt}),Te=Dn(e,`FORBID_TAGS`,qt({}),{transform:dt}),Ee=Dn(e,`FORBID_ATTR`,qt({}),{transform:dt}),Ge=Bt(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?qt(e.USE_PROFILES):e.USE_PROFILES:!1,Oe=e.ALLOW_ARIA_ATTR!==!1,ke=e.ALLOW_DATA_ATTR!==!1,Ae=e.ALLOW_UNKNOWN_PROTOCOLS||!1,je=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,E=e.SAFE_FOR_TEMPLATES||!1,D=e.SAFE_FOR_XML!==!1,Me=e.WHOLE_DOCUMENT||!1,Le=e.RETURN_DOM||!1,Re=e.RETURN_DOM_FRAGMENT||!1,ze=e.RETURN_TRUSTED_TYPE||!1,Ie=e.FORCE_BODY||!1,Be=e.SANITIZE_DOM!==!1,Ve=e.SANITIZE_NAMED_PROPS||!1,Ue=e.KEEP_CONTENT!==!1,We=e.IN_PLACE||!1,be=Xt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:mn,et=typeof e.NAMESPACE==`string`?e.NAMESPACE:$e,at=Bt(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?qt(e.MATHML_TEXT_INTEGRATION_POINTS):k({},it),st=Bt(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?qt(e.HTML_INTEGRATION_POINTS):k({},ot);let t=Bt(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?qt(e.CUSTOM_ELEMENT_HANDLING):bt(null);if(we=bt(null),Bt(t,`tagNameCheck`)&&ht(t.tagNameCheck)&&(we.tagNameCheck=t.tagNameCheck),Bt(t,`attributeNameCheck`)&&ht(t.attributeNameCheck)&&(we.attributeNameCheck=t.attributeNameCheck),Bt(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(we.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),yt(we),E&&(ke=!1),Re&&(Le=!0),Ge&&(T=k({},rn),Se=bt(null),Ge.html===!0&&(k(T,Zt),k(Se,an)),Ge.svg===!0&&(k(T,Qt),k(Se,on),k(Se,cn)),Ge.svgFilters===!0&&(k(T,$t),k(Se,on),k(Se,cn)),Ge.mathMl===!0&&(k(T,tn),k(Se,sn),k(Se,cn))),De.tagCheck=null,De.attributeCheck=null,Bt(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?De.tagCheck=e.ADD_TAGS:kt(e.ADD_TAGS)&&(T===xe&&(T=qt(T)),k(T,e.ADD_TAGS,dt))),Bt(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?De.attributeCheck=e.ADD_ATTR:kt(e.ADD_ATTR)&&(Se===Ce&&(Se=qt(Se)),k(Se,e.ADD_ATTR,dt))),Bt(e,`ADD_URI_SAFE_ATTR`)&&kt(e.ADD_URI_SAFE_ATTR)&&k(Ye,e.ADD_URI_SAFE_ATTR,dt),Bt(e,`FORBID_CONTENTS`)&&kt(e.FORBID_CONTENTS)&&(O===Ke&&(O=qt(O)),k(O,e.FORBID_CONTENTS,dt)),Bt(e,`ADD_FORBID_CONTENTS`)&&kt(e.ADD_FORBID_CONTENTS)&&(O===Ke&&(O=qt(O)),k(O,e.ADD_FORBID_CONTENTS,dt)),Ue&&(T[`#text`]=!0),Me&&k(T,[`html`,`head`,`body`]),T.table&&(k(T,[`tbody`]),delete Te.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ut(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ut(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=re(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=ae()),x&&typeof S==`string`&&(S=re(``)));vt&&vt(e),ft=e},_t=k({},[...Qt,...$t,...en]),xt=k({},[...tn,...nn]),St=function(e,t,n){return t.namespaceURI===$e?e===`svg`:t.namespaceURI===Ze?e===`svg`&&(n===`annotation-xml`||at[n]):!!_t[e]},Ct=function(e,t,n){return t.namespaceURI===$e?e===`math`:t.namespaceURI===Qe?e===`math`&&st[n]:!!xt[e]},It=function(e,t,n){return t.namespaceURI===Qe&&!st[n]||t.namespaceURI===Ze&&!at[n]?!1:!xt[e]&&(ct[e]||!_t[e])},Lt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:et,tagName:`template`});let n=At(e.tagName),r=At(t.tagName);return nt[e.namespaceURI]?e.namespaceURI===Qe?St(n,t,r):e.namespaceURI===Ze?Ct(n,t,r):e.namespaceURI===$e?It(n,t,r):!!(lt===`application/xhtml+xml`&&nt[e.namespaceURI]):!1},Rt=function(e){Dt(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Ut(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},zt=function(e){Gt(e);let t=h(e);if(t){let e=[];wt(t,t=>{Dt(e,t)}),wt(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},Vt=function(e,n){try{Dt(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Dt(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Le||Re)try{Rt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Wt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||Se[dt(i)]))try{e.removeAttribute(i)}catch{}}},Gt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===Cn.element&&Wt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Kt=function(e){if(!D)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===Cn.processingInstruction||n===Cn.comment&&Ht(bn,e.data)){try{p(e)}catch{}continue}if(n===Cn.element){let t=e,n=dt(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},kn=function(e){let t=null,r=null;if(Ie)e=`<remove></remove>`+e;else{let t=Mt(e,/^[\r\n\t ]+/);r=t&&t[0]}lt===`application/xhtml+xml`&&et===$e&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?re(e):e;if(et===$e)try{t=new l().parseFromString(i,lt)}catch{}if(!t||!t.documentElement){t=se.createDocument(et,`template`,null);try{t.documentElement.innerHTML=tt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),et===$e?ue.call(t,Me?`html`:`body`)[0]:Me?t.documentElement:a},An=function(e){return ce.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},jn=function(e){return e=Nt(e,fe,` `),e=Nt(e,pe,` `),e=Nt(e,me,` `),e},Mn=function(e){e.normalize();let t=ce.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=jn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&wt(r,e=>{Pn(e.content)&&Mn(e.content)})},Nn=function(e){let t=b?b(e):null;return typeof t!=`string`||dt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Pn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===Cn.documentFragment}catch{return!1}},A=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Fn(e,n,r){e.length!==0&&wt(e,e=>{e.call(t,n,r,ft)})}let In=function(e,t){return!!(D&&e.hasChildNodes()&&!A(e.firstElementChild)&&Ht(yn,e.textContent)&&Ht(yn,e.innerHTML)||D&&e.namespaceURI===$e&&t===`style`&&A(e.firstElementChild)||e.nodeType===Cn.processingInstruction||D&&e.nodeType===Cn.comment&&Ht(bn,e.data))},Ln=function(e,t){if(!Te[t]&&Vn(t)&&(we.tagNameCheck instanceof RegExp&&Ht(we.tagNameCheck,t)||we.tagNameCheck instanceof Function&&we.tagNameCheck(t)))return!1;if(Ue&&!O[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=We?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return Rt(e),!0},Rn=function(e,n){if(Fn(w.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Nn(e))return Rt(e),!0;let r=dt(b?b(e):e.nodeName);if(Fn(w.uponSanitizeElement,e,{tagName:r,allowedTags:T}),e!==n&&g(e)===null)return!0;if(In(e,r))return Rt(e),!0;if(Te[r]||!(De.tagCheck instanceof Function&&De.tagCheck(r))&&!T[r]){let t=Ln(e,r);return t===!1&&Fn(w.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===Cn.element&&!Lt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Ht(xn,e.innerHTML))return Rt(e),!0;if(E&&e.nodeType===Cn.text){let n=jn(e.textContent);e.textContent!==n&&(Dt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Fn(w.afterSanitizeElements,e,null),!1},zn=function(e,t,r){if(Ee[t]||D&&t===`patchsrc`||D&&t===`for`&&e!==`label`&&e!==`output`||Be&&(t===`id`||t===`name`)&&(r in n||r in mt))return!1;let i=Se[t]||De.attributeCheck instanceof Function&&De.attributeCheck(t,e);if(!(ke&&Ht(he,t))&&!(Oe&&Ht(ge,t))){if(!i){if(!(Vn(e)&&(we.tagNameCheck instanceof RegExp&&Ht(we.tagNameCheck,e)||we.tagNameCheck instanceof Function&&we.tagNameCheck(e))&&(we.attributeNameCheck instanceof RegExp&&Ht(we.attributeNameCheck,t)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(t,e))||t===`is`&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&Ht(we.tagNameCheck,r)||we.tagNameCheck instanceof Function&&we.tagNameCheck(r))))return!1}else if(!Ye[t]&&!Ht(be,Nt(r,ve,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Pt(r,`data:`)===0&&qe[e])&&!(Ae&&!Ht(_e,Nt(r,ve,``)))&&r)return!1}return!0},Bn=k({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Vn=function(e){return!Bn[At(e)]&&Ht(ye,e)},Hn=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return re(r);case`TrustedScriptURL`:return ie(r)}return r},Un=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Nn(e)?Rt(e):Et(t.removed)}catch{Vt(n,e)}},Wn=function(e){Fn(w.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Nn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Se,forceKeepAttr:void 0},r=t.length,i=dt(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=dt(o),u=c,d=o===`value`?u:Ft(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Fn(w.uponSanitizeAttribute,e,n),d=n.attrValue,Ve&&(l===`id`||l===`name`)&&Pt(d,He)!==0&&(Vt(o,e),d=He+d),D&&Ht(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Vt(o,e);continue}if(l===`attributename`&&Mt(d,`href`)){Vt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){Vt(o,e);continue}if(!je&&Ht(Sn,d)){Vt(o,e);continue}if(E&&(d=jn(d)),!zn(i,l,d)){Vt(o,e);continue}d=Hn(i,l,s,d),d!==u&&Un(e,o,s,d)}}Fn(w.afterSanitizeAttributes,e,null)},Gn=function(e){let t=null,n=An(e);for(Fn(w.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Fn(w.uponSanitizeShadowNode,t,null),Rn(t,e),Wn(t),Pn(t.content)&&Gn(t.content),(y?y(t):t.nodeType)===Cn.element){let e=_(t);Pn(e)&&(Kn(e),Gn(e))}Fn(w.afterSanitizeShadowDOM,e,null)},Kn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Gn(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===Cn.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&dt(e)===`template`){let e=n.content;Pn(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Pn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(tt=!e,tt&&(e=`<!-->`),typeof e!=`string`&&!A(e)&&(e=Jt(e),typeof e!=`string`))throw Ut(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ne?(T=Pe,Se=Fe):gt(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(T=qt(T)),w.uponSanitizeAttribute.length>0&&(Se=qt(Se)),t.removed=[];let c=We&&typeof e!=`string`&&A(e);if(c){Kt(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=dt(t);if(!T[n]||Te[n])throw zt(e),Ut(`root node is forbidden and cannot be sanitized in-place`)}if(Nn(e))throw zt(e),Ut(`root node is clobbered and cannot be sanitized in-place`);try{Kn(e)}catch(t){throw zt(e),t}}else if(A(e))i=kn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Cn.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Kn(a);else{if(!Le&&!E&&!Me&&e.indexOf(`<`)===-1)return x&&ze?re(e):e;if(i=kn(e),!i)return Le?null:ze?S:``}i&&Ie&&Rt(i.firstChild);let l=c?e:i,u=An(l);try{for(;o=u.nextNode();)Rn(o,l),Wn(o),Pn(o.content)&&Gn(o.content)}catch(n){throw c&&(zt(e),wt(t.removed,e=>{e.element&&Gt(e.element)})),n}if(c)return wt(t.removed,e=>{e.element&&Gt(e.element)}),E&&Mn(e),e;if(Le){if(E&&Mn(i),Re)for(s=le.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Se.shadowroot||Se.shadowrootmode)&&(s=de.call(r,s,!0)),s}let d=Me?i.outerHTML:i.innerHTML;return Me&&T[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Ht(_n,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
3
|
`+d),E&&(d=jn(d)),x&&ze?re(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};gt(e),Ne=!0,Pe=T,Fe=Se},t.clearConfig=function(){ft=null,Ne=!1,Pe=null,Fe=null,x=C,S=``},t.isValidAttribute=function(e,t,n){ft||gt({});let r=dt(e),i=dt(t);return zn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Bt(w,e)&&Dt(w[e],t)},t.removeHook=function(e,t){if(Bt(w,e)){if(t!==void 0){let n=Tt(w[e],t);return n===-1?void 0:Ot(w[e],n,1)[0]}return Et(w[e])}},t.removeHooks=function(e){Bt(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=En()},t}var kn=On();function An(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jn=An();function Mn(e){jn=e}var Nn={exec:()=>null};function Pn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function A(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(In.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Fn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),In={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Pn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Pn(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Pn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Pn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Pn(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Pn(e=>RegExp(`^ {0,${e}}>`))},Ln=/^(?:[ \t]*(?:\n|$))+/,Rn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Un=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wn=A(Un).replace(/bull/g,Hn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Gn=A(Un).replace(/bull/g,Hn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Kn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,qn=/^[^\n]+/,Jn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yn=A(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Jn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xn=A(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hn).getRegex(),Zn=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Qn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$n=A(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Qn).replace(`tag`,Zn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),er=e=>A(Kn).replace(`hr`,Bn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zn).getRegex(),tr=er(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),nr=er(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),rr={blockquote:A(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,nr).getRegex(),code:Rn,def:Yn,fences:zn,heading:Vn,hr:Bn,html:$n,lheading:Wn,list:Xn,newline:Ln,paragraph:tr,table:Nn,text:qn},ir=A(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Bn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zn).getRegex(),ar={...rr,lheading:Gn,table:ir,paragraph:A(Kn).replace(`hr`,Bn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ir).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zn).getRegex()},or={...rr,html:A(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Qn).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:A(Kn).replace(`hr`,Bn).replace(`heading`,` *#{1,6} *[^
|
|
4
4
|
]`).replace(`lheading`,Wn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},sr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,lr=/^( {2,}|\\)\n(?!\s*$)/,ur=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,dr=/[\p{P}\p{S}]/u,fr=/[\s\p{P}\p{S}]/u,pr=/[^\s\p{P}\p{S}]/u,mr=A(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,fr).getRegex(),hr=/(?!~)[\p{P}\p{S}]/u,gr=/(?!~)[\s\p{P}\p{S}]/u,_r=/(?:[^\s\p{P}\p{S}]|~)/u,vr=A(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Fn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),yr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,br=A(yr,`u`).replace(/punct/g,dr).getRegex(),xr=A(yr,`u`).replace(/punct/g,hr).getRegex(),Sr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Cr=A(Sr,`gu`).replace(/notPunctSpace/g,pr).replace(/punctSpace/g,fr).replace(/punct/g,dr).getRegex(),wr=A(Sr,`gu`).replace(/notPunctSpace/g,_r).replace(/punctSpace/g,gr).replace(/punct/g,hr).getRegex(),Tr=A(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,pr).replace(/punctSpace/g,fr).replace(/punct/g,dr).getRegex(),Er=A(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,dr).getRegex(),Dr=A(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,pr).replace(/punctSpace/g,fr).replace(/punct/g,dr).getRegex(),Or=A(/\\(punct)/,`gu`).replace(/punct/g,dr).getRegex(),kr=A(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ar=A(Qn).replace(`(?:-->|$)`,`-->`).getRegex(),jr=A(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Ar).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Mr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Nr=A(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Mr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pr=A(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Mr).replace(`ref`,Jn).getRegex(),Fr=A(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Jn).getRegex(),Ir=A(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Pr).replace(`nolink`,Fr).getRegex(),Lr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Rr={_backpedal:Nn,anyPunctuation:Or,autolink:kr,blockSkip:vr,br:lr,code:cr,del:Nn,delLDelim:Nn,delRDelim:Nn,emStrongLDelim:br,emStrongRDelimAst:Cr,emStrongRDelimUnd:Tr,escape:sr,link:Nr,nolink:Fr,punctuation:mr,reflink:Pr,reflinkSearch:Ir,tag:jr,text:ur,url:Nn},zr={...Rr,link:A(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Mr).getRegex(),reflink:A(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Mr).getRegex()},Br={...Rr,emStrongRDelimAst:wr,emStrongLDelim:xr,delLDelim:Er,delRDelim:Dr,url:A(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Lr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:A(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Lr).getRegex()},Vr={...Br,br:A(lr).replace(`{2,}`,`*`).getRegex(),text:A(Br.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Hr={normal:rr,gfm:ar,pedantic:or},Ur={normal:Rr,gfm:Br,breaks:Vr,pedantic:zr},Wr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Gr=e=>Wr[e];function Kr(e,t){if(t){if(In.escapeTest.test(e))return e.replace(In.escapeReplace,Gr)}else if(In.escapeTestNoEncode.test(e))return e.replace(In.escapeReplaceNoEncode,Gr);return e}function qr(e){try{e=encodeURI(e).replace(In.percentDecode,`%`)}catch{return null}return e}function Jr(e,t){let n=e.replace(In.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(In.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(In.slashPipe,`|`);return n}function Yr(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Xr(e){let t=e.split(`
|
|
@@ -319,4 +319,4 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
319
319
|
|[ \r ]+
|
|
320
320
|
?)[ \r ]*`,Rl=`[̀-ͯ]`,zl=RegExp(Rl+`+$`),Bl=`(`+Nl+`+)|`+(Ll+`|`)+`([!-\\[\\]-‧-豈-]`+(Rl+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(Rl+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+Il)+(`|`+Fl+`)`),Vl=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Bl,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Hc(`EOF`,new Vc(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new M(`Unexpected character: '`+e[t]+`'`,new Hc(e[t],new Vc(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
|
|
321
321
|
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new Hc(r,new Vc(this,t,this.tokenRegex.lastIndex))}},Hl=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new M(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}},Ul=Bc;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Wl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`")if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new M("\\char` missing argument");else r=t.text.charCodeAt(0);else n=10;if(n){if(r=Wl[t.text],r==null||r>=n)throw new M(`Invalid base-`+n+` digit `+t.text);for(var i;(i=Wl[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var Gl=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new M(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new M(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new M(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new M(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>Gl(e,!1,!0,!1)),$(`\\renewcommand`,e=>Gl(e,!0,!1,!1)),$(`\\providecommand`,e=>Gl(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),Ml[n],F.math[n],F.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var Kl={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},ql=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in Kl?t=Kl[n]:(n.slice(0,4)===`\\not`||n in F.math&&ql.has(F.math[n].group))&&(t=`\\dotsb`),t});var Jl={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in Jl?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in Jl&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in Jl?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new M(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var Yl=P(Ta[`Main-Regular`][84][1]-.7*Ta[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+Yl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+Yl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var Xl=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,Xl(!1)),$(`\\bra@set`,Xl(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var Zl={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Ql=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Hl(Ul,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Vl(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new Hc(`EOF`,n.loc)),this.pushTokens(r),new Hc(``,Vc.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new M(`Extra }`,i)}else if(i.text===`EOF`)throw new M(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n)if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new M(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;r<n.length;r++){var i=this.popToken();if(n[r]!==i.text)throw new M(`Use of the macro doesn't match its definition`,i)}}for(var a=[],o=0;o<e;o++)a.push(this.consumeArg(t&&t[o+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new M(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new M(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new M(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new M(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Hc(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new Vl(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Ml,e)||Object.prototype.hasOwnProperty.call(F.math,e)||Object.prototype.hasOwnProperty.call(F.text,e)||Object.prototype.hasOwnProperty.call(Zl,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(Ml,e)&&!Ml[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},$l=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,eu=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),tu={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},nu={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},ru=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new Ql(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new M(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Hc(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&Ml[i.text]&&Ml[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r<e.length;r++){var i=e[r];if(i.type===`infix`){if(t!==-1)throw new M(`only one infix operator per group`,i.token);t=r,n=i.replaceWith}}if(t!==-1&&n){var a,o,s=e.slice(0,t),c=e.slice(t+1);return a=s.length===1&&s[0].type===`ordgroup`?s[0]:{type:`ordgroup`,mode:this.mode,body:s},o=c.length===1&&c[0].type===`ordgroup`?c[0]:{type:`ordgroup`,mode:this.mode,body:c},[n===`\\\\abovefrac`?this.callFunction(n,[a,e[t],o],[]):this.callFunction(n,[a,o],[])]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var r;do r=this.parseGroup(e);while(r?.type===`internal`);if(!r)throw new M(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});var r={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(e){var t=this.parseGroup(`atom`,e);if(t?.type===`internal`||this.mode===`text`)return t;for(var n,r;;){this.consumeSpaces();var i=this.fetch();if(i.text===`\\limits`||i.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=i.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=i.text===`\\limits`);else throw new M(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new M(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new M(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new M(`Double superscript`,i);var a={type:`textord`,mode:this.mode,text:`\\prime`},o=[a];for(this.consume();this.fetch().text===`'`;)o.push(a),this.consume();this.fetch().text===`^`&&o.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:o}}else if(eu[i.text]){var s=$l.test(i.text),c=[];for(c.push(new Hc(eu[i.text])),this.consume();;){var l=this.fetch().text;if(!eu[l]||$l.test(l)!==s)break;c.unshift(new Hc(eu[l])),this.consume()}var u=this.subparse(c);s?r={type:`ordgroup`,mode:`math`,body:u}:n={type:`ordgroup`,mode:`math`,body:u}}else break}return n&&r?{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r}:n?{type:`supsub`,mode:this.mode,base:t,sup:n}:r?{type:`supsub`,mode:this.mode,base:t,sub:r}:t}parseFunction(e,t){var n=this.fetch(),r=n.text,i=Ml[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new M(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new M(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new M(`Can't use function '`+r+`' in math mode`,n);var a=this.parseArguments(r,i),o=a.args,s=a.optArgs;return this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){var a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=Ml[e];if(o&&o.handler)return o.handler(a,t,n);throw new M(`No function handler for `+e)}parseArguments(e,t){var n=t.numOptionalArgs??0,r=t.numArgs+n;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],o=0;o<r;o++){var s=t.argTypes?.[o],c=o<n;(`primitive`in t&&t.primitive&&s==null||t.type===`sqrt`&&o===1&&a[0]==null)&&(s=`primitive`);var l=this.parseGroupOfType(`argument to '`+e+`'`,s,c);if(c)a.push(l);else if(l!=null)i.push(l);else throw new M(`Null argument, please report this as a bug`)}return{args:i,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case`color`:return this.parseColorGroup(n);case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:var r=this.parseArgumentGroup(n,`text`);return r==null?null:{type:`styling`,mode:r.mode,body:[r],style:`text`,resetFont:!0};case`raw`:var i=this.parseStringGroup(n);return i==null?null:{type:`raw`,mode:`text`,string:i.text};case`primitive`:if(n)throw new M(`A primitive argument cannot be optional`);var a=this.parseGroup(e);if(a==null)throw new M(`Expected group as `+e,this.fetch());return a;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new M(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===` `;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n=``,r;(r=this.fetch()).text!==`EOF`;)n+=r.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),r=n,i=``,a;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new M(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new M(`Invalid color: '`+t.text+`'`,t);var r=n[0];return/^[0-9a-f]{6}$/i.test(r)&&(r=`#`+r),{type:`color-token`,mode:this.mode,color:r}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!r)throw new M(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!oa(i))throw new M(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode(`%`,14),this.gullet.lexer.setCatcode(`~`,13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,`$1`);return{type:`url`,mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();var a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){var n=this.fetch(),r=n.text,i;if(r===`{`||r===`\\begingroup`){this.consume();var a=r===`{`?`}`:`\\endgroup`;this.gullet.beginGroup();var o=this.parseExpression(!1,a),s=this.fetch();this.expect(a),this.gullet.endGroup(),i={type:`ordgroup`,mode:this.mode,loc:Vc.range(n,s),body:o,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(Zl,r)){if(this.settings.throwOnError)throw new M(`Undefined control sequence: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var r=e[n];if(r.type===`textord`){var i=r.text,a=e[n+1];if(!(!a||a.type!==`textord`)){if(i===`-`&&a.text===`-`){var o=e[n+2];n+1<t&&o&&o.type===`textord`&&o.text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:Vc.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:Vc.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:Vc.range(r,a),text:i+i}),--t)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),r=n.charAt(0)===`*`;if(r&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new M(`\\verb assertion failed --
|
|
322
|
-
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(nu,t[0])&&!F[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=nu[t[0]]+t.slice(1));var i=zl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(F[this.mode][t]){this.settings.strict&&this.mode===`math`&&$a.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=F[this.mode][t].group,s=Vc.range(e);a=Ls(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Hi(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:Vc.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!tu[l])throw new M(`Unknown accent ' `+l+`'`,e);var u=tu[l][this.mode]||tu[l].text;if(!u)throw new M(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:Vc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ru.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var iu=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ru(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new M(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Hc(`\\df@tag`)])}]}return r},au=function(e,t,n){t.textContent=``;var r=lu(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),au=function(){throw new M(`KaTeX doesn't work in quirks mode.`)});var ou=function(e,t){return lu(e,t).toMarkup()},su=function(e,t){return iu(e,new Si(t))},cu=function(e,t,n){if(n.throwOnError||!(e instanceof M))throw e;var r=K([`katex-error`],[new va(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},lu=function(e,t){var n=new Si(t);try{return Ts(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},uu={version:`0.18.1`,render:au,renderToString:ou,ParseError:M,SETTINGS_SCHEMA:vi,__parse:su,__renderToDomTree:lu,__renderToHTMLTree:function(e,t){var n=new Si(t);try{return Es(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},__setFontMetrics:Oa,__defineSymbol:I,__defineFunction:J,__defineMacro:$,__domTree:{Span:ma,Anchor:ha,SymbolNode:va,SvgNode:ya,PathNode:ba,LineNode:xa}},du=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function fu(e){return e===`$`||e===`\\`}function pu(e,t=0){for(let[n,r,i]of du){if(!e.startsWith(n,t))continue;let a=t+n.length,o=hu(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!gu(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function mu(e,t=0){for(let n=t;n<e.length;n++){if(!fu(e[n]))continue;let t=pu(e,n);if(t)return{...t,start:n}}return null}function hu(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function gu(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function _u(e,t,n={}){let r=uu.renderToString(e,{displayMode:t,output:`html`,throwOnError:!1,errorColor:`var(--danger)`,strict:!1,trust:!1,macros:n});return`<span class="${t?`math math-display`:`math`}" role="math" aria-label="${yu(e)}">${r}</span>`}var vu=`.math-display{display:block}`;function yu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var bu={},xu=new si({gfm:!0,breaks:!1,async:!1}).use({extensions:[{name:`math`,level:`inline`,start(e){let t=e.search(/\$|\\[([]/);return t<0?void 0:t},tokenizer(e){let t=pu(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return _u(e.text??``,e.display===!0,bu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&_u(e,!0,bu)}}});function Su(e){return bu={},xu.parse(e)}var Cu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,wu=/\bmathjax\b|\bkatex\b/i;function Tu(e){if(Eu(e))return!1;let t=e.body??e.documentElement;if(!t)return!1;let n=e.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();){let e=n.currentNode;/[$\\]/.test(e.data)&&(e.parentElement?.closest(Cu)||r.push(e))}let i={},a=!1;for(let t of r)Du(e,t,i)&&(a=!0);return a}function Eu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(wu.test(t.getAttribute(`src`)??``)||wu.test(t.textContent??``))return!0;return!1}function Du(e,t,n){let r=t.data;if(!mu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=mu(r,0);t;t=mu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=_u(t.tex,t.display,n);a.firstChild;)i.appendChild(a.firstChild);o=t.start+t.length}return o<r.length&&i.appendChild(e.createTextNode(r.slice(o))),t.replaceWith(i),!0}function Ou({session:e,path:t,kind:n,root:r}){let i=ku(e,t,r);return i===null?null:n===`markdown`?(0,D.jsx)(Au,{session:e,path:t,text:i,root:r}):(0,D.jsx)(Nu,{session:e,path:t,text:i,root:r})}function ku(e,t,n){let r=Ue(e,t,null,n,{passive:!0,live:!0}).model;return(0,E.useSyncExternalStore)(r=>ge(T(e,t,n),r),()=>r?.getValue()??null)}kn.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Au({session:e,path:t,text:n,root:r}){let i=(0,E.useMemo)(()=>kn.sanitize(Su(n)),[n]),a=(0,E.useRef)(null);(0,E.useEffect)(()=>{let n=a.current;if(!n)return;let i=!1,o=[];for(let a of n.querySelectorAll(`img`)){let n=ae(t,a.getAttribute(`src`)??``);n&&(a.removeAttribute(`src`),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}${l(r)}`).then(e=>e.blob()).then(e=>{if(i)return;let t=URL.createObjectURL(e);o.push(t),a.src=t}).catch(()=>void 0))}return()=>{i=!0;for(let e of o)URL.revokeObjectURL(e)}},[i,e,t,r]);let{openFile:o}=_(),s=n=>{let i=n.target.closest(`a`);if(!i)return;let a=i.getAttribute(`href`)??``;if(/^https?:/i.test(a)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let s=ae(t,a);s&&o(e,s,void 0,{...ie(s)?{view:`preview`}:{},...r===void 0?{}:{root:r}})},c=se().editorFontSize;return(0,D.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,D.jsx)(`div`,{ref:a,onClick:s,style:{fontSize:c},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:i}})})}var ju=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Mu=20*1024*1024;function Nu({session:e,path:t,text:n,root:r}){let[i,a]=(0,E.useState)(null),o=(0,E.useRef)(new Map),s=se().editorFontSize;return(0,E.useEffect)(()=>{let i=!1;return Pu(e,t,n,o.current,s,r).then(e=>{i||a(e)}),()=>{i=!0}},[e,t,n,s,r]),i===null?null:(0,D.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:i,title:t,className:`size-full bg-paper`})}async function Pu(e,t,n,r,i,a){let o=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=o.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=o.head??o.documentElement;t.insertBefore(e,t.firstChild)}Tu(o)&&await Fu(o);let s=[];for(let[n,i]of ju)for(let c of o.querySelectorAll(n)){let n=ae(t,c.getAttribute(i)??``);n&&(c.removeAttribute(i),s.push(Iu(e,n,r,a).then(e=>{e&&c.setAttribute(i,e)})))}return await Promise.all(s),`<!doctype html>${o.documentElement.outerHTML}`}async function Fu(e){let{default:t}=await x(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${vu}`,(e.head??e.documentElement).appendChild(n)}function Iu(e,t,n,r){let i=n.get(t);if(i)return i;let a=C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${l(r)}`).then(e=>e.blob()).then(async e=>e.size>Mu?null:`data:${Lu(t,e.type)};base64,${Ru(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,a),a}function Lu(e,t){let n=(e.split(`/`).pop()??``).split(`.`).pop()?.toLowerCase()??``;return n===`css`?`text/css`:n===`js`||n===`mjs`?`text/javascript`:t!==``&&t!==`application/octet-stream`?t:`application/octet-stream`}function Ru(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var zu={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Bu(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:zu[t.slice(n+1).toLowerCase()]??null}function Vu({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Wu(e,t,r);return a?(0,D.jsxs)(Hu,{children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,D.jsx)(Uu,{session:e,path:t})]}):i?n===`image`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,D.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,D.jsx)(Hu,{children:(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Hu({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function Uu({session:e,path:t}){return(0,D.jsx)(`button`,{type:`button`,onClick:()=>void f(e,t).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function Wu(e,t,n){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${l(n)}`).then(e=>e.blob()).then(e=>{a||(r=URL.createObjectURL(e),i(r))}).catch(()=>{a||o(!0)}),()=>{a=!0,r&&URL.revokeObjectURL(r)}},[e,t,n]),{url:r,error:a}}function Gu({tab:e,reveal:t}){let n=ne(e);if(n===`diff`)return(0,D.jsx)(it,{session:e.session,path:e.path,root:e.root},oe(e));if(n===`commit`&&e.sha)return(0,D.jsx)(rt,{session:e.session,sha:e.sha,path:e.path,root:e.root},oe(e));if(n===`external`&&e.root!==void 0){let n=Bu(e.path);if(n)return(0,D.jsx)(Vu,{session:e.session,path:e.path,kind:n,root:e.root},oe(e));let r=e.view===`preview`?ie(e.path):null;return r?(0,D.jsx)(Ou,{session:e.session,path:e.path,kind:r,root:e.root},oe(e)):(0,D.jsx)(Ge,{session:e.session,path:e.path,reveal:t,root:e.root},oe(e))}if(n===`untitled`)return(0,D.jsx)(ot,{name:e.path},oe(e));let r=Bu(e.path);if(r)return(0,D.jsx)(Vu,{session:e.session,path:e.path,kind:r},oe(e));let i=e.view===`preview`?ie(e.path):null;return i?(0,D.jsx)(Ou,{session:e.session,path:e.path,kind:i},oe(e)):(0,D.jsx)(Ge,{session:e.session,path:e.path,reveal:t},oe(e))}export{Gu as PaneEditorBody};
|
|
322
|
+
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(nu,t[0])&&!F[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=nu[t[0]]+t.slice(1));var i=zl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(F[this.mode][t]){this.settings.strict&&this.mode===`math`&&$a.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=F[this.mode][t].group,s=Vc.range(e);a=Ls(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Hi(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:Vc.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!tu[l])throw new M(`Unknown accent ' `+l+`'`,e);var u=tu[l][this.mode]||tu[l].text;if(!u)throw new M(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:Vc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ru.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var iu=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ru(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new M(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Hc(`\\df@tag`)])}]}return r},au=function(e,t,n){t.textContent=``;var r=lu(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),au=function(){throw new M(`KaTeX doesn't work in quirks mode.`)});var ou=function(e,t){return lu(e,t).toMarkup()},su=function(e,t){return iu(e,new Si(t))},cu=function(e,t,n){if(n.throwOnError||!(e instanceof M))throw e;var r=K([`katex-error`],[new va(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},lu=function(e,t){var n=new Si(t);try{return Ts(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},uu={version:`0.18.1`,render:au,renderToString:ou,ParseError:M,SETTINGS_SCHEMA:vi,__parse:su,__renderToDomTree:lu,__renderToHTMLTree:function(e,t){var n=new Si(t);try{return Es(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},__setFontMetrics:Oa,__defineSymbol:I,__defineFunction:J,__defineMacro:$,__domTree:{Span:ma,Anchor:ha,SymbolNode:va,SvgNode:ya,PathNode:ba,LineNode:xa}},du=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function fu(e){return e===`$`||e===`\\`}function pu(e,t=0){for(let[n,r,i]of du){if(!e.startsWith(n,t))continue;let a=t+n.length,o=hu(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!gu(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function mu(e,t=0){for(let n=t;n<e.length;n++){if(!fu(e[n]))continue;let t=pu(e,n);if(t)return{...t,start:n}}return null}function hu(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function gu(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function _u(e,t,n={}){let r=uu.renderToString(e,{displayMode:t,output:`html`,throwOnError:!1,errorColor:`var(--danger)`,strict:!1,trust:!1,macros:n});return`<span class="${t?`math math-display`:`math`}" role="math" aria-label="${yu(e)}">${r}</span>`}var vu=`.math-display{display:block}`;function yu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var bu={},xu=new si({gfm:!0,breaks:!1,async:!1}).use({extensions:[{name:`math`,level:`inline`,start(e){let t=e.search(/\$|\\[([]/);return t<0?void 0:t},tokenizer(e){let t=pu(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return _u(e.text??``,e.display===!0,bu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&_u(e,!0,bu)}}});function Su(e){return bu={},xu.parse(e)}var Cu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,wu=/\bmathjax\b|\bkatex\b/i;function Tu(e){if(Eu(e))return!1;let t=e.body??e.documentElement;if(!t)return!1;let n=e.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();){let e=n.currentNode;/[$\\]/.test(e.data)&&(e.parentElement?.closest(Cu)||r.push(e))}let i={},a=!1;for(let t of r)Du(e,t,i)&&(a=!0);return a}function Eu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(wu.test(t.getAttribute(`src`)??``)||wu.test(t.textContent??``))return!0;return!1}function Du(e,t,n){let r=t.data;if(!mu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=mu(r,0);t;t=mu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=_u(t.tex,t.display,n);a.firstChild;)i.appendChild(a.firstChild);o=t.start+t.length}return o<r.length&&i.appendChild(e.createTextNode(r.slice(o))),t.replaceWith(i),!0}function Ou({session:e,path:t,kind:n,root:r}){let i=ku(e,t,r);return i===null?null:n===`markdown`?(0,D.jsx)(Au,{session:e,path:t,text:i,root:r}):(0,D.jsx)(Nu,{session:e,path:t,text:i,root:r})}function ku(e,t,n){let r=Ue(e,t,null,n,{passive:!0,live:!0}).model;return(0,E.useSyncExternalStore)(r=>ge(T(e,t,n),r),()=>r?.getValue()??null)}kn.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Au({session:e,path:t,text:n,root:r}){let i=(0,E.useMemo)(()=>kn.sanitize(Su(n)),[n]),a=(0,E.useRef)(null);(0,E.useEffect)(()=>{let n=a.current;if(!n)return;let i=!1,o=[];for(let a of n.querySelectorAll(`img`)){let n=ae(t,a.getAttribute(`src`)??``);n&&(a.removeAttribute(`src`),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}${f(r)}`).then(e=>e.blob()).then(e=>{if(i)return;let t=URL.createObjectURL(e);o.push(t),a.src=t}).catch(()=>void 0))}return()=>{i=!0;for(let e of o)URL.revokeObjectURL(e)}},[i,e,t,r]);let{openFile:o}=b(),c=n=>{let i=n.target.closest(`a`);if(!i)return;let a=i.getAttribute(`href`)??``;if(/^https?:/i.test(a)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let s=ae(t,a);s&&o(e,s,void 0,{...ie(s)?{view:`preview`}:{},...r===void 0?{}:{root:r}})},l=se().editorFontSize;return(0,D.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,D.jsx)(`div`,{ref:a,onClick:c,style:{fontSize:l},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:i}})})}var ju=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Mu=20*1024*1024;function Nu({session:e,path:t,text:n,root:r}){let[i,a]=(0,E.useState)(null),o=(0,E.useRef)(new Map),s=se().editorFontSize;return(0,E.useEffect)(()=>{let i=!1;return Pu(e,t,n,o.current,s,r).then(e=>{i||a(e)}),()=>{i=!0}},[e,t,n,s,r]),i===null?null:(0,D.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:i,title:t,className:`size-full bg-paper`})}async function Pu(e,t,n,r,i,a){let o=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=o.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=o.head??o.documentElement;t.insertBefore(e,t.firstChild)}Tu(o)&&await Fu(o);let s=[];for(let[n,i]of ju)for(let c of o.querySelectorAll(n)){let n=ae(t,c.getAttribute(i)??``);n&&(c.removeAttribute(i),s.push(Iu(e,n,r,a).then(e=>{e&&c.setAttribute(i,e)})))}return await Promise.all(s),`<!doctype html>${o.documentElement.outerHTML}`}async function Fu(e){let{default:t}=await ee(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${vu}`,(e.head??e.documentElement).appendChild(n)}function Iu(e,t,n,r){let i=n.get(t);if(i)return i;let a=s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${f(r)}`).then(e=>e.blob()).then(async e=>e.size>Mu?null:`data:${Lu(t,e.type)};base64,${Ru(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,a),a}function Lu(e,t){let n=(e.split(`/`).pop()??``).split(`.`).pop()?.toLowerCase()??``;return n===`css`?`text/css`:n===`js`||n===`mjs`?`text/javascript`:t!==``&&t!==`application/octet-stream`?t:`application/octet-stream`}function Ru(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var zu={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Bu(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:zu[t.slice(n+1).toLowerCase()]??null}function Vu({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Wu(e,t,r);return a?(0,D.jsxs)(Hu,{children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,D.jsx)(Uu,{session:e,path:t})]}):i?n===`image`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,D.jsx)(Hu,{children:(0,D.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,D.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,D.jsx)(Hu,{children:(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Hu({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function Uu({session:e,path:t}){return(0,D.jsx)(`button`,{type:`button`,onClick:()=>void h(e,t).catch(e=>r.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function Wu(e,t,n){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${f(n)}`).then(e=>e.blob()).then(e=>{a||(r=URL.createObjectURL(e),i(r))}).catch(()=>{a||o(!0)}),()=>{a=!0,r&&URL.revokeObjectURL(r)}},[e,t,n]),{url:r,error:a}}function Gu({tab:e,reveal:t}){let n=ne(e);if(n===`diff`)return(0,D.jsx)(it,{session:e.session,path:e.path,root:e.root},oe(e));if(n===`commit`&&e.sha)return(0,D.jsx)(rt,{session:e.session,sha:e.sha,path:e.path,root:e.root},oe(e));if(n===`external`&&e.root!==void 0){let n=Bu(e.path);if(n)return(0,D.jsx)(Vu,{session:e.session,path:e.path,kind:n,root:e.root},oe(e));let r=e.view===`preview`?ie(e.path):null;return r?(0,D.jsx)(Ou,{session:e.session,path:e.path,kind:r,root:e.root},oe(e)):(0,D.jsx)(Ge,{session:e.session,path:e.path,reveal:t,root:e.root},oe(e))}if(n===`untitled`)return(0,D.jsx)(ot,{name:e.path},oe(e));let r=Bu(e.path);if(r)return(0,D.jsx)(Vu,{session:e.session,path:e.path,kind:r},oe(e));let i=e.view===`preview`?ie(e.path):null;return i?(0,D.jsx)(Ou,{session:e.session,path:e.path,kind:i},oe(e)):(0,D.jsx)(Ge,{session:e.session,path:e.path,reveal:t},oe(e))}export{Gu as PaneEditorBody};
|