@puddle-code/cli 0.0.9 → 0.0.10

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +22 -14
  2. package/dist/index.js +26 -3
  3. package/dist/public/assets/{Dashboard-CAM3cXGU.js → Dashboard-Botzm-4a.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-CnJvqROE.js → EditorTabClose-DXG0-8LG.js} +1 -1
  5. package/dist/public/assets/{ModelRefcount-DxceM9Ni.js → ModelRefcount-Cr0OdhVF.js} +1 -1
  6. package/dist/public/assets/PaneEditorBody-BzhoRYgd.js +66 -0
  7. package/dist/public/assets/SettingsDialog-Cd6rZoyo.js +1 -0
  8. package/dist/public/assets/{Terminal-DwGMsU4j.js → Terminal-DogmkohW.js} +2 -2
  9. package/dist/public/assets/Workspace-BDettW-h.js +7 -0
  10. package/dist/public/assets/{api-MnOKfpqf.js → api-BHwI7sYX.js} +1 -1
  11. package/dist/public/assets/{buffer-store-BLJJ5bBb.js → buffer-store-DF2zMOcz.js} +3 -3
  12. package/dist/public/assets/context-menu-CHZoXuDL.js +1 -0
  13. package/dist/public/assets/{cssMode-BRkqXiJB.js → cssMode-DYb85Jum.js} +1 -1
  14. package/dist/public/assets/{editor-tabs-DHrvhXUq.js → editor-tabs-BaSR99_-.js} +1 -1
  15. package/dist/public/assets/{htmlMode-BqZkTR1f.js → htmlMode-DyXrW8ZC.js} +1 -1
  16. package/dist/public/assets/index-BgfBBLZx.js +10 -0
  17. package/dist/public/assets/index-szwjDL7m.css +2 -0
  18. package/dist/public/assets/{jsonMode-CyukyrLW.js → jsonMode-B5kO-8PP.js} +1 -1
  19. package/dist/public/assets/session-seed-Dy0HnELo.js +1 -0
  20. package/dist/public/assets/ssh-mode-CY9J7nfI.js +1 -0
  21. package/dist/public/assets/{tsMode-ClBkYZNn.js → tsMode-BnA0oGE5.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/PaneEditorBody-Xz_NA7oS.js +0 -1
  25. package/dist/public/assets/SettingsDialog-CGLXP6AW.js +0 -1
  26. package/dist/public/assets/Workspace-vM9qSoWV.js +0 -7
  27. package/dist/public/assets/context-menu-DDQiarCp.js +0 -1
  28. package/dist/public/assets/index-B3xVOA2-.css +0 -2
  29. package/dist/public/assets/index-QU4DiDhV.js +0 -10
  30. package/dist/public/assets/session-seed-CRfTF2sq.js +0 -1
  31. package/dist/public/assets/ssh-mode-d5hq-vUb.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,20 +7,28 @@ Past releases: see docs/changelogs/.
7
7
 
8
8
  # Changelog
9
9
 
10
- ## [0.0.9] — 2026-07-21
10
+ ## [0.0.10] — 2026-07-24
11
11
 
12
12
  ### Added
13
13
 
14
- - **Settings Sync**: export a profile's machine-agnostic settings (Appearance, Profile glyph, Sessions, Editor, Hotkeys — never accounts, repos, or paths) as one opaque string and import it on another machine, updating only the fields it carries. A collapsible checklist chooses what to include; the string is gzip+base64 with a CRC-32 integrity check and a random Caesar shuffle (decoded via the known gzip `H` prefix).
15
- - Customisable **keyboard shortcuts** (Settings Hotkeys), stored per profile. Rebind the global/layout actions — command palette, close tab (⌃⌥W), toggle left/right sidebar (⌥⌘, / ⌥⌘.), open a navigator (⌥⌘E/F/V/B), new agent (⌃⌥\`), new terminal (⌃\`), toggle Scratchpad (⌥⌘S), editor save/word-wrap — with a key recorder, reset-to-default, and conflict + browser-reserved warnings. Filetree and terminal line-edit keys stay fixed. (protocol 7.6)
16
- - The session lifecycle menu gains "Spawn agent in worktree" — a submenu of the profile's logged-in accounts (the default account first, so opening it and pressing Enter spawns the default) that starts an agent joining the session's existing worktree, alongside the existing "Open terminal in worktree".
17
- - The homescreen gains two action tiles in the projects grid: "Open project" (the new-project dialogue) and "Open terminal" — a shell at `~` on the daemon host in a heading-less bottom pane that exists only on the homescreen, for cloning repositories before opening them as projects. One shell at a time: while it lives, opening reattaches to it (the tile reads "Close terminal", which ends it). Protocol 7.5: the `home` PTY stream and the `kill-shell` WS message.
18
- - Storm-navy is now a profile icon colour (the theme-aware primary ink — navy in light, near-white in dark).
19
-
20
- ### Changed
21
-
22
- - Protocol bumped to **8.0** (a deliberate major bump with no schema change) so every connected daemon hits a major mismatch on the next handshake and auto-upgrades onto this build, picking up the accumulated 7.x daemon-side changes.
23
- - The profile icon picker is now a small curated set of ~60 lucide glyphs in a simple grid, all statically imported — no lazy-loaded per-icon chunks, no search, no scroll. This replaces the full searchable set, which relied on lazy chunks that could 404 behind a stale shell and never scrolled reliably in the popover.
24
- - The profile icon "Default" now renders a neutral grey glyph rather than the navy heading ink (navy is its own explicit swatch), and the near-duplicate amber and accent swatches were dropped from the picker.
25
- - Scratchpad entries drag from anywhere on the row (the grip handle is gone, reclaiming the left gutter), and editing now happens in a modal opened by clicking the row (or the `+`/pencil) rather than expanding inline.
26
- - Deleting a Scratchpad entry now asks for confirmation inline — a warning line with Delete/Cancel instead of removing it on the first click, since there is no undo.
14
+ - Captured session environment (SPEC §4): `export`s typed in a session terminal
15
+ (or made by `source`d scripts, `nvm use`, venv activation) persist per
16
+ session and are re-injected into new shell tabs, agent restarts/resumes, and
17
+ respawns after a daemon restart. Capture is a prompt hook injected into
18
+ session shells (zsh via a ZDOTDIR shim, bash 4 via `--rcfile`; other
19
+ shells and macOS bash 3.2 degrade to no capture), reporting over an OSC 7733
20
+ side-channel the daemon strips before recording — values never reach
21
+ terminal logs, replay, or viewers, and live only in the daemon's SQLite.
22
+ - `GET /api/sessions/:id/env` (captured var names + byte sizes never values)
23
+ and `DELETE /api/sessions/:id/env` (clear). Protocol **8.0 9.0**.
24
+ - Per-profile `captureSessionEnv` setting (default on) with a toggle under
25
+ Settings Sessions; an `env` strip under each session pane listing captured
26
+ var names; and a confirmed "Clear captured env" session-menu action.
27
+ - Manual acceptance script `docs/acceptance/captured-env.md`.
28
+ - Markdown and HTML preview (SPEC §8): markdown/HTML file tabs carry a
29
+ source ⇄ preview toggle on the tab chip. Markdown renders inline as
30
+ theme-styled, DOMPurify-sanitised prose that tracks unsaved edits live and
31
+ resolves relative images through the authed media endpoint; HTML renders in
32
+ a fully sandboxed iframe (no same-origin access). The chosen view persists
33
+ per tab in the workspace layout (protocol **9.0 → 9.1**, additive `view`
34
+ field on editor tab refs).
package/dist/index.js CHANGED
@@ -4167,7 +4167,7 @@ function openBrowser(url2, platform = process.platform) {
4167
4167
  }
4168
4168
 
4169
4169
  // ../shared/src/protocol.ts
4170
- var PROTOCOL_VERSION = { major: 8, minor: 0 };
4170
+ var PROTOCOL_VERSION = { major: 9, minor: 1 };
4171
4171
 
4172
4172
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
4173
4173
  var external_exports = {};
@@ -18797,6 +18797,12 @@ var sessionDefaultsSchema = external_exports.looseObject({
18797
18797
  });
18798
18798
  var profileSettingsSchema = external_exports.looseObject({
18799
18799
  allowSkipPermissions: external_exports.boolean().default(false),
18800
+ /**
18801
+ * Captured session environment (SPEC §4): whether this profile's session
18802
+ * shells carry the capture hook and whether captured vars are re-injected at
18803
+ * PTY spawn. Off pauses the whole feature; stored maps are kept untouched.
18804
+ */
18805
+ captureSessionEnv: external_exports.boolean().default(true),
18800
18806
  /**
18801
18807
  * Launch-text templates (SPEC §4). A key that is ABSENT falls back to the
18802
18808
  * daemon's built-in default; an EMPTY string is an intentional empty preamble.
@@ -19079,6 +19085,16 @@ var createSessionRequestSchema = external_exports.object({
19079
19085
  });
19080
19086
  var patchSessionRequestSchema = external_exports.object({ title: external_exports.string().max(200) });
19081
19087
  var migrateSessionRequestSchema = external_exports.object({ account_id: rowId });
19088
+ var sessionEnvVarSchema = external_exports.object({
19089
+ name: external_exports.string(),
19090
+ bytes: external_exports.number().int().nonnegative()
19091
+ });
19092
+ var sessionEnvResponseSchema = external_exports.object({
19093
+ vars: external_exports.array(sessionEnvVarSchema)
19094
+ });
19095
+ var clearSessionEnvResponseSchema = external_exports.object({
19096
+ cleared: external_exports.number().int().nonnegative()
19097
+ });
19082
19098
  var archiveRequestSchema = external_exports.object({
19083
19099
  force: external_exports.boolean().default(false),
19084
19100
  /**
@@ -19158,7 +19174,14 @@ var editorTabRefSchema = external_exports.object({
19158
19174
  session: sessionId,
19159
19175
  path: external_exports.string(),
19160
19176
  kind: external_exports.enum(["file", "diff", "commit"]).optional(),
19161
- sha: external_exports.string().optional()
19177
+ sha: external_exports.string().optional(),
19178
+ /**
19179
+ * How a `file` tab renders: Monaco (`source`, the default when absent) or a
19180
+ * rendered `preview` — meaningful only for previewable types (markdown,
19181
+ * HTML; SPEC §8). Not part of the tab's identity: toggling rewrites the tab
19182
+ * ref in place.
19183
+ */
19184
+ view: external_exports.enum(["source", "preview"]).optional()
19162
19185
  });
19163
19186
  var tabRefSchema = external_exports.discriminatedUnion("type", [
19164
19187
  external_exports.object({ type: external_exports.literal("editor"), tab: editorTabRefSchema }),
@@ -19606,7 +19629,7 @@ import { readFileSync } from "node:fs";
19606
19629
  import { dirname, join as join2 } from "node:path";
19607
19630
  import { fileURLToPath } from "node:url";
19608
19631
  function cliVersion() {
19609
- if (true) return "0.0.9";
19632
+ if (true) return "0.0.10";
19610
19633
  const here = dirname(fileURLToPath(import.meta.url));
19611
19634
  for (const candidate of [
19612
19635
  join2(here, "..", "..", "package.json"),
@@ -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{b as r,i}from"./api-MnOKfpqf.js";import{a,g as o,i as s,n as c,o as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./utils-B6KiDbIe.js";import{A as f,O as p,c as m,j as h,k as g,n as _,r as v,t as y}from"./context-menu-DDQiarCp.js";import{i as b,r as x}from"./dist-VDiYuPKw.js";import{Ct as S,Ft as C,K as w,Mt as T,O as E,Ot as D,P as O,Pt as k,T as A,U as j,_t as M,bt as N,gt as P,nn as F,u as I,z as L}from"./index-QU4DiDhV.js";var R=e(t(),1),z=n(),B=!1;function V(){let[e,t]=(0,R.useState)(B),[n,r]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return E.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{B=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&E.killShell(i,n),a()):(B=!0,t(!0))},onExit:a}}function H({term:e,onExit:t}){return(0,z.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,z.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,z.jsx)(I,{stream:`home`,term:e,onExit:t})})})}var U=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function W({projectId:e}){let t=T(e),n=(0,R.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,z.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,z.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),U.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function G({icon:e,label:t,onClick:n}){return(0,z.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,z.jsx)(e,{className:`size-4`})})}function K({project:e,repoPath:t,draggable:n,dragging:i,onDragStart:p,onDragEnd:g,onDragOver:b}){let x=M(),[S,w]=(0,R.useState)(!1),[T,E]=(0,R.useState)(e.name),D=t=>x.mutate({id:e.id,archived:t},{onError:e=>r.error(e.message)}),O=()=>{let t=T.trim();if(!t||t===e.name){w(!1);return}x.mutate({id:e.id,name:t},{onSuccess:()=>w(!1),onError:e=>r.error(e.message)})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(y,{children:[(0,z.jsx)(m,{asChild:!0,children:(0,z.jsxs)(`div`,{draggable:n,onDragStart:p,onDragEnd:g,onDragOver:b,className:d(`group relative transition-opacity`,i&&`opacity-50`),children:[(0,z.jsxs)(F,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,z.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{projectId:e.id})})]}),(0,z.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex`,children:e.archived?(0,z.jsx)(G,{icon:h,label:`Reopen project`,onClick:()=>D(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(G,{icon:j,label:`Rename project`,onClick:()=>{E(e.name),w(!0)}}),(0,z.jsx)(G,{icon:f,label:`Archive project`,onClick:()=>D(!0)})]})})]})}),(0,z.jsx)(_,{children:e.archived?(0,z.jsxs)(v,{onSelect:()=>D(!1),children:[(0,z.jsx)(h,{}),` Reopen`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(v,{onSelect:()=>{E(e.name),w(!0)},children:[(0,z.jsx)(j,{}),` Rename`]}),(0,z.jsxs)(v,{onSelect:()=>D(!0),children:[(0,z.jsx)(f,{}),` Archive`]})]})})]}),(0,z.jsx)(u,{open:S,onOpenChange:w,children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{children:`Rename project`})}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),O()},children:[(0,z.jsx)(C,{value:T,onChange:e=>E(e.target.value),autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(k,{className:`text-fg-muted`,children:`Path`}),(0,z.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>w(!1),children:`Cancel`}),(0,z.jsx)(o,{type:`submit`,disabled:!T.trim()||x.isPending,children:`Rename`})]})]})]})})]})}function q({icon:e,label:t,hint:n,onClick:r}){return(0,z.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,z.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,z.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function J(){let e=O(),t=S(e??void 0),n=D(),r=N(e??void 0),i=P(e??``),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(!1),m=V(),h=e=>n.data?.find(t=>t.id===e)?.path,_=t.data??[],v=r.data?.projectOrder??[],y=p(_.filter(e=>!e.archived),v),C=_.filter(e=>e.archived),T=(e,t)=>{e!==t&&i.mutate({projectOrder:g(y.map(e=>e.id),e,t)})};return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[_.length===0&&(0,z.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,z.jsx)(x,{className:`size-8 text-fg-muted`}),(0,z.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — open one below, or press ⌘K.`})]}),(0,z.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[y.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&T(s,e.id)}},e.id)),(0,z.jsx)(q,{icon:w,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,z.jsx)(q,{icon:L,label:m.open?`Close terminal`:`Open terminal`,hint:m.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:m.toggle})]}),C.length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(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,z.jsx)(b,{className:d(`size-3 transition-transform`,l&&`rotate-90`)}),(0,z.jsx)(f,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Archived`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:C.length})]}),l&&(0,z.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),m.open&&(0,z.jsx)(H,{term:m.term,onExit:m.onExit}),e!==null&&(0,z.jsx)(A,{profileId:e,open:a,onOpenChange:o})]})}export{J as Dashboard};
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,i}from"./api-BHwI7sYX.js";import{a,g as o,i as s,n as c,o as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./utils-B6KiDbIe.js";import{A as f,O as p,c as m,j as h,k as g,n as _,r as v,t as y}from"./context-menu-CHZoXuDL.js";import{i as b,r as x}from"./dist-VDiYuPKw.js";import{It as S,K as C,Lt as w,O as T,P as E,Pt as D,T as O,U as k,_t as A,in as j,kt as M,u as N,vt as P,wt as F,xt as I,z as L}from"./index-BgfBBLZx.js";var R=e(t(),1),z=n(),B=!1;function V(){let[e,t]=(0,R.useState)(B),[n,r]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return T.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{B=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&T.killShell(i,n),a()):(B=!0,t(!0))},onExit:a}}function H({term:e,onExit:t}){return(0,z.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,z.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,z.jsx)(N,{stream:`home`,term:e,onExit:t})})})}var U=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function W({projectId:e}){let t=D(e),n=(0,R.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,z.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,z.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),U.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function G({icon:e,label:t,onClick:n}){return(0,z.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,z.jsx)(e,{className:`size-4`})})}function K({project:e,repoPath:t,draggable:n,dragging:i,onDragStart:p,onDragEnd:g,onDragOver:b}){let x=P(),[C,T]=(0,R.useState)(!1),[E,D]=(0,R.useState)(e.name),O=t=>x.mutate({id:e.id,archived:t},{onError:e=>r.error(e.message)}),A=()=>{let t=E.trim();if(!t||t===e.name){T(!1);return}x.mutate({id:e.id,name:t},{onSuccess:()=>T(!1),onError:e=>r.error(e.message)})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(y,{children:[(0,z.jsx)(m,{asChild:!0,children:(0,z.jsxs)(`div`,{draggable:n,onDragStart:p,onDragEnd:g,onDragOver:b,className:d(`group relative transition-opacity`,i&&`opacity-50`),children:[(0,z.jsxs)(j,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,z.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{projectId:e.id})})]}),(0,z.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex`,children:e.archived?(0,z.jsx)(G,{icon:h,label:`Reopen project`,onClick:()=>O(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(G,{icon:k,label:`Rename project`,onClick:()=>{D(e.name),T(!0)}}),(0,z.jsx)(G,{icon:f,label:`Archive project`,onClick:()=>O(!0)})]})})]})}),(0,z.jsx)(_,{children:e.archived?(0,z.jsxs)(v,{onSelect:()=>O(!1),children:[(0,z.jsx)(h,{}),` Reopen`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(v,{onSelect:()=>{D(e.name),T(!0)},children:[(0,z.jsx)(k,{}),` Rename`]}),(0,z.jsxs)(v,{onSelect:()=>O(!0),children:[(0,z.jsx)(f,{}),` Archive`]})]})})]}),(0,z.jsx)(u,{open:C,onOpenChange:T,children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{children:`Rename project`})}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,z.jsx)(w,{value:E,onChange:e=>D(e.target.value),autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(S,{className:`text-fg-muted`,children:`Path`}),(0,z.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>T(!1),children:`Cancel`}),(0,z.jsx)(o,{type:`submit`,disabled:!E.trim()||x.isPending,children:`Rename`})]})]})]})})]})}function q({icon:e,label:t,hint:n,onClick:r}){return(0,z.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,z.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,z.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function J(){let e=E(),t=F(e??void 0),n=M(),r=I(e??void 0),i=A(e??``),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(!1),m=V(),h=e=>n.data?.find(t=>t.id===e)?.path,_=t.data??[],v=r.data?.projectOrder??[],y=p(_.filter(e=>!e.archived),v),S=_.filter(e=>e.archived),w=(e,t)=>{e!==t&&i.mutate({projectOrder:g(y.map(e=>e.id),e,t)})};return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[_.length===0&&(0,z.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,z.jsx)(x,{className:`size-8 text-fg-muted`}),(0,z.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — open one below, or press ⌘K.`})]}),(0,z.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[y.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&w(s,e.id)}},e.id)),(0,z.jsx)(q,{icon:C,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,z.jsx)(q,{icon:L,label:m.open?`Close terminal`:`Open terminal`,hint:m.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:m.toggle})]}),S.length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(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,z.jsx)(b,{className:d(`size-3 transition-transform`,l&&`rotate-90`)}),(0,z.jsx)(f,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Archived`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:S.length})]}),l&&(0,z.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:S.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),m.open&&(0,z.jsx)(H,{term:m.term,onExit:m.onExit}),e!==null&&(0,z.jsx)(O,{profileId:e,open:a,onOpenChange:o})]})}export{J 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-BLJJ5bBb.js";import{s as h,t as g}from"./editor-sync-F3Wyveaa.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t){let n=m(e,t);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(n,e),[n]),()=>p(n))}function x({session:e,path:t,kind:n,label:d,onClose:f}){let p=b(e,t)&&n!==`commit`,[m,x]=(0,v.useState)(!1),S=()=>p?x(!0):f();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${d}`,children:p?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(_,{className:`size-2 fill-current group-hover:hidden`}),(0,y.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,y.jsx)(a,{className:`size-3 opacity-0 group-hover:opacity-100`})}),(0,y.jsx)(u,{open:m,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,d,`?`]}),(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),g(e,t),x(!1),f()},children:`Discard`})]})]})})]})}export{x as EditorTabClose};
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-DF2zMOcz.js";import{s as h,t as g}from"./editor-sync-F3Wyveaa.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t){let n=m(e,t);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(n,e),[n]),()=>p(n))}function x({session:e,path:t,kind:n,label:d,onClose:f}){let p=b(e,t)&&n!==`commit`,[m,x]=(0,v.useState)(!1),S=()=>p?x(!0):f();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${d}`,children:p?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(_,{className:`size-2 fill-current group-hover:hidden`}),(0,y.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,y.jsx)(a,{className:`size-3 opacity-0 group-hover:opacity-100`})}),(0,y.jsx)(u,{open:m,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,d,`?`]}),(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),g(e,t),x(!1),f()},children:`Discard`})]})]})})]})}export{x as EditorTabClose};
@@ -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-BLJJ5bBb.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))),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
+ 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-DF2zMOcz.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))),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};
@@ -0,0 +1,66 @@
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,a as i,g as a,h as o,i as s,m as c,n as l,p as u,r as d,t as f,u as p}from"./editor-tabs-BaSR99_-.js";import{b as m,r as h,t as g}from"./api-BHwI7sYX.js";import{t as ee}from"./createLucideIcon-DyMAgLa3.js";import{S as te,a as _,o as v,s as y}from"./index-BgfBBLZx.js";import{i as b,r as x}from"./editor.api2-4X9Vh9Zw.js";import{a as ne,c as S,d as re,f as C,i as ie,l as ae,n as oe,o as se,r as ce,s as le,t as ue,u as de}from"./buffer-store-DF2zMOcz.js";import{a as w,c as fe,i as pe,l as me,n as he,o as ge,r as _e,s as ve}from"./editor-sync-F3Wyveaa.js";import{r as ye}from"./buffer-logic-BrpRsL1b.js";var be=ee(`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`}]]),T=e(t(),1);function xe(e){return!e}function E(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=b.CtrlCmd:e===`ctrl`?r|=b.WinCtrl:e===`alt`?r|=b.Alt:e===`shift`&&(r|=b.Shift);let i=x[/^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 Se(e,t){let n=E(te(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=E(te(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>v({editorWordWrap:xe(_().editorWordWrap)})})}function D(e,t,n){let i=ue(e,t),a=r(e,t),s=o(e),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),f=(0,T.useRef)(!1),p=(0,T.useRef)(null),h=(0,T.useRef)(null),ee=(0,T.useRef)(n);ee.current=n;let te=(0,T.useRef)(!1),_=(0,T.useCallback)((e,t)=>{h.current?.cancel(),te.current=!0;try{se(i,e,t)}finally{te.current=!1}},[i]),v=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>ae(i,e),[i]),()=>ce(i)),y=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>ge(i,e),[i]),()=>w(i));(0,T.useEffect)(()=>{let n=a.data;if(!n||n.binary||n.content===null||f.current)return;f.current=!0;let r=S(i)!==void 0,o=oe(e,t,n.content,n.mtime_ms);l(o),!r&&me(e,t).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?ye(o,e.content)&&d(!0):m(`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:()=>{ye(o,e.content)&&d(!0)}}}))})},[a.data,i,e,t]),(0,T.useEffect)(()=>{if(!c)return;let n=fe(e,t);h.current=n;let r=c.onDidChangeContent(()=>{te.current||(n(c.getValue(),S(i)??0),he(e,t))});return()=>{n.flush(),r.dispose(),h.current=null}},[c,i,e,t]),(0,T.useEffect)(()=>{!c||!y.savedElsewhere||ce(i)||a.refetch().then(e=>{ce(i)||(e.data&&e.data.content!==null&&_(e.data.content,e.data.mtime_ms),pe(i))})},[y.savedElsewhere,c,i]),(0,T.useEffect)(()=>{let e=a.data;!c||!e||e.content===null||!ce(i)&&e.mtime_ms!==S(i)&&_(e.content,e.mtime_ms)},[a.data,c,i]);let b=(0,T.useCallback)((n,r)=>{ie(i,n,r),h.current?.cancel(),ve(e,t),_e(e,t,r),d(!1)},[i,e,t]),x=(0,T.useCallback)(()=>{a.refetch().then(n=>{n.data&&n.data.content!==null&&_(n.data.content,n.data.mtime_ms),ve(e,t),d(!1)})},[i,e,t,_]),ne=(0,T.useCallback)((e,n)=>{s.mutate({path:t,content:e},{onSuccess:e=>b(n,e.mtime_ms),onError:e=>m.error(e instanceof Error?e.message:`Overwrite failed`)})},[s,t,b]),re=(0,T.useCallback)(()=>{if(!c||!ce(i))return;let e=c.getValue(),n=c.getAlternativeVersionId();s.mutate({path:t,content:e,expected_mtime_ms:S(i)},{onSuccess:e=>b(n,e.mtime_ms),onError:t=>{t instanceof g&&t.status===409&&t.code===`stale_file`?m.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>x()},cancel:{label:`Overwrite`,onClick:()=>ne(e,n)}}):m.error(t instanceof Error?t.message:`Save failed`)}})},[c,i,s,t,b,x,ne]),C=(0,T.useRef)(re);C.current=re;let le=(0,T.useCallback)(()=>{let n=p.current,r=ee.current;!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]),de=(0,T.useCallback)(e=>{p.current=e,Se(e,{onSave:()=>C.current()}),le()},[le]);(0,T.useEffect)(()=>{le()},[n,c,le]);let be=(0,T.useCallback)(()=>{x()},[x]),xe,E=null;a.data?.binary?xe=`binary`:a.error?a.error instanceof g&&a.error.status===413?xe=`too-large`:(xe=`error`,E=a.error instanceof Error?a.error.message:`Failed to load file`):xe=c?`ready`:`loading`;let D=v&&y.savedElsewhere?`saved-elsewhere`:v&&y.dirtyElsewhere?`dirty-elsewhere`:null;return{status:xe,errorMessage:E,model:c,dirty:v,restoredNotice:u,discardRestore:be,peerBadge:D,save:re,onMount:de}}var O=n();function Ce({message:e,session:t,path:n,download:r}){return(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,O.jsx)(`span`,{children:e}),r&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>void p(t,n).catch(e=>m.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,O.jsx)(be,{className:`size-4`}),`Download`]})]})}function k({session:e,path:t,reveal:n}){let r=y(),i=D(e,t,n),a=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(i.status===`binary`)return(0,O.jsx)(Ce,{message:`Binary file — use Download`,session:e,path:t,download:!0});if(i.status===`too-large`)return(0,O.jsx)(Ce,{message:`File too large to edit — use Download`,session:e,path:t,download:!0});if(i.status===`error`)return(0,O.jsx)(Ce,{message:i.errorMessage??`Failed to load file`,session:e,path:t});let o=i.peerBadge===`saved-elsewhere`?`Saved in another window`:i.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[i.restoredNotice&&(0,O.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,O.jsx)(`span`,{children:`Restored unsaved changes`}),(0,O.jsx)(`button`,{type:`button`,onClick:i.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),o&&(0,O.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:o}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:i.model&&(0,O.jsx)(re,{path:i.model.uri.toString(),defaultValue:i.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>i.onMount(e),loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:a,tabSize:r.editorTabSize,wordWrap:r.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function A({children:e}){return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function we(e,t){let n=(0,T.useRef)(t);n.current=t,(0,T.useEffect)(()=>(le(e),()=>{n.current?.(),ne(e)}),[e])}function Te(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Ee({session:e,refName:t,path:n,content:r}){let i=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,O.jsx)(re,{path:Te(`puddle-view`,e,t,n),defaultValue:r,theme:de,loading:(0,O.jsx)(A,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function j({session:e,against:t,path:n}){let r=c(e,t,n);return r.isPending?(0,O.jsx)(A,{children:`…`}):r.error?(0,O.jsx)(A,{children:r.error instanceof Error?r.error.message:`Failed to load`}):r.data.binary?(0,O.jsx)(A,{children:`Binary file — deleted`}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(Ee,{session:e,refName:t,path:n,content:r.data.content??``})})]})}function M({session:e,against:t,path:n,basePath:r}){let i=y(),a=D(e,n,null),o=c(e,t,r),s=(0,T.useRef)(null);we(ue(e,n),()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),s.current=null});let l=(0,T.useRef)(a.save);l.current=a.save;let u=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=o.error instanceof g&&o.error.status===404;return a.status===`binary`||o.data?.binary?(0,O.jsx)(A,{children:`Binary file`}):a.status===`too-large`?(0,O.jsx)(A,{children:`File too large to show`}):a.status===`error`?(0,O.jsx)(A,{children:a.errorMessage??`Failed to load file`}):d?(0,O.jsx)(k,{session:e,path:n,reveal:null}):o.isPending||!a.model?(0,O.jsx)(A,{children:`…`}):o.error?(0,O.jsx)(A,{children:o.error instanceof Error?o.error.message:`Failed to load base`}):(0,O.jsx)(C,{modifiedModelPath:a.model.uri.toString(),originalModelPath:Te(`puddle-base`,e,t,r),original:o.data.content??``,language:a.model.getLanguageId(),theme:de,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(A,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null}),e.getModifiedEditor().addCommand(b.CtrlCmd|x.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function De({session:e,path:t}){return we(ue(e,t)),(0,O.jsx)(k,{session:e,path:t,reveal:null})}function Oe({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,O.jsx)(De,{session:e,path:n.path});case`deleted`:return(0,O.jsx)(j,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,O.jsx)(M,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function ke({session:e,sha:t,path:n}){let r=c(e,t,n);return r.isPending?(0,O.jsx)(A,{children:`…`}):r.error?(0,O.jsx)(A,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,O.jsx)(A,{children:`Binary file`}):(0,O.jsx)(Ee,{session:e,refName:t,path:n,content:r.data.content??``})}function Ae({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,T.useRef)(null),c=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,T.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,O.jsx)(C,{originalModelPath:Te(`puddle-hist-orig`,e,t,n),modifiedModelPath:Te(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:de,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(A,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function je({session:e,sha:t,path:n,basePath:r}){let i=c(e,`${t}^`,r),a=c(e,t,n);return i.error instanceof g&&i.error.status===404?(0,O.jsx)(ke,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,O.jsx)(A,{children:`…`}):i.error?(0,O.jsx)(A,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,O.jsx)(A,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,O.jsx)(A,{children:`Binary file`}):(0,O.jsx)(Ae,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function Me({session:e,sha:t,entry:n,isRootCommit:r}){switch(i(n.status,r)){case`added`:return(0,O.jsx)(ke,{session:e,sha:t,path:n.path});case`deleted`:return(0,O.jsx)(j,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,O.jsx)(je,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Ne({session:e,sha:t,path:n}){let r=u(e,t);if(r.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let i=r.data.files.find(e=>e.path===n);return i?(0,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(Me,{session:e,sha:t,entry:i,isRootCommit:r.data.parents.length===0})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Pe({session:e,path:t}){let n=a(e);if(n.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(Oe,{session:e,against:n.data.against,entry:r})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,O.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}function Fe(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 Ie(e){if(Array.isArray(e))return e}function Le(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 Re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ze(e,t){return Ie(e)||Le(e,t)||Be(e,t)||Re()}function Be(e,t){if(e){if(typeof e==`string`)return Fe(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)?Fe(e,t):void 0}}var Ve=Object.entries,N=Object.setPrototypeOf,He=Object.isFrozen,Ue=Object.getPrototypeOf,We=Object.getOwnPropertyDescriptor,P=Object.freeze,F=Object.seal,Ge=Object.create,Ke=typeof Reflect<`u`&&Reflect,qe=Ke.apply,Je=Ke.construct;P||=function(e){return e},F||=function(e){return e},qe||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Je||=function(e){return new e(...[...arguments].slice(1))};var Ye=z(Array.prototype.forEach),Xe=z(Array.prototype.lastIndexOf),Ze=z(Array.prototype.pop),Qe=z(Array.prototype.push),$e=z(Array.prototype.splice),et=Array.isArray,tt=z(String.prototype.toLowerCase),nt=z(String.prototype.toString),rt=z(String.prototype.match),it=z(String.prototype.replace),at=z(String.prototype.indexOf),ot=z(String.prototype.trim),st=z(Number.prototype.toString),I=z(Boolean.prototype.toString),ct=typeof BigInt>`u`?null:z(BigInt.prototype.toString),lt=typeof Symbol>`u`?null:z(Symbol.prototype.toString),L=z(Object.prototype.hasOwnProperty),ut=z(Object.prototype.toString),R=z(RegExp.prototype.test),dt=ft(TypeError);function z(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return qe(e,t,n)}}function ft(e){return function(){return Je(e,[...arguments])}}function B(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:tt;if(N&&N(e,null),!et(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(He(t)||(t[r]=e),i=e)}e[i]=!0}return e}function pt(e){for(let t=0;t<e.length;t++)L(e,t)||(e[t]=null);return e}function V(e){let t=Ge(null);for(let r of Ve(e)){var n=ze(r,2);let i=n[0],a=n[1];L(e,i)&&(et(a)?t[i]=pt(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=V(a):t[i]=a)}return t}function mt(e){switch(typeof e){case`string`:return e;case`number`:return st(e);case`boolean`:return I(e);case`bigint`:return ct?ct(e):`0`;case`symbol`:return lt?lt(e):`Symbol()`;case`undefined`:return ut(e);case`function`:case`object`:{if(e===null)return ut(e);let t=e,n=H(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:ut(e)}return ut(e)}default:return ut(e)}}function H(e,t){for(;e!==null;){let n=We(e,t);if(n){if(n.get)return z(n.get);if(typeof n.value==`function`)return z(n.value)}e=Ue(e)}function n(){return null}return n}function ht(e){try{return R(e,``),!0}catch{return!1}}var gt=P(`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(`.`)),_t=P(`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(`.`)),vt=P([`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`]),yt=P([`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`]),bt=P(`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(`.`)),xt=P([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),St=P([`#text`]),Ct=P(`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(`.`)),wt=P(`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(`.`)),Tt=P(`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(`.`)),Et=P([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Dt=F(/{{[\w\W]*|^[\w\W]*}}/g),Ot=F(/<%[\w\W]*|^[\w\W]*%>/g),kt=F(/\${[\w\W]*/g),At=F(/^data-[\-\w.\u00B7-\uFFFF]+$/),jt=F(/^aria-[\-\w]+$/),Mt=F(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nt=F(/^(?:\w+script|data):/i),Pt=F(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ft=F(/^html$/i),It=F(/^[a-z][.\w]*(-[.\w]+)+$/i),Lt=F(/<[/\w!]/g),Rt=F(/<[/\w]/g),zt=F(/<\/no(script|embed|frames)/i),Bt=F(/\/>/i),U={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Vt=function(){return typeof window>`u`?null:window},Ht=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}},Ut=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Wt=function(e,t,n,r){return L(e,t)&&et(e[t])?B(r.base?V(r.base):{},e[t],r.transform):n};function Gt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Vt(),t=e=>Gt(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==U.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=H(d,`cloneNode`),p=H(d,`remove`),m=H(d,`nextSibling`),h=H(d,`childNodes`),g=H(d,`parentNode`),ee=H(d,`shadowRoot`),te=H(d,`attributes`),_=o&&o.prototype?H(o.prototype,`nodeType`):null,v=o&&o.prototype?H(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,b=``,x,ne=!1,S=0,re=function(){if(S>0)throw dt(`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.`)},C=function(e){re(),S++;try{return y.createHTML(e)}finally{S--}},ie=function(e){re(),S++;try{return y.createScriptURL(e)}finally{S--}},ae=function(){return ne||=(x=Ht(u,i),!0),x},oe=n,se=oe.implementation,ce=oe.createNodeIterator,le=oe.createDocumentFragment,ue=oe.getElementsByTagName,de=r.importNode,w=Ut();t.isSupported=typeof Ve==`function`&&typeof g==`function`&&se&&se.createHTMLDocument!==void 0;let fe=Dt,pe=Ot,me=kt,he=At,ge=jt,_e=Nt,ve=Pt,ye=It,be=Mt,T=null,xe=B({},[...gt,..._t,...vt,...bt,...St]),E=null,Se=B({},[...Ct,...wt,...Tt,...Et]),D=Object.seal(Ge(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}})),O=null,Ce=null,k=Object.seal(Ge(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),A=!0,we=!0,Te=!1,Ee=!0,j=!1,M=!0,De=!1,Oe=!1,ke=null,Ae=null,je=!1,Me=!1,Ne=!1,Pe=!1,Fe=!0,Ie=!1,Le=`user-content-`,Re=!0,ze=!1,Be={},N=null,He=B({},`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(`.`)),Ue=null,We=B({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,qe=B({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Je=`http://www.w3.org/1998/Math/MathML`,st=`http://www.w3.org/2000/svg`,I=`http://www.w3.org/1999/xhtml`,ct=I,lt=!1,ut=null,z=B({},[Je,st,I],nt),ft=P([`mi`,`mo`,`mn`,`ms`,`mtext`]),pt=B({},ft),Kt=P([`annotation-xml`]),qt=B({},Kt),Jt=B({},[`title`,`style`,`font`,`a`,`script`]),Yt=null,Xt=[`application/xhtml+xml`,`text/html`],W=null,G=null,Zt=n.createElement(`form`),K=function(e){return e instanceof RegExp||e instanceof Function},Qt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(G&&G===e)return;(!e||typeof e!=`object`)&&(e={}),e=V(e),Yt=Xt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,W=Yt===`application/xhtml+xml`?nt:tt,T=Wt(e,`ALLOWED_TAGS`,xe,{transform:W}),E=Wt(e,`ALLOWED_ATTR`,Se,{transform:W}),ut=Wt(e,`ALLOWED_NAMESPACES`,z,{transform:nt}),Ke=Wt(e,`ADD_URI_SAFE_ATTR`,qe,{transform:W,base:qe}),Ue=Wt(e,`ADD_DATA_URI_TAGS`,We,{transform:W,base:We}),N=Wt(e,`FORBID_CONTENTS`,He,{transform:W}),O=Wt(e,`FORBID_TAGS`,V({}),{transform:W}),Ce=Wt(e,`FORBID_ATTR`,V({}),{transform:W}),Be=L(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?V(e.USE_PROFILES):e.USE_PROFILES:!1,A=e.ALLOW_ARIA_ATTR!==!1,we=e.ALLOW_DATA_ATTR!==!1,Te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ee=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,j=e.SAFE_FOR_TEMPLATES||!1,M=e.SAFE_FOR_XML!==!1,De=e.WHOLE_DOCUMENT||!1,Me=e.RETURN_DOM||!1,Ne=e.RETURN_DOM_FRAGMENT||!1,Pe=e.RETURN_TRUSTED_TYPE||!1,je=e.FORCE_BODY||!1,Fe=e.SANITIZE_DOM!==!1,Ie=e.SANITIZE_NAMED_PROPS||!1,Re=e.KEEP_CONTENT!==!1,ze=e.IN_PLACE||!1,be=ht(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Mt,ct=typeof e.NAMESPACE==`string`?e.NAMESPACE:I,pt=L(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?V(e.MATHML_TEXT_INTEGRATION_POINTS):B({},ft),qt=L(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?V(e.HTML_INTEGRATION_POINTS):B({},Kt);let t=L(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?V(e.CUSTOM_ELEMENT_HANDLING):Ge(null);if(D=Ge(null),L(t,`tagNameCheck`)&&K(t.tagNameCheck)&&(D.tagNameCheck=t.tagNameCheck),L(t,`attributeNameCheck`)&&K(t.attributeNameCheck)&&(D.attributeNameCheck=t.attributeNameCheck),L(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(D.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),F(D),j&&(we=!1),Ne&&(Me=!0),Be&&(T=B({},St),E=Ge(null),Be.html===!0&&(B(T,gt),B(E,Ct)),Be.svg===!0&&(B(T,_t),B(E,wt),B(E,Et)),Be.svgFilters===!0&&(B(T,vt),B(E,wt),B(E,Et)),Be.mathMl===!0&&(B(T,bt),B(E,Tt),B(E,Et))),k.tagCheck=null,k.attributeCheck=null,L(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?k.tagCheck=e.ADD_TAGS:et(e.ADD_TAGS)&&(T===xe&&(T=V(T)),B(T,e.ADD_TAGS,W))),L(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?k.attributeCheck=e.ADD_ATTR:et(e.ADD_ATTR)&&(E===Se&&(E=V(E)),B(E,e.ADD_ATTR,W))),L(e,`ADD_URI_SAFE_ATTR`)&&et(e.ADD_URI_SAFE_ATTR)&&B(Ke,e.ADD_URI_SAFE_ATTR,W),L(e,`FORBID_CONTENTS`)&&et(e.FORBID_CONTENTS)&&(N===He&&(N=V(N)),B(N,e.FORBID_CONTENTS,W)),L(e,`ADD_FORBID_CONTENTS`)&&et(e.ADD_FORBID_CONTENTS)&&(N===He&&(N=V(N)),B(N,e.ADD_FORBID_CONTENTS,W)),Re&&(T[`#text`]=!0),De&&B(T,[`html`,`head`,`body`]),T.table&&(B(T,[`tbody`]),delete O.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw dt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw dt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=y;y=e.TRUSTED_TYPES_POLICY;try{b=C(``)}catch(e){throw y=t,e}}else e.TRUSTED_TYPES_POLICY===null?(y=void 0,b=``):(y===void 0&&(y=ae()),y&&typeof b==`string`&&(b=C(``)));P&&P(e),G=e},$t=B({},[..._t,...vt,...yt]),en=B({},[...bt,...xt]),tn=function(e,t,n){return t.namespaceURI===I?e===`svg`:t.namespaceURI===Je?e===`svg`&&(n===`annotation-xml`||pt[n]):!!$t[e]},nn=function(e,t,n){return t.namespaceURI===I?e===`math`:t.namespaceURI===st?e===`math`&&qt[n]:!!en[e]},rn=function(e,t,n){return t.namespaceURI===st&&!qt[n]||t.namespaceURI===Je&&!pt[n]?!1:!en[e]&&(Jt[e]||!$t[e])},an=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:ct,tagName:`template`});let n=tt(e.tagName),r=tt(t.tagName);return ut[e.namespaceURI]?e.namespaceURI===st?tn(n,t,r):e.namespaceURI===Je?nn(n,t,r):e.namespaceURI===I?rn(n,t,r):!!(Yt===`application/xhtml+xml`&&ut[e.namespaceURI]):!1},q=function(e){Qe(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw dt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},on=function(e){cn(e);let t=h(e);if(t){let e=[];Ye(t,t=>{Qe(e,t)}),Ye(e,e=>{try{p(e)}catch{}})}let n=te(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{}}},J=function(e,n){try{Qe(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Qe(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Me||Ne)try{q(n)}catch{}else try{n.setAttribute(e,``)}catch{}},sn=function(e){let t=te(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||E[W(i)]))try{e.removeAttribute(i)}catch{}}},cn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(_?_(e):e.nodeType)===U.element&&sn(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ln=function(e){if(!M)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=_?_(e):e.nodeType;if(n===U.processingInstruction||n===U.comment&&R(Rt,e.data)){try{p(e)}catch{}continue}if(n===U.element){let t=e,n=W(v?v(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])}},un=function(e){let t=null,r=null;if(je)e=`<remove></remove>`+e;else{let t=rt(e,/^[\r\n\t ]+/);r=t&&t[0]}Yt===`application/xhtml+xml`&&ct===I&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=y?C(e):e;if(ct===I)try{t=new l().parseFromString(i,Yt)}catch{}if(!t||!t.documentElement){t=se.createDocument(ct,`template`,null);try{t.documentElement.innerHTML=lt?b:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),ct===I?ue.call(t,De?`html`:`body`)[0]:De?t.documentElement:a},dn=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)},fn=function(e){return e=it(e,fe,` `),e=it(e,pe,` `),e=it(e,me,` `),e},pn=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=fn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&Ye(r,e=>{hn(e.content)&&pn(e.content)})},mn=function(e){let t=v?v(e):null;return typeof t!=`string`||W(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==te(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==_(e)||e.childNodes!==h(e)},hn=function(e){if(!_||typeof e!=`object`||!e)return!1;try{return _(e)===U.documentFragment}catch{return!1}},gn=function(e){if(!_||typeof e!=`object`||!e)return!1;try{return typeof _(e)==`number`}catch{return!1}};function Y(e,n,r){e.length!==0&&Ye(e,e=>{e.call(t,n,r,G)})}let _n=function(e,t){return!!(M&&e.hasChildNodes()&&!gn(e.firstElementChild)&&R(Lt,e.textContent)&&R(Lt,e.innerHTML)||M&&e.namespaceURI===I&&t===`style`&&gn(e.firstElementChild)||e.nodeType===U.processingInstruction||M&&e.nodeType===U.comment&&R(Rt,e.data))},vn=function(e,t){if(!O[t]&&Sn(t)&&(D.tagNameCheck instanceof RegExp&&R(D.tagNameCheck,t)||D.tagNameCheck instanceof Function&&D.tagNameCheck(t)))return!1;if(Re&&!N[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=ze?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return q(e),!0},yn=function(e,n){if(Y(w.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(mn(e))return q(e),!0;let r=W(v?v(e):e.nodeName);if(Y(w.uponSanitizeElement,e,{tagName:r,allowedTags:T}),e!==n&&g(e)===null)return!0;if(_n(e,r))return q(e),!0;if(O[r]||!(k.tagCheck instanceof Function&&k.tagCheck(r))&&!T[r]){let t=vn(e,r);return t===!1&&Y(w.afterSanitizeElements,e,null),t}if((_?_(e):e.nodeType)===U.element&&!an(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&R(zt,e.innerHTML))return q(e),!0;if(j&&e.nodeType===U.text){let n=fn(e.textContent);e.textContent!==n&&(Qe(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Y(w.afterSanitizeElements,e,null),!1},bn=function(e,t,r){if(Ce[t]||M&&t===`patchsrc`||M&&t===`for`&&e!==`label`&&e!==`output`||Fe&&(t===`id`||t===`name`)&&(r in n||r in Zt))return!1;let i=E[t]||k.attributeCheck instanceof Function&&k.attributeCheck(t,e);if(!(we&&R(he,t))&&!(A&&R(ge,t))){if(!i){if(!(Sn(e)&&(D.tagNameCheck instanceof RegExp&&R(D.tagNameCheck,e)||D.tagNameCheck instanceof Function&&D.tagNameCheck(e))&&(D.attributeNameCheck instanceof RegExp&&R(D.attributeNameCheck,t)||D.attributeNameCheck instanceof Function&&D.attributeNameCheck(t,e))||t===`is`&&D.allowCustomizedBuiltInElements&&(D.tagNameCheck instanceof RegExp&&R(D.tagNameCheck,r)||D.tagNameCheck instanceof Function&&D.tagNameCheck(r))))return!1}else if(!Ke[t]&&!R(be,it(r,ve,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&at(r,`data:`)===0&&Ue[e])&&!(Te&&!R(_e,it(r,ve,``)))&&r)return!1}return!0},xn=B({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Sn=function(e){return!xn[tt(e)]&&R(ye,e)},Cn=function(e,t,n,r){if(y&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return C(r);case`TrustedScriptURL`:return ie(r)}return r},wn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),mn(e)?q(e):Ze(t.removed)}catch{J(n,e)}},Tn=function(e){Y(w.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||mn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:E,forceKeepAttr:void 0},r=t.length,i=W(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=W(o),u=c,d=o===`value`?u:ot(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Y(w.uponSanitizeAttribute,e,n),d=n.attrValue,Ie&&(l===`id`||l===`name`)&&at(d,Le)!==0&&(J(o,e),d=Le+d),M&&R(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){J(o,e);continue}if(l===`attributename`&&rt(d,`href`)){J(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){J(o,e);continue}if(!Ee&&R(Bt,d)){J(o,e);continue}if(j&&(d=fn(d)),!bn(i,l,d)){J(o,e);continue}d=Cn(i,l,s,d),d!==u&&wn(e,o,s,d)}}Y(w.afterSanitizeAttributes,e,null)},En=function(e){let t=null,n=dn(e);for(Y(w.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Y(w.uponSanitizeShadowNode,t,null),yn(t,e),Tn(t),hn(t.content)&&En(t.content),(_?_(t):t.nodeType)===U.element){let e=ee(t);hn(e)&&(Dn(e),En(e))}Y(w.afterSanitizeShadowDOM,e,null)},Dn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){En(e.shadow);continue}let n=e.node,r=(_?_(n):n.nodeType)===U.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=v?v(n):null;if(typeof e==`string`&&W(e)===`template`){let e=n.content;hn(e)&&t.push({node:e,shadow:null})}}if(r){let e=ee(n);hn(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(lt=!e,lt&&(e=`<!-->`),typeof e!=`string`&&!gn(e)&&(e=mt(e),typeof e!=`string`))throw dt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Oe?(T=ke,E=Ae):Qt(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(T=V(T)),w.uponSanitizeAttribute.length>0&&(E=V(E)),t.removed=[];let c=ze&&typeof e!=`string`&&gn(e);if(c){ln(e);let t=v?v(e):e.nodeName;if(typeof t==`string`){let n=W(t);if(!T[n]||O[n])throw on(e),dt(`root node is forbidden and cannot be sanitized in-place`)}if(mn(e))throw on(e),dt(`root node is clobbered and cannot be sanitized in-place`);try{Dn(e)}catch(t){throw on(e),t}}else if(gn(e))i=un(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===U.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Dn(a);else{if(!Me&&!j&&!De&&e.indexOf(`<`)===-1)return y&&Pe?C(e):e;if(i=un(e),!i)return Me?null:Pe?b:``}i&&je&&q(i.firstChild);let l=c?e:i,u=dn(l);try{for(;o=u.nextNode();)yn(o,l),Tn(o),hn(o.content)&&En(o.content)}catch(n){throw c&&(on(e),Ye(t.removed,e=>{e.element&&cn(e.element)})),n}if(c)return Ye(t.removed,e=>{e.element&&cn(e.element)}),j&&pn(e),e;if(Me){if(j&&pn(i),Ne)for(s=le.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(E.shadowroot||E.shadowrootmode)&&(s=de.call(r,s,!0)),s}let d=De?i.outerHTML:i.innerHTML;return De&&T[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&R(Ft,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
+ `+d),j&&(d=fn(d)),y&&Pe?C(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Qt(e),Oe=!0,ke=T,Ae=E},t.clearConfig=function(){G=null,Oe=!1,ke=null,Ae=null,y=x,b=``},t.isValidAttribute=function(e,t,n){G||Qt({});let r=W(e),i=W(t);return bn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&L(w,e)&&Qe(w[e],t)},t.removeHook=function(e,t){if(L(w,e)){if(t!==void 0){let n=Xe(w[e],t);return n===-1?void 0:$e(w[e],n,1)[0]}return Ze(w[e])}},t.removeHooks=function(e){L(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=Ut()},t}var Kt=Gt();function qt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Jt=qt();function Yt(e){Jt=e}var Xt={exec:()=>null};function W(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 G(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(K.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Zt=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),K={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:W(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:W(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:W(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:W(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:W(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:W(e=>RegExp(`^ {0,${e}}>`))},Qt=/^(?:[ \t]*(?:\n|$))+/,$t=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,en=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,an=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,q=G(an).replace(/bull/g,rn).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(),on=G(an).replace(/bull/g,rn).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(),J=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,sn=/^[^\n]+/,cn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ln=G(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,cn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),un=G(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,rn).getRegex(),dn=`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`,fn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,pn=G(`^ {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`,fn).replace(`tag`,dn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mn=e=>G(J).replace(`hr`,tn).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`,dn).getRegex(),hn=mn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),gn=mn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Y={blockquote:G(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,gn).getRegex(),code:$t,def:ln,fences:en,heading:nn,hr:tn,html:pn,lheading:q,list:un,newline:Qt,paragraph:hn,table:Xt,text:sn},_n=G(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,tn).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`,dn).getRegex(),vn={...Y,lheading:on,table:_n,paragraph:G(J).replace(`hr`,tn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,_n).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`,dn).getRegex()},yn={...Y,html:G(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,fn).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:Xt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:G(J).replace(`hr`,tn).replace(`heading`,` *#{1,6} *[^
4
+ ]`).replace(`lheading`,q).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},bn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Sn=/^( {2,}|\\)\n(?!\s*$)/,Cn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wn=/[\p{P}\p{S}]/u,Tn=/[\s\p{P}\p{S}]/u,En=/[^\s\p{P}\p{S}]/u,Dn=G(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Tn).getRegex(),On=/(?!~)[\p{P}\p{S}]/u,kn=/(?!~)[\s\p{P}\p{S}]/u,An=/(?:[^\s\p{P}\p{S}]|~)/u,jn=G(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Zt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Mn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Nn=G(Mn,`u`).replace(/punct/g,wn).getRegex(),Pn=G(Mn,`u`).replace(/punct/g,On).getRegex(),Fn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,In=G(Fn,`gu`).replace(/notPunctSpace/g,En).replace(/punctSpace/g,Tn).replace(/punct/g,wn).getRegex(),Ln=G(Fn,`gu`).replace(/notPunctSpace/g,An).replace(/punctSpace/g,kn).replace(/punct/g,On).getRegex(),Rn=G(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,En).replace(/punctSpace/g,Tn).replace(/punct/g,wn).getRegex(),zn=G(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,wn).getRegex(),Bn=G(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,En).replace(/punctSpace/g,Tn).replace(/punct/g,wn).getRegex(),Vn=G(/\\(punct)/,`gu`).replace(/punct/g,wn).getRegex(),Hn=G(/^<(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(),Un=G(fn).replace(`(?:-->|$)`,`-->`).getRegex(),Wn=G(`^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`,Un).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Kn=G(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Gn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qn=G(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Gn).replace(`ref`,cn).getRegex(),Jn=G(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,cn).getRegex(),Yn=G(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,qn).replace(`nolink`,Jn).getRegex(),Xn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Zn={_backpedal:Xt,anyPunctuation:Vn,autolink:Hn,blockSkip:jn,br:Sn,code:xn,del:Xt,delLDelim:Xt,delRDelim:Xt,emStrongLDelim:Nn,emStrongRDelimAst:In,emStrongRDelimUnd:Rn,escape:bn,link:Kn,nolink:Jn,punctuation:Dn,reflink:qn,reflinkSearch:Yn,tag:Wn,text:Cn,url:Xt},Qn={...Zn,link:G(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Gn).getRegex(),reflink:G(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Gn).getRegex()},$n={...Zn,emStrongRDelimAst:Ln,emStrongLDelim:Pn,delLDelim:zn,delRDelim:Bn,url:G(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Xn).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:G(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Xn).getRegex()},er={...$n,br:G(Sn).replace(`{2,}`,`*`).getRegex(),text:G($n.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},tr={normal:Y,gfm:vn,pedantic:yn},nr={normal:Zn,gfm:$n,breaks:er,pedantic:Qn},rr={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},ir=e=>rr[e];function X(e,t){if(t){if(K.escapeTest.test(e))return e.replace(K.escapeReplace,ir)}else if(K.escapeTestNoEncode.test(e))return e.replace(K.escapeReplaceNoEncode,ir);return e}function ar(e){try{e=encodeURI(e).replace(K.percentDecode,`%`)}catch{return null}return e}function or(e,t){let n=e.replace(K.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(K.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(K.slashPipe,`|`);return n}function sr(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 cr(e){let t=e.split(`
5
+ `),n=t.length-1;for(;n>=0&&K.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
6
+ `)}function lr(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function ur(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function dr(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function fr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
7
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
8
+ `)}var pr=class{options;rules;lexer;constructor(e){this.options=e||Jt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:cr(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=fr(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=sr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:sr(t[0],`
9
+ `),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:sr(t[0],`
10
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=sr(t[0],`
11
+ `).split(`
12
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
13
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
14
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
15
+ ${s}`:s,r=r?`${r}
16
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
17
+ `+e.join(`
18
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
19
+ `+e.join(`
20
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
21
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=ur(t[2].split(`
22
+ `,1)[0],t[1].length),l=e.split(`
23
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
24
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
25
+ `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
26
+ `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
27
+ `+l}u=!l.trim(),r+=p+`
28
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=cr(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:sr(t[0],`
29
+ `),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=or(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
30
+ `):[],a={type:`table`,raw:sr(t[0],`
31
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(or(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:sr(t[0],`
32
+ `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
33
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=sr(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=lr(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),dr(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return dr(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Z=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Jt,this.options.tokenizer=this.options.tokenizer||new pr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:K,block:tr.normal,inline:nr.normal};this.options.pedantic?(t.block=tr.pedantic,t.inline=nr.pedantic):this.options.gfm&&(t.block=tr.gfm,this.options.breaks?t.inline=nr.breaks:t.inline=nr.gfm),this.tokenizer.rules=t}static get rules(){return{block:tr,inline:nr}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(K.carriageReturn,`
34
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(K.tabCharGlobal,` `).replace(K.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
35
+ `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
36
+ `)?``:`
37
+ `)+i.raw,n.text+=`
38
+ `+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
39
+ `)?``:`
40
+ `)+i.raw,n.text+=`
41
+ `+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
42
+ `)?``:`
43
+ `)+i.raw,r.text+=`
44
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
45
+ `)?``:`
46
+ `)+i.raw,n.text+=`
47
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf(`[`)+1,-1))?`[`+`a`.repeat(t.length-2)+`]`:t))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,`++`),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},mr=class{options;parser;constructor(e){this.options=e||Jt}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(K.notSpaceStart)?.[0],i=e.replace(K.endingNewline,``)+`
48
+ `;return r?`<pre><code class="language-`+X(r)+`">`+(n?i:X(i,!0))+`</code></pre>
49
+ `:`<pre><code>`+(n?i:X(i,!0))+`</code></pre>
50
+ `}blockquote({tokens:e}){return`<blockquote>
51
+ ${this.parser.parse(e)}</blockquote>
52
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
53
+ `}hr(e){return`<hr>
54
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
55
+ `+r+`</`+i+`>
56
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
57
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
58
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
59
+ <thead>
60
+ `+t+`</thead>
61
+ `+r+`</table>
62
+ `}tablerow({text:e}){return`<tr>
63
+ ${e}</tr>
64
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
65
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${X(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ar(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+X(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ar(e);if(i===null)return X(n);e=i;let a=`<img src="${e}" alt="${X(n)}"`;return t&&(a+=` title="${X(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:X(e.text)}},hr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Q=class e{options;renderer;textRenderer;constructor(e){this.options=e||Jt,this.options.renderer=this.options.renderer||new mr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hr}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},gr=class{options;block;constructor(e){this.options=e||Jt}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Z.lex:Z.lexInline}provideParser(e=this.block){return e?Q.parse:Q.parseInline}},_r=new class{defaults=qt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Q;Renderer=mr;TextRenderer=hr;Lexer=Z;Tokenizer=pr;Hooks=gr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new mr(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new pr(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new gr;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];gr.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&gr.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Z.lex(e,t??this.defaults)}parser(e,t){return Q.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Z.lex:Z.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Q.parse:Q.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Z.lex:Z.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Q.parse:Q.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
66
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+X(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return _r.parse(e,t)}$.options=$.setOptions=function(e){return _r.setOptions(e),$.defaults=_r.defaults,Yt($.defaults),$},$.getDefaults=qt,$.defaults=Jt,$.use=function(...e){return _r.use(...e),$.defaults=_r.defaults,Yt($.defaults),$},$.walkTokens=function(e,t){return _r.walkTokens(e,t)},$.parseInline=_r.parseInline,$.Parser=Q,$.parser=Q.parse,$.Renderer=mr,$.TextRenderer=hr,$.Lexer=Z,$.lexer=Z.lex,$.Tokenizer=pr,$.Hooks=gr,$.parse=$,$.options,$.setOptions,$.use,$.walkTokens,$.parseInline,Q.parse,Z.lex;var vr=$.setOptions({gfm:!0,breaks:!1,async:!1});function yr(e){return vr.parse(e)}function br({session:e,path:t,kind:n}){let r=xr(e,t);return r===null?null:n===`markdown`?(0,O.jsx)(Sr,{session:e,path:t,text:r}):(0,O.jsx)(Cr,{path:t,text:r})}function xr(e,t){let n=r(e,t),i=n.data&&!n.data.binary?n.data.content:null,a=i!==null&&n.data?oe(e,t,i,n.data.mtime_ms):null;return(0,T.useSyncExternalStore)(n=>ae(ue(e,t),n),()=>a?.getValue()??null)}Kt.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Sr({session:e,path:t,text:n}){let r=(0,T.useMemo)(()=>Kt.sanitize(yr(n)),[n]),i=(0,T.useRef)(null);return(0,T.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a=[];for(let i of n.querySelectorAll(`img`)){let n=s(t,i.getAttribute(`src`)??``);n&&(i.removeAttribute(`src`),h(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}`).then(e=>e.blob()).then(e=>{if(r)return;let t=URL.createObjectURL(e);a.push(t),i.src=t}).catch(()=>void 0))}return()=>{r=!0;for(let e of a)URL.revokeObjectURL(e)}},[r,e,t]),(0,O.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,O.jsx)(`div`,{ref:i,onClick:e=>{let t=e.target.closest(`a`);t&&!/^https?:/i.test(t.getAttribute(`href`)??``)&&e.preventDefault()},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-sm text-fg-secondary`,dangerouslySetInnerHTML:{__html:r}})})}function Cr({path:e,text:t}){return(0,O.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:t,title:e,className:`size-full bg-paper`})}var wr={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 Tr(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:wr[t.slice(n+1).toLowerCase()]??null}function Er({session:e,path:t,kind:n}){let{url:r,error:i}=kr(e,t);return i?(0,O.jsxs)(Dr,{children:[(0,O.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,O.jsx)(Or,{session:e,path:t})]}):r?n===`image`?(0,O.jsx)(Dr,{children:(0,O.jsx)(`img`,{src:r,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,O.jsx)(Dr,{children:(0,O.jsx)(`video`,{src:r,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,O.jsx)(Dr,{children:(0,O.jsx)(`audio`,{src:r,controls:!0,className:`w-full max-w-xl`})}):(0,O.jsx)(`iframe`,{src:r,title:t,className:`h-full w-full border-0 bg-ground`}):(0,O.jsx)(Dr,{children:(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Dr({children:e}){return(0,O.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 Or({session:e,path:t}){return(0,O.jsx)(`button`,{type:`button`,onClick:()=>void p(e,t).catch(e=>m.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 kr(e,t){let[n,r]=(0,T.useState)(null),[i,a]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let n=null,i=!1;return r(null),a(!1),h(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(e=>{i||(n=URL.createObjectURL(e),r(n))}).catch(()=>{i||a(!0)}),()=>{i=!0,n&&URL.revokeObjectURL(n)}},[e,t]),{url:n,error:i}}function Ar({tab:e,reveal:t}){let n=l(e);if(n===`diff`)return(0,O.jsx)(Pe,{session:e.session,path:e.path},f(e));if(n===`commit`&&e.sha)return(0,O.jsx)(Ne,{session:e.session,sha:e.sha,path:e.path},f(e));let r=Tr(e.path);if(r)return(0,O.jsx)(Er,{session:e.session,path:e.path,kind:r},f(e));let i=e.view===`preview`?d(e.path):null;return i?(0,O.jsx)(br,{session:e.session,path:e.path,kind:i},f(e)):(0,O.jsx)(k,{session:e.session,path:e.path,reveal:t},f(e))}export{Ar as PaneEditorBody};
@@ -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{b as r,d as i,f as a,h as o,l as s,m as c,p as l,u}from"./api-BHwI7sYX.js";import{a as d,g as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-B43iKmfK.js";import{t as v}from"./utils-B6KiDbIe.js";import{t as y}from"./createLucideIcon-DyMAgLa3.js";import{a as b,c as x,d as S,i as C,l as w,n as T,o as E,r as D,s as O,t as k,u as ee}from"./session-seed-Dy0HnELo.js";import{i as te,r as ne}from"./dist-VDiYuPKw.js";import{A as re,C as ie,D as ae,E as oe,F as se,G as ce,H as le,I as ue,It as de,L as fe,Lt as A,N as pe,P as j,Qt as me,R as he,Rt as M,St as N,V as P,W as ge,X as _e,Z as ve,_t as F,a as ye,at as be,b as xe,f as Se,ft as I,g as Ce,gt as L,ht as R,i as we,j as Te,k as Ee,kt as De,l as Oe,lt as ke,m as Ae,mt as je,nn as Me,nt as Ne,o as z,p as Pe,s as B,st as Fe,tt as Ie,ut as Le,v as Re,wt as ze,x as Be,xt as V,y as Ve,yt as He}from"./index-BgfBBLZx.js";var Ue=y(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),We=y(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ge=y(`folder-input`,[[`path`,{d:`M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ke=y(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),qe=y(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Je=y(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Ye=y(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Xe=y(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Ze=y(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),H=e(t(),1),U=n();function W({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,U.jsxs)(`div`,{className:v(`flex items-center gap-4 py-2.5`,a),children:[(0,U.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,U.jsx)(`span`,{className:v(`text-xs text-fg-muted`,n),children:t})]}),(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function G({children:e,note:t}){return(0,U.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Qe(){let e=B(),[t,n]=(0,H.useState)(Me());return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{note:`This browser only`,children:`Appearance`}),(0,U.jsx)(W,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,U.jsxs)(D,{value:t,onValueChange:e=>{n(e),me(e)},children:[(0,U.jsx)(E,{className:`w-32`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(C,{children:[(0,U.jsx)(b,{value:`dark`,children:`Dark`}),(0,U.jsx)(b,{value:`light`,children:`Light`}),(0,U.jsx)(b,{value:`system`,children:`System`})]})]})}),(0,U.jsx)(W,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,U.jsx)(A,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>z({uiFontSize:Number(e.target.value)||we.uiFontSize})})}),(0,U.jsx)(W,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,U.jsx)(A,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>z({terminalFontSize:Number(e.target.value)||13})})}),(0,U.jsx)(W,{label:`Density`,children:(0,U.jsxs)(D,{value:e.density,onValueChange:e=>z({density:e}),children:[(0,U.jsx)(E,{className:`w-36`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(C,{children:[(0,U.jsx)(b,{value:`compact`,children:`Compact`}),(0,U.jsx)(b,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,U.jsx)(W,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,U.jsx)(T,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>z({reducedMotion:e})})}),(0,U.jsx)(W,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,U.jsx)(T,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>z({showAllProjectSessions:e})})})]})}function $e({profile:e}){let t=L(),[n,i]=(0,H.useState)(!1),a=n=>{t.mutate({id:e.id,icon:n},{onError:e=>r.error(e.message)}),i(!1)},o=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>r.error(e.message)});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:`Icon`,description:`The glyph shown wherever this profile appears.`,children:(0,U.jsxs)(Se,{open:n,onOpenChange:i,children:[(0,U.jsx)(Ae,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,U.jsx)(se,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,U.jsx)(Pe,{align:`end`,className:`w-72`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:v(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,U.jsx)(se,{icon:null,colour:null,className:`size-4`})}),fe.map(({name:t,Icon:n})=>(0,U.jsx)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:v(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,U.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,U.jsx)(W,{label:`Icon colour`,description:`Any theme colour; recolours with light/dark.`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,U.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:v(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,U.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),c.map(t=>(0,U.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:v(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,U.jsx)(`span`,{className:v(`size-3.5 rounded-full bg-current`,ue(t))}),(0,U.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var K=`__none__`;function et(){let e=j(),t=N().data?.find(t=>t.id===e),n=_e(e??void 0),i=V(e??void 0),a=L(),o=F(e??``),c=Fe(),[l,u]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),[x,S]=(0,H.useState)(!1),[w,T]=(0,H.useState)(``);if((0,H.useEffect)(()=>{t&&(u(t.name),y(t.branch_prefix))},[t]),!t)return null;let k=i.data?.default_account_id;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Profile`}),(0,U.jsxs)(W,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,U.jsx)(A,{id:`profile-name`,value:l,onChange:e=>u(e.target.value),className:`w-44 font-mono`}),(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:l===t.name||l.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:l},{onError:e=>r.error(e.message)}),children:`Save`})]}),(0,U.jsxs)(W,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,U.jsx)(A,{id:`branch-prefix`,value:v,onChange:e=>y(e.target.value),placeholder:s,className:`w-44 font-mono`}),(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:v},{onError:e=>r.error(e.message)}),children:`Save`})]}),(0,U.jsx)($e,{profile:t}),(0,U.jsx)(W,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,U.jsxs)(D,{value:typeof k==`number`?String(k):K,onValueChange:e=>o.mutate({default_account_id:e===K?null:Number(e)},{onError:e=>r.error(e.message)}),children:[(0,U.jsx)(E,{className:`w-56`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(C,{children:[(0,U.jsx)(b,{value:K,children:`First available`}),n.data?.map(e=>(0,U.jsx)(b,{value:String(e.id),children:(0,U.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,U.jsx)(W,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,U.jsx)(f,{variant:`danger`,size:`sm`,onClick:()=>S(!0),children:`Delete…`})}),(0,U.jsx)(_,{open:x,onOpenChange:e=>{e||(S(!1),T(``))},children:(0,U.jsxs)(m,{children:[(0,U.jsxs)(d,{children:[(0,U.jsxs)(h,{children:[`Delete profile `,(0,U.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,U.jsx)(g,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(de,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,U.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,U.jsx)(A,{id:`delete-confirm-name`,value:w,onChange:e=>T(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,U.jsxs)(p,{children:[(0,U.jsx)(f,{variant:`ghost`,onClick:()=>{S(!1),T(``)},children:`Cancel`}),(0,U.jsx)(f,{variant:`danger`,disabled:w!==t.name||c.isPending,onClick:()=>c.mutate(t.id,{onSuccess:()=>{Ee(),pe.set(null)},onError:e=>{S(!1),T(``),r.error(e.message)}}),children:`Delete profile`})]})]})})]})}function tt({agentId:e,profileId:t,onClose:n}){let i=Ne(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),l=ke(oe(s,150)),u=a.trim()!==``&&(s.startsWith(`/`)||s.startsWith(`~`));return(0,U.jsx)(_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,U.jsxs)(m,{children:[(0,U.jsxs)(d,{children:[(0,U.jsx)(h,{children:`Import an existing account`}),(0,U.jsx)(g,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(A,{placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value),className:`font-mono`}),(0,U.jsx)(ae,{value:s,onValueChange:c,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,U.jsxs)(p,{children:[(0,U.jsx)(f,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,U.jsxs)(f,{disabled:!u||i.isPending,onClick:()=>i.mutate({profile_id:t,agent_type:e,label:a.trim(),import_dir:s.trim()},{onSuccess:e=>{n(),e.logged_in||r.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>r.error(e.message)}),children:[(0,U.jsx)(Ge,{}),`Import`]})]})]})})}function nt({account:e,gateOpen:t}){let n=I(),i=je(),a=be(),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,v]=(0,H.useState)(e.label);return(0,H.useEffect)(()=>v(e.label),[e.label]),(0,U.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`input`,{value:u,onChange:e=>v(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){v(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{r.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,U.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-running`:`text-waiting`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,U.jsx)(T,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>r.error(e.message)})})]}),(0,U.jsxs)(f,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>s(e.stream),onError:e=>r.error(e.message)}),children:[(0,U.jsx)(ce,{}),e.logged_in?`Re-login`:`Login`]}),(0,U.jsxs)(f,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,U.jsx)(x,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,U.jsx)(Oe,{stream:o,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,U.jsx)(_,{open:c,onOpenChange:l,children:(0,U.jsxs)(m,{children:[(0,U.jsxs)(d,{children:[(0,U.jsxs)(h,{children:[`Delete `,(0,U.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,U.jsx)(g,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,U.jsxs)(p,{children:[(0,U.jsx)(f,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,U.jsx)(f,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),r.error(e.message)}}),children:`Delete account`})]})]})})]})}function rt(){let e=j(),t=ve(),n=_e(e??void 0),i=V(e??void 0),a=Ne(),o=I(),[s,c]=(0,H.useState)({}),[l,u]=(0,H.useState)(null),[d,p]=(0,H.useState)(null),m=i.data?.allowSkipPermissions===!0,h=t=>{let n=(s[t]??``).trim();!n||e===null||a.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{c(e=>({...e,[t]:``})),o.mutate(e.id,{onSuccess:n=>u({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>r.error(e.message)})};return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,U.jsxs)(`div`,{className:`mb-5`,children:[(0,U.jsx)(W,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,U.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.id})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,U.jsx)(nt,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,U.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,U.jsx)(A,{placeholder:`label, e.g. personal`,value:s[e.id]??``,onChange:t=>c(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,U.jsxs)(f,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(s[e.id]??``).trim()||a.isPending,children:[(0,U.jsx)(le,{}),`Add account`]}),(0,U.jsxs)(f,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,U.jsx)(Ge,{}),`Import existing…`]})]})]})]},e.id)}),l&&(0,U.jsx)(Oe,{stream:l.stream,label:l.label,onClose:()=>u(null)}),d!==null&&e!==null&&(0,U.jsx)(tt,{agentId:d,profileId:e,onClose:()=>p(null)})]})}function it(){let e=Ie(),t=R(),[n,r]=(0,H.useState)(``);return(0,H.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,U.jsx)(W,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,U.jsx)(A,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function at({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=k(e,n),o=n.sessionDefaults??{},[s,c]=(0,H.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,U.jsx)(W,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,U.jsx)(A,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,U.jsx)(W,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,U.jsx)(T,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,U.jsx)(W,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,U.jsx)(T,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ot(){return(0,U.jsx)(W,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,U.jsx)(A,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:B().terminalScrollback,onChange:e=>z({terminalScrollback:Number(e.target.value)||5e3})})})}function q({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,H.useState)(r);return(0,U.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,U.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,U.jsx)(M,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,U.jsx)(f,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var st={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function ct({initial:e,onSave:t,pending:n}){let[r,i]=(0,H.useState)(e),a=r.length>0?r:l;return(0,U.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,U.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,U.jsx)(A,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:l}),(0,U.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,U.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ce(st,a)})]}),(0,U.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:o.map(([e,t])=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,U.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,U.jsx)(f,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(l),t(l)},children:`Reset to default`})]})]})}function lt(){let e=j(),t=N().data?.find(t=>t.id===e),n=V(e??void 0),o=F(e??``),[s,c]=(0,H.useState)(!1),[l,v]=(0,H.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>o.mutate({allowSkipPermissions:e},{onSuccess:()=>{c(!1),v(``)},onError:e=>r.error(e.message)}),x=e=>t=>o.mutate({[e]:t},{onError:e=>r.error(e.message)});return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Sessions`}),(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,U.jsx)(W,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,U.jsx)(T,{id:`gate`,checked:y,onCheckedChange:e=>{e?c(!0):b(!1)}})}),(0,U.jsx)(W,{label:`Capture exported env vars`,description:n.data?.captureSessionEnv===!1?`Paused: session shells spawn plain — nothing new is captured or injected. Already-captured vars are kept for when this is re-enabled.`:`Vars exported in a session terminal persist: re-injected into its new shells and agent restarts. Values stay on the daemon host.`,htmlFor:`capture-env`,children:(0,U.jsx)(T,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:o.isPending,onCheckedChange:e=>o.mutate({captureSessionEnv:e},{onError:e=>r.error(e.message)})})}),(0,U.jsx)(it,{}),(0,U.jsx)(ot,{}),(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(G,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(at,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>o.mutate({sessionDefaults:e},{onError:e=>r.error(e.message)}),pending:o.isPending},`${e}:agent-seed`),(0,U.jsx)(at,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>o.mutate({sessionDefaults:e},{onError:e=>r.error(e.message)}),pending:o.isPending},`${e}:terminal-seed`)]})]}),(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(G,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??i,defaultText:i,onSave:x(`onboardingTemplate`),pending:o.isPending},`${e}:onboarding`),(0,U.jsx)(q,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??u,defaultText:u,onSave:x(`concurrentTemplate`),pending:o.isPending},`${e}:concurrent`),(0,U.jsx)(q,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??a,defaultText:a,onSave:x(`restartTemplate`),pending:o.isPending},`${e}:restart`)]})]}),(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(G,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,U.jsx)(ct,{initial:n.data.tabTitleTemplate??"${name}",onSave:x(`tabTitleTemplate`),pending:o.isPending},`${e}:tab-title`)]}),(0,U.jsx)(_,{open:s,onOpenChange:e=>{e||(c(!1),v(``))},children:(0,U.jsxs)(m,{children:[(0,U.jsxs)(d,{children:[(0,U.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Ye,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,U.jsx)(g,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,U.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,U.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,U.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,U.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,U.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,U.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,U.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,U.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(de,{htmlFor:`confirm-name`,children:[`Type `,(0,U.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,U.jsx)(A,{id:`confirm-name`,value:l,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,U.jsxs)(p,{children:[(0,U.jsx)(f,{variant:`ghost`,onClick:()=>{c(!1),v(``)},children:`Cancel`}),(0,U.jsx)(f,{variant:`danger`,disabled:l!==t?.name||o.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var ut={desktop:!0,sound:!1,muted_projects:[]};function dt(){let e=j(),t=V(e??void 0),n=F(e??``),i=ze(e??void 0),a={...ut,...t.data?.notifications??{}},o=e=>n.mutate({notifications:e},{onError:e=>r.error(e.message)});return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{note:`Delivery lands in a later phase`,children:`Notifications`}),(0,U.jsx)(W,{label:`Desktop notification on waiting`,description:`When a session flips to waiting for input.`,htmlFor:`notify-desktop`,children:(0,U.jsx)(T,{id:`notify-desktop`,checked:a.desktop,onCheckedChange:e=>o({...a,desktop:e})})}),(0,U.jsx)(W,{label:`Sound`,htmlFor:`notify-sound`,children:(0,U.jsx)(T,{id:`notify-sound`,checked:a.sound,onCheckedChange:e=>o({...a,sound:e})})}),(0,U.jsx)(W,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,U.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[a.muted_projects.length,` muted`]})}),(0,U.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,U.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,U.jsx)(T,{checked:a.muted_projects.includes(e.id),onCheckedChange:t=>o({...a,muted_projects:t?[...a.muted_projects,e.id]:a.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function ft(){let e=B();return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{note:`This browser only`,children:`Editor`}),(0,U.jsx)(W,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,U.jsx)(A,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>z({editorTabSize:Number(e.target.value)||2})})}),(0,U.jsx)(W,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,U.jsx)(T,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>z({editorWordWrap:e})})}),(0,U.jsx)(W,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,U.jsx)(A,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>z({editorLinkSshHost:e.target.value})})})]})}function pt({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=xe(e.nativeEvent);t&&(n(t),a(!1))},className:v(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Be(e)}),!t&&(0,U.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,U.jsx)(qe,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function mt(){let e=j(),t=V(e??void 0),n=F(e??``),i=t.data?.hotkeys??{},a=(e,t)=>i[e]||t,o=new Map;for(let e of Re){let t=a(e.id,e.defaultBinding);o.set(t,(o.get(t)??0)+1)}let s=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>r.error(e.message)}),c=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>r.error(e.message)})};return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Hotkeys`}),(0,U.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed. Browser-reserved combos (⌘W, ⌘T, ⌘⇧B, …) can’t be captured by a web tab.`}),Ve.map(e=>{let t=Re.filter(t=>t.group===e);return t.length===0?null:(0,U.jsxs)(`div`,{className:`mb-5`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=a(e.id,e.defaultBinding),n=(o.get(t)??0)>1,r=ie(t)?`Browser-reserved — won’t fire in a tab.`:n?`Conflicts with another shortcut.`:void 0;return(0,U.jsx)(W,{label:e.label,description:r,descriptionClassName:r?`text-interrupted`:void 0,children:(0,U.jsx)(pt,{value:t,isDefault:!i[e.id],onRecord:t=>s(e.id,t),onReset:()=>c(e.id)})},e.id)})]},e)})]})}var ht=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,J=65,Y=Object.fromEntries([...ht].map((e,t)=>[e,t])),gt=`H`,_t=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function vt(e){let t=4294967295;for(let n of e)t=_t[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function yt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function bt(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function xt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function St(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function X(e,t){let n=(t%J+J)%J,r=``;for(let t of e){let e=Y[t];r+=e===void 0?t:ht[(e+n)%J]}return r}async function Ct(e){let t=await xt(JSON.stringify(e));return X(yt(t)+vt(t),1+Math.floor(Math.random()*(J-1)))}async function wt(e){let t=e.trim(),n=t[0];if(!n||Y[n]===void 0)throw Error(`Not a settings export.`);let r=X(t,-((Y[n]-Y[gt]+J)%J));if(r.length<9||r[0]!==gt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=bt(i);if(vt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await St(o))}var Z=[{id:`appearance`,label:`Appearance`,fields:[{key:`theme`,store:`theme`},{key:`uiFontSize`,store:`client`},{key:`terminalFontSize`,store:`client`},{key:`density`,store:`client`},{key:`reducedMotion`,store:`client`},{key:`terminalScrollback`,store:`client`},{key:`showAllProjectSessions`,store:`client`}]},{id:`profile`,label:`Profile`,fields:[{key:`branch_prefix`,store:`profileColumn`},{key:`icon`,store:`profileColumn`},{key:`icon_colour`,store:`profileColumn`}]},{id:`sessions`,label:`Sessions`,fields:[{key:`onboardingTemplate`,store:`profileSettings`},{key:`concurrentTemplate`,store:`profileSettings`},{key:`restartTemplate`,store:`profileSettings`},{key:`tabTitleTemplate`,store:`profileSettings`},{key:`sessionDefaults`,store:`profileSettings`},{key:`allowSkipPermissions`,store:`profileSettings`}]},{id:`editor`,label:`Editor`,fields:[{key:`editorTabSize`,store:`client`},{key:`editorWordWrap`,store:`client`},{key:`editorLinkSshHost`,store:`client`}]},{id:`hotkeys`,label:`Hotkeys`,fields:[{key:`hotkeys`,store:`profileSettings`}]}];function Tt(e,t){switch(e.store){case`client`:return t.client[e.key];case`theme`:return t.theme;case`profileSettings`:return t.profileSettings[e.key];case`profileColumn`:return t.profile[e.key]}}function Et(e,t){let n={};for(let r of Z){if(!e.includes(r.id))continue;let i={};for(let e of r.fields){let n=Tt(e,t);n!==void 0&&(i[e.key]=n)}Object.keys(i).length>0&&(n[r.id]=i)}return n}function Dt(e,t){if(!e||typeof e!=`object`)return[];let n=e,r={},i={},a={},o=[];for(let e of Z){let s=n[e.id];if(!s||typeof s!=`object`)continue;let c=s,l=!1;for(let n of e.fields){if(!(n.key in c))continue;l=!0;let e=c[n.key];n.store===`client`?r[n.key]=e:n.store===`theme`?t.setTheme(e):n.store===`profileSettings`?i[n.key]=e:a[n.key]=e}l&&o.push(e.label)}return Object.keys(r).length>0&&t.setClient(r),Object.keys(i).length>0&&t.patchProfileSettings(i),Object.keys(a).length>0&&t.patchProfileColumns(a),o}function Ot(){let e=j(),t=V(e??void 0),n=N().data?.find(t=>t.id===e),i=F(e??``),a=L(),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(()=>Object.fromEntries(Z.map(e=>[e.id,!0]))),y=async()=>{g(!0);try{let t=Dt(await wt(o.trim()),{setClient:e=>z(e),setTheme:e=>{typeof e==`string`&&me(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>r.error(e.message)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>r.error(e.message)})}});t.length===0?r.error(`Nothing recognised to import.`):(r.success(`Imported ${t.join(`, `)}.`),s(``))}catch(e){r.error(e.message)}finally{g(!1)}},b=async()=>{g(!0);try{let e=Et(Z.filter(e=>_[e.id]).map(e=>e.id),{client:ye(),theme:Me(),profileSettings:t.data??{},profile:n??{}});l(await Ct(e)),d(!1)}finally{g(!1)}};return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Sync`}),(0,U.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines as one string. Accounts, repositories, and anything machine-specific are never included. Applies to this profile.`}),(0,U.jsxs)(`div`,{className:`mb-6`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,U.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste an exported string — only the settings it carries are updated.`}),(0,U.jsx)(M,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(f,{size:`sm`,disabled:!o.trim()||h,onClick:()=>void y(),children:`Import`})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`mb-2 mt-1 flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[p?(0,U.jsx)(ee,{className:`size-3.5`}):(0,U.jsx)(te,{className:`size-3.5`}),`Choose what to include`]}),p&&(0,U.jsx)(`div`,{className:`mb-3 flex flex-col gap-2 pl-1`,children:Z.map(e=>(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,U.jsx)(T,{checked:_[e.id]??!1,onCheckedChange:t=>v(n=>({...n,[e.id]:t}))}),e.label]},e.id))}),(0,U.jsx)(f,{size:`sm`,disabled:h,onClick:()=>void b(),children:`Export`}),c&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(M,{readOnly:!0,value:c,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`resize-y font-mono text-xs`}),(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsxs)(f,{size:`sm`,variant:`secondary`,onClick:()=>{navigator.clipboard?.writeText(c),d(!0)},children:[u?(0,U.jsx)(S,{}):(0,U.jsx)(w,{}),u?`Copied`:`Copy`]})})]})]})]})}function kt({repo:e}){let t=He(),n=Le(),[i,a]=(0,H.useState)(e.default_base_branch),[o,s]=(0,H.useState)(e.onboarding_notes??``),c=e=>r.error(e.message);return(0,U.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-fg`,children:e.path}),(0,U.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,U.jsxs)(f,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>r.success(`Fetched.`),onError:c}),children:[(0,U.jsx)(P,{}),`Fetch now`]})]}),(0,U.jsxs)(W,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,U.jsx)(A,{id:`base-${e.id}`,value:i,onChange:e=>a(e.target.value),className:`w-40 font-mono`}),(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:i===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:i},{onError:c}),children:`Save`})]}),(0,U.jsx)(W,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,U.jsx)(T,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,U.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,U.jsx)(M,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4,className:`font-mono`}),(0,U.jsx)(`div`,{children:(0,U.jsx)(f,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,U.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,U.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,U.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,U.jsx)(`li`,{className:`truncate font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function At(){let e=De();return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{children:`Repositories`}),e.data?.length===0&&(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,U.jsx)(kt,{repo:e},e.id))]})}function Q({label:e,description:t,field:n,config:i,min:a,step:o=1}){let s=R();return(0,U.jsx)(W,{label:e,description:t,htmlFor:`host-${n}`,children:(0,U.jsx)(A,{id:`host-${n}`,type:`number`,min:a,step:o,className:`w-32 tabular-nums`,defaultValue:i[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==i[n]&&s.mutate({[n]:t},{onError:e=>r.error(e.message)})}})})}function jt(){let e=Ie(),t=R();return e.data?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(G,{note:`Affects all profiles on this host`,children:`Host`}),(0,U.jsx)(Q,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,U.jsx)(Q,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,U.jsx)(Q,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,U.jsx)(Q,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,U.jsx)(W,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,U.jsx)(T,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>r.error(e.message)})})})]}):null}var $=[{id:`appearance`,label:`Appearance`,icon:ge,render:()=>(0,U.jsx)(Qe,{})},{id:`profile`,label:`Profile`,icon:he,render:()=>(0,U.jsx)(et,{})},{id:`accounts`,label:`Accounts`,icon:Ze,render:()=>(0,U.jsx)(rt,{})},{id:`sessions`,label:`Sessions`,icon:Xe,render:()=>(0,U.jsx)(lt,{})},{id:`editor`,label:`Editor`,icon:We,render:()=>(0,U.jsx)(ft,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ke,render:()=>(0,U.jsx)(mt,{})},{id:`notifications`,label:`Notifications`,icon:Ue,render:()=>(0,U.jsx)(dt,{})},{id:`repositories`,label:`Repositories`,icon:ne,render:()=>(0,U.jsx)(At,{})},{id:`host`,label:`Host`,icon:Je,render:()=>(0,U.jsx)(jt,{})},{id:`sync`,label:`Sync`,icon:P,render:()=>(0,U.jsx)(Ot,{})}],Mt={terminal:`sessions`};function Nt(){let e=Te(),t=e===null?null:Mt[e]??e,n=$.find(e=>e.id===t)??$[0];return(0,U.jsx)(_,{open:e!==null,onOpenChange:e=>!e&&Ee(),children:(0,U.jsxs)(m,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,U.jsx)(h,{className:`sr-only`,children:`Settings`}),(0,U.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,U.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),$.map(({id:e,label:t,icon:r})=>(0,U.jsxs)(`button`,{onClick:()=>re(e),className:v(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,U.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,U.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Nt as SettingsDialog};