@nathanstephenson/flow 0.1.10-beta.8 → 0.1.10-beta.9
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/build/backend-worker-chunks/{claude-THGSOTC2.mjs → claude-X57GT57M.mjs} +12 -4
- package/build/backend-worker-chunks/{pi-5LAWIJNE.mjs → pi-IZ3GX6HN.mjs} +5 -1
- package/build/backend-worker.mjs +7 -4
- package/dist/backend/claude/index.js +15 -4
- package/dist/backend/mcp.js +4 -1
- package/dist/backend/pi/index.js +6 -1
- package/dist/backend/worker/index.js +8 -3
- package/dist/build-id +1 -1
- package/dist/cli/bootstrap.js +1 -1
- package/dist/client/connection.js +46 -0
- package/dist/client/project-name.js +3 -1
- package/dist/client/scope-kind.js +4 -0
- package/dist/daemon/changes.js +22 -12
- package/dist/daemon/git.js +10 -1
- package/dist/daemon/host.js +248 -42
- package/dist/daemon/pull-request.js +90 -25
- package/dist/daemon/repository.js +15 -9
- package/dist/daemon/runtime.js +2 -0
- package/dist/daemon/server.js +25 -0
- package/dist/daemon/tour.js +7 -1
- package/dist/daemon/workflow-environment.js +6 -4
- package/dist/daemon/workflow-executions.js +1 -1
- package/dist/isolation/filesystem.js +1 -1
- package/dist/protocol/spend.js +1 -1
- package/dist/workflows/executors.js +2 -1
- package/package.json +1 -1
- package/web/dist/assets/index-CHFNROUs.js +51 -0
- package/web/dist/assets/index-D9AneSPi.css +2 -0
- package/web/dist/assets/{select-C-BND5Jn.js → select-COVn-75j.js} +1 -1
- package/web/dist/assets/{settings-mcp-DEU2AgQP.js → settings-mcp-BHZwEeJF.js} +1 -1
- package/web/dist/assets/{settings-secrets-29ZG3w6p.js → settings-secrets-NGSRhEbU.js} +1 -1
- package/web/dist/assets/settings-workflows-uew3ONyO.js +23 -0
- package/web/dist/assets/{workflow-api-DkUjAZ4w.js → workflow-api-3z2Qqsmo.js} +1 -1
- package/web/dist/assets/{workflows-DOxarXng.js → workflows-hcZXxss1.js} +2 -2
- package/web/dist/assets/{workflows-pane-DlaP2y8m.js → workflows-pane-DntY7Dcw.js} +1 -1
- package/web/dist/index.html +5 -5
- package/web/dist/assets/index-Cf28Ke0f.js +0 -51
- package/web/dist/assets/index-DBl7acBx.css +0 -2
- package/web/dist/assets/settings-workflows-CS_5CtP9.js +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-B0Z9INg1.js";import{$n as a,$t as o,A as s,An as c,Bn as l,C as u,E as d,En as f,Er as p,Gn as m,Hn as h,In as g,J as _,Jn as v,K as y,Kn as b,Kt as x,Mn as S,N as C,Nn as w,O as T,Or as E,P as D,Pn as O,Q as k,Qn as A,Rn as j,S as M,T as N,Tn as P,U as F,Un as I,Vn as L,Wn as R,Xn as ee,Y as z,Yn as B,Z as te,Zn as V,_ as ne,an as re,bn as ie,cr as ae,ct as oe,dr as se,et as ce,fr as le,ft as ue,g as de,gn as fe,gt as pe,ht as me,i as he,in as ge,j as _e,jn as ve,kn as ye,kr as be,l as xe,mn as Se,mt as Ce,nt as we,on as Te,ot as Ee,q as De,rn as Oe,rt as ke,sn as Ae,sr as je,st as Me,tn as Ne,tt as Pe,ur as Fe,v as Ie,wn as Le,wr as Re,x as ze,xn as Be,y as Ve,yn as He,yr as Ue,z as We}from"./workflow-api-
|
|
2
|
-
`)+1),fromSessionId:t.fromSessionId},...t.note===void 0?{}:{note:t.note},...t.attachments===void 0?{}:{attachments:t.attachments},at:n})};case`subagent_instruction`:return{...e,entries:hn(e.entries,{kind:`user`,id:t.id,text:t.text,producer:t.producer,at:n})};case`turn_started`:return{...e,turnInFlight:!0};case`message`:return{...e,entries:hn(e.entries,{kind:`assistant`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`thinking`:return{...e,entries:hn(e.entries,{kind:`thinking`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`tool_started`:return{...e,entries:hn(e.entries,{kind:`tool`,id:t.callId,name:t.name,input:t.input,status:`running`,...mn(t)})};case`tool_updated`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,update:t.update}))};case`tool_ended`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,result:t.result,status:t.isError?`error`:`complete`}))};case`subagent`:{let r=e.entries.find(e=>e.kind===`subagent`&&e.id===t.subagentId),i=r!==void 0&&an(r.status),a=an(t.state),o=a?void 0:r?.endedAt??n;return{...e,activeSubagents:e.activeSubagents+ +!!a-+!!i,entries:hn(e.entries,{kind:`subagent`,id:t.subagentId,name:t.name,...t.description===void 0?{}:{description:t.description},...t.model===void 0?{}:{model:t.model},...t.effort===void 0?{}:{effort:t.effort},...t.producer===void 0?{}:{producer:t.producer},status:t.state,...t.state===`waiting`?{waitingOn:t.on}:{},startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`background_call`:{let r=e.entries.find(e=>e.kind===`background_call`&&e.id===t.callId),i=r?.status===`running`,a=t.state===`running`,o=a?void 0:r?.endedAt??n;return{...e,activeBackgroundCalls:e.activeBackgroundCalls+ +!!a-+!!i,entries:hn(e.entries,{kind:`background_call`,id:t.callId,tool:t.tool,status:t.state,...mn(t),startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`enquiry`:{let n=t.state===`asked`,r=n&&e.asking?.askId===t.askId?e.asking:n?{askId:t.askId,questions:t.questions,...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}}:e.asking?.askId===t.askId?void 0:e.asking;return{...e,...r===void 0?{asking:void 0}:{asking:r},entries:hn(e.entries,{kind:`enquiry`,id:t.askId,questions:t.questions,status:t.state,...t.state===`answered`?{answers:t.answers}:{},...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}})}}case`permission`:{let n=t.state===`asked`?e.authorising??{callId:t.callId,tool:t.tool,...t.context===void 0?{}:{context:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope},...t.producer===void 0?{}:{producer:t.producer}}:e.authorising?.callId===t.callId?pn(e.entries,t.callId):e.authorising;return{...e,...n===void 0?{authorising:void 0}:{authorising:n},entries:gn(e.entries,t.callId,e=>({...e,authorisation:fn(t),...t.context===void 0?{}:{permissionContext:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope}}))}}case`turn_ended`:return{...e,entries:sn(e.entries,n),turnInFlight:!1,asking:e.asking?.producer===void 0?void 0:e.asking,authorising:e.authorising?.producer===void 0?void 0:e.authorising};case`queue_changed`:return{...e,queue:[...t.pending],queuedMessages:e.queuedMessages?.length===t.pending.length&&e.queuedMessages.every((e,n)=>e.text===t.pending[n]&&e.id===t.ids?.[n]&&(e.attachments?.length??0)===(t.attachments?.[n]?.length??0)&&(e.attachments??[]).every((e,r)=>e===t.attachments?.[n]?.[r]))?e.queuedMessages:t.pending.map((e,n)=>({id:t.ids?.[n],text:e,...t.attachments?.[n]?.length?{attachments:t.attachments[n]}:{}}))};case`workflow_spend`:{let n={...e.workflowSpend,[t.executionId]:t.spend},r=nn([...e.parentSpend?[e.parentSpend]:[],...Object.values(n)]);return{...e,workflowSpend:n,spend:r,...e.contextUsage?{contextUsage:{...e.contextUsage,spend:r}}:{}}}case`context_usage`:{let n=t.spend||e.workflowSpend?nn([...t.spend?[t.spend]:[],...Object.values(e.workflowSpend??{})]):void 0;return{...e,...t.spend?{parentSpend:t.spend}:{},...n?{spend:n}:{},contextUsage:{used:t.used,window:t.window,...n===void 0?{}:{spend:n}}}}case`model_changed`:return{...e,model:t.model};case`permission_mode_changed`:return{...e,permissionMode:t.mode};case`effort_changed`:return{...e,effort:t.effort};case`branch_changed`:return{...e,branch:t.branch};case`notice`:return{...e,entries:[...e.entries,{kind:`notice`,id:`notice-${e.entries.length}`,level:t.level,text:t.text,...t.sessionId===void 0?{}:{sessionId:t.sessionId}}]};case`compacting`:return t.active?{...e,compacting:!0}:un(e);case`compacted`:return{...un(e),entries:[...e.entries,{kind:`marker`,id:`compacted-${e.entries.length}`,marker:`compacted`,text:dn(t.trigger,t.before,t.after)}]};case`session_dormant`:return{...e,lifecycle:`dormant`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`dormant-${e.entries.length}`,marker:`dormant`,text:`Dormant: ${t.reason}`}]};case`session_settled`:return{...e,lifecycle:`settled`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`settled-${e.entries.length}`,marker:`settled`,text:`Settled`}]};case`rewound`:{let n=e.entries.findIndex(e=>e.kind===`user`&&e.id===t.userMessageId),r=t.restore===`files`?`Files rewound`:t.restore===`both`?`Rewound conversation and files`:`Rewound conversation`;return{...e,entries:[...n<0||t.restore===`files`?e.entries:e.entries.map((e,t)=>t<n||e.rewound?e:{...e,rewound:!0}),{kind:`marker`,id:`rewound-${e.entries.length}`,marker:`rewound`,text:r}]}}case`forked`:return{...e,entries:[...e.entries,{kind:`marker`,id:`forked-${e.entries.length}`,marker:`forked`,text:`Forked`,fromSessionId:t.fromSessionId}]};case`revived`:return{...e,...t.scope===void 0?{}:{scope:t.scope},lifecycle:`live`,turnInFlight:!1,entries:[...e.entries,{kind:`marker`,id:`revived-${t.fromSeq}`,marker:`revived`,text:`Revived from seq ${t.fromSeq}`}]};case`session_ended`:return{...e,lifecycle:`ended`,turnInFlight:!1,endedReason:t.reason,asking:void 0,authorising:void 0}}}function un(e){if(!e.compacting)return e;let{compacting:t,...n}=e;return n}function dn(e,t,n){let r=e===`auto`?`Compacted automatically`:`Compacted`;return n===void 0?`${r}, from ${Jt(t)} tokens`:`${r}, ${Jt(t)} → ${Jt(n)} tokens`}function fn(e){return e.state===`asked`?`asked`:e.state===`aborted`||e.decision===`deny`?`denied`:e.decision===`always`?`always`:`allowed`}function pn(e,t){let n=e.find(e=>e.kind===`tool`&&e.id!==t&&e.authorisation===`asked`);return n?.kind===`tool`?{callId:n.id,tool:n.name,...n.permissionContext===void 0?{}:{context:n.permissionContext},...n.allowAlways===void 0?{}:{allowAlways:n.allowAlways},...n.authorizationScope===void 0?{}:{authorizationScope:n.authorizationScope},...n.producer===void 0?{}:{producer:n.producer}}:void 0}function mn(e){return e.producer===void 0?{}:{producer:e.producer}}function hn(e,t){let n=e.findIndex(e=>e.kind===t.kind&&e.id===t.id);if(n<0)return[...e,t];let r=[...e];return r[n]=t,r}function gn(e,t,n){let r=e.findIndex(e=>e.kind===`tool`&&e.id===t);if(r<0)return e;let i=e[r];if(!i||i.kind!==`tool`)return e;let a=[...e];return a[r]=n(i),a}var H=e(be(),1),_n=e(E(),1);function vn(e){return`${e.kind}:${e.id}`}var U=Re();function yn(e,t){let n=/\/worktrees\/([^/]+)\/[^/]+$/.exec(e)?.[1];return n===void 0?void 0:t.find(e=>e.name===n)?.path}var bn=rt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xn=rt(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Sn=rt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Cn=rt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wn=rt(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),Tn=rt(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),En=rt(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Dn=rt(`folder-search`,[[`path`,{d:`M10.7 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 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),On=rt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),kn=rt(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),An=rt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),jn=rt(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Mn=rt(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Nn=rt(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Pn=rt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fn=rt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),In=rt(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Ln=rt(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Rn=rt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),zn=rt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Bn(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function Vn(e){return e.trim()!==``}function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Un(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Wn(e,t){return t!=null&&!x(t)?0:typeof e==`function`?e():e}function Gn(e,t,n){let r=Wn(e,n);return typeof r==`number`?r:r?.[t]}function Kn(e){return typeof e==`function`?e():e}function qn(e,t){return t||e===`click`||e===`mousedown`}function Jn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Yn=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ie,currentIdRef:{current:null},currentContextRef:{current:null}});function Xn(e,t){e.current=t.current}function Zn(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Be();return V(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:Gn(i.current,`open`),close:Gn(n,`close`)}},[n,o,i,a]),(0,U.jsx)(Yn.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function Qn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:f}=H.useContext(Yn),[p,m]=H.useState(!1),h=H.useRef(n);return V(()=>{h.current=n},[n]),V(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,l,f,r]),V(()=>{if(!n)return;let e=l.current,t=a.current;f.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:Gn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,d(F))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,f]),V(()=>()=>{if(a.current===i){if(l.current=null,!h.current)return;a.current=null,Xn(o,c),f.clear()}},[l,a,o,i,c,f]),H.useMemo(()=>({hasProvider:u,delayRef:o,isInstantPhase:p}),[u,o,p])}function $n(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function er(e){return e!=null&&e.clientX!=null}function tr(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=H.useRef(!1),u=H.useRef(null),[d,f]=H.useState(),[p,m]=H.useState([]),h=A(e=>{i.set(`positionReference`,e)}),g=A((e,t,n)=>{l.current||c.current.openEvent&&!er(c.current.openEvent)||i.set(`positionReference`,$n(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=A(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=x(d)?o:a;H.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ae(o);function r(t){let n=Ae(t);Te(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||er(c.current.openEvent)?u.current=Le(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),H.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),H.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),H.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=H.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return H.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function nr(){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Ft,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function rr(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:nr(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:L,inactiveTriggerProps:L,popupProps:L}}function ir(e,t,n=!1){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var ar=e=>e.triggerIdProp??e.activeTriggerId,or=e=>e.openProp??e.open,sr=e=>(e.popupElement?.id??e.floatingId)||void 0;function cr(e,t){return t!==void 0&&or(e)&&ar(e)===t}function lr(e,t){return cr(e,t)?!0:t!==void 0&&or(e)&&ar(e)==null&&e.triggerCount===1}var ur={open:or,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ar,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:sr,isTriggerActive:(e,t)=>t!==void 0&&ar(e)===t,isOpenedByTrigger:(e,t)=>cr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ar(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>lr(e,t)?sr(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},dr=S();function fr(e){let t=H.useCallback(t=>e===void 0?h:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,dr.useSyncExternalStore)(t,n,()=>e?.serverStore)}var pr=He&&fe;function mr(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=H.useRef(!1),c=H.useRef(null),l=H.useRef(!0),u=Be();H.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ae(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&se(e)&&e===re(b(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return P(Le(t,`blur`,r),pr&&Le(t,`keydown`,a,!0),pr&&Le(t,`pointerdown`,o,!0))},[i,n]),H.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);Fe(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=H.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ae(t.nativeEvent);if(Fe(a)){if(pr&&!t.relatedTarget){if(!l.current&&!Oe(a))return}else if(!ge(a))return}let o=Ne(t.relatedTarget,i.context.triggerElements),{nativeEvent:f,currentTarget:p}=t,m=typeof r==`function`?r():r;if(i.select(`open`)&&o||m===0||m===void 0){i.setOpen(!0,d(De,f,p));return}u.start(m,()=>{s.current||i.setOpen(!0,d(De,f,p))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Fe(n)&&n.hasAttribute(N(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=re(b(e));!n&&t===e||Te(o.current.floatingContext?.refs.floating.current,t)||Te(e,t)||a||Ne(n??t,i.context.triggerElements)||i.setOpen(!1,d(De,r))})}}},[o,r,i,u]);return H.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var hr=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ie,this.restTimeout=new ie,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},gr=new WeakMap;function _r(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&gr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),gr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function vr(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=gr.get(n);a&&a!==e&&_r(a),_r(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,gr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function yr(e){let t=e.context.dataRef.current,n=a(()=>t.hoverInteractionState??hr.create()).current;return t.hoverInteractionState||=n,w(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function br(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,s=a.useState(`open`),c=a.useState(`floatingElement`),l=a.useState(`domReferenceElement`),{dataRef:u}=a.context,f=Xe(),p=Qe(),m=yr(a),h=Be(),g=A(()=>qn(u.current.openEvent?.type,m.interactedInside)),v=A(()=>Jn(u.current.openEvent?.type)),y=A(()=>{_r(m)});V(()=>{s||(m.pointerType=void 0,m.restTimeoutPending=!1,m.interactedInside=!1,y())},[s,m,y]),H.useEffect(()=>y,[y]),V(()=>{if(n&&s&&m.handleCloseOptions?.blockPointerEvents&&v()&&Fe(l)&&c){let e=l,t=c,n=b(c),r=f?.nodesRef.current.find(e=>e.id===p)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=m.pointerEventsScopeElement===t?null:m.pointerEventsScopeElement,a=r===t?null:r,o=m.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return vr(m,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{y()}}},[n,s,l,c,m,v,f,p,y]),H.useEffect(()=>{if(!n)return;function e(){return!!(f&&p&&qe(f.nodesRef.current,p).length>0)}function t(e){let t=Gn(r,`close`,m.pointerType),n=()=>{a.setOpen(!1,d(_,e)),f?.events.emit(`floating.closed`,e)};t?m.openChangeTimeout.start(t,n):(m.openChangeTimeout.clear(),n())}function s(e){let t=Ae(e);if(!o(t)){m.interactedInside=!1;return}m.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function l(){m.openChangeTimeout.clear(),h.clear(),f?.events.off(`floating.closed`,x),y()}function b(n){if(e()&&f){f.events.on(`floating.closed`,x);return}if(Ne(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(f&&r&&Fe(o)&&qe(f.nodesRef.current,r,!1).some(e=>Te(e.context?.elements.floating,o)))){if(m.handler){m.handler(n);return}y(),v()&&!g()&&t(n)}}function x(t){!f||!p||e()||h.start(0,()=>{f.events.off(`floating.closed`,x),a.setOpen(!1,d(_,t)),f.events.emit(`floating.closed`,t)})}let S=c;return P(S&&Le(S,`mouseenter`,l),S&&Le(S,`mouseleave`,b),S&&Le(S,`pointerdown`,s,!0),()=>{f?.events.off(`floating.closed`,x)})},[n,c,a,u,r,i,v,g,y,m,f,p,h])}var xr={current:null};function Sr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=xr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:v,events:y}=g.context,S=Xe(l),C=yr(g),w=H.useRef(!1),T=Dt(i),E=Dt(r),D=Dt(o),O=Dt(n),k=Dt(m),j=Dt(p),M=A(()=>qn(v.current.openEvent?.type,C.interactedInside)),N=A(()=>k.current?.()!==!1),F=A((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!Te(e,t);if(!Fe(n))return!1;let i=n;return r.hasMatchingElement(e=>Te(e,i))&&(!e||!Te(e,i))}),I=A(()=>{C.handler&&=(b(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,C.handler),void 0)}),L=A(()=>{_r(C)});return u&&(C.handleCloseOptions=T.current?.__options),H.useEffect(()=>I,[I]),H.useEffect(()=>{if(!n)return;function e(e){e.open?w.current=!1:(w.current=e.reason===_,I(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return y.on(`openchange`,e),()=>{y.off(`openchange`,e)}},[n,y,C,I]),H.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Gn(E.current,`close`,C.pointerType);n?C.openChangeTimeout.start(n,()=>{g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e)}):t&&(C.openChangeTimeout.clear(),g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e))}let t=c.current??(u?g.select(`domReferenceElement`):null);if(!Fe(t))return;function r(e){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,a&&!x(C.pointerType))return;let t=Kn(D.current),n=Gn(E.current,`open`,C.pointerType),r=Ae(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(Fe(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(Te(e,r)){s=e;break}}Fe(i)&&Fe(o)&&!g.context.triggerElements.hasElement(i)&&Te(i,o)&&(s=o);let c=s!=null&&F(o,s,r),l=g.select(`open`),u=j.current?.()??g.select(`transitionStatus`)===`ending`,f=!l&&u&&w.current,p=!c&&Fe(s)&&Fe(o)&&Te(o,s)&&f,m=t>0&&!n,h=c&&(l||f)||p,v=!l||c;if(h){N()&&g.setOpen(!0,d(_,e,s));return}m||(n?C.openChangeTimeout.start(n,()=>{v&&N()&&g.setOpen(!0,d(_,e,s))}):v&&N()&&g.setOpen(!0,d(_,e,s)))}function i(t){if(M()){L();return}I();let n=g.select(`domReferenceElement`),r=b(n);C.restTimeout.clear(),C.restTimeoutPending=!1;let i=v.current.floatingContext??f?.();if(!Ne(t.relatedTarget,g.context.triggerElements)){if(T.current&&i){g.select(`open`)||C.openChangeTimeout.clear();let n=c.current;C.handler=T.current({...i,tree:S,x:t.clientX,y:t.clientY,onClose(){L(),I(),O.current&&!M()&&n===g.select(`domReferenceElement`)&&e(t,!0)}}),r.addEventListener(`mousemove`,C.handler),C.handler(t);return}(C.pointerType!==`touch`||!Te(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Te(t,e.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}let l=h?Le(t,`mouseout`,o):void 0;return s?P(Le(t,`mousemove`,r,{once:!0}),Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l):P(Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l)},[I,L,v,E,g,n,T,C,u,F,M,a,s,D,c,S,O,f,j,N,h]),H.useMemo(()=>{if(!n)return;function e(e){C.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=F(r,n,e.target);if(a&&!x(C.pointerType))return;if(i&&o&&C.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=C.handleCloseOptions?.getScope?.()??n.ownerDocument.body;vr(C,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=Kn(D.current);if(i&&!o||s===0||!o&&C.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;C.restTimeout.clear();function c(){if(C.restTimeoutPending=!1,M())return;let e=g.select(`open`);!C.blockMouseMove&&(!e||o)&&N()&&g.setOpen(!0,d(_,t,n))}C.pointerType===`touch`?_n.flushSync(()=>{c()}):o&&i?c():(C.restTimeoutPending=!0,C.restTimeout.start(s,c))}}},[n,C,M,F,a,g,D,N])}var Cr=.1,wr=Cr*Cr,Tr=.5;function Er(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Dr(e,t,n,r,i,a,o,s,c,l){let u=!1;return Er(e,t,n,r,i,a)&&(u=!u),Er(e,t,i,a,o,s)&&(u=!u),Er(e,t,o,s,c,l)&&(u=!u),Er(e,t,c,l,n,r)&&(u=!u),u}function Or(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Ar(e={}){let{blockPointerEvents:t=!1}=e,n=new ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*wr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ae(r),g=r.type===`mouseleave`,_=Te(u,h),v=Te(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Fe(r.relatedTarget)&&Te(u,r.relatedTarget))return;function y(){return!!(s&&qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=kr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=kr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=kr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=kr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Or(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Tr+1,o=C||T?S.bottom-Tr:S.top,s=C?T?S.bottom-Tr:S.top:S.bottom-Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Tr,o=C||T?S.top+Tr:S.bottom,s=C?T?S.top+Tr:S.bottom:S.top+Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Tr+1,o=w||E?S.right-Tr:S.left,s=w?E?S.right-Tr:S.left:S.right-Tr;M=Dr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Tr,o=w||E?S.left+Tr:S.right,s=w?E?S.left+Tr:S.right:S.left+Tr;M=Dr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function jr(){let{config:e,refresh:t}=Ue(),{save:n,saving:r}=Ve(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Un(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mr,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(Nr,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(Fr,{onAdd:l}),(0,U.jsx)(Ir,{current:o,saving:r,onSave:n,onSaved:t}),(0,U.jsxs)(Ie,{title:`Worktrees`,description:`Machine-wide.`,children:[(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Always start new Agent Sessions in a Worktree`}),(0,U.jsx)(dt,{checked:e.worktrees?.always===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{always:e}},e?`New Agent Sessions start in a Worktree.`:`New Agent Sessions start in the Project.`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Update the Source Branch before cutting a Worktree`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Fast-forwards the branch from its upstream in the Project. If this fails, the Worktree is cut from the local branch and a warning is shown.`})]}),(0,U.jsx)(dt,{checked:e.worktrees?.updateSource===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{updateSource:e}},e?`Source Branches are updated before a Worktree is cut.`:`Worktrees are cut from the local branch.`)})]})]})]})}function Mr({included:e,onRemove:t}){return(0,U.jsx)(Ie,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(zn,{"aria-hidden":!0})})]})]},e.path))})})}function Nr({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(Ie,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Hn(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(O,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function Pr(e){let[t,n]=(0,H.useState)(void 0),r=(0,H.useRef)(``);return(0,H.useEffect)(()=>{if(r.current=e,!Vn(e)){n(void 0);return}let t=new AbortController,i=setTimeout(()=>{(async()=>{try{let i=await p(`/api/directories?q=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)return;let a=await i.json();a.query===r.current&&n(a)}catch{}})()},150);return()=>{t.abort(),clearTimeout(i)}},[e]),t}function Fr({onAdd:e}){let[t,n]=(0,H.useState)(``),r=Pr(t),i=Bn(t);return(0,U.jsxs)(Ie,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(he,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[i===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function Ir({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(Ie,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(he,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(de,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}var Lr=H.createContext(void 0);function Rr(e){let t=H.useContext(Lr);if(!e&&t===void 0)throw Error(B(27));return t}var zr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Rr(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return j(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:pt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Br=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...c}=e,l=Rr(),u=l.useState(`open`),{getButtonProps:f,buttonRef:p}=R({disabled:a,native:o}),m={disabled:a};function h(e){u&&l.setOpen(!1,d(s,e.nativeEvent))}return j(`button`,e,{state:m,ref:[t,p],props:[{onClick:h},c,f]})}),Vr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),j(`p`,e,{ref:t,props:[{id:c},o]})}),Hr=H.createContext(void 0);function Ur(){let e=H.useContext(Hr);if(e===void 0)throw Error(B(26));return e}var Wr={...$e,...Ee,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},Gr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Rr(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Ur(),we({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?_t(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=j(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...wt,hidden:!m,onKeyDown(e){st.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Wr});return(0,U.jsx)(ct,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Kr=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Rr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,U.jsx)(Hr.Provider,{value:n,children:(0,U.jsxs)(u,{ref:t,...r,children:[a&&o===!0&&(0,U.jsx)(nt,{ref:i.context.internalBackdropRef,inert:Me(!s)}),e.children]})}):null});function qr({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=H.useState(0),[u,d]=H.useState(0),f=c===0,p=gt(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ae(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Te(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return tt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),V(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),bt(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Jr={...ur,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Yr=class extends f{constructor(e,t,n){let r=new Ft,i=Xr(e,r,t,n);super(i,Zr(r),Jr)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ot(n,e,t.trigger),this.update(n)}};function Xr(e,t,n,r=!1){let i={...rr(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=ir(t,n,r),i}function Zr(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Qr(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Rr(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=Nt((e,t)=>new Yr({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);kt(x,S),Bt(x);let{forceUnmount:T}=vt(S,x);H.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,d(D))}),[T,x]);let E=S||C;return(0,U.jsxs)(Lr.Provider,{value:x,children:[u&&(0,U.jsx)(ht,{handle:u,store:x}),E&&(0,U.jsx)(qr,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function $r(e){return Qr(`dialog`,e)}var ei=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),j(`h2`,e,{ref:t,props:[{id:c},o]})}),ti=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Rr(!0),f=fr(l)??d;if(!f)throw Error(B(79));let p=xe(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=H.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=St(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=R({disabled:a,native:o}),S=Ut(m),C=Tt(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return j(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[k]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:mt})});function ni({...e}){return(0,U.jsx)($r,{"data-slot":`dialog`,...e})}function ri({...e}){return(0,U.jsx)(ti,{"data-slot":`dialog-trigger`,...e})}function ii({...e}){return(0,U.jsx)(Kr,{"data-slot":`dialog-portal`,...e})}function ai({className:e,...t}){return(0,U.jsx)(zr,{"data-slot":`dialog-overlay`,className:g(`fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function oi({className:e,children:t,showCloseButton:n=!0,...r}){return(0,U.jsxs)(ii,{children:[(0,U.jsx)(ai,{}),(0,U.jsxs)(Gr,{"data-slot":`dialog-content`,className:g(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-sm text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,U.jsxs)(Br,{"data-slot":`dialog-close`,render:(0,U.jsx)(O,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(zn,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function si({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-1.5`,e),...t})}function ci({className:e,showCloseButton:t=!1,children:n,...r}){return(0,U.jsxs)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,U.jsx)(Br,{render:(0,U.jsx)(O,{variant:`outline`}),children:`Close`})]})}function li({className:e,...t}){return(0,U.jsx)(ei,{"data-slot":`dialog-title`,className:g(`font-heading text-base leading-none font-medium`,e),...t})}function ui({className:e,...t}){return(0,U.jsx)(Vr,{"data-slot":`dialog-description`,className:g(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function di({session:e,onClose:t}){let{connection:n,config:r}=Ue(),[i,a]=(0,H.useState)(e.suggestedScope??``),[o,s]=(0,H.useState)(()=>yn(e.scope,r.projectList??[])??``),[c,l]=(0,H.useState)(void 0),[u,d]=(0,H.useState)(!1),f=i.trim()!==``&&(!e.worktree||o.trim()!==``),p=async()=>{d(!0),l(void 0);try{await n.command({type:`relocate`,sessionId:e.id,scope:i.trim(),...e.worktree?{repo:o.trim()}:{}}),await n.command({type:`revive`,sessionId:e.id}),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,U.jsx)(ni,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,U.jsxs)(oi,{className:`sm:max-w-lg`,children:[(0,U.jsxs)(si,{children:[(0,U.jsx)(li,{children:`Relocate Agent Session`}),(0,U.jsx)(ui,{children:`Its Scope no longer exists. Choose where its files are now.`})]}),(0,U.jsx)(ne,{label:`Old Scope`,children:e.scope}),(0,U.jsx)(fi,{label:`Scope`,value:i,onChange:a}),e.worktree?(0,U.jsx)(fi,{label:`Repository`,value:o,onChange:s}):null,c===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,U.jsxs)(ci,{children:[(0,U.jsx)(O,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(O,{disabled:!f||u,onClick:()=>void p(),children:`Relocate and revive`})]})]})})}function fi({label:e,value:t,onChange:n}){let r=Pr(t),i=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),(0,U.jsx)(he,{id:i,className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`/path/to/folder`,spellCheck:!1}),r?.paths.filter(e=>e!==t).slice(0,5).map(e=>(0,U.jsx)(O,{variant:`ghost`,size:`sm`,className:`justify-start font-mono text-xs`,onClick:()=>n(e),children:e},e))]})}var pi=new Map;function mi(e,t){pi.set(e,structuredClone(t))}function hi(e){let t=pi.get(e);return t&&structuredClone(t)}function gi(e){pi.delete(e)}function _i(e){for(let t of pi.keys())e.has(t)||pi.delete(t)}var vi=2e3,yi=3e4,bi=(0,H.createContext)(void 0);function xi(){let e=(0,H.useContext)(bi);if(!e)throw Error(`useAgentSessions outside SessionsProvider`);return e}function Si({children:e}){let{connection:t}=Ue(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(void 0),c=(0,H.useRef)(()=>{});(0,H.useEffect)(()=>{let e=!1,n,i,o=0,s=0,l=0,u=e=>{n&&clearTimeout(n),n=setTimeout(()=>void d(),e)},d=async()=>{if(e||document.hidden)return;i?.abort(),i=new AbortController;let n=++o;try{let i=await t.listSessions();if(e||n<=s)return;s=n,l=0,_i(new Set(i.map(e=>e.id))),r(i),a(!0),u(vi)}catch{if(e)return;a(!0),l+=1,u(Math.min(yi,vi*2**l))}},f=()=>{document.hidden||d()};return c.current=()=>void d(),d(),document.addEventListener(`visibilitychange`,f),()=>{e=!0,c.current=()=>{},n&&clearTimeout(n),i?.abort(),document.removeEventListener(`visibilitychange`,f)}},[t]);let l=(0,H.useCallback)(()=>c.current(),[]),u=n.find(e=>e.id===o);return(0,U.jsxs)(bi.Provider,{value:{sessions:n,loaded:i,nudge:l,relocate:s},children:[e,u?(0,U.jsx)(di,{session:u,onClose:()=>{s(void 0),l()}}):null]})}function Ci(){let{connection:e}=Ue(),{nudge:t,relocate:n}=xi();return(0,H.useCallback)(async r=>{try{let n=await e.command(r);return t(),n}catch(e){if(e.code===`scope_missing`&&`sessionId`in r){n(r.sessionId),t();return}ze.error(`${r.type} failed`,e instanceof Error?e.message:String(e)),t();return}},[e,t,n])}var wi=[`general`,`projects`,`permissions`,`providers`,`appearance`,`keyboard`,`workflows`,`secrets`,`mcp`],Ti={sessionId:void 0};function Ei(e){let[t=``,n=``]=e.replace(/^#\/?/,``).split(`?`,2),r=t.split(`/`).filter(e=>e!==``);if(r[0]===`settings`)return{sessionId:void 0,settings:ki(r[1])};let i=Di(r),a=new URLSearchParams(n).get(`settings`);return a===null?i:{...i,settings:ki(a)}}function Di(e){if(e[0]===`spend`)return{sessionId:void 0,spend:!0};if(e[0]===`schedules`){let t={sessionId:void 0,schedules:!0};if(e[1]===`occurrences`){let n=Ai(e[2]??``);return n?{...t,occurrenceId:n}:t}let n=Ai(e[1]??``);return n?{...t,scheduleId:n}:t}if(e[0]===`new`&&e[1])return{sessionId:void 0,backend:Ai(e[1])};if(e[0]!==`s`||e[1]===void 0)return Ti;let t=Ai(e[1]);return{sessionId:t===``?void 0:t}}function Oi(e){let t=e.spend?`#/spend`:e.schedules?`#/schedules${e.occurrenceId?`/occurrences/${encodeURIComponent(e.occurrenceId)}`:e.scheduleId?`/${encodeURIComponent(e.scheduleId)}`:``}`:e.sessionId===void 0?e.backend?`#/new/${encodeURIComponent(e.backend)}`:``:`#/s/${encodeURIComponent(e.sessionId)}`;return e.settings===void 0?t:`${t||`#/`}?settings=${e.settings}`}function ki(e){return wi.find(t=>t===Ai(e??``))??wi[0]}function Ai(e){try{return decodeURIComponent(e)}catch{return``}}function ji(e){return e.title||e.id}var Mi=60,Ni=[{key:`description`,shape:`text`},{key:`command`,shape:`text`},{key:`questions`,shape:`questions`},{key:`file_path`,shape:`path`},{key:`notebook_path`,shape:`path`},{key:`pattern`,shape:`text`},{key:`url`,shape:`text`},{key:`query`,shape:`text`},{key:`path`,shape:`path`},{key:`prompt`,shape:`text`}],Pi=Ni.filter(({key:e})=>e!==`description`);function Fi(e){return Li(e,Mi)}function Ii(e){return Li(e,1/0,Pi)}function Li(e,t,n=Ni){if(!e||typeof e!=`object`)return;let r=e;for(let e of n){let n=r[e.key];if(e.shape===`questions`){let e=Ri(n,t);if(e!==void 0)return e;continue}if(typeof n==`string`&&n.trim()!==``)return e.shape===`path`?Bi(n.trim(),t):zi(n,t)}let i=Object.values(r).filter(e=>typeof e==`string`),a=i.length===1?i[0]:void 0;return a&&a.trim()!==``?zi(a,t):void 0}function Ri(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0];if(!n||typeof n!=`object`)return;let r=n.question;if(typeof r!=`string`||r.trim()===``)return;let i=e.length-1;return zi(i>0?`${r} (+${i} more)`:r,t)}function zi(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Bi(e,t){return e.length<=t?e:`…${e.slice(-(t-1))}`}var Vi=H.createContext(void 0);function Hi(e){let t=H.useContext(Vi);if(t===void 0&&!e)throw Error(B(72));return t}var Ui={...ur,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Wi=class extends f{constructor(e,t,n){let r=new Ft;super(Gi(e,r,t,n),Ki(r),Ui)}setOpen=(e,t)=>{Mt(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,d(z,e))}};function Gi(e,t,n,r=!1){let i={...rr(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e};return i.floatingRootContext=ir(t,n,r),i}function Ki(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var qi=ye(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:f=null,children:p}=e,m=Nt((e,t)=>new Wi({open:n,openProp:r,activeTriggerId:f,triggerIdProp:u},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,u),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Bt(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=vt(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=H.useRef(null);V(()=>{h&&t&&m.setOpen(!1,d(_e))},[h,t,m]),V(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),V(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),H.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,d(D))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,U.jsxs)(Vi.Provider,{value:m,children:[l&&(0,U.jsx)(ht,{handle:l,store:m}),E&&(0,U.jsx)(Ji,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function Ji({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=gt(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=tr(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>ee(a.reference,i.reference),[a.reference,i.reference]);return bt(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??L}),null}var Yi=H.createContext(void 0);function Xi(){return H.useContext(Yi)}var Zi=`data-base-ui-tooltip-trigger`;function Qi(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Fe(n))return n}}let t=e.target;return Fe(t)?t:null}function $i(e){let t=e;for(;t;){let e=t.closest(`[${Zi}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Fe(n.host)?n.host:null}return null}var ea=c(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:f,...p}=e,m=Hi(!0),h=fr(a)??m;if(!h)throw Error(B(82));let g=xe(f),v=h.useState(`isTriggerActive`,g),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`floatingRootContext`),S=H.useRef(null),C=c??600,w=u??0,{registerTrigger:T,isMountedByThisTrigger:E}=St(g,S,h,{payload:o,closeOnClick:l,closeDelay:w}),D=Xi(),{delayRef:O,isInstantPhase:k,hasProvider:A}=Qn(b,{open:y}),M=yr(b);h.useSyncedValue(`isInstantPhase`,k);let N=h.useState(`disabled`),P=s??N,F=Dt(P),I=h.useState(`trackCursorAxis`),L=h.useState(`disableHoverablePopup`),R=H.useRef(!1),ee=Be(),z=H.useRef(void 0);function te(){return A?Gn(O.current,`open`)===0?0:c??D??600:C}function V(e){let t=S.current;if(!t||!e)return!1;let n=$i(e);return n!==null&&n!==t&&Te(t,n)}function ne(e){let t=V(e);return R.current=t,t&&(M.openChangeTimeout.clear(),M.restTimeout.clear(),M.restTimeoutPending=!1,ee.clear()),t}let re=Sr(b,{enabled:!P,mouseOnly:!0,move:!1,handleClose:!L&&I!==`both`?Ar():null,restMs:te,delay(){return u==null&&A?{close:Gn(O.current,`close`)}:{close:w}},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!R.current}}),ie=mr(b,{enabled:!P}).reference,ae=e=>{let t=R.current,n=Qi(e),r=ne(n),i=S.current,a=i&&n&&Te(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,d(_,e));return}if(t&&!r&&a&&!F.current&&!h.select(`open`)&&i&&x(z.current)){let t=()=>{!R.current&&!F.current&&!h.select(`open`)&&h.setOpen(!0,d(_,e,i))},n=te();n===0?(ee.clear(),t()):ee.start(n,t)}},oe=h.useState(`triggerProps`,E);return j(`button`,e,{state:{open:y},ref:[t,T,S],props:[re,ie,E||I!==`none`?oe:void 0,{onMouseOver(e){ae(e.nativeEvent)},onFocus(e){V(Qi(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){R.current=!1,ee.clear(),z.current=void 0},onPointerEnter(e){z.current=e.pointerType},onPointerDown(e){z.current=e.pointerType,h.set(`closeOnClick`,l),l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,"data-trigger-disabled":P?``:void 0,[Zi]:P?void 0:``},p],stateAttributesMapping:mt})}),ta=H.createContext(void 0);function na(){let e=H.useContext(ta);if(e===void 0)throw Error(B(70));return e}var ra=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Hi().useState(`mounted`)||n?(0,U.jsx)(ta.Provider,{value:n,children:(0,U.jsx)(M,{ref:t,...r})}):null}),ia=H.createContext(void 0);function aa(){let e=H.useContext(ia);if(e===void 0)throw Error(B(71));return e}var oa=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Pe,style:g,..._}=e,v=Hi(),y=na(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=v.useState(`adaptiveOrigin`),O=ot({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:D}),k=H.useMemo(()=>({open:b,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,O.side,O.align,O.anchorHidden,S,T]),A=et(e,k,{styles:O.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,U.jsx)(ia.Provider,{value:O,children:A})}),sa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{side:s,align:c}=aa(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);we({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),br(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return j(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[wt,f,Pt(d),a],stateAttributesMapping:pt})}),ca=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=aa(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return j(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:$e})}),la=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,U.jsx)(Yi.Provider,{value:t,children:(0,U.jsx)(Zn,{delay:i,timeoutMs:r,children:e.children})})};function ua({delay:e=0,...t}){return(0,U.jsx)(la,{"data-slot":`tooltip-provider`,delay:e,...t})}function da({...e}){return(0,U.jsx)(qi,{"data-slot":`tooltip`,...e})}function fa({...e}){return(0,U.jsx)(ea,{"data-slot":`tooltip-trigger`,...e})}function pa({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,U.jsx)(ra,{children:(0,U.jsx)(oa,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,U.jsxs)(sa,{"data-slot":`tooltip-content`,className:g(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,U.jsx)(ca,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:translate-x-[1.5px] data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:translate-x-[-1.5px] data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:translate-x-[-1.5px] data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:translate-x-[1.5px] data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var ma=H.createContext(void 0);function ha(e){let t=H.useContext(ma);if(t===void 0&&!e)throw Error(B(33));return t}var ga=H.createContext(void 0);function _a(e){let t=H.useContext(ga);if(t===void 0&&!e)throw Error(B(36));return t}var va=H.createContext(void 0);function ya(e=!0){let t=H.useContext(va);if(t===void 0&&!e)throw Error(B(25));return t}function ba(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=ya(!0),f=d!==void 0;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:We})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!He&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&m(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var xa={type:`regular-item`};function Sa(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=R({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=ba({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>ee(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=I(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Ca=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Et({guess:!0,label:a}),f=ha(!0),p=xe(i),{store:m}=_a(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Sa({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:xa});return j(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),wa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=_a(),{side:c,align:l}=ha(),u=it(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;we({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){s.setOpen(!1,d(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),br(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k={transitionStatus:p,side:c,align:l,open:f,nested:v.type===`menu`,instant:g},A=j(`div`,e,{state:k,ref:[t,s.context.popupRef,O],stateAttributesMapping:pt,props:[m,{onKeyDown(e){u&&st.has(e.key)&&e.stopPropagation()}},Pt(p),o,{"data-rootownerid":b}]}),M=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(M=!0),(0,U.jsx)(ct,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?M:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:A})}),Ta=H.createContext(void 0);function Ea(){let e=H.useContext(Ta);if(e===void 0)throw Error(B(32));return e}var Da=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=_a();return i.useState(`mounted`)||n?(0,U.jsx)(Ta.Provider,{value:n,children:(0,U.jsx)(u,{ref:t,...r})}):null}),Oa=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ce,style:_,...v}=e,{store:b}=_a(),x=Ea(),S=ya(!0),C=b.useState(`parent`),w=b.useState(`floatingRootContext`),T=b.useState(`floatingTreeRoot`),E=b.useState(`mounted`),D=b.useState(`open`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`activeTriggerElement`),j=b.useState(`transitionStatus`),M=b.useState(`positionerElement`),N=b.useState(`instantType`),P=b.useState(`adaptiveOrigin`),F=b.useState(`lastOpenChangeReason`),I=b.useState(`floatingNodeId`),L=b.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=H.useRef(null),z=ke(M),B=n,te=c,ne=l,re=s,ie=g;C.type===`context-menu`&&(B=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??Pe):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,le=ot({anchor:B,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:p,collisionBoundary:u,collisionPadding:f,sticky:m,nodeId:I,keepMounted:x,disableAnchorTracking:h,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===b.select(`floatingParentNodeId`)&&b.setOpen(!1,d(y)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[b,T.events,I]),H.useEffect(()=>{if(b.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==b.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;b.setOpen(!1,d(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,b]);let ue=Be();H.useEffect(()=>{D||ue.clear()},[D,ue]),H.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==b.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=b.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{b.setOpen(!1,d(y))}):b.setOpen(!1,d(y))}else ue.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,b,ue]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:b.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,b,I,L]),V(()=>{let e=R,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return z(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[R,z,b]);let de={open:D,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:C.type===`menu`,instant:N},fe=C.type===`menubar`&&C.context.modal;Ze(D&&(fe||O&&F!==`trigger-hover`),k===`touch`,M,A);let pe=et(e,de,{styles:le.positionerStyles,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),me=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),he=null;return C.type===`menubar`?he=C.context.contentElement:C.type===void 0&&(he=A),(0,U.jsxs)(ma.Provider,{value:le,children:[me&&(0,U.jsx)(nt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Me(!D),cutout:he}),(0,U.jsx)(Je,{id:I,children:(0,U.jsx)(Ye,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:pe})})]})}),ka=H.createContext(null);function Aa(e){let t=H.useContext(ka);if(t===null&&!e)throw Error(B(5));return t}var ja={...ur,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Ma=class extends f{constructor(e){super({...Pa(),...e},Na(),ja),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Na(){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ft}}function Pa(){return{...rr(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new at,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:L,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var Fa=H.createContext(void 0);function Ia(){return H.useContext(Fa)}var La=ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:f,closeParentOnEsc:p=!1,handle:m,triggerId:h,defaultTriggerId:g=null,highlightItemOnHover:_=!0}=e,v=ya(!0),y=_a(!0),b=Aa(!0),x=Ia(),S=H.useMemo(()=>x&&y?{type:`menu`,store:y.store}:b?{type:`menubar`,context:b}:v&&!y?{type:`context-menu`,context:v}:{type:void 0},[v,y,b,x]),C=Ra({open:a,openProp:n,activeTriggerId:g,triggerIdProp:h,parent:S});C.useControlledProp(`openProp`,n),C.useControlledProp(`triggerIdProp`,h),C.useContextCallback(`onOpenChangeComplete`,i);let w=te(),T=te(),E=C.useState(`floatingTreeRoot`),O=ut(E),k=Qe(),j=C.useState(`open`),M=C.useState(`activeTriggerElement`),N=C.useState(`positionerElement`),P=C.useState(`hoverEnabled`),F=C.useState(`disabled`),I=C.useState(`lastOpenChangeReason`),R=C.useState(`parent`),z=C.useState(`activeIndex`),B=C.useState(`payload`),ne=C.useState(`floatingParentNodeId`),re=H.useRef(null),ie=H.useRef(R.type!==`context-menu`),ae=Be(),oe=H.useRef(!0),se=Be(),ce=ne!=null,{openMethod:le,triggerProps:ue}=Ke(j);C.useSyncedValues({disabled:o,highlightItemOnHover:_,modal:R.type===void 0?s:void 0,openMethod:le,rootId:w}),Bt(C);let{forceUnmount:de}=vt(j,C,()=>{C.set(`allowMouseEnter`,!1)});V(()=>{v&&!y?C.update({parent:{type:`context-menu`,context:v},floatingNodeId:O,floatingParentNodeId:k}):y&&C.update({floatingNodeId:O,floatingParentNodeId:k})},[v,y,O,k,C]),H.useEffect(()=>{if(j||(re.current=null),R.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,R.type]),V(()=>{!j&&!P&&C.set(`hoverEnabled`,!0)},[j,P,C]);let fe=A((e,t)=>{let n=t.reason;if(!e&&!C.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Lt(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;C.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,se.start(300,()=>{oe.current=!0})):(oe.current=!0,se.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};re.current=t.event,Ot(c,e,t.trigger,i()),C.update(c),R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?C.set(`instantType`,`group`):o||s?C.set(`instantType`,o?`click`:`dismiss`):C.set(`instantType`,void 0)}),pe=Vt({popupStore:C,floatingId:T,nested:k!=null,onOpenChange:fe}),me=pe.context.events;V(()=>{let e=({open:e,eventDetails:t})=>fe(e,t);return me.on(`setOpen`,e),()=>{me?.off(`setOpen`,e)}},[me,fe]);let he=H.useCallback(()=>{C.setOpen(!1,d(D))},[C]);H.useImperativeHandle(f,()=>({unmount:de,close:he}),[de,he]);let ge;R.type===`context-menu`&&(ge=R.context),H.useImperativeHandle(ge?.positionerRef,()=>N,[N]),H.useImperativeHandle(ge?.actionsRef,()=>({setOpen:fe}),[fe]);let _e=gt(pe,{enabled:!F,bubbles:{escapeKey:p&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:ce?E:void 0}),ve=Ge(),ye=H.useCallback(e=>{C.select(`activeIndex`)!==e&&C.set(`activeIndex`,e)},[C]),be=zt(pe,{enabled:!F,listRef:C.context.itemDomElements,activeIndex:z,nested:R.type!==void 0,loopFocus:c,orientation:u,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,rtl:ve===`rtl`,disabledIndices:l,onNavigate:ye,openOnArrowKeyDown:R.type!==`context-menu`,externalTree:ce?E:void 0,focusItemOnHover:_}),xe=H.useCallback(e=>{C.context.typingRef.current=e},[C]),Se=yt(pe,{enabled:!F,listRef:C.context.itemLabels,elementsRef:C.context.itemDomElements,activeIndex:z,resetMs:500,onMatch:e=>{j&&e!==z&&C.set(`activeIndex`,e)},onTyping:xe}),Ce=H.useMemo(()=>{let e=ee(Se.reference,be.reference,_e.reference,{onMouseMove(){C.set(`allowMouseEnter`,!0)}},ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[C,Se.reference,be.reference,_e.reference,ue,j]),we=H.useMemo(()=>{let e=ee(be.trigger,_e.trigger,ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[be.trigger,_e.trigger,ue]),Te=H.useMemo(()=>ee(wt,{id:T,role:`menu`,"aria-labelledby":M?.id,onMouseMove(){C.set(`allowMouseEnter`,!0),R.type===`menu`&&C.set(`hoverEnabled`,!1)},onClick(){C.select(`hoverEnabled`)&&C.set(`hoverEnabled`,!1)},onKeyDown(e){let t=C.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Se.floating,be.floating,_e.floating),[M,T,R.type,C,Se.floating,be.floating,_e.floating]),Ee=be.item??L;bt(C,{floatingRootContext:pe,activeTriggerProps:Ce,inactiveTriggerProps:we,popupProps:Te,itemProps:Ee});let De=H.useMemo(()=>({store:C,parent:S}),[C,S]),Oe=(0,U.jsxs)(ga.Provider,{value:De,children:[m&&(0,U.jsx)(ht,{handle:m,store:C}),typeof t==`function`?t({payload:B}):t]});return R.type===void 0||R.type===`context-menu`?(0,U.jsx)(Ht,{externalTree:E,children:Oe}):Oe});function Ra(e){return a(()=>new Ma(e)).current}function za(e){let t=_a().store,n=H.useMemo(()=>({parentMenu:t}),[t]);return(0,U.jsx)(Fa.Provider,{value:n,children:(0,U.jsx)(La,{...e})})}function Ba(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=v(),{ref:i,index:a}=Et(e),o=n===a,s=H.useRef(null),c=I(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function Va(e){let{render:t,className:n,style:r,state:i=L,props:a=l,refs:o=l,metadata:s,stateAttributesMapping:c,tag:u=`div`,...d}=e,{compositeProps:f,compositeRef:p}=Ba({metadata:s});return j(u,e,{state:i,ref:[p,...o],props:[f,...a,d],stateAttributesMapping:c})}function Ha(e){if(se(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!le(e))return Ha(je(e))}function Ua(e,t){let n=H.useRef(null);function r(t){_n.flushSync(()=>{e.setOpen(!1,d(C,t.nativeEvent,t.currentTarget))}),me(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&pe(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{_n.flushSync(()=>{e.setOpen(!1,d(C,n.nativeEvent,n.currentTarget))});let i=Ce(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Te(r,i);){let e=i;if(i=ue(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Wa(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,b(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:L,[t,n,r])}var Ga=c(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=_a(!0),h=fr(d)??m?.store;if(!h)throw Error(B(85));let g=xe(s),_=h.useState(`isTriggerActive`,g),y=h.useState(`floatingRootContext`),x=h.useState(`isOpenedByTrigger`,g),S=h.useState(`triggerPopupId`,g),C=H.useRef(null),w=qa(),E=v(!0),D=Xe(),O=H.useMemo(()=>D??new at,[D]),k=ut(O),M=Qe(),{registerTrigger:N,isMountedByThisTrigger:P}=St(g,C,h,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:k,floatingParentNodeId:M,keyboardEventRelay:E?.relayKeyboardEvent}),F=w.type===`menubar`,I=h.useState(`disabled`),z=a||I||F&&w.context.disabled,{getButtonProps:te,buttonRef:V}=R({disabled:z,native:o});H.useEffect(()=>{!x&&w.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,x,w.type]);let ne=H.useRef(null),re=Be(),ie=A(e=>{if(!ne.current)return;re.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Te(ne.current,t)||Te(h.select(`positionerElement`),t)||t===ne.current||(t==null||Ha(t)!==h.select(`rootId`))&&(lt(e,ne.current)||O.events.emit(`close`,{domEvent:e,reason:T}))});H.useEffect(()=>{x&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&b(ne.current).addEventListener(`mouseup`,ie,{once:!0})},[x,ie,h]);let ae=F&&w.context.hasSubmenuOpen,se=Sr(y,{enabled:(c??ae)&&!z&&(!F||ae&&!P),handleClose:Ar({blockPointerEvents:!F}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ce=Ka(x,h.select(`lastOpenChangeReason`)),le=Ut(y,{enabled:!z,event:x&&F?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&ce}),ue=mr(y,{enabled:!z&&ae}),de=Wa({open:x,enabled:F,mouseDownAction:`open`}),fe=H.useMemo(()=>ee(ue.reference,le.reference),[ue.reference,le.reference]),pe=h.useState(`triggerProps`,P),{preFocusGuardRef:me,handlePreFocusGuardFocus:he,handleFocusTargetFocus:ge}=Ua(h,C),_e={disabled:z,open:x},ve=[ne,t,V,N,C],ye=[fe,se??L,pe,{"aria-haspopup":`menu`,"aria-controls":S,id:g,onMouseDown:e=>{h.select(`open`)||(re.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),b(e.currentTarget).addEventListener(`mouseup`,ie,{once:!0}))}},F?{role:`menuitem`}:{},de,p,te],be=j(`button`,e,{enabled:!F,stateAttributesMapping:ft,state:_e,ref:ve,props:ye});return F?(0,U.jsx)(Va,{tag:`button`,render:n,className:r,style:i,state:_e,refs:ve,props:ye,stateAttributesMapping:ft}):x?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(oe,{ref:me,onFocus:he},`${g}-pre-focus-guard`),(0,U.jsx)(H.Fragment,{children:be},g),(0,U.jsx)(oe,{ref:h.context.triggerFocusTargetRef,onFocus:ge},`${g}-post-focus-guard`)]}):(0,U.jsx)(H.Fragment,{children:be},g)});function Ka(e,t){let n=Be(),[r,i]=H.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function qa(){let e=Aa(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Ja=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return j(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Ya={"aria-expanded":void 0},Xa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ia();if(!p?.parentMenu)throw Error(B(37));let m=Et({guess:!0,label:a}),h=ha(),{store:g}=_a(),_=xe(o),v=g.useState(`open`),y=g.useState(`floatingRootContext`),b=g.useState(`floatingTreeRoot`),x=g.useState(`triggerPopupId`,_),S=xt(_,g),C=H.useCallback(e=>{let t=S(e);return e!==null&&g.select(`open`)&&g.select(`activeTriggerId`)==null&&g.update({activeTriggerId:_,activeTriggerElement:e,closeDelay:u}),t},[S,u,g,_]),w=H.useRef(null),T=H.useCallback(e=>{w.current=e,g.set(`activeTriggerElement`,e)},[g]);g.useSyncedValue(`closeDelay`,u);let E=p.parentMenu,D=g.useState(`disabled`),O=E.useState(`disabled`),k=d||D||O,A=E.useState(`itemProps`),M=E.useState(`isActive`,m.index),N=H.useMemo(()=>({type:`submenu-trigger`,setActive(){E.select(`highlightItemOnHover`)&&E.set(`activeIndex`,m.index)}}),[E,m.index]),{getItemProps:P,itemRef:F}=Sa({closeOnClick:!1,disabled:k,highlighted:M,id:_,store:g,typingRef:E.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:h?.context.nodeId}),I=Sr(y,{enabled:g.useState(`hoverEnabled`)&&c&&!k,handleClose:Ar({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>E.select(`allowMouseEnter`):void 0,triggerElementRef:w,externalTree:b,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),R=Ut(y,{enabled:!k,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??L,ee=g.useState(`triggerProps`,!0);delete ee.id;let z={disabled:k,highlighted:M,open:v},te=g.useState(`openMethod`),V=g.useState(`lastOpenChangeReason`)===`list-navigation`||te===`keyboard`;return j(`div`,e,{state:z,stateAttributesMapping:mt,props:[R,I,ee,A,v&&V&&Se?Ya:void 0,{"aria-controls":x,tabIndex:v||M?0:-1,onBlur(){M&&E.set(`activeIndex`,null)}},f,P],ref:[t,m.ref,F,C,T]})});function Za({...e}){return(0,U.jsx)(La,{"data-slot":`dropdown-menu`,...e})}function Qa({className:e,...t}){return(0,U.jsx)(Ga,{"data-slot":`dropdown-menu-trigger`,className:e,...t})}function $a({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,U.jsx)(Da,{children:(0,U.jsx)(Oa,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,U.jsx)(wa,{"data-slot":`dropdown-menu-content`,className:g(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function eo({className:e,inset:t,variant:n=`default`,...r}){return(0,U.jsx)(Ca,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function to({...e}){return(0,U.jsx)(za,{"data-slot":`dropdown-menu-sub`,...e})}function no({className:e,inset:t,children:n,...r}){return(0,U.jsxs)(Xa,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:g(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,U.jsx)(Cn,{className:`ml-auto`})]})}function ro({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,U.jsx)($a,{"data-slot":`dropdown-menu-sub-content`,className:g(`w-auto min-w-[96px] rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function io({className:e,...t}){return(0,U.jsx)(Ja,{"data-slot":`dropdown-menu-separator`,className:g(`-mx-1 my-1 h-px bg-border/50`,e),...t})}var ao=6e4,oo=60*ao,so=24*oo;function co(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,t-n);return r<ao?`just now`:r<oo?`${Math.floor(r/ao)}m`:r<so?`${Math.floor(r/oo)}h`:new Date(n).toISOString().slice(0,10)}function lo(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.old_string==`string`?t.old_string:void 0,r=typeof t.new_string==`string`?t.new_string:typeof t.content==`string`?t.content:void 0;if(n!==void 0||r!==void 0)return{...typeof t.file_path==`string`?{path:t.file_path}:{},removed:fo(n),added:fo(r)}}function uo(e,t){let n=!!t?.trim();if(!n){let t=/^--- [^\n]*\n\+\+\+ [^\n]*\n/m.test(e),n=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m.test(e);if(!t||!n)return}let r=0,i=0;return(e.match(/[^\n]*\n|[^\n]+$/g)??[]).map(e=>{let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(t)return r=Number(t[1]??1),i=Number(t[2]??1),{text:e,kind:`context`};let a=r>0||i>0,o=`context`;return(a||n)&&(e.startsWith(`-`)&&(a||!e.startsWith(`--- `))&&(o=`removed`),e.startsWith(`+`)&&(a||!e.startsWith(`+++ `))&&(o=`added`)),a&&((o===`removed`||e.startsWith(` `))&&(r=Math.max(0,r-1)),(o===`added`||e.startsWith(` `))&&(i=Math.max(0,i-1))),{text:e,kind:o}})}function fo(e){if(!e)return[];let t=e.split(`
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-B0Z9INg1.js";import{$n as a,$t as o,A as s,An as c,Bn as l,C as u,E as d,En as f,Er as p,Gn as m,Hn as h,In as g,J as _,Jn as v,K as y,Kn as b,Kt as x,Mn as S,N as C,Nn as w,O as T,Or as E,P as D,Pn as O,Q as k,Qn as A,Rn as j,S as M,T as N,Tn as P,U as F,Un as I,Vn as L,Wn as R,Xn as ee,Y as z,Yn as B,Z as te,Zn as V,_ as ne,an as re,bn as ie,cr as ae,ct as oe,dr as se,et as ce,fr as le,ft as ue,g as de,gn as fe,gt as pe,ht as me,i as he,in as ge,j as _e,jn as ve,kn as ye,kr as be,l as xe,mn as Se,mt as Ce,nt as we,on as Te,ot as Ee,q as De,rn as Oe,rt as ke,sn as Ae,sr as je,st as Me,tn as Ne,tt as Pe,ur as Fe,v as Ie,wn as Le,wr as Re,x as ze,xn as Be,y as Ve,yn as He,yr as Ue,z as We}from"./workflow-api-3z2Qqsmo.js";import{$ as Ge,A as Ke,At as qe,Ct as Je,D as Ye,Dt as Xe,E as Ze,Et as Qe,J as $e,K as et,M as tt,N as nt,Nt as rt,O as it,Ot as at,Q as ot,R as st,St as ct,T as lt,Tt as ut,U as dt,X as ft,Y as pt,Z as mt,at as ht,bt as gt,ct as _t,dt as vt,et as yt,ft as bt,gt as xt,ht as St,i as Ct,it as wt,j as Tt,k as Et,kt as Dt,lt as Ot,mt as kt,n as At,o as jt,ot as Mt,pt as Nt,q as Pt,rt as Ft,s as It,st as Lt,t as Rt,tt as zt,ut as Bt,vt as Vt,wt as Ht,xt as Ut,yt as Wt}from"./select-COVn-75j.js";function Gt(e){if(!e)return;let{used:t,window:n}=e;return n>0?`context ${Math.round(t/n*100)}%`:`${t} tokens`}function Kt(e){if(!e||e.window<=0)return;let{used:t,window:n,spend:r}=e,i=[{label:`Context`,value:`${Math.round(t/n*100)}% · ${Jt(t)}/${Jt(n)} tokens`}];if(!r)return i;if(i.push({label:`Spent`,value:`${Jt(r.tokens)} tokens · ${qt(r.costUSD)}`}),i.push({label:`Cache reads`,value:`${Jt(r.cached)} of ${Jt(r.tokens)}`}),r.models.length>1)for(let e of r.models)i.push({label:e.id,value:`${Jt(e.tokens)} · ${qt(e.costUSD)}`,model:!0});return i}function qt(e){return e>=.01?`$${e.toFixed(2)}`:e===0?`$0.00`:`$${e.toFixed(4)}`}function Jt(e){return e>=1e6?`${Math.round(e/1e5)/10}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`}function Yt(e){return e.lifecycle===`live`?e.awaiting?`awaiting`:e.turnInFlight?`running`:`idle`:e.lifecycle}function Xt(e){return e===`running`||e===`awaiting`}function Zt(e){return e.status===`settled`||e.status===`ended`?`filed-away`:e.attention?.group===`needs-input`?`needs-input`:e.attention?.group===`unread`?`unread`:e.status===`running`||e.status===`awaiting`||$t(e)?`working`:e.status===`idle`?`idle`:`dormant`}function Qt(e){switch(e){case`needs-input`:return`Needs input`;case`unread`:return`Unread`;case`working`:return`Working`;case`idle`:return`Idle`;case`dormant`:return`Dormant`;case`filed-away`:return`Filed away`}}function $t(e){return e.status===`idle`&&e.activeSubagents+e.activeBackgroundCalls+(e.activeWorkflows??0)>0}function en(e){return e!==`settled`&&e!==`ended`}function tn(e){return e===`dormant`||e===`settled`}function nn(e){let t={tokens:0,cached:0,costUSD:0,models:[]};for(let n of e){t.tokens+=n.tokens,t.cached+=n.cached,t.costUSD+=n.costUSD;for(let e of n.models){let n=t.models.find(t=>t.id===e.id);n?(n.tokens+=e.tokens,n.cached+=e.cached,n.costUSD+=e.costUSD):t.models.push({...e})}}return t}function rn(){return{status:`idle`,lifecycle:`live`,turnInFlight:!1,entries:[],queue:[],activeSubagents:0,activeBackgroundCalls:0,lastSeq:0}}function an(e){return e===`running`||e===`waiting`}function on(e,t=rn()){let n=t;for(let t of e)n=cn(n,t);return n}function sn(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`user`&&r.producer===void 0)return e;if(r.kind===`assistant`&&r.producer===void 0){if(r.endedAt===t)return e;let i=e.slice();return i[n]={...r,endedAt:t},i}}return e}function cn(e,t){let n=ln(e,t.event,t.at);return n===void 0?{...e,lastSeq:t.seq}:n===e?e:{...n,status:Yt({lifecycle:n.lifecycle,turnInFlight:n.turnInFlight,awaiting:n.asking!==void 0&&n.asking.producer===void 0||n.authorising!==void 0&&n.authorising.producer===void 0}),lastSeq:t.seq}}function ln(e,t,n){switch(t.type){case`session_started`:return{...e,backend:t.backend,scope:t.scope,capabilities:t.capabilities,...t.permissionMode?{permissionMode:t.permissionMode}:{},...t.worktree===void 0?{}:{worktree:t.worktree}};case`capabilities_changed`:return{...e,capabilities:t.capabilities};case`user_message`:return{...e,spoken:!0,entries:hn(e.entries,{kind:`user`,id:t.id,...t.fromSessionId===void 0?{text:t.text}:{text:t.text.slice(t.text.indexOf(`
|
|
2
|
+
`)+1),fromSessionId:t.fromSessionId},...t.note===void 0?{}:{note:t.note},...t.attachments===void 0?{}:{attachments:t.attachments},at:n})};case`subagent_instruction`:return{...e,entries:hn(e.entries,{kind:`user`,id:t.id,text:t.text,producer:t.producer,at:n})};case`turn_started`:return{...e,turnInFlight:!0};case`message`:return{...e,entries:hn(e.entries,{kind:`assistant`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`thinking`:return{...e,entries:hn(e.entries,{kind:`thinking`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`tool_started`:return{...e,entries:hn(e.entries,{kind:`tool`,id:t.callId,name:t.name,input:t.input,status:`running`,...mn(t)})};case`tool_updated`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,update:t.update}))};case`tool_ended`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,result:t.result,status:t.isError?`error`:`complete`}))};case`subagent`:{let r=e.entries.find(e=>e.kind===`subagent`&&e.id===t.subagentId),i=r!==void 0&&an(r.status),a=an(t.state),o=a?void 0:r?.endedAt??n;return{...e,activeSubagents:e.activeSubagents+ +!!a-+!!i,entries:hn(e.entries,{kind:`subagent`,id:t.subagentId,name:t.name,...t.description===void 0?{}:{description:t.description},...t.model===void 0?{}:{model:t.model},...t.effort===void 0?{}:{effort:t.effort},...t.producer===void 0?{}:{producer:t.producer},status:t.state,...t.state===`waiting`?{waitingOn:t.on}:{},startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`background_call`:{let r=e.entries.find(e=>e.kind===`background_call`&&e.id===t.callId),i=r?.status===`running`,a=t.state===`running`,o=a?void 0:r?.endedAt??n;return{...e,activeBackgroundCalls:e.activeBackgroundCalls+ +!!a-+!!i,entries:hn(e.entries,{kind:`background_call`,id:t.callId,tool:t.tool,status:t.state,...mn(t),startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`enquiry`:{let n=t.state===`asked`,r=n&&e.asking?.askId===t.askId?e.asking:n?{askId:t.askId,questions:t.questions,...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}}:e.asking?.askId===t.askId?void 0:e.asking;return{...e,...r===void 0?{asking:void 0}:{asking:r},entries:hn(e.entries,{kind:`enquiry`,id:t.askId,questions:t.questions,status:t.state,...t.state===`answered`?{answers:t.answers}:{},...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}})}}case`permission`:{let n=t.state===`asked`?e.authorising??{callId:t.callId,tool:t.tool,...t.context===void 0?{}:{context:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope},...t.producer===void 0?{}:{producer:t.producer}}:e.authorising?.callId===t.callId?pn(e.entries,t.callId):e.authorising;return{...e,...n===void 0?{authorising:void 0}:{authorising:n},entries:gn(e.entries,t.callId,e=>({...e,authorisation:fn(t),...t.context===void 0?{}:{permissionContext:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope}}))}}case`turn_ended`:return{...e,entries:sn(e.entries,n),turnInFlight:!1,asking:e.asking?.producer===void 0?void 0:e.asking,authorising:e.authorising?.producer===void 0?void 0:e.authorising};case`queue_changed`:return{...e,queue:[...t.pending],queuedMessages:e.queuedMessages?.length===t.pending.length&&e.queuedMessages.every((e,n)=>e.text===t.pending[n]&&e.id===t.ids?.[n]&&(e.attachments?.length??0)===(t.attachments?.[n]?.length??0)&&(e.attachments??[]).every((e,r)=>e===t.attachments?.[n]?.[r]))?e.queuedMessages:t.pending.map((e,n)=>({id:t.ids?.[n],text:e,...t.attachments?.[n]?.length?{attachments:t.attachments[n]}:{}}))};case`workflow_spend`:{let n={...e.workflowSpend,[t.executionId]:t.spend},r=nn([...e.parentSpend?[e.parentSpend]:[],...Object.values(n)]);return{...e,workflowSpend:n,spend:r,...e.contextUsage?{contextUsage:{...e.contextUsage,spend:r}}:{}}}case`context_usage`:{let n=t.spend||e.workflowSpend?nn([...t.spend?[t.spend]:[],...Object.values(e.workflowSpend??{})]):void 0;return{...e,...t.spend?{parentSpend:t.spend}:{},...n?{spend:n}:{},contextUsage:{used:t.used,window:t.window,...n===void 0?{}:{spend:n}}}}case`model_changed`:return{...e,model:t.model};case`permission_mode_changed`:return{...e,permissionMode:t.mode};case`effort_changed`:return{...e,effort:t.effort};case`branch_changed`:return{...e,branch:t.branch};case`notice`:return{...e,entries:[...e.entries,{kind:`notice`,id:`notice-${e.entries.length}`,level:t.level,text:t.text,...t.sessionId===void 0?{}:{sessionId:t.sessionId}}]};case`compacting`:return t.active?{...e,compacting:!0}:un(e);case`compacted`:return{...un(e),entries:[...e.entries,{kind:`marker`,id:`compacted-${e.entries.length}`,marker:`compacted`,text:dn(t.trigger,t.before,t.after)}]};case`session_dormant`:return{...e,lifecycle:`dormant`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`dormant-${e.entries.length}`,marker:`dormant`,text:`Dormant: ${t.reason}`}]};case`session_settled`:return{...e,lifecycle:`settled`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`settled-${e.entries.length}`,marker:`settled`,text:`Settled`}]};case`rewound`:{let n=e.entries.findIndex(e=>e.kind===`user`&&e.id===t.userMessageId),r=t.restore===`files`?`Files rewound`:t.restore===`both`?`Rewound conversation and files`:`Rewound conversation`;return{...e,entries:[...n<0||t.restore===`files`?e.entries:e.entries.map((e,t)=>t<n||e.rewound?e:{...e,rewound:!0}),{kind:`marker`,id:`rewound-${e.entries.length}`,marker:`rewound`,text:r}]}}case`forked`:return{...e,entries:[...e.entries,{kind:`marker`,id:`forked-${e.entries.length}`,marker:`forked`,text:`Forked`,fromSessionId:t.fromSessionId}]};case`revived`:return{...e,...t.scope===void 0?{}:{scope:t.scope},lifecycle:`live`,turnInFlight:!1,entries:[...e.entries,{kind:`marker`,id:`revived-${t.fromSeq}`,marker:`revived`,text:`Revived from seq ${t.fromSeq}`}]};case`session_ended`:return{...e,lifecycle:`ended`,turnInFlight:!1,endedReason:t.reason,asking:void 0,authorising:void 0}}}function un(e){if(!e.compacting)return e;let{compacting:t,...n}=e;return n}function dn(e,t,n){let r=e===`auto`?`Compacted automatically`:`Compacted`;return n===void 0?`${r}, from ${Jt(t)} tokens`:`${r}, ${Jt(t)} → ${Jt(n)} tokens`}function fn(e){return e.state===`asked`?`asked`:e.state===`aborted`||e.decision===`deny`?`denied`:e.decision===`always`?`always`:`allowed`}function pn(e,t){let n=e.find(e=>e.kind===`tool`&&e.id!==t&&e.authorisation===`asked`);return n?.kind===`tool`?{callId:n.id,tool:n.name,...n.permissionContext===void 0?{}:{context:n.permissionContext},...n.allowAlways===void 0?{}:{allowAlways:n.allowAlways},...n.authorizationScope===void 0?{}:{authorizationScope:n.authorizationScope},...n.producer===void 0?{}:{producer:n.producer}}:void 0}function mn(e){return e.producer===void 0?{}:{producer:e.producer}}function hn(e,t){let n=e.findIndex(e=>e.kind===t.kind&&e.id===t.id);if(n<0)return[...e,t];let r=[...e];return r[n]=t,r}function gn(e,t,n){let r=e.findIndex(e=>e.kind===`tool`&&e.id===t);if(r<0)return e;let i=e[r];if(!i||i.kind!==`tool`)return e;let a=[...e];return a[r]=n(i),a}var H=e(be(),1),_n=e(E(),1);function vn(e){return`${e.kind}:${e.id}`}var U=Re();function yn(e,t){let n=/\/worktrees\/([^/]+)\/[^/]+$/.exec(e)?.[1];return n===void 0?void 0:t.find(e=>e.name===n)?.path}var bn=rt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xn=rt(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Sn=rt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Cn=rt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wn=rt(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),Tn=rt(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),En=rt(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Dn=rt(`folder-search`,[[`path`,{d:`M10.7 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 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),On=rt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),kn=rt(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),An=rt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),jn=rt(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Mn=rt(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Nn=rt(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Pn=rt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fn=rt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),In=rt(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Ln=rt(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Rn=rt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),zn=rt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Bn(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function Vn(e){return e.trim()!==``}function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Un(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Wn(e,t){return t!=null&&!x(t)?0:typeof e==`function`?e():e}function Gn(e,t,n){let r=Wn(e,n);return typeof r==`number`?r:r?.[t]}function Kn(e){return typeof e==`function`?e():e}function qn(e,t){return t||e===`click`||e===`mousedown`}function Jn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Yn=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ie,currentIdRef:{current:null},currentContextRef:{current:null}});function Xn(e,t){e.current=t.current}function Zn(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Be();return V(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:Gn(i.current,`open`),close:Gn(n,`close`)}},[n,o,i,a]),(0,U.jsx)(Yn.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function Qn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:f}=H.useContext(Yn),[p,m]=H.useState(!1),h=H.useRef(n);return V(()=>{h.current=n},[n]),V(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,l,f,r]),V(()=>{if(!n)return;let e=l.current,t=a.current;f.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:Gn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,d(F))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,f]),V(()=>()=>{if(a.current===i){if(l.current=null,!h.current)return;a.current=null,Xn(o,c),f.clear()}},[l,a,o,i,c,f]),H.useMemo(()=>({hasProvider:u,delayRef:o,isInstantPhase:p}),[u,o,p])}function $n(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function er(e){return e!=null&&e.clientX!=null}function tr(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=H.useRef(!1),u=H.useRef(null),[d,f]=H.useState(),[p,m]=H.useState([]),h=A(e=>{i.set(`positionReference`,e)}),g=A((e,t,n)=>{l.current||c.current.openEvent&&!er(c.current.openEvent)||i.set(`positionReference`,$n(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=A(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=x(d)?o:a;H.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ae(o);function r(t){let n=Ae(t);Te(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||er(c.current.openEvent)?u.current=Le(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),H.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),H.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),H.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=H.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return H.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function nr(){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Ft,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function rr(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:nr(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:L,inactiveTriggerProps:L,popupProps:L}}function ir(e,t,n=!1){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var ar=e=>e.triggerIdProp??e.activeTriggerId,or=e=>e.openProp??e.open,sr=e=>(e.popupElement?.id??e.floatingId)||void 0;function cr(e,t){return t!==void 0&&or(e)&&ar(e)===t}function lr(e,t){return cr(e,t)?!0:t!==void 0&&or(e)&&ar(e)==null&&e.triggerCount===1}var ur={open:or,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ar,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:sr,isTriggerActive:(e,t)=>t!==void 0&&ar(e)===t,isOpenedByTrigger:(e,t)=>cr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ar(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>lr(e,t)?sr(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},dr=S();function fr(e){let t=H.useCallback(t=>e===void 0?h:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,dr.useSyncExternalStore)(t,n,()=>e?.serverStore)}var pr=He&&fe;function mr(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=H.useRef(!1),c=H.useRef(null),l=H.useRef(!0),u=Be();H.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ae(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&se(e)&&e===re(b(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return P(Le(t,`blur`,r),pr&&Le(t,`keydown`,a,!0),pr&&Le(t,`pointerdown`,o,!0))},[i,n]),H.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);Fe(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=H.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ae(t.nativeEvent);if(Fe(a)){if(pr&&!t.relatedTarget){if(!l.current&&!Oe(a))return}else if(!ge(a))return}let o=Ne(t.relatedTarget,i.context.triggerElements),{nativeEvent:f,currentTarget:p}=t,m=typeof r==`function`?r():r;if(i.select(`open`)&&o||m===0||m===void 0){i.setOpen(!0,d(De,f,p));return}u.start(m,()=>{s.current||i.setOpen(!0,d(De,f,p))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Fe(n)&&n.hasAttribute(N(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=re(b(e));!n&&t===e||Te(o.current.floatingContext?.refs.floating.current,t)||Te(e,t)||a||Ne(n??t,i.context.triggerElements)||i.setOpen(!1,d(De,r))})}}},[o,r,i,u]);return H.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var hr=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ie,this.restTimeout=new ie,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},gr=new WeakMap;function _r(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&gr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),gr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function vr(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=gr.get(n);a&&a!==e&&_r(a),_r(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,gr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function yr(e){let t=e.context.dataRef.current,n=a(()=>t.hoverInteractionState??hr.create()).current;return t.hoverInteractionState||=n,w(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function br(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,s=a.useState(`open`),c=a.useState(`floatingElement`),l=a.useState(`domReferenceElement`),{dataRef:u}=a.context,f=Xe(),p=Qe(),m=yr(a),h=Be(),g=A(()=>qn(u.current.openEvent?.type,m.interactedInside)),v=A(()=>Jn(u.current.openEvent?.type)),y=A(()=>{_r(m)});V(()=>{s||(m.pointerType=void 0,m.restTimeoutPending=!1,m.interactedInside=!1,y())},[s,m,y]),H.useEffect(()=>y,[y]),V(()=>{if(n&&s&&m.handleCloseOptions?.blockPointerEvents&&v()&&Fe(l)&&c){let e=l,t=c,n=b(c),r=f?.nodesRef.current.find(e=>e.id===p)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=m.pointerEventsScopeElement===t?null:m.pointerEventsScopeElement,a=r===t?null:r,o=m.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return vr(m,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{y()}}},[n,s,l,c,m,v,f,p,y]),H.useEffect(()=>{if(!n)return;function e(){return!!(f&&p&&qe(f.nodesRef.current,p).length>0)}function t(e){let t=Gn(r,`close`,m.pointerType),n=()=>{a.setOpen(!1,d(_,e)),f?.events.emit(`floating.closed`,e)};t?m.openChangeTimeout.start(t,n):(m.openChangeTimeout.clear(),n())}function s(e){let t=Ae(e);if(!o(t)){m.interactedInside=!1;return}m.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function l(){m.openChangeTimeout.clear(),h.clear(),f?.events.off(`floating.closed`,x),y()}function b(n){if(e()&&f){f.events.on(`floating.closed`,x);return}if(Ne(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(f&&r&&Fe(o)&&qe(f.nodesRef.current,r,!1).some(e=>Te(e.context?.elements.floating,o)))){if(m.handler){m.handler(n);return}y(),v()&&!g()&&t(n)}}function x(t){!f||!p||e()||h.start(0,()=>{f.events.off(`floating.closed`,x),a.setOpen(!1,d(_,t)),f.events.emit(`floating.closed`,t)})}let S=c;return P(S&&Le(S,`mouseenter`,l),S&&Le(S,`mouseleave`,b),S&&Le(S,`pointerdown`,s,!0),()=>{f?.events.off(`floating.closed`,x)})},[n,c,a,u,r,i,v,g,y,m,f,p,h])}var xr={current:null};function Sr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=xr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:v,events:y}=g.context,S=Xe(l),C=yr(g),w=H.useRef(!1),T=Dt(i),E=Dt(r),D=Dt(o),O=Dt(n),k=Dt(m),j=Dt(p),M=A(()=>qn(v.current.openEvent?.type,C.interactedInside)),N=A(()=>k.current?.()!==!1),F=A((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!Te(e,t);if(!Fe(n))return!1;let i=n;return r.hasMatchingElement(e=>Te(e,i))&&(!e||!Te(e,i))}),I=A(()=>{C.handler&&=(b(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,C.handler),void 0)}),L=A(()=>{_r(C)});return u&&(C.handleCloseOptions=T.current?.__options),H.useEffect(()=>I,[I]),H.useEffect(()=>{if(!n)return;function e(e){e.open?w.current=!1:(w.current=e.reason===_,I(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return y.on(`openchange`,e),()=>{y.off(`openchange`,e)}},[n,y,C,I]),H.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Gn(E.current,`close`,C.pointerType);n?C.openChangeTimeout.start(n,()=>{g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e)}):t&&(C.openChangeTimeout.clear(),g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e))}let t=c.current??(u?g.select(`domReferenceElement`):null);if(!Fe(t))return;function r(e){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,a&&!x(C.pointerType))return;let t=Kn(D.current),n=Gn(E.current,`open`,C.pointerType),r=Ae(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(Fe(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(Te(e,r)){s=e;break}}Fe(i)&&Fe(o)&&!g.context.triggerElements.hasElement(i)&&Te(i,o)&&(s=o);let c=s!=null&&F(o,s,r),l=g.select(`open`),u=j.current?.()??g.select(`transitionStatus`)===`ending`,f=!l&&u&&w.current,p=!c&&Fe(s)&&Fe(o)&&Te(o,s)&&f,m=t>0&&!n,h=c&&(l||f)||p,v=!l||c;if(h){N()&&g.setOpen(!0,d(_,e,s));return}m||(n?C.openChangeTimeout.start(n,()=>{v&&N()&&g.setOpen(!0,d(_,e,s))}):v&&N()&&g.setOpen(!0,d(_,e,s)))}function i(t){if(M()){L();return}I();let n=g.select(`domReferenceElement`),r=b(n);C.restTimeout.clear(),C.restTimeoutPending=!1;let i=v.current.floatingContext??f?.();if(!Ne(t.relatedTarget,g.context.triggerElements)){if(T.current&&i){g.select(`open`)||C.openChangeTimeout.clear();let n=c.current;C.handler=T.current({...i,tree:S,x:t.clientX,y:t.clientY,onClose(){L(),I(),O.current&&!M()&&n===g.select(`domReferenceElement`)&&e(t,!0)}}),r.addEventListener(`mousemove`,C.handler),C.handler(t);return}(C.pointerType!==`touch`||!Te(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Te(t,e.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}let l=h?Le(t,`mouseout`,o):void 0;return s?P(Le(t,`mousemove`,r,{once:!0}),Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l):P(Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l)},[I,L,v,E,g,n,T,C,u,F,M,a,s,D,c,S,O,f,j,N,h]),H.useMemo(()=>{if(!n)return;function e(e){C.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=F(r,n,e.target);if(a&&!x(C.pointerType))return;if(i&&o&&C.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=C.handleCloseOptions?.getScope?.()??n.ownerDocument.body;vr(C,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=Kn(D.current);if(i&&!o||s===0||!o&&C.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;C.restTimeout.clear();function c(){if(C.restTimeoutPending=!1,M())return;let e=g.select(`open`);!C.blockMouseMove&&(!e||o)&&N()&&g.setOpen(!0,d(_,t,n))}C.pointerType===`touch`?_n.flushSync(()=>{c()}):o&&i?c():(C.restTimeoutPending=!0,C.restTimeout.start(s,c))}}},[n,C,M,F,a,g,D,N])}var Cr=.1,wr=Cr*Cr,Tr=.5;function Er(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Dr(e,t,n,r,i,a,o,s,c,l){let u=!1;return Er(e,t,n,r,i,a)&&(u=!u),Er(e,t,i,a,o,s)&&(u=!u),Er(e,t,o,s,c,l)&&(u=!u),Er(e,t,c,l,n,r)&&(u=!u),u}function Or(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Ar(e={}){let{blockPointerEvents:t=!1}=e,n=new ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*wr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ae(r),g=r.type===`mouseleave`,_=Te(u,h),v=Te(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Fe(r.relatedTarget)&&Te(u,r.relatedTarget))return;function y(){return!!(s&&qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=kr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=kr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=kr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=kr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Or(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Tr+1,o=C||T?S.bottom-Tr:S.top,s=C?T?S.bottom-Tr:S.top:S.bottom-Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Tr,o=C||T?S.top+Tr:S.bottom,s=C?T?S.top+Tr:S.bottom:S.top+Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Tr+1,o=w||E?S.right-Tr:S.left,s=w?E?S.right-Tr:S.left:S.right-Tr;M=Dr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Tr,o=w||E?S.left+Tr:S.right,s=w?E?S.left+Tr:S.right:S.left+Tr;M=Dr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function jr(){let{config:e,refresh:t}=Ue(),{save:n,saving:r}=Ve(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Un(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mr,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(Nr,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(Fr,{onAdd:l}),(0,U.jsx)(Ir,{current:o,saving:r,onSave:n,onSaved:t}),(0,U.jsxs)(Ie,{title:`Worktrees`,description:`Machine-wide.`,children:[(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Always start new Agent Sessions in a Worktree`}),(0,U.jsx)(dt,{checked:e.worktrees?.always===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{always:e}},e?`New Agent Sessions start in a Worktree.`:`New Agent Sessions start in the Project.`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Update the Source Branch before cutting a Worktree`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Fast-forwards the branch from its upstream in the Project. If this fails, the Worktree is cut from the local branch and a warning is shown.`})]}),(0,U.jsx)(dt,{checked:e.worktrees?.updateSource===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{updateSource:e}},e?`Source Branches are updated before a Worktree is cut.`:`Worktrees are cut from the local branch.`)})]})]})]})}function Mr({included:e,onRemove:t}){return(0,U.jsx)(Ie,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(zn,{"aria-hidden":!0})})]})]},e.path))})})}function Nr({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(Ie,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Hn(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(O,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function Pr(e){let[t,n]=(0,H.useState)(void 0),r=(0,H.useRef)(``);return(0,H.useEffect)(()=>{if(r.current=e,!Vn(e)){n(void 0);return}let t=new AbortController,i=setTimeout(()=>{(async()=>{try{let i=await p(`/api/directories?q=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)return;let a=await i.json();a.query===r.current&&n(a)}catch{}})()},150);return()=>{t.abort(),clearTimeout(i)}},[e]),t}function Fr({onAdd:e}){let[t,n]=(0,H.useState)(``),r=Pr(t),i=Bn(t);return(0,U.jsxs)(Ie,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(he,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[i===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function Ir({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(Ie,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(he,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(de,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}var Lr=H.createContext(void 0);function Rr(e){let t=H.useContext(Lr);if(!e&&t===void 0)throw Error(B(27));return t}var zr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Rr(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return j(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:pt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Br=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...c}=e,l=Rr(),u=l.useState(`open`),{getButtonProps:f,buttonRef:p}=R({disabled:a,native:o}),m={disabled:a};function h(e){u&&l.setOpen(!1,d(s,e.nativeEvent))}return j(`button`,e,{state:m,ref:[t,p],props:[{onClick:h},c,f]})}),Vr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),j(`p`,e,{ref:t,props:[{id:c},o]})}),Hr=H.createContext(void 0);function Ur(){let e=H.useContext(Hr);if(e===void 0)throw Error(B(26));return e}var Wr={...$e,...Ee,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},Gr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Rr(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Ur(),we({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?_t(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=j(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...wt,hidden:!m,onKeyDown(e){st.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Wr});return(0,U.jsx)(ct,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Kr=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Rr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,U.jsx)(Hr.Provider,{value:n,children:(0,U.jsxs)(u,{ref:t,...r,children:[a&&o===!0&&(0,U.jsx)(nt,{ref:i.context.internalBackdropRef,inert:Me(!s)}),e.children]})}):null});function qr({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=H.useState(0),[u,d]=H.useState(0),f=c===0,p=gt(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ae(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Te(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return tt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),V(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),bt(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Jr={...ur,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Yr=class extends f{constructor(e,t,n){let r=new Ft,i=Xr(e,r,t,n);super(i,Zr(r),Jr)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ot(n,e,t.trigger),this.update(n)}};function Xr(e,t,n,r=!1){let i={...rr(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=ir(t,n,r),i}function Zr(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Qr(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Rr(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=Nt((e,t)=>new Yr({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);kt(x,S),Bt(x);let{forceUnmount:T}=vt(S,x);H.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,d(D))}),[T,x]);let E=S||C;return(0,U.jsxs)(Lr.Provider,{value:x,children:[u&&(0,U.jsx)(ht,{handle:u,store:x}),E&&(0,U.jsx)(qr,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function $r(e){return Qr(`dialog`,e)}var ei=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),j(`h2`,e,{ref:t,props:[{id:c},o]})}),ti=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Rr(!0),f=fr(l)??d;if(!f)throw Error(B(79));let p=xe(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=H.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=St(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=R({disabled:a,native:o}),S=Ut(m),C=Tt(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return j(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[k]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:mt})});function ni({...e}){return(0,U.jsx)($r,{"data-slot":`dialog`,...e})}function ri({...e}){return(0,U.jsx)(ti,{"data-slot":`dialog-trigger`,...e})}function ii({...e}){return(0,U.jsx)(Kr,{"data-slot":`dialog-portal`,...e})}function ai({className:e,...t}){return(0,U.jsx)(zr,{"data-slot":`dialog-overlay`,className:g(`fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function oi({className:e,children:t,showCloseButton:n=!0,...r}){return(0,U.jsxs)(ii,{children:[(0,U.jsx)(ai,{}),(0,U.jsxs)(Gr,{"data-slot":`dialog-content`,className:g(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-sm text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,U.jsxs)(Br,{"data-slot":`dialog-close`,render:(0,U.jsx)(O,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(zn,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function si({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-1.5`,e),...t})}function ci({className:e,showCloseButton:t=!1,children:n,...r}){return(0,U.jsxs)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,U.jsx)(Br,{render:(0,U.jsx)(O,{variant:`outline`}),children:`Close`})]})}function li({className:e,...t}){return(0,U.jsx)(ei,{"data-slot":`dialog-title`,className:g(`font-heading text-base leading-none font-medium`,e),...t})}function ui({className:e,...t}){return(0,U.jsx)(Vr,{"data-slot":`dialog-description`,className:g(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function di({session:e,onClose:t}){let{connection:n,config:r}=Ue(),[i,a]=(0,H.useState)(e.suggestedScope??``),[o,s]=(0,H.useState)(()=>yn(e.scope,r.projectList??[])??``),[c,l]=(0,H.useState)(void 0),[u,d]=(0,H.useState)(!1),f=i.trim()!==``&&(!e.worktree||o.trim()!==``),p=async()=>{d(!0),l(void 0);try{await n.command({type:`relocate`,sessionId:e.id,scope:i.trim(),...e.worktree?{repo:o.trim()}:{}}),await n.command({type:`revive`,sessionId:e.id}),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,U.jsx)(ni,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,U.jsxs)(oi,{className:`sm:max-w-lg`,children:[(0,U.jsxs)(si,{children:[(0,U.jsx)(li,{children:`Relocate Agent Session`}),(0,U.jsx)(ui,{children:`Its Scope no longer exists. Choose where its files are now.`})]}),(0,U.jsx)(ne,{label:`Old Scope`,children:e.scope}),(0,U.jsx)(fi,{label:`Scope`,value:i,onChange:a}),e.worktree?(0,U.jsx)(fi,{label:`Repository`,value:o,onChange:s}):null,c===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,U.jsxs)(ci,{children:[(0,U.jsx)(O,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(O,{disabled:!f||u,onClick:()=>void p(),children:`Relocate and revive`})]})]})})}function fi({label:e,value:t,onChange:n}){let r=Pr(t),i=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),(0,U.jsx)(he,{id:i,className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`/path/to/folder`,spellCheck:!1}),r?.paths.filter(e=>e!==t).slice(0,5).map(e=>(0,U.jsx)(O,{variant:`ghost`,size:`sm`,className:`justify-start font-mono text-xs`,onClick:()=>n(e),children:e},e))]})}var pi=new Map;function mi(e,t){pi.set(e,structuredClone(t))}function hi(e){let t=pi.get(e);return t&&structuredClone(t)}function gi(e){pi.delete(e)}function _i(e){for(let t of pi.keys())e.has(t)||pi.delete(t)}var vi=2e3,yi=3e4,bi=(0,H.createContext)(void 0);function xi(){let e=(0,H.useContext)(bi);if(!e)throw Error(`useAgentSessions outside SessionsProvider`);return e}function Si({children:e}){let{connection:t}=Ue(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(void 0),c=(0,H.useRef)(()=>{});(0,H.useEffect)(()=>{let e=!1,n,i,o=0,s=0,l=0,u=e=>{n&&clearTimeout(n),n=setTimeout(()=>void d(),e)},d=async()=>{if(e||document.hidden)return;i?.abort(),i=new AbortController;let n=++o;try{let i=await t.listSessions();if(e||n<=s)return;s=n,l=0,_i(new Set(i.map(e=>e.id))),r(i),a(!0),u(vi)}catch{if(e)return;a(!0),l+=1,u(Math.min(yi,vi*2**l))}},f=()=>{document.hidden||d()};return c.current=()=>void d(),d(),document.addEventListener(`visibilitychange`,f),()=>{e=!0,c.current=()=>{},n&&clearTimeout(n),i?.abort(),document.removeEventListener(`visibilitychange`,f)}},[t]);let l=(0,H.useCallback)(()=>c.current(),[]),u=n.find(e=>e.id===o);return(0,U.jsxs)(bi.Provider,{value:{sessions:n,loaded:i,nudge:l,relocate:s},children:[e,u?(0,U.jsx)(di,{session:u,onClose:()=>{s(void 0),l()}}):null]})}function Ci(){let{connection:e}=Ue(),{nudge:t,relocate:n}=xi();return(0,H.useCallback)(async r=>{try{let n=await e.command(r);return t(),n}catch(e){if(e.code===`scope_missing`&&`sessionId`in r&&r.sessionId!==void 0){n(r.sessionId),t();return}ze.error(`${r.type} failed`,e instanceof Error?e.message:String(e)),t();return}},[e,t,n])}var wi=[`general`,`projects`,`permissions`,`providers`,`appearance`,`keyboard`,`workflows`,`secrets`,`mcp`],Ti={sessionId:void 0};function Ei(e){let[t=``,n=``]=e.replace(/^#\/?/,``).split(`?`,2),r=t.split(`/`).filter(e=>e!==``);if(r[0]===`settings`)return{sessionId:void 0,settings:ki(r[1])};let i=Di(r),a=new URLSearchParams(n).get(`settings`);return a===null?i:{...i,settings:ki(a)}}function Di(e){if(e[0]===`spend`)return{sessionId:void 0,spend:!0};if(e[0]===`pull-requests`){let t=Ai(e[1]??``),n=Number(e[2]);return t?Number.isSafeInteger(n)&&n>0?{sessionId:void 0,pullRequests:!0,project:t,pullRequest:n}:{sessionId:void 0,pullRequests:!0,project:t}:{sessionId:void 0,pullRequests:!0}}if(e[0]===`schedules`){let t={sessionId:void 0,schedules:!0};if(e[1]===`occurrences`){let n=Ai(e[2]??``);return n?{...t,occurrenceId:n}:t}let n=Ai(e[1]??``);return n?{...t,scheduleId:n}:t}if(e[0]===`new`&&e[1])return{sessionId:void 0,backend:Ai(e[1])};if(e[0]!==`s`||e[1]===void 0)return Ti;let t=Ai(e[1]);return{sessionId:t===``?void 0:t}}function Oi(e){let t=e.spend?`#/spend`:e.pullRequests?`#/pull-requests${e.project?`/${encodeURIComponent(e.project)}${e.pullRequest?`/${e.pullRequest}`:``}`:``}`:e.schedules?`#/schedules${e.occurrenceId?`/occurrences/${encodeURIComponent(e.occurrenceId)}`:e.scheduleId?`/${encodeURIComponent(e.scheduleId)}`:``}`:e.sessionId===void 0?e.backend?`#/new/${encodeURIComponent(e.backend)}`:``:`#/s/${encodeURIComponent(e.sessionId)}`;return e.settings===void 0?t:`${t||`#/`}?settings=${e.settings}`}function ki(e){return wi.find(t=>t===Ai(e??``))??wi[0]}function Ai(e){try{return decodeURIComponent(e)}catch{return``}}function ji(e){return e.title||e.id}var Mi=60,Ni=[{key:`description`,shape:`text`},{key:`command`,shape:`text`},{key:`questions`,shape:`questions`},{key:`file_path`,shape:`path`},{key:`notebook_path`,shape:`path`},{key:`pattern`,shape:`text`},{key:`url`,shape:`text`},{key:`query`,shape:`text`},{key:`path`,shape:`path`},{key:`prompt`,shape:`text`}],Pi=Ni.filter(({key:e})=>e!==`description`);function Fi(e){return Li(e,Mi)}function Ii(e){return Li(e,1/0,Pi)}function Li(e,t,n=Ni){if(!e||typeof e!=`object`)return;let r=e;for(let e of n){let n=r[e.key];if(e.shape===`questions`){let e=Ri(n,t);if(e!==void 0)return e;continue}if(typeof n==`string`&&n.trim()!==``)return e.shape===`path`?Bi(n.trim(),t):zi(n,t)}let i=Object.values(r).filter(e=>typeof e==`string`),a=i.length===1?i[0]:void 0;return a&&a.trim()!==``?zi(a,t):void 0}function Ri(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0];if(!n||typeof n!=`object`)return;let r=n.question;if(typeof r!=`string`||r.trim()===``)return;let i=e.length-1;return zi(i>0?`${r} (+${i} more)`:r,t)}function zi(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Bi(e,t){return e.length<=t?e:`…${e.slice(-(t-1))}`}var Vi=H.createContext(void 0);function Hi(e){let t=H.useContext(Vi);if(t===void 0&&!e)throw Error(B(72));return t}var Ui={...ur,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Wi=class extends f{constructor(e,t,n){let r=new Ft;super(Gi(e,r,t,n),Ki(r),Ui)}setOpen=(e,t)=>{Mt(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,d(z,e))}};function Gi(e,t,n,r=!1){let i={...rr(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e};return i.floatingRootContext=ir(t,n,r),i}function Ki(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var qi=ye(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:f=null,children:p}=e,m=Nt((e,t)=>new Wi({open:n,openProp:r,activeTriggerId:f,triggerIdProp:u},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,u),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Bt(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=vt(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=H.useRef(null);V(()=>{h&&t&&m.setOpen(!1,d(_e))},[h,t,m]),V(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),V(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),H.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,d(D))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,U.jsxs)(Vi.Provider,{value:m,children:[l&&(0,U.jsx)(ht,{handle:l,store:m}),E&&(0,U.jsx)(Ji,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function Ji({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=gt(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=tr(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>ee(a.reference,i.reference),[a.reference,i.reference]);return bt(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??L}),null}var Yi=H.createContext(void 0);function Xi(){return H.useContext(Yi)}var Zi=`data-base-ui-tooltip-trigger`;function Qi(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Fe(n))return n}}let t=e.target;return Fe(t)?t:null}function $i(e){let t=e;for(;t;){let e=t.closest(`[${Zi}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Fe(n.host)?n.host:null}return null}var ea=c(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:f,...p}=e,m=Hi(!0),h=fr(a)??m;if(!h)throw Error(B(82));let g=xe(f),v=h.useState(`isTriggerActive`,g),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`floatingRootContext`),S=H.useRef(null),C=c??600,w=u??0,{registerTrigger:T,isMountedByThisTrigger:E}=St(g,S,h,{payload:o,closeOnClick:l,closeDelay:w}),D=Xi(),{delayRef:O,isInstantPhase:k,hasProvider:A}=Qn(b,{open:y}),M=yr(b);h.useSyncedValue(`isInstantPhase`,k);let N=h.useState(`disabled`),P=s??N,F=Dt(P),I=h.useState(`trackCursorAxis`),L=h.useState(`disableHoverablePopup`),R=H.useRef(!1),ee=Be(),z=H.useRef(void 0);function te(){return A?Gn(O.current,`open`)===0?0:c??D??600:C}function V(e){let t=S.current;if(!t||!e)return!1;let n=$i(e);return n!==null&&n!==t&&Te(t,n)}function ne(e){let t=V(e);return R.current=t,t&&(M.openChangeTimeout.clear(),M.restTimeout.clear(),M.restTimeoutPending=!1,ee.clear()),t}let re=Sr(b,{enabled:!P,mouseOnly:!0,move:!1,handleClose:!L&&I!==`both`?Ar():null,restMs:te,delay(){return u==null&&A?{close:Gn(O.current,`close`)}:{close:w}},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!R.current}}),ie=mr(b,{enabled:!P}).reference,ae=e=>{let t=R.current,n=Qi(e),r=ne(n),i=S.current,a=i&&n&&Te(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,d(_,e));return}if(t&&!r&&a&&!F.current&&!h.select(`open`)&&i&&x(z.current)){let t=()=>{!R.current&&!F.current&&!h.select(`open`)&&h.setOpen(!0,d(_,e,i))},n=te();n===0?(ee.clear(),t()):ee.start(n,t)}},oe=h.useState(`triggerProps`,E);return j(`button`,e,{state:{open:y},ref:[t,T,S],props:[re,ie,E||I!==`none`?oe:void 0,{onMouseOver(e){ae(e.nativeEvent)},onFocus(e){V(Qi(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){R.current=!1,ee.clear(),z.current=void 0},onPointerEnter(e){z.current=e.pointerType},onPointerDown(e){z.current=e.pointerType,h.set(`closeOnClick`,l),l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,"data-trigger-disabled":P?``:void 0,[Zi]:P?void 0:``},p],stateAttributesMapping:mt})}),ta=H.createContext(void 0);function na(){let e=H.useContext(ta);if(e===void 0)throw Error(B(70));return e}var ra=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Hi().useState(`mounted`)||n?(0,U.jsx)(ta.Provider,{value:n,children:(0,U.jsx)(M,{ref:t,...r})}):null}),ia=H.createContext(void 0);function aa(){let e=H.useContext(ia);if(e===void 0)throw Error(B(71));return e}var oa=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Pe,style:g,..._}=e,v=Hi(),y=na(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=v.useState(`adaptiveOrigin`),O=ot({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:D}),k=H.useMemo(()=>({open:b,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,O.side,O.align,O.anchorHidden,S,T]),A=et(e,k,{styles:O.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,U.jsx)(ia.Provider,{value:O,children:A})}),sa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{side:s,align:c}=aa(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);we({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),br(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return j(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[wt,f,Pt(d),a],stateAttributesMapping:pt})}),ca=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=aa(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return j(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:$e})}),la=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,U.jsx)(Yi.Provider,{value:t,children:(0,U.jsx)(Zn,{delay:i,timeoutMs:r,children:e.children})})};function ua({delay:e=0,...t}){return(0,U.jsx)(la,{"data-slot":`tooltip-provider`,delay:e,...t})}function da({...e}){return(0,U.jsx)(qi,{"data-slot":`tooltip`,...e})}function fa({...e}){return(0,U.jsx)(ea,{"data-slot":`tooltip-trigger`,...e})}function pa({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,U.jsx)(ra,{children:(0,U.jsx)(oa,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,U.jsxs)(sa,{"data-slot":`tooltip-content`,className:g(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,U.jsx)(ca,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:translate-x-[1.5px] data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:translate-x-[-1.5px] data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:translate-x-[-1.5px] data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:translate-x-[1.5px] data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var ma=H.createContext(void 0);function ha(e){let t=H.useContext(ma);if(t===void 0&&!e)throw Error(B(33));return t}var ga=H.createContext(void 0);function _a(e){let t=H.useContext(ga);if(t===void 0&&!e)throw Error(B(36));return t}var va=H.createContext(void 0);function ya(e=!0){let t=H.useContext(va);if(t===void 0&&!e)throw Error(B(25));return t}function ba(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=ya(!0),f=d!==void 0;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:We})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!He&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&m(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var xa={type:`regular-item`};function Sa(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=R({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=ba({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>ee(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=I(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Ca=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Et({guess:!0,label:a}),f=ha(!0),p=xe(i),{store:m}=_a(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Sa({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:xa});return j(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),wa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=_a(),{side:c,align:l}=ha(),u=it(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;we({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){s.setOpen(!1,d(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),br(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k={transitionStatus:p,side:c,align:l,open:f,nested:v.type===`menu`,instant:g},A=j(`div`,e,{state:k,ref:[t,s.context.popupRef,O],stateAttributesMapping:pt,props:[m,{onKeyDown(e){u&&st.has(e.key)&&e.stopPropagation()}},Pt(p),o,{"data-rootownerid":b}]}),M=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(M=!0),(0,U.jsx)(ct,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?M:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:A})}),Ta=H.createContext(void 0);function Ea(){let e=H.useContext(Ta);if(e===void 0)throw Error(B(32));return e}var Da=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=_a();return i.useState(`mounted`)||n?(0,U.jsx)(Ta.Provider,{value:n,children:(0,U.jsx)(u,{ref:t,...r})}):null}),Oa=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ce,style:_,...v}=e,{store:b}=_a(),x=Ea(),S=ya(!0),C=b.useState(`parent`),w=b.useState(`floatingRootContext`),T=b.useState(`floatingTreeRoot`),E=b.useState(`mounted`),D=b.useState(`open`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`activeTriggerElement`),j=b.useState(`transitionStatus`),M=b.useState(`positionerElement`),N=b.useState(`instantType`),P=b.useState(`adaptiveOrigin`),F=b.useState(`lastOpenChangeReason`),I=b.useState(`floatingNodeId`),L=b.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=H.useRef(null),z=ke(M),B=n,te=c,ne=l,re=s,ie=g;C.type===`context-menu`&&(B=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??Pe):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,le=ot({anchor:B,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:p,collisionBoundary:u,collisionPadding:f,sticky:m,nodeId:I,keepMounted:x,disableAnchorTracking:h,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===b.select(`floatingParentNodeId`)&&b.setOpen(!1,d(y)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[b,T.events,I]),H.useEffect(()=>{if(b.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==b.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;b.setOpen(!1,d(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,b]);let ue=Be();H.useEffect(()=>{D||ue.clear()},[D,ue]),H.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==b.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=b.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{b.setOpen(!1,d(y))}):b.setOpen(!1,d(y))}else ue.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,b,ue]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:b.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,b,I,L]),V(()=>{let e=R,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return z(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[R,z,b]);let de={open:D,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:C.type===`menu`,instant:N},fe=C.type===`menubar`&&C.context.modal;Ze(D&&(fe||O&&F!==`trigger-hover`),k===`touch`,M,A);let pe=et(e,de,{styles:le.positionerStyles,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),me=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),he=null;return C.type===`menubar`?he=C.context.contentElement:C.type===void 0&&(he=A),(0,U.jsxs)(ma.Provider,{value:le,children:[me&&(0,U.jsx)(nt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Me(!D),cutout:he}),(0,U.jsx)(Je,{id:I,children:(0,U.jsx)(Ye,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:pe})})]})}),ka=H.createContext(null);function Aa(e){let t=H.useContext(ka);if(t===null&&!e)throw Error(B(5));return t}var ja={...ur,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Ma=class extends f{constructor(e){super({...Pa(),...e},Na(),ja),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Na(){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ft}}function Pa(){return{...rr(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new at,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:L,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var Fa=H.createContext(void 0);function Ia(){return H.useContext(Fa)}var La=ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:f,closeParentOnEsc:p=!1,handle:m,triggerId:h,defaultTriggerId:g=null,highlightItemOnHover:_=!0}=e,v=ya(!0),y=_a(!0),b=Aa(!0),x=Ia(),S=H.useMemo(()=>x&&y?{type:`menu`,store:y.store}:b?{type:`menubar`,context:b}:v&&!y?{type:`context-menu`,context:v}:{type:void 0},[v,y,b,x]),C=Ra({open:a,openProp:n,activeTriggerId:g,triggerIdProp:h,parent:S});C.useControlledProp(`openProp`,n),C.useControlledProp(`triggerIdProp`,h),C.useContextCallback(`onOpenChangeComplete`,i);let w=te(),T=te(),E=C.useState(`floatingTreeRoot`),O=ut(E),k=Qe(),j=C.useState(`open`),M=C.useState(`activeTriggerElement`),N=C.useState(`positionerElement`),P=C.useState(`hoverEnabled`),F=C.useState(`disabled`),I=C.useState(`lastOpenChangeReason`),R=C.useState(`parent`),z=C.useState(`activeIndex`),B=C.useState(`payload`),ne=C.useState(`floatingParentNodeId`),re=H.useRef(null),ie=H.useRef(R.type!==`context-menu`),ae=Be(),oe=H.useRef(!0),se=Be(),ce=ne!=null,{openMethod:le,triggerProps:ue}=Ke(j);C.useSyncedValues({disabled:o,highlightItemOnHover:_,modal:R.type===void 0?s:void 0,openMethod:le,rootId:w}),Bt(C);let{forceUnmount:de}=vt(j,C,()=>{C.set(`allowMouseEnter`,!1)});V(()=>{v&&!y?C.update({parent:{type:`context-menu`,context:v},floatingNodeId:O,floatingParentNodeId:k}):y&&C.update({floatingNodeId:O,floatingParentNodeId:k})},[v,y,O,k,C]),H.useEffect(()=>{if(j||(re.current=null),R.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,R.type]),V(()=>{!j&&!P&&C.set(`hoverEnabled`,!0)},[j,P,C]);let fe=A((e,t)=>{let n=t.reason;if(!e&&!C.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Lt(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;C.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,se.start(300,()=>{oe.current=!0})):(oe.current=!0,se.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};re.current=t.event,Ot(c,e,t.trigger,i()),C.update(c),R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?C.set(`instantType`,`group`):o||s?C.set(`instantType`,o?`click`:`dismiss`):C.set(`instantType`,void 0)}),pe=Vt({popupStore:C,floatingId:T,nested:k!=null,onOpenChange:fe}),me=pe.context.events;V(()=>{let e=({open:e,eventDetails:t})=>fe(e,t);return me.on(`setOpen`,e),()=>{me?.off(`setOpen`,e)}},[me,fe]);let he=H.useCallback(()=>{C.setOpen(!1,d(D))},[C]);H.useImperativeHandle(f,()=>({unmount:de,close:he}),[de,he]);let ge;R.type===`context-menu`&&(ge=R.context),H.useImperativeHandle(ge?.positionerRef,()=>N,[N]),H.useImperativeHandle(ge?.actionsRef,()=>({setOpen:fe}),[fe]);let _e=gt(pe,{enabled:!F,bubbles:{escapeKey:p&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:ce?E:void 0}),ve=Ge(),ye=H.useCallback(e=>{C.select(`activeIndex`)!==e&&C.set(`activeIndex`,e)},[C]),be=zt(pe,{enabled:!F,listRef:C.context.itemDomElements,activeIndex:z,nested:R.type!==void 0,loopFocus:c,orientation:u,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,rtl:ve===`rtl`,disabledIndices:l,onNavigate:ye,openOnArrowKeyDown:R.type!==`context-menu`,externalTree:ce?E:void 0,focusItemOnHover:_}),xe=H.useCallback(e=>{C.context.typingRef.current=e},[C]),Se=yt(pe,{enabled:!F,listRef:C.context.itemLabels,elementsRef:C.context.itemDomElements,activeIndex:z,resetMs:500,onMatch:e=>{j&&e!==z&&C.set(`activeIndex`,e)},onTyping:xe}),Ce=H.useMemo(()=>{let e=ee(Se.reference,be.reference,_e.reference,{onMouseMove(){C.set(`allowMouseEnter`,!0)}},ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[C,Se.reference,be.reference,_e.reference,ue,j]),we=H.useMemo(()=>{let e=ee(be.trigger,_e.trigger,ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[be.trigger,_e.trigger,ue]),Te=H.useMemo(()=>ee(wt,{id:T,role:`menu`,"aria-labelledby":M?.id,onMouseMove(){C.set(`allowMouseEnter`,!0),R.type===`menu`&&C.set(`hoverEnabled`,!1)},onClick(){C.select(`hoverEnabled`)&&C.set(`hoverEnabled`,!1)},onKeyDown(e){let t=C.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Se.floating,be.floating,_e.floating),[M,T,R.type,C,Se.floating,be.floating,_e.floating]),Ee=be.item??L;bt(C,{floatingRootContext:pe,activeTriggerProps:Ce,inactiveTriggerProps:we,popupProps:Te,itemProps:Ee});let De=H.useMemo(()=>({store:C,parent:S}),[C,S]),Oe=(0,U.jsxs)(ga.Provider,{value:De,children:[m&&(0,U.jsx)(ht,{handle:m,store:C}),typeof t==`function`?t({payload:B}):t]});return R.type===void 0||R.type===`context-menu`?(0,U.jsx)(Ht,{externalTree:E,children:Oe}):Oe});function Ra(e){return a(()=>new Ma(e)).current}function za(e){let t=_a().store,n=H.useMemo(()=>({parentMenu:t}),[t]);return(0,U.jsx)(Fa.Provider,{value:n,children:(0,U.jsx)(La,{...e})})}function Ba(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=v(),{ref:i,index:a}=Et(e),o=n===a,s=H.useRef(null),c=I(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function Va(e){let{render:t,className:n,style:r,state:i=L,props:a=l,refs:o=l,metadata:s,stateAttributesMapping:c,tag:u=`div`,...d}=e,{compositeProps:f,compositeRef:p}=Ba({metadata:s});return j(u,e,{state:i,ref:[p,...o],props:[f,...a,d],stateAttributesMapping:c})}function Ha(e){if(se(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!le(e))return Ha(je(e))}function Ua(e,t){let n=H.useRef(null);function r(t){_n.flushSync(()=>{e.setOpen(!1,d(C,t.nativeEvent,t.currentTarget))}),me(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&pe(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{_n.flushSync(()=>{e.setOpen(!1,d(C,n.nativeEvent,n.currentTarget))});let i=Ce(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Te(r,i);){let e=i;if(i=ue(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Wa(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,b(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:L,[t,n,r])}var Ga=c(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=_a(!0),h=fr(d)??m?.store;if(!h)throw Error(B(85));let g=xe(s),_=h.useState(`isTriggerActive`,g),y=h.useState(`floatingRootContext`),x=h.useState(`isOpenedByTrigger`,g),S=h.useState(`triggerPopupId`,g),C=H.useRef(null),w=qa(),E=v(!0),D=Xe(),O=H.useMemo(()=>D??new at,[D]),k=ut(O),M=Qe(),{registerTrigger:N,isMountedByThisTrigger:P}=St(g,C,h,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:k,floatingParentNodeId:M,keyboardEventRelay:E?.relayKeyboardEvent}),F=w.type===`menubar`,I=h.useState(`disabled`),z=a||I||F&&w.context.disabled,{getButtonProps:te,buttonRef:V}=R({disabled:z,native:o});H.useEffect(()=>{!x&&w.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,x,w.type]);let ne=H.useRef(null),re=Be(),ie=A(e=>{if(!ne.current)return;re.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Te(ne.current,t)||Te(h.select(`positionerElement`),t)||t===ne.current||(t==null||Ha(t)!==h.select(`rootId`))&&(lt(e,ne.current)||O.events.emit(`close`,{domEvent:e,reason:T}))});H.useEffect(()=>{x&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&b(ne.current).addEventListener(`mouseup`,ie,{once:!0})},[x,ie,h]);let ae=F&&w.context.hasSubmenuOpen,se=Sr(y,{enabled:(c??ae)&&!z&&(!F||ae&&!P),handleClose:Ar({blockPointerEvents:!F}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ce=Ka(x,h.select(`lastOpenChangeReason`)),le=Ut(y,{enabled:!z,event:x&&F?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&ce}),ue=mr(y,{enabled:!z&&ae}),de=Wa({open:x,enabled:F,mouseDownAction:`open`}),fe=H.useMemo(()=>ee(ue.reference,le.reference),[ue.reference,le.reference]),pe=h.useState(`triggerProps`,P),{preFocusGuardRef:me,handlePreFocusGuardFocus:he,handleFocusTargetFocus:ge}=Ua(h,C),_e={disabled:z,open:x},ve=[ne,t,V,N,C],ye=[fe,se??L,pe,{"aria-haspopup":`menu`,"aria-controls":S,id:g,onMouseDown:e=>{h.select(`open`)||(re.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),b(e.currentTarget).addEventListener(`mouseup`,ie,{once:!0}))}},F?{role:`menuitem`}:{},de,p,te],be=j(`button`,e,{enabled:!F,stateAttributesMapping:ft,state:_e,ref:ve,props:ye});return F?(0,U.jsx)(Va,{tag:`button`,render:n,className:r,style:i,state:_e,refs:ve,props:ye,stateAttributesMapping:ft}):x?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(oe,{ref:me,onFocus:he},`${g}-pre-focus-guard`),(0,U.jsx)(H.Fragment,{children:be},g),(0,U.jsx)(oe,{ref:h.context.triggerFocusTargetRef,onFocus:ge},`${g}-post-focus-guard`)]}):(0,U.jsx)(H.Fragment,{children:be},g)});function Ka(e,t){let n=Be(),[r,i]=H.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function qa(){let e=Aa(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Ja=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return j(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Ya={"aria-expanded":void 0},Xa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ia();if(!p?.parentMenu)throw Error(B(37));let m=Et({guess:!0,label:a}),h=ha(),{store:g}=_a(),_=xe(o),v=g.useState(`open`),y=g.useState(`floatingRootContext`),b=g.useState(`floatingTreeRoot`),x=g.useState(`triggerPopupId`,_),S=xt(_,g),C=H.useCallback(e=>{let t=S(e);return e!==null&&g.select(`open`)&&g.select(`activeTriggerId`)==null&&g.update({activeTriggerId:_,activeTriggerElement:e,closeDelay:u}),t},[S,u,g,_]),w=H.useRef(null),T=H.useCallback(e=>{w.current=e,g.set(`activeTriggerElement`,e)},[g]);g.useSyncedValue(`closeDelay`,u);let E=p.parentMenu,D=g.useState(`disabled`),O=E.useState(`disabled`),k=d||D||O,A=E.useState(`itemProps`),M=E.useState(`isActive`,m.index),N=H.useMemo(()=>({type:`submenu-trigger`,setActive(){E.select(`highlightItemOnHover`)&&E.set(`activeIndex`,m.index)}}),[E,m.index]),{getItemProps:P,itemRef:F}=Sa({closeOnClick:!1,disabled:k,highlighted:M,id:_,store:g,typingRef:E.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:h?.context.nodeId}),I=Sr(y,{enabled:g.useState(`hoverEnabled`)&&c&&!k,handleClose:Ar({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>E.select(`allowMouseEnter`):void 0,triggerElementRef:w,externalTree:b,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),R=Ut(y,{enabled:!k,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??L,ee=g.useState(`triggerProps`,!0);delete ee.id;let z={disabled:k,highlighted:M,open:v},te=g.useState(`openMethod`),V=g.useState(`lastOpenChangeReason`)===`list-navigation`||te===`keyboard`;return j(`div`,e,{state:z,stateAttributesMapping:mt,props:[R,I,ee,A,v&&V&&Se?Ya:void 0,{"aria-controls":x,tabIndex:v||M?0:-1,onBlur(){M&&E.set(`activeIndex`,null)}},f,P],ref:[t,m.ref,F,C,T]})});function Za({...e}){return(0,U.jsx)(La,{"data-slot":`dropdown-menu`,...e})}function Qa({className:e,...t}){return(0,U.jsx)(Ga,{"data-slot":`dropdown-menu-trigger`,className:e,...t})}function $a({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,U.jsx)(Da,{children:(0,U.jsx)(Oa,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,U.jsx)(wa,{"data-slot":`dropdown-menu-content`,className:g(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function eo({className:e,inset:t,variant:n=`default`,...r}){return(0,U.jsx)(Ca,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function to({...e}){return(0,U.jsx)(za,{"data-slot":`dropdown-menu-sub`,...e})}function no({className:e,inset:t,children:n,...r}){return(0,U.jsxs)(Xa,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:g(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,U.jsx)(Cn,{className:`ml-auto`})]})}function ro({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,U.jsx)($a,{"data-slot":`dropdown-menu-sub-content`,className:g(`w-auto min-w-[96px] rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function io({className:e,...t}){return(0,U.jsx)(Ja,{"data-slot":`dropdown-menu-separator`,className:g(`-mx-1 my-1 h-px bg-border/50`,e),...t})}var ao=6e4,oo=60*ao,so=24*oo;function co(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,t-n);return r<ao?`just now`:r<oo?`${Math.floor(r/ao)}m`:r<so?`${Math.floor(r/oo)}h`:new Date(n).toISOString().slice(0,10)}function lo(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.old_string==`string`?t.old_string:void 0,r=typeof t.new_string==`string`?t.new_string:typeof t.content==`string`?t.content:void 0;if(n!==void 0||r!==void 0)return{...typeof t.file_path==`string`?{path:t.file_path}:{},removed:fo(n),added:fo(r)}}function uo(e,t){let n=!!t?.trim();if(!n){let t=/^--- [^\n]*\n\+\+\+ [^\n]*\n/m.test(e),n=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m.test(e);if(!t||!n)return}let r=0,i=0;return(e.match(/[^\n]*\n|[^\n]+$/g)??[]).map(e=>{let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(t)return r=Number(t[1]??1),i=Number(t[2]??1),{text:e,kind:`context`};let a=r>0||i>0,o=`context`;return(a||n)&&(e.startsWith(`-`)&&(a||!e.startsWith(`--- `))&&(o=`removed`),e.startsWith(`+`)&&(a||!e.startsWith(`+++ `))&&(o=`added`)),a&&((o===`removed`||e.startsWith(` `))&&(r=Math.max(0,r-1)),(o===`added`||e.startsWith(` `))&&(i=Math.max(0,i-1))),{text:e,kind:o}})}function fo(e){if(!e)return[];let t=e.split(`
|
|
3
3
|
`);for(;t.length>0&&t[t.length-1]===``;)t.pop();return t}var po=[[/^mcp__/,`mcp`],[/^(bash|shell|exec|run_?command)$/,`shell`],[/^(read|read_?file|view|notebookread)$/,`read`],[/^(write|write_?file|create_?file|notebookedit)$/,`write`],[/^(edit|multi_?edit|str_replace(_based_edit_tool|_editor)?|apply_?patch)$/,`edit`],[/^(grep|search|ripgrep)$/,`search`],[/^(glob|ls|list|find|list_?directory)$/,`list`],[/^(web_?fetch|web_?search|fetch)$/,`web`],[/^(task|agent)$/,`agent`],[/^todo_?write$/,`todo`]];function mo(e){let t=e.toLowerCase();return po.find(([e])=>e.test(t))?.[1]??`other`}function ho(e){if(typeof e==`string`)return e;let t=Array.isArray(e)?e:typeof e==`object`&&e&&Array.isArray(e.content)?e.content:void 0;if(!t)return;let n=t.flatMap(e=>typeof e==`object`&&e&&typeof e.text==`string`?[e.text]:[]);return n.length>0?n.join(`
|
|
4
4
|
`):void 0}function go(e){if(e!==void 0)return e.split(`
|
|
5
5
|
`).filter(e=>e.trim()!==``).length}function _o(e,t){return`${e} ${t}${e===1?``:`s`}`}function vo(e){if(e.status===`error`)return`failed`;if(e.status!==`complete`)return;let t=lo(e.input);if(t)return`+${t.added.length} −${t.removed.length}`;let n=go(ho(e.result));if(n!==void 0)switch(mo(e.name)){case`read`:return _o(n,`line`);case`list`:return _o(n,`file`);case`search`:return _o(n,`result`);default:return}}var yo={shell:In,read:En,write:Tn,edit:wn,search:Fn,list:Dn,web:kn,agent:xn,todo:An,mcp:Nn,other:Rn};function bo({name:e,className:t}){let n=yo[mo(e)];return(0,U.jsx)(n,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,t)})}var xo={scale:1,x:0,y:0};function So(e,t,n){let r=Math.min(8,Math.max(1,e.scale));return{scale:r,x:Math.min(0,Math.max(t-t*r,e.x)),y:Math.min(0,Math.max(n-n*r,e.y))}}function Co(e,t,n,r,i,a){let o=Math.min(8,Math.max(1,e.scale*t)),s=o/e.scale;return So({scale:o,x:n-(n-e.x)*s,y:r-(r-e.y)*s},i,a)}function wo(e,t,n,r,i){return So({...e,x:e.x+t,y:e.y+n},r,i)}function To({src:e,alt:t,className:n,referrerPolicy:r,onError:i}){return(0,U.jsxs)(ni,{children:[(0,U.jsx)(ri,{render:(0,U.jsx)(`button`,{type:`button`,"aria-label":t?`Open ${t}`:`Open image`,className:`cursor-zoom-in rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/30`}),children:(0,U.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`,referrerPolicy:r,onError:i,className:g(`block`,n)})}),(0,U.jsxs)(oi,{className:`w-auto max-w-[80vw] gap-0 p-2 sm:max-w-[80vw]`,children:[(0,U.jsx)(li,{className:`sr-only`,children:t||`Image`}),(0,U.jsx)(Eo,{src:e,alt:t,referrerPolicy:r})]})]})}function Eo({src:e,alt:t,referrerPolicy:n}){let r=(0,H.useRef)(null),i=(0,H.useRef)(void 0),[a,o]=(0,H.useState)(xo);(0,H.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?16:1,i=t.deltaX*r,a=t.deltaY*r;o(e=>t.ctrlKey?Co(e,Math.exp(-Math.max(-50,Math.min(50,a))*.01),t.clientX-n.left,t.clientY-n.top,n.width,n.height):wo(e,-i,-a,n.width,n.height))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let s=()=>r.current.getBoundingClientRect(),c=()=>{i.current=void 0};return(0,U.jsx)(`div`,{ref:r,className:g(`relative touch-none overflow-hidden rounded-md select-none`,a.scale>1?`cursor-grab active:cursor-grabbing`:`cursor-zoom-in`),onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),i.current={x:e.clientX,y:e.clientY})},onPointerMove:e=>{let t=i.current;if(!t)return;let{width:n,height:r}=s(),a=e.clientX-t.x,c=e.clientY-t.y;i.current={x:e.clientX,y:e.clientY},o(e=>wo(e,a,c,n,r))},onPointerUp:c,onPointerCancel:c,onDoubleClick:e=>{let{left:t,top:n,width:r,height:i}=s(),a=e.clientX-t,c=e.clientY-n;o(e=>e.scale>1?xo:Co(e,2,a,c,r,i))},children:(0,U.jsx)(`img`,{src:e,alt:t,referrerPolicy:n,draggable:!1,className:`block max-h-[calc(80dvh-1rem)] max-w-[calc(80vw-1rem)] origin-top-left will-change-transform`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.scale})`}})})}function Do(e){if(!e.startsWith(`/`))return;let t=/^\/([A-Za-z0-9][\w-]*(?::(?:[A-Za-z0-9][\w-]*)?)?)?/.exec(e)?.[1]??``;return{name:t,to:t.length+1}}function Oo(e){let t=Do(e);if(!t||t.name===``||t.name.endsWith(`:`))return;let n=e[t.to];if(n===void 0||n===` `||n===`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{Pn as t,kr as n,n as r,t as i,wr as a}from"./workflow-api-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{Pn as t,kr as n,n as r,t as i,wr as a}from"./workflow-api-3z2Qqsmo.js";import{C as o,S as s,_t as c,d as l,ht as u,u as d,x as f,yt as p}from"./workflows-hcZXxss1.js";import{i as m,n as h,o as g,s as _,t as v}from"./select-COVn-75j.js";import{t as y}from"./index-CHFNROUs.js";var b=e(n(),1),x=a();function S({sessionId:e,placement:n=`right`,mobileNavigation:a}){let S=i(`/api/workflows`),C=`/api/sessions/${encodeURIComponent(e)}/workflows`,w=i(C),[T,E]=(0,b.useState)(()=>p(e)),[D,O]=(0,b.useState)(T?.workflowId??``),[k,A]=(0,b.useState)(T?.input??{}),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(T?.error??``),[F,I]=(0,b.useState)(!1),[L,R]=(0,b.useState)(T!==void 0),z=i(j?`${C}/${j}`:void 0,1e3),{sessions:B}=u(),V=B.find(t=>t.id===e),H=S.data?.workflows.find(e=>e.id===D),U=z.data?.execution,W=!!(z.data?.enquiries.length||z.data?.permissions.length),G=[...w.data?.executions??[]].sort((e,t)=>t.startedAt-e.startedAt);(0,b.useEffect)(()=>{let t=p(e);E(t),O(t?.workflowId??``),A(t?.input??{}),M(``),P(t?.error??``),R(t!==void 0)},[e]),(0,b.useEffect)(()=>{if(j||!G.length)return;let e=G.find(e=>e.status===`running`||e.status===`recovery-required`);M((e??G[0]).id)},[j,w.data]);let K=``;try{H&&(s(H),o(H.inputSchema,k))}catch(e){K=f(e)}let q=H&&V&&H.backend!==V.backend,J=async(t,n)=>{I(!0);try{let i=await r(t,`POST`,n);i.execution&&(M(i.execution.id),R(!1),t===C&&(c(e),E(void 0))),P(`Request accepted`)}catch(e){P(f(e))}finally{I(!1)}};return(0,x.jsxs)(`section`,{className:`workflow-panel grid grid-cols-[minmax(0,1fr)] content-start gap-3 overflow-auto p-3 text-sm`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workflows`}),(0,x.jsx)(t,{size:`sm`,variant:`outline`,disabled:F||!w.data||w.data.occupied||V?.status===`ended`,onClick:()=>R(e=>!e),children:L?`Close`:`New workflow`})]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Independent of parent chat. Steps share this Scope.`}),(S.error||w.error||z.error||N)&&(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:N||S.error||w.error||z.error}),T&&(0,x.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/5 p-3`,role:`alert`,children:[(0,x.jsx)(`p`,{className:`font-medium`,children:`Workflow did not start`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`This Agent Session was kept. Review the preserved inputs below and retry here; retrying will not create another Agent Session.`})]}),L&&!w.data?.occupied&&(0,x.jsx)(`section`,{"aria-label":`New workflow`,children:(0,x.jsxs)(`div`,{className:`grid gap-3 pt-2`,children:[(0,x.jsxs)(v,{value:D,onValueChange:e=>{if(e===null)return;O(e);let t=S.data?.workflows.find(t=>t.id===e);A(t?l(t.inputSchema):{})},children:[(0,x.jsx)(g,{className:`w-full`,"aria-label":`Workflow`,children:(0,x.jsx)(_,{children:H?.name??`Select workflow`})}),(0,x.jsxs)(h,{children:[(0,x.jsx)(m,{value:``,children:`Select workflow`}),S.data?.workflows.map(e=>(0,x.jsx)(m,{value:e.id,children:e.name},e.id))]})]}),H&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(d,{schema:H.inputSchema,value:k,onChange:A}),q&&(0,x.jsxs)(`p`,{role:`alert`,children:[`This workflow requires Backend Adapter `,H.backend,`.`,` `,(0,x.jsx)(`a`,{className:`underline`,href:`#/new/${encodeURIComponent(H.backend)}`,children:`Create a matching Agent Session`}),`.`]}),K&&(0,x.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-destructive`,role:`alert`,children:K}),(0,x.jsx)(t,{size:`sm`,className:`justify-self-start`,disabled:F||!w.data||w.data.occupied||V?.status===`ended`||!!K||!!q,onClick:()=>void J(C,{workflowId:D,input:k,...T?{launchId:T.launchId,nameSession:!0}:{}}),children:T?`Retry workflow`:`Start workflow`})]})]})}),(0,x.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:`Execution history`}),(0,x.jsxs)(v,{items:[{value:``,label:`Select execution`},...G.map(e=>({value:e.id,label:`${e.name} · ${e.status.replaceAll(`-`,` `)} · ${new Date(e.startedAt).toLocaleString()}${e.testStepId?` · step test`:``}`}))],disabled:F,value:j,onValueChange:e=>{e!==null&&(M(e),a?.onBack())},children:[(0,x.jsx)(g,{className:`w-full`,"aria-label":`Execution history`,children:(0,x.jsx)(_,{})}),(0,x.jsxs)(h,{children:[(0,x.jsx)(m,{value:``,children:`Select execution`}),G.map(e=>(0,x.jsxs)(m,{value:e.id,children:[e.name,` · `,e.status.replaceAll(`-`,` `),` · `,new Date(e.startedAt).toLocaleString(),e.testStepId?` · step test`:``]},e.id))]})]})]}),U&&(0,x.jsxs)(x.Fragment,{children:[[`running`,`recovery-required`].includes(U.status)&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Cancel stops work; it does not undo changes.`}),(0,x.jsx)(t,{size:`sm`,variant:`destructive`,className:`justify-self-start`,disabled:F,onClick:()=>void J(`${C}/${j}/cancel`),children:`Cancel execution`})]}),U.status===`recovery-required`&&(0,x.jsx)(`p`,{children:`Ask the parent in chat to diagnose and recover this execution.`}),W&&(0,x.jsxs)(`section`,{"aria-label":`Workflow input actions`,className:`grid gap-2`,children:[(0,x.jsx)(`h4`,{className:`font-medium`,children:`Input requested in parent chat`}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The parent relays one request at a time using the normal composer controls. This pane stays on the execution so management actions remain available.`}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:V?.status===`dormant`||V?.status===`settled`?`Revive the parent manually to continue. The request will remain pending here.`:V?.status===`running`||V?.status===`awaiting`?`The request is queued behind the parent’s current turn.`:`The parent is preparing the next request.`}),(0,x.jsx)(t,{size:`sm`,variant:`outline`,className:`justify-self-start`,onClick:()=>document.querySelector(`[data-pane] [data-composer-input]`)?.focus(),children:`Go to parent chat`})]}),z.data&&(0,x.jsx)(y,{view:z.data,detailBase:`${C}/${j}`,transcriptBase:`${C}/${j}`,placement:n,mobileNavigation:a},`${e}/${j}`)]})]})}export{S as default};
|
package/web/dist/index.html
CHANGED
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
document.documentElement.style.colorScheme = "light";
|
|
27
27
|
}
|
|
28
28
|
</script>
|
|
29
|
-
<script type="module" crossorigin src="/assets/index-
|
|
29
|
+
<script type="module" crossorigin src="/assets/index-CHFNROUs.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-B0Z9INg1.js">
|
|
31
|
-
<link rel="modulepreload" crossorigin href="/assets/workflow-api-
|
|
32
|
-
<link rel="modulepreload" crossorigin href="/assets/select-
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/assets/workflows-
|
|
31
|
+
<link rel="modulepreload" crossorigin href="/assets/workflow-api-3z2Qqsmo.js">
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/assets/select-COVn-75j.js">
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/assets/workflows-hcZXxss1.js">
|
|
34
34
|
<link rel="stylesheet" crossorigin href="/assets/workflows-Bb90N0XJ.css">
|
|
35
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
35
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D9AneSPi.css">
|
|
36
36
|
</head>
|
|
37
37
|
<body><div id="root"></div></body>
|
|
38
38
|
</html>
|