@puddle-code/cli 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -3
- package/dist/index.js +3 -2
- package/dist/public/assets/{Dashboard-BeA3XFFb.js → Dashboard-cH617BN6.js} +1 -1
- package/dist/public/assets/{EditorTabClose-DCz7GOWM.js → EditorTabClose-74lvYANq.js} +1 -1
- package/dist/public/assets/{LazyTerminal-g5UEjTBk.js → LazyTerminal-bbmj7YnL.js} +2 -2
- package/dist/public/assets/{ModelRefcount-CJbBti7L.js → ModelRefcount-C8AaAjdS.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-Bvrqvhjw.js → PaneEditorBody-H5C70EA-.js} +1 -1
- package/dist/public/assets/{SettingsDialog-CYoCdkEX.js → SettingsDialog-C12Ulc04.js} +1 -1
- package/dist/public/assets/{Terminal-CX7z9Fpb.js → Terminal-BzDAcHMO.js} +2 -2
- package/dist/public/assets/Workspace-CrbIuaBO.js +8 -0
- package/dist/public/assets/{buffer-store-B_o7o_Pt.js → buffer-store-7XJyeYTl.js} +2 -2
- package/dist/public/assets/{context-menu-BrgiEZVv.js → context-menu-BQLwy3k3.js} +1 -1
- package/dist/public/assets/{cssMode-52Fk27Yr.js → cssMode-Ba1MkL7V.js} +1 -1
- package/dist/public/assets/{drafts-CZrBJe5X.js → drafts-BJXURaei.js} +1 -1
- package/dist/public/assets/{file-links-C4gg9SyG.js → file-links-CZ2K_lr6.js} +1 -1
- package/dist/public/assets/{htmlMode-D8Ac4j1L.js → htmlMode-Br4Vhh_e.js} +1 -1
- package/dist/public/assets/{index-DtvjVJQS.js → index-DzKOX38n.js} +3 -3
- package/dist/public/assets/{jsonMode-Cbi08U3y.js → jsonMode-Cjygy0Yx.js} +1 -1
- package/dist/public/assets/{media-refresh-store-BmcKGDho.js → media-refresh-store-PUCHJ25x.js} +1 -1
- package/dist/public/assets/{session-seed-d7l8pRcG.js → session-seed-DjANSMsS.js} +1 -1
- package/dist/public/assets/{tsMode-Bci-rzFN.js → tsMode-B6BOKeVT.js} +1 -1
- package/dist/public/assets/{use-find-controls-MrQ6ItX5.js → use-find-controls-Bl_efA6K.js} +1 -1
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
- package/dist/public/assets/Workspace-Cg8Ccwsw.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,10 @@ Past releases: see docs/changelogs/.
|
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
|
|
10
|
-
## [0.1.
|
|
10
|
+
## [0.1.12] — 2026-09-09
|
|
11
11
|
|
|
12
12
|
### Fixed
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
- Keep
|
|
14
|
+
- Paste clipboard images into the focused file-tree directory with timestamped screenshot names.
|
|
15
|
+
- Keep session shell history on its private file when directory, environment, or prompt hooks repoint `HISTFILE` at runtime.
|
|
16
|
+
- Make Option+Left/Right move by word in macOS terminals instead of inserting the unrecognised xterm sequence tail.
|
package/dist/index.js
CHANGED
|
@@ -20003,7 +20003,7 @@ import { readFileSync } from "node:fs";
|
|
|
20003
20003
|
import { dirname, join as join2 } from "node:path";
|
|
20004
20004
|
import { fileURLToPath } from "node:url";
|
|
20005
20005
|
function cliVersion() {
|
|
20006
|
-
if (true) return "0.1.
|
|
20006
|
+
if (true) return "0.1.12";
|
|
20007
20007
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
20008
20008
|
for (const candidate of [
|
|
20009
20009
|
join2(here, "..", "..", "package.json"),
|
|
@@ -20373,7 +20373,8 @@ var RELEASE_PROTOCOLS = {
|
|
|
20373
20373
|
"0.1.8": { major: 17, minor: 2 },
|
|
20374
20374
|
"0.1.9": { major: 17, minor: 3 },
|
|
20375
20375
|
"0.1.10": { major: 17, minor: 3 },
|
|
20376
|
-
"0.1.11": { major: 17, minor: 3 }
|
|
20376
|
+
"0.1.11": { major: 17, minor: 3 },
|
|
20377
|
+
"0.1.12": { major: 17, minor: 3 }
|
|
20377
20378
|
};
|
|
20378
20379
|
function validProtocol(value) {
|
|
20379
20380
|
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{n}from"./createLucideIcon-C6JENrH3.js";import{a as r}from"./api-BBFo3oc-.js";import{a as i,h as a,i as o,n as s,o as c,t as l}from"./dialog-DI1-uj7G.js";import{a as u,c as d,l as f,o as p,s as m,t as h}from"./LazyTerminal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n}from"./createLucideIcon-C6JENrH3.js";import{a as r}from"./api-BBFo3oc-.js";import{a as i,h as a,i as o,n as s,o as c,t as l}from"./dialog-DI1-uj7G.js";import{a as u,c as d,l as f,o as p,s as m,t as h}from"./LazyTerminal-bbmj7YnL.js";import{n as g}from"./x-C-HTKvar.js";import{A as _,M as v,c as y,j as b,k as x,n as S,r as C,t as w}from"./context-menu-BQLwy3k3.js";import{r as T}from"./dist-CKuo36qW.js";import{An as E,Dn as D,Jt as O,Nn as k,On as A,Pt as j,Rn as M,Un as N,Vt as P,cr as F,en as I,ft as L,mt as R,pt as z,ut as B}from"./index-DzKOX38n.js";var V=e(t(),1),H=n(),U=!1;function W(){let[e,t]=(0,V.useState)(U),[n,i]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!e)return;let t=!1;return R.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{U=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&R.killShell(r,n),a()):(U=!0,t(!0))},onExit:a}}function G({term:e,onExit:t}){return(0,H.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,H.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,H.jsx)(h,{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=N(e),n=(0,V.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),K.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function J({icon:e,label:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,H.jsx)(e,{className:`size-4`})})}function Y({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:m,onDragEnd:h,onDragOver:_}){let x=A(),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)(e.name),[k,j]=(0,V.useState)(z(e)),M=t=>x.mutate({id:e.id,archived:t},{onError:e=>u(e)}),N=()=>{O(e.name),j(z(e)),E(!0)},P=()=>{let t=D.trim(),n=L(k);if(!t){E(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==z(e)?{abbrev:n}:{}};if(Object.keys(r).length===0){E(!1);return}x.mutate({id:e.id,...r},{onSuccess:()=>E(!1),onError:e=>u(e)})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(w,{children:[(0,H.jsx)(y,{asChild:!0,children:(0,H.jsxs)(`div`,{draggable:n,onDragStart:m,onDragEnd:h,onDragOver:_,className:g(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,H.jsxs)(F,{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:v,label:`Reopen project`,onClick:()=>M(!1)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{icon:p,label:`Edit project`,onClick:N}),(0,H.jsx)(J,{icon:b,label:`Archive project`,onClick:()=>M(!0)})]})})]})}),(0,H.jsx)(S,{children:e.archived?(0,H.jsxs)(C,{onSelect:()=>M(!1),children:[(0,H.jsx)(v,{}),` Reopen`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(C,{onSelect:N,children:[(0,H.jsx)(p,{}),` Edit`]}),(0,H.jsxs)(C,{onSelect:()=>M(!0),children:[(0,H.jsx)(b,{}),` Archive`]})]})})]}),(0,H.jsx)(l,{open:T,onOpenChange:E,children:(0,H.jsxs)(s,{children:[(0,H.jsx)(i,{children:(0,H.jsx)(c,{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)(d,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,H.jsx)(f,{id:`project-name-${e.id}`,value:D,onChange:e=>O(e.target.value),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(d,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,H.jsx)(f,{id:`project-abbrev-${e.id}`,maxLength:5,value:k,onChange:e=>j(L(e.target.value)),className:`w-24 uppercase`}),(0,H.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(d,{className:`text-fg-muted`,children:`Path`}),(0,H.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,H.jsxs)(o,{children:[(0,H.jsx)(a,{type:`button`,variant:`ghost`,onClick:()=>E(!1),children:`Cancel`}),(0,H.jsx)(a,{type:`submit`,disabled:!D.trim()||x.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=P(),t=k(e??void 0),n=M(),r=E(e??void 0),i=D(e??``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=W(),f=j(`palette.toggle`),p=e=>n.data?.find(t=>t.id===e)?.path,h=t.data??[],v=r.data?.projectOrder??[],y=x(h.filter(e=>!e.archived),v),S=h.filter(e=>e.archived),C=(e,t)=>{e!==t&&i.mutate({projectOrder:_(y.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:[h.length===0&&(0,H.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,H.jsx)(m,{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 `,f,`.`]})]}),(0,H.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[y.map(e=>(0,H.jsx)(Y,{project:e,repoPath:p(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&C(s,e.id)}},e.id)),(0,H.jsx)(X,{icon:I,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,H.jsx)(X,{icon:O,label:d.open?`Close terminal`:`Open terminal`,hint:d.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:d.toggle})]}),S.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,H.jsx)(T,{className:g(`size-3 transition-transform`,l&&`rotate-90`)}),(0,H.jsx)(b,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Archived`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:S.length})]}),l&&(0,H.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:S.map(e=>(0,H.jsx)(Y,{project:e,repoPath:p(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),d.open&&(0,H.jsx)(G,{term:d.term,onExit:d.onExit}),e!==null&&(0,H.jsx)(B,{profileId:e,open:a,onOpenChange:o})]})}export{Z as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./createLucideIcon-C6JENrH3.js";import{a as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-DI1-uj7G.js";import{t as d}from"./x-C-HTKvar.js";import{i as f,t as p,u as m}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./createLucideIcon-C6JENrH3.js";import{a as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-DI1-uj7G.js";import{t as d}from"./x-C-HTKvar.js";import{i as f,t as p,u as m}from"./buffer-store-7XJyeYTl.js";import{t as h}from"./drafts-BJXURaei.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)(d,{className:`size-3`})}),(0,y.jsx)(u,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(i,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,f,`?`]}),(0,y.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(a,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(a,{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-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,r,t as i}from"./createLucideIcon-C6JENrH3.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{T as o,t as s}from"./api-BBFo3oc-.js";import{C as c,D as l,S as u,b as d,k as f}from"./dialog-DI1-uj7G.js";import{n as p}from"./x-C-HTKvar.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(r(),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)(c.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 d(()=>{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]=l(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,l=f(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),p=d?.[0],h=d?.[1];return r?null:(0,$.jsx)(c.div,{"data-radix-popper-side":p,"data-radix-popper-align":h,...i,ref:l})});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:l=!0,collisionBoundary:p=[],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=f(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(p)?p:[p],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}),l&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),l&&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;d(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=u(y);d(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return d(()=>{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)(c.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:p(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:p(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(c.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:p(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=i(`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=i(`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:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),u(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:p(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>f(t),className:p(`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===d,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)(()=>a(()=>import(`./Terminal-CX7z9Fpb.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),vn=null;async function yn(){vn=(await a(()=>import(`./Terminal-CX7z9Fpb.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).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-BzDAcHMO.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/createLucideIcon-C6JENrH3.js","assets/api-BBFo3oc-.js","assets/x-C-HTKvar.js","assets/file-links-CZ2K_lr6.js","assets/index-DzKOX38n.js","assets/preload-helper-Czpn1I53.js","assets/dialog-DI1-uj7G.js","assets/index-CvsABxea.css","assets/use-find-controls-Bl_efA6K.js","assets/chevron-down-DPOlcAF_.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,r,t as i}from"./createLucideIcon-C6JENrH3.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{T as o,t as s}from"./api-BBFo3oc-.js";import{C as c,D as l,S as u,b as d,k as f}from"./dialog-DI1-uj7G.js";import{n as p}from"./x-C-HTKvar.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(r(),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)(c.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 d(()=>{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]=l(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,l=f(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),p=d?.[0],h=d?.[1];return r?null:(0,$.jsx)(c.div,{"data-radix-popper-side":p,"data-radix-popper-align":h,...i,ref:l})});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:l=!0,collisionBoundary:p=[],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=f(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(p)?p:[p],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}),l&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),l&&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;d(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=u(y);d(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return d(()=>{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)(c.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:p(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:p(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(c.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:p(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=i(`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=i(`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:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),u(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:p(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>f(t),className:p(`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===d,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)(()=>a(()=>import(`./Terminal-BzDAcHMO.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),vn=null;async function yn(){vn=(await a(()=>import(`./Terminal-BzDAcHMO.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).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-
|
|
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-7XJyeYTl.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,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-Czw_C2pz.js","assets/preload-helper-Czpn1I53.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-_wZywoZs.js","assets/rolldown-runtime-QTnfLwEv.js","assets/chunk-DU6HZSFF-CCNUFaQT.js","assets/purify.es-sLXpNpJ5.js","assets/chunk-75Z2AOVW-kxCDxh6q.js","assets/dist-D9sYb5Oa.js","assets/chunk-CLGD4ZFX-pSu1f4n0.js","assets/chunk-PWAF6VOD-D1QREJv6.js","assets/chunk-GMAD6QVW-CYrdWVZ3.js","assets/chunk-P2QGCYS3-CkK7MDIt.js","assets/chunk-4HAMMTFA-BZ51_p7P.js","assets/rough.esm-CSKSodPl.js","assets/chunk-GVQU2GXP-eDWbw8E-.js","assets/chunk-OSK3NFVY-DgJh1Aoq.js","assets/line-Y9535-xV.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-L3NEJ4N5-BWoXa-mv.js","assets/chunk-TLUHSLCS-B7jq2TOO.js","assets/chunk-2E4U76K2-Co6b1Y97.js","assets/graphlib-DS17s2tU.js","assets/chunk-LNGE3PJU-DNNNwF8Y.js","assets/PdfViewer-BJyMmihS.js","assets/react-CZI7_Jkm.js","assets/createLucideIcon-C6JENrH3.js","assets/api-BBFo3oc-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{n as r}from"./createLucideIcon-C6JENrH3.js";import{A as i,B as a,I as o,K as s,N as c,O as l,P as u,R as d,V as f,c as p,g as m,h,i as g,m as _,n as v,p as y,s as b,v as ee,w as x,x as te,z as ne}from"./media-refresh-store-BmcKGDho.js";import{t as re}from"./preload-helper-Czpn1I53.js";import{T as ie,r as ae,t as oe}from"./api-BBFo3oc-.js";import{a as se,n as ce,r as le,t as ue}from"./use-find-controls-MrQ6ItX5.js";import{B as de,H as fe,Jn as pe,Kn as me,Pt as he,St as ge,U as _e,V as ve,Vt as ye,W as be,a as xe,ir as Se,jt as Ce,mn as we,mr as Te,nr as Ee,qn as De,tr as Oe,z as ke}from"./index-DtvjVJQS.js";import{t as Ae}from"./purify.es-sLXpNpJ5.js";import{a as je,c as Me,i as Ne,p as Pe,r as Fe}from"./editor.api2-4X9Vh9Zw.js";import{a as Ie,c as Le,d as Re,f as ze,i as Be,l as Ve,o as He,p as Ue,r as We,s as Ge,t as Ke,u as qe}from"./buffer-store-B_o7o_Pt.js";import{i as Je,n as Ye,r as Xe,t as Ze}from"./drafts-CZrBJe5X.js";import{r as Qe}from"./buffer-logic-BAkSBQT7.js";import{a as $e,i as et,n as tt,o as nt,r as rt}from"./editor-sync-W1bamxAP.js";var S=t(n(),1),it=new Map,at=new Map,ot=1;function st(e){for(let t of at.get(e)??[])t()}function ct(e,t){it.set(e,t),st(e)}function lt(e){let t={phase:`unresolved`,revision:ot++};return ct(e,t),t}function ut(e){let t=it.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(ct(e,{phase:`loading`,revision:t.revision}),t.revision)}function dt(e,t,n,r){let i=it.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(ct(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function ft(e,t){let n=it.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(ct(e,{...n,phase:`comparing`}),!0)}function pt(e,t,n){let r=it.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(ct(e,{phase:`load-error`,revision:t,message:n}),!0)}function mt(e,t){return t&&e?.phase===`unresolved`}function ht(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function gt(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function _t(e){return e.phase===`opening`||e.phase===`comparing`}function vt(e){it.delete(e)&&st(e)}function yt(e){return it.get(e)??null}function bt(e,t){let n=at.get(e);return n||(n=new Set,at.set(e,n)),n.add(t),()=>n.delete(t)}function xt(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var C=r();function St({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=pe(),l=(0,S.useId)(),u=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,S.useRef)(o);d.current=o;let f=(0,S.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,S.useRef)(p);return m.current=p,(0,S.useEffect)(()=>()=>m.current(),[]),(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,C.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,C.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,C.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,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(Ue,{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:Re,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(Ne.CtrlCmd|Fe.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...xt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Ct({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:_t(i)&&n.model?(0,C.jsx)(St,{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,C.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,C.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,C.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,C.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,C.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}var wt=`data-puddle-source-line`,Tt=`data-puddle-source-end-line`,Et=`data-puddle-source-line-count`;function Dt(e){return Number.isFinite(e.line)&&Number.isFinite(e.offset)}function Ot(e){let t=e.filter(Dt).map(({line:e,offset:t})=>({line:Math.max(1,e),offset:Math.max(0,t)})).sort((e,t)=>e.offset-t.offset||e.line-t.line),n=[];for(let e of t){let t=n.at(-1);t&&(e.line<t.line||e.offset<t.offset)||t&&(e.line===t.line||e.offset===t.offset)||n.push(e)}return n}function kt(e,t,n,r,i){return n<=t?r:r+Math.min(1,Math.max(0,(e-t)/(n-t)))*(i-r)}function At(e,t,n){if(e.length===0)return null;if(t<=e[0][n])return[e[0],e[0]];let r=e.at(-1);if(t>=r[n])return[r,r];let i=0,a=e.length-1;for(;i+1<a;){let r=Math.floor((i+a)/2);e[r][n]<=t?i=r:a=r}return[e[i],e[a]]}function jt(e,t){let n=At(e,t,`line`);return n?kt(t,n[0].line,n[1].line,n[0].offset,n[1].offset):null}function Mt(e,t){let n=At(e,t,`offset`);return n?kt(t,n[0].offset,n[1].offset,n[0].line,n[1].line):null}function Nt(e,t){let n=Number(e.getAttribute(t));return Number.isFinite(n)&&n>=1?n:null}function Pt(e,t,n){let r=e.getBoundingClientRect().top,i=[{line:1,offset:0}];for(let a of t.querySelectorAll(`[${wt}]`)){let t=Nt(a,wt);if(t===null||t>n+1||a.getClientRects().length===0)continue;let o=a.getBoundingClientRect(),s=o.top-r+e.scrollTop;i.push({line:t,offset:s});let c=Nt(a,Tt);c!==null&&c<=n+1&&c>t&&o.height>0&&i.push({line:c,offset:s+o.height})}return i.push({line:Math.max(1,n+1),offset:e.scrollHeight}),Ot(i)}function Ft(e){return e===``?1:e.split(/\r\n?|\n/).length}function It(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Lt(e,t,n){return It(e/Math.max(1,t-n))}function Rt(e,t,n){return It(e)*Math.max(0,t-n)}function zt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var Bt=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n,r=null){let i={ratio:It(n),sourceLine:r!==null&&Number.isFinite(r)?Math.max(1,r):null,revision:++this.revision},a=zt(e,t);this.positions.set(a,i);for(let e of this.listeners.get(a)??[])e(i);return i}get(e,t){return this.positions.get(zt(e,t))}subscribe(e,t,n){let r=zt(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 Vt(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function Ht(e,t,n,r){let i=Math.max(0,t-n);if(e.ratio<=0)return 0;if(e.ratio>=1)return i;if(e.sourceLine!==null&&r){let t=jt(r,e.sourceLine);if(t!==null)return Math.min(i,Math.max(0,t))}return Rt(e.ratio,t,n)}function Ut(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??Bt,r,i=t.sourceAnchors?.(),a=()=>void 0,o,s=t=>{r=t,e.scrollTop=Ht(t,e.scrollHeight,e.clientHeight,i)};t.receiver?a=n.subscribe(t.channel,t.target,s):t.driver&&(o=Vt(()=>{let r=Lt(e.scrollTop,e.scrollHeight,e.clientHeight),a=i?Mt(i,e.scrollTop):null;n.publish(t.channel,t.target,r,a)}),e.addEventListener(`scroll`,o.schedule,{passive:!0}),o.schedule());let c=new ResizeObserver(()=>{i=t.sourceAnchors?.(),t.receiver&&r?s(r):t.driver&&o?.schedule()});for(let e of t.resizeElements??[])c.observe(e);return()=>{t.driver&&o&&e.removeEventListener(`scroll`,o.schedule),a(),c.disconnect(),o?.dispose()}}function Wt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0)return null;let r=1,i=n;for(;r<i;){let n=Math.ceil((r+i)/2);e.getTopForLineNumber(n)<=t?r=n:i=n-1}let a=e.getTopForLineNumber(r),o=r<n?e.getTopForLineNumber(r+1):e.getScrollHeight();return o<=a?r:r+Math.min(1,Math.max(0,(t-a)/(o-a)))}function Gt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0||!Number.isFinite(t))return null;let r=Math.min(n+1,Math.max(1,t)),i=Math.floor(r);if(i>n)return e.getScrollHeight();let a=i+1,o=e.getTopForLineNumber(i),s=a<=n?e.getTopForLineNumber(a):e.getScrollHeight();return o+(r-i)*(s-o)}function Kt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??Bt,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t;let r=t.ratio>0&&t.ratio<1&&t.sourceLine!==null?Gt(e,t.sourceLine):null;e.setScrollTop(r??Ht(t,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))),i.push(e.onDidContentSizeChange(()=>a&&l(a)))):t.driver&&(s=Vt(()=>{let n=Lt(e.getScrollTop(),e.getScrollHeight(),c());r.publish(t.channel,t.target,n,Wt(e,e.getScrollTop()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidChangeModelContent(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),i.push(e.onDidContentSizeChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function qt(e){return!e}function Jt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=Ne.CtrlCmd:e===`ctrl`?r|=Ne.WinCtrl:e===`alt`?r|=Ne.Alt:e===`shift`&&(r|=Ne.Shift);let i=Fe[/^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 Yt(e,t){let n=Jt(Ce(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Jt(Ce(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>De({editorWordWrap:qt(me().editorWordWrap)})})}function Xt(e){return`file-conflict:${e}`}function Zt(e,t,n,r,i){let a=i?.passive===!0,o=i?.focused??!0,s=Ke(e,t,r),c=f(e,t,{root:r,live:i?.live}),l=ne(e,r),[u,d]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),h=(0,S.useRef)(!1),g=(0,S.useRef)(null),_=(0,S.useRef)(null),v=(0,S.useRef)(n);v.current=n;let y=(0,S.useRef)(!1),b=(0,S.useCallback)((e,t)=>{_.current?.cancel(),y.current=!0;try{Ge(s,e,t)}finally{y.current=!1}},[s]),x=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>qe(s,e),[s]),()=>Be(s)),re=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>nt(s,e),[s]),()=>$e(s)),ae=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>bt(s,e),[s]),()=>yt(s));(0,S.useEffect)(()=>{let n=c.data;if(!n||n.binary||n.content===null||h.current)return;h.current=!0;let i=Ve(s)!==void 0,a=We(e,t,n.content,n.mtime_ms,r),o=a.getValue();d(a),!i&&Je(e,t,r).then(i=>{if(!i)return;let s=Ye(i,o,n.mtime_ms);s===`discard`?Ze(e,t,r):s===`restore`?Qe(a,i.content)&&m(!0):ie(`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:()=>{Qe(a,i.content)&&m(!0)}}})})},[c.data,s,e,t,r]),(0,S.useEffect)(()=>{if(!u||a)return;let n=Xe(e,t,r);_.current=n;let i=u.onDidChangeContent(()=>{y.current||(n(u.getValue(),Ve(s)??0),tt(e,t,r))});return()=>{n.flush(),i.dispose(),_.current=null}},[u,s,e,t,r,a]),(0,S.useEffect)(()=>{!u||!re.savedElsewhere||Be(s)||c.refetch().then(e=>{Be(s)||(e.data&&e.data.content!==null&&b(e.data.content,e.data.mtime_ms),et(s))})},[re.savedElsewhere,u,s]),(0,S.useEffect)(()=>{let e=c.data;!u||!e||e.content===null||!Be(s)&&e.mtime_ms!==Ve(s)&&b(e.content,e.mtime_ms)},[c.data,u,s]);let se=(0,S.useCallback)((n,i)=>{Ie(s,n,i),_.current?.cancel(),Ze(e,t,r),rt(e,t,i,r),m(!1),vt(s)},[s,e,t,r]),ce=(0,S.useCallback)(()=>{let e=ut(s);e!==null&&(ie.dismiss(Xt(s)),c.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.`);dt(s,e,n.content,n.mtime_ms)}).catch(t=>{pt(s,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[c,s]),le=(0,S.useRef)(ce);le.current=ce,(0,S.useEffect)(()=>{if(!mt(ae,o))return;let e=Xt(s);return ie(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>le.current()}}),()=>{ie.dismiss(e)}},[ae,o,s]);let ue=(0,S.useCallback)(()=>{c.refetch().then(n=>{n.data&&n.data.content!==null&&b(n.data.content,n.data.mtime_ms),Ze(e,t,r),m(!1),vt(s)})},[s,e,t,b]),de=(0,S.useCallback)((e,n)=>{l.mutate({path:t,content:e},{onSuccess:e=>se(n,e.mtime_ms),onError:e=>ie.error(e instanceof Error?e.message:`Overwrite failed`)})},[l,t,se]),fe=(0,S.useCallback)(async()=>{if(!u||!Be(s))return!0;let e=u.getValue(),n=u.getAlternativeVersionId();if(gt(yt(s)))return!1;let r=ht(yt(s))??Ve(s);try{let i=await l.mutateAsync({path:t,content:e,expected_mtime_ms:r});return se(n,i.mtime_ms),!0}catch(e){return e instanceof oe&&e.status===409&&e.code===`stale_file`?lt(s):ie.error(e instanceof Error?e.message:`Save failed`),!1}},[u,s,l,t,se]),pe=(0,S.useRef)(fe);pe.current=fe,(0,S.useEffect)(()=>ee(te(e,t,r),()=>pe.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let me=(0,S.useCallback)(()=>{let n=g.current,i=v.current;!n||!i||i.session!==e||i.path!==t||(i.root??void 0)!==(r??void 0)||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus())},[e,t,r]),he=(0,S.useCallback)(e=>{g.current=e,Yt(e,{onSave:()=>pe.current()}),me()},[me]);(0,S.useEffect)(()=>{me()},[n,u,me]);let ge=(0,S.useCallback)(()=>{ue()},[ue]),_e=(0,S.useCallback)(()=>{!u||yt(s)?.phase!==`comparing`||de(u.getValue(),u.getAlternativeVersionId())},[u,s,de]),ve=(0,S.useCallback)(e=>{ft(s,e)},[s]),ye,be=null;c.data?.binary?ye=`binary`:c.error?c.error instanceof oe&&c.error.status===413?ye=`too-large`:(ye=`error`,be=c.error instanceof Error?c.error.message:`Failed to load file`):ye=u?`ready`:`loading`;let xe=x&&re.savedElsewhere?`saved-elsewhere`:x&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:ye,errorMessage:be,model:u,dirty:x,restoredNotice:p,discardRestore:ge,peerBadge:xe,conflict:ae,takeDisk:ue,keepMine:_e,compare:ce,comparisonReady:ve,save:fe,onMount:he}}function Qt(e,t,n,r){for(let i of e)if(rn([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function $t(e,t){return tn(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function en(e){let t=tn(e.originalStartLineNumber,e.originalEndLineNumber),n=tn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function tn(e,t){return t===0?0:Math.max(0,t-e+1)}function nn(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 rn(e,t){let n=[];for(let r of e){let e=tn(r.originalStartLineNumber,r.originalEndLineNumber),i=tn(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(nn(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(nn(r.modifiedStartLineNumber+i,t))}return n}var an=28,on=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function sn(e){if(e){for(let[t,n]of on)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function cn({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,Pe.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(Pe.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:$t(s,n.getLineCount()),heightInPx:an+en(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=Pe.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(Pe.EditorOption.fontFamily),fontSize:e.getOption(Pe.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!==Pe.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=Qt(i,t,n.getLineCount(),sn(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=Qt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=$t(o,n.getLineCount()),r.zone.heightInPx=an+en(o)*e.getOption(Pe.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var ln={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function un(e,t,n,r){let i=we(),a=o(e,t,{root:n,enabled:i.data!==void 0&&ge(i.data.protocol)&&r!==null}),[s,c]=(0,S.useState)(null),l=(0,S.useCallback)(e=>{c(e)},[]);return(0,S.useEffect)(()=>{let e=a.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=Pe.createModel(e.exists?e.content??``:``,r.getLanguageId()),o=Pe.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();o.setModel({original:i,modified:r});let l=cn({editor:s,original:i,modified:r,path:t}),u=()=>{let e=o.getLineChanges();e&&(l.update(e),c.set(rn(e,r.getLineCount()).map(e=>({range:new Me(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:ln[e.kind]}}))))},d=o.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),o.setModel(null),o.dispose(),i.dispose(),n.remove()}},[s,r,a.data]),l}function dn({message:e,session:t,path:n,root:r,download:i}){return(0,C.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,C.jsx)(`span`,{children:e}),i&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>void l(t,n,r).catch(e=>ie.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,C.jsx)(s,{className:`size-4`}),`Download`]})]})}function fn({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=pe(),l=Zt(e,t,n,r,{focused:i}),u=x(e,t,r),d=un(e,t,r,l.model),f=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[p,m]=(0,S.useState)(null),h=(0,S.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),g=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,S.useEffect)(()=>{if(!(!p||!l.model||g))return Kt(p,{channel:s,target:h,driver:a,receiver:o},Pe.ScrollType.Immediate)},[p,l.model,g,s,h,a,o]),(0,S.useEffect)(()=>{let e=l.model;e&&Pe.setModelMarkers(e,`puddle-compilation`,u.map(t=>{let n=Math.min(t.line,e.getLineCount()),r=e.getLineMaxColumn(n),i=Math.min(t.column??1,r),a=t.end_line??n,o=Math.max(n,Math.min(a,e.getLineCount())),s=e.getLineMaxColumn(o),c=Math.min(t.end_column??(t.column?i+1:s),s);return{severity:t.severity===`error`?je.Error:t.severity===`warning`?je.Warning:je.Info,message:t.message,source:`Puddle compilation`,startLineNumber:n,startColumn:i,endLineNumber:o,endColumn:Math.max(i,c)}}))},[l.model,u]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,C.jsx)(Ct,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,C.jsx)(dn,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,C.jsx)(dn,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,C.jsx)(dn,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let _=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,C.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,C.jsx)(`span`,{children:`Restored unsaved changes`}),(0,C.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),_&&(0,C.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:_}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,C.jsx)(ze,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),d(e),m(e)},loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:f,fontSize:c.editorFontSize,...xt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function pn({children:e}){return(0,C.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function mn(e,t){let n=(0,S.useRef)(t);n.current=t,(0,S.useEffect)(()=>(Le(e),()=>{n.current?.(),He(e)}),[e])}function hn(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function gn({session:e,refName:t,path:n,content:r}){let i=pe(),a=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,C.jsx)(ze,{path:hn(`puddle-view`,e,t,n),defaultValue:r,theme:Re,loading:(0,C.jsx)(pn,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...xt(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function _n({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=u(e,t,n,{root:r,enabled:!i}),o=d(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,C.jsx)(pn,{children:`…`}):s.error?(0,C.jsx)(pn,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,C.jsx)(pn,{children:`Binary file — deleted`}):(0,C.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,C.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(gn,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function vn({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=pe(),c=Zt(e,n,null,i,{focused:o}),l=u(e,t,r,{root:i,enabled:!a}),f=d(e,r,{root:i,enabled:a}),p=a?f:l,m=(0,S.useRef)(null);mn(Ke(e,n,i),()=>{let e=m.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),m.current=null});let h=(0,S.useRef)(c.save);h.current=c.save;let g=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),_=p.error instanceof oe&&p.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,C.jsx)(Ct,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||p.data?.binary?(0,C.jsx)(pn,{children:`Binary file`}):c.status===`too-large`?(0,C.jsx)(pn,{children:`File too large to show`}):c.status===`error`?(0,C.jsx)(pn,{children:c.errorMessage??`Failed to load file`}):_||a&&f.data&&!f.data.exists?(0,C.jsx)(fn,{session:e,path:n,reveal:null,root:i,focused:o}):p.isPending||!c.model?(0,C.jsx)(pn,{children:`…`}):p.error?(0,C.jsx)(pn,{children:p.error instanceof Error?p.error.message:`Failed to load base`}):(0,C.jsx)(Ue,{modifiedModelPath:c.model.uri.toString(),originalModelPath:hn(`puddle-base`,e,`${t}:${i??``}`,r),original:p.data.content??``,language:c.model.getLanguageId(),theme:Re,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(pn,{children:`…`}),onMount:e=>{m.current=e,e.onDidDispose(()=>{m.current=null}),e.getModifiedEditor().addCommand(Ne.CtrlCmd|Fe.KeyS,()=>h.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...xt(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function yn({session:e,against:t,entry:n,root:r}){let i=pe(),a=n.old_path??n.path,o=u(e,t,a,{root:r,enabled:n.status!==`added`}),s=d(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,C.jsx)(_n,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,C.jsx)(pn,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,C.jsx)(pn,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,C.jsx)(pn,{children:`Binary file`}):n.status===`added`?(0,C.jsx)(gn,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,C.jsx)(Ue,{originalModelPath:hn(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:hn(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Re,loading:(0,C.jsx)(pn,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...xt(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,C.jsx)(pn,{children:`Failed to load HEAD content`})}function bn({session:e,path:t,root:n,focused:r}){return mn(Ke(e,t,n)),(0,C.jsx)(fn,{session:e,path:t,reveal:null,root:n,focused:r})}function xn({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,C.jsx)(yn,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,C.jsx)(bn,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,C.jsx)(_n,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,C.jsx)(vn,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function Sn({session:e,sha:t,path:n,root:r}){let i=u(e,t,n,{root:r});return i.isPending?(0,C.jsx)(pn,{children:`…`}):i.error?(0,C.jsx)(pn,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,C.jsx)(pn,{children:`Binary file`}):(0,C.jsx)(gn,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function Cn({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=pe(),l=(0,S.useRef)(null),u=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,S.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,C.jsx)(Ue,{originalModelPath:hn(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:hn(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Re,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(pn,{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,...xt(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function wn({session:e,sha:t,path:n,basePath:r,root:i}){let a=u(e,`${t}^`,r,{root:i}),o=u(e,t,n,{root:i});return a.error instanceof oe&&a.error.status===404?(0,C.jsx)(Sn,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,C.jsx)(pn,{children:`…`}):a.error?(0,C.jsx)(pn,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,C.jsx)(pn,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,C.jsx)(pn,{children:`Binary file`}):(0,C.jsx)(Cn,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function Tn({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(m(n.status,r)){case`added`:return(0,C.jsx)(Sn,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,C.jsx)(_n,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,C.jsx)(wn,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function En({session:e,sha:t,path:n,root:r}){let i=c(e,t,r);if(i.isPending)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,C.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,C.jsx)(`div`,{className:`h-full`,children:(0,C.jsx)(Tn,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,C.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,C.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,C.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Dn({session:e,path:t,root:n,area:r,focused:i=!0}){let o=a(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(o.isPending)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(o.error)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load diff`});let s=o.data.entries.find(e=>e.path===t);return s?(0,C.jsx)(`div`,{className:`h-full`,children:(0,C.jsx)(xn,{session:e,against:o.data.against,entry:s,root:n,area:r,focused:i})}):(0,C.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,C.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var On=800;function kn({name:e}){let t=pe(),n=ye(),r=h(n,e),i=Te(),a=he(`editor.save`),o=(0,S.useRef)(null),s=(0,S.useRef)(null),c=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,S.useEffect)(()=>{if(n===null)return;let t=xe(t=>{y(n,e,t).catch(e=>ie.error(e instanceof Error?e.message:`Draft not saved`))},On);return s.current=t,()=>{t.flush(),s.current=null}},[n,e]),n===null)return null;if(r.error)return(0,C.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,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let l=()=>{let t=o.current;t&&(s.current?.flush(),p({name:e,content:t.getValue()}))};return(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,C.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,a,` saves it into one`]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(ze,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Re,keepCurrentModel:!1,loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{o.current=t,b(e,t.getValue()),Yt(t,{onSave:l})},onChange:t=>{let r=t??``;b(e,r),_(i,n,e,r),s.current?.(r)},options:{automaticLayout:!0,fontFamily:c,fontSize:t.editorFontSize,...xt(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}var An=0;function jn(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 Mn(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 Nn=class{root;matchName=`puddle-find-${++An}-match`;activeName=`puddle-find-${An}-active`;style;signature=``;ranges=[];index=-1;limited=!1;constructor(e){this.root=e,this.style=document.createElement(`style`),this.style.textContent=`
|
|
2
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{n as r}from"./createLucideIcon-C6JENrH3.js";import{A as i,B as a,I as o,K as s,N as c,O as l,P as u,R as d,V as f,c as p,g as m,h,i as g,m as _,n as v,p as y,s as b,v as ee,w as x,x as te,z as ne}from"./media-refresh-store-PUCHJ25x.js";import{t as re}from"./preload-helper-Czpn1I53.js";import{T as ie,r as ae,t as oe}from"./api-BBFo3oc-.js";import{a as se,n as ce,r as le,t as ue}from"./use-find-controls-Bl_efA6K.js";import{B as de,H as fe,Jn as pe,Kn as me,Pt as he,St as ge,U as _e,V as ve,Vt as ye,W as be,a as xe,ir as Se,jt as Ce,mn as we,mr as Te,nr as Ee,qn as De,tr as Oe,z as ke}from"./index-DzKOX38n.js";import{t as Ae}from"./purify.es-sLXpNpJ5.js";import{a as je,c as Me,i as Ne,p as Pe,r as Fe}from"./editor.api2-4X9Vh9Zw.js";import{a as Ie,c as Le,d as Re,f as ze,i as Be,l as Ve,o as He,p as Ue,r as We,s as Ge,t as Ke,u as qe}from"./buffer-store-7XJyeYTl.js";import{i as Je,n as Ye,r as Xe,t as Ze}from"./drafts-BJXURaei.js";import{r as Qe}from"./buffer-logic-BAkSBQT7.js";import{a as $e,i as et,n as tt,o as nt,r as rt}from"./editor-sync-W1bamxAP.js";var S=t(n(),1),it=new Map,at=new Map,ot=1;function st(e){for(let t of at.get(e)??[])t()}function ct(e,t){it.set(e,t),st(e)}function lt(e){let t={phase:`unresolved`,revision:ot++};return ct(e,t),t}function ut(e){let t=it.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(ct(e,{phase:`loading`,revision:t.revision}),t.revision)}function dt(e,t,n,r){let i=it.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(ct(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function ft(e,t){let n=it.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(ct(e,{...n,phase:`comparing`}),!0)}function pt(e,t,n){let r=it.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(ct(e,{phase:`load-error`,revision:t,message:n}),!0)}function mt(e,t){return t&&e?.phase===`unresolved`}function ht(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function gt(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function _t(e){return e.phase===`opening`||e.phase===`comparing`}function vt(e){it.delete(e)&&st(e)}function yt(e){return it.get(e)??null}function bt(e,t){let n=at.get(e);return n||(n=new Set,at.set(e,n)),n.add(t),()=>n.delete(t)}function xt(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var C=r();function St({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=pe(),l=(0,S.useId)(),u=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,S.useRef)(o);d.current=o;let f=(0,S.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,S.useRef)(p);return m.current=p,(0,S.useEffect)(()=>()=>m.current(),[]),(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,C.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,C.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,C.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,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(Ue,{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:Re,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(Ne.CtrlCmd|Fe.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...xt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Ct({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:_t(i)&&n.model?(0,C.jsx)(St,{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,C.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,C.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,C.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,C.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,C.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}var wt=`data-puddle-source-line`,Tt=`data-puddle-source-end-line`,Et=`data-puddle-source-line-count`;function Dt(e){return Number.isFinite(e.line)&&Number.isFinite(e.offset)}function Ot(e){let t=e.filter(Dt).map(({line:e,offset:t})=>({line:Math.max(1,e),offset:Math.max(0,t)})).sort((e,t)=>e.offset-t.offset||e.line-t.line),n=[];for(let e of t){let t=n.at(-1);t&&(e.line<t.line||e.offset<t.offset)||t&&(e.line===t.line||e.offset===t.offset)||n.push(e)}return n}function kt(e,t,n,r,i){return n<=t?r:r+Math.min(1,Math.max(0,(e-t)/(n-t)))*(i-r)}function At(e,t,n){if(e.length===0)return null;if(t<=e[0][n])return[e[0],e[0]];let r=e.at(-1);if(t>=r[n])return[r,r];let i=0,a=e.length-1;for(;i+1<a;){let r=Math.floor((i+a)/2);e[r][n]<=t?i=r:a=r}return[e[i],e[a]]}function jt(e,t){let n=At(e,t,`line`);return n?kt(t,n[0].line,n[1].line,n[0].offset,n[1].offset):null}function Mt(e,t){let n=At(e,t,`offset`);return n?kt(t,n[0].offset,n[1].offset,n[0].line,n[1].line):null}function Nt(e,t){let n=Number(e.getAttribute(t));return Number.isFinite(n)&&n>=1?n:null}function Pt(e,t,n){let r=e.getBoundingClientRect().top,i=[{line:1,offset:0}];for(let a of t.querySelectorAll(`[${wt}]`)){let t=Nt(a,wt);if(t===null||t>n+1||a.getClientRects().length===0)continue;let o=a.getBoundingClientRect(),s=o.top-r+e.scrollTop;i.push({line:t,offset:s});let c=Nt(a,Tt);c!==null&&c<=n+1&&c>t&&o.height>0&&i.push({line:c,offset:s+o.height})}return i.push({line:Math.max(1,n+1),offset:e.scrollHeight}),Ot(i)}function Ft(e){return e===``?1:e.split(/\r\n?|\n/).length}function It(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Lt(e,t,n){return It(e/Math.max(1,t-n))}function Rt(e,t,n){return It(e)*Math.max(0,t-n)}function zt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var Bt=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n,r=null){let i={ratio:It(n),sourceLine:r!==null&&Number.isFinite(r)?Math.max(1,r):null,revision:++this.revision},a=zt(e,t);this.positions.set(a,i);for(let e of this.listeners.get(a)??[])e(i);return i}get(e,t){return this.positions.get(zt(e,t))}subscribe(e,t,n){let r=zt(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 Vt(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function Ht(e,t,n,r){let i=Math.max(0,t-n);if(e.ratio<=0)return 0;if(e.ratio>=1)return i;if(e.sourceLine!==null&&r){let t=jt(r,e.sourceLine);if(t!==null)return Math.min(i,Math.max(0,t))}return Rt(e.ratio,t,n)}function Ut(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??Bt,r,i=t.sourceAnchors?.(),a=()=>void 0,o,s=t=>{r=t,e.scrollTop=Ht(t,e.scrollHeight,e.clientHeight,i)};t.receiver?a=n.subscribe(t.channel,t.target,s):t.driver&&(o=Vt(()=>{let r=Lt(e.scrollTop,e.scrollHeight,e.clientHeight),a=i?Mt(i,e.scrollTop):null;n.publish(t.channel,t.target,r,a)}),e.addEventListener(`scroll`,o.schedule,{passive:!0}),o.schedule());let c=new ResizeObserver(()=>{i=t.sourceAnchors?.(),t.receiver&&r?s(r):t.driver&&o?.schedule()});for(let e of t.resizeElements??[])c.observe(e);return()=>{t.driver&&o&&e.removeEventListener(`scroll`,o.schedule),a(),c.disconnect(),o?.dispose()}}function Wt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0)return null;let r=1,i=n;for(;r<i;){let n=Math.ceil((r+i)/2);e.getTopForLineNumber(n)<=t?r=n:i=n-1}let a=e.getTopForLineNumber(r),o=r<n?e.getTopForLineNumber(r+1):e.getScrollHeight();return o<=a?r:r+Math.min(1,Math.max(0,(t-a)/(o-a)))}function Gt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0||!Number.isFinite(t))return null;let r=Math.min(n+1,Math.max(1,t)),i=Math.floor(r);if(i>n)return e.getScrollHeight();let a=i+1,o=e.getTopForLineNumber(i),s=a<=n?e.getTopForLineNumber(a):e.getScrollHeight();return o+(r-i)*(s-o)}function Kt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??Bt,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t;let r=t.ratio>0&&t.ratio<1&&t.sourceLine!==null?Gt(e,t.sourceLine):null;e.setScrollTop(r??Ht(t,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))),i.push(e.onDidContentSizeChange(()=>a&&l(a)))):t.driver&&(s=Vt(()=>{let n=Lt(e.getScrollTop(),e.getScrollHeight(),c());r.publish(t.channel,t.target,n,Wt(e,e.getScrollTop()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidChangeModelContent(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),i.push(e.onDidContentSizeChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function qt(e){return!e}function Jt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=Ne.CtrlCmd:e===`ctrl`?r|=Ne.WinCtrl:e===`alt`?r|=Ne.Alt:e===`shift`&&(r|=Ne.Shift);let i=Fe[/^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 Yt(e,t){let n=Jt(Ce(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Jt(Ce(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>De({editorWordWrap:qt(me().editorWordWrap)})})}function Xt(e){return`file-conflict:${e}`}function Zt(e,t,n,r,i){let a=i?.passive===!0,o=i?.focused??!0,s=Ke(e,t,r),c=f(e,t,{root:r,live:i?.live}),l=ne(e,r),[u,d]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),h=(0,S.useRef)(!1),g=(0,S.useRef)(null),_=(0,S.useRef)(null),v=(0,S.useRef)(n);v.current=n;let y=(0,S.useRef)(!1),b=(0,S.useCallback)((e,t)=>{_.current?.cancel(),y.current=!0;try{Ge(s,e,t)}finally{y.current=!1}},[s]),x=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>qe(s,e),[s]),()=>Be(s)),re=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>nt(s,e),[s]),()=>$e(s)),ae=(0,S.useSyncExternalStore)((0,S.useCallback)(e=>bt(s,e),[s]),()=>yt(s));(0,S.useEffect)(()=>{let n=c.data;if(!n||n.binary||n.content===null||h.current)return;h.current=!0;let i=Ve(s)!==void 0,a=We(e,t,n.content,n.mtime_ms,r),o=a.getValue();d(a),!i&&Je(e,t,r).then(i=>{if(!i)return;let s=Ye(i,o,n.mtime_ms);s===`discard`?Ze(e,t,r):s===`restore`?Qe(a,i.content)&&m(!0):ie(`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:()=>{Qe(a,i.content)&&m(!0)}}})})},[c.data,s,e,t,r]),(0,S.useEffect)(()=>{if(!u||a)return;let n=Xe(e,t,r);_.current=n;let i=u.onDidChangeContent(()=>{y.current||(n(u.getValue(),Ve(s)??0),tt(e,t,r))});return()=>{n.flush(),i.dispose(),_.current=null}},[u,s,e,t,r,a]),(0,S.useEffect)(()=>{!u||!re.savedElsewhere||Be(s)||c.refetch().then(e=>{Be(s)||(e.data&&e.data.content!==null&&b(e.data.content,e.data.mtime_ms),et(s))})},[re.savedElsewhere,u,s]),(0,S.useEffect)(()=>{let e=c.data;!u||!e||e.content===null||!Be(s)&&e.mtime_ms!==Ve(s)&&b(e.content,e.mtime_ms)},[c.data,u,s]);let se=(0,S.useCallback)((n,i)=>{Ie(s,n,i),_.current?.cancel(),Ze(e,t,r),rt(e,t,i,r),m(!1),vt(s)},[s,e,t,r]),ce=(0,S.useCallback)(()=>{let e=ut(s);e!==null&&(ie.dismiss(Xt(s)),c.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.`);dt(s,e,n.content,n.mtime_ms)}).catch(t=>{pt(s,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[c,s]),le=(0,S.useRef)(ce);le.current=ce,(0,S.useEffect)(()=>{if(!mt(ae,o))return;let e=Xt(s);return ie(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>le.current()}}),()=>{ie.dismiss(e)}},[ae,o,s]);let ue=(0,S.useCallback)(()=>{c.refetch().then(n=>{n.data&&n.data.content!==null&&b(n.data.content,n.data.mtime_ms),Ze(e,t,r),m(!1),vt(s)})},[s,e,t,b]),de=(0,S.useCallback)((e,n)=>{l.mutate({path:t,content:e},{onSuccess:e=>se(n,e.mtime_ms),onError:e=>ie.error(e instanceof Error?e.message:`Overwrite failed`)})},[l,t,se]),fe=(0,S.useCallback)(async()=>{if(!u||!Be(s))return!0;let e=u.getValue(),n=u.getAlternativeVersionId();if(gt(yt(s)))return!1;let r=ht(yt(s))??Ve(s);try{let i=await l.mutateAsync({path:t,content:e,expected_mtime_ms:r});return se(n,i.mtime_ms),!0}catch(e){return e instanceof oe&&e.status===409&&e.code===`stale_file`?lt(s):ie.error(e instanceof Error?e.message:`Save failed`),!1}},[u,s,l,t,se]),pe=(0,S.useRef)(fe);pe.current=fe,(0,S.useEffect)(()=>ee(te(e,t,r),()=>pe.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let me=(0,S.useCallback)(()=>{let n=g.current,i=v.current;!n||!i||i.session!==e||i.path!==t||(i.root??void 0)!==(r??void 0)||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus())},[e,t,r]),he=(0,S.useCallback)(e=>{g.current=e,Yt(e,{onSave:()=>pe.current()}),me()},[me]);(0,S.useEffect)(()=>{me()},[n,u,me]);let ge=(0,S.useCallback)(()=>{ue()},[ue]),_e=(0,S.useCallback)(()=>{!u||yt(s)?.phase!==`comparing`||de(u.getValue(),u.getAlternativeVersionId())},[u,s,de]),ve=(0,S.useCallback)(e=>{ft(s,e)},[s]),ye,be=null;c.data?.binary?ye=`binary`:c.error?c.error instanceof oe&&c.error.status===413?ye=`too-large`:(ye=`error`,be=c.error instanceof Error?c.error.message:`Failed to load file`):ye=u?`ready`:`loading`;let xe=x&&re.savedElsewhere?`saved-elsewhere`:x&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:ye,errorMessage:be,model:u,dirty:x,restoredNotice:p,discardRestore:ge,peerBadge:xe,conflict:ae,takeDisk:ue,keepMine:_e,compare:ce,comparisonReady:ve,save:fe,onMount:he}}function Qt(e,t,n,r){for(let i of e)if(rn([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function $t(e,t){return tn(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function en(e){let t=tn(e.originalStartLineNumber,e.originalEndLineNumber),n=tn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function tn(e,t){return t===0?0:Math.max(0,t-e+1)}function nn(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 rn(e,t){let n=[];for(let r of e){let e=tn(r.originalStartLineNumber,r.originalEndLineNumber),i=tn(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(nn(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(nn(r.modifiedStartLineNumber+i,t))}return n}var an=28,on=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function sn(e){if(e){for(let[t,n]of on)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function cn({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,Pe.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(Pe.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:$t(s,n.getLineCount()),heightInPx:an+en(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=Pe.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(Pe.EditorOption.fontFamily),fontSize:e.getOption(Pe.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!==Pe.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=Qt(i,t,n.getLineCount(),sn(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=Qt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=$t(o,n.getLineCount()),r.zone.heightInPx=an+en(o)*e.getOption(Pe.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var ln={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function un(e,t,n,r){let i=we(),a=o(e,t,{root:n,enabled:i.data!==void 0&&ge(i.data.protocol)&&r!==null}),[s,c]=(0,S.useState)(null),l=(0,S.useCallback)(e=>{c(e)},[]);return(0,S.useEffect)(()=>{let e=a.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=Pe.createModel(e.exists?e.content??``:``,r.getLanguageId()),o=Pe.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();o.setModel({original:i,modified:r});let l=cn({editor:s,original:i,modified:r,path:t}),u=()=>{let e=o.getLineChanges();e&&(l.update(e),c.set(rn(e,r.getLineCount()).map(e=>({range:new Me(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:ln[e.kind]}}))))},d=o.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),o.setModel(null),o.dispose(),i.dispose(),n.remove()}},[s,r,a.data]),l}function dn({message:e,session:t,path:n,root:r,download:i}){return(0,C.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,C.jsx)(`span`,{children:e}),i&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>void l(t,n,r).catch(e=>ie.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,C.jsx)(s,{className:`size-4`}),`Download`]})]})}function fn({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=pe(),l=Zt(e,t,n,r,{focused:i}),u=x(e,t,r),d=un(e,t,r,l.model),f=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[p,m]=(0,S.useState)(null),h=(0,S.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),g=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,S.useEffect)(()=>{if(!(!p||!l.model||g))return Kt(p,{channel:s,target:h,driver:a,receiver:o},Pe.ScrollType.Immediate)},[p,l.model,g,s,h,a,o]),(0,S.useEffect)(()=>{let e=l.model;e&&Pe.setModelMarkers(e,`puddle-compilation`,u.map(t=>{let n=Math.min(t.line,e.getLineCount()),r=e.getLineMaxColumn(n),i=Math.min(t.column??1,r),a=t.end_line??n,o=Math.max(n,Math.min(a,e.getLineCount())),s=e.getLineMaxColumn(o),c=Math.min(t.end_column??(t.column?i+1:s),s);return{severity:t.severity===`error`?je.Error:t.severity===`warning`?je.Warning:je.Info,message:t.message,source:`Puddle compilation`,startLineNumber:n,startColumn:i,endLineNumber:o,endColumn:Math.max(i,c)}}))},[l.model,u]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,C.jsx)(Ct,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,C.jsx)(dn,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,C.jsx)(dn,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,C.jsx)(dn,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let _=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,C.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,C.jsx)(`span`,{children:`Restored unsaved changes`}),(0,C.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),_&&(0,C.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:_}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,C.jsx)(ze,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),d(e),m(e)},loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:f,fontSize:c.editorFontSize,...xt(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function pn({children:e}){return(0,C.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function mn(e,t){let n=(0,S.useRef)(t);n.current=t,(0,S.useEffect)(()=>(Le(e),()=>{n.current?.(),He(e)}),[e])}function hn(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function gn({session:e,refName:t,path:n,content:r}){let i=pe(),a=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,C.jsx)(ze,{path:hn(`puddle-view`,e,t,n),defaultValue:r,theme:Re,loading:(0,C.jsx)(pn,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...xt(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function _n({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=u(e,t,n,{root:r,enabled:!i}),o=d(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,C.jsx)(pn,{children:`…`}):s.error?(0,C.jsx)(pn,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,C.jsx)(pn,{children:`Binary file — deleted`}):(0,C.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,C.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(gn,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function vn({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=pe(),c=Zt(e,n,null,i,{focused:o}),l=u(e,t,r,{root:i,enabled:!a}),f=d(e,r,{root:i,enabled:a}),p=a?f:l,m=(0,S.useRef)(null);mn(Ke(e,n,i),()=>{let e=m.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),m.current=null});let h=(0,S.useRef)(c.save);h.current=c.save;let g=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),_=p.error instanceof oe&&p.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,C.jsx)(Ct,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||p.data?.binary?(0,C.jsx)(pn,{children:`Binary file`}):c.status===`too-large`?(0,C.jsx)(pn,{children:`File too large to show`}):c.status===`error`?(0,C.jsx)(pn,{children:c.errorMessage??`Failed to load file`}):_||a&&f.data&&!f.data.exists?(0,C.jsx)(fn,{session:e,path:n,reveal:null,root:i,focused:o}):p.isPending||!c.model?(0,C.jsx)(pn,{children:`…`}):p.error?(0,C.jsx)(pn,{children:p.error instanceof Error?p.error.message:`Failed to load base`}):(0,C.jsx)(Ue,{modifiedModelPath:c.model.uri.toString(),originalModelPath:hn(`puddle-base`,e,`${t}:${i??``}`,r),original:p.data.content??``,language:c.model.getLanguageId(),theme:Re,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(pn,{children:`…`}),onMount:e=>{m.current=e,e.onDidDispose(()=>{m.current=null}),e.getModifiedEditor().addCommand(Ne.CtrlCmd|Fe.KeyS,()=>h.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...xt(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function yn({session:e,against:t,entry:n,root:r}){let i=pe(),a=n.old_path??n.path,o=u(e,t,a,{root:r,enabled:n.status!==`added`}),s=d(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,C.jsx)(_n,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,C.jsx)(pn,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,C.jsx)(pn,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,C.jsx)(pn,{children:`Binary file`}):n.status===`added`?(0,C.jsx)(gn,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,C.jsx)(Ue,{originalModelPath:hn(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:hn(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Re,loading:(0,C.jsx)(pn,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...xt(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,C.jsx)(pn,{children:`Failed to load HEAD content`})}function bn({session:e,path:t,root:n,focused:r}){return mn(Ke(e,t,n)),(0,C.jsx)(fn,{session:e,path:t,reveal:null,root:n,focused:r})}function xn({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,C.jsx)(yn,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,C.jsx)(bn,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,C.jsx)(_n,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,C.jsx)(vn,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function Sn({session:e,sha:t,path:n,root:r}){let i=u(e,t,n,{root:r});return i.isPending?(0,C.jsx)(pn,{children:`…`}):i.error?(0,C.jsx)(pn,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,C.jsx)(pn,{children:`Binary file`}):(0,C.jsx)(gn,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function Cn({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=pe(),l=(0,S.useRef)(null),u=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,S.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,C.jsx)(Ue,{originalModelPath:hn(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:hn(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Re,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,C.jsx)(pn,{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,...xt(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function wn({session:e,sha:t,path:n,basePath:r,root:i}){let a=u(e,`${t}^`,r,{root:i}),o=u(e,t,n,{root:i});return a.error instanceof oe&&a.error.status===404?(0,C.jsx)(Sn,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,C.jsx)(pn,{children:`…`}):a.error?(0,C.jsx)(pn,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,C.jsx)(pn,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,C.jsx)(pn,{children:`Binary file`}):(0,C.jsx)(Cn,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function Tn({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(m(n.status,r)){case`added`:return(0,C.jsx)(Sn,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,C.jsx)(_n,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,C.jsx)(wn,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function En({session:e,sha:t,path:n,root:r}){let i=c(e,t,r);if(i.isPending)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,C.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,C.jsx)(`div`,{className:`h-full`,children:(0,C.jsx)(Tn,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,C.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,C.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,C.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Dn({session:e,path:t,root:n,area:r,focused:i=!0}){let o=a(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(o.isPending)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(o.error)return(0,C.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load diff`});let s=o.data.entries.find(e=>e.path===t);return s?(0,C.jsx)(`div`,{className:`h-full`,children:(0,C.jsx)(xn,{session:e,against:o.data.against,entry:s,root:n,area:r,focused:i})}):(0,C.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,C.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var On=800;function kn({name:e}){let t=pe(),n=ye(),r=h(n,e),i=Te(),a=he(`editor.save`),o=(0,S.useRef)(null),s=(0,S.useRef)(null),c=(0,S.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,S.useEffect)(()=>{if(n===null)return;let t=xe(t=>{y(n,e,t).catch(e=>ie.error(e instanceof Error?e.message:`Draft not saved`))},On);return s.current=t,()=>{t.flush(),s.current=null}},[n,e]),n===null)return null;if(r.error)return(0,C.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,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let l=()=>{let t=o.current;t&&(s.current?.flush(),p({name:e,content:t.getValue()}))};return(0,C.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,C.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,a,` saves it into one`]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,C.jsx)(ze,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Re,keepCurrentModel:!1,loading:(0,C.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{o.current=t,b(e,t.getValue()),Yt(t,{onSave:l})},onChange:t=>{let r=t??``;b(e,r),_(i,n,e,r),s.current?.(r)},options:{automaticLayout:!0,fontFamily:c,fontSize:t.editorFontSize,...xt(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}var An=0;function jn(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 Mn(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 Nn=class{root;matchName=`puddle-find-${++An}-match`;activeName=`puddle-find-${An}-active`;style;signature=``;ranges=[];index=-1;limited=!1;constructor(e){this.root=e,this.style=document.createElement(`style`),this.style.textContent=`
|
|
3
3
|
::highlight(${this.matchName}) { background: var(--selection); }
|
|
4
4
|
::highlight(${this.activeName}) { background: var(--accent); color: var(--action-ink); }
|
|
5
5
|
`,document.head.appendChild(this.style)}find(e,t,n){let r=JSON.stringify([e,t]);if(r!==this.signature||n===`reset`){this.signature=r;let n=jn(this.root),i=se(n.text,e,t);if(this.ranges=i.matches.map(e=>Mn(e,n.nodes)).filter(e=>e!==null),this.limited=i.limited,this.index=this.ranges.length>0?0:-1,i.invalid)return this.clearHighlights(),{index:-1,count:0,invalid:!0}}else this.ranges.length>0&&(this.index=n===`previous`?(this.index-1+this.ranges.length)%this.ranges.length:(this.index+1)%this.ranges.length);return this.paint(),{index:this.index,count:this.ranges.length,limited:this.limited}}clear(){this.signature=``,this.ranges=[],this.index=-1,this.limited=!1,this.clearHighlights()}dispose(){this.clear(),this.style.remove()}clearHighlights(){CSS.highlights.delete(this.matchName),CSS.highlights.delete(this.activeName)}paint(){if(this.clearHighlights(),this.ranges.length===0)return;CSS.highlights.set(this.matchName,new Highlight(...this.ranges));let e=this.ranges[this.index];e&&(CSS.highlights.set(this.activeName,new Highlight(e)),e.startContainer.parentElement?.scrollIntoView({block:`center`,inline:`nearest`}))}},Pn={};function Fn(e){let t=Pn[e];if(t)return t;t=Pn[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);t.push(n)}for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[r]=`%`+(`0`+r.toString(16).toUpperCase()).slice(-2)}return t}function In(e,t){typeof t!=`string`&&(t=In.defaultChars);let n=Fn(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(e){let t=``;for(let r=0,i=e.length;r<i;r+=3){let a=parseInt(e.slice(r+1,r+3),16);if(a<128){t+=n[a];continue}if((a&224)==192&&r+3<i){let n=parseInt(e.slice(r+4,r+6),16);if((n&192)==128){let e=a<<6&1984|n&63;e<128?t+=`��`:t+=String.fromCharCode(e),r+=3;continue}}if((a&240)==224&&r+6<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16);if((n&192)==128&&(i&192)==128){let e=a<<12&61440|n<<6&4032|i&63;e<2048||e>=55296&&e<=57343?t+=`���`:t+=String.fromCharCode(e),r+=6;continue}}if((a&248)==240&&r+9<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16),o=parseInt(e.slice(r+10,r+12),16);if((n&192)==128&&(i&192)==128&&(o&192)==128){let e=a<<18&1835008|n<<12&258048|i<<6&4032|o&63;e<65536||e>1114111?t+=`����`:(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(e&1023))),r+=9;continue}}t+=`�`}return t})}In.defaultChars=`;/?:@&=+$,#`,In.componentChars=``;var Ln={};function Rn(e){let t=Ln[e];if(t)return t;t=Ln[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);/^[0-9a-z]$/i.test(n)?t.push(n):t.push(`%`+(`0`+e.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<e.length;n++)t[e.charCodeAt(n)]=e[n];return t}function zn(e,t,n){typeof t!=`string`&&(n=t,t=zn.defaultChars),n===void 0&&(n=!0);let r=Rn(t),i=``;for(let t=0,a=e.length;t<a;t++){let o=e.charCodeAt(t);if(n&&o===37&&t+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3))){i+=e.slice(t,t+3),t+=2;continue}if(o<128){i+=r[o];continue}if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<a){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+=`%EF%BF%BD`;continue}i+=encodeURIComponent(e[t])}return i}zn.defaultChars=`;/?:@&=+$,-_.!~*'()#`,zn.componentChars=`-_.!~*'()`;function Bn(e){let t=``;return t+=e.protocol||``,t+=e.slashes?`//`:``,t+=e.auth?e.auth+`@`:``,e.hostname&&e.hostname.indexOf(`:`)!==-1?t+=`[`+e.hostname+`]`:t+=e.hostname||``,t+=e.port?`:`+e.port:``,t+=e.pathname||``,t+=e.search||``,t+=e.hash||``,t}function Vn(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var Hn=/^([a-z0-9.+-]+:)/i,Un=/:[0-9]*$/,Wn=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Gn=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
|