@puddle-code/cli 0.1.1 → 0.1.2

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 (24) hide show
  1. package/CHANGELOG.md +7 -5
  2. package/dist/index.js +3 -2
  3. package/dist/public/assets/{Dashboard-D5c0i44_.js → Dashboard-BhJZAZkm.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-SDjhp_uE.js → EditorTabClose-D5-9GTuN.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-BldwHaN4.js → LazyTerminal-DpW_dV8-.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-Csg6sffQ.js → ModelRefcount-Bc70ux--.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-DezeQALr.js → PaneEditorBody-DPfYk1MG.js} +1 -1
  8. package/dist/public/assets/SettingsDialog-C1YGjO8w.js +1 -0
  9. package/dist/public/assets/{Terminal-Ct0grO8I.js → Terminal-DmMk3PAE.js} +1 -1
  10. package/dist/public/assets/{Workspace-BzMWey5E.js → Workspace-HBspP42h.js} +3 -3
  11. package/dist/public/assets/{buffer-store-BXopEwK6.js → buffer-store-Ch_ccGob.js} +2 -2
  12. package/dist/public/assets/{context-menu-Dsw6sIkz.js → context-menu-BIpVA6AC.js} +1 -1
  13. package/dist/public/assets/{cssMode-lD_ILMBr.js → cssMode-DP2qOqv1.js} +1 -1
  14. package/dist/public/assets/{drafts-BJ4bJnkA.js → drafts-CyZAHsxG.js} +1 -1
  15. package/dist/public/assets/{file-links-Db989aPp.js → file-links-DhiBZF5y.js} +1 -1
  16. package/dist/public/assets/{htmlMode-7jMfz6m7.js → htmlMode-DDBP46Y_.js} +1 -1
  17. package/dist/public/assets/{index-BsC4i0JY.js → index-CzVID1ZA.js} +3 -3
  18. package/dist/public/assets/{jsonMode-CAIP9wAp.js → jsonMode-B-208CCp.js} +1 -1
  19. package/dist/public/assets/{session-seed-CsbnF8Fn.js → session-seed-YCLBYoEN.js} +1 -1
  20. package/dist/public/assets/{tsMode-D_fFoWih.js → tsMode-BOmmwl1s.js} +1 -1
  21. package/dist/public/assets/{use-find-controls-Dsils9K4.js → use-find-controls-Bs5HCbAh.js} +1 -1
  22. package/dist/public/index.html +2 -2
  23. package/package.json +1 -1
  24. package/dist/public/assets/SettingsDialog-DTSMTCLl.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,12 +7,14 @@ Past releases: see docs/changelogs/.
7
7
 
8
8
  # Changelog
9
9
 
10
- ## [0.1.1] — 2026-08-24
10
+ ## [0.1.2] — 2026-08-24
11
11
 
12
- ### Added
12
+ ### Fixed
13
13
 
14
- - Let users switch among the native System, Rangefinder, Drafting, and Invert cursor packages in Appearance settings.
14
+ - Resume catalogue-discovered Codex and OpenCode conversations against their native creation time instead of the later Puddle placement time.
15
+ - Preserve shell Up/Down history navigation across environment activation by initialising private history before user shell integrations.
16
+ - Let the README cockpit shadows fade into their backdrops before the lower image edge, with pure white behind the light screenshot.
15
17
 
16
- ### Fixed
18
+ ### Changed
17
19
 
18
- - Render repository-relative `srcset` images, including theme-aware README pictures, in Markdown and HTML previews.
20
+ - Remove the redundant cursor-style description from Appearance settings.
package/dist/index.js CHANGED
@@ -19877,7 +19877,7 @@ import { readFileSync } from "node:fs";
19877
19877
  import { dirname, join as join2 } from "node:path";
19878
19878
  import { fileURLToPath } from "node:url";
19879
19879
  function cliVersion() {
19880
- if (true) return "0.1.1";
19880
+ if (true) return "0.1.2";
19881
19881
  const here = dirname(fileURLToPath(import.meta.url));
19882
19882
  for (const candidate of [
19883
19883
  join2(here, "..", "..", "package.json"),
@@ -20237,7 +20237,8 @@ var RELEASE_PROTOCOLS = {
20237
20237
  "0.0.55": { major: 16, minor: 3 },
20238
20238
  "0.0.56": { major: 16, minor: 4 },
20239
20239
  "0.1.0": { major: 17, minor: 0 },
20240
- "0.1.1": { major: 17, minor: 0 }
20240
+ "0.1.1": { major: 17, minor: 0 },
20241
+ "0.1.2": { major: 17, minor: 0 }
20241
20242
  };
20242
20243
  function validProtocol(value) {
20243
20244
  if (typeof value !== "object" || value === null) return false;
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,r}from"./x-BJOrp_m5.js";import{Tt as i,at as a,ct as o,nt as s,p as c,pt as l,tt as u,v as d,vt as f}from"./hotkeys-CekBkaTu.js";import{a as p,h as m,i as h,n as g,o as _,t as v}from"./dialog-DjL0qoAv.js";import{a as y,c as b,l as x,o as S,s as C,t as w}from"./LazyTerminal-BldwHaN4.js";import{A as T,M as E,c as D,j as O,k,n as A,r as j,t as M}from"./context-menu-Dsw6sIkz.js";import{r as N}from"./dist-DDFe8e3m.js";import{Dt as P,Nt as F,Xt as I,at as L,ct as R,lt as z,st as B}from"./index-BsC4i0JY.js";var V=e(t(),1),H=n(),U=!1;function W(){let[e,t]=(0,V.useState)(U),[n,r]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!e)return;let t=!1;return z.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{U=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&z.killShell(i,n),a()):(U=!0,t(!0))},onExit:a}}function G({term:e,onExit:t}){return(0,H.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,H.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,H.jsx)(w,{stream:`home`,term:e,onExit:t})})})}var K=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function q({projectId:e}){let t=f(e),n=(0,V.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),K.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function J({icon:e,label:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,H.jsx)(e,{className:`size-4`})})}function Y({project:e,repoPath:t,draggable:n,dragging:i,onDragStart:a,onDragEnd:o,onDragOver:c}){let l=s(),[u,d]=(0,V.useState)(!1),[f,C]=(0,V.useState)(e.name),[w,T]=(0,V.useState)(R(e)),k=t=>l.mutate({id:e.id,archived:t},{onError:e=>y(e)}),N=()=>{C(e.name),T(R(e)),d(!0)},P=()=>{let t=f.trim(),n=B(w);if(!t){d(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==R(e)?{abbrev:n}:{}};if(Object.keys(r).length===0){d(!1);return}l.mutate({id:e.id,...r},{onSuccess:()=>d(!1),onError:e=>y(e)})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(M,{children:[(0,H.jsx)(D,{asChild:!0,children:(0,H.jsxs)(`div`,{draggable:n,onDragStart:a,onDragEnd:o,onDragOver:c,className:r(`group relative transition-opacity`,i&&`opacity-50`),children:[(0,H.jsxs)(I,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,H.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(q,{projectId:e.id})})]}),(0,H.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,H.jsx)(J,{icon:E,label:`Reopen project`,onClick:()=>k(!1)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{icon:S,label:`Edit project`,onClick:N}),(0,H.jsx)(J,{icon:O,label:`Archive project`,onClick:()=>k(!0)})]})})]})}),(0,H.jsx)(A,{children:e.archived?(0,H.jsxs)(j,{onSelect:()=>k(!1),children:[(0,H.jsx)(E,{}),` Reopen`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(j,{onSelect:N,children:[(0,H.jsx)(S,{}),` Edit`]}),(0,H.jsxs)(j,{onSelect:()=>k(!0),children:[(0,H.jsx)(O,{}),` Archive`]})]})})]}),(0,H.jsx)(v,{open:u,onOpenChange:d,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(p,{children:(0,H.jsx)(_,{children:`Edit project`})}),(0,H.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(b,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,H.jsx)(x,{id:`project-name-${e.id}`,value:f,onChange:e=>C(e.target.value),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(b,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,H.jsx)(x,{id:`project-abbrev-${e.id}`,maxLength:5,value:w,onChange:e=>T(B(e.target.value)),className:`w-24 uppercase`}),(0,H.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(b,{className:`text-fg-muted`,children:`Path`}),(0,H.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,H.jsxs)(h,{children:[(0,H.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>d(!1),children:`Cancel`}),(0,H.jsx)(m,{type:`submit`,disabled:!f.trim()||l.isPending,children:`Save`})]})]})]})})]})}function X({icon:e,label:t,hint:n,onClick:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,H.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function Z(){let e=d(),t=o(e??void 0),n=l(),i=a(e??void 0),s=u(e??``),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),v=W(),y=c(`palette.toggle`),b=e=>n.data?.find(t=>t.id===e)?.path,x=t.data??[],S=i.data?.projectOrder??[],w=k(x.filter(e=>!e.archived),S),E=x.filter(e=>e.archived),D=(e,t)=>{e!==t&&s.mutate({projectOrder:T(w.map(e=>e.id),e,t)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[x.length===0&&(0,H.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,H.jsx)(C,{className:`size-8 text-fg-muted`}),(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,y,`.`]})]}),(0,H.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[w.map(e=>(0,H.jsx)(Y,{project:e,repoPath:b(e.repo_id),draggable:!0,dragging:m===e.id,onDragStart:()=>h(e.id),onDragEnd:()=>h(null),onDragOver:t=>{t.preventDefault(),m&&m!==e.id&&D(m,e.id)}},e.id)),(0,H.jsx)(X,{icon:F,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>p(!0)}),(0,H.jsx)(X,{icon:P,label:v.open?`Close terminal`:`Open terminal`,hint:v.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:v.toggle})]}),E.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,H.jsx)(N,{className:r(`size-3 transition-transform`,g&&`rotate-90`)}),(0,H.jsx)(O,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Archived`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:E.length})]}),g&&(0,H.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:E.map(e=>(0,H.jsx)(Y,{project:e,repoPath:b(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),v.open&&(0,H.jsx)(G,{term:v.term,onExit:v.onExit}),e!==null&&(0,H.jsx)(L,{profileId:e,open:f,onOpenChange:p})]})}export{Z as Dashboard};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,r}from"./x-BJOrp_m5.js";import{Tt as i,at as a,ct as o,nt as s,p as c,pt as l,tt as u,v as d,vt as f}from"./hotkeys-CekBkaTu.js";import{a as p,h as m,i as h,n as g,o as _,t as v}from"./dialog-DjL0qoAv.js";import{a as y,c as b,l as x,o as S,s as C,t as w}from"./LazyTerminal-DpW_dV8-.js";import{A as T,M as E,c as D,j as O,k,n as A,r as j,t as M}from"./context-menu-BIpVA6AC.js";import{r as N}from"./dist-DDFe8e3m.js";import{Dt as P,Nt as F,Xt as I,at as L,ct as R,lt as z,st as B}from"./index-CzVID1ZA.js";var V=e(t(),1),H=n(),U=!1;function W(){let[e,t]=(0,V.useState)(U),[n,r]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!e)return;let t=!1;return z.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{U=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&z.killShell(i,n),a()):(U=!0,t(!0))},onExit:a}}function G({term:e,onExit:t}){return(0,H.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,H.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,H.jsx)(w,{stream:`home`,term:e,onExit:t})})})}var K=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function q({projectId:e}){let t=f(e),n=(0,V.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),K.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function J({icon:e,label:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,H.jsx)(e,{className:`size-4`})})}function Y({project:e,repoPath:t,draggable:n,dragging:i,onDragStart:a,onDragEnd:o,onDragOver:c}){let l=s(),[u,d]=(0,V.useState)(!1),[f,C]=(0,V.useState)(e.name),[w,T]=(0,V.useState)(R(e)),k=t=>l.mutate({id:e.id,archived:t},{onError:e=>y(e)}),N=()=>{C(e.name),T(R(e)),d(!0)},P=()=>{let t=f.trim(),n=B(w);if(!t){d(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==R(e)?{abbrev:n}:{}};if(Object.keys(r).length===0){d(!1);return}l.mutate({id:e.id,...r},{onSuccess:()=>d(!1),onError:e=>y(e)})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(M,{children:[(0,H.jsx)(D,{asChild:!0,children:(0,H.jsxs)(`div`,{draggable:n,onDragStart:a,onDragEnd:o,onDragOver:c,className:r(`group relative transition-opacity`,i&&`opacity-50`),children:[(0,H.jsxs)(I,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,H.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(q,{projectId:e.id})})]}),(0,H.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,H.jsx)(J,{icon:E,label:`Reopen project`,onClick:()=>k(!1)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{icon:S,label:`Edit project`,onClick:N}),(0,H.jsx)(J,{icon:O,label:`Archive project`,onClick:()=>k(!0)})]})})]})}),(0,H.jsx)(A,{children:e.archived?(0,H.jsxs)(j,{onSelect:()=>k(!1),children:[(0,H.jsx)(E,{}),` Reopen`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(j,{onSelect:N,children:[(0,H.jsx)(S,{}),` Edit`]}),(0,H.jsxs)(j,{onSelect:()=>k(!0),children:[(0,H.jsx)(O,{}),` Archive`]})]})})]}),(0,H.jsx)(v,{open:u,onOpenChange:d,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(p,{children:(0,H.jsx)(_,{children:`Edit project`})}),(0,H.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(b,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,H.jsx)(x,{id:`project-name-${e.id}`,value:f,onChange:e=>C(e.target.value),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(b,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,H.jsx)(x,{id:`project-abbrev-${e.id}`,maxLength:5,value:w,onChange:e=>T(B(e.target.value)),className:`w-24 uppercase`}),(0,H.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(b,{className:`text-fg-muted`,children:`Path`}),(0,H.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,H.jsxs)(h,{children:[(0,H.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>d(!1),children:`Cancel`}),(0,H.jsx)(m,{type:`submit`,disabled:!f.trim()||l.isPending,children:`Save`})]})]})]})})]})}function X({icon:e,label:t,hint:n,onClick:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,H.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function Z(){let e=d(),t=o(e??void 0),n=l(),i=a(e??void 0),s=u(e??``),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),v=W(),y=c(`palette.toggle`),b=e=>n.data?.find(t=>t.id===e)?.path,x=t.data??[],S=i.data?.projectOrder??[],w=k(x.filter(e=>!e.archived),S),E=x.filter(e=>e.archived),D=(e,t)=>{e!==t&&s.mutate({projectOrder:T(w.map(e=>e.id),e,t)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[x.length===0&&(0,H.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,H.jsx)(C,{className:`size-8 text-fg-muted`}),(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,y,`.`]})]}),(0,H.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[w.map(e=>(0,H.jsx)(Y,{project:e,repoPath:b(e.repo_id),draggable:!0,dragging:m===e.id,onDragStart:()=>h(e.id),onDragEnd:()=>h(null),onDragOver:t=>{t.preventDefault(),m&&m!==e.id&&D(m,e.id)}},e.id)),(0,H.jsx)(X,{icon:F,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>p(!0)}),(0,H.jsx)(X,{icon:P,label:v.open?`Close terminal`:`Open terminal`,hint:v.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:v.toggle})]}),E.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,H.jsx)(N,{className:r(`size-3 transition-transform`,g&&`rotate-90`)}),(0,H.jsx)(O,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Archived`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:E.length})]}),g&&(0,H.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:E.map(e=>(0,H.jsx)(Y,{project:e,repoPath:b(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),v.open&&(0,H.jsx)(G,{term:v.term,onExit:v.onExit}),e!==null&&(0,H.jsx)(L,{profileId:e,open:f,onOpenChange:p})]})}export{Z as Dashboard};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,t as i}from"./x-BJOrp_m5.js";import{a,h as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-DjL0qoAv.js";import{i as f,t as p,u as m}from"./buffer-store-BXopEwK6.js";import{t as h}from"./drafts-BJ4bJnkA.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=p(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>m(r,e),[r]),()=>f(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:r,label:f,onClose:p}){let m=b(e,t,r)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>m?x(!0):p();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${f}`,children:(0,y.jsx)(i,{className:`size-3`})}),(0,y.jsx)(d,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(c,{children:[(0,y.jsxs)(a,{children:[(0,y.jsxs)(l,{children:[`Discard changes to `,f,`?`]}),(0,y.jsx)(u,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(s,{children:[(0,y.jsx)(o,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(o,{variant:`danger`,onClick:()=>{h(e,t,r),g(e,t,r),x(!1),p()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,t as i}from"./x-BJOrp_m5.js";import{a,h as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-DjL0qoAv.js";import{i as f,t as p,u as m}from"./buffer-store-Ch_ccGob.js";import{t as h}from"./drafts-CyZAHsxG.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=p(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>m(r,e),[r]),()=>f(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:r,label:f,onClose:p}){let m=b(e,t,r)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>m?x(!0):p();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${f}`,children:(0,y.jsx)(i,{className:`size-3`})}),(0,y.jsx)(d,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(c,{children:[(0,y.jsxs)(a,{children:[(0,y.jsxs)(l,{children:[`Discard changes to `,f,`?`]}),(0,y.jsx)(u,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(s,{children:[(0,y.jsx)(o,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(o,{variant:`danger`,onClick:()=>{h(e,t,r),g(e,t,r),x(!1),p()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-Ct0grO8I.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/x-BJOrp_m5.js","assets/hotkeys-CekBkaTu.js","assets/file-links-Db989aPp.js","assets/index-BsC4i0JY.js","assets/preload-helper-Czpn1I53.js","assets/dialog-DjL0qoAv.js","assets/index-BBk5N4Nn.css","assets/use-find-controls-Dsils9K4.js","assets/chevron-down-59O6CgEo.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,o as i,r as a}from"./x-BJOrp_m5.js";import{Ht as o,xt as s}from"./hotkeys-CekBkaTu.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{C as l,D as u,S as d,b as f,k as p}from"./dialog-DjL0qoAv.js";var m=e(t(),1),h=[`top`,`right`,`bottom`,`left`],g=Math.min,_=Math.max,v=Math.round,y=Math.floor,b=e=>({x:e,y:e}),x={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function S(e,t,n){return _(e,g(t,n))}function C(e,t){return typeof e==`function`?e(t):e}function w(e){return e.split(`-`)[0]}function T(e){return e.split(`-`)[1]}function E(e){return e===`x`?`y`:`x`}function D(e){return e===`y`?`height`:`width`}function O(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function k(e){return E(O(e))}function A(e,t,n){n===void 0&&(n=!1);let r=T(e),i=k(e),a=D(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=z(o)),[o,z(o)]}function j(e){let t=z(e);return[M(e),t,M(t)]}function M(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var N=[`left`,`right`],P=[`right`,`left`],F=[`top`,`bottom`],I=[`bottom`,`top`];function L(e,t,n){switch(e){case`top`:case`bottom`:return n?t?P:N:t?N:P;case`left`:case`right`:return t?F:I;default:return[]}}function R(e,t,n,r){let i=T(e),a=L(w(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(M)))),a}function z(e){let t=w(e);return x[t]+e.slice(t.length)}function ee(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ne(e,t,n){let{reference:r,floating:i}=e,a=O(t),o=k(t),s=D(o),c=w(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=T(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function re(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=C(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ie=50,ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:re},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ne(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ie&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ne(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=C(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=k(i),m=D(p),h=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],w=f[p]-a.reference[p],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),O=E?E[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(E)))&&(O=s.floating[b]||a.floating[m]);let A=x/2-w/2,j=O/2-h[m]/2-1,M=g(d[v],j),N=g(d[y],j),P=O-h[m]-N,F=O/2-h[m]/2+A,I=S(M,F,P),L=!c.arrow&&T(i)!=null&&F!==I&&a.reference[m]/2-(F<M?M:N)-h[m]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=C(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=w(r),_=O(o),v=w(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[z(o)]:j(o)),x=p!==`none`;!d&&x&&b.push(...R(o,m,p,y));let S=[o,...b],T=await s.detectOverflow(t,h),E=[],D=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=A(r,a,y);E.push(T[e[0]],T[e[1]])}if(D=[...D,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==O(t))||D.every(e=>O(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=O(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return h.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=C(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=w(n),s=T(n),c=O(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=C(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=C(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=O(i),p=E(f),m=u[p],h=u[f],g=(e,t)=>S(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=C(e,t),u={x:n,y:r},d=O(i),f=E(d),p=u[f],m=u[d],h=C(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(w(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=C(e,t),c=await i.detectOverflow(t,s),l=w(n),u=T(n),d=O(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=g(p-c[m],v),x=g(f-c[h],y),S=t.middlewareData.shift,E=!S,D=b,k=x;S!=null&&S.enabled.x&&(k=y),S!=null&&S.enabled.y&&(D=v),E&&!u&&(d?k=f-2*_(c.left,c.right):D=p-2*_(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:D});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function V(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return _e()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return _e()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(V(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,Te;function Ee(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Oe()&&(K(t.backdropFilter)||K(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function De(e){let t=Y(e);for(;G(t)&&!q(t);){if(Ee(t))return t;if(Se(t))return null;t=Y(t)}return null}function Oe(){return Te??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Te}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function ke(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||U(e);return ye(t)?t.host:t}function Ae(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&be(t)?t:Ae(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ae(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=je(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Me(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=v(n)!==a||v(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ne(e){return W(e)?e:e.contextElement}function Z(e){let t=Ne(e);if(!G(t))return b(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Me(t),o=(a?v(n.width):n.width)/r,s=(a?v(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Pe=b(0);function Fe(e){let t=H(e);return!Oe()||!t.visualViewport?Pe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ne(e),o=b(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Ie(a,n,r)?Fe(a):b(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=je(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=je(n)}}return B({width:u,height:d,x:c,y:l})}function Le(e,t){let n=ke(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Re(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Le(e,n),y:n.top+t.scrollTop}}function ze(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=b(1),u=b(0),d=G(r);if((d||!a)&&((V(r)!==`body`||be(o))&&(c=ke(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Re(o,c):b(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Be(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ve(e){let t=ke(e),n=e.ownerDocument.body,r=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Le(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=_(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var He=25;function Ue(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Oe()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Le(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=He&&(s-=o)}return{width:s,height:c,x:l,y:u}}function We(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ge(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ue(e,n,t);else if(t===`document`)r=Ve(U(e));else if(W(t))r=We(t,n);else{let n=Fe(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function Ke(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Ee(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:Ke(t,this._c):[].concat(n),r],o=Ge(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ge(t,a[e],i);s=_(n.top,s),c=g(n.right,c),l=g(n.bottom,l),u=_(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Je(e){let{width:t,height:n}=Me(e);return{width:t,height:n}}function Ye(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=b(0);if((r||!a)&&((V(t)!==`body`||be(i))&&(s=ke(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Le(i));let l=i&&!r&&!a?Re(i,s):b(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Xe(e){return J(e).position===`static`}function Ze(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Qe(e,t){let n=H(e);if(Se(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Xe(t))return t;t=Y(t)}return n}let r=Ze(e,t);for(;r&&xe(r)&&Xe(r);)r=Ze(r,t);return r&&q(r)&&Xe(r)&&!Ee(r)?n:r||De(e)||n}var $e=async function(e){let t=this.getOffsetParent||Qe,n=this.getDimensions,r=await n(e.floating);return{reference:Ye(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function et(e){return J(e).direction===`rtl`}var tt={convertOffsetParentRelativeRectToViewportRelativeRect:ze,getDocumentElement:U,getClippingRect:qe,getOffsetParent:Qe,getElementRects:$e,getClientRects:Be,getDimensions:Je,getScale:Z,isElement:W,isRTL:et};function nt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=y(d),h=y(a.clientWidth-(u+f)),v=y(a.clientHeight-(d+p)),b=y(u),x={rootMargin:-m+`px `+-h+`px `+-v+`px `+-b+`px`,threshold:_(0,g(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!nt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function it(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ne(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?rt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!nt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var at=pe,ot=me,st=se,ct=ge,lt=ue,ut=oe,dt=he,ft=(e,t,n)=>{let r=new Map,i=n??{},a={...tt,...i.platform,_c:r};return ae(e,t,{...i,platform:a})},pt=e(i(),1),mt=typeof document<`u`?m.useLayoutEffect:function(){};function ht(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ht(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ht(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function gt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _t(e,t){let n=gt(e);return Math.round(t*n)/n}function vt(e){let t=m.useRef(e);return mt(()=>{t.current=e}),t}function yt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);ht(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=vt(c),O=vt(i),k=vt(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),ft(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ht(T.current,t)&&(T.current=t,pt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);mt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);mt(()=>(j.current=!0,()=>{j.current=!1}),[]),mt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=_t(N.floating,u.x),r=_t(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...gt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var bt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ut({element:r.current,padding:i}).fn(n):r?ut({element:r,padding:i}).fn(n):{}}}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>({fn:dt(e).fn,options:[e,t]}),wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=lt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=bt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=n(),Ot=`Arrow`,kt=m.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(l.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});kt.displayName=Ot;var At=kt;function jt(e){let[t,n]=m.useState(void 0);return f(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Mt=`Popper`,[Nt,Pt]=u(Mt),[Ft,It]=Nt(Mt),Lt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,$.jsx)(Ft,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Lt.displayName=Mt;var Rt=`PopperAnchor`,zt=m.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=It(Rt,n),o=m.useRef(null),s=a.onAnchorChange,c=p(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),u=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&s(u.current)});let d=a.placementState&&Yt(a.placementState),f=d?.[0],h=d?.[1];return r?null:(0,$.jsx)(l.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...i,ref:c})});zt.displayName=Rt;var Bt=`PopperContent`,[Vt,Ht]=Nt(Bt),Ut=m.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=It(Bt,n),[S,C]=m.useState(null),w=p(t,C),[T,E]=m.useState(null),D=jt(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],N=M.length>0,P={padding:j,boundary:M.filter(qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=yt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>it(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[xt({mainAxis:i+k,alignmentAxis:o}),c&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),c&&wt({...P}),Tt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Dt({element:T,padding:s}),Jt({arrowWidth:O,arrowHeight:k}),_&&Et({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;f(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=d(y);f(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return f(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Vt,{scope:n,placedSide:te,placedAlign:B,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(l.div,{"data-side":te,"data-align":B,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Ut.displayName=Bt;var Wt=`PopperArrow`,Gt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Kt=m.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ht(Wt,n),a=Gt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(At,{...r,ref:t,style:{...r.style,display:`block`}})})});Kt.displayName=Wt;function qt(e){return e!==null}var Jt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Yt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Yt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Xt=Lt,Zt=zt,Qt=Ut,$t=Kt,en=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,tn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,nn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,rn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function an({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:a(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:a(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(l.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));cn.displayName=sn;var ln=cn;function un({className:e,...t}){return(0,$.jsx)(ln,{className:a(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=r(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),fn=r(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function pn(e){o.error(hn(e),{id:`err:${hn(e)}`})}function mn(e){if(!(e instanceof s)||e.code!==`conversation_live`)return null;let t=e.details?.existing_session_id,n=e.details?.existing_project_id;return typeof t==`string`&&typeof n==`string`?{sessionId:t,projectId:n}:null}function hn(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}function gn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:o,className:s,hintsClassName:c,autoFocus:l}){let[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),d(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),d(!0),p(0)},onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:e=>{if(!(!u||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),p(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),p(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[f]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),d(!1))},placeholder:o,className:s,autoComplete:`off`,spellCheck:!1,autoFocus:l}),u&&i.length>0&&(0,$.jsx)(`ul`,{className:a(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,c??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>p(t),className:a(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===f,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var _n=(0,m.lazy)(()=>c(()=>import(`./Terminal-Ct0grO8I.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),vn=null;async function yn(){vn=(await c(()=>import(`./Terminal-Ct0grO8I.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).Terminal}function bn(e){return vn?(0,$.jsx)(vn,{...e}):(0,$.jsx)(m.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(_n,{...e})})}export{Qt as _,pn as a,jt as b,un as c,en as d,rn as f,$t as g,Zt as h,mn as i,an as l,tn as m,yn as n,fn as o,nn as p,gn as r,dn as s,bn as t,on as u,Xt as v,Pt as y};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-DmMk3PAE.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/x-BJOrp_m5.js","assets/hotkeys-CekBkaTu.js","assets/file-links-DhiBZF5y.js","assets/index-CzVID1ZA.js","assets/preload-helper-Czpn1I53.js","assets/dialog-DjL0qoAv.js","assets/index-BBk5N4Nn.css","assets/use-find-controls-Bs5HCbAh.js","assets/chevron-down-59O6CgEo.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,o as i,r as a}from"./x-BJOrp_m5.js";import{Ht as o,xt as s}from"./hotkeys-CekBkaTu.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{C as l,D as u,S as d,b as f,k as p}from"./dialog-DjL0qoAv.js";var m=e(t(),1),h=[`top`,`right`,`bottom`,`left`],g=Math.min,_=Math.max,v=Math.round,y=Math.floor,b=e=>({x:e,y:e}),x={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function S(e,t,n){return _(e,g(t,n))}function C(e,t){return typeof e==`function`?e(t):e}function w(e){return e.split(`-`)[0]}function T(e){return e.split(`-`)[1]}function E(e){return e===`x`?`y`:`x`}function D(e){return e===`y`?`height`:`width`}function O(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function k(e){return E(O(e))}function A(e,t,n){n===void 0&&(n=!1);let r=T(e),i=k(e),a=D(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=z(o)),[o,z(o)]}function j(e){let t=z(e);return[M(e),t,M(t)]}function M(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var N=[`left`,`right`],P=[`right`,`left`],F=[`top`,`bottom`],I=[`bottom`,`top`];function L(e,t,n){switch(e){case`top`:case`bottom`:return n?t?P:N:t?N:P;case`left`:case`right`:return t?F:I;default:return[]}}function R(e,t,n,r){let i=T(e),a=L(w(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(M)))),a}function z(e){let t=w(e);return x[t]+e.slice(t.length)}function ee(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ne(e,t,n){let{reference:r,floating:i}=e,a=O(t),o=k(t),s=D(o),c=w(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=T(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function re(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=C(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ie=50,ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:re},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ne(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ie&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ne(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=C(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=k(i),m=D(p),h=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],w=f[p]-a.reference[p],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),O=E?E[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(E)))&&(O=s.floating[b]||a.floating[m]);let A=x/2-w/2,j=O/2-h[m]/2-1,M=g(d[v],j),N=g(d[y],j),P=O-h[m]-N,F=O/2-h[m]/2+A,I=S(M,F,P),L=!c.arrow&&T(i)!=null&&F!==I&&a.reference[m]/2-(F<M?M:N)-h[m]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=C(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=w(r),_=O(o),v=w(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[z(o)]:j(o)),x=p!==`none`;!d&&x&&b.push(...R(o,m,p,y));let S=[o,...b],T=await s.detectOverflow(t,h),E=[],D=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=A(r,a,y);E.push(T[e[0]],T[e[1]])}if(D=[...D,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==O(t))||D.every(e=>O(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=O(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return h.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=C(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=w(n),s=T(n),c=O(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=C(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=C(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=O(i),p=E(f),m=u[p],h=u[f],g=(e,t)=>S(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=C(e,t),u={x:n,y:r},d=O(i),f=E(d),p=u[f],m=u[d],h=C(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(w(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=C(e,t),c=await i.detectOverflow(t,s),l=w(n),u=T(n),d=O(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=g(p-c[m],v),x=g(f-c[h],y),S=t.middlewareData.shift,E=!S,D=b,k=x;S!=null&&S.enabled.x&&(k=y),S!=null&&S.enabled.y&&(D=v),E&&!u&&(d?k=f-2*_(c.left,c.right):D=p-2*_(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:D});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function V(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return _e()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return _e()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(V(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,Te;function Ee(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Oe()&&(K(t.backdropFilter)||K(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function De(e){let t=Y(e);for(;G(t)&&!q(t);){if(Ee(t))return t;if(Se(t))return null;t=Y(t)}return null}function Oe(){return Te??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Te}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function ke(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||U(e);return ye(t)?t.host:t}function Ae(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&be(t)?t:Ae(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ae(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=je(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Me(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=v(n)!==a||v(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ne(e){return W(e)?e:e.contextElement}function Z(e){let t=Ne(e);if(!G(t))return b(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Me(t),o=(a?v(n.width):n.width)/r,s=(a?v(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Pe=b(0);function Fe(e){let t=H(e);return!Oe()||!t.visualViewport?Pe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ne(e),o=b(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Ie(a,n,r)?Fe(a):b(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=je(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=je(n)}}return B({width:u,height:d,x:c,y:l})}function Le(e,t){let n=ke(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Re(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Le(e,n),y:n.top+t.scrollTop}}function ze(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=b(1),u=b(0),d=G(r);if((d||!a)&&((V(r)!==`body`||be(o))&&(c=ke(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Re(o,c):b(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Be(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ve(e){let t=ke(e),n=e.ownerDocument.body,r=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Le(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=_(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var He=25;function Ue(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Oe()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Le(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=He&&(s-=o)}return{width:s,height:c,x:l,y:u}}function We(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ge(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ue(e,n,t);else if(t===`document`)r=Ve(U(e));else if(W(t))r=We(t,n);else{let n=Fe(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function Ke(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Ee(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:Ke(t,this._c):[].concat(n),r],o=Ge(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ge(t,a[e],i);s=_(n.top,s),c=g(n.right,c),l=g(n.bottom,l),u=_(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Je(e){let{width:t,height:n}=Me(e);return{width:t,height:n}}function Ye(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=b(0);if((r||!a)&&((V(t)!==`body`||be(i))&&(s=ke(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Le(i));let l=i&&!r&&!a?Re(i,s):b(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Xe(e){return J(e).position===`static`}function Ze(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Qe(e,t){let n=H(e);if(Se(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Xe(t))return t;t=Y(t)}return n}let r=Ze(e,t);for(;r&&xe(r)&&Xe(r);)r=Ze(r,t);return r&&q(r)&&Xe(r)&&!Ee(r)?n:r||De(e)||n}var $e=async function(e){let t=this.getOffsetParent||Qe,n=this.getDimensions,r=await n(e.floating);return{reference:Ye(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function et(e){return J(e).direction===`rtl`}var tt={convertOffsetParentRelativeRectToViewportRelativeRect:ze,getDocumentElement:U,getClippingRect:qe,getOffsetParent:Qe,getElementRects:$e,getClientRects:Be,getDimensions:Je,getScale:Z,isElement:W,isRTL:et};function nt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=y(d),h=y(a.clientWidth-(u+f)),v=y(a.clientHeight-(d+p)),b=y(u),x={rootMargin:-m+`px `+-h+`px `+-v+`px `+-b+`px`,threshold:_(0,g(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!nt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function it(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ne(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?rt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!nt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var at=pe,ot=me,st=se,ct=ge,lt=ue,ut=oe,dt=he,ft=(e,t,n)=>{let r=new Map,i=n??{},a={...tt,...i.platform,_c:r};return ae(e,t,{...i,platform:a})},pt=e(i(),1),mt=typeof document<`u`?m.useLayoutEffect:function(){};function ht(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ht(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ht(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function gt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _t(e,t){let n=gt(e);return Math.round(t*n)/n}function vt(e){let t=m.useRef(e);return mt(()=>{t.current=e}),t}function yt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);ht(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=vt(c),O=vt(i),k=vt(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),ft(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ht(T.current,t)&&(T.current=t,pt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);mt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);mt(()=>(j.current=!0,()=>{j.current=!1}),[]),mt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=_t(N.floating,u.x),r=_t(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...gt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var bt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ut({element:r.current,padding:i}).fn(n):r?ut({element:r,padding:i}).fn(n):{}}}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>({fn:dt(e).fn,options:[e,t]}),wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=lt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=bt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=n(),Ot=`Arrow`,kt=m.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(l.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});kt.displayName=Ot;var At=kt;function jt(e){let[t,n]=m.useState(void 0);return f(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Mt=`Popper`,[Nt,Pt]=u(Mt),[Ft,It]=Nt(Mt),Lt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,$.jsx)(Ft,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Lt.displayName=Mt;var Rt=`PopperAnchor`,zt=m.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=It(Rt,n),o=m.useRef(null),s=a.onAnchorChange,c=p(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),u=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&s(u.current)});let d=a.placementState&&Yt(a.placementState),f=d?.[0],h=d?.[1];return r?null:(0,$.jsx)(l.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...i,ref:c})});zt.displayName=Rt;var Bt=`PopperContent`,[Vt,Ht]=Nt(Bt),Ut=m.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=It(Bt,n),[S,C]=m.useState(null),w=p(t,C),[T,E]=m.useState(null),D=jt(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(u)?u:[u],N=M.length>0,P={padding:j,boundary:M.filter(qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=yt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>it(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[xt({mainAxis:i+k,alignmentAxis:o}),c&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),c&&wt({...P}),Tt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Dt({element:T,padding:s}),Jt({arrowWidth:O,arrowHeight:k}),_&&Et({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;f(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=d(y);f(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return f(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Vt,{scope:n,placedSide:te,placedAlign:B,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(l.div,{"data-side":te,"data-align":B,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Ut.displayName=Bt;var Wt=`PopperArrow`,Gt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Kt=m.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ht(Wt,n),a=Gt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(At,{...r,ref:t,style:{...r.style,display:`block`}})})});Kt.displayName=Wt;function qt(e){return e!==null}var Jt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Yt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Yt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Xt=Lt,Zt=zt,Qt=Ut,$t=Kt,en=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,tn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,nn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,rn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function an({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:a(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:a(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(l.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));cn.displayName=sn;var ln=cn;function un({className:e,...t}){return(0,$.jsx)(ln,{className:a(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=r(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),fn=r(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function pn(e){o.error(hn(e),{id:`err:${hn(e)}`})}function mn(e){if(!(e instanceof s)||e.code!==`conversation_live`)return null;let t=e.details?.existing_session_id,n=e.details?.existing_project_id;return typeof t==`string`&&typeof n==`string`?{sessionId:t,projectId:n}:null}function hn(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}function gn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:o,className:s,hintsClassName:c,autoFocus:l}){let[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),d(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),d(!0),p(0)},onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:e=>{if(!(!u||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),p(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),p(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[f]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),d(!1))},placeholder:o,className:s,autoComplete:`off`,spellCheck:!1,autoFocus:l}),u&&i.length>0&&(0,$.jsx)(`ul`,{className:a(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,c??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>p(t),className:a(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===f,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var _n=(0,m.lazy)(()=>c(()=>import(`./Terminal-DmMk3PAE.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),vn=null;async function yn(){vn=(await c(()=>import(`./Terminal-DmMk3PAE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))).Terminal}function bn(e){return vn?(0,$.jsx)(vn,{...e}):(0,$.jsx)(m.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(_n,{...e})})}export{Qt as _,pn as a,jt as b,un as c,en as d,rn as f,$t as g,Zt as h,mn as i,an as l,tn as m,yn as n,fn as o,nn as p,gn as r,dn as s,bn as t,on as u,Xt as v,Pt as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-BXopEwK6.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(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{c as n,o as r,t as i}from"./buffer-store-Ch_ccGob.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n}from"./x-BJOrp_m5.js";import{Ct as r,Ht as i,R as a,c as o,p as s,qt as c,v as l,xt as u}from"./hotkeys-CekBkaTu.js";import{A as d,B as f,D as p,F as m,M as h,N as g,O as _,P as v,S as y,a as b,d as x,f as S,g as ee,m as te,n as ne,o as re,p as ie,v as ae,w as oe}from"./editor-context-DBjXfTll.js";import{t as se}from"./preload-helper-Czpn1I53.js";import{a as ce,n as le,r as ue,t as de}from"./use-find-controls-Dsils9K4.js";import{F as fe,I as C,It as pe,L as me,Lt as he,P as ge,R as _e,Rt as ve,a as ye,ht as be,z as xe}from"./index-BsC4i0JY.js";import{c as w,i as Se,p as T,r as Ce}from"./editor.api2-4X9Vh9Zw.js";import{a as we,c as Te,d as Ee,f as De,i as Oe,l as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe,u as Fe}from"./buffer-store-BXopEwK6.js";import{i as Ie,n as Le,r as Re,t as ze}from"./drafts-BJ4bJnkA.js";import{r as Be}from"./buffer-logic-BAkSBQT7.js";import{a as Ve,i as He,n as Ue,o as We,r as Ge}from"./editor-sync-W1bamxAP.js";var E=e(t(),1),Ke=new Map,qe=new Map,Je=1;function Ye(e){for(let t of qe.get(e)??[])t()}function Xe(e,t){Ke.set(e,t),Ye(e)}function Ze(e){let t={phase:`unresolved`,revision:Je++};return Xe(e,t),t}function Qe(e){let t=Ke.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(Xe(e,{phase:`loading`,revision:t.revision}),t.revision)}function $e(e,t,n,r){let i=Ke.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(Xe(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function et(e,t){let n=Ke.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(Xe(e,{...n,phase:`comparing`}),!0)}function tt(e,t,n){let r=Ke.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(Xe(e,{phase:`load-error`,revision:t,message:n}),!0)}function nt(e,t){return t&&e?.phase===`unresolved`}function rt(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function it(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function at(e){return e.phase===`opening`||e.phase===`comparing`}function ot(e){Ke.delete(e)&&Ye(e)}function st(e){return Ke.get(e)??null}function ct(e,t){let n=qe.get(e);return n||(n=new Set,qe.set(e,n)),n.add(t),()=>n.delete(t)}function lt(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var D=n();function ut({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=ve(),l=(0,E.useId)(),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,E.useRef)(o);d.current=o;let f=(0,E.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,E.useRef)(p);return m.current=p,(0,E.useEffect)(()=>()=>m.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(je,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:Ee,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(Se.CtrlCmd|Ce.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...lt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function dt({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:at(i)&&n.model?(0,D.jsx)(ut,{session:e,path:t,conflict:i,model:n.model,onTakeDisk:n.takeDisk,onKeepMine:n.keepMine,onSave:n.save,onReady:r?n.comparisonReady:void 0}):i.phase===`load-error`?(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground px-4 text-center text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,D.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,D.jsx)(`button`,{type:`button`,onClick:n.compare,className:`rounded-md bg-elevated px-3 py-1.5 text-xs text-fg-secondary transition-colors hover:bg-border hover:text-fg`,children:`Retry compare`})]}):(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}function O(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function ft(e,t,n){return O(e/Math.max(1,t-n))}function pt(e,t,n){return O(e)*Math.max(0,t-n)}function mt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var ht=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n){let r={ratio:O(n),revision:++this.revision},i=mt(e,t);this.positions.set(i,r);for(let e of this.listeners.get(i)??[])e(r);return r}get(e,t){return this.positions.get(mt(e,t))}subscribe(e,t,n){let r=mt(e,t),i=this.listeners.get(r);i||(i=new Set,this.listeners.set(r,i)),i.add(n);let a=this.positions.get(r);return a&&n(a),()=>{i?.delete(n),i?.size===0&&this.listeners.delete(r)}}};function gt(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function _t(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??ht,r,i=()=>void 0,a,o=t=>{r=t,e.scrollTop=pt(t.ratio,e.scrollHeight,e.clientHeight)};t.receiver?i=n.subscribe(t.channel,t.target,o):t.driver&&(a=gt(()=>{n.publish(t.channel,t.target,ft(e.scrollTop,e.scrollHeight,e.clientHeight))}),e.addEventListener(`scroll`,a.schedule,{passive:!0}),a.schedule());let s=new ResizeObserver(()=>{t.receiver&&r?o(r):t.driver&&a?.schedule()});for(let e of t.resizeElements??[])s.observe(e);return()=>{t.driver&&a&&e.removeEventListener(`scroll`,a.schedule),i(),s.disconnect(),a?.dispose()}}function vt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??ht,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t,e.setScrollTop(pt(t.ratio,e.getScrollHeight(),c()),n)};return t.receiver?(o=r.subscribe(t.channel,t.target,l),i.push(e.onDidChangeModel(()=>a&&l(a))),i.push(e.onDidLayoutChange(()=>a&&l(a)))):t.driver&&(s=gt(()=>{r.publish(t.channel,t.target,ft(e.getScrollTop(),e.getScrollHeight(),c()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function yt(e){return!e}function bt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=Se.CtrlCmd:e===`ctrl`?r|=Se.WinCtrl:e===`alt`?r|=Se.Alt:e===`shift`&&(r|=Se.Shift);let i=Ce[/^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 xt(e,t){let n=bt(o(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=bt(o(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>he({editorWordWrap:yt(pe().editorWordWrap)})})}function St(e){return`file-conflict:${e}`}function Ct(e,t,n,r,a){let o=a?.passive===!0,s=a?.focused??!0,c=Pe(e,t,r),l=m(e,t,{root:r,live:a?.live}),d=g(e,r),[f,p]=(0,E.useState)(null),[h,_]=(0,E.useState)(!1),v=(0,E.useRef)(!1),y=(0,E.useRef)(null),b=(0,E.useRef)(null),x=(0,E.useRef)(n);x.current=n;let S=(0,E.useRef)(!1),te=(0,E.useCallback)((e,t)=>{b.current?.cancel(),S.current=!0;try{Ne(c,e,t)}finally{S.current=!1}},[c]),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Fe(c,e),[c]),()=>Oe(c)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>We(c,e),[c]),()=>Ve(c)),ie=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ct(c,e),[c]),()=>st(c));(0,E.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||v.current)return;v.current=!0;let a=ke(c)!==void 0,o=Me(e,t,n.content,n.mtime_ms,r),s=o.getValue();p(o),!a&&Ie(e,t,r).then(a=>{if(!a)return;let c=Le(a,s,n.mtime_ms);c===`discard`?ze(e,t,r):c===`restore`?Be(o,a.content)&&_(!0):i(`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:()=>{Be(o,a.content)&&_(!0)}}})})},[l.data,c,e,t,r]),(0,E.useEffect)(()=>{if(!f||o)return;let n=Re(e,t,r);b.current=n;let i=f.onDidChangeContent(()=>{S.current||(n(f.getValue(),ke(c)??0),Ue(e,t,r))});return()=>{n.flush(),i.dispose(),b.current=null}},[f,c,e,t,r,o]),(0,E.useEffect)(()=>{!f||!re.savedElsewhere||Oe(c)||l.refetch().then(e=>{Oe(c)||(e.data&&e.data.content!==null&&te(e.data.content,e.data.mtime_ms),He(c))})},[re.savedElsewhere,f,c]),(0,E.useEffect)(()=>{let e=l.data;!f||!e||e.content===null||!Oe(c)&&e.mtime_ms!==ke(c)&&te(e.content,e.mtime_ms)},[l.data,f,c]);let oe=(0,E.useCallback)((n,i)=>{we(c,n,i),b.current?.cancel(),ze(e,t,r),Ge(e,t,i,r),_(!1),ot(c)},[c,e,t,r]),se=(0,E.useCallback)(()=>{let e=Qe(c);e!==null&&(i.dismiss(St(c)),l.refetch({throwOnError:!0}).then(t=>{let n=t.data;if(!n)throw Error(`The disk version did not load.`);if(n.content===null)throw Error(`The file on disk is binary and cannot be compared as text.`);$e(c,e,n.content,n.mtime_ms)}).catch(t=>{tt(c,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[l,c]),ce=(0,E.useRef)(se);ce.current=se,(0,E.useEffect)(()=>{if(!nt(ie,s))return;let e=St(c);return i(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>ce.current()}}),()=>{i.dismiss(e)}},[ie,s,c]);let le=(0,E.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&te(n.data.content,n.data.mtime_ms),ze(e,t,r),_(!1),ot(c)})},[c,e,t,te]),ue=(0,E.useCallback)((e,n)=>{d.mutate({path:t,content:e},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>i.error(e instanceof Error?e.message:`Overwrite failed`)})},[d,t,oe]),de=(0,E.useCallback)(()=>{if(!f||!Oe(c))return;let e=f.getValue(),n=f.getAlternativeVersionId();if(it(st(c)))return;let r=rt(st(c))??ke(c);d.mutate({path:t,content:e,expected_mtime_ms:r},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>{e instanceof u&&e.status===409&&e.code===`stale_file`?Ze(c):i.error(e instanceof Error?e.message:`Save failed`)}})},[f,c,d,t,oe]),fe=(0,E.useRef)(de);fe.current=de,(0,E.useEffect)(()=>ee(ae(e,t,r),()=>fe.current()),[e,t,r]);let C=(0,E.useCallback)(()=>{let n=y.current,i=x.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),pe=(0,E.useCallback)(e=>{y.current=e,xt(e,{onSave:()=>fe.current()}),C()},[C]);(0,E.useEffect)(()=>{C()},[n,f,C]);let me=(0,E.useCallback)(()=>{le()},[le]),he=(0,E.useCallback)(()=>{!f||st(c)?.phase!==`comparing`||ue(f.getValue(),f.getAlternativeVersionId())},[f,c,ue]),ge=(0,E.useCallback)(e=>{et(c,e)},[c]),_e,ve=null;l.data?.binary?_e=`binary`:l.error?l.error instanceof u&&l.error.status===413?_e=`too-large`:(_e=`error`,ve=l.error instanceof Error?l.error.message:`Failed to load file`):_e=f?`ready`:`loading`;let ye=ne&&re.savedElsewhere?`saved-elsewhere`:ne&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:_e,errorMessage:ve,model:f,dirty:ne,restoredNotice:h,discardRestore:me,peerBadge:ye,conflict:ie,takeDisk:le,keepMine:he,compare:se,comparisonReady:ge,save:de,onMount:pe}}function wt(e,t,n,r){for(let i of e)if(kt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function Tt(e,t){return Dt(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function Et(e){let t=Dt(e.originalStartLineNumber,e.originalEndLineNumber),n=Dt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function Dt(e,t){return t===0?0:Math.max(0,t-e+1)}function Ot(e,t){if(e>t)return{startLineNumber:Math.max(1,t),endLineNumber:Math.max(1,t),kind:`deleted-after`};let n=Math.max(1,e);return{startLineNumber:n,endLineNumber:n,kind:`deleted-before`}}function kt(e,t){let n=[];for(let r of e){let e=Dt(r.originalStartLineNumber,r.originalEndLineNumber),i=Dt(r.modifiedStartLineNumber,r.modifiedEndLineNumber);if(e===0&&i>0){n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedEndLineNumber,kind:`added`});continue}if(i===0&&e>0){n.push(Ot(r.modifiedStartLineNumber,t));continue}let a=Math.min(e,i);a>0&&n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedStartLineNumber+a-1,kind:`modified`}),i>a&&n.push({startLineNumber:r.modifiedStartLineNumber+a,endLineNumber:r.modifiedEndLineNumber,kind:`added`}),e>a&&n.push(Ot(r.modifiedStartLineNumber+i,t))}return n}var At=28,jt=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function Mt(e){if(e){for(let[t,n]of jt)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function Nt({editor:e,original:t,modified:n,path:r}){let i=[],a=null,o=!1,s=t=>{try{e.changeViewZones(e=>e.removeZone(t))}catch{}},c=()=>{let e=a;e&&(a=null,e.frame!==null&&cancelAnimationFrame(e.frame),e.diffEditor&&(e.diffEditor.setModel(null),e.diffEditor.dispose()),s(e.zoneId))},l=e=>{let t=e.diffEditor;if(!t)return;let r=Math.max(1,Math.min(n.getLineCount(),e.change.modifiedStartLineNumber));t.getModifiedEditor().revealLineInCenter(r,T.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(T.EditorOption.lineHeight),d=document.createElement(`div`);d.className=`puddle-dirty-peek`;let f=document.createElement(`div`);f.className=`puddle-dirty-peek-header`;let p=document.createElement(`span`);p.className=`puddle-dirty-peek-title`,p.textContent=`${r.split(`/`).pop()??r} · Local changes against HEAD`;let m=document.createElement(`button`);m.type=`button`,m.className=`puddle-dirty-peek-close`,m.setAttribute(`aria-label`,`Close inline change`),m.title=`Close inline change`,m.textContent=`×`,m.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),c()}),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),c()});let h=document.createElement(`div`);h.className=`puddle-dirty-peek-editor`,f.append(p,m),d.append(f,h);let g=document.createElement(`div`);g.className=`puddle-dirty-peek-margin`;let _={afterLineNumber:Tt(s,n.getLineCount()),heightInPx:At+Et(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=T.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(T.EditorOption.fontFamily),fontSize:e.getOption(T.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==T.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=wt(i,t,n.getLineCount(),Mt(e.target.element));r&&(e.event.preventDefault(),e.event.stopPropagation(),u(t,r))});return{update(t){if(i=t,!a)return;let r=a,o=wt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=Tt(o,n.getLineCount()),r.zone.heightInPx=At+Et(o)*e.getOption(T.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var Pt={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function Ft(e,t,n,r){let i=a(),o=d(e,t,{root:n,enabled:i.data!==void 0&&be(i.data.protocol)&&r!==null}),[s,c]=(0,E.useState)(null),l=(0,E.useCallback)(e=>{c(e)},[]);return(0,E.useEffect)(()=>{let e=o.data;if(!s||!r||!e||e.repository===null||e.ignored||e.binary)return;let n=document.createElement(`div`);n.className=`puddle-hidden-diff-controller`,document.body.appendChild(n);let i=T.createModel(e.exists?e.content??``:``,r.getLanguageId()),a=T.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:i,modified:r});let l=Nt({editor:s,original:i,modified:r,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(kt(e,r.getLineCount()).map(e=>({range:new w(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:Pt[e.kind]}}))))},d=a.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),a.setModel(null),a.dispose(),i.dispose(),n.remove()}},[s,r,o.data]),l}function It({message:e,session:t,path:n,root:r,download:a}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),a&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void y(t,n,r).catch(e=>i.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-4`}),`Download`]})]})}function Lt({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=ve(),l=Ct(e,t,n,r,{focused:i}),u=Ft(e,t,r,l.model),d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[f,p]=(0,E.useState)(null),m=(0,E.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),h=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,E.useEffect)(()=>{if(!(!f||!l.model||h))return vt(f,{channel:s,target:m,driver:a,receiver:o},T.ScrollType.Immediate)},[f,l.model,h,s,m,a,o]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,D.jsx)(dt,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,D.jsx)(It,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,D.jsx)(It,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,D.jsx)(It,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let g=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),g&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:g}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,D.jsx)(De,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),u(e),p(e)},loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:d,fontSize:c.editorFontSize,...lt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Rt(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(Te(e),()=>{n.current?.(),Ae(e)}),[e])}function zt(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Bt({session:e,refName:t,path:n,content:r}){let i=ve(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(De,{path:zt(`puddle-view`,e,t,n),defaultValue:r,theme:Ee,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...lt(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Vt({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=_(e,t,n,{root:r,enabled:!i}),o=h(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,D.jsx)(k,{children:`…`}):s.error?(0,D.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,D.jsx)(k,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(Bt,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function Ht({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=ve(),c=Ct(e,n,null,i,{focused:o}),l=_(e,t,r,{root:i,enabled:!a}),d=h(e,r,{root:i,enabled:a}),f=a?d:l,p=(0,E.useRef)(null);Rt(Pe(e,n,i),()=>{let e=p.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),p.current=null});let m=(0,E.useRef)(c.save);m.current=c.save;let g=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),v=f.error instanceof u&&f.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,D.jsx)(dt,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||f.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):c.status===`too-large`?(0,D.jsx)(k,{children:`File too large to show`}):c.status===`error`?(0,D.jsx)(k,{children:c.errorMessage??`Failed to load file`}):v||a&&d.data&&!d.data.exists?(0,D.jsx)(Lt,{session:e,path:n,reveal:null,root:i,focused:o}):f.isPending||!c.model?(0,D.jsx)(k,{children:`…`}):f.error?(0,D.jsx)(k,{children:f.error instanceof Error?f.error.message:`Failed to load base`}):(0,D.jsx)(je,{modifiedModelPath:c.model.uri.toString(),originalModelPath:zt(`puddle-base`,e,`${t}:${i??``}`,r),original:f.data.content??``,language:c.model.getLanguageId(),theme:Ee,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{p.current=e,e.onDidDispose(()=>{p.current=null}),e.getModifiedEditor().addCommand(Se.CtrlCmd|Ce.KeyS,()=>m.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...lt(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ut({session:e,against:t,entry:n,root:r}){let i=ve(),a=n.old_path??n.path,o=_(e,t,a,{root:r,enabled:n.status!==`added`}),s=h(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,D.jsx)(Vt,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,D.jsx)(k,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,D.jsx)(k,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):n.status===`added`?(0,D.jsx)(Bt,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,D.jsx)(je,{originalModelPath:zt(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:zt(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Ee,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...lt(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,D.jsx)(k,{children:`Failed to load HEAD content`})}function Wt({session:e,path:t,root:n,focused:r}){return Rt(Pe(e,t,n)),(0,D.jsx)(Lt,{session:e,path:t,reveal:null,root:n,focused:r})}function Gt({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,D.jsx)(Ut,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,D.jsx)(Wt,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,D.jsx)(Vt,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,D.jsx)(Ht,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function Kt({session:e,sha:t,path:n,root:r}){let i=_(e,t,n,{root:r});return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(Bt,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function qt({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=ve(),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,D.jsx)(je,{originalModelPath:zt(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:zt(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Ee,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...lt(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Jt({session:e,sha:t,path:n,basePath:r,root:i}){let a=_(e,`${t}^`,r,{root:i}),o=_(e,t,n,{root:i});return a.error instanceof u&&a.error.status===404?(0,D.jsx)(Kt,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,D.jsx)(k,{children:`…`}):a.error?(0,D.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,D.jsx)(k,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(qt,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function Yt({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(te(n.status,r)){case`added`:return(0,D.jsx)(Kt,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,D.jsx)(Vt,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,D.jsx)(Jt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function Xt({session:e,sha:t,path:n,root:r}){let i=p(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Yt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Zt({session:e,path:t,root:n,area:r,focused:i=!0}){let a=v(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(a.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(a.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load diff`});let o=a.data.entries.find(e=>e.path===t);return o?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Gt,{session:e,against:a.data.against,entry:o,root:n,area:r,focused:i})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Qt=800;function $t({name:e}){let t=ve(),n=l(),r=ie(n,e),a=c(),o=s(`editor.save`),u=(0,E.useRef)(null),d=(0,E.useRef)(null),f=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=ye(t=>{x(n,e,t).catch(e=>i.error(e instanceof Error?e.message:`Draft not saved`))},Qt);return d.current=t,()=>{t.flush(),d.current=null}},[n,e]),n===null)return null;if(r.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load the draft`});if(r.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let p=()=>{let t=u.current;t&&(d.current?.flush(),re({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(De,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Ee,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{u.current=t,b(e,t.getValue()),xt(t,{onSave:p})},onChange:t=>{let r=t??``;b(e,r),S(a,n,e,r),d.current?.(r)},options:{automaticLayout:!0,fontFamily:f,fontSize:t.editorFontSize,...lt(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function en(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 tn(e){if(Array.isArray(e))return e}function nn(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 rn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n}from"./x-BJOrp_m5.js";import{Ct as r,Ht as i,R as a,c as o,p as s,qt as c,v as l,xt as u}from"./hotkeys-CekBkaTu.js";import{A as d,B as f,D as p,F as m,M as h,N as g,O as _,P as v,S as y,a as b,d as x,f as S,g as ee,m as te,n as ne,o as re,p as ie,v as ae,w as oe}from"./editor-context-DBjXfTll.js";import{t as se}from"./preload-helper-Czpn1I53.js";import{a as ce,n as le,r as ue,t as de}from"./use-find-controls-Bs5HCbAh.js";import{F as fe,I as C,It as pe,L as me,Lt as he,P as ge,R as _e,Rt as ve,a as ye,ht as be,z as xe}from"./index-CzVID1ZA.js";import{c as w,i as Se,p as T,r as Ce}from"./editor.api2-4X9Vh9Zw.js";import{a as we,c as Te,d as Ee,f as De,i as Oe,l as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe,u as Fe}from"./buffer-store-Ch_ccGob.js";import{i as Ie,n as Le,r as Re,t as ze}from"./drafts-CyZAHsxG.js";import{r as Be}from"./buffer-logic-BAkSBQT7.js";import{a as Ve,i as He,n as Ue,o as We,r as Ge}from"./editor-sync-W1bamxAP.js";var E=e(t(),1),Ke=new Map,qe=new Map,Je=1;function Ye(e){for(let t of qe.get(e)??[])t()}function Xe(e,t){Ke.set(e,t),Ye(e)}function Ze(e){let t={phase:`unresolved`,revision:Je++};return Xe(e,t),t}function Qe(e){let t=Ke.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(Xe(e,{phase:`loading`,revision:t.revision}),t.revision)}function $e(e,t,n,r){let i=Ke.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(Xe(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function et(e,t){let n=Ke.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(Xe(e,{...n,phase:`comparing`}),!0)}function tt(e,t,n){let r=Ke.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(Xe(e,{phase:`load-error`,revision:t,message:n}),!0)}function nt(e,t){return t&&e?.phase===`unresolved`}function rt(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function it(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function at(e){return e.phase===`opening`||e.phase===`comparing`}function ot(e){Ke.delete(e)&&Ye(e)}function st(e){return Ke.get(e)??null}function ct(e,t){let n=qe.get(e);return n||(n=new Set,qe.set(e,n)),n.add(t),()=>n.delete(t)}function lt(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var D=n();function ut({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=ve(),l=(0,E.useId)(),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,E.useRef)(o);d.current=o;let f=(0,E.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,E.useRef)(p);return m.current=p,(0,E.useEffect)(()=>()=>m.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(je,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:Ee,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(Se.CtrlCmd|Ce.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...lt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function dt({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:at(i)&&n.model?(0,D.jsx)(ut,{session:e,path:t,conflict:i,model:n.model,onTakeDisk:n.takeDisk,onKeepMine:n.keepMine,onSave:n.save,onReady:r?n.comparisonReady:void 0}):i.phase===`load-error`?(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground px-4 text-center text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,D.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,D.jsx)(`button`,{type:`button`,onClick:n.compare,className:`rounded-md bg-elevated px-3 py-1.5 text-xs text-fg-secondary transition-colors hover:bg-border hover:text-fg`,children:`Retry compare`})]}):(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}function O(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function ft(e,t,n){return O(e/Math.max(1,t-n))}function pt(e,t,n){return O(e)*Math.max(0,t-n)}function mt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var ht=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n){let r={ratio:O(n),revision:++this.revision},i=mt(e,t);this.positions.set(i,r);for(let e of this.listeners.get(i)??[])e(r);return r}get(e,t){return this.positions.get(mt(e,t))}subscribe(e,t,n){let r=mt(e,t),i=this.listeners.get(r);i||(i=new Set,this.listeners.set(r,i)),i.add(n);let a=this.positions.get(r);return a&&n(a),()=>{i?.delete(n),i?.size===0&&this.listeners.delete(r)}}};function gt(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function _t(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??ht,r,i=()=>void 0,a,o=t=>{r=t,e.scrollTop=pt(t.ratio,e.scrollHeight,e.clientHeight)};t.receiver?i=n.subscribe(t.channel,t.target,o):t.driver&&(a=gt(()=>{n.publish(t.channel,t.target,ft(e.scrollTop,e.scrollHeight,e.clientHeight))}),e.addEventListener(`scroll`,a.schedule,{passive:!0}),a.schedule());let s=new ResizeObserver(()=>{t.receiver&&r?o(r):t.driver&&a?.schedule()});for(let e of t.resizeElements??[])s.observe(e);return()=>{t.driver&&a&&e.removeEventListener(`scroll`,a.schedule),i(),s.disconnect(),a?.dispose()}}function vt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??ht,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t,e.setScrollTop(pt(t.ratio,e.getScrollHeight(),c()),n)};return t.receiver?(o=r.subscribe(t.channel,t.target,l),i.push(e.onDidChangeModel(()=>a&&l(a))),i.push(e.onDidLayoutChange(()=>a&&l(a)))):t.driver&&(s=gt(()=>{r.publish(t.channel,t.target,ft(e.getScrollTop(),e.getScrollHeight(),c()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function yt(e){return!e}function bt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=Se.CtrlCmd:e===`ctrl`?r|=Se.WinCtrl:e===`alt`?r|=Se.Alt:e===`shift`&&(r|=Se.Shift);let i=Ce[/^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 xt(e,t){let n=bt(o(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=bt(o(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>he({editorWordWrap:yt(pe().editorWordWrap)})})}function St(e){return`file-conflict:${e}`}function Ct(e,t,n,r,a){let o=a?.passive===!0,s=a?.focused??!0,c=Pe(e,t,r),l=m(e,t,{root:r,live:a?.live}),d=g(e,r),[f,p]=(0,E.useState)(null),[h,_]=(0,E.useState)(!1),v=(0,E.useRef)(!1),y=(0,E.useRef)(null),b=(0,E.useRef)(null),x=(0,E.useRef)(n);x.current=n;let S=(0,E.useRef)(!1),te=(0,E.useCallback)((e,t)=>{b.current?.cancel(),S.current=!0;try{Ne(c,e,t)}finally{S.current=!1}},[c]),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Fe(c,e),[c]),()=>Oe(c)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>We(c,e),[c]),()=>Ve(c)),ie=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>ct(c,e),[c]),()=>st(c));(0,E.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||v.current)return;v.current=!0;let a=ke(c)!==void 0,o=Me(e,t,n.content,n.mtime_ms,r),s=o.getValue();p(o),!a&&Ie(e,t,r).then(a=>{if(!a)return;let c=Le(a,s,n.mtime_ms);c===`discard`?ze(e,t,r):c===`restore`?Be(o,a.content)&&_(!0):i(`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:()=>{Be(o,a.content)&&_(!0)}}})})},[l.data,c,e,t,r]),(0,E.useEffect)(()=>{if(!f||o)return;let n=Re(e,t,r);b.current=n;let i=f.onDidChangeContent(()=>{S.current||(n(f.getValue(),ke(c)??0),Ue(e,t,r))});return()=>{n.flush(),i.dispose(),b.current=null}},[f,c,e,t,r,o]),(0,E.useEffect)(()=>{!f||!re.savedElsewhere||Oe(c)||l.refetch().then(e=>{Oe(c)||(e.data&&e.data.content!==null&&te(e.data.content,e.data.mtime_ms),He(c))})},[re.savedElsewhere,f,c]),(0,E.useEffect)(()=>{let e=l.data;!f||!e||e.content===null||!Oe(c)&&e.mtime_ms!==ke(c)&&te(e.content,e.mtime_ms)},[l.data,f,c]);let oe=(0,E.useCallback)((n,i)=>{we(c,n,i),b.current?.cancel(),ze(e,t,r),Ge(e,t,i,r),_(!1),ot(c)},[c,e,t,r]),se=(0,E.useCallback)(()=>{let e=Qe(c);e!==null&&(i.dismiss(St(c)),l.refetch({throwOnError:!0}).then(t=>{let n=t.data;if(!n)throw Error(`The disk version did not load.`);if(n.content===null)throw Error(`The file on disk is binary and cannot be compared as text.`);$e(c,e,n.content,n.mtime_ms)}).catch(t=>{tt(c,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[l,c]),ce=(0,E.useRef)(se);ce.current=se,(0,E.useEffect)(()=>{if(!nt(ie,s))return;let e=St(c);return i(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>ce.current()}}),()=>{i.dismiss(e)}},[ie,s,c]);let le=(0,E.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&te(n.data.content,n.data.mtime_ms),ze(e,t,r),_(!1),ot(c)})},[c,e,t,te]),ue=(0,E.useCallback)((e,n)=>{d.mutate({path:t,content:e},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>i.error(e instanceof Error?e.message:`Overwrite failed`)})},[d,t,oe]),de=(0,E.useCallback)(()=>{if(!f||!Oe(c))return;let e=f.getValue(),n=f.getAlternativeVersionId();if(it(st(c)))return;let r=rt(st(c))??ke(c);d.mutate({path:t,content:e,expected_mtime_ms:r},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>{e instanceof u&&e.status===409&&e.code===`stale_file`?Ze(c):i.error(e instanceof Error?e.message:`Save failed`)}})},[f,c,d,t,oe]),fe=(0,E.useRef)(de);fe.current=de,(0,E.useEffect)(()=>ee(ae(e,t,r),()=>fe.current()),[e,t,r]);let C=(0,E.useCallback)(()=>{let n=y.current,i=x.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),pe=(0,E.useCallback)(e=>{y.current=e,xt(e,{onSave:()=>fe.current()}),C()},[C]);(0,E.useEffect)(()=>{C()},[n,f,C]);let me=(0,E.useCallback)(()=>{le()},[le]),he=(0,E.useCallback)(()=>{!f||st(c)?.phase!==`comparing`||ue(f.getValue(),f.getAlternativeVersionId())},[f,c,ue]),ge=(0,E.useCallback)(e=>{et(c,e)},[c]),_e,ve=null;l.data?.binary?_e=`binary`:l.error?l.error instanceof u&&l.error.status===413?_e=`too-large`:(_e=`error`,ve=l.error instanceof Error?l.error.message:`Failed to load file`):_e=f?`ready`:`loading`;let ye=ne&&re.savedElsewhere?`saved-elsewhere`:ne&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:_e,errorMessage:ve,model:f,dirty:ne,restoredNotice:h,discardRestore:me,peerBadge:ye,conflict:ie,takeDisk:le,keepMine:he,compare:se,comparisonReady:ge,save:de,onMount:pe}}function wt(e,t,n,r){for(let i of e)if(kt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function Tt(e,t){return Dt(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function Et(e){let t=Dt(e.originalStartLineNumber,e.originalEndLineNumber),n=Dt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function Dt(e,t){return t===0?0:Math.max(0,t-e+1)}function Ot(e,t){if(e>t)return{startLineNumber:Math.max(1,t),endLineNumber:Math.max(1,t),kind:`deleted-after`};let n=Math.max(1,e);return{startLineNumber:n,endLineNumber:n,kind:`deleted-before`}}function kt(e,t){let n=[];for(let r of e){let e=Dt(r.originalStartLineNumber,r.originalEndLineNumber),i=Dt(r.modifiedStartLineNumber,r.modifiedEndLineNumber);if(e===0&&i>0){n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedEndLineNumber,kind:`added`});continue}if(i===0&&e>0){n.push(Ot(r.modifiedStartLineNumber,t));continue}let a=Math.min(e,i);a>0&&n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedStartLineNumber+a-1,kind:`modified`}),i>a&&n.push({startLineNumber:r.modifiedStartLineNumber+a,endLineNumber:r.modifiedEndLineNumber,kind:`added`}),e>a&&n.push(Ot(r.modifiedStartLineNumber+i,t))}return n}var At=28,jt=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function Mt(e){if(e){for(let[t,n]of jt)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function Nt({editor:e,original:t,modified:n,path:r}){let i=[],a=null,o=!1,s=t=>{try{e.changeViewZones(e=>e.removeZone(t))}catch{}},c=()=>{let e=a;e&&(a=null,e.frame!==null&&cancelAnimationFrame(e.frame),e.diffEditor&&(e.diffEditor.setModel(null),e.diffEditor.dispose()),s(e.zoneId))},l=e=>{let t=e.diffEditor;if(!t)return;let r=Math.max(1,Math.min(n.getLineCount(),e.change.modifiedStartLineNumber));t.getModifiedEditor().revealLineInCenter(r,T.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(T.EditorOption.lineHeight),d=document.createElement(`div`);d.className=`puddle-dirty-peek`;let f=document.createElement(`div`);f.className=`puddle-dirty-peek-header`;let p=document.createElement(`span`);p.className=`puddle-dirty-peek-title`,p.textContent=`${r.split(`/`).pop()??r} · Local changes against HEAD`;let m=document.createElement(`button`);m.type=`button`,m.className=`puddle-dirty-peek-close`,m.setAttribute(`aria-label`,`Close inline change`),m.title=`Close inline change`,m.textContent=`×`,m.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),c()}),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),c()});let h=document.createElement(`div`);h.className=`puddle-dirty-peek-editor`,f.append(p,m),d.append(f,h);let g=document.createElement(`div`);g.className=`puddle-dirty-peek-margin`;let _={afterLineNumber:Tt(s,n.getLineCount()),heightInPx:At+Et(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=T.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(T.EditorOption.fontFamily),fontSize:e.getOption(T.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==T.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=wt(i,t,n.getLineCount(),Mt(e.target.element));r&&(e.event.preventDefault(),e.event.stopPropagation(),u(t,r))});return{update(t){if(i=t,!a)return;let r=a,o=wt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=Tt(o,n.getLineCount()),r.zone.heightInPx=At+Et(o)*e.getOption(T.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var Pt={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function Ft(e,t,n,r){let i=a(),o=d(e,t,{root:n,enabled:i.data!==void 0&&be(i.data.protocol)&&r!==null}),[s,c]=(0,E.useState)(null),l=(0,E.useCallback)(e=>{c(e)},[]);return(0,E.useEffect)(()=>{let e=o.data;if(!s||!r||!e||e.repository===null||e.ignored||e.binary)return;let n=document.createElement(`div`);n.className=`puddle-hidden-diff-controller`,document.body.appendChild(n);let i=T.createModel(e.exists?e.content??``:``,r.getLanguageId()),a=T.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:i,modified:r});let l=Nt({editor:s,original:i,modified:r,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(kt(e,r.getLineCount()).map(e=>({range:new w(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:Pt[e.kind]}}))))},d=a.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),a.setModel(null),a.dispose(),i.dispose(),n.remove()}},[s,r,o.data]),l}function It({message:e,session:t,path:n,root:r,download:a}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),a&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void y(t,n,r).catch(e=>i.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-4`}),`Download`]})]})}function Lt({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=ve(),l=Ct(e,t,n,r,{focused:i}),u=Ft(e,t,r,l.model),d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[f,p]=(0,E.useState)(null),m=(0,E.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),h=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,E.useEffect)(()=>{if(!(!f||!l.model||h))return vt(f,{channel:s,target:m,driver:a,receiver:o},T.ScrollType.Immediate)},[f,l.model,h,s,m,a,o]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,D.jsx)(dt,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,D.jsx)(It,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,D.jsx)(It,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,D.jsx)(It,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let g=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),g&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:g}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,D.jsx)(De,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),u(e),p(e)},loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:d,fontSize:c.editorFontSize,...lt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Rt(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(Te(e),()=>{n.current?.(),Ae(e)}),[e])}function zt(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Bt({session:e,refName:t,path:n,content:r}){let i=ve(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(De,{path:zt(`puddle-view`,e,t,n),defaultValue:r,theme:Ee,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...lt(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Vt({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=_(e,t,n,{root:r,enabled:!i}),o=h(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,D.jsx)(k,{children:`…`}):s.error?(0,D.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,D.jsx)(k,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(Bt,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function Ht({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=ve(),c=Ct(e,n,null,i,{focused:o}),l=_(e,t,r,{root:i,enabled:!a}),d=h(e,r,{root:i,enabled:a}),f=a?d:l,p=(0,E.useRef)(null);Rt(Pe(e,n,i),()=>{let e=p.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),p.current=null});let m=(0,E.useRef)(c.save);m.current=c.save;let g=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),v=f.error instanceof u&&f.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,D.jsx)(dt,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||f.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):c.status===`too-large`?(0,D.jsx)(k,{children:`File too large to show`}):c.status===`error`?(0,D.jsx)(k,{children:c.errorMessage??`Failed to load file`}):v||a&&d.data&&!d.data.exists?(0,D.jsx)(Lt,{session:e,path:n,reveal:null,root:i,focused:o}):f.isPending||!c.model?(0,D.jsx)(k,{children:`…`}):f.error?(0,D.jsx)(k,{children:f.error instanceof Error?f.error.message:`Failed to load base`}):(0,D.jsx)(je,{modifiedModelPath:c.model.uri.toString(),originalModelPath:zt(`puddle-base`,e,`${t}:${i??``}`,r),original:f.data.content??``,language:c.model.getLanguageId(),theme:Ee,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{p.current=e,e.onDidDispose(()=>{p.current=null}),e.getModifiedEditor().addCommand(Se.CtrlCmd|Ce.KeyS,()=>m.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...lt(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ut({session:e,against:t,entry:n,root:r}){let i=ve(),a=n.old_path??n.path,o=_(e,t,a,{root:r,enabled:n.status!==`added`}),s=h(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,D.jsx)(Vt,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,D.jsx)(k,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,D.jsx)(k,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):n.status===`added`?(0,D.jsx)(Bt,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,D.jsx)(je,{originalModelPath:zt(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:zt(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Ee,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...lt(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,D.jsx)(k,{children:`Failed to load HEAD content`})}function Wt({session:e,path:t,root:n,focused:r}){return Rt(Pe(e,t,n)),(0,D.jsx)(Lt,{session:e,path:t,reveal:null,root:n,focused:r})}function Gt({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,D.jsx)(Ut,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,D.jsx)(Wt,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,D.jsx)(Vt,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,D.jsx)(Ht,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function Kt({session:e,sha:t,path:n,root:r}){let i=_(e,t,n,{root:r});return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(Bt,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function qt({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=ve(),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,D.jsx)(je,{originalModelPath:zt(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:zt(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Ee,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...lt(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Jt({session:e,sha:t,path:n,basePath:r,root:i}){let a=_(e,`${t}^`,r,{root:i}),o=_(e,t,n,{root:i});return a.error instanceof u&&a.error.status===404?(0,D.jsx)(Kt,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,D.jsx)(k,{children:`…`}):a.error?(0,D.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,D.jsx)(k,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(qt,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function Yt({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(te(n.status,r)){case`added`:return(0,D.jsx)(Kt,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,D.jsx)(Vt,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,D.jsx)(Jt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function Xt({session:e,sha:t,path:n,root:r}){let i=p(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Yt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Zt({session:e,path:t,root:n,area:r,focused:i=!0}){let a=v(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(a.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(a.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load diff`});let o=a.data.entries.find(e=>e.path===t);return o?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Gt,{session:e,against:a.data.against,entry:o,root:n,area:r,focused:i})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Qt=800;function $t({name:e}){let t=ve(),n=l(),r=ie(n,e),a=c(),o=s(`editor.save`),u=(0,E.useRef)(null),d=(0,E.useRef)(null),f=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=ye(t=>{x(n,e,t).catch(e=>i.error(e instanceof Error?e.message:`Draft not saved`))},Qt);return d.current=t,()=>{t.flush(),d.current=null}},[n,e]),n===null)return null;if(r.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load the draft`});if(r.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let p=()=>{let t=u.current;t&&(d.current?.flush(),re({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(De,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Ee,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{u.current=t,b(e,t.getValue()),xt(t,{onSave:p})},onChange:t=>{let r=t??``;b(e,r),S(a,n,e,r),d.current?.(r)},options:{automaticLayout:!0,fontFamily:f,fontSize:t.editorFontSize,...lt(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function en(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 tn(e){if(Array.isArray(e))return e}function nn(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 rn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function an(e,t){return tn(e)||nn(e,t)||on(e,t)||rn()}function on(e,t){if(e){if(typeof e==`string`)return en(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)?en(e,t):void 0}}var sn=Object.entries,cn=Object.setPrototypeOf,ln=Object.isFrozen,un=Object.getPrototypeOf,dn=Object.getOwnPropertyDescriptor,fn=Object.freeze,pn=Object.seal,mn=Object.create,hn=typeof Reflect<`u`&&Reflect,gn=hn.apply,_n=hn.construct;fn||=function(e){return e},pn||=function(e){return e},gn||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},_n||=function(e){return new e(...[...arguments].slice(1))};var vn=Rn(Array.prototype.forEach),yn=Rn(Array.prototype.lastIndexOf),bn=Rn(Array.prototype.pop),xn=Rn(Array.prototype.push),Sn=Rn(Array.prototype.splice),Cn=Array.isArray,wn=Rn(String.prototype.toLowerCase),Tn=Rn(String.prototype.toString),En=Rn(String.prototype.match),Dn=Rn(String.prototype.replace),On=Rn(String.prototype.indexOf),kn=Rn(String.prototype.trim),An=Rn(Number.prototype.toString),jn=Rn(Boolean.prototype.toString),Mn=typeof BigInt>`u`?null:Rn(BigInt.prototype.toString),Nn=typeof Symbol>`u`?null:Rn(Symbol.prototype.toString),Pn=Rn(Object.prototype.hasOwnProperty),Fn=Rn(Object.prototype.toString),In=Rn(RegExp.prototype.test),Ln=zn(TypeError);function Rn(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return gn(e,t,n)}}function zn(e){return function(){return _n(e,[...arguments])}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wn;if(cn&&cn(e,null),!Cn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ln(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Bn(e){for(let t=0;t<e.length;t++)Pn(e,t)||(e[t]=null);return e}function Vn(e){let t=mn(null);for(let r of sn(e)){var n=an(r,2);let i=n[0],a=n[1];Pn(e,i)&&(Cn(a)?t[i]=Bn(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Vn(a):t[i]=a)}return t}function Hn(e){switch(typeof e){case`string`:return e;case`number`:return An(e);case`boolean`:return jn(e);case`bigint`:return Mn?Mn(e):`0`;case`symbol`:return Nn?Nn(e):`Symbol()`;case`undefined`:return Fn(e);case`function`:case`object`:{if(e===null)return Fn(e);let t=e,n=Un(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Fn(e)}return Fn(e)}default:return Fn(e)}}function Un(e,t){for(;e!==null;){let n=dn(e,t);if(n){if(n.get)return Rn(n.get);if(typeof n.value==`function`)return Rn(n.value)}e=un(e)}function n(){return null}return n}function Wn(e){try{return In(e,``),!0}catch{return!1}}var Gn=fn(`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(`.`)),Kn=fn(`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(`.`)),qn=fn([`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`]),Jn=fn([`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`]),Yn=fn(`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(`.`)),Xn=fn([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Zn=fn([`#text`]),Qn=fn(`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(`.`)),$n=fn(`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(`.`)),er=fn(`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(`.`)),tr=fn([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nr=pn(/{{[\w\W]*|^[\w\W]*}}/g),rr=pn(/<%[\w\W]*|^[\w\W]*%>/g),ir=pn(/\${[\w\W]*/g),ar=pn(/^data-[\-\w.\u00B7-\uFFFF]+$/),or=pn(/^aria-[\-\w]+$/),sr=pn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cr=pn(/^(?:\w+script|data):/i),lr=pn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ur=pn(/^html$/i),dr=pn(/^[a-z][.\w]*(-[.\w]+)+$/i),fr=pn(/<[/\w!]/g),pr=pn(/<[/\w]/g),mr=pn(/<\/no(script|embed|frames)/i),hr=pn(/\/>/i),gr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_r=function(){return typeof window>`u`?null:window},vr=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}},yr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},br=function(e,t,n,r){return Pn(e,t)&&Cn(e[t])?A(r.base?Vn(r.base):{},e[t],r.transform):n};function xr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_r(),t=e=>xr(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==gr.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=Un(d,`cloneNode`),p=Un(d,`remove`),m=Un(d,`nextSibling`),h=Un(d,`childNodes`),g=Un(d,`parentNode`),_=Un(d,`shadowRoot`),v=Un(d,`attributes`),y=o&&o.prototype?Un(o.prototype,`nodeType`):null,b=o&&o.prototype?Un(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,ee,te=!1,ne=0,re=function(){if(ne>0)throw Ln(`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.`)},ie=function(e){re(),ne++;try{return x.createHTML(e)}finally{ne--}},ae=function(e){re(),ne++;try{return x.createScriptURL(e)}finally{ne--}},oe=function(){return te||=(ee=vr(u,i),!0),ee},se=n,ce=se.implementation,le=se.createNodeIterator,ue=se.createDocumentFragment,de=se.getElementsByTagName,fe=r.importNode,C=yr();t.isSupported=typeof sn==`function`&&typeof g==`function`&&ce&&ce.createHTMLDocument!==void 0;let pe=nr,me=rr,he=ir,ge=ar,_e=or,ve=cr,ye=lr,be=dr,xe=sr,w=null,Se=A({},[...Gn,...Kn,...qn,...Yn,...Zn]),T=null,Ce=A({},[...Qn,...$n,...er,...tr]),we=Object.seal(mn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ee=null,De=Object.seal(mn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Oe=!0,ke=!0,Ae=!1,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!1,Ie=null,Le=null,Re=!1,ze=!1,Be=!1,Ve=!1,He=!0,Ue=!1,We=`user-content-`,Ge=!0,E=!1,Ke={},qe=null,Je=A({},`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(`.`)),Ye=null,Xe=A({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ze=null,Qe=A({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),$e=`http://www.w3.org/1998/Math/MathML`,et=`http://www.w3.org/2000/svg`,tt=`http://www.w3.org/1999/xhtml`,nt=tt,rt=!1,it=null,at=A({},[$e,et,tt],Tn),ot=fn([`mi`,`mo`,`mn`,`ms`,`mtext`]),st=A({},ot),ct=fn([`annotation-xml`]),lt=A({},ct),D=A({},[`title`,`style`,`font`,`a`,`script`]),ut=null,dt=[`application/xhtml+xml`,`text/html`],O=null,ft=null,pt=n.createElement(`form`),mt=function(e){return e instanceof RegExp||e instanceof Function},ht=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ft&&ft===e)return;(!e||typeof e!=`object`)&&(e={}),e=Vn(e),ut=dt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,O=ut===`application/xhtml+xml`?Tn:wn,w=br(e,`ALLOWED_TAGS`,Se,{transform:O}),T=br(e,`ALLOWED_ATTR`,Ce,{transform:O}),it=br(e,`ALLOWED_NAMESPACES`,at,{transform:Tn}),Ze=br(e,`ADD_URI_SAFE_ATTR`,Qe,{transform:O,base:Qe}),Ye=br(e,`ADD_DATA_URI_TAGS`,Xe,{transform:O,base:Xe}),qe=br(e,`FORBID_CONTENTS`,Je,{transform:O}),Te=br(e,`FORBID_TAGS`,Vn({}),{transform:O}),Ee=br(e,`FORBID_ATTR`,Vn({}),{transform:O}),Ke=Pn(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Vn(e.USE_PROFILES):e.USE_PROFILES:!1,Oe=e.ALLOW_ARIA_ATTR!==!1,ke=e.ALLOW_DATA_ATTR!==!1,Ae=e.ALLOW_UNKNOWN_PROTOCOLS||!1,je=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=e.SAFE_FOR_TEMPLATES||!1,Ne=e.SAFE_FOR_XML!==!1,Pe=e.WHOLE_DOCUMENT||!1,ze=e.RETURN_DOM||!1,Be=e.RETURN_DOM_FRAGMENT||!1,Ve=e.RETURN_TRUSTED_TYPE||!1,Re=e.FORCE_BODY||!1,He=e.SANITIZE_DOM!==!1,Ue=e.SANITIZE_NAMED_PROPS||!1,Ge=e.KEEP_CONTENT!==!1,E=e.IN_PLACE||!1,xe=Wn(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:sr,nt=typeof e.NAMESPACE==`string`?e.NAMESPACE:tt,st=Pn(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Vn(e.MATHML_TEXT_INTEGRATION_POINTS):A({},ot),lt=Pn(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Vn(e.HTML_INTEGRATION_POINTS):A({},ct);let t=Pn(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Vn(e.CUSTOM_ELEMENT_HANDLING):mn(null);if(we=mn(null),Pn(t,`tagNameCheck`)&&mt(t.tagNameCheck)&&(we.tagNameCheck=t.tagNameCheck),Pn(t,`attributeNameCheck`)&&mt(t.attributeNameCheck)&&(we.attributeNameCheck=t.attributeNameCheck),Pn(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(we.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),pn(we),Me&&(ke=!1),Be&&(ze=!0),Ke&&(w=A({},Zn),T=mn(null),Ke.html===!0&&(A(w,Gn),A(T,Qn)),Ke.svg===!0&&(A(w,Kn),A(T,$n),A(T,tr)),Ke.svgFilters===!0&&(A(w,qn),A(T,$n),A(T,tr)),Ke.mathMl===!0&&(A(w,Yn),A(T,er),A(T,tr))),De.tagCheck=null,De.attributeCheck=null,Pn(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?De.tagCheck=e.ADD_TAGS:Cn(e.ADD_TAGS)&&(w===Se&&(w=Vn(w)),A(w,e.ADD_TAGS,O))),Pn(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?De.attributeCheck=e.ADD_ATTR:Cn(e.ADD_ATTR)&&(T===Ce&&(T=Vn(T)),A(T,e.ADD_ATTR,O))),Pn(e,`ADD_URI_SAFE_ATTR`)&&Cn(e.ADD_URI_SAFE_ATTR)&&A(Ze,e.ADD_URI_SAFE_ATTR,O),Pn(e,`FORBID_CONTENTS`)&&Cn(e.FORBID_CONTENTS)&&(qe===Je&&(qe=Vn(qe)),A(qe,e.FORBID_CONTENTS,O)),Pn(e,`ADD_FORBID_CONTENTS`)&&Cn(e.ADD_FORBID_CONTENTS)&&(qe===Je&&(qe=Vn(qe)),A(qe,e.ADD_FORBID_CONTENTS,O)),Ge&&(w[`#text`]=!0),Pe&&A(w,[`html`,`head`,`body`]),w.table&&(A(w,[`tbody`]),delete Te.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ln(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ln(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ie(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=oe()),x&&typeof S==`string`&&(S=ie(``)));fn&&fn(e),ft=e},gt=A({},[...Kn,...qn,...Jn]),_t=A({},[...Yn,...Xn]),vt=function(e,t,n){return t.namespaceURI===tt?e===`svg`:t.namespaceURI===$e?e===`svg`&&(n===`annotation-xml`||st[n]):!!gt[e]},yt=function(e,t,n){return t.namespaceURI===tt?e===`math`:t.namespaceURI===et?e===`math`&&lt[n]:!!_t[e]},bt=function(e,t,n){return t.namespaceURI===et&&!lt[n]||t.namespaceURI===$e&&!st[n]?!1:!_t[e]&&(D[e]||!gt[e])},xt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:nt,tagName:`template`});let n=wn(e.tagName),r=wn(t.tagName);return it[e.namespaceURI]?e.namespaceURI===et?vt(n,t,r):e.namespaceURI===$e?yt(n,t,r):e.namespaceURI===tt?bt(n,t,r):!!(ut===`application/xhtml+xml`&&it[e.namespaceURI]):!1},St=function(e){xn(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Ln(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Ct=function(e){Et(e);let t=h(e);if(t){let e=[];vn(t,t=>{xn(e,t)}),vn(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},wt=function(e,n){try{xn(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{xn(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(ze||Be)try{St(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Tt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||T[O(i)]))try{e.removeAttribute(i)}catch{}}},Et=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===gr.element&&Tt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Dt=function(e){if(!Ne)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===gr.processingInstruction||n===gr.comment&&In(pr,e.data)){try{p(e)}catch{}continue}if(n===gr.element){let t=e,n=O(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Ot=function(e){let t=null,r=null;if(Re)e=`<remove></remove>`+e;else{let t=En(e,/^[\r\n\t ]+/);r=t&&t[0]}ut===`application/xhtml+xml`&&nt===tt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?ie(e):e;if(nt===tt)try{t=new l().parseFromString(i,ut)}catch{}if(!t||!t.documentElement){t=ce.createDocument(nt,`template`,null);try{t.documentElement.innerHTML=rt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),nt===tt?de.call(t,Pe?`html`:`body`)[0]:Pe?t.documentElement:a},kt=function(e){return le.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},At=function(e){return e=Dn(e,pe,` `),e=Dn(e,me,` `),e=Dn(e,he,` `),e},jt=function(e){e.normalize();let t=le.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=At(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&vn(r,e=>{Nt(e.content)&&jt(e.content)})},Mt=function(e){let t=b?b(e):null;return typeof t!=`string`||O(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Nt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===gr.documentFragment}catch{return!1}},Pt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Ft(e,n,r){e.length!==0&&vn(e,e=>{e.call(t,n,r,ft)})}let It=function(e,t){return!!(Ne&&e.hasChildNodes()&&!Pt(e.firstElementChild)&&In(fr,e.textContent)&&In(fr,e.innerHTML)||Ne&&e.namespaceURI===tt&&t===`style`&&Pt(e.firstElementChild)||e.nodeType===gr.processingInstruction||Ne&&e.nodeType===gr.comment&&In(pr,e.data))},Lt=function(e,t){if(!Te[t]&&Bt(t)&&(we.tagNameCheck instanceof RegExp&&In(we.tagNameCheck,t)||we.tagNameCheck instanceof Function&&we.tagNameCheck(t)))return!1;if(Ge&&!qe[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=E?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return St(e),!0},k=function(e,n){if(Ft(C.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Mt(e))return St(e),!0;let r=O(b?b(e):e.nodeName);if(Ft(C.uponSanitizeElement,e,{tagName:r,allowedTags:w}),e!==n&&g(e)===null)return!0;if(It(e,r))return St(e),!0;if(Te[r]||!(De.tagCheck instanceof Function&&De.tagCheck(r))&&!w[r]){let t=Lt(e,r);return t===!1&&Ft(C.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===gr.element&&!xt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&In(mr,e.innerHTML))return St(e),!0;if(Me&&e.nodeType===gr.text){let n=At(e.textContent);e.textContent!==n&&(xn(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Ft(C.afterSanitizeElements,e,null),!1},Rt=function(e,t,r){if(Ee[t]||Ne&&t===`patchsrc`||Ne&&t===`for`&&e!==`label`&&e!==`output`||He&&(t===`id`||t===`name`)&&(r in n||r in pt))return!1;let i=T[t]||De.attributeCheck instanceof Function&&De.attributeCheck(t,e);if(!(ke&&In(ge,t))&&!(Oe&&In(_e,t))){if(!i){if(!(Bt(e)&&(we.tagNameCheck instanceof RegExp&&In(we.tagNameCheck,e)||we.tagNameCheck instanceof Function&&we.tagNameCheck(e))&&(we.attributeNameCheck instanceof RegExp&&In(we.attributeNameCheck,t)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(t,e))||t===`is`&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&In(we.tagNameCheck,r)||we.tagNameCheck instanceof Function&&we.tagNameCheck(r))))return!1}else if(!Ze[t]&&!In(xe,Dn(r,ye,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&On(r,`data:`)===0&&Ye[e])&&!(Ae&&!In(ve,Dn(r,ye,``)))&&r)return!1}return!0},zt=A({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Bt=function(e){return!zt[wn(e)]&&In(be,e)},Vt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ie(r);case`TrustedScriptURL`:return ae(r)}return r},Ht=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Mt(e)?St(e):bn(t.removed)}catch{wt(n,e)}},Ut=function(e){Ft(C.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Mt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0},r=t.length,i=O(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=O(o),u=c,d=o===`value`?u:kn(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Ft(C.uponSanitizeAttribute,e,n),d=n.attrValue,Ue&&(l===`id`||l===`name`)&&On(d,We)!==0&&(wt(o,e),d=We+d),Ne&&In(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){wt(o,e);continue}if(l===`attributename`&&En(d,`href`)){wt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){wt(o,e);continue}if(!je&&In(hr,d)){wt(o,e);continue}if(Me&&(d=At(d)),!Rt(i,l,d)){wt(o,e);continue}d=Vt(i,l,s,d),d!==u&&Ht(e,o,s,d)}}Ft(C.afterSanitizeAttributes,e,null)},Wt=function(e){let t=null,n=kt(e);for(Ft(C.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Ft(C.uponSanitizeShadowNode,t,null),k(t,e),Ut(t),Nt(t.content)&&Wt(t.content),(y?y(t):t.nodeType)===gr.element){let e=_(t);Nt(e)&&(Gt(e),Wt(e))}Ft(C.afterSanitizeShadowDOM,e,null)},Gt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Wt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===gr.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&O(e)===`template`){let e=n.content;Nt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Nt(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(rt=!e,rt&&(e=`<!-->`),typeof e!=`string`&&!Pt(e)&&(e=Hn(e),typeof e!=`string`))throw Ln(`dirty is not a string, aborting`);if(!t.isSupported)return e;Fe?(w=Ie,T=Le):ht(n),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(w=Vn(w)),C.uponSanitizeAttribute.length>0&&(T=Vn(T)),t.removed=[];let c=E&&typeof e!=`string`&&Pt(e);if(c){Dt(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=O(t);if(!w[n]||Te[n])throw Ct(e),Ln(`root node is forbidden and cannot be sanitized in-place`)}if(Mt(e))throw Ct(e),Ln(`root node is clobbered and cannot be sanitized in-place`);try{Gt(e)}catch(t){throw Ct(e),t}}else if(Pt(e))i=Ot(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===gr.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Gt(a);else{if(!ze&&!Me&&!Pe&&e.indexOf(`<`)===-1)return x&&Ve?ie(e):e;if(i=Ot(e),!i)return ze?null:Ve?S:``}i&&Re&&St(i.firstChild);let l=c?e:i,u=kt(l);try{for(;o=u.nextNode();)k(o,l),Ut(o),Nt(o.content)&&Wt(o.content)}catch(n){throw c&&(Ct(e),vn(t.removed,e=>{e.element&&Et(e.element)})),n}if(c)return vn(t.removed,e=>{e.element&&Et(e.element)}),Me&&jt(e),e;if(ze){if(Me&&jt(i),Be)for(s=ue.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(T.shadowroot||T.shadowrootmode)&&(s=fe.call(r,s,!0)),s}let d=Pe?i.outerHTML:i.innerHTML;return Pe&&w[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&In(ur,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
3
  `+d),Me&&(d=At(d)),x&&Ve?ie(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(e),Fe=!0,Ie=w,Le=T},t.clearConfig=function(){ft=null,Fe=!1,Ie=null,Le=null,x=ee,S=``},t.isValidAttribute=function(e,t,n){ft||ht({});let r=O(e),i=O(t);return Rt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Pn(C,e)&&xn(C[e],t)},t.removeHook=function(e,t){if(Pn(C,e)){if(t!==void 0){let n=yn(C[e],t);return n===-1?void 0:Sn(C[e],n,1)[0]}return bn(C[e])}},t.removeHooks=function(e){Pn(C,e)&&(C[e]=[])},t.removeAllHooks=function(){C=yr()},t}var Sr=xr(),Cr=0;function wr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!e.textContent||t?.closest(`script, style, noscript, [hidden], [aria-hidden="true"]`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=[],r=``,i;for(;i=t.nextNode();){let e=i.textContent??``,t=r.length;r+=e,n.push({node:i,start:t,end:r.length})}return{text:r,nodes:n}}function Tr(e,t){let n=t.find(t=>t.end>e.start),r=t.findLast(t=>t.start<e.end);if(!n||!r)return null;let i=document.createRange();return i.setStart(n.node,e.start-n.start),i.setEnd(r.node,e.end-r.start),i}var Er=class{root;matchName=`puddle-find-${++Cr}-match`;activeName=`puddle-find-${Cr}-active`;style;signature=``;ranges=[];index=-1;limited=!1;constructor(e){this.root=e,this.style=document.createElement(`style`),this.style.textContent=`
4
4
  ::highlight(${this.matchName}) { background: var(--selection); }
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,r as i}from"./x-BJOrp_m5.js";import{A as a,E as o,Ft as s,G as c,H as l,Ht as u,I as d,It as f,Lt as p,Mt as m,Nt as h,Pt as g,Q as _,T as v,W as ee,Y as te,Z as y,a as b,at as x,ct as S,et as C,f as w,g as ne,i as re,j as ie,mt as ae,n as oe,ot as se,pt as ce,q as le,rt as ue,t as de,tt as T,v as E,z as fe}from"./hotkeys-CekBkaTu.js";import{a as D,h as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-DjL0qoAv.js";import{a as P,c as pe,l as F,o as me,r as he,s as ge,u as I}from"./LazyTerminal-DpW_dV8-.js";import{a as L,i as R,n as z,o as B,r as V,t as _e}from"./session-seed-YCLBYoEN.js";import{t as ve}from"./chevron-down-59O6CgEo.js";import{r as ye}from"./dist-DDFe8e3m.js";import{$ as be,At as xe,Ct as Se,Et as Ce,G as we,It as Te,J as Ee,Jt as De,K as Oe,Lt as H,Mt as ke,Q as Ae,Rt as U,St as je,Tt as Me,V as W,W as G,Wt as Ne,X as Pe,Y as Fe,_t as Ie,et as Le,jt as Re,kt as ze,ot as Be,q as Ve,r as He,rt as Ue,tt as We,vt as Ge,wt as Ke,yt as qe,zt as Je}from"./index-CzVID1ZA.js";var Ye=r(`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`}]]),Xe=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=r(`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=r(`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`}]]),$e=r(`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`}]]),et=r(`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`}]]),tt=r(`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`}]]),nt=r(`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`}]]),K=e(t(),1),q=n();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(F,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:a,className:o}){return(0,q.jsxs)(`div`,{className:i(`flex items-center gap-4 py-2.5`,o),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:i(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=U(),[t,n]=(0,K.useState)(De());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ne(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`dark`,children:`Dark`}),(0,q.jsx)(R,{value:`light`,children:`Light`}),(0,q.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(z,{value:e.cursorPackage,onValueChange:e=>H({cursorPackage:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsx)(V,{children:Je.map(e=>(0,q.jsx)(R,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>H({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>H({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>H({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(z,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`compact`,children:`Compact`}),(0,q.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=C(),[n,r]=(0,K.useState)(!1),a=n=>{t.mutate({id:e.id,icon:n},{onError:e=>P(e)}),r(!1)},o=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>P(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(be,{open:n,onOpenChange:r,children:[(0,q.jsx)(We,{asChild:!0,children:(0,q.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,q.jsx)(je,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Le,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:i(`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,q.jsx)(je,{icon:null,colour:null,className:`size-4`})}),Ke.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:i(`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,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),f.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:i(`size-3.5 rounded-full bg-current`,Se(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var at=`__none__`;function ot(){let e=E(),t=se().data?.find(t=>t.id===e),n=v(e??void 0),r=x(e??void 0),i=C(),a=T(e??``),o=l(),[s,c]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(F,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(F,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsx)(it,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(z,{value:typeof g==`number`?String(g):at,onValueChange:e=>a.mutate({default_account_id:e===at?null:Number(e)},{onError:e=>P(e)}),children:[(0,q.jsx)(L,{className:`w-56`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:at,children:`First available`}),n.data?.map(e=>(0,q.jsx)(R,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(O,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(N,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{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,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(F,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Ie(),ne.set(null)},onError:e=>{p(!1),h(``),P(e)}}),children:`Delete profile`})]})]})})]})}function st({agent:e,profileId:t,onClose:n,onCreated:r}){let i=ie(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=ee(Be(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>P(e)})};return(0,q.jsx)(N,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,q.jsx)(F,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(he,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(O,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(xe,{}),`Add account`]})]})]})})}function ct({account:e,gateOpen:t,installed:n}){let r=te(),i=y(),a=fe(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{P(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(me,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>P(e)})})]}),(0,q.jsxs)(O,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>P(e)}),children:[(0,q.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(O,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ce,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Ae,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(N,{open:c,onOpenChange:l,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),P(e)}}),children:`Delete account`})]})]})})]})}function lt(){let e=E(),t=o(),n=v(e??void 0),r=x(e??void 0),i=te(),[a,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(ct,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(O,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,q.jsx)(xe,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Ae,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,q.jsx)(st,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>P(e)})}})]})}function ut(){let e=a(),t=_(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function dt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=_e(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ft(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function pt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(I,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var mt={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 ht({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:s;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ue(mt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:p.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function gt(){let e=E(),t=se().data?.find(t=>t.id===e),n=x(e??void 0),r=T(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>P(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>P(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>P(e)})})}),(0,q.jsx)(ut,{}),(0,q.jsx)(ft,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(dt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(dt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(pt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??h,defaultText:h,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(pt,{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??m,defaultText:m,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(pt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??g,defaultText:g,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(ht,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(N,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{className:`flex items-center gap-2`,children:[(0,q.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.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,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.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,q.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,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(F,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var _t={desktop:!0,sound:!1,muted_projects:[]};function vt(){let[e,t]=(0,K.useState)(G);return(0,K.useEffect)(()=>{let e=()=>t(G());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(G())]}function yt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function bt(){let e=E(),t=x(e??void 0),n=T(e??``),r=S(e??void 0),[i,a]=vt(),o={..._t,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>P(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(yt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function xt(){let e=U();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>H({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({editorWordWrap:e})})}),(0,q.jsx)(Y,{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,q.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:He.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function St({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=re(e.nativeEvent);t&&(n(t),o(!1))},className:i(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:b(e)}),!t&&(0,q.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,q.jsx)(Qe,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function Ct(){let e=E(),t=x(e??void 0),n=T(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of de){let t=i(e.id,w(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>P(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>P(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>P(e)})})}),oe.map(e=>{let t=de.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,w(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(St,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var wt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...wt].map((e,t)=>[e,t])),Tt=`H`,Et=(()=>{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 Dt(e){let t=4294967295;for(let n of e)t=Et[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Ot(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function kt(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 At(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function jt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Mt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:wt[(e+n)%Z]}return r}async function Nt(e){let t=await At(JSON.stringify(e));return Mt(Ot(t)+Dt(t),1+Math.floor(Math.random()*(Z-1)))}async function Pt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Mt(t,-((Q[n]-Q[Tt]+Z)%Z));if(r.length<9||r[0]!==Tt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=kt(i);if(Dt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await jt(o))}var Ft=`puddle.sync-selection`;function It(){try{let e=JSON.parse(localStorage.getItem(Ft)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Ee.map(e=>e.id)}function Lt({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Ee.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Rt(){let e=E(),t=x(e??void 0),n=se().data?.find(t=>t.id===e),r=ae(e??void 0,void 0),i=T(e??``),a=C(),o=d(),s=Oe(),c=Ve(),[l,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(It),y=n&&s.data?we(s.data.file,n.name):void 0,b=y?.enabled===!0,S=b&&y?y.groups:ee,w=()=>({client:Te(),theme:De(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ne={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&Ne(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>P(e)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>P(e)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},re=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??b,groups:t,doc:Pe(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>P(e)})},ie=(e,t)=>{let n=t?[...S,e]:S.filter(t=>t!==e);te(n),localStorage.setItem(Ft,JSON.stringify(n)),b&&re({},n)},oe=async()=>{v(!0);try{let e=Fe(await Pt(l.trim()),ne,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{v(!1)}},ce=async()=>{v(!0);try{let e=await Nt(Pe(S,w()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:b,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>re({enabled:e},S)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,q.jsx)(ve,{className:`size-3.5`}):(0,q.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Lt,{selected:S,onToggle:ie})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(O,{size:`sm`,disabled:_,onClick:()=>void ce(),children:`Export & copy`}),p&&(0,q.jsx)(I,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(I,{value:l,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(O,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void oe(),children:`Import`})})]})]})}function zt({repo:e}){let t=ue(),n=c(),[r,i]=(0,K.useState)(e.default_base_branch),[a,o]=(0,K.useState)(e.onboarding_notes??``),s=e=>P(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.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,q.jsxs)(O,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,q.jsx)(ze,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,q.jsx)(Y,{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,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.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,q.jsx)(I,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.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,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Bt(){let e=ce();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(zt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=_();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>P(e)})}})})}function Vt(){let e=a(),t=_(),n=le();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(F,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>P(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>P(e)})})})]}):null}var Ht=[{id:`appearance`,label:`Appearance`,icon:Re,render:()=>(0,q.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Me,render:()=>(0,q.jsx)(ot,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,q.jsx)(lt,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,q.jsx)(gt,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,q.jsx)(xt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,q.jsx)(Ct,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`projects`,label:`Projects`,icon:ge,render:()=>(0,q.jsx)(Bt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,q.jsx)(Vt,{})},{id:`sync`,label:`Sync`,icon:ze,render:()=>(0,q.jsx)(Rt,{})}],Ut={terminal:`sessions`,repositories:`projects`};function Wt(){let e=qe(),t=e===null?null:Ut[e]??e,n=Ht.find(e=>e.id===t)??Ht[0];return(0,q.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&Ie(),children:(0,q.jsxs)(A,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(j,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Ht.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Ge(e),className:i(`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,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Wt as SettingsDialog};