@cuongtran001/kanna 1.26.2 → 1.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/client/assets/{arc-G7GFNodT.js → arc-4hC8scRi.js} +1 -1
  2. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DeeY8zo3.js → architectureDiagram-3BPJPVTR-Bv30cOni.js} +1 -1
  3. package/dist/client/assets/{blockDiagram-GPEHLZMM-ZgLo283e.js → blockDiagram-GPEHLZMM-DXMaLW9j.js} +1 -1
  4. package/dist/client/assets/{c4Diagram-AAUBKEIU-Cd0b2E56.js → c4Diagram-AAUBKEIU-DsYJm2wH.js} +1 -1
  5. package/dist/client/assets/channel-B4JDea6G.js +1 -0
  6. package/dist/client/assets/{chunk-2J33WTMH-mpKQZiYs.js → chunk-2J33WTMH-BCJl2DGt.js} +1 -1
  7. package/dist/client/assets/{chunk-4BX2VUAB-B0iaJW8Y.js → chunk-4BX2VUAB-BozjevpA.js} +1 -1
  8. package/dist/client/assets/{chunk-55IACEB6-BARuViHP.js → chunk-55IACEB6-Baf9605v.js} +1 -1
  9. package/dist/client/assets/{chunk-727SXJPM-DGqKAozB.js → chunk-727SXJPM-Dt4h5Ari.js} +1 -1
  10. package/dist/client/assets/{chunk-AQP2D5EJ-6UTw0-au.js → chunk-AQP2D5EJ-BDsFJNTa.js} +1 -1
  11. package/dist/client/assets/{chunk-FMBD7UC4-DlALaErT.js → chunk-FMBD7UC4-DBZR7R-X.js} +1 -1
  12. package/dist/client/assets/{chunk-ND2GUHAM-BvfxD4G8.js → chunk-ND2GUHAM-BHYA9alQ.js} +1 -1
  13. package/dist/client/assets/{chunk-QZHKN3VN-WKgxuNNa.js → chunk-QZHKN3VN-Cm53kphq.js} +1 -1
  14. package/dist/client/assets/classDiagram-4FO5ZUOK-CjxmYqrd.js +1 -0
  15. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CjxmYqrd.js +1 -0
  16. package/dist/client/assets/{cose-bilkent-S5V4N54A-C41e2edl.js → cose-bilkent-S5V4N54A-kavWIhg7.js} +1 -1
  17. package/dist/client/assets/{dagre-BM42HDAG-BD8QRFoW.js → dagre-BM42HDAG-CMy40sGO.js} +1 -1
  18. package/dist/client/assets/{diagram-2AECGRRQ-BftaeV3V.js → diagram-2AECGRRQ-DvoRroZZ.js} +1 -1
  19. package/dist/client/assets/{diagram-5GNKFQAL-HvrEa0pH.js → diagram-5GNKFQAL-3vy7SLH9.js} +1 -1
  20. package/dist/client/assets/{diagram-KO2AKTUF-BQ-mWVpg.js → diagram-KO2AKTUF-BMwK56LI.js} +1 -1
  21. package/dist/client/assets/{diagram-LMA3HP47-BYz527hJ.js → diagram-LMA3HP47-DdvSuL5D.js} +1 -1
  22. package/dist/client/assets/{diagram-OG6HWLK6-rKEaXv_U.js → diagram-OG6HWLK6-CLedRUGP.js} +1 -1
  23. package/dist/client/assets/{erDiagram-TEJ5UH35-DKQ9iA30.js → erDiagram-TEJ5UH35-rP5xW4hR.js} +1 -1
  24. package/dist/client/assets/{flowDiagram-I6XJVG4X-CwaBp08t.js → flowDiagram-I6XJVG4X-B2Tz21pY.js} +1 -1
  25. package/dist/client/assets/{ganttDiagram-6RSMTGT7-DS5ATbm6.js → ganttDiagram-6RSMTGT7-Cabp2zF-.js} +1 -1
  26. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-3UzX-xGJ.js → gitGraphDiagram-PVQCEYII-j240syQv.js} +1 -1
  27. package/dist/client/assets/{index-BJIqKJPT.js → index-CucTDMIL.js} +1 -1
  28. package/dist/client/assets/{index-CNaEDhLA.js → index-DjkUUJ1s.js} +3 -3
  29. package/dist/client/assets/{infoDiagram-5YYISTIA-BZiyHXyw.js → infoDiagram-5YYISTIA-CCBxxM3E.js} +1 -1
  30. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-CIiqNiGR.js → ishikawaDiagram-YF4QCWOH-C5F1x8qL.js} +1 -1
  31. package/dist/client/assets/{journeyDiagram-JHISSGLW-C3030F0l.js → journeyDiagram-JHISSGLW-Cah2UqJC.js} +1 -1
  32. package/dist/client/assets/{kanban-definition-UN3LZRKU-PdSWPksr.js → kanban-definition-UN3LZRKU-CcK3_chd.js} +1 -1
  33. package/dist/client/assets/{linear-CV5KWM8U.js → linear-BG5oXhLJ.js} +1 -1
  34. package/dist/client/assets/{mermaid.core-Bhvd1JLY.js → mermaid.core-B3dPZhst.js} +4 -4
  35. package/dist/client/assets/{mindmap-definition-RKZ34NQL-CcVhhTLU.js → mindmap-definition-RKZ34NQL-C0-qSaM_.js} +1 -1
  36. package/dist/client/assets/{pieDiagram-4H26LBE5-DQCUkg_x.js → pieDiagram-4H26LBE5-D97HJnf6.js} +1 -1
  37. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-WSXG94ET.js → quadrantDiagram-W4KKPZXB-DVSGyQ2C.js} +1 -1
  38. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BdjUVq88.js → requirementDiagram-4Y6WPE33-RkfSKpJn.js} +1 -1
  39. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-pLMEQNMb.js → sankeyDiagram-5OEKKPKP-MDIKrtrd.js} +1 -1
  40. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BAc0y6w7.js → sequenceDiagram-3UESZ5HK-CVZ-_36Y.js} +1 -1
  41. package/dist/client/assets/{stateDiagram-AJRCARHV-MFj6qkHu.js → stateDiagram-AJRCARHV-vZwVljOH.js} +1 -1
  42. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CtJpqvsz.js +1 -0
  43. package/dist/client/assets/{timeline-definition-PNZ67QCA-Ba4wN3ah.js → timeline-definition-PNZ67QCA-DG4D72_i.js} +1 -1
  44. package/dist/client/assets/{vennDiagram-CIIHVFJN-CdA93fAH.js → vennDiagram-CIIHVFJN-BMZVzTaw.js} +1 -1
  45. package/dist/client/assets/{wardley-L42UT6IY-DoNWrNb_.js → wardley-L42UT6IY-IIvlmkZA.js} +1 -1
  46. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-D1pBJjcW.js → wardleyDiagram-YWT4CUSO-Zbc4-0Pz.js} +1 -1
  47. package/dist/client/assets/{xychartDiagram-2RQKCTM6-BDd2kC-_.js → xychartDiagram-2RQKCTM6-Co97hrme.js} +1 -1
  48. package/dist/client/index.html +1 -1
  49. package/package.json +1 -1
  50. package/dist/client/assets/channel-BbjRYXW4.js +0 -1
  51. package/dist/client/assets/classDiagram-4FO5ZUOK-CEzSUkYM.js +0 -1
  52. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CEzSUkYM.js +0 -1
  53. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BWixcgJz.js +0 -1
@@ -818,7 +818,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
818
818
  `)!==n.readPathDeny.join(`
819
819
  `)&&(w.readPathDeny=x),y.join(`
820
820
  `)!==n.writePathDeny.join(`
821
- `)&&(w.writePathDeny=y),Object.keys(w).length===0?null:w}function g(){r(m())}function v(){r(null)}return c.jsxs(c.Fragment,{children:[c.jsx(Ma,{open:e,onOpenChange:x=>{x||i()},children:c.jsxs(Xo,{className:"max-w-2xl",children:[c.jsxs(Pa,{children:["Permissions — ",t]}),c.jsxs(fl,{className:"space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Default action"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Behaviour when a tool call has no explicit allow/deny rule. ",c.jsx("strong",{children:"auto-allow"})," bypasses prompts and runs untrusted shell commands without supervision — use a worktree."]}),c.jsx(ms,{value:s,onValueChange:h,options:[{value:"ask",label:"Ask"},{value:"auto-allow",label:"Auto-allow (unsafe)"},{value:"auto-deny",label:"Auto-deny"}]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Read-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot read paths matching any entry. Defaults shown below — edit to add or remove."}),c.jsx("textarea",{value:o,onChange:x=>f.getState().setReadDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Write-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot edit or write paths matching any entry."}),c.jsx("textarea",{value:a,onChange:x=>f.getState().setWriteDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]})]}),c.jsxs(Eu,{className:"justify-between",children:[c.jsx(Re,{variant:"ghost",onClick:v,children:"Reset to defaults"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Re,{variant:"ghost",onClick:i,children:"Cancel"}),c.jsx(Re,{onClick:g,children:"Apply"})]})]})]})}),c.jsx(Ma,{open:l,onOpenChange:x=>{x||(f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null))},children:c.jsxs(Xo,{className:"max-w-md",children:[c.jsx(Pa,{children:"Enable auto-allow for this chat?"}),c.jsxs(fl,{className:"space-y-3 text-sm",children:[c.jsx("p",{children:"Auto-allow disables tool-call prompts. The model can run shell commands, write files, and edit code without asking. Read/write deny lists still apply."}),c.jsx("p",{className:"text-warning",children:"Use a worktree for risky tasks."})]}),c.jsxs(Eu,{className:"justify-end gap-2",children:[c.jsx(Re,{variant:"ghost",onClick:()=>{f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null)},children:"Cancel"}),c.jsx(Re,{variant:"destructive",onClick:()=>{const x=f.getState();u&&x.setDefaultAction(u),x.setConfirmUnsafeOpen(!1),x.setPendingDefaultAction(null)},children:"Enable auto-allow"})]})]})})]})}const Zye={defaultAction:"ask",bash:{autoAllowVerbs:["ls","pwd","git status","git diff","git log"]},readPathDeny:["~/.ssh","~/.aws","~/.gcp","~/.config/gh","~/.claude","~/.kanna","~/Library/Keychains","/etc/shadow","/etc/sudoers","~/.gnupg","~/.gitconfig","**/.git/config","~/.npmrc","~/.netrc","~/.docker/config.json","**/.env","**/.env.*","**/credentials*","**/*.pem","**/*.key","**/id_rsa*","**/id_ed25519*"],writePathDeny:["/etc/**","/usr/**","/System/**","~/.ssh/**","~/.aws/**","~/.config/gh/**","~/.claude/**","~/.kanna/**","~/.gnupg/**","~/.gitconfig","**/.git/config"],toolDenyList:[{tool:"mcp__kanna__bash",pattern:"rm\\s+-rf\\s+(/|~|\\$HOME)(?:\\b|$|\\s)"},{tool:"mcp__kanna__bash",pattern:"git\\s+push\\b.*--force"}],toolAllowList:[]},ar={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},setInterval(e,t){return window.setInterval(e,t)},clearInterval(e){window.clearInterval(e)},requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)}},Lt=_.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{ref:r,type:t,className:le("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));Lt.displayName="Input";const LY=_.createContext(null);function e_e({children:e,ports:t={}}){const n=t.timer??ar,[r,i]=_.useState(null),[s,o]=_.useState(""),a=_.useRef(null);_.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),n.setTimeout(()=>{var y,w;(y=a.current)==null||y.focus(),(w=a.current)==null||w.select()},0))},[r,n]);const l=_.useCallback(()=>{i(null),o("")},[]),u=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!1):r.kind==="prompt"?r.resolve(null):r.resolve(),l())},[l,r]),f=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!0):r.kind==="prompt"?r.resolve(s.trim()||null):r.resolve(),l())},[l,r,s]),h=_.useCallback(y=>new Promise(w=>{i({kind:"confirm",options:y,resolve:w})}),[]),m=_.useCallback(y=>new Promise(w=>{i({kind:"prompt",options:y,resolve:w})}),[]),g=_.useCallback(y=>new Promise(w=>{i({kind:"alert",options:y,resolve:w})}),[]),v=_.useMemo(()=>({confirm:h,prompt:m,alert:g}),[g,h,m]);let x="Confirm";return r&&(r.kind==="alert"?x=r.options.closeLabel??"OK":"confirmLabel"in r.options&&(x=r.options.confirmLabel??"Confirm")),c.jsxs(LY.Provider,{value:v,children:[e,c.jsx(Ma,{open:r!==null,onOpenChange:y=>{y||!r||u()},children:c.jsx(Xo,{size:"sm",onKeyDown:y=>{y.key!=="Enter"||y.shiftKey||!r||r.kind!=="confirm"||(y.preventDefault(),f())},children:r?c.jsxs(c.Fragment,{children:[c.jsxs(fl,{className:"space-y-4",children:[c.jsx(Pa,{children:r.options.title}),r.options.description?c.jsx(n0,{children:r.options.description}):null,r.kind==="prompt"?c.jsx(Lt,{ref:a,type:"text",value:s,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),f())},placeholder:r.options.placeholder}):null]}),c.jsxs(Eu,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:u,className:r.kind==="alert"?"hidden":void 0,children:"cancelLabel"in r.options?r.options.cancelLabel??"Cancel":"Cancel"}),c.jsx(Re,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:f,disabled:r.kind==="prompt"&&!s.trim(),children:x})]})]}):null})})]})}function CE(){const e=_.useContext(LY);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const $D=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("bg-card text-card-foreground",e),...t}));$D.displayName="Card";const FD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("flex flex-col space-y-1.5 p-2",e),...t}));FD.displayName="CardHeader";const $Y=_.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:le("text-2xl font-semibold leading-none tracking-tight",e),...t}));$Y.displayName="CardTitle";const FY=_.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:le("text-sm text-muted-foreground",e),...t}));FY.displayName="CardDescription";const BD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("p-6 pt-0",e),...t}));BD.displayName="CardContent";const t_e=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("flex items-center p-6 pt-0",e),...t}));t_e.displayName="CardFooter";const n_e={info:{dotVar:"var(--info)",bgClass:"bg-info/[0.06]"},warning:{dotVar:"var(--warning)",bgClass:"bg-warning/[0.06]"},success:{dotVar:"var(--success)",bgClass:"bg-success/[0.06]"},error:{dotVar:"var(--destructive)",bgClass:"bg-destructive/[0.06]"}};function r_e({variant:e,children:t,dot:n=!0,className:r}){const i=n_e[e];return c.jsxs("div",{role:"status",className:le("flex flex-wrap items-center justify-center gap-x-2 gap-y-1 border-b border-border px-4 py-2 text-xs leading-tight",i.bgClass,r),children:[n?c.jsx("span",{"aria-hidden":"true",className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:i.dotVar}}):null,t]})}const i_e="modulepreload",s_e=function(e){return"/"+e},b6={},Z=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(u=>{if(u=s_e(u),u in b6)return;b6[u]=!0;const f=u.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":i_e,f||(m.as="script"),m.crossOrigin="",m.href=u,l&&m.setAttribute("nonce",l),document.head.appendChild(m),f)return new Promise((g,v)=>{m.addEventListener("load",g),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},o_e=_.lazy(()=>Z(()=>import("./index-BJIqKJPT.js"),[]).then(e=>({default:e.Toaster})));function a_e(){return c.jsx(_.Suspense,{fallback:null,children:c.jsx(o_e,{position:"bottom-right",theme:"system",closeButton:!0,duration:6e3})})}const l_e="1.26.2",c_e={version:l_e},Hr="Kanna",x6="kanna",u_e=".kanna",d_e=".kanna-dev",f_e="KANNA_RUNTIME_PROFILE",zD=`kanna/${c_e.version}`,h_e="[kanna]",p_e=`~/${Hr}`;function kE(){const e=Reflect.get(globalThis,"process");return e==null?void 0:e.env}function m_e(e=kE()){var t;return((t=e==null?void 0:e[f_e])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function g_e(e=kE()){return m_e(e)==="dev"?d_e:u_e}function v_e(e=kE()){return`~/${g_e(e)}`}function b_e(e=kE()){return`${v_e(e)}/keybindings.json`}function uw(e){return e?`${x6} ${e}`:x6}const BY="always",zY="funk",x_e=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function y_e(e){switch(e){case"never":case"unfocused":case"always":return e;default:return BY}}function __e(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return zY}}const Vh=Qt()(e=>({chatSoundPreference:BY,chatSoundId:zY,setChatSoundPreference:t=>e({chatSoundPreference:y_e(t)}),setChatSoundId:t=>e({chatSoundId:__e(t)})})),S_e={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function w_e(e=Nt){return e.getVisibilityState()!=="visible"||!e.hasFocus()}function C_e(e){const t=new Audio(S_e[e]);return t.preload="auto",t.play()}async function oM(e,t,n=ar){if(t<=0)return;const r=Array.from({length:t},(i,s)=>new Promise(o=>{n.setTimeout(()=>{C_e(e).catch(()=>{}).finally(()=>o())},s*90)}));await Promise.all(r)}function k_e(e,t=Nt){return e==="never"?!1:e==="always"?!0:w_e(t)}function E_e(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function y6(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function N_e(e,t){if(!e)return 0;const n=y6(e),r=y6(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const UY="h-[var(--shell-top-band)] max-h-[var(--shell-top-band)]",T_e="md:my-2 md:mr-2 md:rounded-2xl md:border md:border-border";function Oh({tooltip:e,children:t,className:n,inline:r=!1,side:i}){const s=le("truncate",n);return c.jsx(o0,{children:c.jsxs(Ni,{children:[c.jsx(Ti,{asChild:!0,children:r?c.jsx("span",{className:s,children:t}):c.jsx("div",{className:s,children:t})}),c.jsx(fi,{side:i,children:e})]})})}function Qo({label:e,children:t,side:n}){return c.jsx(o0,{children:c.jsxs(Ni,{children:[c.jsx(Ti,{asChild:!0,children:t}),c.jsx(fi,{side:n,children:e})]})})}const A_e=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;function R_e(e){const t=e.match(A_e);return!t||t.length===0?null:t[t.length-1].toLowerCase()}function j_e(e){const t=[];for(const n of e.split(/[\s,]+/)){if(!n)continue;const r=R_e(n);r&&!t.includes(r)&&t.push(r)}return t}const aM=Qt()(e=>({text:"",setText:t=>e({text:t}),resetForOpen:()=>e({text:""})})),M_e=()=>aM(e=>e.text),Ea=_.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:le("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ea.displayName="Textarea";function P_e({open:e,busy:t,onClose:n,onImportAll:r,onImportSessions:i}){const s=M_e(),o=aM(m=>m.setText),a=aM(m=>m.resetForOpen);_.useEffect(()=>{e&&a()},[e,a]);const l=_.useMemo(()=>j_e(s),[s]),f=s.trim().length>0&&l.length===0,h=()=>{l.length===0||t||i(l)};return c.jsx(Ma,{open:e,onOpenChange:m=>{m||n()},children:c.jsxs(Xo,{size:"sm",children:[c.jsxs(fl,{className:"space-y-3",children:[c.jsx(Pa,{children:"Import Claude sessions"}),c.jsx(Ea,{value:s,onChange:m=>o(m.target.value),placeholder:"Paste one or more session ids (uuid, filename, or full path)…",rows:4}),f?c.jsx("p",{className:"text-xs text-destructive",children:"No valid session id found in the pasted text."}):null,c.jsx("p",{className:"text-xs text-muted-foreground",children:"Empty input imports ALL sessions (full scan). Active sessions import as a live view — sending a message there takes over the session."})]}),c.jsxs(Eu,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:n,disabled:t,children:"Cancel"}),c.jsx(Re,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:"Import all"}),c.jsxs(Re,{variant:"secondary",size:"sm",onClick:h,disabled:l.length===0||t,children:["Import ",l.length===1?"session":"sessions"]})]})]})})}function lM(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const I_e=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function HY(e){const t=e.trim();for(const n of I_e){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function a0(e){return e.split("/").pop()||e}const O_e=1440*6e4;function D_e(e,t){const n=Math.max(0,t-e),r=Math.floor(n/1e3),i=Math.floor(r/3600),s=Math.floor(r%3600/60),o=r%60;return i>0?`${i}h ${s}m`:s>0?`${s}m ${o}s`:`${o}s`}function WY(e){const t=new Date(e),n=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0");return`${n}:${r}`}function L_e(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=O_e,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function VY(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}const $_e=80;function F_e(e){return VY(e,$_e)}function B_e(e){return e.lastMessageAt??e._creationTime}const UD=1e3,PC=60*UD,Ag=60*PC,xA=24*Ag;function js(e){const t=Math.max(0,e);if(t<PC)return`${Math.floor(t/UD)}s`;if(t<Ag)return`${Math.floor(t/PC)}m`;if(t<xA){const i=Math.floor(t/Ag),s=Math.floor(t%Ag/PC);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/xA),r=Math.floor(t%xA/Ag);return r===0?`${n}d`:`${n}d ${r}h`}function Ep(e){const t=Math.max(0,e);if(t>=Ag)return js(t);const n=Math.floor(t/UD),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function fp(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function _6(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function zy(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function KY(e){switch(e){case"active":return"bg-emerald-500 dark:bg-emerald-400";case"attention":return"bg-amber-500 dark:bg-amber-400";case"destructive":return"bg-destructive";case"muted":default:return"bg-muted-foreground"}}function z_e(e){switch(e){case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed";case"killed":return"Killed";case"unknown":return"Unknown"}}function GY(e){switch(e){case"running":return"active";case"failed":return"destructive";case"killed":return"attention";case"completed":case"unknown":default:return"muted"}}function EE(e){return e.status==="running"||e.status==="starting"?{tone:"warning",label:fp(e.status)}:e.status==="waiting_for_user"?{tone:"info",label:fp(e.status)}:e.status==="failed"?{tone:"destructive",label:fp(e.status)}:e.unread?{tone:"success",label:"Unread"}:null}function NE(e){switch(e){case"warning":return"bg-warning";case"info":return"bg-info";case"success":return"bg-success";case"destructive":return"bg-destructive";default:return""}}function qY(e){switch(e){case"warning":return"text-warning";case"info":return"text-info";case"success":return"text-success";case"destructive":return"text-destructive";default:return"text-muted-foreground"}}function YY(e){switch(e){case"active":return{glyph:"●",toneClass:"text-success",title:"Claude PTY session active"};case"warming":return{glyph:"◐",toneClass:"text-warning",title:"Claude PTY session warming"};case"idle":return{glyph:"○",toneClass:"text-muted-foreground",title:"Claude PTY session idle"};case"cooling":return{glyph:"◌",toneClass:"text-muted-foreground",title:"Claude PTY session cooling down"};case"cold":default:return null}}function HD(e){const t=e+"CollectionProvider",[n,r]=Vu(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:y,children:w}=x,k=Dn.useRef(null),C=Dn.useRef(new Map).current;return c.jsx(i,{scope:y,itemMap:C,collectionRef:k,children:w})};o.displayName=t;const a=e+"CollectionSlot",l=wp(a),u=Dn.forwardRef((x,y)=>{const{scope:w,children:k}=x,C=s(a,w),E=zn(y,C.collectionRef);return c.jsx(l,{ref:E,children:k})});u.displayName=a;const f=e+"CollectionItemSlot",h="data-radix-collection-item",m=wp(f),g=Dn.forwardRef((x,y)=>{const{scope:w,children:k,...C}=x,E=Dn.useRef(null),N=zn(y,E),A=s(f,w);return Dn.useEffect(()=>(A.itemMap.set(E,{ref:E,...C}),()=>void A.itemMap.delete(E))),c.jsx(m,{[h]:"",ref:N,children:k})});g.displayName=f;function v(x){const y=s(e+"CollectionConsumer",x);return Dn.useCallback(()=>{const k=y.collectionRef.current;if(!k)return[];const C=Array.from(k.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((A,j)=>C.indexOf(A.ref.current)-C.indexOf(j.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:g},v,r]}var U_e=_.createContext(void 0);function WD(e){const t=_.useContext(U_e);return e||t||"ltr"}var yA="rovingFocusGroup.onEntryFocus",H_e={bubbles:!1,cancelable:!0},l0="RovingFocusGroup",[cM,XY,W_e]=HD(l0),[V_e,QY]=Vu(l0,[W_e]),[K_e,G_e]=V_e(l0),JY=_.forwardRef((e,t)=>c.jsx(cM.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(cM.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(q_e,{...e,ref:t})})}));JY.displayName=l0;var q_e=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=_.useRef(null),g=zn(t,m),v=WD(s),[x,y]=wv({prop:o,defaultProp:a??null,onChange:l,caller:l0}),[w,k]=_.useState(!1),C=dl(u),E=XY(n),N=_.useRef(!1),[A,j]=_.useState(0);return _.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(yA,C),()=>P.removeEventListener(yA,C)},[C]),c.jsx(K_e,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(P=>y(P),[y]),onItemShiftTab:_.useCallback(()=>k(!0),[]),onFocusableItemAdd:_.useCallback(()=>j(P=>P+1),[]),onFocusableItemRemove:_.useCallback(()=>j(P=>P-1),[]),children:c.jsx(wn.div,{tabIndex:w||A===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:at(e.onMouseDown,()=>{N.current=!0}),onFocus:at(e.onFocus,P=>{const M=!N.current;if(P.target===P.currentTarget&&M&&!w){const F=new CustomEvent(yA,H_e);if(P.currentTarget.dispatchEvent(F),!F.defaultPrevented){const W=E().filter(z=>z.focusable),D=W.find(z=>z.active),B=W.find(z=>z.id===x),V=[D,B,...W].filter(Boolean).map(z=>z.ref.current);tX(V,f)}}N.current=!1}),onBlur:at(e.onBlur,()=>k(!1))})})}),ZY="RovingFocusGroupItem",eX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=_u(),u=s||l,f=G_e(ZY,n),h=f.currentTabStopId===u,m=XY(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),c.jsx(cM.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:c.jsx(wn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:at(e.onMouseDown,y=>{r?f.onItemFocus(u):y.preventDefault()}),onFocus:at(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:at(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=Q_e(y,f.orientation,f.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const E=C.indexOf(y.currentTarget);C=f.loop?J_e(C,E+1):C.slice(E+1)}setTimeout(()=>tX(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});eX.displayName=ZY;var Y_e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function X_e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q_e(e,t,n){const r=X_e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Y_e[r]}function tX(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function J_e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Z_e=JY,e0e=eX,uM=["Enter"," "],t0e=["ArrowDown","PageUp","Home"],nX=["ArrowUp","PageDown","End"],n0e=[...t0e,...nX],r0e={ltr:[...uM,"ArrowRight"],rtl:[...uM,"ArrowLeft"]},i0e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},c0="Menu",[Uy,s0e,o0e]=HD(c0),[Jp,rX]=Vu(c0,[o0e,$f,QY]),TE=$f(),iX=QY(),[a0e,Zp]=Jp(c0),[l0e,u0]=Jp(c0),sX=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=TE(t),[l,u]=_.useState(null),f=_.useRef(!1),h=dl(s),m=WD(i);return _.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(xE,{...a,children:c.jsx(a0e,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:u,children:c.jsx(l0e,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};sX.displayName=c0;var c0e="MenuAnchor",VD=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=TE(n);return c.jsx(i0,{...i,...r,ref:t})});VD.displayName=c0e;var KD="MenuPortal",[u0e,oX]=Jp(KD,{forceMount:void 0}),aX=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Zp(KD,t);return c.jsx(u0e,{scope:t,forceMount:n,children:c.jsx(za,{present:n||s.open,children:c.jsx(nb,{asChild:!0,container:i,children:r})})})};aX.displayName=KD;var Na="MenuContent",[d0e,GD]=Jp(Na),lX=_.forwardRef((e,t)=>{const n=oX(Na,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Zp(Na,e.__scopeMenu),o=u0(Na,e.__scopeMenu);return c.jsx(Uy.Provider,{scope:e.__scopeMenu,children:c.jsx(za,{present:r||s.open,children:c.jsx(Uy.Slot,{scope:e.__scopeMenu,children:o.modal?c.jsx(f0e,{...i,ref:t}):c.jsx(h0e,{...i,ref:t})})})})}),f0e=_.forwardRef((e,t)=>{const n=Zp(Na,e.__scopeMenu),r=_.useRef(null),i=zn(t,r);return _.useEffect(()=>{const s=r.current;if(s)return hE(s)},[]),c.jsx(qD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:at(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),h0e=_.forwardRef((e,t)=>{const n=Zp(Na,e.__scopeMenu);return c.jsx(qD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),p0e=wp("MenuContent.ScrollLock"),qD=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...x}=e,y=Zp(Na,n),w=u0(Na,n),k=TE(n),C=iX(n),E=s0e(n),[N,A]=_.useState(null),j=_.useRef(null),P=zn(t,j,y.onContentChange),M=_.useRef(0),F=_.useRef(""),W=_.useRef(0),D=_.useRef(null),B=_.useRef("right"),I=_.useRef(0),V=v?t0:_.Fragment,z=v?{as:p0e,allowPinchZoom:!0}:void 0,U=$=>{var ae,_e;const q=F.current+$,O=E().filter(te=>!te.disabled),J=document.activeElement,ne=(ae=O.find(te=>te.ref.current===J))==null?void 0:ae.textValue,oe=O.map(te=>te.textValue),he=E0e(oe,q,ne),ce=(_e=O.find(te=>te.textValue===he))==null?void 0:_e.ref.current;(function te(ue){F.current=ue,window.clearTimeout(M.current),ue!==""&&(M.current=window.setTimeout(()=>te(""),1e3))})(q),ce&&setTimeout(()=>ce.focus())};_.useEffect(()=>()=>window.clearTimeout(M.current),[]),dE();const H=_.useCallback($=>{var O,J;return B.current===((O=D.current)==null?void 0:O.side)&&T0e($,(J=D.current)==null?void 0:J.area)},[]);return c.jsx(d0e,{scope:n,searchRef:F,onItemEnter:_.useCallback($=>{H($)&&$.preventDefault()},[H]),onItemLeave:_.useCallback($=>{var q;H($)||((q=j.current)==null||q.focus(),A(null))},[H]),onTriggerLeave:_.useCallback($=>{H($)&&$.preventDefault()},[H]),pointerGraceTimerRef:W,onPointerGraceIntentChange:_.useCallback($=>{D.current=$},[]),children:c.jsx(V,{...z,children:c.jsx(e0,{asChild:!0,trapped:i,onMountAutoFocus:at(s,$=>{var q;$.preventDefault(),(q=j.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:c.jsx(tb,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:c.jsx(Z_e,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:A,onEntryFocus:at(l,$=>{w.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(yE,{role:"menu","aria-orientation":"vertical","data-state":CX(y.open),"data-radix-menu-content":"",dir:w.dir,...k,...x,ref:P,style:{outline:"none",...x.style},onKeyDown:at(x.onKeyDown,$=>{const O=$.target.closest("[data-radix-menu-content]")===$.currentTarget,J=$.ctrlKey||$.altKey||$.metaKey,ne=$.key.length===1;O&&($.key==="Tab"&&$.preventDefault(),!J&&ne&&U($.key));const oe=j.current;if($.target!==oe||!n0e.includes($.key))return;$.preventDefault();const ce=E().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);nX.includes($.key)&&ce.reverse(),C0e(ce)}),onBlur:at(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(M.current),F.current="")}),onPointerMove:at(e.onPointerMove,Hy($=>{const q=$.target,O=I.current!==$.clientX;if($.currentTarget.contains(q)&&O){const J=$.clientX>I.current?"right":"left";B.current=J,I.current=$.clientX}}))})})})})})})});lX.displayName=Na;var m0e="MenuGroup",YD=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"group",...r,ref:t})});YD.displayName=m0e;var g0e="MenuLabel",cX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{...r,ref:t})});cX.displayName=g0e;var D1="MenuItem",S6="menu.itemSelect",AE=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=u0(D1,e.__scopeMenu),a=GD(D1,e.__scopeMenu),l=zn(t,s),u=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(S6,{bubbles:!0,cancelable:!0});h.addEventListener(S6,g=>r==null?void 0:r(g),{once:!0}),yq(h,m),m.defaultPrevented?u.current=!1:o.onClose()}};return c.jsx(uX,{...i,ref:l,disabled:n,onClick:at(e.onClick,f),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:at(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:at(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||uM.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});AE.displayName=D1;var uX=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=GD(D1,n),a=iX(n),l=_.useRef(null),u=zn(t,l),[f,h]=_.useState(!1),[m,g]=_.useState("");return _.useEffect(()=>{const v=l.current;v&&g((v.textContent??"").trim())},[s.children]),c.jsx(Uy.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:c.jsx(e0e,{asChild:!0,...a,focusable:!r,children:c.jsx(wn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:at(e.onPointerMove,Hy(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:at(e.onPointerLeave,Hy(v=>o.onItemLeave(v))),onFocus:at(e.onFocus,()=>h(!0)),onBlur:at(e.onBlur,()=>h(!1))})})})}),v0e="MenuCheckboxItem",dX=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return c.jsx(gX,{scope:e.__scopeMenu,checked:n,children:c.jsx(AE,{role:"menuitemcheckbox","aria-checked":L1(n)?"mixed":n,...i,ref:t,"data-state":QD(n),onSelect:at(i.onSelect,()=>r==null?void 0:r(L1(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dX.displayName=v0e;var fX="MenuRadioGroup",[b0e,x0e]=Jp(fX,{value:void 0,onValueChange:()=>{}}),hX=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=dl(r);return c.jsx(b0e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(YD,{...i,ref:t})})});hX.displayName=fX;var pX="MenuRadioItem",mX=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=x0e(pX,e.__scopeMenu),s=n===i.value;return c.jsx(gX,{scope:e.__scopeMenu,checked:s,children:c.jsx(AE,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":QD(s),onSelect:at(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});mX.displayName=pX;var XD="MenuItemIndicator",[gX,y0e]=Jp(XD,{checked:!1}),vX=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=y0e(XD,n);return c.jsx(za,{present:r||L1(s.checked)||s.checked===!0,children:c.jsx(wn.span,{...i,ref:t,"data-state":QD(s.checked)})})});vX.displayName=XD;var _0e="MenuSeparator",bX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});bX.displayName=_0e;var S0e="MenuArrow",xX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=TE(n);return c.jsx(_E,{...i,...r,ref:t})});xX.displayName=S0e;var w0e="MenuSub",[LZe,yX]=Jp(w0e),Ux="MenuSubTrigger",_X=_.forwardRef((e,t)=>{const n=Zp(Ux,e.__scopeMenu),r=u0(Ux,e.__scopeMenu),i=yX(Ux,e.__scopeMenu),s=GD(Ux,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),c.jsx(VD,{asChild:!0,...u,children:c.jsx(uX,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":CX(n.open),...e,ref:yD(t,i.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:at(e.onPointerMove,Hy(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:at(e.onPointerLeave,Hy(h=>{var g,v;f();const m=(g=n.content)==null?void 0:g.getBoundingClientRect();if(m){const x=(v=n.content)==null?void 0:v.dataset.side,y=x==="right",w=y?-5:5,k=m[y?"left":"right"],C=m[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:k,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:k,y:m.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:at(e.onKeyDown,h=>{var g;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||r0e[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});_X.displayName=Ux;var SX="MenuSubContent",wX=_.forwardRef((e,t)=>{const n=oX(Na,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Zp(Na,e.__scopeMenu),o=u0(Na,e.__scopeMenu),a=yX(SX,e.__scopeMenu),l=_.useRef(null),u=zn(t,l);return c.jsx(Uy.Provider,{scope:e.__scopeMenu,children:c.jsx(za,{present:r||s.open,children:c.jsx(Uy.Slot,{scope:e.__scopeMenu,children:c.jsx(qD,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:at(e.onFocusOutside,f=>{f.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:at(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:at(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),m=i0e[o.dir].includes(f.key);h&&m&&(s.onOpenChange(!1),(g=a.trigger)==null||g.focus(),f.preventDefault())})})})})})});wX.displayName=SX;function CX(e){return e?"open":"closed"}function L1(e){return e==="indeterminate"}function QD(e){return L1(e)?"indeterminate":e?"checked":"unchecked"}function C0e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function k0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function E0e(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=k0e(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function N0e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,f=a.y,h=l.x,m=l.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(i=!i)}return i}function T0e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return N0e(n,t)}function Hy(e){return t=>t.pointerType==="mouse"?e(t):void 0}var A0e=sX,R0e=VD,j0e=aX,M0e=lX,P0e=YD,I0e=cX,O0e=AE,D0e=dX,L0e=hX,$0e=mX,F0e=vX,B0e=bX,z0e=xX,U0e=_X,H0e=wX,JD="ContextMenu",[W0e]=Vu(JD,[rX]),to=rX(),[V0e,kX]=W0e(JD),EX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,a]=_.useState(!1),l=to(t),u=dl(r),f=_.useCallback(h=>{a(h),u(h)},[u]);return c.jsx(V0e,{scope:t,open:o,onOpenChange:f,modal:s,children:c.jsx(A0e,{...l,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};EX.displayName=JD;var NX="ContextMenuTrigger",TX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=kX(NX,n),o=to(n),a=_.useRef({x:0,y:0}),l=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),h=m=>{a.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(R0e,{...o,virtualRef:l}),c.jsx(wn.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:at(e.onContextMenu,m=>{f(),h(m),m.preventDefault()}),onPointerDown:r?e.onPointerDown:at(e.onPointerDown,dw(m=>{f(),u.current=window.setTimeout(()=>h(m),700)})),onPointerMove:r?e.onPointerMove:at(e.onPointerMove,dw(f)),onPointerCancel:r?e.onPointerCancel:at(e.onPointerCancel,dw(f)),onPointerUp:r?e.onPointerUp:at(e.onPointerUp,dw(f))})]})});TX.displayName=NX;var K0e="ContextMenuPortal",AX=e=>{const{__scopeContextMenu:t,...n}=e,r=to(t);return c.jsx(j0e,{...r,...n})};AX.displayName=K0e;var RX="ContextMenuContent",jX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=kX(RX,n),s=to(n),o=_.useRef(!1);return c.jsx(M0e,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,a),!a.defaultPrevented&&o.current&&a.preventDefault(),o.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)==null||l.call(e,a),!a.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});jX.displayName=RX;var G0e="ContextMenuGroup",q0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(P0e,{...i,...r,ref:t})});q0e.displayName=G0e;var Y0e="ContextMenuLabel",X0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(I0e,{...i,...r,ref:t})});X0e.displayName=Y0e;var Q0e="ContextMenuItem",MX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(O0e,{...i,...r,ref:t})});MX.displayName=Q0e;var J0e="ContextMenuCheckboxItem",Z0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(D0e,{...i,...r,ref:t})});Z0e.displayName=J0e;var eSe="ContextMenuRadioGroup",tSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(L0e,{...i,...r,ref:t})});tSe.displayName=eSe;var nSe="ContextMenuRadioItem",rSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx($0e,{...i,...r,ref:t})});rSe.displayName=nSe;var iSe="ContextMenuItemIndicator",sSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(F0e,{...i,...r,ref:t})});sSe.displayName=iSe;var oSe="ContextMenuSeparator",PX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(B0e,{...i,...r,ref:t})});PX.displayName=oSe;var aSe="ContextMenuArrow",lSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(z0e,{...i,...r,ref:t})});lSe.displayName=aSe;var cSe="ContextMenuSubTrigger",uSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(U0e,{...i,...r,ref:t})});uSe.displayName=cSe;var dSe="ContextMenuSubContent",fSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(H0e,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fSe.displayName=dSe;function dw(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var hSe=EX,pSe=TX,mSe=AX,IX=jX,OX=MX,DX=PX;const LX=_.createContext(null);function em({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return c.jsx(LX.Provider,{value:i,children:c.jsx(hSe,{onOpenChange:e,...t},n)})}const tm=pSe,Ff=_.forwardRef(({className:e,...t},n)=>c.jsx(mSe,{children:c.jsx(IX,{ref:n,className:le("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));Ff.displayName=IX.displayName;const fr=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(LX);return c.jsx(OX,{ref:r,className:le("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});fr.displayName=OX.displayName;const ZD=_.forwardRef(({className:e,...t},n)=>c.jsx(DX,{ref:n,className:le("-mx-1 my-1 h-px bg-border",e),...t}));ZD.displayName=DX.displayName;var RE="Popover",[$X]=Vu(RE,[$f]),d0=$f(),[gSe,Bf]=$X(RE),FX=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,a=d0(t),l=_.useRef(null),[u,f]=_.useState(!1),[h,m]=wv({prop:r,defaultProp:i??!1,onChange:s,caller:RE});return c.jsx(xE,{...a,children:c.jsx(gSe,{scope:t,contentId:_u(),triggerRef:l,open:h,onOpenChange:m,onOpenToggle:_.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:o,children:n})})};FX.displayName=RE;var BX="PopoverAnchor",vSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(BX,n),s=d0(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=i;return _.useEffect(()=>(o(),()=>a()),[o,a]),c.jsx(i0,{...s,...r,ref:t})});vSe.displayName=BX;var zX="PopoverTrigger",UX=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(zX,n),s=d0(n),o=zn(t,i.triggerRef),a=c.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":GX(i.open),...r,ref:o,onClick:at(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:c.jsx(i0,{asChild:!0,...s,children:a})});UX.displayName=zX;var eL="PopoverPortal",[bSe,xSe]=$X(eL,{forceMount:void 0}),HX=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Bf(eL,t);return c.jsx(bSe,{scope:t,forceMount:n,children:c.jsx(za,{present:n||s.open,children:c.jsx(nb,{asChild:!0,container:i,children:r})})})};HX.displayName=eL;var Ev="PopoverContent",WX=_.forwardRef((e,t)=>{const n=xSe(Ev,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Bf(Ev,e.__scopePopover);return c.jsx(za,{present:r||s.open,children:s.modal?c.jsx(_Se,{...i,ref:t}):c.jsx(SSe,{...i,ref:t})})});WX.displayName=Ev;var ySe=wp("PopoverContent.RemoveScroll"),_Se=_.forwardRef((e,t)=>{const n=Bf(Ev,e.__scopePopover),r=_.useRef(null),i=zn(t,r),s=_.useRef(!1);return _.useEffect(()=>{const o=r.current;if(o)return hE(o)},[]),c.jsx(t0,{as:ySe,allowPinchZoom:!0,children:c.jsx(VX,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:at(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:at(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),SSe=_.forwardRef((e,t)=>{const n=Bf(Ev,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return c.jsx(VX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),VX=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...h}=e,m=Bf(Ev,n),g=d0(n);return dE(),c.jsx(e0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:c.jsx(tb,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:c.jsx(yE,{"data-state":GX(m.open),role:"dialog",id:m.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),KX="PopoverClose",wSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(KX,n);return c.jsx(wn.button,{type:"button",...r,ref:t,onClick:at(e.onClick,()=>i.onOpenChange(!1))})});wSe.displayName=KX;var CSe="PopoverArrow",kSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=d0(n);return c.jsx(_E,{...i,...r,ref:t})});kSe.displayName=CSe;function GX(e){return e?"open":"closed"}var ESe=FX,NSe=UX,TSe=HX,qX=WX;const bc=ESe,xc=NSe,_l=_.forwardRef(({className:e,align:t="center",sideOffset:n=4,ports:r={},...i},s)=>{const o=r.dom??Nt;return c.jsx(TSe,{children:c.jsx(qX,{ref:s,align:t,sideOffset:n,[A1]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),o.dispatchCustomWindowEvent(ED),(l=i.onCloseAutoFocus)==null||l.call(i,a)},className:le("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",e),...i})})});_l.displayName=qX.displayName;const dM=Jt("StackActionsPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function ASe({editorLabel:e,onOpenBoards:t,starred:n,onCopyPath:r,onShowArchived:i,onOpenInFinder:s,onOpenInEditor:o,onToggleStar:a,onHide:l,children:u}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:u}),c.jsxs(Ff,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),t()},children:[c.jsx(JG,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(ZD,{})]}):null,c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),a()},children:[n?c.jsx(yge,{className:"h-3.5 w-3.5"}):c.jsx(eq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:n?"Unstar project":"Star project"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),r()},children:[c.jsx(ja,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),i()},children:[c.jsx(aD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),s()},children:[c.jsx(aE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),o()},children:[c.jsx(cD,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),l()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[c.jsx(spe,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function RSe({canFork:e,onRename:t,onOpenInFinder:n,onFork:r,onArchive:i,onDelete:s,onEditPermissions:o,children:a}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:a}),c.jsxs(Ff,{children:[c.jsxs(fr,{onSelect:l=>{l.preventDefault(),t()},children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(fr,{onSelect:l=>{l.preventDefault(),n()},children:[c.jsx(aE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),c.jsxs(fr,{disabled:!e,onSelect:l=>{l.preventDefault(),e&&r()},children:[c.jsx(QG,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),o?c.jsxs(fr,{onSelect:l=>{l.preventDefault(),o()},children:[c.jsx(mD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Permissions…"})]}):null,c.jsxs(fr,{onSelect:l=>{l.preventDefault(),i()},children:[c.jsx(aD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),c.jsxs(fr,{onSelect:l=>{l.preventDefault(),s()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}function jSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){const s=dM.useScopedStore(l=>l.open),o=dM.useScopedStore(l=>l.setOpen);function a(l){return()=>{o(!1),l()}}return c.jsxs(bc,{open:s,onOpenChange:o,children:[c.jsx(xc,{asChild:!0,children:i}),c.jsxs(_l,{align:"end",sideOffset:4,className:"w-44 p-1",role:"menu","aria-label":`Actions for ${e}`,children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:a(t),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Rename"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:a(n),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(nq,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Edit members"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:a(r),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium text-destructive dark:text-red-400 hover:bg-destructive/10 focus-visible:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus-visible:bg-red-500/20 outline-hidden",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsxs("span",{children:["Delete ",e]})]})]})]})}function MSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){return c.jsx(dM.Provider,{init:{},children:c.jsx(jSe,{stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i})})}function PSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:i}),c.jsxs(Ff,{children:[c.jsxs(fr,{onSelect:s=>{s.preventDefault(),t()},children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(fr,{onSelect:s=>{s.preventDefault(),n()},children:[c.jsx(nq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Edit members"})]}),c.jsxs(fr,{onSelect:s=>{s.preventDefault(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Delete ",e]})]})]})]})}function ISe({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onOpenInFinder:a,onForkChat:l,onArchiveChat:u,onDeleteChat:f,onEditPermissions:h}){var A;const m=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,g=m&&e.stateEnteredAt!=null?`${fp(e.status)} ${Ep(n-e.stateEnteredAt)}`:js(n-(e.lastMessageAt??e._creationTime)),v=i&&r?r:g,x=i&&!!r,y=Pve(e.chatId),w=t===y,k=((A=EE(e))==null?void 0:A.tone)??null;let C;e.canFork?C="w-12":m?C="w-12 md:w-20":C="w-6 md:w-14";let E=null;v&&(x?E=c.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity duration-150 group-hover:opacity-0",children:c.jsx(OY,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):E=c.jsx("span",{className:le("hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] tabular-nums transition-opacity duration-150 group-hover:opacity-0 whitespace-nowrap",m?qY(k):"text-muted-foreground"),children:v}));const N=c.jsxs("div",{"data-chat-id":y,className:le("group flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-md cursor-pointer transition-colors duration-150",w?"bg-muted":"hover:bg-muted/40"),onClick:()=>s(e.chatId),children:[c.jsx("span",{className:"relative flex h-3.5 w-3.5 shrink-0 items-center justify-center","aria-hidden":!0,children:k?c.jsx("span",{className:le("h-2 w-2 rounded-full",NE(k))}):null}),(()=>{const j=YY(e.sessionState);return j?c.jsx(Qo,{label:j.title,children:c.jsx("span",{className:le("shrink-0 text-[10px] leading-none",j.toneClass),"aria-label":j.title,children:j.glyph})}):null})(),e.hasPolicyOverride?c.jsx(mD,{className:"size-3 shrink-0 text-warning","aria-label":"Per-chat permission override active"}):null,c.jsx("span",{className:le("truncate flex-1 text-sm",w?"text-foreground font-medium":"text-foreground/90",e.status==="idle"&&!e.unread&&!w?"text-muted-foreground":""),children:e.title}),c.jsxs("div",{className:le("relative h-6 shrink-0",C),children:[E,c.jsxs("div",{className:le("absolute inset-0 flex items-center justify-end gap-0 transition-opacity duration-150",v?"opacity-100 md:opacity-0 md:group-hover:opacity-100":"opacity-100"),children:[e.canFork?c.jsx(Re,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:j=>{j.stopPropagation(),l(e.chatId)},title:"Fork chat",children:c.jsx(QG,{className:"size-3.5"})}):null,c.jsx(Re,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:j=>{j.stopPropagation(),u(e.chatId)},title:"Archive chat",children:c.jsx(aD,{className:"size-3.5"})})]})]})]},e._id);return c.jsx(RSe,{canFork:e.canFork,onRename:()=>o(e.chatId),onOpenInFinder:()=>a(e.localPath),onFork:()=>l(e.chatId),onArchive:()=>u(e.chatId),onDelete:()=>f(e.chatId),onEditPermissions:h?()=>h(e.chatId):void 0,children:N})}const OSe=_.memo(ISe);function DSe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const jE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sb(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function tL(e){return"nodeType"in e}function Eo(e){var t,n;return e?sb(e)?e:tL(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function nL(e){const{Document:t}=Eo(e);return e instanceof t}function f0(e){return sb(e)?!1:e instanceof Eo(e).HTMLElement}function YX(e){return e instanceof Eo(e).SVGElement}function ob(e){return e?sb(e)?e.document:tL(e)?nL(e)?e:f0(e)||YX(e)?e.ownerDocument:document:document:document}const cc=jE?_.useLayoutEffect:_.useEffect;function rL(e){const t=_.useRef(e);return cc(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function LSe(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Wy(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return cc(()=>{n.current!==e&&(n.current=e)},t),n}function h0(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function $1(e){const t=rL(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function fM(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let _A={};function p0(e,t){return _.useMemo(()=>{if(t)return t;const n=_A[e]==null?0:_A[e]+1;return _A[e]=n,e+"-"+n},[e,t])}function XX(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const a=Object.entries(o);for(const[l,u]of a){const f=s[l];f!=null&&(s[l]=f+e*u)}return s},{...t})}}const Wg=XX(1),F1=XX(-1);function $Se(e){return"clientX"in e&&"clientY"in e}function iL(e){if(!e)return!1;const{KeyboardEvent:t}=Eo(e.target);return t&&e instanceof t}function FSe(e){if(!e)return!1;const{TouchEvent:t}=Eo(e.target);return t&&e instanceof t}function hM(e){if(FSe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return $Se(e)?{x:e.clientX,y:e.clientY}:null}const Vy=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Vy.Translate.toString(e),Vy.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),w6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function BSe(e){return e.matches(w6)?e:e.querySelector(w6)}const zSe={display:"none"};function USe(e){let{id:t,value:n}=e;return Dn.createElement("div",{id:t,style:zSe},n)}function HSe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Dn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function WSe(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const QX=_.createContext(null);function VSe(e){const t=_.useContext(QX);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function KSe(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var a;return(a=o[i])==null?void 0:a.call(o,s)})},[e]),t]}const GSe={draggable:`
821
+ `)&&(w.writePathDeny=y),Object.keys(w).length===0?null:w}function g(){r(m())}function v(){r(null)}return c.jsxs(c.Fragment,{children:[c.jsx(Ma,{open:e,onOpenChange:x=>{x||i()},children:c.jsxs(Xo,{className:"max-w-2xl",children:[c.jsxs(Pa,{children:["Permissions — ",t]}),c.jsxs(fl,{className:"space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Default action"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Behaviour when a tool call has no explicit allow/deny rule. ",c.jsx("strong",{children:"auto-allow"})," bypasses prompts and runs untrusted shell commands without supervision — use a worktree."]}),c.jsx(ms,{value:s,onValueChange:h,options:[{value:"ask",label:"Ask"},{value:"auto-allow",label:"Auto-allow (unsafe)"},{value:"auto-deny",label:"Auto-deny"}]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Read-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot read paths matching any entry. Defaults shown below — edit to add or remove."}),c.jsx("textarea",{value:o,onChange:x=>f.getState().setReadDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Write-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot edit or write paths matching any entry."}),c.jsx("textarea",{value:a,onChange:x=>f.getState().setWriteDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]})]}),c.jsxs(Eu,{className:"justify-between",children:[c.jsx(Re,{variant:"ghost",onClick:v,children:"Reset to defaults"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Re,{variant:"ghost",onClick:i,children:"Cancel"}),c.jsx(Re,{onClick:g,children:"Apply"})]})]})]})}),c.jsx(Ma,{open:l,onOpenChange:x=>{x||(f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null))},children:c.jsxs(Xo,{className:"max-w-md",children:[c.jsx(Pa,{children:"Enable auto-allow for this chat?"}),c.jsxs(fl,{className:"space-y-3 text-sm",children:[c.jsx("p",{children:"Auto-allow disables tool-call prompts. The model can run shell commands, write files, and edit code without asking. Read/write deny lists still apply."}),c.jsx("p",{className:"text-warning",children:"Use a worktree for risky tasks."})]}),c.jsxs(Eu,{className:"justify-end gap-2",children:[c.jsx(Re,{variant:"ghost",onClick:()=>{f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null)},children:"Cancel"}),c.jsx(Re,{variant:"destructive",onClick:()=>{const x=f.getState();u&&x.setDefaultAction(u),x.setConfirmUnsafeOpen(!1),x.setPendingDefaultAction(null)},children:"Enable auto-allow"})]})]})})]})}const Zye={defaultAction:"ask",bash:{autoAllowVerbs:["ls","pwd","git status","git diff","git log"]},readPathDeny:["~/.ssh","~/.aws","~/.gcp","~/.config/gh","~/.claude","~/.kanna","~/Library/Keychains","/etc/shadow","/etc/sudoers","~/.gnupg","~/.gitconfig","**/.git/config","~/.npmrc","~/.netrc","~/.docker/config.json","**/.env","**/.env.*","**/credentials*","**/*.pem","**/*.key","**/id_rsa*","**/id_ed25519*"],writePathDeny:["/etc/**","/usr/**","/System/**","~/.ssh/**","~/.aws/**","~/.config/gh/**","~/.claude/**","~/.kanna/**","~/.gnupg/**","~/.gitconfig","**/.git/config"],toolDenyList:[{tool:"mcp__kanna__bash",pattern:"rm\\s+-rf\\s+(/|~|\\$HOME)(?:\\b|$|\\s)"},{tool:"mcp__kanna__bash",pattern:"git\\s+push\\b.*--force"}],toolAllowList:[]},ar={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},setInterval(e,t){return window.setInterval(e,t)},clearInterval(e){window.clearInterval(e)},requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)}},Lt=_.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{ref:r,type:t,className:le("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));Lt.displayName="Input";const LY=_.createContext(null);function e_e({children:e,ports:t={}}){const n=t.timer??ar,[r,i]=_.useState(null),[s,o]=_.useState(""),a=_.useRef(null);_.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),n.setTimeout(()=>{var y,w;(y=a.current)==null||y.focus(),(w=a.current)==null||w.select()},0))},[r,n]);const l=_.useCallback(()=>{i(null),o("")},[]),u=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!1):r.kind==="prompt"?r.resolve(null):r.resolve(),l())},[l,r]),f=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!0):r.kind==="prompt"?r.resolve(s.trim()||null):r.resolve(),l())},[l,r,s]),h=_.useCallback(y=>new Promise(w=>{i({kind:"confirm",options:y,resolve:w})}),[]),m=_.useCallback(y=>new Promise(w=>{i({kind:"prompt",options:y,resolve:w})}),[]),g=_.useCallback(y=>new Promise(w=>{i({kind:"alert",options:y,resolve:w})}),[]),v=_.useMemo(()=>({confirm:h,prompt:m,alert:g}),[g,h,m]);let x="Confirm";return r&&(r.kind==="alert"?x=r.options.closeLabel??"OK":"confirmLabel"in r.options&&(x=r.options.confirmLabel??"Confirm")),c.jsxs(LY.Provider,{value:v,children:[e,c.jsx(Ma,{open:r!==null,onOpenChange:y=>{y||!r||u()},children:c.jsx(Xo,{size:"sm",onKeyDown:y=>{y.key!=="Enter"||y.shiftKey||!r||r.kind!=="confirm"||(y.preventDefault(),f())},children:r?c.jsxs(c.Fragment,{children:[c.jsxs(fl,{className:"space-y-4",children:[c.jsx(Pa,{children:r.options.title}),r.options.description?c.jsx(n0,{children:r.options.description}):null,r.kind==="prompt"?c.jsx(Lt,{ref:a,type:"text",value:s,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),f())},placeholder:r.options.placeholder}):null]}),c.jsxs(Eu,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:u,className:r.kind==="alert"?"hidden":void 0,children:"cancelLabel"in r.options?r.options.cancelLabel??"Cancel":"Cancel"}),c.jsx(Re,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:f,disabled:r.kind==="prompt"&&!s.trim(),children:x})]})]}):null})})]})}function CE(){const e=_.useContext(LY);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const $D=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("bg-card text-card-foreground",e),...t}));$D.displayName="Card";const FD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("flex flex-col space-y-1.5 p-2",e),...t}));FD.displayName="CardHeader";const $Y=_.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:le("text-2xl font-semibold leading-none tracking-tight",e),...t}));$Y.displayName="CardTitle";const FY=_.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:le("text-sm text-muted-foreground",e),...t}));FY.displayName="CardDescription";const BD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("p-6 pt-0",e),...t}));BD.displayName="CardContent";const t_e=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:le("flex items-center p-6 pt-0",e),...t}));t_e.displayName="CardFooter";const n_e={info:{dotVar:"var(--info)",bgClass:"bg-info/[0.06]"},warning:{dotVar:"var(--warning)",bgClass:"bg-warning/[0.06]"},success:{dotVar:"var(--success)",bgClass:"bg-success/[0.06]"},error:{dotVar:"var(--destructive)",bgClass:"bg-destructive/[0.06]"}};function r_e({variant:e,children:t,dot:n=!0,className:r}){const i=n_e[e];return c.jsxs("div",{role:"status",className:le("flex flex-wrap items-center justify-center gap-x-2 gap-y-1 border-b border-border px-4 py-2 text-xs leading-tight",i.bgClass,r),children:[n?c.jsx("span",{"aria-hidden":"true",className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:i.dotVar}}):null,t]})}const i_e="modulepreload",s_e=function(e){return"/"+e},b6={},Z=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(u=>{if(u=s_e(u),u in b6)return;b6[u]=!0;const f=u.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":i_e,f||(m.as="script"),m.crossOrigin="",m.href=u,l&&m.setAttribute("nonce",l),document.head.appendChild(m),f)return new Promise((g,v)=>{m.addEventListener("load",g),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},o_e=_.lazy(()=>Z(()=>import("./index-CucTDMIL.js"),[]).then(e=>({default:e.Toaster})));function a_e(){return c.jsx(_.Suspense,{fallback:null,children:c.jsx(o_e,{position:"bottom-right",theme:"system",closeButton:!0,duration:6e3})})}const l_e="1.26.3",c_e={version:l_e},Hr="Kanna",x6="kanna",u_e=".kanna",d_e=".kanna-dev",f_e="KANNA_RUNTIME_PROFILE",zD=`kanna/${c_e.version}`,h_e="[kanna]",p_e=`~/${Hr}`;function kE(){const e=Reflect.get(globalThis,"process");return e==null?void 0:e.env}function m_e(e=kE()){var t;return((t=e==null?void 0:e[f_e])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function g_e(e=kE()){return m_e(e)==="dev"?d_e:u_e}function v_e(e=kE()){return`~/${g_e(e)}`}function b_e(e=kE()){return`${v_e(e)}/keybindings.json`}function uw(e){return e?`${x6} ${e}`:x6}const BY="always",zY="funk",x_e=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function y_e(e){switch(e){case"never":case"unfocused":case"always":return e;default:return BY}}function __e(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return zY}}const Vh=Qt()(e=>({chatSoundPreference:BY,chatSoundId:zY,setChatSoundPreference:t=>e({chatSoundPreference:y_e(t)}),setChatSoundId:t=>e({chatSoundId:__e(t)})})),S_e={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function w_e(e=Nt){return e.getVisibilityState()!=="visible"||!e.hasFocus()}function C_e(e){const t=new Audio(S_e[e]);return t.preload="auto",t.play()}async function oM(e,t,n=ar){if(t<=0)return;const r=Array.from({length:t},(i,s)=>new Promise(o=>{n.setTimeout(()=>{C_e(e).catch(()=>{}).finally(()=>o())},s*90)}));await Promise.all(r)}function k_e(e,t=Nt){return e==="never"?!1:e==="always"?!0:w_e(t)}function E_e(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function y6(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function N_e(e,t){if(!e)return 0;const n=y6(e),r=y6(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const UY="h-[var(--shell-top-band)] max-h-[var(--shell-top-band)]",T_e="md:my-2 md:mr-2 md:rounded-2xl md:border md:border-border";function Oh({tooltip:e,children:t,className:n,inline:r=!1,side:i}){const s=le("truncate",n);return c.jsx(o0,{children:c.jsxs(Ni,{children:[c.jsx(Ti,{asChild:!0,children:r?c.jsx("span",{className:s,children:t}):c.jsx("div",{className:s,children:t})}),c.jsx(fi,{side:i,children:e})]})})}function Qo({label:e,children:t,side:n}){return c.jsx(o0,{children:c.jsxs(Ni,{children:[c.jsx(Ti,{asChild:!0,children:t}),c.jsx(fi,{side:n,children:e})]})})}const A_e=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;function R_e(e){const t=e.match(A_e);return!t||t.length===0?null:t[t.length-1].toLowerCase()}function j_e(e){const t=[];for(const n of e.split(/[\s,]+/)){if(!n)continue;const r=R_e(n);r&&!t.includes(r)&&t.push(r)}return t}const aM=Qt()(e=>({text:"",setText:t=>e({text:t}),resetForOpen:()=>e({text:""})})),M_e=()=>aM(e=>e.text),Ea=_.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:le("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ea.displayName="Textarea";function P_e({open:e,busy:t,onClose:n,onImportAll:r,onImportSessions:i}){const s=M_e(),o=aM(m=>m.setText),a=aM(m=>m.resetForOpen);_.useEffect(()=>{e&&a()},[e,a]);const l=_.useMemo(()=>j_e(s),[s]),f=s.trim().length>0&&l.length===0,h=()=>{l.length===0||t||i(l)};return c.jsx(Ma,{open:e,onOpenChange:m=>{m||n()},children:c.jsxs(Xo,{size:"sm",children:[c.jsxs(fl,{className:"space-y-3",children:[c.jsx(Pa,{children:"Import Claude sessions"}),c.jsx(Ea,{value:s,onChange:m=>o(m.target.value),placeholder:"Paste one or more session ids (uuid, filename, or full path)…",rows:4}),f?c.jsx("p",{className:"text-xs text-destructive",children:"No valid session id found in the pasted text."}):null,c.jsx("p",{className:"text-xs text-muted-foreground",children:"Empty input imports ALL sessions (full scan). Active sessions import as a live view — sending a message there takes over the session."})]}),c.jsxs(Eu,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:n,disabled:t,children:"Cancel"}),c.jsx(Re,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:"Import all"}),c.jsxs(Re,{variant:"secondary",size:"sm",onClick:h,disabled:l.length===0||t,children:["Import ",l.length===1?"session":"sessions"]})]})]})})}function lM(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const I_e=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function HY(e){const t=e.trim();for(const n of I_e){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function a0(e){return e.split("/").pop()||e}const O_e=1440*6e4;function D_e(e,t){const n=Math.max(0,t-e),r=Math.floor(n/1e3),i=Math.floor(r/3600),s=Math.floor(r%3600/60),o=r%60;return i>0?`${i}h ${s}m`:s>0?`${s}m ${o}s`:`${o}s`}function WY(e){const t=new Date(e),n=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0");return`${n}:${r}`}function L_e(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=O_e,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function VY(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}const $_e=80;function F_e(e){return VY(e,$_e)}function B_e(e){return e.lastMessageAt??e._creationTime}const UD=1e3,PC=60*UD,Ag=60*PC,xA=24*Ag;function js(e){const t=Math.max(0,e);if(t<PC)return`${Math.floor(t/UD)}s`;if(t<Ag)return`${Math.floor(t/PC)}m`;if(t<xA){const i=Math.floor(t/Ag),s=Math.floor(t%Ag/PC);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/xA),r=Math.floor(t%xA/Ag);return r===0?`${n}d`:`${n}d ${r}h`}function Ep(e){const t=Math.max(0,e);if(t>=Ag)return js(t);const n=Math.floor(t/UD),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function fp(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function _6(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function zy(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function KY(e){switch(e){case"active":return"bg-emerald-500 dark:bg-emerald-400";case"attention":return"bg-amber-500 dark:bg-amber-400";case"destructive":return"bg-destructive";case"muted":default:return"bg-muted-foreground"}}function z_e(e){switch(e){case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed";case"killed":return"Killed";case"unknown":return"Unknown"}}function GY(e){switch(e){case"running":return"active";case"failed":return"destructive";case"killed":return"attention";case"completed":case"unknown":default:return"muted"}}function EE(e){return e.status==="running"||e.status==="starting"?{tone:"warning",label:fp(e.status)}:e.status==="waiting_for_user"?{tone:"info",label:fp(e.status)}:e.status==="failed"?{tone:"destructive",label:fp(e.status)}:e.unread?{tone:"success",label:"Unread"}:null}function NE(e){switch(e){case"warning":return"bg-warning";case"info":return"bg-info";case"success":return"bg-success";case"destructive":return"bg-destructive";default:return""}}function qY(e){switch(e){case"warning":return"text-warning";case"info":return"text-info";case"success":return"text-success";case"destructive":return"text-destructive";default:return"text-muted-foreground"}}function YY(e){switch(e){case"active":return{glyph:"●",toneClass:"text-success",title:"Claude PTY session active"};case"warming":return{glyph:"◐",toneClass:"text-warning",title:"Claude PTY session warming"};case"idle":return{glyph:"○",toneClass:"text-muted-foreground",title:"Claude PTY session idle"};case"cooling":return{glyph:"◌",toneClass:"text-muted-foreground",title:"Claude PTY session cooling down"};case"cold":default:return null}}function HD(e){const t=e+"CollectionProvider",[n,r]=Vu(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:y,children:w}=x,k=Dn.useRef(null),C=Dn.useRef(new Map).current;return c.jsx(i,{scope:y,itemMap:C,collectionRef:k,children:w})};o.displayName=t;const a=e+"CollectionSlot",l=wp(a),u=Dn.forwardRef((x,y)=>{const{scope:w,children:k}=x,C=s(a,w),E=zn(y,C.collectionRef);return c.jsx(l,{ref:E,children:k})});u.displayName=a;const f=e+"CollectionItemSlot",h="data-radix-collection-item",m=wp(f),g=Dn.forwardRef((x,y)=>{const{scope:w,children:k,...C}=x,E=Dn.useRef(null),N=zn(y,E),A=s(f,w);return Dn.useEffect(()=>(A.itemMap.set(E,{ref:E,...C}),()=>void A.itemMap.delete(E))),c.jsx(m,{[h]:"",ref:N,children:k})});g.displayName=f;function v(x){const y=s(e+"CollectionConsumer",x);return Dn.useCallback(()=>{const k=y.collectionRef.current;if(!k)return[];const C=Array.from(k.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((A,j)=>C.indexOf(A.ref.current)-C.indexOf(j.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:g},v,r]}var U_e=_.createContext(void 0);function WD(e){const t=_.useContext(U_e);return e||t||"ltr"}var yA="rovingFocusGroup.onEntryFocus",H_e={bubbles:!1,cancelable:!0},l0="RovingFocusGroup",[cM,XY,W_e]=HD(l0),[V_e,QY]=Vu(l0,[W_e]),[K_e,G_e]=V_e(l0),JY=_.forwardRef((e,t)=>c.jsx(cM.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(cM.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(q_e,{...e,ref:t})})}));JY.displayName=l0;var q_e=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=_.useRef(null),g=zn(t,m),v=WD(s),[x,y]=wv({prop:o,defaultProp:a??null,onChange:l,caller:l0}),[w,k]=_.useState(!1),C=dl(u),E=XY(n),N=_.useRef(!1),[A,j]=_.useState(0);return _.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(yA,C),()=>P.removeEventListener(yA,C)},[C]),c.jsx(K_e,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(P=>y(P),[y]),onItemShiftTab:_.useCallback(()=>k(!0),[]),onFocusableItemAdd:_.useCallback(()=>j(P=>P+1),[]),onFocusableItemRemove:_.useCallback(()=>j(P=>P-1),[]),children:c.jsx(wn.div,{tabIndex:w||A===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:at(e.onMouseDown,()=>{N.current=!0}),onFocus:at(e.onFocus,P=>{const M=!N.current;if(P.target===P.currentTarget&&M&&!w){const F=new CustomEvent(yA,H_e);if(P.currentTarget.dispatchEvent(F),!F.defaultPrevented){const W=E().filter(z=>z.focusable),D=W.find(z=>z.active),B=W.find(z=>z.id===x),V=[D,B,...W].filter(Boolean).map(z=>z.ref.current);tX(V,f)}}N.current=!1}),onBlur:at(e.onBlur,()=>k(!1))})})}),ZY="RovingFocusGroupItem",eX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=_u(),u=s||l,f=G_e(ZY,n),h=f.currentTabStopId===u,m=XY(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),c.jsx(cM.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:c.jsx(wn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:at(e.onMouseDown,y=>{r?f.onItemFocus(u):y.preventDefault()}),onFocus:at(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:at(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=Q_e(y,f.orientation,f.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const E=C.indexOf(y.currentTarget);C=f.loop?J_e(C,E+1):C.slice(E+1)}setTimeout(()=>tX(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});eX.displayName=ZY;var Y_e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function X_e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q_e(e,t,n){const r=X_e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Y_e[r]}function tX(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function J_e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Z_e=JY,e0e=eX,uM=["Enter"," "],t0e=["ArrowDown","PageUp","Home"],nX=["ArrowUp","PageDown","End"],n0e=[...t0e,...nX],r0e={ltr:[...uM,"ArrowRight"],rtl:[...uM,"ArrowLeft"]},i0e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},c0="Menu",[Uy,s0e,o0e]=HD(c0),[Jp,rX]=Vu(c0,[o0e,$f,QY]),TE=$f(),iX=QY(),[a0e,Zp]=Jp(c0),[l0e,u0]=Jp(c0),sX=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=TE(t),[l,u]=_.useState(null),f=_.useRef(!1),h=dl(s),m=WD(i);return _.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(xE,{...a,children:c.jsx(a0e,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:u,children:c.jsx(l0e,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};sX.displayName=c0;var c0e="MenuAnchor",VD=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=TE(n);return c.jsx(i0,{...i,...r,ref:t})});VD.displayName=c0e;var KD="MenuPortal",[u0e,oX]=Jp(KD,{forceMount:void 0}),aX=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Zp(KD,t);return c.jsx(u0e,{scope:t,forceMount:n,children:c.jsx(za,{present:n||s.open,children:c.jsx(nb,{asChild:!0,container:i,children:r})})})};aX.displayName=KD;var Na="MenuContent",[d0e,GD]=Jp(Na),lX=_.forwardRef((e,t)=>{const n=oX(Na,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Zp(Na,e.__scopeMenu),o=u0(Na,e.__scopeMenu);return c.jsx(Uy.Provider,{scope:e.__scopeMenu,children:c.jsx(za,{present:r||s.open,children:c.jsx(Uy.Slot,{scope:e.__scopeMenu,children:o.modal?c.jsx(f0e,{...i,ref:t}):c.jsx(h0e,{...i,ref:t})})})})}),f0e=_.forwardRef((e,t)=>{const n=Zp(Na,e.__scopeMenu),r=_.useRef(null),i=zn(t,r);return _.useEffect(()=>{const s=r.current;if(s)return hE(s)},[]),c.jsx(qD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:at(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),h0e=_.forwardRef((e,t)=>{const n=Zp(Na,e.__scopeMenu);return c.jsx(qD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),p0e=wp("MenuContent.ScrollLock"),qD=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...x}=e,y=Zp(Na,n),w=u0(Na,n),k=TE(n),C=iX(n),E=s0e(n),[N,A]=_.useState(null),j=_.useRef(null),P=zn(t,j,y.onContentChange),M=_.useRef(0),F=_.useRef(""),W=_.useRef(0),D=_.useRef(null),B=_.useRef("right"),I=_.useRef(0),V=v?t0:_.Fragment,z=v?{as:p0e,allowPinchZoom:!0}:void 0,U=$=>{var ae,_e;const q=F.current+$,O=E().filter(te=>!te.disabled),J=document.activeElement,ne=(ae=O.find(te=>te.ref.current===J))==null?void 0:ae.textValue,oe=O.map(te=>te.textValue),he=E0e(oe,q,ne),ce=(_e=O.find(te=>te.textValue===he))==null?void 0:_e.ref.current;(function te(ue){F.current=ue,window.clearTimeout(M.current),ue!==""&&(M.current=window.setTimeout(()=>te(""),1e3))})(q),ce&&setTimeout(()=>ce.focus())};_.useEffect(()=>()=>window.clearTimeout(M.current),[]),dE();const H=_.useCallback($=>{var O,J;return B.current===((O=D.current)==null?void 0:O.side)&&T0e($,(J=D.current)==null?void 0:J.area)},[]);return c.jsx(d0e,{scope:n,searchRef:F,onItemEnter:_.useCallback($=>{H($)&&$.preventDefault()},[H]),onItemLeave:_.useCallback($=>{var q;H($)||((q=j.current)==null||q.focus(),A(null))},[H]),onTriggerLeave:_.useCallback($=>{H($)&&$.preventDefault()},[H]),pointerGraceTimerRef:W,onPointerGraceIntentChange:_.useCallback($=>{D.current=$},[]),children:c.jsx(V,{...z,children:c.jsx(e0,{asChild:!0,trapped:i,onMountAutoFocus:at(s,$=>{var q;$.preventDefault(),(q=j.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:c.jsx(tb,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:c.jsx(Z_e,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:A,onEntryFocus:at(l,$=>{w.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(yE,{role:"menu","aria-orientation":"vertical","data-state":CX(y.open),"data-radix-menu-content":"",dir:w.dir,...k,...x,ref:P,style:{outline:"none",...x.style},onKeyDown:at(x.onKeyDown,$=>{const O=$.target.closest("[data-radix-menu-content]")===$.currentTarget,J=$.ctrlKey||$.altKey||$.metaKey,ne=$.key.length===1;O&&($.key==="Tab"&&$.preventDefault(),!J&&ne&&U($.key));const oe=j.current;if($.target!==oe||!n0e.includes($.key))return;$.preventDefault();const ce=E().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);nX.includes($.key)&&ce.reverse(),C0e(ce)}),onBlur:at(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(M.current),F.current="")}),onPointerMove:at(e.onPointerMove,Hy($=>{const q=$.target,O=I.current!==$.clientX;if($.currentTarget.contains(q)&&O){const J=$.clientX>I.current?"right":"left";B.current=J,I.current=$.clientX}}))})})})})})})});lX.displayName=Na;var m0e="MenuGroup",YD=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"group",...r,ref:t})});YD.displayName=m0e;var g0e="MenuLabel",cX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{...r,ref:t})});cX.displayName=g0e;var D1="MenuItem",S6="menu.itemSelect",AE=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=u0(D1,e.__scopeMenu),a=GD(D1,e.__scopeMenu),l=zn(t,s),u=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(S6,{bubbles:!0,cancelable:!0});h.addEventListener(S6,g=>r==null?void 0:r(g),{once:!0}),yq(h,m),m.defaultPrevented?u.current=!1:o.onClose()}};return c.jsx(uX,{...i,ref:l,disabled:n,onClick:at(e.onClick,f),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:at(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:at(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||uM.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});AE.displayName=D1;var uX=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=GD(D1,n),a=iX(n),l=_.useRef(null),u=zn(t,l),[f,h]=_.useState(!1),[m,g]=_.useState("");return _.useEffect(()=>{const v=l.current;v&&g((v.textContent??"").trim())},[s.children]),c.jsx(Uy.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:c.jsx(e0e,{asChild:!0,...a,focusable:!r,children:c.jsx(wn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:at(e.onPointerMove,Hy(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:at(e.onPointerLeave,Hy(v=>o.onItemLeave(v))),onFocus:at(e.onFocus,()=>h(!0)),onBlur:at(e.onBlur,()=>h(!1))})})})}),v0e="MenuCheckboxItem",dX=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return c.jsx(gX,{scope:e.__scopeMenu,checked:n,children:c.jsx(AE,{role:"menuitemcheckbox","aria-checked":L1(n)?"mixed":n,...i,ref:t,"data-state":QD(n),onSelect:at(i.onSelect,()=>r==null?void 0:r(L1(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dX.displayName=v0e;var fX="MenuRadioGroup",[b0e,x0e]=Jp(fX,{value:void 0,onValueChange:()=>{}}),hX=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=dl(r);return c.jsx(b0e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(YD,{...i,ref:t})})});hX.displayName=fX;var pX="MenuRadioItem",mX=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=x0e(pX,e.__scopeMenu),s=n===i.value;return c.jsx(gX,{scope:e.__scopeMenu,checked:s,children:c.jsx(AE,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":QD(s),onSelect:at(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});mX.displayName=pX;var XD="MenuItemIndicator",[gX,y0e]=Jp(XD,{checked:!1}),vX=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=y0e(XD,n);return c.jsx(za,{present:r||L1(s.checked)||s.checked===!0,children:c.jsx(wn.span,{...i,ref:t,"data-state":QD(s.checked)})})});vX.displayName=XD;var _0e="MenuSeparator",bX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});bX.displayName=_0e;var S0e="MenuArrow",xX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=TE(n);return c.jsx(_E,{...i,...r,ref:t})});xX.displayName=S0e;var w0e="MenuSub",[LZe,yX]=Jp(w0e),Ux="MenuSubTrigger",_X=_.forwardRef((e,t)=>{const n=Zp(Ux,e.__scopeMenu),r=u0(Ux,e.__scopeMenu),i=yX(Ux,e.__scopeMenu),s=GD(Ux,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),c.jsx(VD,{asChild:!0,...u,children:c.jsx(uX,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":CX(n.open),...e,ref:yD(t,i.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:at(e.onPointerMove,Hy(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:at(e.onPointerLeave,Hy(h=>{var g,v;f();const m=(g=n.content)==null?void 0:g.getBoundingClientRect();if(m){const x=(v=n.content)==null?void 0:v.dataset.side,y=x==="right",w=y?-5:5,k=m[y?"left":"right"],C=m[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:k,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:k,y:m.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:at(e.onKeyDown,h=>{var g;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||r0e[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});_X.displayName=Ux;var SX="MenuSubContent",wX=_.forwardRef((e,t)=>{const n=oX(Na,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Zp(Na,e.__scopeMenu),o=u0(Na,e.__scopeMenu),a=yX(SX,e.__scopeMenu),l=_.useRef(null),u=zn(t,l);return c.jsx(Uy.Provider,{scope:e.__scopeMenu,children:c.jsx(za,{present:r||s.open,children:c.jsx(Uy.Slot,{scope:e.__scopeMenu,children:c.jsx(qD,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:at(e.onFocusOutside,f=>{f.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:at(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:at(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),m=i0e[o.dir].includes(f.key);h&&m&&(s.onOpenChange(!1),(g=a.trigger)==null||g.focus(),f.preventDefault())})})})})})});wX.displayName=SX;function CX(e){return e?"open":"closed"}function L1(e){return e==="indeterminate"}function QD(e){return L1(e)?"indeterminate":e?"checked":"unchecked"}function C0e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function k0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function E0e(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=k0e(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function N0e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,f=a.y,h=l.x,m=l.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(i=!i)}return i}function T0e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return N0e(n,t)}function Hy(e){return t=>t.pointerType==="mouse"?e(t):void 0}var A0e=sX,R0e=VD,j0e=aX,M0e=lX,P0e=YD,I0e=cX,O0e=AE,D0e=dX,L0e=hX,$0e=mX,F0e=vX,B0e=bX,z0e=xX,U0e=_X,H0e=wX,JD="ContextMenu",[W0e]=Vu(JD,[rX]),to=rX(),[V0e,kX]=W0e(JD),EX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,a]=_.useState(!1),l=to(t),u=dl(r),f=_.useCallback(h=>{a(h),u(h)},[u]);return c.jsx(V0e,{scope:t,open:o,onOpenChange:f,modal:s,children:c.jsx(A0e,{...l,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};EX.displayName=JD;var NX="ContextMenuTrigger",TX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=kX(NX,n),o=to(n),a=_.useRef({x:0,y:0}),l=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),h=m=>{a.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(R0e,{...o,virtualRef:l}),c.jsx(wn.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:at(e.onContextMenu,m=>{f(),h(m),m.preventDefault()}),onPointerDown:r?e.onPointerDown:at(e.onPointerDown,dw(m=>{f(),u.current=window.setTimeout(()=>h(m),700)})),onPointerMove:r?e.onPointerMove:at(e.onPointerMove,dw(f)),onPointerCancel:r?e.onPointerCancel:at(e.onPointerCancel,dw(f)),onPointerUp:r?e.onPointerUp:at(e.onPointerUp,dw(f))})]})});TX.displayName=NX;var K0e="ContextMenuPortal",AX=e=>{const{__scopeContextMenu:t,...n}=e,r=to(t);return c.jsx(j0e,{...r,...n})};AX.displayName=K0e;var RX="ContextMenuContent",jX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=kX(RX,n),s=to(n),o=_.useRef(!1);return c.jsx(M0e,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,a),!a.defaultPrevented&&o.current&&a.preventDefault(),o.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)==null||l.call(e,a),!a.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});jX.displayName=RX;var G0e="ContextMenuGroup",q0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(P0e,{...i,...r,ref:t})});q0e.displayName=G0e;var Y0e="ContextMenuLabel",X0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(I0e,{...i,...r,ref:t})});X0e.displayName=Y0e;var Q0e="ContextMenuItem",MX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(O0e,{...i,...r,ref:t})});MX.displayName=Q0e;var J0e="ContextMenuCheckboxItem",Z0e=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(D0e,{...i,...r,ref:t})});Z0e.displayName=J0e;var eSe="ContextMenuRadioGroup",tSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(L0e,{...i,...r,ref:t})});tSe.displayName=eSe;var nSe="ContextMenuRadioItem",rSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx($0e,{...i,...r,ref:t})});rSe.displayName=nSe;var iSe="ContextMenuItemIndicator",sSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(F0e,{...i,...r,ref:t})});sSe.displayName=iSe;var oSe="ContextMenuSeparator",PX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(B0e,{...i,...r,ref:t})});PX.displayName=oSe;var aSe="ContextMenuArrow",lSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(z0e,{...i,...r,ref:t})});lSe.displayName=aSe;var cSe="ContextMenuSubTrigger",uSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(U0e,{...i,...r,ref:t})});uSe.displayName=cSe;var dSe="ContextMenuSubContent",fSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=to(n);return c.jsx(H0e,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fSe.displayName=dSe;function dw(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var hSe=EX,pSe=TX,mSe=AX,IX=jX,OX=MX,DX=PX;const LX=_.createContext(null);function em({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return c.jsx(LX.Provider,{value:i,children:c.jsx(hSe,{onOpenChange:e,...t},n)})}const tm=pSe,Ff=_.forwardRef(({className:e,...t},n)=>c.jsx(mSe,{children:c.jsx(IX,{ref:n,className:le("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));Ff.displayName=IX.displayName;const fr=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(LX);return c.jsx(OX,{ref:r,className:le("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});fr.displayName=OX.displayName;const ZD=_.forwardRef(({className:e,...t},n)=>c.jsx(DX,{ref:n,className:le("-mx-1 my-1 h-px bg-border",e),...t}));ZD.displayName=DX.displayName;var RE="Popover",[$X]=Vu(RE,[$f]),d0=$f(),[gSe,Bf]=$X(RE),FX=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,a=d0(t),l=_.useRef(null),[u,f]=_.useState(!1),[h,m]=wv({prop:r,defaultProp:i??!1,onChange:s,caller:RE});return c.jsx(xE,{...a,children:c.jsx(gSe,{scope:t,contentId:_u(),triggerRef:l,open:h,onOpenChange:m,onOpenToggle:_.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:o,children:n})})};FX.displayName=RE;var BX="PopoverAnchor",vSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(BX,n),s=d0(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=i;return _.useEffect(()=>(o(),()=>a()),[o,a]),c.jsx(i0,{...s,...r,ref:t})});vSe.displayName=BX;var zX="PopoverTrigger",UX=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(zX,n),s=d0(n),o=zn(t,i.triggerRef),a=c.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":GX(i.open),...r,ref:o,onClick:at(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:c.jsx(i0,{asChild:!0,...s,children:a})});UX.displayName=zX;var eL="PopoverPortal",[bSe,xSe]=$X(eL,{forceMount:void 0}),HX=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Bf(eL,t);return c.jsx(bSe,{scope:t,forceMount:n,children:c.jsx(za,{present:n||s.open,children:c.jsx(nb,{asChild:!0,container:i,children:r})})})};HX.displayName=eL;var Ev="PopoverContent",WX=_.forwardRef((e,t)=>{const n=xSe(Ev,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Bf(Ev,e.__scopePopover);return c.jsx(za,{present:r||s.open,children:s.modal?c.jsx(_Se,{...i,ref:t}):c.jsx(SSe,{...i,ref:t})})});WX.displayName=Ev;var ySe=wp("PopoverContent.RemoveScroll"),_Se=_.forwardRef((e,t)=>{const n=Bf(Ev,e.__scopePopover),r=_.useRef(null),i=zn(t,r),s=_.useRef(!1);return _.useEffect(()=>{const o=r.current;if(o)return hE(o)},[]),c.jsx(t0,{as:ySe,allowPinchZoom:!0,children:c.jsx(VX,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:at(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:at(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),SSe=_.forwardRef((e,t)=>{const n=Bf(Ev,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return c.jsx(VX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),VX=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...h}=e,m=Bf(Ev,n),g=d0(n);return dE(),c.jsx(e0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:c.jsx(tb,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:c.jsx(yE,{"data-state":GX(m.open),role:"dialog",id:m.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),KX="PopoverClose",wSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Bf(KX,n);return c.jsx(wn.button,{type:"button",...r,ref:t,onClick:at(e.onClick,()=>i.onOpenChange(!1))})});wSe.displayName=KX;var CSe="PopoverArrow",kSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=d0(n);return c.jsx(_E,{...i,...r,ref:t})});kSe.displayName=CSe;function GX(e){return e?"open":"closed"}var ESe=FX,NSe=UX,TSe=HX,qX=WX;const bc=ESe,xc=NSe,_l=_.forwardRef(({className:e,align:t="center",sideOffset:n=4,ports:r={},...i},s)=>{const o=r.dom??Nt;return c.jsx(TSe,{children:c.jsx(qX,{ref:s,align:t,sideOffset:n,[A1]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),o.dispatchCustomWindowEvent(ED),(l=i.onCloseAutoFocus)==null||l.call(i,a)},className:le("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",e),...i})})});_l.displayName=qX.displayName;const dM=Jt("StackActionsPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function ASe({editorLabel:e,onOpenBoards:t,starred:n,onCopyPath:r,onShowArchived:i,onOpenInFinder:s,onOpenInEditor:o,onToggleStar:a,onHide:l,children:u}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:u}),c.jsxs(Ff,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),t()},children:[c.jsx(JG,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(ZD,{})]}):null,c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),a()},children:[n?c.jsx(yge,{className:"h-3.5 w-3.5"}):c.jsx(eq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:n?"Unstar project":"Star project"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),r()},children:[c.jsx(ja,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),i()},children:[c.jsx(aD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),s()},children:[c.jsx(aE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),o()},children:[c.jsx(cD,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),c.jsxs(fr,{onSelect:f=>{f.stopPropagation(),l()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[c.jsx(spe,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function RSe({canFork:e,onRename:t,onOpenInFinder:n,onFork:r,onArchive:i,onDelete:s,onEditPermissions:o,children:a}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:a}),c.jsxs(Ff,{children:[c.jsxs(fr,{onSelect:l=>{l.preventDefault(),t()},children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(fr,{onSelect:l=>{l.preventDefault(),n()},children:[c.jsx(aE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),c.jsxs(fr,{disabled:!e,onSelect:l=>{l.preventDefault(),e&&r()},children:[c.jsx(QG,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),o?c.jsxs(fr,{onSelect:l=>{l.preventDefault(),o()},children:[c.jsx(mD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Permissions…"})]}):null,c.jsxs(fr,{onSelect:l=>{l.preventDefault(),i()},children:[c.jsx(aD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),c.jsxs(fr,{onSelect:l=>{l.preventDefault(),s()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}function jSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){const s=dM.useScopedStore(l=>l.open),o=dM.useScopedStore(l=>l.setOpen);function a(l){return()=>{o(!1),l()}}return c.jsxs(bc,{open:s,onOpenChange:o,children:[c.jsx(xc,{asChild:!0,children:i}),c.jsxs(_l,{align:"end",sideOffset:4,className:"w-44 p-1",role:"menu","aria-label":`Actions for ${e}`,children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:a(t),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Rename"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:a(n),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(nq,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Edit members"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:a(r),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium text-destructive dark:text-red-400 hover:bg-destructive/10 focus-visible:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus-visible:bg-red-500/20 outline-hidden",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsxs("span",{children:["Delete ",e]})]})]})]})}function MSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){return c.jsx(dM.Provider,{init:{},children:c.jsx(jSe,{stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i})})}function PSe({stackTitle:e,onRename:t,onEditMembers:n,onDelete:r,children:i}){return c.jsxs(em,{children:[c.jsx(tm,{asChild:!0,children:i}),c.jsxs(Ff,{children:[c.jsxs(fr,{onSelect:s=>{s.preventDefault(),t()},children:[c.jsx(Xp,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(fr,{onSelect:s=>{s.preventDefault(),n()},children:[c.jsx(nq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Edit members"})]}),c.jsxs(fr,{onSelect:s=>{s.preventDefault(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[c.jsx(Wu,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Delete ",e]})]})]})]})}function ISe({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onOpenInFinder:a,onForkChat:l,onArchiveChat:u,onDeleteChat:f,onEditPermissions:h}){var A;const m=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,g=m&&e.stateEnteredAt!=null?`${fp(e.status)} ${Ep(n-e.stateEnteredAt)}`:js(n-(e.lastMessageAt??e._creationTime)),v=i&&r?r:g,x=i&&!!r,y=Pve(e.chatId),w=t===y,k=((A=EE(e))==null?void 0:A.tone)??null;let C;e.canFork?C="w-12":m?C="w-12 md:w-20":C="w-6 md:w-14";let E=null;v&&(x?E=c.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity duration-150 group-hover:opacity-0",children:c.jsx(OY,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):E=c.jsx("span",{className:le("hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] tabular-nums transition-opacity duration-150 group-hover:opacity-0 whitespace-nowrap",m?qY(k):"text-muted-foreground"),children:v}));const N=c.jsxs("div",{"data-chat-id":y,className:le("group flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-md cursor-pointer transition-colors duration-150",w?"bg-muted":"hover:bg-muted/40"),onClick:()=>s(e.chatId),children:[c.jsx("span",{className:"relative flex h-3.5 w-3.5 shrink-0 items-center justify-center","aria-hidden":!0,children:k?c.jsx("span",{className:le("h-2 w-2 rounded-full",NE(k))}):null}),(()=>{const j=YY(e.sessionState);return j?c.jsx(Qo,{label:j.title,children:c.jsx("span",{className:le("shrink-0 text-[10px] leading-none",j.toneClass),"aria-label":j.title,children:j.glyph})}):null})(),e.hasPolicyOverride?c.jsx(mD,{className:"size-3 shrink-0 text-warning","aria-label":"Per-chat permission override active"}):null,c.jsx("span",{className:le("truncate flex-1 text-sm",w?"text-foreground font-medium":"text-foreground/90",e.status==="idle"&&!e.unread&&!w?"text-muted-foreground":""),children:e.title}),c.jsxs("div",{className:le("relative h-6 shrink-0",C),children:[E,c.jsxs("div",{className:le("absolute inset-0 flex items-center justify-end gap-0 transition-opacity duration-150",v?"opacity-100 md:opacity-0 md:group-hover:opacity-100":"opacity-100"),children:[e.canFork?c.jsx(Re,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:j=>{j.stopPropagation(),l(e.chatId)},title:"Fork chat",children:c.jsx(QG,{className:"size-3.5"})}):null,c.jsx(Re,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:j=>{j.stopPropagation(),u(e.chatId)},title:"Archive chat",children:c.jsx(aD,{className:"size-3.5"})})]})]})]},e._id);return c.jsx(RSe,{canFork:e.canFork,onRename:()=>o(e.chatId),onOpenInFinder:()=>a(e.localPath),onFork:()=>l(e.chatId),onArchive:()=>u(e.chatId),onDelete:()=>f(e.chatId),onEditPermissions:h?()=>h(e.chatId):void 0,children:N})}const OSe=_.memo(ISe);function DSe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const jE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sb(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function tL(e){return"nodeType"in e}function Eo(e){var t,n;return e?sb(e)?e:tL(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function nL(e){const{Document:t}=Eo(e);return e instanceof t}function f0(e){return sb(e)?!1:e instanceof Eo(e).HTMLElement}function YX(e){return e instanceof Eo(e).SVGElement}function ob(e){return e?sb(e)?e.document:tL(e)?nL(e)?e:f0(e)||YX(e)?e.ownerDocument:document:document:document}const cc=jE?_.useLayoutEffect:_.useEffect;function rL(e){const t=_.useRef(e);return cc(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function LSe(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Wy(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return cc(()=>{n.current!==e&&(n.current=e)},t),n}function h0(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function $1(e){const t=rL(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function fM(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let _A={};function p0(e,t){return _.useMemo(()=>{if(t)return t;const n=_A[e]==null?0:_A[e]+1;return _A[e]=n,e+"-"+n},[e,t])}function XX(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const a=Object.entries(o);for(const[l,u]of a){const f=s[l];f!=null&&(s[l]=f+e*u)}return s},{...t})}}const Wg=XX(1),F1=XX(-1);function $Se(e){return"clientX"in e&&"clientY"in e}function iL(e){if(!e)return!1;const{KeyboardEvent:t}=Eo(e.target);return t&&e instanceof t}function FSe(e){if(!e)return!1;const{TouchEvent:t}=Eo(e.target);return t&&e instanceof t}function hM(e){if(FSe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return $Se(e)?{x:e.clientX,y:e.clientY}:null}const Vy=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Vy.Translate.toString(e),Vy.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),w6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function BSe(e){return e.matches(w6)?e:e.querySelector(w6)}const zSe={display:"none"};function USe(e){let{id:t,value:n}=e;return Dn.createElement("div",{id:t,style:zSe},n)}function HSe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Dn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function WSe(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const QX=_.createContext(null);function VSe(e){const t=_.useContext(QX);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function KSe(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var a;return(a=o[i])==null?void 0:a.call(o,s)})},[e]),t]}const GSe={draggable:`
822
822
  To pick up a draggable item, press the space bar.
823
823
  While dragging, use the arrow keys to move the item.
824
824
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -2740,7 +2740,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[QE(e),e])),sRe=new Map([["s",wi(383)],[wi(38
2740
2740
  `:"").join("");return c.jsx(Pre,{source:r,lang:n},Li())}if(Mt(e)){const n=e.getListType(),r=jd(e),i=Li();return n==="number"?c.jsx("ol",{className:"list-decimal ml-5 my-2",children:r},i):c.jsx("ul",{className:"list-disc ml-5 my-2",children:r},i)}if(Sn(e)){const n=e.getChecked(),r=jd(e),i=Li();return n!==void 0?c.jsxs("li",{className:"my-0.5 list-none flex items-start gap-1.5",children:[c.jsx("input",{type:"checkbox",readOnly:!0,checked:n,className:"mt-[3px] shrink-0"}),c.jsx("span",{children:r})]},i):c.jsx("li",{className:"my-0.5",children:r},i)}if(mo(e)||Qd(e)){const n=e.getURL();return c.jsx("a",{href:n,className:"transition-all underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40",target:"_blank",rel:"noopener noreferrer",children:jd(e)},Li())}if(hr(e)){const n=e.getChildren(),r=n[0],i=r!==void 0&&or(r)&&r.getChildren().every(a=>kt(a)&&(a.getHeaderStyles()&Rn.ROW)!==0),s=i?r:void 0,o=i?n.slice(1):n;return c.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:c.jsxs("table",{className:"table-auto min-w-full divide-y divide-border bg-background",children:[s!==void 0&&c.jsx("thead",{children:c.jsx("tr",{children:s.getChildren().map(a=>c.jsx("th",{className:"text-left text-xs uppercase text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",children:jd(a)},Li()))})}),c.jsx("tbody",{className:"divide-y divide-border",children:o.map(a=>or(a)?c.jsx("tr",{children:a.getChildren().map(l=>kt(l)?c.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal",children:jd(l)},Li()):null)},Li()):null)})]})},Li())}if(hi(e))return c.jsx("br",{},Li());if(Fe(e))return v3e(e);if(zv(e))return c.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:e.getTextContent()},Li());const t=e.getTextContent();return t?c.jsx("span",{children:t},Li()):null}function v3e(e){const t=e.getFormat(),n=e.getTextContent(),r=(t&f_)!==0,i=(t&h_)!==0,s=(t&p_)!==0,o=(t&c5)!==0;let a=n;return o?c.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:n},Li()):(s&&(a=c.jsx("del",{className:"line-through",children:a},Li())),i&&(a=c.jsx("em",{className:"italic",children:a},Li())),r&&(a=c.jsx("strong",{className:"font-semibold",children:a},Li())),!r&&!i&&!s?n:a)}function jd(e){return e.getChildren().map(Ore)}function b3e(){Ire=0;const t=Pn().getChildren();return c.jsx(c.Fragment,{children:t.map(Ore)})}function $p(e,t=Rre){const n=Vte(s3({namespace:"kanna-md-renderer",nodes:g3e,editable:!1}));return n.update(()=>{xre(e,t,void 0,!0)},{discrete:!0}),n.getEditorState().read(()=>b3e())}const oI=Jt("ThinkingBlock",()=>e=>({expanded:!1,setExpanded:t=>e({expanded:t})}));function x3e({content:e}){const t=oI.useScopedStore(i=>i.expanded),n=oI.useScopedStore(i=>i.setExpanded),r=e.trim();return r.length===0?null:c.jsxs("div",{className:"my-3 first:mt-0 last:mb-0",children:[c.jsxs("button",{type:"button",onClick:()=>n(!t),"aria-expanded":t,className:"group/thinking flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[c.jsx(TC,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Thinking"}),c.jsx(Ra,{className:le("h-3.5 w-3.5 transition-transform duration-200",t&&"rotate-90")})]}),t&&c.jsx("div",{className:"mt-2 border-l-2 border-muted-foreground/20 pl-3 text-sm text-muted-foreground italic prose prose-sm dark:prose-invert max-w-[70ch]",children:$p(r)})]})}const RN=_.memo(({content:e})=>c.jsx(oI.Provider,{init:void 0,children:c.jsx(x3e,{content:e})}));class R_ extends Xu{constructor(n,r,i,s,o=Nt){super(s);K(this,"__mentionKind");K(this,"__value");K(this,"__label");K(this,"__dom");this.__mentionKind=n,this.__value=r,this.__label=i,this.__dom=o}static getType(){return"kanna-mention"}static clone(n){return new R_(n.__mentionKind,n.__value,n.__label,n.__key,n.__dom)}static importJSON(n){return aI({mentionKind:n.mentionKind,value:n.value,label:n.label})}exportJSON(){return{type:R_.getType(),version:1,mentionKind:this.__mentionKind,value:this.__value,label:this.__label}}createDOM(n,r){const i=this.__dom.createElement("span");return i.dataset.lexicalDecorator="true",i}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__mentionKind==="agent"?`@agent/${this.__value}`:`@${this.__value}`}decorate(n,r){const i=this.__label;return this.__mentionKind==="agent"?c.jsx("span",{className:le("inline-flex items-center rounded px-1 text-sm","bg-primary/10 text-primary border border-primary/20"),children:i}):c.jsx("span",{className:le("inline-flex items-center rounded px-1 text-sm","bg-muted text-muted-foreground border border-border"),children:i})}}function aI(e){return pi(new R_(e.mentionKind,e.value,e.label))}class j_ extends Xu{constructor(n,r,i,s=Nt){super(i);K(this,"__commandName");K(this,"__hasArgument");K(this,"__dom");this.__commandName=n,this.__hasArgument=r,this.__dom=s}static getType(){return"kanna-slash-command"}static clone(n){return new j_(n.__commandName,n.__hasArgument,n.__key,n.__dom)}static importJSON(n){return Dre({commandName:n.commandName,hasArgument:n.hasArgument})}exportJSON(){return{type:j_.getType(),version:1,commandName:this.__commandName,hasArgument:this.__hasArgument}}createDOM(n,r){const i=this.__dom.createElement("span");return i.dataset.lexicalDecorator="true",i}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__hasArgument?`/${this.__commandName} `:`/${this.__commandName}`}decorate(n,r){return c.jsx("span",{className:le("inline-flex items-center rounded px-1 text-sm font-mono","bg-muted text-muted-foreground border border-border"),children:`/${this.__commandName}`})}}function Dre(e){return pi(new j_(e.commandName,e.hasArgument))}class Wv extends Xu{constructor(n,r,i=Nt){super(r);K(this,"__attachment");K(this,"__dom");this.__attachment=n,this.__dom=i}static getType(){return"kanna-attachment"}static clone(n){return new Wv(n.__attachment,n.__key,n.__dom)}static importJSON(n){return o3(n.attachment)}getAttachment(){return this.getLatest().__attachment}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return""}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}exportJSON(){return{type:Wv.getType(),version:1,attachment:this.__attachment}}decorate(n,r){const i=this.getLatest().__attachment;return i.kind==="image"&&i.contentUrl?c.jsx(tN,{attachment:i,size:"composer"}):c.jsx(qo,{attachment:i})}}function o3(e){return pi(new Wv(e))}function y3e(){return kIe(Wv)}const _3e=.25,S3e=8,J7=.25;function Z7(e){return Math.min(S3e,Math.max(_3e,e))}function w3e(){return e=>({scale:1,offset:{x:0,y:0},drag:null,zoomIn:()=>e(t=>{const n=Z7(t.scale+J7);return n===t.scale?t:{scale:n}}),zoomOut:()=>e(t=>{const n=Z7(t.scale-J7);return n===t.scale?t:{scale:n}}),resetView:()=>e({scale:1,offset:{x:0,y:0}}),beginDrag:(t,n)=>e(r=>({drag:{x:t-r.offset.x,y:n-r.offset.y}})),dragTo:(t,n)=>e(r=>r.drag?{offset:{x:t-r.drag.x,y:n-r.drag.y}}:r),endDrag:()=>e({drag:null})})}const nu=Jt("MermaidZoomModal",w3e);function C3e({svg:e,onClose:t,ports:n}){const r=(n==null?void 0:n.dom)??Nt,i=nu.useScopedStore(v=>v.scale),s=nu.useScopedStore(v=>v.offset),o=nu.useScopedStore(v=>v.zoomIn),a=nu.useScopedStore(v=>v.zoomOut),l=nu.useScopedStore(v=>v.resetView),u=nu.useScopedStore(v=>v.beginDrag),f=nu.useScopedStore(v=>v.dragTo),h=nu.useScopedStore(v=>v.endDrag);_.useEffect(()=>{const v=x=>{x.key==="Escape"&&t()};return r.addWindowListener("keydown",v)},[t,r]);const m=v=>u(v.clientX,v.clientY),g=v=>f(v.clientX,v.clientY);return Js.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-background/95",role:"dialog","aria-modal":"true","aria-label":"Diagram zoom view",children:[c.jsxs("div",{className:"flex justify-end gap-1 p-2",children:[c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Zoom out",className:"h-9 w-9",onClick:a,children:c.jsx(GG,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Zoom in",className:"h-9 w-9",onClick:o,children:c.jsx(Co,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Reset view",className:"h-9 w-9",onClick:l,children:c.jsx(zme,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Close",className:"h-9 w-9",onClick:t,children:c.jsx(ts,{className:"h-4 w-4"})})]}),c.jsx("div",{className:"flex-1 overflow-hidden touch-none cursor-grab active:cursor-grabbing",onPointerDown:m,onPointerMove:g,onPointerUp:h,onPointerLeave:h,children:c.jsx("div",{"data-mermaid-stage":!0,className:"w-full h-full flex items-center justify-center",style:{transform:`translate(${s.x}px, ${s.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e}})})]}),r.getBodyElement())}function k3e({svg:e,onClose:t,ports:n}){return c.jsx(nu.Provider,{init:void 0,children:c.jsx(C3e,{svg:e,onClose:t,ports:n})})}const ru=Jt("MermaidDiagram",()=>e=>({renderState:{status:"loading"},showSource:!1,zoomOpen:!1,copied:!1,setRenderState:t=>e({renderState:t}),setShowSource:t=>e({showSource:t}),setZoomOpen:t=>e({zoomOpen:t}),setCopied:t=>e({copied:t})})),eW=/error on line (\d+)\s*[.:]?\s*(.*)$/i,E3e=/^[\s-]*\^\s*$/;function tW(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(" ")}function N3e(e){const t=e.trim();if(t.length===0)return{line:null,summary:"Unknown error",excerpt:null};const n=t.split(`
2741
2741
  `),r=n.findIndex(h=>eW.test(h)),i=r===-1?null:eW.exec(n[r]??"");if(i===null)return{line:null,summary:tW(n),excerpt:null};const s=Number(i[1]),o=n.slice(r+1),a=o.findIndex(h=>E3e.test(h)),l=a===-1?null:o.slice(0,a+1).join(`
2742
2742
  `),u=a===-1?o:o.slice(a+1),f=tW([i[2]??"",...u]);return{line:Number.isInteger(s)?s:null,summary:f.length>0?f:`Parse error on line ${String(s)}`,excerpt:l}}const T3e=[{from:"-.x",to:"-.-x"},{from:"-.o",to:"-.-o"}],Zw={"[":"]","(":")","{":"}"};function A3e(e){const t=[];let n="",r=1,i=0,s=!1,o=!1,a=!1;const l=[];for(;i<e.length;){const u=e[i]??"";if(u===`
2743
- `){o=!1,a=!1,s=!1,l.length=0,r+=1,n+=u,i+=1;continue}if(o){n+=u,i+=1;continue}if(s){u==='"'&&(s=!1),n+=u,i+=1;continue}if(u==='"'){s=!0,n+=u,i+=1;continue}if(e.startsWith("%%",i)){o=!0,n+="%%",i+=2;continue}if(l.length>0){u===l[l.length-1]?l.pop():Zw[u]&&l.push(Zw[u]),n+=u,i+=1;continue}if(Zw[u]){l.push(Zw[u]),n+=u,i+=1;continue}if(u==="|"){a=!a,n+=u,i+=1;continue}if(a){n+=u,i+=1;continue}const f=T3e.find(h=>e.startsWith(h.from,i));if(f){n+=f.to,t.push({line:r,from:f.from,to:f.to}),i+=f.from.length;continue}n+=u,i+=1}return{source:n,repairs:t}}const R3e=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function j3e(e){const t=e.message.toLowerCase();return R3e.some(n=>t.includes(n))}function M3e(e){let t=null;return()=>(t||(t=e().catch(n=>{throw t=null,s5(n)})),t)}const P3e=M3e(()=>Z(()=>import("./mermaid.core-Bhvd1JLY.js").then(e=>e.bm),[]).then(e=>e.default));async function I3e(e,t,n){try{const{svg:r}=await e.render(t,n);return{svg:r,repairs:[]}}catch(r){const i=A3e(n);if(i.repairs.length===0)throw r;try{const{svg:s}=await e.render(`${t}-repaired`,i.source);return{svg:s,repairs:i.repairs}}catch{throw r}}}function O3e(e){const t=[];for(const n of e){const r=`${n.from} → ${n.to}`;t.includes(r)||t.push(r)}return t.join(", ")}function D3e({source:e,ports:t}){const{resolvedTheme:n}=AN(),r=n==="dark"?"dark":"default",i=ru.useScopedStore(C=>C.renderState),s=i.status==="error"?i.message:void 0,o=i.status==="error"&&i.kind==="stale-chunk",a=ru.useScopedStore(C=>C.showSource),l=ru.useScopedStore(C=>C.zoomOpen),u=ru.useScopedStore(C=>C.copied),f=ru.useScopedStore(C=>C.setRenderState),h=ru.useScopedStore(C=>C.setShowSource),m=ru.useScopedStore(C=>C.setZoomOpen),g=ru.useScopedStore(C=>C.setCopied),x=`mermaid-${_.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=_.useCallback(()=>m(!1),[m]),w=async()=>{await((t==null?void 0:t.clipboard)??Ua).writeText(e),g(!0),((t==null?void 0:t.timer)??ar).setTimeout(()=>g(!1),2e3)},k=(t==null?void 0:t.loadMermaid)??P3e;if(_.useEffect(()=>{let C=!1;return k().then(async E=>{E.initialize({startOnLoad:!1,securityLevel:"strict",theme:r});const{svg:N,repairs:A}=await I3e(E,x,e);C||f({status:"ready",svg:N,repairs:A})}).catch(E=>{if(C)return;const N=s5(E);if(j3e(N)){f({status:"error",kind:"stale-chunk"});return}f({status:"error",message:N.message})}),()=>{C=!0}},[e,r,x,f,k]),o)return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(kf,{className:"size-3.5 shrink-0"}),c.jsx("span",{children:"This diagram needs the latest version of the app."}),c.jsxs(Re,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??Nt).reload(),children:[c.jsx(Z_,{className:"size-3 mr-1"}),"Reload"]})]}),c.jsx(Fw,{source:e})]});if(i.status==="error"){const C=N3e(s??"");return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[c.jsx(kf,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("span",{children:["Couldn't render this Mermaid diagram",C.line!==null?c.jsxs("span",{className:"text-muted-foreground",children:[" — line ",c.jsx("span",{className:"tabular-nums",children:C.line})]}):null]}),c.jsx("div",{className:"text-muted-foreground",children:C.summary}),C.excerpt?c.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:C.excerpt}):null]})]}),c.jsx(Fw,{source:e,highlightLine:C.line??void 0})]})}return i.status==="loading"?c.jsx("div",{className:"relative group/mermaid",children:c.jsx(Fw,{source:e})}):a?c.jsxs("div",{className:"relative group/mermaid",children:[c.jsx(Fw,{source:e}),c.jsx(nW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:void 0})]}):c.jsxs("div",{className:"relative group/mermaid my-3",children:[i.repairs.length>0&&c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(Fge,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("span",{children:["Corrected ",c.jsx("span",{className:"tabular-nums",children:i.repairs.length}),i.repairs.length===1?" invalid link":" invalid links"," to render this (",c.jsx("span",{className:"font-mono",children:O3e(i.repairs)}),"). The source is unchanged."]})]}),c.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:i.svg}}),c.jsx(nW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:()=>m(!0)}),l&&c.jsx(k3e,{svg:i.svg,onClose:y})]})}function Lre({source:e,ports:t}){return c.jsx(ru.Provider,{init:void 0,children:c.jsx(D3e,{source:e,ports:t})})}function nW({showSource:e,onToggleSource:t,onCopy:n,copied:r,onZoom:i}){return c.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[i&&!e&&c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:i,children:c.jsx(cme,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:c.jsx(Xj,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":r?"Copied":"Copy diagram source",className:le("h-8 w-8 rounded-md text-muted-foreground",!r&&"hover:text-foreground",r&&"hover:!bg-transparent"),onClick:n,children:r?c.jsx(Ls,{className:"h-4 w-4 text-success"}):c.jsx(ja,{className:"h-4 w-4"})})]})}class If extends Xu{constructor(n,r,i=Nt){super(r);K(this,"__source");K(this,"__dom");this.__source=n,this.__dom=i}static getType(){return"kanna-mermaid"}static clone(n){return new If(n.__source,n.__key,n.__dom)}static importJSON(n){return $re(n.source)}exportJSON(){return{type:If.getType(),version:1,source:this.__source}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(n,r){return c.jsx(Lre,{source:this.__source})}}function $re(e){return pi(new If(e))}function L3e(e){return e instanceof If}function $3e(e,t=28){if(e.length<=t)return e;const n="…",r=e.lastIndexOf("."),i=r>0&&e.length-r<=6,s=i?e.slice(r):"",o=i?e.slice(0,r):e,a=t-n.length-s.length;if(a<=2){const f=t-n.length,h=Math.ceil(f/2),m=Math.floor(f/2);return`${e.slice(0,h)}${n}${e.slice(e.length-m)}`}const l=Math.ceil(a/2),u=a-l;return`${o.slice(0,l)}${n}${o.slice(o.length-u)}${s}`}const F3e=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),B3e=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function eC(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function rW(e){var r,i;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((r=t==null?void 0:t.groups)!=null&&r.path)return{path:t.groups.path,line:eC(t.groups.line),column:eC(t.groups.column)};const n=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(i=n==null?void 0:n.groups)!=null&&i.path?{path:n.groups.path,line:eC(n.groups.line),column:eC(n.groups.column)}:e.startsWith("/")?{path:e}:null}function z3e(e,t=Nt){if(!e)return null;const n=e.trim();if(!n||/^(mailto:|ftp:|file:)/i.test(n))return null;if(/^https?:/i.test(n))try{const r=new URL(n);return r.origin!==t.getOrigin()||!r.pathname.startsWith("/")?null:rW(`${r.pathname}${r.hash}`)}catch{return null}return rW(n)}function U3e(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const n=t.length>0?t[t.length-1]:e;if(B3e.has(n))return!0;const r=n.lastIndexOf(".");if(r<0)return!0;const i=n.slice(r).toLowerCase();return F3e.has(i)}const H3e=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function W3e(e){return e?e.startsWith("file://")?!0:H3e.some(t=>e.startsWith(t)):!1}function Fre(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function hf(e,t){if(!e)return"";if(t){const n=t.endsWith("/")?t:`${t}/`;if(e.startsWith(n))return e.slice(n.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function yb(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const Xx=Jt("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function V3e(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function K3e({path:e,linkText:t}){const n=_.useMemo(()=>Fre(e),[e]),r=Xx.useScopedStore(A=>A.probe),i=Xx.useScopedStore(A=>A.previewOpen),s=Xx.useScopedStore(A=>A.setProbe),o=Xx.useScopedStore(A=>A.setPreviewOpen);_.useEffect(()=>{const A=new AbortController;return o5(n,{signal:A.signal}).then(j=>{A.signal.aborted||s(j)}),()=>A.abort()},[n,s]);const a=V3e(e),l=t||a,u=$3e(l,28),f=r.kind==="ready"?r.mimeType:"application/octet-stream",h=r.kind==="ready"?r.size:0,m={id:`local-file-${n}`,kind:"file",displayName:u,absolutePath:e,relativePath:e,contentUrl:n,mimeType:f,size:h};if(r.kind==="missing")return c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,disabledReason:"File no longer available"})});const g=am(m),v=S0(g,f),x=h>0?lm(h):null,y=r.kind==="loading",w=r.kind==="error";let k;y?k=c.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):w?k=c.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):k=c.jsxs(c.Fragment,{children:[v,x?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:x})]}):null]});const C=r.kind==="ready"?fb(m):null,E=C!==null&&!C.openInNewTab,N=[E?"Preview":"Download",l,v,x].filter(A=>!!A);return E?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,onClick:()=>o(!0),meta:k,ariaLabel:N.join(", ")})}),c.jsx(pm,{source:i?yb(m,"local_file_link"):null,open:i,onOpenChange:o})]}):c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,href:n,download:a,meta:k,ariaLabel:N.join(", ")})})}function G3e({path:e,linkText:t}){return c.jsx(Xx.Provider,{init:void 0,children:c.jsx(K3e,{path:e,linkText:t})})}class Of extends Xu{constructor(n,r,i,s,o=Nt){super(s);K(this,"__path");K(this,"__line");K(this,"__column");K(this,"__dom");this.__path=n,this.__line=r,this.__column=i,this.__dom=o}static getType(){return"kanna-local-file-link"}static clone(n){return new Of(n.__path,n.__line,n.__column,n.__key,n.__dom)}static importJSON(n){return Bre({path:n.path,line:n.line,column:n.column})}exportJSON(){const n={type:Of.getType(),version:1,path:this.__path};return this.__line!==void 0&&(n.line=this.__line),this.__column!==void 0&&(n.column=this.__column),n}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(n,r){const i=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return c.jsx(G3e,{path:this.__path,linkText:i})}}function Bre(e){return pi(new Of(e.path,e.line,e.column))}function q3e(e){return e instanceof Of}class M_ extends Xu{constructor(n,r,i=Nt){super(r);K(this,"__content");K(this,"__dom");this.__content=n,this.__dom=i}static getType(){return"kanna-thinking"}static clone(n){return new M_(n.__content,n.__key,n.__dom)}static importJSON(n){return Y3e(n.content)}exportJSON(){return{type:M_.getType(),version:1,content:this.__content}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(n,r){return c.jsx(RN,{content:this.__content})}}function Y3e(e){return pi(new M_(e))}const X3e=[R_,j_,Wv],Q3e=[If,Of,M_],J3e=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,Z3e=/^[ \t]*`{3,}[ \t]*$/;function e$e(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function t$e(e,t,n){const r=e$e(n.length),i=[];let s=t;for(let o=t+1;o<e.length;o++){const a=e[o];if(a===void 0||(s=o,r.test(a)))break;i.push(a)}return{source:i.join(`
2743
+ `){o=!1,a=!1,s=!1,l.length=0,r+=1,n+=u,i+=1;continue}if(o){n+=u,i+=1;continue}if(s){u==='"'&&(s=!1),n+=u,i+=1;continue}if(u==='"'){s=!0,n+=u,i+=1;continue}if(e.startsWith("%%",i)){o=!0,n+="%%",i+=2;continue}if(l.length>0){u===l[l.length-1]?l.pop():Zw[u]&&l.push(Zw[u]),n+=u,i+=1;continue}if(Zw[u]){l.push(Zw[u]),n+=u,i+=1;continue}if(u==="|"){a=!a,n+=u,i+=1;continue}if(a){n+=u,i+=1;continue}const f=T3e.find(h=>e.startsWith(h.from,i));if(f){n+=f.to,t.push({line:r,from:f.from,to:f.to}),i+=f.from.length;continue}n+=u,i+=1}return{source:n,repairs:t}}const R3e=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function j3e(e){const t=e.message.toLowerCase();return R3e.some(n=>t.includes(n))}function M3e(e){let t=null;return()=>(t||(t=e().catch(n=>{throw t=null,s5(n)})),t)}const P3e=M3e(()=>Z(()=>import("./mermaid.core-B3dPZhst.js").then(e=>e.bm),[]).then(e=>e.default));async function I3e(e,t,n){try{const{svg:r}=await e.render(t,n);return{svg:r,repairs:[]}}catch(r){const i=A3e(n);if(i.repairs.length===0)throw r;try{const{svg:s}=await e.render(`${t}-repaired`,i.source);return{svg:s,repairs:i.repairs}}catch{throw r}}}function O3e(e){const t=[];for(const n of e){const r=`${n.from} → ${n.to}`;t.includes(r)||t.push(r)}return t.join(", ")}function D3e({source:e,ports:t}){const{resolvedTheme:n}=AN(),r=n==="dark"?"dark":"default",i=ru.useScopedStore(C=>C.renderState),s=i.status==="error"?i.message:void 0,o=i.status==="error"&&i.kind==="stale-chunk",a=ru.useScopedStore(C=>C.showSource),l=ru.useScopedStore(C=>C.zoomOpen),u=ru.useScopedStore(C=>C.copied),f=ru.useScopedStore(C=>C.setRenderState),h=ru.useScopedStore(C=>C.setShowSource),m=ru.useScopedStore(C=>C.setZoomOpen),g=ru.useScopedStore(C=>C.setCopied),x=`mermaid-${_.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=_.useCallback(()=>m(!1),[m]),w=async()=>{await((t==null?void 0:t.clipboard)??Ua).writeText(e),g(!0),((t==null?void 0:t.timer)??ar).setTimeout(()=>g(!1),2e3)},k=(t==null?void 0:t.loadMermaid)??P3e;if(_.useEffect(()=>{let C=!1;return k().then(async E=>{E.initialize({startOnLoad:!1,securityLevel:"strict",theme:r});const{svg:N,repairs:A}=await I3e(E,x,e);C||f({status:"ready",svg:N,repairs:A})}).catch(E=>{if(C)return;const N=s5(E);if(j3e(N)){f({status:"error",kind:"stale-chunk"});return}f({status:"error",message:N.message})}),()=>{C=!0}},[e,r,x,f,k]),o)return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(kf,{className:"size-3.5 shrink-0"}),c.jsx("span",{children:"This diagram needs the latest version of the app."}),c.jsxs(Re,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??Nt).reload(),children:[c.jsx(Z_,{className:"size-3 mr-1"}),"Reload"]})]}),c.jsx(Fw,{source:e})]});if(i.status==="error"){const C=N3e(s??"");return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[c.jsx(kf,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("span",{children:["Couldn't render this Mermaid diagram",C.line!==null?c.jsxs("span",{className:"text-muted-foreground",children:[" — line ",c.jsx("span",{className:"tabular-nums",children:C.line})]}):null]}),c.jsx("div",{className:"text-muted-foreground",children:C.summary}),C.excerpt?c.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:C.excerpt}):null]})]}),c.jsx(Fw,{source:e,highlightLine:C.line??void 0})]})}return i.status==="loading"?c.jsx("div",{className:"relative group/mermaid",children:c.jsx(Fw,{source:e})}):a?c.jsxs("div",{className:"relative group/mermaid",children:[c.jsx(Fw,{source:e}),c.jsx(nW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:void 0})]}):c.jsxs("div",{className:"relative group/mermaid my-3",children:[i.repairs.length>0&&c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(Fge,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("span",{children:["Corrected ",c.jsx("span",{className:"tabular-nums",children:i.repairs.length}),i.repairs.length===1?" invalid link":" invalid links"," to render this (",c.jsx("span",{className:"font-mono",children:O3e(i.repairs)}),"). The source is unchanged."]})]}),c.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:i.svg}}),c.jsx(nW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:()=>m(!0)}),l&&c.jsx(k3e,{svg:i.svg,onClose:y})]})}function Lre({source:e,ports:t}){return c.jsx(ru.Provider,{init:void 0,children:c.jsx(D3e,{source:e,ports:t})})}function nW({showSource:e,onToggleSource:t,onCopy:n,copied:r,onZoom:i}){return c.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[i&&!e&&c.jsx(Re,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:i,children:c.jsx(cme,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:c.jsx(Xj,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"icon","aria-label":r?"Copied":"Copy diagram source",className:le("h-8 w-8 rounded-md text-muted-foreground",!r&&"hover:text-foreground",r&&"hover:!bg-transparent"),onClick:n,children:r?c.jsx(Ls,{className:"h-4 w-4 text-success"}):c.jsx(ja,{className:"h-4 w-4"})})]})}class If extends Xu{constructor(n,r,i=Nt){super(r);K(this,"__source");K(this,"__dom");this.__source=n,this.__dom=i}static getType(){return"kanna-mermaid"}static clone(n){return new If(n.__source,n.__key,n.__dom)}static importJSON(n){return $re(n.source)}exportJSON(){return{type:If.getType(),version:1,source:this.__source}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(n,r){return c.jsx(Lre,{source:this.__source})}}function $re(e){return pi(new If(e))}function L3e(e){return e instanceof If}function $3e(e,t=28){if(e.length<=t)return e;const n="…",r=e.lastIndexOf("."),i=r>0&&e.length-r<=6,s=i?e.slice(r):"",o=i?e.slice(0,r):e,a=t-n.length-s.length;if(a<=2){const f=t-n.length,h=Math.ceil(f/2),m=Math.floor(f/2);return`${e.slice(0,h)}${n}${e.slice(e.length-m)}`}const l=Math.ceil(a/2),u=a-l;return`${o.slice(0,l)}${n}${o.slice(o.length-u)}${s}`}const F3e=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),B3e=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function eC(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function rW(e){var r,i;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((r=t==null?void 0:t.groups)!=null&&r.path)return{path:t.groups.path,line:eC(t.groups.line),column:eC(t.groups.column)};const n=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(i=n==null?void 0:n.groups)!=null&&i.path?{path:n.groups.path,line:eC(n.groups.line),column:eC(n.groups.column)}:e.startsWith("/")?{path:e}:null}function z3e(e,t=Nt){if(!e)return null;const n=e.trim();if(!n||/^(mailto:|ftp:|file:)/i.test(n))return null;if(/^https?:/i.test(n))try{const r=new URL(n);return r.origin!==t.getOrigin()||!r.pathname.startsWith("/")?null:rW(`${r.pathname}${r.hash}`)}catch{return null}return rW(n)}function U3e(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const n=t.length>0?t[t.length-1]:e;if(B3e.has(n))return!0;const r=n.lastIndexOf(".");if(r<0)return!0;const i=n.slice(r).toLowerCase();return F3e.has(i)}const H3e=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function W3e(e){return e?e.startsWith("file://")?!0:H3e.some(t=>e.startsWith(t)):!1}function Fre(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function hf(e,t){if(!e)return"";if(t){const n=t.endsWith("/")?t:`${t}/`;if(e.startsWith(n))return e.slice(n.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function yb(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const Xx=Jt("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function V3e(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function K3e({path:e,linkText:t}){const n=_.useMemo(()=>Fre(e),[e]),r=Xx.useScopedStore(A=>A.probe),i=Xx.useScopedStore(A=>A.previewOpen),s=Xx.useScopedStore(A=>A.setProbe),o=Xx.useScopedStore(A=>A.setPreviewOpen);_.useEffect(()=>{const A=new AbortController;return o5(n,{signal:A.signal}).then(j=>{A.signal.aborted||s(j)}),()=>A.abort()},[n,s]);const a=V3e(e),l=t||a,u=$3e(l,28),f=r.kind==="ready"?r.mimeType:"application/octet-stream",h=r.kind==="ready"?r.size:0,m={id:`local-file-${n}`,kind:"file",displayName:u,absolutePath:e,relativePath:e,contentUrl:n,mimeType:f,size:h};if(r.kind==="missing")return c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,disabledReason:"File no longer available"})});const g=am(m),v=S0(g,f),x=h>0?lm(h):null,y=r.kind==="loading",w=r.kind==="error";let k;y?k=c.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):w?k=c.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):k=c.jsxs(c.Fragment,{children:[v,x?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:x})]}):null]});const C=r.kind==="ready"?fb(m):null,E=C!==null&&!C.openInNewTab,N=[E?"Preview":"Download",l,v,x].filter(A=>!!A);return E?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,onClick:()=>o(!0),meta:k,ariaLabel:N.join(", ")})}),c.jsx(pm,{source:i?yb(m,"local_file_link"):null,open:i,onOpenChange:o})]}):c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(qo,{attachment:m,href:n,download:a,meta:k,ariaLabel:N.join(", ")})})}function G3e({path:e,linkText:t}){return c.jsx(Xx.Provider,{init:void 0,children:c.jsx(K3e,{path:e,linkText:t})})}class Of extends Xu{constructor(n,r,i,s,o=Nt){super(s);K(this,"__path");K(this,"__line");K(this,"__column");K(this,"__dom");this.__path=n,this.__line=r,this.__column=i,this.__dom=o}static getType(){return"kanna-local-file-link"}static clone(n){return new Of(n.__path,n.__line,n.__column,n.__key,n.__dom)}static importJSON(n){return Bre({path:n.path,line:n.line,column:n.column})}exportJSON(){const n={type:Of.getType(),version:1,path:this.__path};return this.__line!==void 0&&(n.line=this.__line),this.__column!==void 0&&(n.column=this.__column),n}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(n,r){const i=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return c.jsx(G3e,{path:this.__path,linkText:i})}}function Bre(e){return pi(new Of(e.path,e.line,e.column))}function q3e(e){return e instanceof Of}class M_ extends Xu{constructor(n,r,i=Nt){super(r);K(this,"__content");K(this,"__dom");this.__content=n,this.__dom=i}static getType(){return"kanna-thinking"}static clone(n){return new M_(n.__content,n.__key,n.__dom)}static importJSON(n){return Y3e(n.content)}exportJSON(){return{type:M_.getType(),version:1,content:this.__content}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(n,r){return c.jsx(RN,{content:this.__content})}}function Y3e(e){return pi(new M_(e))}const X3e=[R_,j_,Wv],Q3e=[If,Of,M_],J3e=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,Z3e=/^[ \t]*`{3,}[ \t]*$/;function e$e(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function t$e(e,t,n){const r=e$e(n.length),i=[];let s=t;for(let o=t+1;o<e.length;o++){const a=e[o];if(a===void 0||(s=o,r.test(a)))break;i.push(a)}return{source:i.join(`
2744
2744
  `),lastLineIndex:s}}const n$e={type:"multiline-element",dependencies:[If],regExpStart:J3e,regExpEnd:{optional:!0,regExp:Z3e},handleImportAfterStartMatch({lines:e,rootNode:t,startLineIndex:n,startMatch:r}){const{source:i,lastLineIndex:s}=t$e(e,n,r[1]??"```");return t.append($re(i)),[!0,s]},replace(e,t,n,r,i,s){return!1},export(e){return e instanceof If?`\`\`\`mermaid
2745
2745
  ${e.getTextContent()}
2746
2746
  \`\`\``:null}},zre="(?:file://|/(?:Users|home|private|tmp|var|opt|root)/)",r$e=new RegExp(`\\[(.+?)\\]\\((${zre}[^)\\s]*)\\)`),i$e=new RegExp(`\\[([^[\\]]+)\\]\\((${zre}[^)\\s]*)\\)$`),s$e={type:"text-match",dependencies:[Of],importRegExp:r$e,regExp:i$e,trigger:")",replace(e,t){const n=t[2];if(!n)return;const r=z3e(n);if(!r||!W3e(r.path)&&!n.startsWith("/"))return;const i=Bre({path:r.path,line:r.line,column:r.column});e.replace(i)},export(e){if(!(e instanceof Of))return null;const t=e.getTextContent();return`[${t}](${t})`}},o$e=[n$e,s$e,...Rre],a$e=[xb,bb,Zu,_c,vb,L0,Uf,kN,Bu,hm,fc,...Q3e];let Ure=0;function ai(){return String(Ure++)}let Ig=null,Og=null;function Hre(e){if(L3e(e)&&Ig&&Og)return c.jsx("span",{children:e.decorate(Ig,Og)},ai());if(q3e(e)&&Ig&&Og)return c.jsx("span",{children:e.decorate(Ig,Og)},ai());if(r3(e)){const n=e.getTag(),r=Md(e),i={h1:"text-[20px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h2:"text-[18px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h3:"text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h4:"text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h5:"text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h6:"text-[16px] font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0"},s=i[n]??i.h1,o=ai();switch(n){case"h1":return c.jsx("h1",{className:s,children:r},o);case"h2":return c.jsx("h2",{className:s,children:r},o);case"h3":return c.jsx("h3",{className:s,children:r},o);case"h4":return c.jsx("h4",{className:s,children:r},o);case"h5":return c.jsx("h5",{className:s,children:r},o);default:return c.jsx("h6",{className:s,children:r},o)}}if(T_(e))return c.jsx("blockquote",{className:"my-2 mt-5 mb-3 first:mt-0 last:mb-0 border-l-2 border-border/80 pl-2 text-muted-foreground",children:Md(e)},ai());if(Ha(e))return c.jsx("p",{className:"break-words mt-5 mb-3 first:mt-0 last:mb-0",children:Md(e)},ai());if(D0(e)){const n=e.getLanguage()??"",r=e.getChildren().map(i=>Fe(i)||zv(i)?i.getTextContent():hi(i)?`
@@ -2823,7 +2823,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2823
2823
  `),r=t.split(`
2824
2824
  `),i=hKe(n,r),s=pKe(n,r,i);return mKe(s)}function hKe(e,t){const n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=1;s<=n;s++)for(let o=1;o<=r;o++)i[s][o]=e[s-1]===t[o-1]?i[s-1][o-1]+1:Math.max(i[s-1][o],i[s][o-1]);return i}function pKe(e,t,n){const r=[];let i=e.length,s=t.length;for(;i>0||s>0;)i>0&&s>0&&e[i-1]===t[s-1]?(r.push({type:"context",text:e[i-1],oldIdx:i,newIdx:s}),i--,s--):s>0&&(i===0||n[i][s-1]>=n[i-1][s])?(r.push({type:"added",text:t[s-1],oldIdx:i,newIdx:s}),s--):(r.push({type:"removed",text:e[i-1],oldIdx:i,newIdx:s}),i--);return r.reverse()}function mKe(e){return e.map(t=>{let n;return t.type==="removed"?n="-":t.type==="added"?n="+":n=" ",{type:t.type,content:`${n}${t.text}`}})}function SC({content:e,isDiff:t=!1,oldString:n,newString:r}){const i=_.useMemo(()=>t&&n!==void 0&&r!==void 0?fKe(n,r):[],[t,n,r]),s=_.useMemo(()=>t?[]:uKe(e),[e,t]),o=_.useMemo(()=>s.some(a=>a.lineNumber!==null),[s]);return t&&i.length>0?c.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:c.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:c.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:c.jsx("tbody",{children:i.map((a,l)=>{let u;a.type==="removed"?u="bg-destructive/10 dark:bg-destructive/15":a.type==="added"?u="bg-success/10 dark:bg-success/15":u="";let f;a.type==="removed"?f="text-destructive":a.type==="added"?f="text-success":f="text-foreground";let h;a.type==="removed"?h="text-destructive/50":a.type==="added"?h="text-success/50":h="text-muted-foreground/50";let m;return a.type==="removed"?m="-":a.type==="added"?m="+":m=" ",c.jsxs("tr",{className:u,children:[c.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${h}`,children:m}),c.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${f}`,children:a.content.slice(1)})]},l)})})})})}):c.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:c.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:c.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:c.jsx("tbody",{children:s.map((a,l)=>c.jsxs("tr",{children:[o&&c.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:a.lineNumber!==null?a.lineNumber:""}),c.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:dKe(a.content)})]},l))})})})})}function hae({tone:e,label:t,pulse:n=!1}){return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide",children:[c.jsx("span",{"aria-hidden":!0,className:le("inline-block size-1.5 rounded-full",KY(e),n&&"animate-pulse")}),c.jsx("span",{className:zy(e),children:t})]})}function K3({status:e,pulse:t=!1}){return c.jsx(hae,{tone:GY(e),label:z_e(e),pulse:t&&e==="running"})}function gKe(){return c.jsx("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"started…"})}function vKe({name:e,description:t,run:n}){const r=e??"Workflow";return c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(mu,{className:"size-4 text-muted-icon shrink-0"}),c.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[c.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:r}),t&&c.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t}),n?c.jsxs(c.Fragment,{children:[c.jsx(K3,{status:n.status}),n.agentCount!=null&&n.agentCount>0&&c.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[n.agentCount," agents"]})]}):c.jsx(gKe,{})]})]})}const pae=_.createContext(null);function mae({children:e,value:t}){return c.jsx(pae.Provider,{value:t,children:e})}function bKe(){return _.useContext(pae)}const xKe=[],Qa=Jt("SubagentTaskMessage",()=>e=>({expanded:!1,loading:!1,loaded:!1,children:xKe,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function yKe(e,t){return t||e==="failed"||e==="error"?"destructive":e==="in_progress"||e==="running"?"active":"muted"}function _Ke(e){if(!e)return"";const t=[],n=(r,i,s)=>{r&&r>0&&t.push(`${r} ${r===1?i:s}`)};return n(e.readCount,"read","reads"),n(e.editFileCount,"edit","edits"),n(e.bashCount,"cmd","cmds"),n(e.searchCount,"search","searches"),n(e.otherToolCount,"tool","tools"),t.join(" · ")}function SKe({subagentType:e,result:t,isError:n,localPath:r}){const i=e||"Agent",s=yKe(t==null?void 0:t.status,n),o=_Ke(t==null?void 0:t.toolStats),a=bKe(),l=t==null?void 0:t.agentId,u=!!(a&&l),f=Qa.useScopedStore(A=>A.expanded),h=Qa.useScopedStore(A=>A.loading),m=Qa.useScopedStore(A=>A.loaded),g=Qa.useScopedStore(A=>A.children),v=Qa.useScopedStore(A=>A.error),x=Qa.useScopedStore(A=>A.setExpanded),y=Qa.useScopedStore(A=>A.setLoading),w=Qa.useScopedStore(A=>A.setLoaded),k=Qa.useScopedStore(A=>A.setChildren),C=Qa.useScopedStore(A=>A.setError),E=_.useCallback(()=>{if(!a||!l)return;const A=!f;x(A),A&&!m&&!h&&(y(!0),C(null),a(l).then(j=>{k($N(j)),w(!0)}).catch(j=>C(j instanceof Error?j.message:"Failed to load subagent transcript")).finally(()=>y(!1)))},[a,l,f,m,h,x,y,C,k,w]),N=c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u?c.jsx(Ra,{className:le("size-4 text-muted-icon shrink-0 transition-transform",f&&"rotate-90"),"aria-hidden":!0}):c.jsx(cE,{className:"size-4 text-muted-icon shrink-0"}),c.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[c.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:i}),(t==null?void 0:t.status)&&c.jsx(hae,{tone:s,label:t.status}),(t==null?void 0:t.totalTokens)!=null&&t.totalTokens>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums",children:[c.jsx(Dy,{className:"size-3","aria-hidden":!0}),bo(t.totalTokens)," tokens"]}),(t==null?void 0:t.totalDurationMs)!=null&&t.totalDurationMs>0&&c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:js(t.totalDurationMs)}),o&&c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums truncate",children:o}),h&&c.jsx(Mn,{className:"size-3 animate-spin text-muted-foreground","aria-label":"Loading"})]})]});return u?c.jsxs("div",{className:"min-w-0",children:[c.jsx("button",{type:"button",onClick:E,"aria-expanded":f,className:"w-full text-left cursor-pointer",children:N}),f&&c.jsxs("div",{className:"mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2",children:[v&&c.jsx("div",{className:"text-xs text-destructive",children:v}),!v&&m&&g.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground",children:"No subagent activity recorded."}),g.map(A=>c.jsx(G3,{message:A,localPath:r??""},A.id))]})]}):N}function wKe({subagentType:e,result:t,isError:n,localPath:r}){return c.jsx(Qa.Provider,{init:void 0,children:c.jsx(SKe,{subagentType:e,result:t,isError:n,localPath:r})})}function OV(e){let t;return Pr(e)&&Array.isArray(e.content)?t=e.content:Array.isArray(e)?t=e:t=[],t.flatMap(n=>!n||typeof n!="object"||!("type"in n)||n.type!=="image"?[]:"data"in n&&typeof n.data=="string"?[{type:"image",data:n.data,mimeType:"mimeType"in n&&typeof n.mimeType=="string"?n.mimeType:void 0}]:"source"in n&&n.source&&typeof n.source=="object"&&"type"in n.source&&n.source.type==="base64"&&"data"in n.source&&typeof n.source.data=="string"?[{type:"image",data:n.source.data,mimeType:"media_type"in n.source&&typeof n.source.media_type=="string"?n.source.media_type:void 0}]:[])}function CKe({images:e}){return c.jsx("div",{className:"flex flex-col gap-3",children:e.map((t,n)=>{const r=t.mimeType||"image/png";return c.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-muted/20",children:c.jsx("img",{src:`data:${r};base64,${t.data}`,alt:`Read result ${n+1}`,className:"max-h-[50vh] w-full object-contain bg-background"})},`${r}:${n}`)})})}function Zk({message:e,isLoading:t=!1,localPath:n,chatId:r=""}){var N;const i=e.result!==void 0,s=!i&&t,o=FN(bp(L3(r))),a=_.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill;if(e.toolKind==="glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolKind==="grep"){const A=e.input.pattern,j=e.input.outputMode;return j==="count"?`Count \`${A}\` occurrences`:j==="content"?`Find \`${A}\` in text`:`Find \`${A}\` in files`}return e.toolKind==="bash"?e.input.description||(e.input.command?HY(e.input.command):"Bash"):e.toolKind==="web_search"?e.input.query||"Web Search":e.toolKind==="read_file"?`Read ${hf(e.input.filePath,n)}`:e.toolKind==="write_file"?`Write ${hf(e.input.filePath,n)}`:e.toolKind==="edit_file"?`Edit ${hf(e.input.filePath,n)}`:e.toolKind==="delete_file"?`Delete ${hf(e.input.filePath,n)}`:e.toolKind==="mcp_generic"?`${lM(e.input.tool)} from ${lM(e.input.server)}`:e.toolKind==="subagent_task"?e.input.subagentType||e.toolName:e.toolKind==="workflow"?e.input.name??"Workflow":e.toolName},[e.input,e.toolKind,e.toolName,n]),l=_.useMemo(()=>e.toolKind==="subagent_task",[e.toolKind]),u=_.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill},[e.input,e.toolKind]),f=e.toolKind==="bash",h=e.toolKind==="write_file",m=e.toolKind==="edit_file",g=e.toolKind==="delete_file",v=e.toolKind==="read_file",x=_.useMemo(()=>{if(typeof e.result=="string")return e.result;if(!e.result)return"";if(Pr(e.result)){const A=e.result.content;if(typeof A=="string")return A}return JSON.stringify(e.result,null,2)},[e.result]),y=_.useMemo(()=>{if(!v)return[];if(Pr(e.result)){const A=e.result.blocks;if(Array.isArray(A)){const j=OV(A);if(j.length>0)return j}}return OV(e.rawResult)},[v,e.rawResult,e.result]),w=_.useMemo(()=>{switch(e.toolKind){case"bash":return e.input.command;case"write_file":case"delete_file":return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]);let k;f?k=c.jsxs("span",{className:"flex items-center gap-2 w-full",children:[c.jsx("span",{children:"Command"}),!!e.input.timeoutMs&&c.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeoutMs),"ms"]}),!!e.input.runInBackground&&c.jsx("span",{className:"text-muted-foreground",children:"background"})]}):h?k="Contents":k="Input";let C;m?C=c.jsx(SC,{content:"",isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):g?C=c.jsx(SC,{content:e.input.content}):!v&&!h?C=c.jsx(tP,{label:k,copyText:w,children:w}):C=null;let E;if(e.toolKind==="workflow"&&!e.isError){const A=Pr(e.result)&&typeof e.result.text=="string"?{taskId:typeof e.result.taskId=="string"?e.result.taskId:void 0,text:e.result.text}:void 0,j=A==null?void 0:A.taskId,P=j?o.find(M=>M.taskId===j):void 0;E=c.jsx(vKe,{name:e.input.name,description:e.input.description,run:P})}else e.toolKind==="subagent_task"&&e.result?E=c.jsx(wKe,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:n}):E=c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:e.isError?c.jsx(ts,{className:"size-4 text-destructive"}):l?c.jsx(cE,{className:"size-4 text-muted-icon"}):e.toolKind==="workflow"?c.jsx(mu,{className:"size-4 text-muted-icon"}):c.jsx(cee,{icon:lee(e.toolName),className:"size-4 text-muted-icon"})}),c.jsx(Rp,{className:"text-left transition-opacity duration-200 truncate",children:c.jsx(V0,{animate:s,shimmerWidth:Math.max(20,(((N=u||a)==null?void 0:N.length)??33)*3),children:u||a})})]});return c.jsx(qu,{className:"w-full",children:c.jsx(l5,{expandedContent:c.jsx(eN,{className:"my-4 text-sm",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[C,i&&v&&!e.isError&&(y.length>0?c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-muted-foreground",children:"Image"}),c.jsx("div",{className:"mt-1",children:c.jsx(CKe,{images:y})})]}):c.jsx(SC,{content:x})),h&&!e.isError&&c.jsx(SC,{content:e.input.content}),i&&!v&&!(h&&!e.isError)&&!(m&&!e.isError)&&!(g&&!e.isError)&&c.jsx(tP,{label:e.isError?"Error":"Result",copyText:x,children:x})]})}),children:E})})}const gae={serverOverloaded:"transient",internalServerError:"transient",httpConnectionFailed:"transient",responseStreamConnectionFailed:"transient",responseStreamDisconnected:"transient",responseTooManyFailedAttempts:"transient",usageLimitExceeded:"quota",sessionBudgetExceeded:"quota",unauthorized:"auth",contextWindowExceeded:"fatal",badRequest:"fatal",cyberPolicy:"fatal",sandboxError:"fatal",threadRollbackFailed:"fatal",activeTurnNotSteerable:"fatal",other:"unknown"},DV=new Set(["httpConnectionFailed","responseStreamConnectionFailed","responseStreamDisconnected","responseTooManyFailedAttempts","activeTurnNotSteerable"]);function EO(e){return e in gae}function kKe(e){if(e==null)return null;if(typeof e=="string")return EO(e)&&!DV.has(e)?e:null;if(typeof e!="object")return null;const t=Object.keys(e);if(t.length!==1)return null;const[n]=t;return DV.has(n)&&EO(n)?n:null}function vae(e){return typeof e=="string"?EO(e)?e:null:kKe(e)}function EKe(e){const t=vae(e);return t===null?"unknown":gae[t]}function NKe(e){return EKe(e)==="transient"}const TKe={serverOverloaded:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`,internalServerError:e=>`${e} hit a server-side error. Retrying usually clears it.`,httpConnectionFailed:()=>"Could not reach the model provider. Check your connection, then retry.",responseStreamConnectionFailed:()=>"The response stream failed to connect. Retry to start a new stream.",responseStreamDisconnected:()=>"The response stream disconnected mid-turn. Retry to pick up from where it stopped.",responseTooManyFailedAttempts:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`,usageLimitExceeded:()=>"You have reached your Codex usage limit. Access returns when the limit window resets.",sessionBudgetExceeded:()=>"This session reached its configured token budget.",unauthorized:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`.",contextWindowExceeded:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`,badRequest:()=>"Codex rejected the request as malformed.",cyberPolicy:()=>"Codex declined this request under its usage policy.",sandboxError:()=>"The Codex sandbox failed to run the requested command.",threadRollbackFailed:()=>"Codex could not roll the conversation back to the requested point.",activeTurnNotSteerable:()=>"The running turn cannot accept new input. Wait for it to finish, or stop it."},AKe="The selected model";function RKe(e,t){const n=vae(e);if(n===null)return null;const r=TKe[n];return r===void 0?null:r(AKe)}const S1=Jt("TranscriptActionCard",()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),jKe={neutral:"border-border bg-card",muted:"border-border/50 bg-card/50 opacity-75",success:"border-emerald-500/30 bg-emerald-500/5",error:"border-destructive/40 bg-destructive/5"},MKe={primary:"default",secondary:"secondary",ghost:"ghost",destructive:"destructive"};function Kl(e){return c.jsx(S1.Provider,{init:void 0,children:c.jsx(PKe,{...e})})}function PKe({title:e,description:t,body:n,errorMessage:r,tone:i="neutral",actions:s=[]}){const o=S1.useScopedStore(h=>h.busyId),a=S1.useScopedStore(h=>h.actionError),l=S1.useScopedStoreApi(),u=_.useCallback(async h=>{const m=l.getState();if(m.busyId)return;m.setActionError(null);let g;try{g=h.onClick()}catch(v){Os.error("[transcript-action-card] sync click threw",String(v)),l.getState().setActionError(v instanceof Error?v.message:String(v));return}if(g instanceof Promise){m.setBusyId(h.id);try{await g}catch(v){Os.error("[transcript-action-card] async click rejected",String(v)),l.getState().setActionError(v instanceof Error?v.message:String(v))}finally{l.getState().setBusyId(null)}}},[l]),f=o!==null;return c.jsxs("div",{"data-focus-fallback-ignore":!0,className:le("rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors",jKe[i]),children:[c.jsx("div",{className:"flex items-start justify-between gap-3",children:c.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[c.jsx("div",{className:"font-medium leading-tight",children:e}),t?c.jsx("div",{className:"text-muted-foreground text-xs leading-snug",children:t}):null]})}),n?c.jsx("div",{className:"text-xs leading-snug",children:n}):null,r?c.jsx("div",{className:"text-destructive text-xs leading-snug",children:r}):null,a?c.jsx("div",{className:"text-destructive text-xs leading-snug",role:"alert",children:a}):null,s.length>0?c.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:s.map(h=>{const m=o===h.id;return c.jsxs(Re,{type:"button",size:"sm",variant:MKe[h.variant??"ghost"],disabled:h.disabled||f&&!m,onClick:()=>{u(h)},className:"gap-1.5",children:[m?c.jsx(Mn,{className:"size-3.5 animate-spin"}):null,h.label]},h.id)})}):null]})}function IKe(e){if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:""}`:r>0?`${r}m${i>0?` ${i}s`:""}`:`${i}s`}function LV({durationMs:e,prefix:t="Worked for"}){return e<=0?null:c.jsxs(tPe,{children:[t," ",IKe(e)]})}const fj=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function bae(e,t){const n=[];let r=0,i=0;fj.lastIndex=0;for(let s=fj.exec(e);s!==null;s=fj.exec(e))s.index>r&&n.push(e.slice(r,s.index)),n.push(c.jsx(X_,{to:`/chat/${s[2]}`,className:"underline decoration-destructive/40 hover:decoration-destructive",children:s[1]},`chat-link-${i++}`)),r=s.index+s[0].length;return r<e.length&&n.push(e.slice(r)),n.length===0?e:n}function OKe({resultMessageId:e,body:t,onRetry:n}){const i=[{id:"retry",label:"Retry",variant:"primary",onClick:_.useCallback(()=>n(e),[n,e])}];return c.jsx("div",{className:"mx-2 my-1",children:c.jsx(Kl,{title:"Turn failed",tone:"error",body:t,actions:i})})}function xae({message:e,onRetry:t}){if(!e.success){const n=e.codexErrorInfo,r=(n?RKe(n):null)??e.result??"",i=r.trim().length>0,s=n!==void 0&&NKe(n);let o=null;return s&&t?o=c.jsx(OKe,{resultMessageId:e.id,body:r,onRetry:t}):i&&(o=c.jsx("div",{className:"px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap",children:bae(r)})),c.jsxs(c.Fragment,{children:[o,e.durationMs>0?c.jsx(LV,{durationMs:e.durationMs,prefix:"Failed after"}):null]})}return c.jsx(LV,{durationMs:e.durationMs})}function DKe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function LKe(e){return typeof e=="string"?e:JSON.stringify(e,null,2)}function $Ke(e){return e.replace(/<persisted-output>\n?/g,"").replace(/\n?<\/persisted-output>/g,"")}function G3({message:e,localPath:t,isRunning:n=!1}){if(e.kind==="tool"&&e.persisted){const i=$Ke(LKe(e.rawResult??""));return c.jsxs("div",{className:"animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs",children:[c.jsxs("div",{className:"font-medium",children:[e.toolName,": output too large (",DKe(e.persisted.originalSize),") — saved to disk"]}),c.jsx("pre",{className:"text-[11px] whitespace-pre-wrap overflow-hidden max-h-48",children:i}),c.jsxs("a",{href:Fre(e.persisted.filePath),className:"text-blue-500 hover:underline break-all",target:"_blank",rel:"noreferrer",children:["View full output (",e.persisted.filePath,")"]})]})}let r;switch(e.kind){case"assistant_text":r=c.jsx(dae,{message:e});break;case"assistant_thinking":r=c.jsx(fae,{message:e});break;case"tool":r=c.jsx(Zk,{message:e,isLoading:n,localPath:t});break;case"result":r=c.jsx(xae,{message:e});break;default:return null}return c.jsx("div",{className:"animate-in fade-in-0 duration-200",children:r})}function FKe(e){switch(e){case"AUTH_REQUIRED":return"Auth required";case"UNKNOWN_SUBAGENT":return"Unknown subagent";case"MANUAL_ONLY":return"Manual only";case"LOOP_DETECTED":return"Loop detected";case"DEPTH_EXCEEDED":return"Depth exceeded";case"TIMEOUT":return"Timeout";case"PROVIDER_ERROR":return"Provider error";case"INTERRUPTED":return"Interrupted";case"USER_CANCELLED":return"Cancelled by you";default:return"Error"}}function BKe({error:e,runId:t,onRetry:n,onOpenSettings:r}){const i=e.code==="TIMEOUT"||e.code==="PROVIDER_ERROR",s=e.code==="AUTH_REQUIRED";return c.jsxs("div",{"data-testid":`subagent-error:${t}`,className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 font-medium text-destructive",children:[c.jsx(kf,{className:"h-4 w-4"}),c.jsx("span",{children:FKe(e.code)})]}),c.jsx("p",{className:"mt-1 text-foreground",children:e.message}),c.jsxs("div",{className:"mt-2 flex gap-2",children:[s&&r&&c.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 text-xs underline",children:[c.jsx(HG,{className:"h-3 w-3"})," Open settings"]}),i&&n&&c.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1 text-xs underline",children:[c.jsx(Hme,{className:"h-3 w-3"})," Retry"]})]})]})}const yae={readonly:!1,localLinkMode:"open",askUserQuestionSurface:"inline"},_ae=_.createContext(yae);function NO({children:e,value:t}){const n=_.useMemo(()=>({...yae,...t}),[t]);return c.jsx(_ae.Provider,{value:n,children:e})}function q3(){return _.useContext(_ae)}const Mh=Jt("AskUserQuestionInteractive",()=>e=>({currentIndex:0,answers:{},customInputs:{},setCurrentIndex:t=>e({currentIndex:t}),setAnswers:t=>e({answers:t}),setCustomInputs:t=>e({customInputs:t})}));function zKe({question:e,header:t,currentIndex:n,totalQuestions:r,onBack:i,children:s}){const o=i&&n>0,a=o||r>1||!!t;let l;return o?l=c.jsx("button",{onClick:i,className:"text-muted-foreground hover:opacity-60 transition-all flex items-center",children:c.jsx(Mhe,{className:"h-4 w-4 -ml-0.5",strokeWidth:3})}):r>1?l=c.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground whitespace-nowrap",children:[n+1," of ",r]}):l=null,c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:"p-3 px-4 bg-card border-b border-border",children:[a&&c.jsxs("div",{className:"flex flex-row items-center gap-2 mb-1",children:[l,t?c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:t}):null]}),c.jsx("h3",{className:"font-medium text-foreground text-sm text-pretty",children:e})]}),r>1&&c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-border",children:c.jsx("div",{className:"h-full bg-muted-foreground/40 transition-all duration-300",style:{width:`${n/r*100}%`}})})]}),s]})}function $V({label:e,description:t}){return c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-foreground text-sm",children:e}),t&&c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]})}function Sae({selected:e,multiSelect:t,onClick:n}){const r=le("flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center",t?"rounded":"rounded-full",e?"border-transparent bg-foreground":"border-muted-foreground/50 bg-background",n&&e&&"cursor-pointer"),i=e?c.jsx(Ls,{strokeWidth:3,className:"translate-y-[0.5px] h-3 w-3 text-white dark:text-background"}):null;return n?c.jsx("button",{type:"button",onClick:n,className:r,children:i}):c.jsx("div",{"aria-hidden":!0,className:r,children:i})}function UKe({option:e,selected:t,multiSelect:n,onClick:r,isLast:i}){const s="w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background",o=i?"":"border-b border-border";return r?c.jsx("button",{onClick:r,className:le(s,o,"transition-all cursor-pointer"),children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx($V,{label:e.label,description:e.description})}),c.jsx(Sae,{selected:t,multiSelect:n})]})}):c.jsx("div",{className:le(s,o),children:c.jsx($V,{label:e.label,description:e.description})})}function HKe({questions:e,onSubmit:t,onCancel:n,ports:r={}}){var W;const i=r.timer??ar,s=Mh.useScopedStore(D=>D.currentIndex),o=Mh.useScopedStore(D=>D.answers),a=Mh.useScopedStore(D=>D.customInputs),l=Mh.useScopedStore(D=>D.setCurrentIndex),u=Mh.useScopedStore(D=>D.setAnswers),f=Mh.useScopedStore(D=>D.setCustomInputs);if(e.length===0)return null;const h=D=>D.id||D.question,m=(D,B)=>{var H;const I=(H=a[D])==null?void 0:H.trim(),V=o[D]||"",z=B||e.find($=>h($)===D);if(z!=null&&z.multiSelect)return[V,I].filter(Boolean).flatMap($=>$.split(", ").filter(Boolean));const U=I||V;return U?[U]:[]},g=D=>{const B=o[h(D)]||"";return D.multiSelect?B.split(", ").filter(Boolean):[B]},v=(D,B)=>{const I=h(D);if(D.multiSelect){const V=o[I]?o[I].split(", ").filter(Boolean):[],z=V.includes(B)?V.filter(U=>U!==B):[...V,B];u({...o,[I]:z.join(", ")})}else u({...o,[I]:B}),f({...a,[I]:""}),s<e.length-1&&i.setTimeout(()=>l(s+1),150)},x=(D,B)=>{const I=h(D);f({...a,[I]:B}),B&&!D.multiSelect&&u({...o,[I]:""})},y=D=>{const B=h(D);D.multiSelect&&a[B]&&f({...a,[B]:""})},w=e.every(D=>m(h(D),D).length>0),k=e[Math.min(s,e.length-1)],C=s>=e.length-1,E=m(h(k),k).length>0,N=()=>{s<e.length-1&&l(s+1)},A=()=>{s>0&&l(s-1)},j=()=>{if(!w)return;const D={};for(const B of e){const I=h(B);D[I]=m(I,B)}t(D)},P=D=>{if(D.key==="Enter"&&E){if(D.preventDefault(),C){j();return}N()}},M=g(k),F=a[h(k)]||"";return c.jsxs("div",{className:"w-full space-y-3",children:[c.jsxs(zKe,{question:k.question,header:k.header,currentIndex:s,totalQuestions:e.length,onBack:s>0?A:void 0,children:[(W=k.options)==null?void 0:W.map(D=>c.jsx(UKe,{option:D,selected:M.includes(D.label),multiSelect:k.multiSelect,onClick:()=>v(k,D.label)},D.label)),c.jsx("div",{className:"transition-all bg-background",children:c.jsxs("div",{className:"flex pr-5 items-center justify-between gap-3",children:[c.jsx("input",{type:"text",value:F,onChange:D=>x(k,D.target.value),onKeyDown:P,placeholder:"Other...",className:"flex-1 px-3 !py-1 pl-4 min-h-[55px] min-w-0 text-sm bg-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-md text-foreground placeholder:text-muted-foreground"}),c.jsx(Sae,{selected:!!F,multiSelect:k.multiSelect,onClick:k.multiSelect&&F?()=>y(k):void 0})]})})]}),c.jsxs("div",{className:"flex items-center mx-2",children:[n?c.jsx(Re,{size:"sm",variant:"outline",className:"rounded-full",onClick:n,children:"Cancel"}):null,c.jsxs("div",{className:"ml-auto flex gap-2",children:[!C&&E&&(k.multiSelect||!!F)&&c.jsx(Re,{size:"sm",onClick:N,children:"Next"}),C&&c.jsx(Re,{size:"sm",onClick:j,disabled:!w,className:le(!w&&"opacity-50 cursor-not-allowed","rounded-full"),children:"Submit"})]})]})]})}function wae({questions:e,onSubmit:t,onCancel:n,ports:r}){return c.jsx(Mh.Provider,{init:void 0,children:c.jsx(HKe,{questions:e,onSubmit:t,onCancel:n,ports:r})})}function WKe({savedAnswers:e,isComplete:t}){return n=>({submittedAnswers:e??null,isSubmitted:t,submitError:null,markSubmitted:r=>n({submittedAnswers:r,isSubmitted:!0,submitError:null}),markSubmitFailed:r=>n(i=>i.isSubmitted||i.submitError!==r?{isSubmitted:!1,submitError:r}:i)})}const Eg=Jt("AskUserQuestionMessage",WKe);function Cae(e){return e==null?void 0:e.answers}function TO(e){return e.id||e.question}function FV({questions:e,statusLabel:t,testId:n}){return c.jsx("div",{className:"w-full","data-testid":n,children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between gap-3",children:[c.jsxs("p",{children:["Question",e.length!==1?"s":""]}),c.jsx("p",{className:"text-muted-foreground",children:t})]}),e.map((r,i)=>{var s;return c.jsxs("div",{className:le("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3",i<e.length-1&&"border-b border-border"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[r.header&&c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:r.header}),c.jsx("div",{className:"text-sm text-pretty",children:r.question})]}),c.jsx("div",{className:"max-w-[50%] text-right text-xs text-muted-foreground text-pretty",children:((s=r.options)==null?void 0:s.map(o=>o.label).join(", "))||"Freeform response"})]},TO(r))})]})})}function VKe({message:e,onSubmit:t,isLatest:n}){var v;const r=q3(),i=e.input.questions,s=!!e.result,o=Cae(e.result),a=((v=e.result)==null?void 0:v.discarded)===!0,l=Eg.useScopedStore(x=>x.submittedAnswers),u=Eg.useScopedStore(x=>x.isSubmitted),f=Eg.useScopedStore(x=>x.markSubmitted),h=Eg.useScopedStore(x=>x.markSubmitFailed),m=Eg.useScopedStore(x=>x.submitError),g=_.useCallback(x=>{f(x);try{const y=t(e.toolId,i,x);y&&typeof y.then=="function"&&y.catch(w=>{h(gs(w))})}catch(y){h(gs(y))}},[f,h,t,e.toolId,i]);if(u||s){const x=o||l||{};return c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between",children:[c.jsxs("p",{children:["Question",i.length!==1?"s":""]}),c.jsx("p",{className:"",children:a?"Discarded":"Answers"})]}),i.map((y,w)=>{const k=x[TO(y)]||x[y.question]||[],C=w===i.length-1,E=y.options?k.map(N=>{var A,j;return(j=(A=y.options)==null?void 0:A.find(P=>P.label===N))==null?void 0:j.description}).filter(N=>!!N):[];return c.jsxs("div",{className:le("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3",!C&&"border-b border-border"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[y.header&&c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:y.header}),c.jsx("div",{className:"text-sm text-pretty",children:y.question})]}),c.jsx("div",{className:"max-w-[50%] text-right",children:k.length>0?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium text-pretty",children:k.join(", ")}),E.length>0&&c.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 text-pretty",children:E.join(" · ")})]}):c.jsx("div",{className:"text-sm font-medium italic",children:a?"Discarded":"No Response"})})]},TO(y))})]})})}return r.readonly?c.jsx(FV,{questions:i,statusLabel:"Awaiting response"}):n?r.askUserQuestionSurface==="footer"?c.jsx(FV,{questions:i,statusLabel:"Answer below",testId:`ask-user-question-moved:${e.toolId}`}):c.jsxs("div",{className:"w-full",children:[m?c.jsx("div",{className:"mb-2 rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap","data-testid":`ask-user-question-error:${e.toolId}`,children:m}):null,c.jsx(wae,{questions:i,onSubmit:g})]}):c.jsx("div",{className:"w-full py-2",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hD,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Questions pending (newer question active)"})]})})}function Y3({message:e,onSubmit:t,isLatest:n}){const r=Cae(e.result)??null,i=!!e.result;return c.jsx(Eg.Provider,{init:{savedAnswers:r,isComplete:i},children:c.jsx(VKe,{message:e,onSubmit:t,isLatest:n})})}function KKe(){return e=>({expanded:!1,copied:!1,showEditInput:!1,editMessage:"",setExpanded:t=>e({expanded:t}),setCopied:t=>e({copied:t}),setEditMessage:t=>e({editMessage:t}),openEdit:()=>e({showEditInput:!0}),cancelEdit:()=>e(t=>t.showEditInput||t.editMessage!==""?{showEditInput:!1,editMessage:""}:t)})}const Dl=Jt("ExitPlanModeMessage",KKe);function GKe({message:e,onConfirm:t,isLatest:n,ports:r={}}){const i=q3(),s=r.clipboard??Ua,o=r.timer??ar,a=!!e.result,l=Dl.useScopedStore(M=>M.expanded),u=Dl.useScopedStore(M=>M.copied),f=Dl.useScopedStore(M=>M.showEditInput),h=Dl.useScopedStore(M=>M.editMessage),m=Dl.useScopedStore(M=>M.setExpanded),g=Dl.useScopedStore(M=>M.setCopied),v=Dl.useScopedStore(M=>M.setEditMessage),x=Dl.useScopedStore(M=>M.openEdit),y=Dl.useScopedStore(M=>M.cancelEdit),w=_.useRef(null),k=_.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&h.trim()&&(M.preventDefault(),t(e.toolId,!1,void 0,h.trim())),M.key==="Escape"&&y()},[h,t,e.toolId,y]),C=e.input;_.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const E=async()=>{C!=null&&C.plan&&(await s.writeText(C.plan),g(!0),o.setTimeout(()=>g(!1),2e3))},N=a?e.result:null,A=(N==null?void 0:N.discarded)===!0;let j;A?j="Discarded":N!=null&&N.clearContext?j="Approved & Cleared Context":N!=null&&N.confirmed?j="Approved":N!=null&&N.message?j=`Adjusted: "${N.message}"`:j="Adjusted Plan";let P;return a?P=c.jsx("div",{className:"flex justify-end mx-2",children:c.jsxs("span",{className:"pl-4 inline text-sm font-medium bg-background text-foreground/60 border border-border py-1.5 px-3 rounded-[20px] leading-relaxed max-w-[85%] sm:max-w-[80%]",children:[c.jsx("em",{children:j}),c.jsx(Qhe,{className:"inline h-4 w-4 ml-1.5 -mt-0.5"})]})}):n?i.readonly?P=c.jsx("div",{className:"flex justify-end mx-2",children:c.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending in original session"})}):P=c.jsxs("div",{className:"flex flex-col gap-3",children:[!f&&c.jsxs("div",{className:"flex flex-col md:flex-row items-stretch md:items-center justify-end gap-2 mx-2",children:[c.jsxs(Re,{size:"sm",onClick:()=>t(e.toolId,!0,!0),className:"rounded-full bg-primary text-background pr-4 md:order-last",children:[c.jsx(Ehe,{className:"h-4 w-4 mr-1.5"}),"Approve & Clear"]}),c.jsxs("div",{className:"flex items-stretch md:items-center gap-2 md:contents",children:[c.jsxs(Re,{size:"sm",variant:"outline",onClick:x,className:"rounded-full border-border flex-1 md:flex-initial md:order-first",children:[c.jsx(Xp,{className:"h-4 w-4 mr-1.5"}),"Suggest Edits"]}),c.jsxs(Re,{size:"sm",variant:"outline",onClick:()=>t(e.toolId,!0),className:"rounded-full border-border flex-1 md:flex-initial",children:[c.jsx(Ls,{className:"h-4 w-4 mr-1.5"}),"Approve"]})]})]}),f&&c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("textarea",{ref:w,value:h,onChange:M=>v(M.target.value),onKeyDown:k,placeholder:"Describe what you'd like to change...",rows:3,className:"w-full rounded-2xl border border-border bg-muted dark:bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground resize-none outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"}),c.jsxs("div",{className:"flex items-center justify-end gap-2 mx-2",children:[c.jsx(Re,{size:"sm",variant:"ghost",onClick:y,className:"rounded-full text-muted-foreground",children:"Cancel"}),c.jsxs(Re,{size:"sm",disabled:!h.trim(),onClick:()=>t(e.toolId,!1,void 0,h.trim()),className:"rounded-full bg-primary text-background disabled:opacity-50 disabled:pointer-events-none",children:[c.jsx(Jme,{className:"h-4 w-4 mr-1.5"}),"Adjust Plan"]})]})]})]}):P=c.jsx("div",{className:"flex justify-end mx-2",children:c.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending (newer prompt active)"})}),c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsxs("div",{className:"relative rounded-2xl border border-border overflow-hidden group/plan",children:[(C==null?void 0:C.plan)&&c.jsx(Re,{variant:"ghost",size:"icon","aria-label":u?"Copied":"Copy plan",className:le("absolute top-2 right-2 z-10 h-11 w-11 md:h-8 md:w-8 rounded-md text-muted-foreground opacity-100 md:opacity-0 md:group-hover/plan:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",!u&&"hover:text-foreground",u&&"hover:!bg-transparent hover:!border-transparent"),onClick:E,children:u?c.jsx(Ls,{className:"h-4 w-4 text-success"}):c.jsx(ja,{className:"h-4 w-4"})}),c.jsxs("div",{className:le("!pt-5 !pb-0 px-4 md:py-4.5 md:px-5.5 bg-muted dark:bg-card overflow-scroll no-pre-highlight transition-all",a&&!l?"max-h-[min(400px,40vh)] ":"",a?"hover:!pb-[32px]":""),children:[a&&c.jsxs(Re,{variant:"ghost",className:"absolute z-10 bottom-2 pr-2.5 !pl-3.5 h-[34px] inline-flex gap-1 text-sm left-[50%] -translate-x-[50%] text-muted-foreground bg-background hover:text-foreground opacity-0 group-hover/plan:opacity-100 transition-all rounded-full border border-border",onClick:()=>m(!l),children:[l?"Show Less":"Show More",c.jsx(Yp,{className:`size-3.5 transition-transform ${l?"rotate-180":""}`})]}),C!=null&&C.plan?c.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:[Vre(C.plan),c.jsx("div",{className:"mt-5"})]}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No plan provided"})]})]}),P]})}function kae({message:e,onConfirm:t,isLatest:n,ports:r}){return c.jsx(Dl.Provider,{init:void 0,children:c.jsx(GKe,{message:e,onConfirm:t,isLatest:n,ports:r})})}function Eae({pendingTool:e,onAskUserQuestionSubmit:t,onExitPlanModeSubmit:n}){if(e.toolKind==="ask_user_question"){const r=e.input.questions,i=Array.isArray(r)?r.filter(o=>Pr(o)):[],s={id:e.toolUseId,kind:"tool",toolKind:"ask_user_question",toolName:"AskUserQuestion",toolId:e.toolUseId,input:{questions:i},timestamp:new Date(e.requestedAt).toISOString()};return c.jsxs("div",{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:"awaiting your response"}),c.jsx(Y3,{message:s,onSubmit:t,isLatest:!0})]})}if(e.toolKind==="exit_plan_mode"){const r=e.input,i={id:e.toolUseId,kind:"tool",toolKind:"exit_plan_mode",toolName:"ExitPlanMode",toolId:e.toolUseId,input:{plan:typeof r.plan=="string"?r.plan:void 0,summary:typeof r.summary=="string"?r.summary:void 0},timestamp:new Date(e.requestedAt).toISOString()};return c.jsxs("div",{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground mb-1",children:"awaiting your response"}),c.jsx(kae,{message:i,onConfirm:(s,o,a,l)=>n(s,{confirmed:o,clearContext:a,message:l}),isLatest:!0})]})}return null}const qKe=40;function ha(e){return VY(e,qKe)}function YKe(e,t){switch(e.toolKind){case"bash":{const n=e.input.description||(e.input.command?HY(e.input.command):"");return n?`$ ${ha(n)}`:"running bash..."}case"read_file":{const n=hf(e.input.filePath,t);return n?`reading ${ha(n)}`:"reading file..."}case"write_file":{const n=hf(e.input.filePath,t);return n?`writing ${ha(n)}`:"writing file..."}case"edit_file":{const n=hf(e.input.filePath,t);return n?`editing ${ha(n)}`:"editing file..."}case"delete_file":{const n=hf(e.input.filePath,t);return n?`deleting ${ha(n)}`:"deleting file..."}case"glob":return e.input.pattern?`globbing ${ha(e.input.pattern)}`:"globbing...";case"grep":return e.input.pattern?`grepping ${ha(e.input.pattern)}`:"grepping...";case"web_search":return e.input.query?`searching: ${ha(e.input.query)}`:"searching web...";case"skill":return e.input.skill?`skill ${ha(e.input.skill)}`:"running skill...";case"todo_write":return"updating todos...";case"subagent_task":return e.input.subagentType?`delegating ${ha(e.input.subagentType)}`:"delegating...";case"ask_user_question":return"asking...";case"exit_plan_mode":return"presenting plan...";case"offer_download":return"preparing download...";case"image_generation":return"generating image...";case"mcp_generic":return ha(`${e.input.server}.${e.input.tool}`);case"unknown_tool":return`running ${ha(e.toolName)}`;default:return"running..."}}function XKe(e,t){if(e.pendingTool)return"waiting for input...";const n=e.entries,r=new Set;for(let s=n.length-1;s>=0;s--){const o=n[s];if(o.kind==="tool_result")r.add(o.toolId);else if(o.kind==="tool_call"&&!r.has(o.tool.toolId))return YKe(o.tool,t)}const i=n[n.length-1];return(i==null?void 0:i.kind)==="assistant_text"?"streaming...":"running..."}function Nae({run:e,indentDepth:t,localPath:n,onOpenSettings:r,onRetry:i,onSubagentAskUserQuestionSubmit:s,onSubagentExitPlanModeSubmit:o,onCancelSubagentRun:a,suppressPendingTool:l=!1}){var g;const u=$N(e.entries),f=u.some(v=>v.kind==="assistant_text"),h=e.status==="running"&&f,m=e.status==="running"?XKe(e,n):"";return c.jsxs("div",{"data-testid":`subagent-message:${e.runId}`,className:le("border-l-2 border-accent pl-3 py-2 space-y-2"),style:{marginLeft:`${t*24}px`},[Ly]:"",children:[c.jsxs("header",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx(Df,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:e.subagentName}),c.jsxs("span",{className:"opacity-60",children:[e.provider,e.model?`/${e.model}`:""]}),((g=e.usage)==null?void 0:g.outputTokens)!=null&&c.jsxs("span",{className:"opacity-60",children:["· ",e.usage.inputTokens??0,"↑ ",e.usage.outputTokens,"↓"]}),e.status==="running"&&c.jsx("span",{"data-testid":`subagent-activity:${e.runId}`,className:"ml-auto inline-block animate-pulse",children:m}),a&&e.status==="running"&&c.jsx("button",{type:"button","data-testid":`subagent-cancel:${e.runId}`,"aria-label":"Cancel subagent",onClick:()=>a(e.chatId,e.runId),className:"text-muted-foreground hover:text-foreground",children:c.jsx(ts,{className:"h-3.5 w-3.5"})})]}),u.map(v=>c.jsx(G3,{message:v,localPath:n,isRunning:e.status==="running"},v.id)),!l&&e.pendingTool&&c.jsx(Eae,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:(v,x,y)=>s==null?void 0:s(e.runId,v,x,y),onExitPlanModeSubmit:(v,x)=>o==null?void 0:o(e.runId,v,x)}),u.length===0&&e.finalText&&c.jsxs("div",{className:le("whitespace-pre-wrap text-sm",h&&"text-foreground/80"),children:[e.finalText,h&&c.jsx("span",{className:"ml-0.5 inline-block w-2 animate-pulse",children:"▍"})]}),e.status==="failed"&&e.error&&c.jsx("div",{children:c.jsx(BKe,{error:e.error,runId:e.runId,subagentId:e.subagentId,onOpenSettings:r,onRetry:i})})]})}const AO=Jt("UserMessage",()=>e=>({selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t})}));function QKe(e){var n;const t=e.match(/^<system-message>\s*([\s\S]*?)\s*<\/system-message>\s*([\s\S]*)$/);return t?{systemMessage:((n=t[1])==null?void 0:n.trim())||null,body:t[2]??""}:{systemMessage:null,body:e}}function JKe({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i}){const s=(i==null?void 0:i.dom)??Nt,o=AO.useScopedStore(y=>y.selectedAttachmentId),a=AO.useScopedStore(y=>y.setSelectedAttachmentId),l=q3(),u=_.useMemo(()=>QKe(e),[e]),f=!l.readonly,h=_.useMemo(()=>t.filter(y=>y.kind==="image"&&y.contentUrl),[t]),m=_.useMemo(()=>t.filter(y=>y.kind!=="image"||!y.contentUrl),[t]),g=t.find(y=>y.id===o)??null,v=g?yb(g,"user_attachment"):null;function x(y){if(!f||!y.contentUrl)return;if(fb(y).openInNewTab){s.openWindow(new URL(y.contentUrl,s.getBaseURI()||s.getHref()).toString(),"_blank","noopener,noreferrer");return}a(y.id)}return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col items-end gap-2",children:[h.length>0?c.jsx("div",{className:"flex max-w-[85%] sm:max-w-[80%] flex-wrap justify-end gap-3",children:h.map(y=>c.jsx(tN,{attachment:y,onClick:f?()=>x(y):void 0},y.id))}):null,m.length>0?c.jsx("div",{className:"flex max-w-[85%] sm:max-w-[80%] flex-wrap justify-end gap-2",children:m.map(y=>c.jsx(qo,{attachment:y,onClick:f?()=>x(y):void 0},y.id))}):null,u.body||!u.body&&t.length===0&&e&&!u.systemMessage?c.jsxs("div",{className:"flex max-w-[85%] items-center gap-2 sm:max-w-[80%]",children:[n?c.jsx(Uge,{"aria-label":"Sent mid-turn",className:"size-3.5 shrink-0 text-muted-foreground"}):null,c.jsx("div",{className:"min-w-0 flex-1 rounded-[20px] rounded-tr-sm border border-border bg-muted px-3.5 py-1.5 text-primary prose prose-sm prose-invert [&_p]:whitespace-pre-line",children:$p(u.body)})]}):null,r?c.jsx("span",{className:"text-xs text-muted-foreground opacity-70",children:"auto-sent"}):null]}),c.jsx(pm,{source:v,open:v!==null,onOpenChange:y=>!y&&a(null)})]})}const ZKe=_.memo(({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i})=>c.jsx(AO.Provider,{init:void 0,children:c.jsx(JKe,{content:e,attachments:t,steered:n,autoContinue:r,ports:i})}));function eGe({json:e}){return c.jsx("div",{className:"flex gap-3 justify-start",children:c.jsx("div",{className:"flex-1 max-w-[90%]",children:c.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96",children:e})})})}const X3=e=>Jt(e,()=>t=>({open:!1,setOpen:n=>t({open:n})})),RO=X3("CollapsibleSection"),jO=X3("ExpandableMcpServer"),MO=X3("RawMessageSection");function tGe({title:e,count:t,children:n,badge:r}){const i=RO.useScopedStore(o=>o.open),s=RO.useScopedStore(o=>o.setOpen);return t===0?null:c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[c.jsx(Ra,{className:le("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",i&&"rotate-90")}),c.jsx("span",{className:"text-muted-foreground font-medium",children:e}),c.jsx("span",{className:"text-muted-foreground/60",children:t}),r]}),i&&c.jsx("div",{className:"ml-5",children:n})]})}function Tae({title:e,count:t,children:n,badge:r}){return c.jsx(RO.Provider,{init:void 0,children:c.jsx(tGe,{title:e,count:t,badge:r,children:n})})}function hj({title:e,items:t,icon:n,getIcon:r}){return t.length===0?null:c.jsx(Tae,{title:e,count:t.length,children:c.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(i=>c.jsx(dee,{icon:r?r(i):n,children:i},i))})})}function nGe(e){const t=e.match(/^mcp__([^_]+)__(.+)$/);return t?{server:t[1],tool:t[2]}:null}function Aae({status:e}){let t;return e==="connected"?t="bg-success":e==="pending"?t="bg-warning":t="bg-destructive",c.jsx("span",{className:le("inline-block h-2 w-2 rounded-full shrink-0",t)})}function rGe(e){switch(e){case"connected":return"Connected";case"failed":return"Failed";case"needs-auth":return"Needs auth";case"pending":return"Connecting...";case"disabled":return"Disabled";default:return e}}function iGe({server:e}){const t=jO.useScopedStore(i=>i.open),n=jO.useScopedStore(i=>i.setOpen),r=e.status==="connected";return c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>r&&e.tools.length>0&&n(!t),className:le("flex items-center gap-1.5",r&&e.tools.length>0&&"cursor-pointer hover:opacity-60 transition-opacity"),children:[r&&e.tools.length>0&&c.jsx(Ra,{className:le("h-3 w-3 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),c.jsx(Aae,{status:e.status}),c.jsx("span",{className:"text-muted-foreground font-medium",children:lM(e.name)}),r?c.jsxs("span",{className:"text-muted-foreground/50",children:[e.tools.length," tools"]}):c.jsx("span",{className:"text-muted-foreground/50",children:rGe(e.status)})]}),!r&&e.error&&c.jsx("span",{className:"text-destructive ml-5",children:e.error}),t&&e.tools.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 ml-5",children:e.tools.map(i=>c.jsx(dee,{icon:lee(`mcp__${e.name}__${i}`),children:i},i))})]})}function BV({server:e}){return c.jsx(jO.Provider,{init:void 0,children:c.jsx(iGe,{server:e})})}function sGe({servers:e}){if(e.length===0)return null;const t=e.filter(i=>i.status==="connected"),n=e.filter(i=>i.status!=="connected"),r=n.length>0?c.jsxs("span",{className:"flex items-center gap-1 ml-1",children:[c.jsx(Aae,{status:"failed"}),c.jsxs("span",{className:"text-muted-foreground/60",children:[n.length," disconnected"]})]}):null;return c.jsx(Tae,{title:"MCP Servers",count:e.length,badge:r,children:c.jsxs("div",{className:"flex flex-col gap-2",children:[t.map(i=>c.jsx(BV,{server:i},i.name)),n.map(i=>c.jsx(BV,{server:i},i.name))]})})}function oGe({rawJson:e}){const t=MO.useScopedStore(r=>r.open),n=MO.useScopedStore(r=>r.setOpen);return c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>n(!t),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[c.jsx(Ra,{className:le("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),c.jsx("span",{className:"text-muted-foreground font-medium",children:"Raw Message"})]}),t&&c.jsx("pre",{className:"ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto",children:e})]})}function aGe({rawJson:e}){return c.jsx(MO.Provider,{init:void 0,children:c.jsx(oGe,{rawJson:e})})}function lGe({message:e,rawJson:t}){const{coreTools:n,mcpServersWithTools:r}=_.useMemo(()=>{const i=new Map,s=[];for(const a of e.tools){const l=nGe(a);if(l){const u=i.get(l.server)||[];u.push(l.tool),i.set(l.server,u)}else s.push(a)}const o=e.mcpServers.map(a=>({name:a.name,status:a.status,error:a.error,tools:i.get(a.name)||[]}));return{coreTools:s,mcpServersWithTools:o}},[e.tools,e.mcpServers]);return c.jsx(qu,{children:c.jsxs(l5,{expandedContent:c.jsx(eN,{className:"my-4 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx(ePe,{children:e.model}),c.jsx(hj,{title:"Tools",items:n,getIcon:i=>eP[i]??aee}),c.jsx(hj,{title:"Agents",items:e.agents,icon:cE}),c.jsx(hj,{title:"Commands",items:e.slashCommands,icon:lge}),c.jsx(sGe,{servers:r}),t&&c.jsx(aGe,{rawJson:t})]})}),children:[c.jsx(fhe,{className:"h-5 w-5 text-logo"}),c.jsx(Rp,{children:"Session Started"})]})})}const PO=Jt("AccountInfoMessage",()=>e=>({expanded:!1,setExpanded:t=>e({expanded:t})})),cGe={"kanna-oauth-pool":"Pool token","claude-pro":"Claude Pro","claude-max":"Claude Max",openrouter:"OpenRouter"};function uGe(e,t){return e?cGe[e]??e:t?`API key (${t})`:null}function dGe({message:e}){const{organization:t,tokenSource:n,apiKeySource:r,subscriptionType:i,email:s,oauthKeyMasked:o}=e.accountInfo,a=o??t??s??"Unknown account",l=uGe(n,r),u=PO.useScopedStore(h=>h.expanded),f=PO.useScopedStore(h=>h.setExpanded);return c.jsx(qu,{children:c.jsxs("div",{className:"flex w-full flex-col",children:[c.jsxs("button",{type:"button",onClick:()=>f(!u),"aria-expanded":u,className:"group/account flex w-full items-center gap-2.5 text-left transition-opacity hover:opacity-80 focus-visible:opacity-100",children:[c.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Account"}),c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[13px] font-medium leading-snug text-foreground",children:a}),l?c.jsx("span",{className:"hidden whitespace-nowrap text-[11px] text-muted-foreground sm:inline",children:l}):null,c.jsx(Ra,{className:le("h-3.5 w-3.5 flex-shrink-0 text-muted-foreground transition-transform duration-200",u&&"rotate-90"),"aria-hidden":!0})]}),l?c.jsx("span",{className:"mt-0.5 text-[11px] text-muted-foreground sm:hidden",children:l}):null,u?c.jsx(eN,{className:"mt-3 mb-2 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx(tP,{label:"OAuth key",copyText:a,children:c.jsx("code",{className:"block text-xs whitespace-pre-wrap break-all",children:a})}),c.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-5 gap-y-1.5",children:[l?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Source"}),c.jsx("dd",{className:"text-foreground/90",children:l})]}):null,i?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Plan"}),c.jsx("dd",{className:"text-foreground/90",children:i})]}):null,s?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Email"}),c.jsx("dd",{className:"font-mono break-all text-foreground/90",children:s})]}):null,t?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Organization"}),c.jsx("dd",{className:"text-foreground/90",children:t})]}):null]})]})}):null]})})}function fGe({message:e}){return c.jsx(PO.Provider,{init:void 0,children:c.jsx(dGe,{message:e})})}function hGe({message:e}){return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qp,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron job armed"}),c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.jobId}),c.jsx("span",{className:"ml-auto rounded-full border border-border px-2 py-0.5 text-xs font-medium text-muted-foreground",children:e.mode==="inline"?"inline · runs in this chat":"spawn · new chat per run"})]}),c.jsx("p",{className:"mt-1.5 text-sm text-foreground/90",children:e.instruction}),c.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[c.jsxs("span",{children:[e.scheduleHuman,e.scheduleHuman!==e.scheduleText?c.jsx("span",{className:"ml-1.5 font-mono opacity-70",children:e.scheduleText}):null]}),e.nextFireAt!==null?c.jsxs("span",{className:"tabular-nums",children:["next fire ",WY(e.nextFireAt)]}):null]}),e.mode==="inline"?c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Context is cleared before every run — this chat becomes a monitoring view."}):null]})}function pGe({message:e}){return c.jsx(Mu.Provider,{init:void 0,children:c.jsx(mGe,{message:e})})}function mGe({message:e}){const t=Mu.useScopedStore(s=>s.copied),n=Mu.useScopedStore(s=>s.setCopied),r=e.suggestion,i=_.useCallback(async()=>{r!==void 0&&(await Ua.writeText(r),n(!0),ar.setTimeout(()=>n(!1),2e3))},[r,n]);return c.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Che,{className:"h-4 w-4 shrink-0 text-destructive","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Invalid /cron command"})]}),e.input!==void 0?c.jsx("code",{className:"mt-1.5 block truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-muted-foreground",children:e.input}):null,c.jsx("p",{className:"mt-1.5 text-sm text-foreground/90",children:e.message}),r!==void 0?c.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[c.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-foreground",children:r}),c.jsxs("button",{type:"button",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-muted/40",onClick:i,children:[t?c.jsx(Ls,{className:"h-3.5 w-3.5 text-success","aria-hidden":"true"}):c.jsx(ja,{className:"h-3.5 w-3.5","aria-hidden":"true"}),t?"Copied":"Copy fix"]})]}):null]})}function gGe({message:e}){return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(qp,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsxs("span",{className:"text-xs",children:["Cron job",c.jsxs("span",{className:"font-mono",children:[" ",e.jobId," "]}),e.change]})]})}const vGe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Q3(e,t){if(e.type==="interval")return bGe(e.ms);const{second:n,minute:r,hour:i,dom:s,month:o,dow:a}=e;if(o.kind!=="any")return t;const l=s.kind==="any"&&a.kind==="any";if(n!==void 0&&r.kind==="any"&&i.kind==="any"&&l){if(n.kind==="any")return"every second";const g=xGe(n.values);if(g!==null)return g===1?"every second":`every ${g} seconds`;if(n.values.length>1)return t}const u=n===void 0?0:pj(n);if(u===null)return t;const f=u===0?"":`:${Fx(u)}`,h=pj(r),m=pj(i);if(r.kind==="any"&&i.kind==="any"&&l)return u===0?"every minute":`every minute at :${Fx(u)}`;if(h!==null&&i.kind==="any"&&l)return`hourly at :${Fx(h)}${f}`;if(h!==null&&m!==null){const g=`${Fx(m)}:${Fx(h)}${f}`;if(l)return`daily at ${g}`;if(s.kind==="any"&&a.kind==="values")return`every ${a.values.map(x=>vGe[x]).join(", ")} at ${g}`;if(a.kind==="any"&&s.kind==="values"&&s.values.length===1)return`on day ${s.values[0]} of each month at ${g}`}return t}function bGe(e){const t=Math.round(e/1e3);if(t%3600===0){const n=t/3600;return n===1?"every hour":`every ${n} hours`}if(t%60===0){const n=t/60;return n===1?"every minute":`every ${n} minutes`}return t===1?"every second":`every ${t} seconds`}function pj(e){return e.kind==="values"&&e.values.length===1?e.values[0]:null}function xGe(e){if(e.length<2||e[0]!==0)return null;const t=e[1];if(t<1||60%t!==0||e.length!==60/t)return null;for(let n=1;n<e.length;n++)if(e[n]!==n*t)return null;return t}function Fx(e){return String(e).padStart(2,"0")}const yGe={running:"border-warning/40 text-warning-text bg-warning/10",completed:"border-success/40 text-success-text bg-success/10",failed:"border-destructive/40 text-destructive-text bg-destructive/10",skipped:"border-border text-muted-foreground bg-muted/40"};function _Ge({message:e,cronJobs:t}){const n=t==null?void 0:t.find(s=>s.jobId===e.jobId),r=n==null?void 0:n.recentRuns.find(s=>s.runId===e.runId),i=(r==null?void 0:r.status)??"running";return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qp,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron run"}),c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.jobId}),c.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:WY(e.firedAt)}),c.jsx(VN,{status:i})]})]}),c.jsx("p",{className:"mt-1.5 text-sm text-foreground/90",children:e.instruction}),e.spawnedChatId?c.jsxs(X_,{to:`/chat/${e.spawnedChatId}`,className:"mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline",children:[c.jsx(eb,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Open run chat"]}):null]})}const SGe={running:"Running",completed:"Completed",failed:"Failed",skipped:"Skipped"},wGe={running:"bg-warning",completed:"bg-success",failed:"bg-destructive",skipped:"bg-muted-foreground"};function VN({status:e}){return c.jsxs("span",{className:le("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",yGe[e]),children:[c.jsx("span",{className:le("h-1.5 w-1.5 rounded-full",wGe[e])}),SGe[e]]})}function CGe({message:e,cronJobs:t}){const n=t??[];return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qp,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron jobs"}),c.jsxs("span",{className:"ml-auto text-xs text-muted-foreground tabular-nums",children:[n.length," armed"]})]}),n.length===0?c.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:"No cron jobs armed in this chat."}):c.jsx("div",{className:"mt-2 space-y-2",children:n.map(r=>c.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[c.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:r.jobId}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground/90",children:r.instruction}),c.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[Q3(r.schedule,r.scheduleText)," · ",r.mode,r.paused?" · paused":""]}),r.lastRun?c.jsx(VN,{status:r.lastRun.status}):null]},r.jobId))}),e.help?c.jsxs("div",{className:"mt-3 border-t border-border pt-2 font-mono text-xs text-muted-foreground",children:[c.jsx("div",{children:"/cron <instruction> inline|spawn <schedule>"}),c.jsx("div",{children:"/cron list · /cron remove <id> · /cron pause <id> · /cron resume <id>"}),c.jsx("div",{children:"schedules: `0 9 * * 1-5` · `*/30 * * * * *` (leading second) · @hourly @daily @weekly @monthly · every 30s / every 5m / every 2h"}),c.jsx("div",{className:"mt-1",children:"inline runs in this chat with context cleared each cycle; spawn creates a new chat per run. Next-fire times use server-local time."})]}):null]})}function kGe({message:e}){const t=e.missedCount??1;return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(oge,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsxs("span",{className:"text-xs tabular-nums",children:[t===1?"Cron run skipped":`Cron runs skipped ${t}×`,c.jsxs("span",{className:"font-mono",children:[" ",e.jobId]})," — ",EGe(e.reason)]})]})}function EGe(e){switch(e){case"chat_busy":return"chat was busy";case"previous_run_active":return"previous run still running";case"server_offline":return"missed while the server was offline"}}function NGe(e){return e===429?"Rate Limited":e===500?"Internal Server Error":e===502?"Bad Gateway":e===503?"Service Unavailable":e===529?"Overloaded":e>=500?"Server Error":(e>=400,"API Error")}function TGe(e){if(e!==0)return"https://status.claude.com"}function AGe({message:e}){const t=e.status>0?`${e.status} ${NGe(e.status)}`:"API Error",n=TGe(e.status);return c.jsx("div",{className:"w-full max-w-[70ch]",children:c.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2.5 space-y-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-destructive-text",children:[c.jsx(kf,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"uppercase tracking-wide",children:t})]}),c.jsx("div",{className:"text-sm whitespace-pre-wrap break-words text-foreground/90",children:e.text}),(e.requestId||n)&&c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground pt-0.5",children:[n&&c.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"hover:underline",children:"Check status"}),e.requestId&&c.jsxs("span",{children:["Request ID: ",c.jsx("code",{className:"text-xs",children:e.requestId})]})]})]})})}const RGe="https://www.anthropic.com/legal/aup";function jGe(e){return e.replace(/^API Error:\s*/i,"")}function MGe({message:e}){const t=jGe(e.text);return c.jsx("div",{className:"w-full max-w-[70ch]",children:c.jsxs("div",{className:"rounded-md border border-warning/40 bg-warning/10 px-3 py-2.5 space-y-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warning",children:[c.jsx(mD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"uppercase tracking-wide",children:"Blocked by Usage Policy"})]}),c.jsx("div",{className:"text-sm whitespace-pre-wrap break-words text-foreground/90",children:t}),c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground pt-0.5",children:[c.jsx("a",{href:RGe,target:"_blank",rel:"noreferrer",className:"hover:underline",children:"Usage Policy"}),e.requestId&&c.jsxs("span",{children:["Request ID: ",c.jsx("code",{className:"text-xs",children:e.requestId})]})]})]})})}const PGe={completed:{Icon:Ls,iconClass:"text-success",textClass:"text-muted-foreground"},in_progress:{Icon:Mn,iconClass:"text-foreground animate-spin",textClass:"text-foreground font-medium"},pending:{Icon:Fhe,iconClass:"text-muted-foreground",textClass:"text-muted-foreground"}};function IGe({message:e}){const t=e.input.todos;return t.length?c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[c.jsx(dD,{className:"h-4 w-4 text-muted-foreground"}),"Progress"]}),c.jsx("div",{children:t.map((n,r)=>{const i=r===t.length-1,{Icon:s,iconClass:o,textClass:a}=PGe[n.status];return c.jsxs("div",{className:le("flex items-center gap-3 px-4 py-2.5 bg-background",!i&&"border-b border-border"),children:[c.jsx(s,{className:le("h-4 w-4 flex-shrink-0",o)}),c.jsx("span",{className:le("text-sm",a),children:n.status==="in_progress"?n.activeForm:n.content})]},r)})})]})}):null}const oy=Jt("OfferDownloadMessage",()=>e=>({probeState:"idle",previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function OGe({message:e}){const t=e.result,n=t==null?void 0:t.contentUrl,r=oy.useScopedStore(x=>x.probeState),i=oy.useScopedStore(x=>x.previewOpen),s=oy.useScopedStore(x=>x.setProbeState),o=oy.useScopedStore(x=>x.setPreviewOpen);if(_.useEffect(()=>{if(!n)return;const x=new AbortController;return o5(n,{signal:x.signal}).then(y=>{x.signal.aborted||(y.kind==="ready"?s("ready"):y.kind==="missing"&&s("missing"))}),()=>x.abort()},[n,s]),!t||!n)return null;const a={id:`offer-download-${e.toolId}`,kind:"file",displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType??"application/octet-stream",size:t.size},l=am(a),u=S0(l,t.mimeType),f=t.size>0?lm(t.size):null,h=c.jsxs(c.Fragment,{children:[u,f?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:f})]}):null]});if(r==="missing")return c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(qo,{attachment:a,disabledReason:"File no longer available"})});if(!fb(a).openInNewTab){const x=`Preview ${a.displayName}, ${u}${f?`, ${f}`:""}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(qo,{attachment:a,onClick:()=>o(!0),meta:h,ariaLabel:x})}),c.jsx(pm,{source:i?yb(a,"offer_download"):null,open:i,onOpenChange:o})]})}const v=["Download",a.displayName,u,f].filter(x=>!!x);return c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(qo,{attachment:a,href:n,download:t.fileName||void 0,meta:h,ariaLabel:v.join(", ")})})}function DGe({message:e}){return c.jsx(oy.Provider,{init:void 0,children:c.jsx(OGe,{message:e})})}const ay=Jt("PreviewFileMessage",()=>e=>({probeState:"idle",previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function LGe({message:e}){const t=e.result,n=t==null?void 0:t.contentUrl,r=ay.useScopedStore(g=>g.probeState),i=ay.useScopedStore(g=>g.previewOpen),s=ay.useScopedStore(g=>g.setProbeState),o=ay.useScopedStore(g=>g.setPreviewOpen);if(_.useEffect(()=>{if(!n)return;const g=new AbortController;return o5(n,{signal:g.signal}).then(v=>{g.signal.aborted||(v.kind==="ready"?s("ready"):v.kind==="missing"&&s("missing"))}),()=>g.abort()},[n,s]),!t||!n)return null;const a={id:`preview-file-${e.toolId}`,kind:"file",displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType,size:t.size},l=am(a),u=S0(l,t.mimeType),f=t.size>0?lm(t.size):null,h=c.jsxs(c.Fragment,{children:[u,f?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:f})]}):null]});if(r==="missing")return c.jsx("div",{className:"flex","data-testid":"preview-file-card",children:c.jsx(qo,{attachment:a,disabledReason:"File no longer available"})});const m=`Preview ${a.displayName}, ${u}${f?`, ${f}`:""}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex","data-testid":"preview-file-card",children:c.jsx(qo,{attachment:a,onClick:()=>o(!0),meta:h,ariaLabel:m})}),c.jsx(pm,{source:i?yb(a,"preview_file"):null,open:i,onOpenChange:o})]})}function $Ge({message:e}){return c.jsx(ay.Provider,{init:void 0,children:c.jsx(LGe,{message:e})})}const Rae=new Map;function zV(e){const t=Rae.get(e);return t!==void 0?t:void 0}function FGe(e){const{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:s}=e,o=zV(t),a=_.useRef(null);a.current===null&&(a.current=oD(()=>({state:o!==void 0?"ready":"idle",data:o!==void 0?o:null,error:null})));const l=dy(a.current,v=>v.state),u=dy(a.current,v=>v.data),f=dy(a.current,v=>v.error),h=_.useRef(t),m=_.useRef(null),g=_.useRef(t);return g.current=t,_.useEffect(()=>{if(h.current===t)return;h.current=t;const v=zV(t);a.current.setState({state:v!==void 0?"ready":"idle",data:v!==void 0?v:null,error:null})},[t]),_.useEffect(()=>{if(!n||o!==void 0)return;const v=r.current;if(!v||typeof IntersectionObserver>"u")return;let x=!1;const y=t,w=new IntersectionObserver(k=>{for(const C of k){if(!C.isIntersecting)continue;if(w.disconnect(),x)return;const E=new AbortController;m.current=E,a.current.setState({state:"loading"}),i(E.signal).then(N=>{x||g.current!==y||(Rae.set(y,N),a.current.setState({data:N,state:"ready"}))}).catch(N=>{x||E.signal.aborted||g.current!==y||a.current.setState({error:N instanceof Error?N:new Error(String(N)),state:"error"})});break}},{rootMargin:s??"200px"});return w.observe(v),()=>{var k;x=!0,w.disconnect(),(k=m.current)==null||k.abort(),m.current=null}},[o,t,n,r,i,s]),_.useMemo(()=>({state:l,data:u,error:f}),[l,u,f])}function BGe({source:e,onOpen:t,variant:n}){const r={id:e.id,kind:"file",displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??"",absolutePath:""},i=am(r),s=S0(i,e.mimeType),o=e.size&&e.size>0?lm(e.size):null;return i==="image"?c.jsx("button",{type:"button",onClick:t,"aria-label":`Preview ${e.displayName}`,className:"overflow-hidden rounded-xl border border-border bg-background",children:c.jsx("img",{src:e.contentUrl,alt:e.altText??e.displayName,loading:"lazy",className:"max-h-64 w-auto max-w-full object-contain"})}):n==="expanded"&&(i==="text"||i==="code"||i==="markdown"||i==="json"||i==="table")?c.jsx(zGe,{source:e,onOpen:t,friendlyType:s,sizeLabel:o}):c.jsx(qo,{attachment:r,onClick:t,meta:c.jsxs(c.Fragment,{children:[s,o?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:o})]}):null]}),ariaLabel:`Preview ${e.displayName}, ${s}${o?`, ${o}`:""}`})}const zGe=function({source:t,onOpen:n,friendlyType:r,sizeLabel:i}){const s=_.useRef(null),o=t.contentUrl,a=_.useCallback(async f=>{const h=await a5(o,4096);if(f.aborted)throw new Error("aborted");return h.content.slice(0,200)},[o]),l=FGe({ref:s,enabled:!0,cacheKey:`snippet:${t.id}|${t.contentUrl}|${t.size??0}`,fetcher:a}),u=l.state==="ready"&&typeof l.data=="string"?l.data:"";return c.jsxs("button",{ref:s,type:"button",onClick:n,"aria-label":`Preview ${t.displayName}`,className:"flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40",children:[c.jsx("div",{className:"text-sm font-medium text-foreground",children:t.displayName}),c.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[r,i?` · ${i}`:""]}),u?c.jsx("pre",{className:"line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-[11px] text-muted-foreground",children:u}):null]})},IO=Jt("ImageGenerationMessage",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function UGe({message:e}){const{status:t,revisedPrompt:n}=e.input,r=e.result,i=r==null?void 0:r.contentUrl,s=e.isError||t==="failed",o=IO.useScopedStore(u=>u.open),a=IO.useScopedStore(u=>u.setOpen);if(!s&&!r&&t==="in_progress")return c.jsxs("div",{className:"flex flex-col gap-1 rounded-md border border-border/40 bg-muted/30 px-3 py-2 text-sm text-muted-foreground","data-testid":"image-generation-pending",children:[c.jsx("span",{children:"Generating image…"}),n?c.jsx("span",{className:"italic",children:n}):null]});if(s||!r||!i)return c.jsxs("div",{className:"flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm","data-testid":"image-generation-error",children:[c.jsx("span",{children:"Image generation failed."}),r!=null&&r.relativePath?c.jsx("span",{className:"text-muted-foreground",children:r.relativePath}):null]});const l={id:`image-gen-${e.toolId}`,contentUrl:i,displayName:r.fileName,fileName:r.fileName,relativePath:r.relativePath,mimeType:"image/png",origin:"image_generation",altText:n??void 0};return c.jsxs("figure",{className:"flex flex-col gap-2","data-testid":"image-generation",children:[c.jsx(BGe,{source:l,onOpen:()=>a(!0),variant:"expanded"}),n?c.jsx("figcaption",{className:"text-xs text-muted-foreground italic",children:n}):null,c.jsx(pm,{source:o?l:null,open:o,onOpenChange:a})]})}function HGe({message:e}){return c.jsx(IO.Provider,{init:void 0,children:c.jsx(UGe,{message:e})})}function WGe({message:e}){return c.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground",children:c.jsxs("div",{className:"inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full",children:[c.jsx(Lhe,{className:"h-4 w-4 ml-1.5"}),c.jsx("em",{children:"Interrupted"})]})})}function eE({size:e=4}){return c.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[c.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:c.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),c.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function VGe(){return c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(eE,{}),c.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),c.jsx(eE,{})]})}function KGe(){return c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(eE,{}),c.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),c.jsx(eE,{})]})}function GGe({message:e}){const t=e.path.lastIndexOf("/"),n=t>=0?e.path.slice(0,t+1):"",r=t>=0?e.path.slice(t+1):e.path;return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(J_,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsx("span",{className:"text-xs",children:"Loaded"}),c.jsxs("span",{className:"min-w-0 truncate font-mono text-xs",children:[n?c.jsx("span",{className:"opacity-60",children:n}):null,c.jsx("span",{className:"text-foreground/70",children:r})]})]})}function qGe({message:e}){return c.jsx(qu,{children:c.jsxs(l5,{expandedContent:c.jsx(eN,{className:"my-4 text-xs",children:c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:$p(e.summary)})}),children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(KG,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c.jsx(Rp,{children:"Summarized"})]})})}const YGe={compacting:"Compacting..."};function XGe({message:e}){const t=YGe[e.status]||e.status;return c.jsxs(qu,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(KG,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c.jsx(Rp,{className:"text-left transition-opacity duration-200 truncate",children:t})]})}function OO(e){return e.kind==="tool"}const QGe={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},delete_file:{key:"delete",singular:"delete",plural:"deletes"},bash:{key:"bash",singular:"command",plural:"commands"},grep:{key:"grep",singular:"search",plural:"searches"},glob:{key:"glob",singular:"glob",plural:"globs"},subagent_task:{key:"task",singular:"agent",plural:"agents"},web_search:{key:"websearch",singular:"web search",plural:"web searches"},skill:{key:"skill",singular:"skill",plural:"skills"},todo_write:{key:"todo",singular:"todo update",plural:"todo updates"}},JGe={key:"other",singular:"tool call",plural:"tool calls"};function ZGe(e){return QGe[e]??JGe}function eqe(e){const t=new Map,n=[];for(const r of e){if(!OO(r))continue;const i=r.toolKind,s=ZGe(i),o=t.get(s.key);o?o.count++:(t.set(s.key,{category:s,count:1}),n.push(s.key))}return n.map(r=>{const{category:i,count:s}=t.get(r);return`${s} ${s===1?i.singular:i.plural}`}).join(", ")}function tqe({messages:e,isLoading:t,localPath:n,expanded:r,onExpandedChange:i,chatId:s}){const o=_.useMemo(()=>eqe(e),[e]),l=e.some(u=>OO(u)&&u.result===void 0)&&t;return c.jsx(qu,{className:"w-full",children:c.jsxs("div",{className:"flex flex-col w-full",children:[c.jsx("button",{onClick:()=>i(!r),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!r&&!l?"hover:opacity-60 transition-opacity":""}`,children:c.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(Ra,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${r?"rotate-90":""}`})}),c.jsx(Rp,{className:"text-left",children:c.jsx(V0,{animate:l,children:o})})]})}),r&&c.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.filter(OO).map(u=>c.jsx(Zk,{message:u,isLoading:t,localPath:n,chatId:s},u.id)),e.length>5&&c.jsx("button",{onClick:()=>i(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:c.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(Ra,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),c.jsx(Rp,{className:"text-left",children:"Collapse"})]})})]})]})})}function nqe(e){if(e!=="system")return e}function tE(e,t){const n=nqe(t),r=new Intl.DateTimeFormat("en-GB",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).formatToParts(new Date(e)),i=o=>{var a;return((a=r.find(l=>l.type===o))==null?void 0:a.value)??"00"};let s=i("hour");return s==="24"&&(s="00"),`${i("day")}/${i("month")}/${i("year")} ${s}:${i("minute")}`}const rqe=/^(\d{2})\/(\d{2})\/(\d{4}) (\d{2}):(\d{2})$/;function UV(e,t){if(e==="system")return-new Date(t).getTimezoneOffset();const n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(t)),r=o=>{var a;return Number(((a=n.find(l=>l.type===o))==null?void 0:a.value)??0)};let i=r("hour");i===24&&(i=0);const s=Date.UTC(r("year"),r("month")-1,r("day"),i,r("minute"),r("second"));return Math.round((s-t)/6e4)}function iqe(e,t){const n=rqe.exec(e.trim());if(!n)return null;const[,r,i,s,o,a]=n,l=Number(r),u=Number(i),f=Number(s),h=Number(o),m=Number(a);if(u<1||u>12||l<1||l>31||h>23||m>59)return null;const g=Date.UTC(f,u-1,l,h,m),v=UV(t,g),x=g-v*6e4,y=UV(t,x);return x-(y-v)*6e4}const ly=Jt("AutoContinueCard",({initialDraft:e})=>t=>({draft:e,editing:!1,setDraft:n=>t({draft:n}),setEditing:n=>t({editing:n})}));function sqe({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){const i=tE(e.scheduledAt??e.resetAt,e.tz);return c.jsx(ly.Provider,{init:{initialDraft:i},children:c.jsx(oqe,{schedule:e,onAccept:t,onReschedule:n,onCancel:r})})}function oqe({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){const i=ly.useScopedStore(v=>v.draft),s=ly.useScopedStore(v=>v.editing),o=ly.useScopedStore(v=>v.setDraft),a=ly.useScopedStore(v=>v.setEditing),l=_.useMemo(()=>iqe(i,e.tz),[i,e.tz]),u=l!==null&&l>Date.now();let f;if(l===null?f="Use format dd/mm/yyyy hh:mm":u?f=null:f="Time must be in the future",e.state==="fired"){const v=tE(e.scheduledAt??e.resetAt,e.tz);return c.jsx(Kl,{title:`Auto-continued at ${v}`,tone:"success"})}if(e.state==="cancelled")return c.jsx(Kl,{title:"Auto-continue cancelled",tone:"muted"});if(e.state==="proposed"){const v=e.resetAt<=Date.now(),x=[{id:"schedule",label:"Schedule",variant:"primary",disabled:!u,onClick:()=>{l!==null&&t(l)}},{id:"dismiss",label:"Dismiss",variant:"ghost",onClick:()=>r()}];return c.jsx(Kl,{title:"Rate limit hit — schedule auto-continue?",description:v?"Reset time has passed — accept to continue now.":void 0,body:c.jsxs("div",{className:"space-y-1",children:[c.jsx(Lt,{value:i,onChange:y=>o(y.target.value),placeholder:"dd/mm/yyyy hh:mm"}),f&&c.jsx("div",{className:"text-destructive text-xs",children:f})]}),actions:x})}const h=tE(e.scheduledAt??e.resetAt,e.tz),m=e.tz==="system"?"local":e.tz;if(!s){const v=[{id:"change",label:"Change time",variant:"secondary",onClick:()=>a(!0)},{id:"cancel",label:"Cancel",variant:"ghost",onClick:()=>r()}];return c.jsx(Kl,{title:`Auto-continue at ${h} (${m})`,actions:v})}const g=[{id:"save",label:"Save",variant:"primary",disabled:!u,onClick:()=>{l!==null&&(n(l),a(!1))}},{id:"back",label:"Back",variant:"ghost",onClick:()=>a(!1)}];return c.jsx(Kl,{title:`Auto-continue at ${h} (${m})`,body:c.jsxs("div",{className:"space-y-1",children:[c.jsx(Lt,{value:i,onChange:v=>o(v.target.value),placeholder:"dd/mm/yyyy hh:mm"}),f&&c.jsx("div",{className:"text-destructive text-xs",children:f})]}),actions:g})}function aqe({toolRequestId:e,plan:t,onAnswer:n}){return c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"font-medium text-sm p-3 px-4 bg-muted border-b border-border flex items-center justify-between",children:[c.jsx("span",{children:"Plan"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"Reconnected — awaiting your response"})]}),c.jsx("div",{className:"bg-background px-4 py-3",children:c.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t})}),c.jsxs("div",{className:"flex justify-end gap-2 px-4 py-3 bg-background border-t border-border",children:[c.jsx(Re,{size:"sm",variant:"outline",className:"rounded-full",onClick:()=>n(e,{kind:"deny",reason:"user_canceled"}),children:"Edit"}),c.jsx(Re,{size:"sm",className:"rounded-full",onClick:()=>n(e,{kind:"answer",payload:{confirmed:!0}}),children:"Confirm"})]})]})}function lqe({toolRequestId:e,toolName:t,args:n,onAnswer:r}){const i=["command","path","url","pattern","query"].find(a=>typeof n[a]=="string"&&String(n[a]).length>0),s=i!==void 0?n[i]:void 0,o=typeof s=="string"?s:JSON.stringify(n);return c.jsxs("div",{className:"rounded-2xl border border-border bg-background px-4 py-3 text-sm",children:[c.jsxs("div",{className:"flex items-baseline gap-2",children:[c.jsx("span",{className:"text-muted-foreground shrink-0",children:"Pending tool:"}),c.jsx("span",{className:"font-mono text-foreground",children:t})]}),o?c.jsx("pre",{className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:o}):null,c.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2",children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>r(e,{kind:"deny",reason:"user_canceled"}),children:"Deny"}),c.jsx(Re,{variant:"default",size:"sm",onClick:()=>r(e,{kind:"allow"}),children:"Allow"})]})]})}function cqe({entry:e,onAnswer:t}){const{toolRequestId:n,toolName:r,arguments:i}=e;if(r==="mcp__kanna__ask_user_question"){const o=(Array.isArray(i.questions)?i.questions.filter(Pr):[]).map(a=>{let l;return typeof a.question=="string"?l=a.question:typeof a.text=="string"?l=a.text:l="",{id:typeof a.id=="string"?a.id:void 0,question:l,header:typeof a.header=="string"?a.header:void 0,options:Array.isArray(a.options)?a.options.filter(Pr).filter(u=>typeof u.label=="string"):void 0,multiSelect:typeof a.multiSelect=="boolean"?a.multiSelect:!1}});return c.jsx(wae,{questions:o,onSubmit:a=>t(n,{kind:"answer",payload:{questions:o,answers:a}}),onCancel:()=>t(n,{kind:"deny",reason:"user_canceled"})})}if(r==="mcp__kanna__exit_plan_mode"){const s=typeof i.plan=="string"?i.plan:"";return c.jsx(aqe,{toolRequestId:n,plan:s,onAnswer:t})}return c.jsx(lqe,{toolRequestId:n,toolName:r,args:i,onAnswer:t})}const J3="mcp__kanna__delegate_subagent";function uqe(e){const t=[];for(const n of e){if(n.kind!=="tool"||n.toolKind!=="mcp_generic"||n.toolName!==J3)continue;const r=n.input.payload.subagent_id;typeof r=="string"&&t.push({toolId:n.toolId,subagentId:r})}return t}function dqe(e,t){const n=new Map;for(const a of t){const l=a.subagentId??"\0null",u=n.get(l)??[];u.push(a),n.set(l,u)}for(const a of n.values())a.sort((l,u)=>l.startedAt-u.startedAt||l.runId.localeCompare(u.runId));const r=new Map,i=new Set,s=new Map;for(const a of e){const l=n.get(a.subagentId);if(!l)continue;const u=s.get(a.subagentId)??0,f=l[u];f&&(r.set(a.toolId,f),i.add(f.runId),s.set(a.subagentId,u+1))}const o=t.filter(a=>!i.has(a.runId));return{matched:r,orphans:o}}function fqe(e,t){if(e.length===0)return;const n=e.map(i=>`${i.runId} (subagentId=${i.subagentId})`).join(", "),r=`Subagent run placement: ${e.length} orphan top-level run(s) with no delegate_subagent tool call: ${n}`;if(t)throw new Error(r);Os.error(r)}const hqe=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite",J3,MHe]),pqe=new Set(["offer_download","image_generation"]);function mqe(e){return e.kind==="tool"}function HV(e){return!mqe(e)||pqe.has(e.toolKind)?!1:!hqe.has(e.toolName)}function gqe(e,{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:s}){let o=!e.hidden;if(o)switch(e.kind){case"system_init":o=t;break;case"account_info":o=n;break;case"tool":o=e.toolKind!=="todo_write"||r;break;case"result":o=!i&&(!e.success||e.durationMs>6e4);break;case"context_window_updated":o=!1;break;case"status":o=s;break;default:o=!0;break}return{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:s,shouldRender:o}}function vqe(e,t){const n=e.findIndex(i=>i.kind==="system_init"),r=e.findIndex(i=>i.kind==="account_info");return e.map((i,s)=>{const o=e[s-1],a=e[s+1];return gqe(i,{isFirstSystem:n===s,isFirstAccount:r===s,isLatestTodoWrite:i.id===t.TodoWrite,hideResult:(a==null?void 0:a.kind)==="context_cleared"||(o==null?void 0:o.kind)==="context_cleared",isFinalStatus:s===e.length-1})})}function bqe(e,t){const n=[];let r=0;for(;r<e.length;){const i=e[r],s=t[r];if(s!=null&&s.shouldRender&&HV(i)){const o=[i],a=r;for(r+=1;r<e.length;){const l=e[r],u=t[r];if(!(u!=null&&u.shouldRender)){r+=1;continue}if(!HV(l))break;o.push(l),r+=1}o.length>=2?n.push({type:"tool-group",messages:o,startIndex:a}):n.push({type:"single",message:i,index:a});continue}n.push({type:"single",message:i,index:r}),r+=1}return n}function WV(e){var n;return e.type==="single"?e.message.id:`tool-group:${((n=e.messages[0])==null?void 0:n.id)??e.startIndex}`}function mj(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function xqe(e,t){return e.id===t.id&&e.kind===t.kind&&e.displayName===t.displayName&&e.absolutePath===t.absolutePath&&e.relativePath===t.relativePath&&e.contentUrl===t.contentUrl&&e.mimeType===t.mimeType&&e.size===t.size}function yqe(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>xqe(n,t[r]))}function Xv(e,t){var n,r;if(e===t)return!0;if(e.kind!==t.kind||e.id!==t.id||e.hidden!==t.hidden)return!1;switch(e.kind){case"user_prompt":return e.content===(t.kind==="user_prompt"?t.content:null)&&t.kind==="user_prompt"&&e.steered===t.steered&&((n=e.autoContinue)==null?void 0:n.scheduleId)===((r=t.autoContinue)==null?void 0:r.scheduleId)&&yqe(e.attachments,t.attachments);case"system_init":return t.kind==="system_init"&&e.provider===t.provider&&e.model===t.model&&mj(e.tools,t.tools)&&mj(e.agents,t.agents)&&mj(e.slashCommands,t.slashCommands)&&e.debugRaw===t.debugRaw;case"account_info":return t.kind==="account_info"&&JSON.stringify(e.accountInfo)===JSON.stringify(t.accountInfo);case"assistant_text":return t.kind==="assistant_text"&&e.text===t.text;case"assistant_thinking":return t.kind==="assistant_thinking"&&e.text===t.text;case"api_error":return t.kind==="api_error"&&e.status===t.status&&e.text===t.text&&e.requestId===t.requestId;case"policy_refusal":return t.kind==="policy_refusal"&&e.text===t.text&&e.requestId===t.requestId;case"tool":return t.kind==="tool"&&e.toolKind===t.toolKind&&e.toolName===t.toolName&&e.toolId===t.toolId&&e.isError===t.isError&&JSON.stringify(e.input)===JSON.stringify(t.input)&&JSON.stringify(e.result)===JSON.stringify(t.result)&&JSON.stringify(e.rawResult)===JSON.stringify(t.rawResult);case"result":return t.kind==="result"&&e.success===t.success&&e.cancelled===t.cancelled&&e.result===t.result&&e.durationMs===t.durationMs&&e.costUsd===t.costUsd&&e.codexErrorInfo===t.codexErrorInfo;case"status":return t.kind==="status"&&e.status===t.status;case"compact_summary":return t.kind==="compact_summary"&&e.summary===t.summary;case"context_window_updated":return t.kind==="context_window_updated"&&JSON.stringify(e.usage)===JSON.stringify(t.usage);case"memory_loaded":return t.kind==="memory_loaded"&&e.path===t.path;case"compact_boundary":case"context_cleared":case"interrupted":return!0;case"unknown":return t.kind==="unknown"&&e.json===t.json;case"auto_continue_prompt":return t.kind==="auto_continue_prompt"&&e.scheduleId===t.scheduleId;case"pending_tool_request":return t.kind==="pending_tool_request"&&e.toolRequestId===t.toolRequestId&&e.toolName===t.toolName;case"cron_armed":case"cron_command_error":case"cron_run":case"cron_run_skipped":case"cron_list":case"cron_job_change":return!0}}function _qe(e,t){return e.kind!==t.kind||e.id!==t.id?!1:e.kind==="single"&&t.kind==="single"?e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&Xv(e.message,t.message):e.kind==="tool-group"&&t.kind==="tool-group"?e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.messages.length===t.messages.length&&e.messages.every((n,r)=>Xv(n,t.messages[r])):!1}function Sqe(e,t){const n=new Map;let r=e.length!==t.byId.size;const i=e.map((s,o)=>{const a=t.byId.get(s.id),l=a&&_qe(a,s)?a:s;return n.set(s.id,l),!r&&t.result[o]!==l&&(r=!0),l});return r?{byId:n,result:i}:t}function wqe(e){const t=_.useRef({byId:new Map,result:[]}),n=_.useMemo(()=>Sqe(e,t.current),[e]);return _.useLayoutEffect(()=>{t.current=n}),n.result}const jae=(e,t)=>{},Cqe=_.memo(({message:e,index:t,isLoading:n,localPath:r,isFirstSystem:i,isFirstAccount:s,isLatestAskUserQuestion:o,isLatestExitPlanMode:a,isLatestTodoWrite:l,hideResult:u,isFinalStatus:f,onAskUserQuestionSubmit:h,onExitPlanModeConfirm:m,onToolRequestAnswer:g=jae,schedules:v,cronJobs:x,onAutoContinueAccept:y,onAutoContinueReschedule:w,onAutoContinueCancel:k,onRetryFailedTurn:C,chatId:E})=>{let N=null;if(e.kind==="user_prompt")N=c.jsx(ZKe,{content:e.content,attachments:e.attachments,steered:e.steered,autoContinue:e.autoContinue},e.id);else switch(e.kind){case"auto_continue_prompt":{const A=v[e.scheduleId];if(!A){N=c.jsx("div",{className:"rounded border px-3 py-2 text-sm opacity-70",children:"Auto-continue expired"},e.id);break}N=c.jsx(sqe,{schedule:A,onAccept:j=>y(e.scheduleId,j),onReschedule:j=>w(e.scheduleId,j),onCancel:()=>k(e.scheduleId)},e.id);break}case"unknown":N=c.jsx(eGe,{json:e.json},e.id);break;case"system_init":N=i?c.jsx(lGe,{message:e,rawJson:e.debugRaw},e.id):null;break;case"account_info":N=s?c.jsx(fGe,{message:e},e.id):null;break;case"assistant_text":N=c.jsx(dae,{message:e},e.id);break;case"assistant_thinking":N=c.jsx(fae,{message:e},e.id);break;case"api_error":N=c.jsx(AGe,{message:e},e.id);break;case"policy_refusal":N=c.jsx(MGe,{message:e},e.id);break;case"tool":if(e.isError){N=c.jsx(Zk,{message:e,isLoading:n,localPath:r,chatId:E},e.id);break}if(e.toolKind==="ask_user_question"){N=c.jsx(Y3,{message:e,onSubmit:h,isLatest:o},e.id);break}if(e.toolKind==="exit_plan_mode"){N=c.jsx(kae,{message:e,onConfirm:m,isLatest:a},e.id);break}if(e.toolKind==="todo_write"){N=l?c.jsx(IGe,{message:e},e.id):null;break}if(e.toolKind==="offer_download"&&e.result){N=c.jsx(DGe,{message:e},e.id);break}if(e.toolKind==="preview_file"&&e.result){N=c.jsx($Ge,{message:e},e.id);break}if(e.toolKind==="image_generation"){N=c.jsx(HGe,{message:e},e.id);break}N=c.jsx(Zk,{message:e,isLoading:n,localPath:r,chatId:E},e.id);break;case"result":N=u?null:c.jsx(xae,{message:e,onRetry:C},e.id);break;case"context_window_updated":N=null;break;case"interrupted":N=c.jsx(WGe,{message:e},e.id);break;case"compact_boundary":N=c.jsx(VGe,{},e.id);break;case"context_cleared":N=c.jsx(KGe,{},e.id);break;case"memory_loaded":N=c.jsx(GGe,{message:e},e.id);break;case"compact_summary":N=c.jsx(qGe,{message:e},e.id);break;case"status":N=f?c.jsx(XGe,{message:e},e.id):null;break;case"pending_tool_request":N=c.jsx(cqe,{entry:e,onAnswer:g},e.id);break;case"cron_armed":N=c.jsx(hGe,{message:e},e.id);break;case"cron_command_error":N=c.jsx(pGe,{message:e},e.id);break;case"cron_run":N=c.jsx(_Ge,{message:e,cronJobs:x},e.id);break;case"cron_run_skipped":N=c.jsx(kGe,{message:e},e.id);break;case"cron_list":N=c.jsx(CGe,{message:e,cronJobs:x},e.id);break;case"cron_job_change":N=c.jsx(gGe,{message:e},e.id);break}return N?c.jsx("div",{id:`msg-${e.id}`,className:"group relative","data-index":t,[Ly]:"",children:N}):null},(e,t)=>e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&e.onAskUserQuestionSubmit===t.onAskUserQuestionSubmit&&e.onExitPlanModeConfirm===t.onExitPlanModeConfirm&&e.onToolRequestAnswer===t.onToolRequestAnswer&&e.schedules===t.schedules&&e.cronJobs===t.cronJobs&&e.onAutoContinueAccept===t.onAutoContinueAccept&&e.onAutoContinueReschedule===t.onAutoContinueReschedule&&e.onAutoContinueCancel===t.onAutoContinueCancel&&e.chatId===t.chatId&&Xv(e.message,t.message)),kqe=_.memo(({id:e,messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:s,chatId:o})=>c.jsx("div",{className:"group relative",[Ly]:"",children:c.jsx(tqe,{messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:a=>s(e,a),chatId:o})}),(e,t)=>e.id===t.id&&e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.expanded===t.expanded&&e.onExpandedChange===t.onExpandedChange&&e.chatId===t.chatId&&e.messages.length===t.messages.length&&e.messages.every((n,r)=>Xv(n,t.messages[r])));function Mae(e,{isLoading:t,localPath:n,latestToolIds:r}){const i=vqe(e,r),s=bqe(e,i),o=[];for(const a of s){if(a.type==="tool-group"){o.push({kind:"tool-group",id:WV(a),startIndex:a.startIndex,messages:a.messages,isLoading:t&&a.messages.some(f=>f.kind==="tool"&&f.result===void 0),localPath:n});continue}const l=i[a.index];if(!l)continue;const u={kind:"single",id:WV(a),message:a.message,index:a.index,isLoading:a.message.kind==="tool"&&a.message.result===void 0&&t,localPath:n,isFirstSystem:l.isFirstSystem,isFirstAccount:l.isFirstAccount,isLatestAskUserQuestion:a.message.id===r.AskUserQuestion,isLatestExitPlanMode:a.message.id===r.ExitPlanMode,isLatestTodoWrite:l.isLatestTodoWrite,hideResult:l.hideResult,isFinalStatus:l.isFinalStatus};l.shouldRender&&o.push(u)}return o}const Eqe={};function Pae(e,t,n,r,i,s,o){const a=n.get(e.runId)??[];return c.jsxs(Dn.Fragment,{children:[c.jsx(Nae,{run:e,indentDepth:t,localPath:r,onSubagentAskUserQuestionSubmit:i,onSubagentExitPlanModeSubmit:s,onCancelSubagentRun:o}),a.map(l=>Pae(l,t+1,n,r,i,s,o))]},e.runId)}const Iae=_.memo(({row:e,toolGroupExpanded:t,onToolGroupExpandedChange:n,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:s,schedules:o,cronJobs:a,onAutoContinueAccept:l,onAutoContinueReschedule:u,onAutoContinueCancel:f,onRetryFailedTurn:h,chatId:m})=>e.kind==="tool-group"?c.jsx(kqe,{id:e.id,startIndex:e.startIndex,messages:e.messages,isLoading:e.isLoading,localPath:e.localPath,expanded:t??!1,onExpandedChange:n,chatId:m}):c.jsx(Cqe,{message:e.message,index:e.index,isLoading:e.isLoading,localPath:e.localPath,isFirstSystem:e.isFirstSystem,isFirstAccount:e.isFirstAccount,isLatestAskUserQuestion:e.isLatestAskUserQuestion,isLatestExitPlanMode:e.isLatestExitPlanMode,isLatestTodoWrite:e.isLatestTodoWrite,hideResult:e.hideResult,isFinalStatus:e.isFinalStatus,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:s,schedules:o,cronJobs:a,onAutoContinueAccept:l,onAutoContinueReschedule:u,onAutoContinueCancel:f,onRetryFailedTurn:h,chatId:m}),(e,t)=>{if(e.toolGroupExpanded!==t.toolGroupExpanded||e.onToolGroupExpandedChange!==t.onToolGroupExpandedChange||e.onAskUserQuestionSubmit!==t.onAskUserQuestionSubmit||e.onExitPlanModeConfirm!==t.onExitPlanModeConfirm||e.onToolRequestAnswer!==t.onToolRequestAnswer||e.schedules!==t.schedules||e.cronJobs!==t.cronJobs||e.onAutoContinueAccept!==t.onAutoContinueAccept||e.onAutoContinueReschedule!==t.onAutoContinueReschedule||e.onAutoContinueCancel!==t.onAutoContinueCancel||e.onRetryFailedTurn!==t.onRetryFailedTurn||e.chatId!==t.chatId||e.row.kind!==t.row.kind||e.row.id!==t.row.id)return!1;if(e.row.kind==="tool-group"&&t.row.kind==="tool-group"){const n=e.row,r=t.row;return n.startIndex===r.startIndex&&n.isLoading===r.isLoading&&n.localPath===r.localPath&&n.messages.length===r.messages.length&&n.messages.every((i,s)=>Xv(i,r.messages[s]))}return e.row.kind==="single"&&t.row.kind==="single"?e.row.index===t.row.index&&e.row.isLoading===t.row.isLoading&&e.row.localPath===t.row.localPath&&e.row.isFirstSystem===t.row.isFirstSystem&&e.row.isFirstAccount===t.row.isFirstAccount&&e.row.isLatestAskUserQuestion===t.row.isLatestAskUserQuestion&&e.row.isLatestExitPlanMode===t.row.isLatestExitPlanMode&&e.row.isLatestTodoWrite===t.row.isLatestTodoWrite&&e.row.hideResult===t.row.hideResult&&e.row.isFinalStatus===t.row.isFinalStatus&&Xv(e.row.message,t.row.message):!1}),Oae={},nE=[],Nqe=(e,t)=>{},Tqe=(e,t)=>{},Aqe=e=>{};function Rqe({messages:e,isLoading:t,localPath:n,latestToolIds:r,onOpenLocalLink:i,chatId:s,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:a,onToolRequestAnswer:l=jae,schedules:u=Oae,cronJobs:f=nE,onAutoContinueAccept:h=Nqe,onAutoContinueReschedule:m=Tqe,onAutoContinueCancel:g=Aqe,onRetryFailedTurn:v,onTunnelAccept:x,onTunnelStop:y,onTunnelRetry:w,subagentRuns:k=Eqe,onSubagentAskUserQuestionSubmit:C,onSubagentExitPlanModeSubmit:E,onCancelSubagentRun:N}){const A=kO.useScopedStore(D=>D.toolGroupExpanded),j=kO.useScopedStore(D=>D.setToolGroupExpanded),P=_.useMemo(()=>Mae(e,{isLoading:t,localPath:n,latestToolIds:r}),[t,r,n,e]),{matchedRunsByToolId:M,childrenByParentRunId:F}=_.useMemo(()=>{const D=[],B=new Map;for(const U of Object.values(k))if(U.parentRunId===null)D.push(U);else{const H=B.get(U.parentRunId)??[];H.push(U),B.set(U.parentRunId,H)}const I=(U,H)=>U.startedAt-H.startedAt||U.runId.localeCompare(H.runId);for(const U of B.values())U.sort(I);const{matched:V,orphans:z}=dqe(uqe(e),D);return fqe(z,!1),{matchedRunsByToolId:V,childrenByParentRunId:B}},[k,e]),W=_.useCallback((D,B)=>{j(D,B)},[j]);return c.jsx(oee,{onOpenLocalLink:i,children:P.map(D=>{const B=D.kind==="single"&&D.message.kind==="tool"&&D.message.toolName===J3?D.message.toolId:null,I=B?M.get(B):void 0;return c.jsxs("div",{className:"mx-auto max-w-[800px] pb-5","data-transcript-row-id":D.id,children:[c.jsx(Iae,{row:D,toolGroupExpanded:D.kind==="tool-group"?A[D.id]??!1:void 0,onToolGroupExpandedChange:W,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:a,onToolRequestAnswer:l,schedules:u,cronJobs:f,onAutoContinueAccept:h,onAutoContinueReschedule:m,onAutoContinueCancel:g,onRetryFailedTurn:v,chatId:s}),I?Pae(I,0,F,n??"",C,E,N):null]},D.id)})})}function jqe(e){return c.jsx(kO.Provider,{init:{},children:c.jsx(Rqe,{...e})})}_.memo(jqe);const Mqe=[];function Pqe(e,t){const n=e.findIndex(r=>r.id===t);if(n<0)return null;for(let r=n-1;r>=0;r-=1){const i=e[r];if((i==null?void 0:i.kind)!=="user_prompt")continue;const s=i.attachments??Mqe;if(!(i.content.trim().length===0&&s.length===0))return{content:i.content,attachments:[...s]}}return null}const Iqe=Object.freeze([]),gj=Qt((e,t)=>({sharesByChat:{},listForChat(n){return t().sharesByChat[n]??Iqe},setShares(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:r}}))},addShare(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:[...i.sharesByChat[n]??[],r]}}))},removeShare(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:(i.sharesByChat[n]??[]).filter(s=>s.tokenId!==r)}}))}})),Dae=_.createContext(null);function Oqe(e,t){return{getTheme:function(){return t??null}}}function Fs(){const e=_.useContext(Dae);return e==null&&(function(t,...n){const r=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const s of n)i.append("v",s);throw r.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),e}const Dqe=Ai?_.useLayoutEffect:_.useEffect,wC={tag:Zg};function Lqe({initialConfig:e,children:t}){const n=_.useMemo(()=>{const{theme:r,namespace:i,nodes:s,onError:o,editorState:a,html:l}=e,u=Oqe(null,r),f=j5({editable:e.editable,html:l,namespace:i,nodes:s,onError:h=>o(h,f),theme:r});return(function(h,m){if(m!==null){if(m===void 0)h.update(()=>{const g=Pn();if(g.isEmpty()){const v=Dt();g.append(v);const x=Ai?document.activeElement:null;(He()!==null||x!==null&&x===h.getRootElement())&&v.select()}},wC);else if(m!==null)switch(typeof m){case"string":{const g=h.parseEditorState(m);h.setEditorState(g,wC);break}case"object":h.setEditorState(m,wC);break;case"function":h.update(()=>{Pn().isEmpty()&&m(h)},wC)}}})(f,a),[f,u]},[]);return Dqe(()=>{const r=e.editable,[i]=n;i.setEditable(r===void 0||r)},[]),c.jsx(Dae.Provider,{value:n,children:t})}const $qe=Ai?_.useLayoutEffect:_.useEffect;function Fqe(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function Bqe(){return(function(e){const[t]=Fs(),n=_.useMemo(()=>e(t),[t,e]),[r,i]=_.useState(()=>n.initialValueFn()),s=_.useRef(r);return $qe(()=>{const{initialValueFn:o,subscribe:a}=n,l=o();return s.current!==l&&(s.current=l,i(l)),a(u=>{s.current=u,i(u)})},[n,e]),r})(Fqe)}const zqe={name:"@lexical/react/ReactProvider"};function Uqe(){return Pn().getTextContent()}function Hqe(e,t=!0){if(e)return!1;let n=Uqe();return t&&(n=n.trim()),n===""}function Wqe(e){if(!Hqe(e,!1))return!1;const t=Pn().getChildren(),n=t.length;if(n>1)return!1;for(let r=0;r<n;r++){const i=t[r];if(bn(i))return!1;if(be(i)){if(!Ha(i)||i.__indent!==0)return!1;const s=i.getChildren(),o=s.length;for(let a=0;a<o;a++){const l=s[r];if(!Fe(l))return!1}}}return!0}function Lae(e){return()=>Wqe(e)}function Vqe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const i of t)r.append("v",i);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Z3=Ai?_.useLayoutEffect:_.useEffect;function Kqe({editor:e,ErrorBoundary:t}){return(function(n,r){const[i,s]=_.useState(()=>n.getDecorators());return Z3(()=>n.registerDecoratorListener(o=>{Js.flushSync(()=>{s(o)})}),[n]),_.useEffect(()=>{s(n.getDecorators())},[n]),_.useMemo(()=>{const o=[],a=Object.keys(i);for(let l=0;l<a.length;l++){const u=a[l],f=c.jsx(r,{onError:m=>n._onError(m),children:c.jsx(_.Suspense,{fallback:null,children:i[u]})}),h=n.getElementByKey(u);h!==null&&o.push(Js.createPortal(f,h,u))}return o},[r,i,n])})(e,t)}function Gqe({editor:e,ErrorBoundary:t}){return(function(n){const r=J5.maybeFromEditor(n);if(r&&r.hasExtensionByName(zqe.name)){for(const i of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(i)&&Vqe(320,i);return!0}return!1})(e)?null:c.jsx(Kqe,{editor:e,ErrorBoundary:t})}function VV(e){return e.getEditorState().read(Lae(e.isComposing()))}function qqe({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){const[r]=Fs();return(function(i){Z3(()=>ji(ure(i),are(i)),[i])})(r),c.jsxs(c.Fragment,{children:[e,c.jsx(Yqe,{content:t}),c.jsx(Gqe,{editor:r,ErrorBoundary:n})]})}function Yqe({content:e}){const[t]=Fs(),n=(function(i){const[s,o]=_.useState(()=>VV(i));return Z3(()=>{function a(){const l=VV(i);o(l)}return a(),ji(i.registerUpdateListener(()=>{a()}),i.registerEditableListener(()=>{a()}))},[i]),s})(t),r=Bqe();return n?typeof e=="function"?e(r):e:null}const $ae=Ai?_.useLayoutEffect:_.useEffect;function Xqe({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:s,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:f,ariaOwns:h,ariaRequired:m,autoCapitalize:g,className:v,id:x,role:y="textbox",spellCheck:w=!0,style:k,tabIndex:C,"data-testid":E,...N},A){const[j,P]=_.useState(e.isEditable()),M=_.useCallback(W=>{W&&W.ownerDocument&&W.ownerDocument.defaultView?e.setRootElement(W):e.setRootElement(null)},[e]),F=_.useMemo(()=>(function(...W){return D=>{for(const B of W)typeof B=="function"?B(D):B!=null&&(B.current=D)}})(A,M),[M,A]);return $ae(()=>(P(e.isEditable()),e.registerEditableListener(W=>{P(W)})),[e]),c.jsx("div",{"aria-activedescendant":j?t:void 0,"aria-autocomplete":j?n:"none","aria-controls":j?r:void 0,"aria-describedby":i,...s!=null?{"aria-errormessage":s}:{},"aria-expanded":j&&y==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":f,"aria-owns":j?h:void 0,"aria-readonly":!j||void 0,"aria-required":m,autoCapitalize:g,className:v,contentEditable:j,"data-testid":E,id:x,ref:F,role:y,spellCheck:w,style:k,tabIndex:C,...N})}const Qqe=_.forwardRef(Xqe);function KV(e){return e.getEditorState().read(Lae(e.isComposing()))}const Jqe=_.forwardRef(Zqe);function Zqe(e,t){const{placeholder:n,...r}=e,[i]=Fs();return c.jsxs(c.Fragment,{children:[c.jsx(Qqe,{editor:i,...r,ref:t}),n!=null&&c.jsx(eYe,{editor:i,content:n})]})}function eYe({content:e,editor:t}){const n=(function(o){const[a,l]=_.useState(()=>KV(o));return $ae(()=>{function u(){const f=KV(o);l(f)}return u(),ji(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a})(t),[r,i]=_.useState(t.isEditable());if(_.useLayoutEffect(()=>(i(t.isEditable()),t.registerEditableListener(o=>{i(o)})),[t]),!n)return null;let s=null;return typeof e=="function"?s=e(r):e!==null&&(s=e),s===null?null:c.jsx("div",{"aria-hidden":!0,children:s})}function tYe(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;const s=t._selection,o=e._selection;if(i)return 1;if(!(Te(s)&&Te(o)&&o.isCollapsed()&&s.isCollapsed()))return 0;const a=(function(w,k,C){const E=w._nodeMap,N=[];for(const A of k){const j=E.get(A);j!==void 0&&N.push(j)}for(const[A,j]of C){if(!j)continue;const P=E.get(A);P===void 0||ki(P)||N.push(P)}return N})(t,n,r);if(a.length===0)return 0;if(a.length>1){const w=t._nodeMap,k=w.get(s.anchor.key),C=w.get(o.anchor.key);return k&&C&&!e._nodeMap.has(k.__key)&&Fe(k)&&k.__text.length===1&&s.anchor.offset===1?2:0}const l=a[0],u=e._nodeMap.get(l.__key);if(!Fe(u)||!Fe(l)||u.__mode!==l.__mode)return 0;const f=u.__text,h=l.__text;if(f===h)return 0;const m=s.anchor,g=o.anchor;if(m.key!==g.key||m.type!=="text")return 0;const v=m.offset,x=g.offset,y=h.length-f.length;return y===1&&x===v-1?2:y===-1&&x===v+1?3:y===-1&&x===v?4:0}function nYe(e,t,n){let r=n(),i=0,s=r,o=0,a=null;return(l,u,f,h,m,g)=>{const v=n();if(g.has(ete)&&(s=r,o=i,a=l),g.has(bP))return i=0,r=v,2;g.has(tte)&&a&&(r=s,i=o,l=a);const x=tYe(l,u,h,m,e.isComposing()),y=(()=>{const w=f===null||f.editor===e,k=g.has(XPe);if(!k&&w&&g.has(Zg))return 0;if(x===1)return 2;if(l===null)return 1;const C=u._selection;if(!(h.size>0||m.size>0))return C!==null?0:2;const E=typeof t=="number"?t:t.peek();return k===!1&&x!==0&&x===i&&v<r+E&&w||h.size===1&&(function(N,A,j){const P=A._nodeMap.get(N),M=j._nodeMap.get(N),F=A._selection,W=j._selection;return!(Te(F)&&Te(W)&&F.anchor.type==="element"&&F.focus.type==="element"&&W.anchor.type==="text"&&W.focus.type==="text"||!Fe(P)||!Fe(M)||P.__parent!==M.__parent)&&JSON.stringify(A.read(()=>P.exportJSON()))===JSON.stringify(j.read(()=>M.exportJSON()))})(Array.from(h)[0],l,u)?0:1})();return r=v,i=x,y}}function GV(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function Fae(e,t,n,r=Date.now,i,s=null){const o=nYe(e,n,r),a=()=>{i&&i(t)};return a(),ji(e.registerCommand(p5,()=>((function(l,u,f){const h=u.redoStack,m=u.undoStack;if(m.length!==0){const g=u.current,v=m.pop();g!==null&&(h.push(g),l.dispatchCommand(Bw,!0)),m.length===0&&l.dispatchCommand(zw,!1),u.current=v||null,f&&f(u),v&&v.editor.setEditorState(v.editorState,{tag:bP})}})(e,t,i),!0),Kt),e.registerCommand(m5,()=>((function(l,u,f){const h=u.redoStack,m=u.undoStack;if(h.length!==0){const g=u.current;g!==null&&(m.push(g),l.dispatchCommand(zw,!0));const v=h.pop();h.length===0&&l.dispatchCommand(Bw,!1),u.current=v||null,f&&f(u),v&&v.editor.setEditorState(v.editorState,{tag:bP})}})(e,t,i),!0),Kt),e.registerCommand(BPe,()=>(GV(t,i),!1),Kt),e.registerCommand(zPe,()=>(GV(t,i),e.dispatchCommand(Bw,!1),e.dispatchCommand(zw,!1),!0),Kt),e.registerUpdateListener(({editorState:l,prevEditorState:u,dirtyLeaves:f,dirtyElements:h,tags:m})=>{const g=t.current,v=t.redoStack,x=t.undoStack,y=g===null?null:g.editorState;if(g!==null&&l===y)return;const w=o(u,l,g,f,h,m);if(w===1){if(v.length!==0&&(t.redoStack=[],e.dispatchCommand(Bw,!1)),g!==null){x.push({...g});const k=typeof s=="number"||s===null?s:s.peek();k!==null&&x.length>k&&x.splice(0,x.length-k),e.dispatchCommand(zw,!0)}}else if(w===2)return;t.current={editor:e,editorState:l},a()}))}function Bae(){return{current:null,redoStack:[],undoStack:[]}}const vj={build:(e,{delay:t,createInitialHistoryState:n,disabled:r,maxDepth:i,now:s},o)=>({...Ju({delay:t,disabled:r,historyState:n(e),maxDepth:i,now:s}),...o.getInitResult()}),config:{createInitialHistoryState:Bae,delay:300,disabled:typeof window>"u",maxDepth:null,now:Date.now},init:()=>({canRedo:$u(!1),canUndo:$u(!1)}),name:"@lexical/history/History",register:(e,t,n)=>{const{canUndo:r,canRedo:i}=n.getInitResult(),s=n.getOutput(),o=a=>Y5(()=>{r.value=a!=null&&a.undoStack.length>0,i.value=a!=null&&a.redoStack.length>0});return _s(()=>{if(!s.disabled.value)return Fae(e,s.historyState.value,s.delay,()=>s.now.peek()(),o,s.maxDepth);o(null)})}};Qu(vj,{disabled:!0});function rYe({delay:e,externalHistoryState:t}){const[n]=Fs();return(function(r,i,s=1e3){const o=_.useMemo(()=>i||Bae(),[i]);_.useEffect(()=>Fae(r,o,s),[s,r,o])})(n,t,e),null}const zae=_.forwardRef(({className:e,children:t,...n},r)=>c.jsx("div",{ref:r,className:le("relative overflow-y-auto overscroll-contain touch-pan-y scrollbar-hide",e),style:{WebkitOverflowScrolling:"touch"},...n,children:t}));zae.displayName="ScrollArea";const qV="(display-mode: standalone)";function iYe(e={dom:Nt}){const[t,n]=_.useState(()=>{const r=e.dom.isIOSStandalone(),i=e.dom.matchesMediaQuery(qV);return r||i});return _.useEffect(()=>e.dom.addMediaQueryListener(qV,r=>{n(r||e.dom.isIOSStandalone())}),[e.dom]),t}const DO=Jt("InputPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function sYe(){return e=>({open:!1,query:"",setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:""}),closeAndClearQuery:()=>e({open:!1,query:""})})}const Ng=Jt("SearchableModelPopover",sYe);function oYe({className:e,...t}){return c.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:le("shrink-0",e),...t,children:c.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})})}function aYe({className:e,...t}){return c.jsx("svg",{viewBox:"0 0 158.7128 157.296",fill:"currentColor","aria-hidden":"true",className:le("shrink-0",e),...t,children:c.jsx("path",{d:"M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z"})})}function lYe({className:e,...t}){return c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:le("shrink-0",e),...t,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M6.3 6.3a8 8 0 1 0 11.4 11.4"}),c.jsx("path",{d:"M17.7 6.3a8 8 0 0 1 0 11.4"}),c.jsx("path",{d:"M2 12h4"}),c.jsx("path",{d:"M18 12h4"})]})}const YV={claude:oYe,codex:aYe,openrouter:lYe};function Ll({onClick:e,selected:t,icon:n,label:r,description:i,disabled:s}){return c.jsxs("button",{onClick:e,disabled:s,className:le("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",t?"bg-muted border-border":"hover:opacity-60",s&&"opacity-40 cursor-not-allowed"),children:[n,c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium",children:r}),i?c.jsx("div",{className:"text-xs text-muted-foreground",children:i}):null]})]})}function bg({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?c.jsx("button",{disabled:!0,className:le("flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap",t),children:e}):c.jsx(DO.Provider,{init:void 0,children:c.jsx(cYe,{trigger:e,triggerClassName:t,children:r})})}function cYe({trigger:e,triggerClassName:t,children:n}){const r=DO.useScopedStore(s=>s.open),i=DO.useScopedStore(s=>s.setOpen);return c.jsxs(bc,{open:r,onOpenChange:i,children:[c.jsx(xc,{asChild:!0,children:c.jsx("button",{type:"button",className:le("flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap","hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),children:e})}),c.jsx(_l,{align:"center",className:"w-64 p-1",children:c.jsx("div",{className:"space-y-1",children:typeof n=="function"?n(()=>i(!1)):n})})]})}function uYe({models:e,selectedModel:t,onSelect:n,ModelIcon:r}){return c.jsx(Ng.Provider,{init:void 0,children:c.jsx(dYe,{models:e,selectedModel:t,onSelect:n,ModelIcon:r})})}function dYe({models:e,selectedModel:t,onSelect:n,ModelIcon:r}){var g;const i=Ng.useScopedStore(v=>v.open),s=Ng.useScopedStore(v=>v.query),o=Ng.useScopedStore(v=>v.setPopoverOpen),a=Ng.useScopedStore(v=>v.setQuery),l=Ng.useScopedStore(v=>v.closeAndClearQuery),u=_.useCallback(v=>{n(v),l()},[n,l]),f=((g=e.find(v=>v.id===t))==null?void 0:g.label)??t,h=_.useMemo(()=>{const v=s.trim().toLowerCase();return v?e.filter(x=>x.id.toLowerCase().includes(v)||x.label.toLowerCase().includes(v)):e},[e,s]);let m;return e.length===0?m=c.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground text-center",children:"Loading models… verify OpenRouter API key in Settings."}):h.length===0?m=c.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground text-center",children:"No matches"}):m=h.map(v=>c.jsx(Ll,{onClick:()=>u(v.id),selected:t===v.id,icon:c.jsx(qj,{className:"h-4 w-4 text-muted-foreground"}),label:v.label,description:v.id},v.id)),c.jsxs(bc,{open:i,onOpenChange:o,children:[c.jsx(xc,{asChild:!0,children:c.jsxs("button",{type:"button",className:le("flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap","hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[c.jsx(r,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"max-w-[200px] truncate",children:f})]})}),c.jsxs(_l,{align:"center",className:"w-80 p-1",children:[c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border/50",children:[c.jsx(zg,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),c.jsx("input",{type:"text",value:s,onChange:v=>a(v.target.value),placeholder:"Search models...",autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),c.jsx("div",{className:"max-h-72 overflow-y-auto py-1 space-y-1",children:m})]})]})}function LO({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,showCodexCliRequirementHints:r=!1,model:i,modelOptions:s,onProviderChange:o,onModelChange:a,onModelOptionChange:l,planMode:u=!1,onPlanModeChange:f,includePlanMode:h=!0,className:m}){var M,F,W,D,B;const g=jr(F0),v=e.find(I=>I.id===t)??e[0],x=YV[t],y=qj,w=h&&(v==null?void 0:v.supportsPlanMode)&&f,k=t==="claude"&&"contextWindow"in s?s:null,C=t==="codex"&&"fastMode"in s?s:null,E=((M=v.models.find(I=>I.id===i))==null?void 0:M.contextWindowOptions)??[],N=(k==null?void 0:k.contextWindow)??Kh[0].id,A=N==="1m"?Oz:Dz,j=((F=v.models.find(I=>I.id===i))==null?void 0:F.label)??i,P=t==="openrouter"?c.jsx(uYe,{models:v.models,selectedModel:i,onSelect:I=>a==null?void 0:a(t,I),ModelIcon:y}):c.jsx(bg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(y,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:j})]}),children:I=>v.models.map(V=>{const z=qj;return c.jsx(Ll,{onClick:()=>{a==null||a(t,V.id),I()},selected:i===V.id,icon:c.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),label:r&&t==="codex"&&V.id==="gpt-5.5"?c.jsxs(c.Fragment,{children:[V.label," ",c.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"codex-cli >= 0.124"})]}):V.label},V.id)})});return c.jsxs("div",{className:le("flex md:justify-center items-center gap-0.5",m),children:[n?c.jsx(bg,{disabled:!o,trigger:c.jsxs(c.Fragment,{children:[c.jsx(x,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:(v==null?void 0:v.label)??t})]}),children:I=>e.map(V=>{const z=YV[V.id];return c.jsx(Ll,{onClick:()=>{o==null||o(V.id),I()},selected:t===V.id,icon:c.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),label:V.label},V.id)})}):null,a==null?c.jsx(Qo,{label:"Model is locked while a cron job is running — pause or remove the cron job to change it",side:"top",children:c.jsxs("span",{"aria-disabled":"true",className:"flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap",children:[c.jsx(WG,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:j})]})}):P,t!=="openrouter"?c.jsx(bg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(TC,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:t==="claude"?((W=Gy.find(I=>I.id===s.reasoningEffort))==null?void 0:W.label)??s.reasoningEffort:((D=U1.find(I=>I.id===s.reasoningEffort))==null?void 0:D.label)??s.reasoningEffort})]}),children:I=>t==="claude"?Gy.map(V=>c.jsx(Ll,{onClick:()=>{l({type:"claudeReasoningEffort",effort:V.id}),I()},selected:s.reasoningEffort===V.id,icon:c.jsx(TC,{className:"h-4 w-4 text-muted-foreground"}),label:V.label,disabled:V.id==="max"&&!kQ(i,g)},V.id)):U1.map(V=>c.jsx(Ll,{onClick:()=>{l({type:"codexReasoningEffort",effort:V.id}),I()},selected:s.reasoningEffort===V.id,icon:c.jsx(TC,{className:"h-4 w-4 text-muted-foreground"}),label:V.label},V.id))}):null,t==="claude"&&E.length>1?c.jsx(bg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(A,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:((B=E.find(I=>I.id===N))==null?void 0:B.label)??N})]}),children:I=>E.map(V=>c.jsx(Ll,{onClick:()=>{l({type:"contextWindow",contextWindow:V.id}),I()},selected:N===V.id,icon:V.id==="1m"?c.jsx(Oz,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(Dz,{className:"h-4 w-4 text-muted-foreground"}),label:V.label,description:V.id==="1m"?"Expanded context window":"Standard context window"},V.id))}):null,t==="codex"?c.jsx(bg,{trigger:c.jsxs(c.Fragment,{children:[C!=null&&C.fastMode?c.jsx(tw,{className:"h-3.5 w-3.5"}):c.jsx(tw,{className:"h-3.5 w-3.5 -scale-x-100"}),c.jsx("span",{children:C!=null&&C.fastMode?"Fast Mode":"Standard"})]}),triggerClassName:C!=null&&C.fastMode?"text-success":void 0,children:I=>c.jsxs(c.Fragment,{children:[c.jsx(Ll,{onClick:()=>{l({type:"fastMode",fastMode:!1}),I()},selected:!(C!=null&&C.fastMode),icon:c.jsx(tw,{className:"h-4 w-4 text-muted-foreground -scale-x-100"}),label:"Standard"}),c.jsx(Ll,{onClick:()=>{l({type:"fastMode",fastMode:!0}),I()},selected:!!(C!=null&&C.fastMode),icon:c.jsx(tw,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast Mode"})]})}):null,w?c.jsx(bg,{trigger:c.jsxs(c.Fragment,{children:[u?c.jsx(k1,{className:"h-3.5 w-3.5"}):c.jsx(jz,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:u?"Plan Mode":"Full Access"})]}),triggerClassName:u?"text-info":void 0,children:I=>c.jsxs(c.Fragment,{children:[c.jsx(Ll,{onClick:()=>{f(!1),I()},selected:!u,icon:c.jsx(jz,{className:"h-4 w-4 text-muted-foreground"}),label:"Full Access",description:"Execution without approval"}),c.jsx(Ll,{onClick:()=>{f(!0),I()},selected:u,icon:c.jsx(k1,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan Mode",description:"Review a plan before execution"})]})}):null]})}function fYe(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,"")}%`:`${Math.round(e)}%`}function XV({usage:e}){const t=fYe(e.usedPercentage),n=Math.max(0,Math.min(100,e.usedPercentage??0)),r=9.75,i=2*Math.PI*r,s=i-n/100*i;return c.jsxs(bc,{children:[c.jsx(xc,{asChild:!0,children:c.jsx("button",{type:"button",className:"group inline-flex h-9 w-9 cursor-pointer touch-manipulation items-center justify-center rounded-full transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e.maxTokens!==void 0&&t?`Context window ${t} used`:`Context window ${bo(e.usedTokens)} tokens used`,children:c.jsxs("span",{className:"relative flex h-6 w-6 items-center justify-center",children:[c.jsxs("svg",{viewBox:"0 0 24 24",className:"-rotate-90 absolute inset-0 h-full w-full transform-gpu","aria-hidden":"true",children:[c.jsx("circle",{cx:"12",cy:"12",r,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-muted-foreground/20"}),c.jsx("circle",{cx:"12",cy:"12",r,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:s,className:"text-muted-foreground transition-[stroke-dashoffset] duration-500 ease-out"})]}),c.jsx("span",{className:le("relative flex h-[15px] w-[15px] items-center justify-center rounded-full bg-background text-[9px] font-medium","text-muted-foreground"),children:e.usedPercentage!==null?Math.round(e.usedPercentage):bo(e.usedTokens)})]})})}),c.jsx(_l,{side:"top",align:"center",className:"w-max max-w-none px-3 py-2",children:c.jsx("div",{className:"space-y-1.5 leading-tight",children:e.maxTokens!==void 0&&t?c.jsxs("div",{className:"whitespace-nowrap text-xs font-medium text-foreground",children:[c.jsx("span",{children:t}),c.jsx("span",{className:"mx-1",children:"·"}),c.jsx("span",{children:bo(e.usedTokens)}),c.jsx("span",{children:"/"}),c.jsxs("span",{children:[bo(e.maxTokens)," context used"]})]}):c.jsxs("div",{className:"text-sm text-foreground",children:[bo(e.usedTokens)," tokens used so far"]})})})]})}function QV({totals:e,className:t}){if(!e)return null;const n=e.cacheHitPercentage===null?null:hYe(e.cacheHitPercentage),i=e.costUsd>0?rKe(e.costUsd):null;return c.jsxs(bc,{children:[c.jsx(xc,{asChild:!0,children:c.jsxs("button",{type:"button","aria-label":pYe(e,n,i),className:le("inline-flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 rounded-md bg-muted/30 px-2.5 py-1.5 text-xs tabular-nums text-muted-foreground transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),children:[c.jsx(bj,{label:"in",value:bo(e.inputTokens)}),c.jsx(xj,{}),c.jsx(bj,{label:"out",value:bo(e.outputTokens)}),n!==null?c.jsxs(c.Fragment,{children:[c.jsx(xj,{}),c.jsx(bj,{label:"cache",value:n})]}):null,i!==null?c.jsxs(c.Fragment,{children:[c.jsx(xj,{}),c.jsx("span",{className:"tabular-nums",children:i})]}):null]})}),c.jsx(_l,{side:"top",align:"center",className:"w-max max-w-none px-3 py-2",children:c.jsxs("div",{className:"space-y-1 text-xs leading-tight",children:[c.jsx(Bx,{label:"Input",value:bo(e.inputTokens)}),c.jsx(Bx,{label:"Output",value:bo(e.outputTokens)}),c.jsx(Bx,{label:"Cache read",value:bo(e.cachedTokens)}),n!==null?c.jsx(Bx,{label:"Cache hit",value:n}):null,i!==null?c.jsx(Bx,{label:"Cost",value:i}):null]})})]})}function bj({label:e,value:t}){return c.jsxs("span",{className:"inline-flex items-baseline gap-1 tabular-nums",children:[c.jsx("span",{className:"font-medium text-foreground",children:t}),c.jsx("span",{children:e})]})}function xj(){return c.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50",children:"·"})}function Bx({label:e,value:t}){return c.jsxs("div",{className:"flex items-baseline justify-between gap-6 whitespace-nowrap",children:[c.jsx("span",{className:"text-muted-foreground",children:e}),c.jsx("span",{className:"font-medium tabular-nums text-foreground",children:t})]})}function hYe(e){const t=Math.max(0,Math.min(100,e));return t<10?`${t.toFixed(1).replace(/\.0$/,"")}%`:`${Math.round(t)}%`}function pYe(e,t,n){const r=[`Input ${bo(e.inputTokens)}`,`Output ${bo(e.outputTokens)}`,`Cache ${bo(e.cachedTokens)}`];return t!==null&&r.push(`hit ${t}`),n!==null&&r.push(`cost ${n}`),`Session tokens: ${r.join(", ")}`}class Uae extends Error{constructor(){super("Upload aborted"),this.name="UploadAbortedError"}}const mYe=80;function e$(e){const t=e.XHR??XMLHttpRequest,n=new t;let r=!1,i=0,s=-1;return{promise:new Promise((a,l)=>{function u(h,m,g=!1){const v=m>0?m:e.file.size,x=v>0?Math.floor(h/v*100):0,y=Date.now(),w=y-i>=mYe;!g&&!w&&!(x!==s)||(i=y,s=x,e.onProgress({loaded:h,total:v}))}n.upload.addEventListener("progress",h=>{u(h.loaded,h.lengthComputable?h.total:e.file.size)}),n.upload.addEventListener("load",()=>{u(e.file.size,e.file.size,!0)}),n.addEventListener("load",()=>{if(r)return;let h;try{h=n.responseText?JSON.parse(n.responseText):null}catch{h=null}if(n.status>=200&&n.status<300){const g=h==null?void 0:h.attachments;if(!Array.isArray(g)){l(new Error("Upload failed: malformed response"));return}a({attachments:g});return}const m=h==null?void 0:h.error;l(new Error(typeof m=="string"?m:"Upload failed"))}),n.addEventListener("error",()=>{r||l(new Error("Upload failed"))}),n.addEventListener("abort",()=>{l(new Uae)});const f=new FormData;f.append("files",e.file),n.open("POST",`/api/projects/${encodeURIComponent(e.projectId)}/uploads`),n.send(f)}),abort:()=>{if(!r){r=!0;try{n.abort()}catch{}}}}}const gYe="(^|[\\s\\n\\t])@agent/([a-z0-9_-]+)";function vYe(){return new RegExp(gYe,"gi")}const bYe=Ai?_.useLayoutEffect:_.useEffect;class Hae{constructor(t){K(this,"key");K(this,"ref");K(this,"icon");K(this,"title");this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const JV=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function ZV(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function xYe(e,t,n,r){const[i]=Fs();_.useEffect(()=>{if(t!=null&&e!=null){const s=i.getRootElement(),o=s!=null?(function(h){let m=getComputedStyle(h);const g=m.position==="absolute",v=/(auto|scroll)/;if(m.position==="fixed")return document.body;for(let x=h;x=x.parentElement;)if(m=getComputedStyle(x),(!g||m.position!=="static")&&v.test(m.overflow+m.overflowY+m.overflowX))return x;return document.body})(s):document.body;let a=!1,l=ZV(t,o);const u=function(){a||(window.requestAnimationFrame(function(){n(),a=!1}),a=!0);const h=ZV(t,o);h!==l&&(l=h,r!=null&&r(h))},f=new ResizeObserver(n);return window.addEventListener("resize",n),document.addEventListener("scroll",u,{capture:!0,passive:!0}),f.observe(t),()=>{f.unobserve(t),window.removeEventListener("resize",n),document.removeEventListener("scroll",u,!0)}}},[t,i,r,n,e])}const eK=yt("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function yYe({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let s="item";return t&&(s+=" selected"),c.jsxs("li",{tabIndex:-1,className:s,ref:i.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:r,onClick:n,children:[i.icon,c.jsx("span",{className:"text",children:i.title})]},i.key)}function _Ye({close:e,editor:t,anchorElementRef:n,resolution:r,options:i,menuRenderFn:s,onSelectOption:o,shouldSplitNodeWithQuery:a=!1,commandPriority:l=Sa,preselectFirstItem:u=!0}){const[f,h]=_.useState(null),m=f!==null?Math.min(i.length-1,f):null,g=r.match&&r.match.matchingString;_.useEffect(()=>{u&&h(0)},[g,u]);const v=_.useCallback(k=>{t.update(()=>{const C=r.match!=null&&a?(function(E){const N=He();if(!Te(N)||!N.isCollapsed())return null;const A=N.anchor;if(A.type!=="text")return null;const j=A.getNode();if(!j.isSimpleText())return null;const P=A.offset,M=j.getTextContent().slice(0,P),F=E.replaceableString.length,W=P-(function(B,I,V){let z=V;for(let U=z;U<=I.length;U++)B.slice(-U)===I.substring(0,U)&&(z=U);return z})(M,E.matchingString,F);if(W<0)return null;let D;return W===0?[D]=j.splitText(P):[,D]=j.splitText(W,P),D})(r.match):null;o(k,C,e,r.match?r.match.matchingString:"")})},[t,a,r.match,o,e]),x=_.useCallback(k=>{const C=t.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+k),h(k))},[t]),y=_.useCallback(()=>n.current&&i.length?xG.createPortal(c.jsx("div",{className:"typeahead-popover mentions-menu",children:c.jsx("ul",{children:i.map((k,C)=>c.jsx(yYe,{index:C,isSelected:m===C,onClick:()=>{h(C),v(k)},onMouseEnter:()=>{h(C)},option:k},k.key))})}),n.current):null,[n,i,m,v,h]);_.useEffect(()=>()=>{const k=t.getRootElement();k!==null&&k.removeAttribute("aria-activedescendant")},[t]),bYe(()=>{i===null?h(null):m===null&&u&&x(0)},[i,m,x,u]),_.useEffect(()=>ji(t.registerCommand(eK,({option:k})=>!(!k.ref||k.ref.current==null)&&(JV(k.ref.current),!0),l)),[t,x,l]),_.useEffect(()=>ji(t.registerCommand(sN,k=>{const C=k;if(i!==null&&i.length){const E=m===null?0:m!==i.length-1?m+1:0;x(E);const N=i[E];if(!N)return x(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;N.ref&&N.ref.current&&t.dispatchCommand(eK,{index:E,option:N}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),t.registerCommand(iN,k=>{const C=k;if(i!==null&&i.length){const E=m===null?i.length-1:m!==0?m-1:i.length-1;x(E);const N=i[E];if(!N)return x(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;N.ref&&N.ref.current&&JV(N.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),t.registerCommand(oN,k=>{const C=k;return C.preventDefault(),C.stopImmediatePropagation(),e(),!0},l),t.registerCommand(N0,k=>{const C=k;return i!==null&&m!==null&&i[m]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),v(i[m]),!0)},l),t.registerCommand(Pp,k=>!(i===null||m===null||i[m]==null||k&&k.shiftKey)&&(k!==null&&(k.preventDefault(),k.stopImmediatePropagation()),v(i[m]),!0),l)),[v,e,t,i,m,x,l]);const w=_.useMemo(()=>({options:i,selectOptionAndCleanUp:v,selectedIndex:m,setHighlightedIndex:h}),[v,m,i]);return s!=null?s(n,w,r.match?r.match.matchingString:""):y()}function tK(e,t){t!=null&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const nK="startTransition";function Wae({options:e,onQueryChange:t,onSelectOption:n,onOpen:r,onClose:i,menuRenderFn:s,triggerFn:o,anchorClassName:a,commandPriority:l=Sa,parent:u,preselectFirstItem:f=!0,ignoreEntityBoundary:h=!1}){const[m]=Fs(),[g,v]=_.useState(null),x=(function(k,C,E,N=Ai?document.body:void 0,A=!0){const[j]=Fs(),P=Ai?document.createElement("div"):null,M=_.useRef(P),F=_.useCallback(()=>{if(M.current===null||N===void 0)return;M.current.style.top=M.current.style.bottom;const D=j.getRootElement(),B=M.current,I=B.firstChild;if(D!==null&&k!==null){const{left:V,top:z,width:U,height:H}=k.getRect(),$=M.current.offsetHeight;if(B.style.top=`${z+$+3+(A?window.pageYOffset:0)}px`,B.style.left=`${V+window.pageXOffset}px`,B.style.height=`${H}px`,B.style.width=`${U}px`,I!==null){I.style.top=`${z}`;const q=I.getBoundingClientRect(),O=q.height,J=q.width,ne=D.getBoundingClientRect();V+J>ne.right&&(B.style.left=`${ne.right-J+window.pageXOffset}px`),(z+O>window.innerHeight||z+O>ne.bottom)&&z-ne.top>O+H&&(B.style.top=`${z-O-H+(A?window.pageYOffset:0)}px`)}B.isConnected||(tK(B,E),N.append(B)),B.setAttribute("id","typeahead-menu"),D.setAttribute("aria-controls","typeahead-menu")}},[j,k,A,E,N]);_.useEffect(()=>{const D=j.getRootElement();return k!==null&&F(),()=>{D!==null&&D.removeAttribute("aria-controls");const B=M.current;B!==null&&B.isConnected&&(B.remove(),B.removeAttribute("id"))}},[j,F,k]);const W=_.useCallback(D=>{k!==null&&(D||C(null))},[k,C]);return xYe(k,M.current,F,W),P!=null&&P===M.current&&(tK(P,E),N!=null&&N.append(P)),M})(g,v,a,u),y=_.useCallback(()=>{if(g===null)return;const k=()=>{v(null)};let C;try{C=i&&i()}finally{C?C.then(k,k):k()}},[i,g]),w=_.useCallback(k=>{v(k),r!=null&&g===null&&r(k)},[r,g]);return _.useEffect(()=>{const k=m.registerUpdateListener(()=>{m.getEditorState().read(()=>{if(!m.isEditable())return void y();if(m.isComposing())return;const C=m._window||window,E=C.document.createRange(),N=He(),A=(function(M){let F=null;return M.getEditorState().read(()=>{const W=He();Te(W)&&(F=(function(D){const B=D.anchor;if(B.type!=="text")return null;const I=B.getNode();if(!I.isSimpleText())return null;const V=B.offset;return I.getTextContent().slice(0,V)})(W))}),F})(m);if(!Te(N)||!N.isCollapsed()||A===null||E===null)return void y();const j=o(A,m);if(t(j?j.matchingString:null),j!==null&&(h||!(function(M,F){return F===0&&M.getEditorState().read(()=>{const W=He();if(Te(W)){const D=W.anchor.getNode().getPreviousSibling();return Fe(D)&&D.isTextEntity()}return!1})})(m,j.leadOffset))&&(function(F,W,D){const B=ns(D);if(B===null||!B.isCollapsed)return!1;const I=B.anchorNode,V=F,z=B.anchorOffset;if(I==null||z==null)return!1;try{W.setStart(I,V),W.setEnd(I,z)}catch{return!1}return!0})(j.leadOffset,E,C)!==null)return P=()=>w({getRect:()=>E.getBoundingClientRect(),match:j}),void(nK in Dn?Dn[nK](P):P());var P;y()})});return()=>{k()}},[m,o,t,g,y,w,h]),_.useEffect(()=>m.registerEditableListener(k=>{k||y()}),[m,y]),g===null||m===null||x.current===null?null:c.jsx(_Ye,{close:y,resolution:g,editor:m,anchorElementRef:x,options:e,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:l,preselectFirstItem:f})}async function SYe(e,t,n={}){const r=n.http??yc,i=new URLSearchParams({query:t});try{const s=await r.getJson(`/api/projects/${encodeURIComponent(e)}/paths?${i.toString()}`,{signal:n.signal});return s.ok?s.data.paths??[]:[]}catch{return[]}}const wYe=120,CYe={http:yc,timer:ar},kYe={items:[],loading:!1,error:null};function EYe(e){const{http:t,timer:n}=e.ports??CYe,r=br.useScopedStore(l=>l.mentionSuggestions),i=br.useScopedStore(l=>l.setMentionSuggestions),s=br.useScopedStoreApi(),o=_.useRef(null),a=_.useRef(null);return _.useEffect(()=>{var u;if(!e.enabled||!e.projectId){i(kYe);return}o.current!==null&&n.clearTimeout(o.current),(u=a.current)==null||u.abort(),i({items:s.getState().mentionSuggestions.items,loading:!0,error:null});const l=new AbortController;return a.current=l,o.current=n.setTimeout(()=>{SYe(e.projectId,e.query,{signal:l.signal,http:t}).then(f=>{l.signal.aborted||i({items:f,loading:!1,error:null})})},wYe),()=>{o.current!==null&&n.clearTimeout(o.current),l.abort()}},[e.enabled,e.projectId,e.query,t,n,i,s]),r}const NYe=[];function TYe(e,t){const n=t.toLowerCase();if(n&&!("agent/".startsWith(n)||n.startsWith("agent/")))return[];const r=n.startsWith("agent/")?n.slice(6):"";return e.filter(i=>i.name.toLowerCase().includes(r)).sort((i,s)=>i.name.localeCompare(s.name)).map(i=>({kind:"agent",subagent:i}))}function AYe(e){const t=jr(n=>{var r;return((r=n.settings)==null?void 0:r.subagents)??NYe});return _.useMemo(()=>({items:e.enabled?TYe(t,e.query):[]}),[e.enabled,e.query,t])}const RYe=/(?:^|\s)(@((?:[^@\s]){0,200}))$/;function jYe(){return _.useCallback((e,t)=>{const n=RYe.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??"",replaceableString:n[1]}},[])}class rK extends Hae{constructor(n){const r=n.kind==="agent"?`agent:${n.subagent.id}`:`path:${n.path.kind}:${n.path.path}`;super(r);K(this,"data");this.data=n}}function MYe({projectId:e}){const t=br.useScopedStore(h=>h.mentionQuery),n=br.useScopedStore(h=>h.setMentionQuery),r=jYe(),i=t!==null,s=EYe({projectId:e,query:t??"",enabled:i}),o=AYe({query:t??"",enabled:i}),a=_.useMemo(()=>{const h=o.items.map(g=>new rK({kind:"agent",subagent:g.subagent})),m=s.items.map(g=>new rK({kind:"path",path:g}));return[...h,...m]},[o.items,s.items]),l=_.useCallback(h=>{n(h)},[n]),u=_.useCallback((h,m,g)=>{const v=h.data,x=v.kind==="agent"?aI({mentionKind:"agent",value:v.subagent.name,label:v.subagent.name}):aI({mentionKind:"path",value:v.path.path,label:v.path.path});m!==null?m.replace(x):R0([x]);const y=Bn(" ");x.insertAfter(y),y.select(),g()},[]),f=_.useCallback((h,{selectedIndex:m,selectOptionAndCleanUp:g,setHighlightedIndex:v,options:x})=>{if(h.current==null||x.length===0&&!s.loading)return null;const y=(w,k)=>{w.preventDefault(),g(k)};return c.jsx("ul",{role:"listbox","data-kanna-typeahead-menu":"mention",className:"absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md",children:s.loading&&x.length===0?Array.from({length:4}).map((w,k)=>c.jsxs("li",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":"true",children:[c.jsx("span",{className:"h-3.5 w-3.5 rounded bg-muted animate-pulse"}),c.jsx("span",{className:"h-3 w-40 max-w-full rounded bg-muted animate-pulse"})]},k)):x.map((w,k)=>{const C=k===m,E=w.data,N=E.kind==="path"?E.path:null,A=(N==null?void 0:N.kind)==="dir"?BG:J_;let j;return E.kind==="agent"?j=c.jsxs(c.Fragment,{children:[c.jsx(Df,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsxs("span",{className:"font-mono truncate",children:["agent/",E.subagent.name]}),E.subagent.description?c.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:E.subagent.description}):null]}):N?j=c.jsxs(c.Fragment,{children:[c.jsx(A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"font-mono truncate",children:N.path})]}):j=null,c.jsxs("li",{ref:w.setRefElement,role:"option","aria-selected":C,onMouseDown:P=>y(P,w),onMouseEnter:()=>v(k),className:le("flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm",C&&"bg-accent text-accent-foreground"),children:[c.jsx(phe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),j]},w.key)})})},[s.loading]);return c.jsx(Wae,{options:a,onQueryChange:l,onSelectOption:u,triggerFn:r,menuRenderFn:f})}const iK=[];function PYe(e,t){return t?e.byProjectId[t]??iK:iK}function IYe(e){return qie(t=>PYe(t,e))}function $O(e){return e.replace(/^\/+/,"")}const sK={project:0,personal:0,builtin:1,plugin:2};function yj(e,t){const n=(sK[e.scope??""]??1)-(sK[t.scope??""]??1);return n!==0?n:e.name.localeCompare(t.name)}function OYe(e,t){return t!=="codex"?e:e.filter(n=>n.scope==="builtin")}function DYe(e,t){if(t==="")return[...e].sort(yj);const n=t.toLowerCase(),r=[],i=[];for(const s of e){const o=s.name.toLowerCase();o.startsWith(n)?r.push(s):o.includes(n)&&i.push(s)}return[...r.sort(yj),...i.sort(yj)]}const LYe=/(?:^|\s)(\/(\S*))$/;function $Ye(){return _.useCallback((e,t)=>{const n=LYe.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??"",replaceableString:n[1]}},[])}class FYe extends Hae{constructor(n){super(n.name);K(this,"command");this.command=n}}function BYe(e){const t=new Set,n=[];for(const r of e){const i=$O(r.name);t.has(i)||(t.add(i),n.push(r))}return n}function zYe({projectId:e,provider:t}){const n=br.useScopedStore(f=>f.slashQuery),r=br.useScopedStore(f=>f.setSlashQuery),i=IYe(e),s=$Ye(),o=_.useMemo(()=>{const f=OYe(i,t),h=DYe(f,n??"");return BYe(h).map(m=>new FYe(m))},[t,i,n]),a=_.useCallback(f=>{r(f)},[r]),l=_.useCallback((f,h,m)=>{const g=f.command,v=Dre({commandName:$O(g.name),hasArgument:!!g.argumentHint});h!==null?h.replace(v):R0([v]);const x=Bn(" ");v.insertAfter(x),x.select(),m()},[]),u=_.useCallback((f,{selectedIndex:h,selectOptionAndCleanUp:m,setHighlightedIndex:g,options:v})=>{if(f.current==null||v.length===0)return null;const x=(y,w)=>{y.preventDefault(),m(w)};return c.jsx("ul",{role:"listbox","data-kanna-typeahead-menu":"slash",className:"absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md",children:v.map((y,w)=>{const k=w===h,C=y.command;return c.jsxs("li",{ref:y.setRefElement,role:"option","aria-selected":k,onMouseDown:E=>x(E,y),onMouseEnter:()=>g(w),className:le("flex flex-col gap-0.5 px-3 py-1.5 cursor-pointer text-sm sm:flex-row sm:items-center sm:gap-3",k&&"bg-accent text-accent-foreground"),children:[c.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[c.jsxs("span",{className:"font-mono break-all sm:whitespace-nowrap sm:break-normal",children:["/",$O(C.name)]}),C.kind==="skill"?c.jsx("span",{className:"shrink-0 rounded-sm border border-border bg-muted px-1 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"skill"}):null,C.argumentHint?c.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground whitespace-nowrap",children:C.argumentHint}):null]}),C.description?c.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground sm:text-right",children:F_e(C.description)}):null]},y.key)})})},[]);return c.jsx(Wae,{options:o,onQueryChange:a,onSelectOption:l,triggerFn:s,menuRenderFn:u})}const UYe=50,HYe=3,WYe={"image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp"};function Vae(e){return WYe[e.type]??"bin"}function VYe(e){const t=e.name.trim().toLowerCase();if(!t)return!0;const n=Vae(e);return t===`image.${n}`||t==="image.png"}function KYe(e,t,n){if(e.name&&!VYe(e))return e;const r=Vae(e),i=t===0?"":`-${t}`,s=`clipboard-${n}${i}.${r}`;return Object.defineProperty(e,"name",{configurable:!0,value:s}),e}function GYe(e,t){const n=[];for(const r of e){if(r.kind!=="file"||!r.type.startsWith("image/"))continue;const i=r.getAsFile();i&&n.push(KYe(i,n.length,t))}return n}function qYe(e){return e?e.types.includes("text/plain")||e.types.includes("text/html"):!1}async function YYe(e,t,n,r,i){if(e.length===0||e.length>UYe)return;let s=0;async function o(){if(s>=e.length)return;const l=e[s++];try{const u=r({projectId:n,file:l,onProgress:()=>{}}),{attachments:f}=await u.promise,h=f[0];if(!h){i==null||i("Upload failed: no attachment returned");return}t.update(()=>{R0([o3(h)])})}catch(u){if(u instanceof Error&&u.name==="UploadAbortedError")return;i==null||i(u instanceof Error?u.message:String(u))}await o()}const a=[];for(let l=0;l<Math.min(HYe,e.length);l++)a.push(o());await Promise.all(a)}function XYe({projectId:e,onUploadError:t,uploadFileFn:n=e$}){const[r]=Fs();return _.useEffect(()=>r.registerCommand(E0,i=>{if(!(i instanceof ClipboardEvent))return!1;const s=i.clipboardData,o=GYe((s==null?void 0:s.items)??[],Date.now());if(o.length===0)return!1;const a=qYe(s);return e&&YYe(o,r,e,n,t),!a},As),[r,e,t,n]),null}const QYe=50,JYe=3;async function ZYe(e,t,n,r,i){if(e.length===0||e.length>QYe)return;let s=0;async function o(){if(s>=e.length)return;const l=e[s++];try{const u=r({projectId:n,file:l,onProgress:()=>{}}),{attachments:f}=await u.promise,h=f[0];if(!h){i==null||i("Upload failed: no attachment returned");return}t.update(()=>{R0([o3(h)])})}catch(u){if(u instanceof Error&&u.name==="UploadAbortedError")return;i==null||i(u instanceof Error?u.message:String(u))}await o()}const a=[];for(let l=0;l<Math.min(JYe,e.length);l++)a.push(o());await Promise.all(a)}function oK(e){var i,s;const t=(i=e.dataTransfer)==null?void 0:i.items;if(t){const o=[];for(let a=0;a<t.length;a++){const l=t[a];if(l&&l.kind==="file"){const u=l.getAsFile();u&&o.push(u)}}return o}const n=(s=e.dataTransfer)==null?void 0:s.files;if(!n)return[];const r=[];for(let o=0;o<n.length;o++){const a=n[o];a&&r.push(a)}return r}function eXe({projectId:e,onUploadError:t,uploadFileFn:n=e$}){const[r]=Fs();return _.useEffect(()=>{const i=r.registerCommand(_5,o=>oK(o).length===0?!1:(o.preventDefault(),!0),As),s=r.registerCommand(y5,o=>{const a=oK(o);return a.length===0?!1:(o.preventDefault(),e&&ZYe(a,r,e,n,t),!0)},As);return()=>{i(),s()}},[r,e,t,n]),null}function Kae(e){if(Fe(e))return e.getTextContent();if(hi(e))return`
2825
2825
  `;if(be(e)){let t="";const n=e.getChildren();for(const r of n)t+=Kae(r);return t}return e.getTextContent()}function rE(e){let t="",n=[];return e.getEditorState().read(()=>{const i=Pn().getChildren(),s=[];for(const o of i)s.push(Kae(o));t=s.join(`
2826
- `),t=t.replace(/(?:\r\n|\r|\n)+$/,"").trimEnd(),n=y3e().map(o=>o.getAttachment())}),{text:t,attachments:n}}function Gae(e=Nt){return e.hasTypeaheadMenuOpen()}function tXe({onSubmit:e,disabled:t,dom:n=Nt}){const[r]=Fs(),i=_.useRef(!1);return _.useEffect(()=>{function s(){i.current=!0}function o(){i.current=!1}let a=null;const l=r.registerRootListener((u,f)=>{f==null||f.removeEventListener("compositionstart",s),f==null||f.removeEventListener("compositionend",o),u==null||u.addEventListener("compositionstart",s),u==null||u.addEventListener("compositionend",o),a=u});return()=>{l(),a==null||a.removeEventListener("compositionstart",s),a==null||a.removeEventListener("compositionend",o)}},[r]),_.useEffect(()=>r.registerCommand(Pp,s=>{if(t||!s||i.current||s.isComposing||s.shiftKey||Gae(n)||n.isTouchDevice()&&!n.matchesMediaQuery("(hover: hover) and (pointer: fine)"))return!1;const o=rE(r);return o.text.trim().length>0||o.attachments.length>0?(s.preventDefault(),r.update(()=>{const l=Pn();l.clear(),l.append(Dt())}),e(o),!0):!1},As),[r,t,e,n]),null}function nXe({onChange:e}){const[t]=Fs();return _.useEffect(()=>t.registerUpdateListener(({editorState:n})=>{const r=n.toJSON();let i="";n.read(()=>{i=Pn().getTextContent()}),e(r,i)}),[t,e]),null}const qae=/(\S+)$/;function aK(e,t){const n=qae.exec(e);if(n===null)return null;const r=n[1];for(const i of t)if(i.shortcut===r)return i;return null}function rXe(e,t,n,r){return e.shiftKey||e.ctrlKey||e.metaKey||e.altKey?"ignore":e.repeat?r?"swallow-repeat":"ignore":t||n===0?"ignore":"attempt"}function iXe({snippets:e}){const[t]=Fs();return _.useEffect(()=>{let n=!1;return t.registerCommand(N0,r=>{if(!r)return!1;const i=rXe(r,Gae(),e.length,n);return r.repeat||(n=!1),i==="ignore"?!1:i==="swallow-repeat"?(r.preventDefault(),!0):t.getEditorState().read(()=>{const o=He();if(!Te(o)||!o.isCollapsed())return!1;const a=o.anchor.getNode();if(!Fe(a))return!1;const l=a.getTextContent().slice(0,o.anchor.offset);return aK(l,e)!==null})?(n=!0,r.preventDefault(),t.update(()=>{const o=He();if(!Te(o)||!o.isCollapsed())return;const a=o.anchor,l=a.getNode();if(!Fe(l))return;const u=a.offset,f=l.getTextContent().slice(0,u),h=qae.exec(f);if(h===null)return;const m=aK(f,e);if(m===null)return;const g=h[1],v=u-g.length,x=m.expansion.split(`
2826
+ `),t=t.replace(/(?:\r\n|\r|\n)+$/,"").trimEnd(),n=y3e().map(o=>o.getAttachment())}),{text:t,attachments:n}}function Gae(e=Nt){return e.hasTypeaheadMenuOpen()}function tXe({onSubmit:e,disabled:t,dom:n=Nt}){const[r]=Fs(),i=_.useRef(!1),s=_.useRef(!1);return _.useEffect(()=>{function o(){i.current=!0}function a(){i.current=!1}let l=null;const u=r.registerRootListener((f,h)=>{h==null||h.removeEventListener("compositionstart",o),h==null||h.removeEventListener("compositionend",a),f==null||f.addEventListener("compositionstart",o),f==null||f.addEventListener("compositionend",a),l=f});return()=>{u(),l==null||l.removeEventListener("compositionstart",o),l==null||l.removeEventListener("compositionend",a)}},[r]),_.useEffect(()=>r.registerCommand(Pp,o=>{if(t||!o||i.current||o.isComposing||o.keyCode===229||o.shiftKey||Gae(n)||n.isTouchDevice()&&!n.matchesMediaQuery("(hover: hover) and (pointer: fine)")||s.current)return!1;const a=rE(r);return a.text.trim().length>0||a.attachments.length>0?(o.preventDefault(),r.update(()=>{const u=Pn();u.clear(),u.append(Dt())}),s.current=!0,Promise.resolve().then(()=>{s.current=!1}),e(a),!0):!1},As),[r,t,e,n]),null}function nXe({onChange:e}){const[t]=Fs();return _.useEffect(()=>t.registerUpdateListener(({editorState:n})=>{const r=n.toJSON();let i="";n.read(()=>{i=Pn().getTextContent()}),e(r,i)}),[t,e]),null}const qae=/(\S+)$/;function aK(e,t){const n=qae.exec(e);if(n===null)return null;const r=n[1];for(const i of t)if(i.shortcut===r)return i;return null}function rXe(e,t,n,r){return e.shiftKey||e.ctrlKey||e.metaKey||e.altKey?"ignore":e.repeat?r?"swallow-repeat":"ignore":t||n===0?"ignore":"attempt"}function iXe({snippets:e}){const[t]=Fs();return _.useEffect(()=>{let n=!1;return t.registerCommand(N0,r=>{if(!r)return!1;const i=rXe(r,Gae(),e.length,n);return r.repeat||(n=!1),i==="ignore"?!1:i==="swallow-repeat"?(r.preventDefault(),!0):t.getEditorState().read(()=>{const o=He();if(!Te(o)||!o.isCollapsed())return!1;const a=o.anchor.getNode();if(!Fe(a))return!1;const l=a.getTextContent().slice(0,o.anchor.offset);return aK(l,e)!==null})?(n=!0,r.preventDefault(),t.update(()=>{const o=He();if(!Te(o)||!o.isCollapsed())return;const a=o.anchor,l=a.getNode();if(!Fe(l))return;const u=a.offset,f=l.getTextContent().slice(0,u),h=qae.exec(f);if(h===null)return;const m=aK(f,e);if(m===null)return;const g=h[1],v=u-g.length,x=m.expansion.split(`
2827
2827
  `);if(l.spliceText(v,g.length,x[0]??"",!0),x.length>1){const y=He();if(!Te(y))return;for(let w=1;w<x.length;w+=1){y.insertLineBreak();const k=x[w];k.length>0&&y.insertText(k)}}}),!0):!1},Sa)},[t,e]),null}function lK(e,t){return e&&!t}function sXe(e){const t=e.maxAttachments??Yae;return e.currentAttachmentCount+e.queuedAttachmentCount+e.incomingAttachmentCount>t}const oXe=[],Yae=50,aXe=3;function lXe(e,t,n){return e.provider!=="claude"?{...e,model:t}:{...e,model:t,modelOptions:{...e.modelOptions,contextWindow:hL(t,e.modelOptions.contextWindow,n)}}}function cXe(e,t,n){return!t||e.provider===t?e:t==="claude"?{provider:"claude",model:n.claude.model,modelOptions:{...n.claude.modelOptions},planMode:e.planMode}:{provider:"codex",model:n.codex.model,modelOptions:{...n.codex.modelOptions},planMode:e.planMode}}function uXe(e){return e.map(t=>({...t,status:"uploaded"}))}async function _j(e,t){e.contentUrl&&await BMe(e.contentUrl,{http:t})}function dXe({bridgeRef:e}){const[t]=Fs();return _.useEffect(()=>(e.current={clearEditor:()=>{t.update(()=>{const n=Pn();n.clear(),n.append(Dt())})},hydrateFromDraft:(n,r)=>{if(n)try{const i=t.parseEditorState(n);t.setEditorState(i);return}catch{}r?t.update(()=>{const i=Pn();i.clear();const s=Dt();s.append(Bn(r)),i.append(s)}):t.update(()=>{const i=Pn();i.clear(),i.append(Dt())})},readCurrentPayload:()=>rE(t),focusEditor:()=>{t.focus()}},()=>{e.current=null}),[t,e]),null}function fXe({isDisabled:e}){const[t]=Fs();return _.useEffect(()=>{t.setEditable(!e)},[t,e]),null}function hXe({onTextChange:e}){const[t]=Fs();return _.useEffect(()=>{const n=rE(t);return e(n.text),t.registerUpdateListener(()=>{const r=rE(t);e(r.text)})},[t,e]),null}function pXe({children:e,onError:t}){return e}const mXe=_.forwardRef(({onSubmit:e,onLayoutChange:t,onCancel:n,disabled:r,canCancel:i,chatId:s,projectId:o,inputElementRef:a,activeProvider:l,availableProviders:u,contextWindowSnapshot:f=null,sessionTotals:h=null,previousPrompt:m=null,ports:g,hasUnpausedCronJob:v=!1},x)=>{const y=(g==null?void 0:g.dom)??Nt,w=(g==null?void 0:g.http)??yc,{getDraft:k,setDraft:C,clearDraft:E,getAttachmentDrafts:N,setAttachmentDrafts:A,clearAttachmentDrafts:j}=fO(),{providerDefaults:P,getComposerState:M,initializeComposerForChat:F,setChatComposerModel:W,setChatComposerPlanMode:D,resetChatComposerFromProvider:B}=Xs(),I=s??P_,z=Xs(ee=>ee.chatStates[I])??M(I),U=iYe(),H=br.useScopedStore(ee=>ee.attachments),$=br.useScopedStore(ee=>ee.setAttachments),q=br.useScopedStore(ee=>ee.selectedAttachmentId),O=br.useScopedStore(ee=>ee.setSelectedAttachmentId),J=br.useScopedStore(ee=>ee.uploadError),ne=br.useScopedStore(ee=>ee.setUploadError),oe=br.useScopedStore(ee=>ee.currentText),he=br.useScopedStore(ee=>ee.setCurrentText),ce=_.useRef([]),ae=_.useRef(0),_e=_.useRef([]),te=_.useRef(0),ue=_.useRef(new Set),pe=_.useRef(o??null),Ne=_.useRef(s??null),je=_.useRef(null),Ke=cXe(z,l,P),qe=z.provider,We=jr(F0),xt=jr(jre),gt=_.useRef(null),Ot=u.find(ee=>ee.id===qe)??u[0],Tt=(Ot==null?void 0:Ot.supportsPlanMode)??!1,wt=_.useMemo(()=>{if(Ke.provider!=="claude")return f;const{modelOptions:ee}=Ke,re=LCe(hL(Ke.model,ee.contextWindow,We));return tKe(f,re)},[f,We,Ke]),Zt=H.filter(ee=>ee.status==="uploaded"),en=H.some(ee=>ee.status==="uploading"),Et=oe.trim().length>0,ln=oe.trim().length>0||Zt.length>0,xn=[...H].sort((ee,re)=>ee.kind===re.kind?0:ee.kind==="image"?-1:1),Bt=H.find(ee=>ee.id===q)??null,tn=jr(ee=>{var re;return((re=ee.settings)==null?void 0:re.subagents)??oXe}),Yt=_.useMemo(()=>{const ee=new Map(tn.map(Q=>[Q.name.toLowerCase(),Q])),re=[...oe.matchAll(vYe())],xe=[];for(const Q of re){const Y=Q[2];if(!Y)continue;const fe=ee.get(Y.toLowerCase());xe.push(fe?{kind:"ok",label:fe.name,id:fe.id}:{kind:"missing",label:Y})}return xe},[oe,tn]),Ut=_.useCallback(ee=>{ee.previewUrl&&URL.revokeObjectURL(ee.previewUrl)},[]),Ht=_.useCallback(ee=>{const re=(ee==null?void 0:ee.cleanupPreviews)??!0;te.current+=1,ue.current.clear(),$(xe=>(re&&xe.forEach(Ut),[])),ce.current=[],ae.current=0,O(null),ne(null)},[Ut,$,O,ne]),$t=_.useRef(void 0),ve=_.useCallback(()=>{if(o)for(;ae.current<aXe&&ce.current.length>0;){const ee=ce.current.shift();if(!ee)break;ae.current+=1;const re=crypto.randomUUID(),xe=ee.type.startsWith("image/")?URL.createObjectURL(ee):void 0,Q=te.current,Y=e$({projectId:o,file:ee,onProgress:({loaded:fe,total:ye})=>{if(Q!==te.current)return;const Ge=ye>0?fe/ye:0;$(ft=>ft.map(vt=>vt.id===re?{...vt,uploadProgress:Ge}:vt))}});$(fe=>[...fe,{id:re,kind:ee.type.startsWith("image/")?"image":"file",displayName:ee.name,absolutePath:"",relativePath:"",contentUrl:"",mimeType:ee.type||"application/octet-stream",size:ee.size,status:"uploading",previewUrl:xe,uploadProgress:0,cancelUpload:Y.abort}]),(async()=>{var fe;try{const{attachments:ye}=await Y.promise,Ge=ye[0];if(!Ge)throw new Error("Upload failed");if(Q!==te.current){_j(Ge,w),xe&&URL.revokeObjectURL(xe);return}if(ue.current.has(re)){ue.current.delete(re),xe&&URL.revokeObjectURL(xe),_j(Ge,w);return}$(ft=>ft.map(vt=>vt.id!==re?vt:{...vt,...Ge,previewUrl:vt.previewUrl,status:"uploaded",uploadProgress:1,cancelUpload:void 0})),ne(null)}catch(ye){if(Q!==te.current){xe&&URL.revokeObjectURL(xe);return}if(ye instanceof Uae){$(Ge=>Ge.filter(ft=>ft.id!==re)),ue.current.delete(re),xe&&URL.revokeObjectURL(xe);return}$(Ge=>Ge.map(ft=>ft.id===re?{...ft,status:"failed",cancelUpload:void 0}:ft)),ne(ye instanceof Error?ye.message:String(ye))}finally{ae.current=Math.max(0,ae.current-1),(fe=$t.current)==null||fe.call($t)}})()}},[w,o,$,ne]);_.useEffect(()=>{$t.current=ve},[ve]);const Ie=_.useCallback(ee=>{if(!o){ne("Open a project before uploading files.");return}if(sXe({currentAttachmentCount:_e.current.length,queuedAttachmentCount:ce.current.length,incomingAttachmentCount:ee.length})){ne(`You can upload up to ${Yae} files at a time.`);return}ce.current.push(...ee),ne(null),ve()},[ve,o,ne]);_.useImperativeHandle(x,()=>({enqueueFiles:Ie}),[Ie]);const Le=_.useCallback(()=>{let ee;return Ke.provider==="claude"?ee={claude:{...Ke.modelOptions}}:ee={codex:{...Ke.modelOptions}},{provider:qe,model:Ke.model,modelOptions:ee,planMode:Tt?Ke.planMode:!1}},[Ke,qe,Tt]),Qe=_.useCallback(async(ee,re)=>{var ft;const xe=_e.current,Q=q,Y=J,ye=[...Zt.map(({previewUrl:vt,status:Wt,uploadProgress:Cr,cancelUpload:Ss,...yr})=>yr),...re],Ge={...Le(),attachments:ye};(ft=je.current)==null||ft.clearEditor(),he(""),s&&E(s),Ht({cleanupPreviews:!1}),Ne.current&&j(Ne.current);try{await e(ee,Ge),xe.forEach(Ut)}catch(vt){Os.error("[ChatInput] Submit failed:",String(vt)),s&&C(s,ee),$(xe),O(Q),ne(Y)}},[Zt,Le,s,E,Ht,j,e,Ut,q,J,C,he,$,O,ne]),pt=_.useCallback(async ee=>{!ln||en||await Qe(ee.text,ee.attachments)},[ln,en,Qe]),sn=_.useCallback(async()=>{var re;if(!ln||en)return;const ee=((re=je.current)==null?void 0:re.readCurrentPayload())??{text:oe,attachments:[]};await Qe(ee.text,ee.attachments)},[ln,en,oe,Qe]),At=_.useCallback((ee,re)=>{s&&C(s,ee,re)},[s,C]);_.useEffect(()=>{F(I,{providerHint:l})},[I,F,l]),_.useEffect(()=>{Ne.current=s??null},[s]),_.useEffect(()=>{var ee,re,xe,Q;if(!s)(ee=je.current)==null||ee.clearEditor();else{const Y=k(s);Y?(re=je.current)==null||re.hydrateFromDraft(Y.lexicalState??null,Y.text):(xe=je.current)==null||xe.clearEditor()}(Q=je.current)==null||Q.focusEditor()},[s]),_.useEffect(()=>{te.current+=1,ce.current=[],ae.current=0,ue.current.clear(),O(null),ne(null),_.startTransition(()=>{$(ee=>(ee.forEach(Ut),uXe(s?N(s):[])))})},[s,Ut,N,O,ne,$]),_.useEffect(()=>{const ee=pe.current;pe.current=o??null,!(ee===null||o===ee)&&(Ht(),s&&j(s))},[o,s,Ht,j]),_.useEffect(()=>{_e.current=H},[H]),_.useEffect(()=>{if(!s)return;const ee=H.filter(re=>re.status==="uploaded").map(({previewUrl:re,status:xe,uploadProgress:Q,cancelUpload:Y,...fe})=>fe);if(ee.length===0){j(s);return}A(s,ee)},[H,s,j,A]),_.useEffect(()=>()=>{_e.current.forEach(Ut)},[Ut]),_.useLayoutEffect(()=>{t==null||t()},[t,H.length,J,oe]),_.useEffect(()=>{const ee=()=>{t==null||t()};return y.addWindowListener("resize",ee)},[y,t]);function nn(ee){Xs.getState().setComposerState(I,ee(Ke))}function qt(ee){nn(re=>re.provider==="claude"&&H1(ee)?{...re,modelOptions:{...re.modelOptions,reasoningEffort:ee}}:re.provider==="codex"&&W1(ee)?{...re,modelOptions:{...re.modelOptions,reasoningEffort:ee}}:re)}function rt(ee){nn(re=>re.provider!=="claude"?re:lXe({...re,modelOptions:{...re.modelOptions,contextWindow:ee}},re.model,We))}function _t(ee){D(I,ee)}function Ze(){_t(!Ke.planMode)}function ot(ee){if(fb(ee).openInNewTab){y.openWindow(new URL(ee.contentUrl,y.getOrigin()).toString(),"_blank","noopener,noreferrer");return}O(ee.id)}function ct(ee){var re;ee.status==="uploading"&&((re=ee.cancelUpload)==null||re.call(ee)),ue.current.add(ee.id),$(xe=>{const Q=xe.find(Y=>Y.id===ee.id);return Q&&Ut(Q),xe.filter(Y=>Y.id!==ee.id)}),q===ee.id&&O(null),ee.status==="uploaded"&&(ue.current.delete(ee.id),_j(ee,w))}function De(ee){var re;if(!ee.nativeEvent.isComposing){if(ee.key==="Tab"&&ee.shiftKey&&Tt){ee.preventDefault(),Ze();return}if(ee.key==="Escape"&&i){ee.preventDefault(),n==null||n();return}ee.key==="ArrowUp"&&!ee.shiftKey&&!ee.altKey&&!ee.ctrlKey&&!ee.metaKey&&oe.length===0&&m&&(ee.preventDefault(),(re=je.current)==null||re.hydrateFromDraft(null,m),he(m),s&&C(s,m))}}const nt=_.useCallback(ee=>{ne(ee)},[ne]),ke=_.useMemo(()=>s3({namespace:`kanna-composer-${I}`,nodes:[...X3e],editable:!r}),[I]);return c.jsxs("div",{children:[c.jsxs("div",{className:le("px-3 pt-0",U&&"px-5"),children:[c.jsxs("div",{className:"max-w-[840px] mx-auto rounded-[32px]",children:[Yt.length>0?c.jsx("div",{className:"flex flex-wrap gap-1 px-2 pt-2",children:Yt.map((ee,re)=>c.jsxs("span",{className:le("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs",ee.kind==="ok"?"bg-accent text-accent-foreground":"bg-destructive/15 text-destructive"),children:[c.jsx(Df,{className:"h-3 w-3"}),"agent/",ee.label,ee.kind==="missing"&&c.jsx("span",{className:"ml-1 font-medium",children:"unknown"})]},`${ee.kind}:${ee.label}:${re}`))}):null,H.length>0?c.jsx(zae,{className:"overflow-x-auto overflow-y-hidden whitespace-nowrap px-2 pb-2",children:c.jsx("div",{className:"flex items-end gap-2 pt-2",children:xn.map(ee=>c.jsx("div",{className:le("flex shrink-0 flex-col justify-end",ee.status==="failed"&&"text-destructive"),children:ee.kind==="image"?c.jsx(tN,{attachment:ee,previewUrl:ee.previewUrl,size:"composer",onClick:ee.status==="uploaded"?()=>ot(ee):void 0,onRemove:()=>ct(ee),uploadProgress:ee.status==="uploading"?ee.uploadProgress??null:void 0,onCancelUpload:ee.status==="uploading"?()=>ct(ee):void 0}):c.jsx(qo,{attachment:ee,onClick:ee.status==="uploaded"&&ee.contentUrl?()=>ot(ee):void 0,onRemove:()=>ct(ee),uploadProgress:ee.status==="uploading"?ee.uploadProgress??null:void 0,onCancelUpload:ee.status==="uploading"?()=>ct(ee):void 0})},ee.id))})}):null,c.jsxs("div",{className:"relative flex items-end max-w-[840px] mx-auto border bg-background dark:bg-card/90 border-border rounded-[29px] pr-1.5 transition-colors focus-within:border-ring/60 focus-within:ring-2 focus-within:ring-ring/30",onKeyDown:De,children:[c.jsx(Re,{type:"button",variant:"ghost",size:"icon","aria-label":"Add attachment",disabled:r,onPointerDown:ee=>ee.preventDefault(),onClick:()=>{var ee;return(ee=gt.current)==null?void 0:ee.click()},className:"relative flex-shrink-0 ml-1 mb-1 h-11 w-11 rounded-full text-muted-foreground hover:text-foreground",children:c.jsx(wme,{className:"h-5 w-5"})}),c.jsx("input",{ref:gt,type:"file",multiple:!0,disabled:r,tabIndex:-1,"aria-hidden":"true",className:"sr-only",onChange:ee=>{const re=[...ee.target.files??[]];re.length>0&&Ie(re),ee.target.value=""}}),c.jsx(Lqe,{initialConfig:ke,children:c.jsxs("div",{[Qq]:"",className:"relative flex-1 min-w-0",children:[c.jsx(qqe,{contentEditable:c.jsx(Jqe,{placeholder:c.jsx("div",{className:"pointer-events-none absolute top-3 left-3 md:top-4 md:left-6 text-muted-foreground text-base select-none",children:"Build something..."}),className:"flex-1 text-base p-3 md:p-4 !pr-2 pl-3 md:pl-6 min-h-[44px] max-h-[200px] outline-none focus:outline-none focus-visible:outline-none focus-visible:ring-0 bg-transparent border-0 shadow-none overflow-auto","aria-label":"Chat input","aria-placeholder":"Build something...","aria-multiline":"true",role:"textbox"}),ErrorBoundary:pXe}),c.jsx(rYe,{}),c.jsx(MYe,{projectId:o??null}),c.jsx(zYe,{projectId:o??null,provider:qe}),c.jsx(XYe,{projectId:o??null,onUploadError:nt}),c.jsx(eXe,{projectId:o??null,onUploadError:nt}),c.jsx(iXe,{snippets:xt}),c.jsx(tXe,{onSubmit:pt,disabled:r||en}),c.jsx(nXe,{onChange:At}),c.jsx(dXe,{bridgeRef:je}),c.jsx(fXe,{isDisabled:r}),c.jsx(hXe,{onTextChange:he})]})}),c.jsx(Re,{type:"button",onPointerDown:ee=>{ee.preventDefault(),!r&&Et&&!en?sn():i?n==null||n():!r&&ln&&!en&&sn()},disabled:r||!i&&!ln||en,size:"icon","aria-label":lK(!!i,Et)?"Stop":"Send message",className:"flex-shrink-0 bg-primary text-background rounded-full cursor-pointer h-11 w-11 mb-1 -mr-0.5 md:mr-0 md:mb-1.5 touch-manipulation disabled:opacity-50",children:lK(!!i,Et)?c.jsx("div",{className:"w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current"}):c.jsx(Dy,{className:"h-5 w-5 md:h-6 md:w-6"})})]})]}),J?c.jsx("div",{className:"max-w-[840px] mx-auto mt-2 px-1 text-sm text-destructive",children:J}):null]}),c.jsxs("div",{className:le("relative py-3 max-w-[840px] mx-auto",U&&"p-5 pt-3"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden flex flex-row",children:[c.jsx("div",{className:"min-w-3"}),c.jsx(LO,{availableProviders:u,selectedProvider:qe,showCodexCliRequirementHints:!0,model:Ke.model,modelOptions:Ke.modelOptions,onProviderChange:ee=>{B(I,ee)},onModelChange:v?void 0:(ee,re)=>{W(I,re)},onModelOptionChange:ee=>{switch(ee.type){case"claudeReasoningEffort":qt(ee.effort);break;case"codexReasoningEffort":qt(ee.effort);break;case"contextWindow":rt(ee.contextWindow);break;case"fastMode":nn(re=>re.provider==="claude"||re.provider==="openrouter"?re:{...re,modelOptions:{...re.modelOptions,fastMode:ee.fastMode}});break}},planMode:Ke.planMode,onPlanModeChange:_t,includePlanMode:Tt,className:"max-w-[840px] mx-auto"}),c.jsx("div",{className:"min-w-3"})]}),h??wt?c.jsxs("div",{className:"hidden shrink-0 items-center gap-2 pr-3 md:flex",children:[c.jsx(QV,{totals:h??null}),wt?c.jsx(XV,{usage:wt}):null]}):null]}),h??wt?c.jsxs("div",{className:"flex md:hidden items-center justify-end gap-2 px-[13px] pt-2",children:[c.jsx(QV,{totals:h??null}),wt?c.jsx(XV,{usage:wt}):null]}):null]}),c.jsx(pm,{source:Bt?yb(Bt,"user_attachment"):null,open:Bt!==null,onOpenChange:ee=>!ee&&O(null)})]})}),gXe=_.memo(mXe),vXe=_.memo(({inputRef:e,onLayoutChange:t,chatInputRef:n,chatInputElementRef:r,activeChatId:i,previousPrompt:s,hasSelectedProject:o,canCancel:a,projectId:l,activeProvider:u,availableProviders:f,contextWindowSnapshot:h,sessionTotals:m,onSubmit:g,onCancel:v,hasUnpausedCronJob:x})=>c.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:c.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:e,children:c.jsx(gXe,{ref:n,inputElementRef:r,onLayoutChange:t,onSubmit:g,onCancel:v,disabled:!o,canCancel:a,chatId:i,projectId:l,activeProvider:u,availableProviders:f,contextWindowSnapshot:h,sessionTotals:m,previousPrompt:s,hasUnpausedCronJob:x},i??"new-chat")})}));function bXe({onStop:e}){return c.jsx(qu,{className:"ml-[1px]",children:c.jsx(uee,{children:c.jsxs("div",{className:"group/draining relative flex items-center gap-1.5",children:[c.jsxs("div",{className:"flex items-center gap-1.5 group-hover/draining:opacity-0 transition-opacity",children:[c.jsx(Mn,{className:"size-4.5 animate-spin text-muted-icon"}),c.jsx(V0,{className:"ml-[1px] text-sm",shimmerWidth:44,children:"Running..."})]}),c.jsxs("button",{onClick:e,className:"absolute inset-0 flex items-center gap-1.5 opacity-0 group-hover/draining:opacity-100 transition-opacity cursor-pointer",children:[c.jsx(ts,{className:"size-4.5 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Stop"})]})]})})})}function xXe({message:e,onRemove:t,onSendNow:n}){return c.jsx("div",{className:"flex justify-end py-2",children:c.jsxs("div",{className:"flex max-w-[85%] sm:max-w-[80%] flex-col items-end gap-1.5",children:[e.attachments.length>0?c.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:e.attachments.map(r=>c.jsxs("div",{className:"max-w-[220px] rounded-xl border border-dashed border-border bg-transparent px-3 py-2 text-left",children:[c.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:r.displayName}),c.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:r.mimeType})]},r.id))}):null,e.content?c.jsxs("div",{className:"relative group",children:[c.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-end gap-2.5 rounded-[20px] border border-dashed border-border bg-transparent pl-3.5 pr-1.5 py-1.5 prose prose-sm prose-invert text-left text-primary [&_p]:whitespace-pre-line",children:[c.jsx("div",{children:$p(e.content)}),c.jsx(Re,{type:"button",variant:"default",size:"none",className:"rounded-full size-[24px] bg-muted text-muted-foreground border border-primary/10 group-hover:!text-primary hover:bg-muted/60",onClick:n,children:c.jsx(Dy,{className:"size-3.5"})})]}),c.jsx(Re,{type:"button",variant:"none",size:"none",className:"pointer-events-none opacity-0 scale-[0.1] group-hover:pointer-events-auto group-hover:scale-[1.0] group-hover:opacity-100 !p-0.5 border rounded-full text-xs font-medium text-muted-foreground hover:text-foreground gap-0.5 absolute top-0 left-0 bg-background -translate-x-[28%] -translate-y-[28%]",onClick:t,children:c.jsx(ts,{className:"size-3"})})]}):null]})})}const yXe={connecting:"Connecting...",acquiring_sandbox:"Booting...",initializing:"Initializing...",starting:"Starting...",running:"Running...",waiting_for_user:"Waiting...",failed:"Failed"};function _Xe({status:e}){const t=(e?yXe[e]:void 0)||"Processing...",n=e==="failed";return c.jsx(qu,{className:"ml-[1px]",children:c.jsxs(uee,{children:[n?c.jsx(ts,{className:"size-4.5 text-destructive"}):c.jsx(Mn,{className:"size-4.5 animate-spin text-muted-icon"}),c.jsx(V0,{className:"ml-[1px] text-sm",shimmerWidth:44,children:t})]})})}function SXe({jobs:e,onPause:t,onResume:n,onRemove:r}){const i=HN(1e3);return e.length===0?null:c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[c.jsx(qp,{className:"h-4 w-4 text-muted-foreground"}),"Cron jobs",c.jsxs("span",{className:"ml-auto text-xs font-normal text-muted-foreground tabular-nums",children:[e.length," armed"]})]}),c.jsx("div",{children:e.map((s,o)=>{const a=o===e.length-1,l=i-s.armedAt;return c.jsxs("div",{className:le("flex items-center gap-3 px-4 py-2.5 bg-background",!a&&"border-b border-border"),children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"truncate text-sm text-foreground",children:s.instruction}),s.lastRun?c.jsx(VN,{status:s.lastRun.status}):null]}),c.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[c.jsx("span",{className:"font-mono",children:s.jobId}),c.jsx("span",{children:Q3(s.schedule,s.scheduleText)}),c.jsxs("span",{children:["· ",s.mode]}),s.model?c.jsx("span",{className:"font-mono",children:s.model}):null,c.jsx(Qo,{label:new Date(s.armedAt).toLocaleString(),side:"top",children:c.jsxs("span",{className:"tabular-nums",children:["created ",js(l)," ago"]})}),c.jsxs("span",{className:"tabular-nums",children:["running for ",js(l)]}),s.paused?c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(E1,{className:"h-3 w-3","aria-hidden":"true"}),"paused"]}):null,!s.paused&&s.nextFireAt!==null?c.jsxs("span",{className:"tabular-nums",children:["next in ",Ep(Math.max(0,s.nextFireAt-i))]}):null]})]}),c.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.paused?c.jsx("button",{type:"button","aria-label":`Resume cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>n(s.jobId),children:c.jsx(qG,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):c.jsx("button",{type:"button","aria-label":`Pause cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>t(s.jobId),children:c.jsx(E1,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button","aria-label":`Remove cron job ${s.jobId}`,className:"rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive",onClick:()=>r(s.jobId),children:c.jsx(ts,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]},s.jobId)})})]})})}const wXe={user_prompt:"user",assistant_text:"assistant",assistant_thinking:"assistant",compact_summary:"assistant",tool:"tool",system_init:"chrome",account_info:"chrome",result:"chrome",status:"chrome",compact_boundary:"chrome",context_cleared:"chrome",interrupted:"chrome",memory_loaded:"chrome",context_window_updated:"chrome",api_error:"card",policy_refusal:"card",pending_tool_request:"card",auto_continue_prompt:"card",unknown:"card",cron_armed:"card",cron_command_error:"card",cron_run:"card",cron_list:"card",cron_run_skipped:"chrome",cron_job_change:"chrome"};function cK(e){return e.kind==="tool-group"?"tool":wXe[e.message.kind]??"card"}function CXe(e,t){return e===null?0:e==="chrome"||t==="chrome"?8:e==="tool"&&t==="tool"?0:e==="assistant"&&t==="tool"||e==="tool"&&t==="assistant"||e==="user"&&t==="user"?4:e==="assistant"&&t==="assistant"?12:16}function kXe(e,t){return CXe(e?cK(e):null,cK(t))}const EXe={0:"pt-0",4:"pt-1",8:"pt-2",12:"pt-3",16:"pt-4",24:"pt-6"};function NXe(e){const t=new Map;let n=null;for(const r of e)t.set(r.id,EXe[kXe(n,r)]),n=r;return t}const TXe=3e4;function AXe({record:e,onAccept:t,onStop:n,onRetry:r,onDismiss:i,ports:s={}}){const o=s.timer??ar,a=s.clipboard??Ua,l=_.useRef(null),u=_.useRef(e.state);_.useEffect(()=>{e.state!==u.current&&l.current&&(l.current(),l.current=null),u.current=e.state},[e.state]);const f=()=>new Promise(m=>{l.current=m,o.setTimeout(()=>{l.current===m&&(l.current=null,m())},TXe)});if(e.state==="proposed"){const m=[{id:"expose",label:"Expose",variant:"primary",onClick:async()=>{await t(e.tunnelId),await f()}},{id:"dismiss",label:"Dismiss",variant:"ghost",onClick:()=>i(e.tunnelId)}];return c.jsx(Kl,{title:`Port ${e.port} detected`,description:"Expose via Cloudflare quick tunnel?",actions:m})}if(e.state==="active"){const m=e.url??"",g=[{id:"copy",label:"Copy URL",variant:"secondary",onClick:async()=>{m&&await a.writeText(m)}},{id:"stop",label:"Stop tunnel",variant:"ghost",onClick:async()=>{await n(e.tunnelId),await f()}}];return c.jsx(Kl,{title:`Tunnel live on port ${e.port}`,tone:"success",body:c.jsx("a",{href:m,target:"_blank",rel:"noreferrer",className:"font-mono break-all underline-offset-4 hover:underline",children:m}),actions:g})}if(e.state==="stopped")return c.jsx(Kl,{title:`Tunnel stopped (port ${e.port})`,tone:"muted"});const h=[{id:"retry",label:"Retry",variant:"primary",onClick:async()=>{await r(e.tunnelId),await f()}},{id:"dismiss",label:"Dismiss",variant:"ghost",onClick:()=>i(e.tunnelId)}];return c.jsx(Kl,{title:`Tunnel failed on port ${e.port}`,tone:"error",errorMessage:e.error??void 0,actions:h})}const Tg=Jt("WorkflowsSectionDetail",()=>e=>({selectedRun:null,selectedRunId:null,setSelectedRun:t=>e({selectedRun:t}),setSelectedRunId:t=>e({selectedRunId:t}),clearSelection:()=>e({selectedRun:null,selectedRunId:null})})),uK="Agents";function dK(e){return typeof e.phaseIndex=="number"&&e.phaseIndex>=1}function RXe(e,t){var s;if(!t.some(dK))return t.length===0?[]:[{key:"ungrouped",phaseIndex:null,title:uK,agents:t}];const n=new Map,r=[];for(const o of t)if(dK(o)){const a=n.get(o.phaseIndex)??[];a.push(o),n.set(o.phaseIndex,a)}else r.push(o);const i=[];e.forEach((o,a)=>{const l=a+1;i.push({key:`phase-${l}`,phaseIndex:l,title:o.title,detail:o.detail,agents:n.get(l)??[]}),n.delete(l)});for(const o of[...n.keys()].sort((a,l)=>a-l)){const a=n.get(o);i.push({key:`phase-${o}`,phaseIndex:o,title:((s=a[0])==null?void 0:s.phaseTitle)??`Phase ${o}`,agents:a})}return r.length>0&&i.push({key:"ungrouped",phaseIndex:null,title:uK,agents:r}),i}function Xae({runs:e,onSelectRun:t,selectedRunId:n}){return e.length===0?c.jsx(jXe,{}):c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("div",{className:"flex items-center justify-between gap-2",children:c.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",style:{fontVariantNumeric:"tabular-nums"},children:[e.length," ",e.length===1?"run":"runs"]})}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(r=>c.jsx(MXe,{run:r,selected:r.runId===n,onSelect:t},r.runId))})]})}function jXe(){return c.jsxs("div",{className:"flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center","data-testid":"workflow-empty",children:[c.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:c.jsx(OG,{className:"size-5","aria-hidden":!0})}),c.jsx("p",{className:"text-sm font-medium text-foreground",children:"No workflow runs"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Workflow runs will appear here when triggered."})]})}function MXe(e){const{run:t,selected:n}=e,r=t.workflowName??t.runId,i=t.status==="running",s=_.useCallback(()=>{e.onSelect(t.runId)},[e,t.runId]);return c.jsx("li",{children:c.jsxs("button",{type:"button","data-testid":`workflow-row:${t.runId}`,onClick:s,className:le("flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted",n&&"bg-muted"),children:[c.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[c.jsx("span",{className:le("truncate text-sm text-foreground",(i||n)&&"font-medium"),children:r}),c.jsx(K3,{status:t.status,pulse:!0})]}),c.jsxs("span",{className:"flex w-full items-center gap-3 text-xs text-muted-foreground",children:[t.agentCount!=null?c.jsxs("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:[t.agentCount," ",t.agentCount===1?"agent":"agents"]}):null,t.totalTokens!=null?c.jsxs("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:[t.totalTokens.toLocaleString()," tokens"]}):null,t.durationMs!=null?c.jsx("span",{className:"tabular-nums",style:{fontVariantNumeric:"tabular-nums"},children:js(t.durationMs)}):null]})]})})}function PXe(e){return e==="running"||e==="progress"?"active":e==="failed"||e==="error"?"destructive":e==="killed"?"attention":"muted"}function IXe(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function OXe({run:e,open:t,onClose:n}){return c.jsx(Ma,{open:t,onOpenChange:r=>{r||n()},children:c.jsxs(Xo,{size:"lg","aria-describedby":void 0,children:[c.jsx(eY,{children:c.jsx(Pa,{children:e?e.workflowName??e.runId:"Workflow run"})}),c.jsx(fl,{children:e?c.jsx(Qae,{run:e}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})})]})})}function fK({label:e,text:t}){return c.jsxs("div",{className:"rounded border border-border/50 bg-muted/40 px-2 py-1",children:[c.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),c.jsx("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground/90",children:t})]})}function DXe({agent:e,onSelectAgent:t}){const n=PXe(e.state),r=n==="active",i=!!(t&&e.agentId);return c.jsxs("li",{"data-testid":`workflow-agent:${e.agentId??e.index}`,className:"group flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50",children:[c.jsx("span",{"aria-hidden":!0,className:le("mt-1.5 inline-block size-1.5 shrink-0 rounded-full",KY(n),r&&"animate-pulse")}),c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:le("truncate text-sm text-foreground",r&&"font-medium"),children:e.label}),e.model?c.jsx("span",{className:"shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.model}):null,i?c.jsxs("button",{type:"button","data-testid":`workflow-agent-transcript:${e.agentId}`,onClick:()=>t==null?void 0:t(e.agentId),className:"ml-auto inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[c.jsx(J_,{className:"size-3","aria-hidden":!0}),"Transcript"]}):null]}),c.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[c.jsx("span",{className:le("capitalize",zy(n)),children:e.state}),e.lastToolName?c.jsxs("span",{className:"truncate",children:["last: ",e.lastToolName]}):null,e.durationMs!=null?c.jsx("span",{className:"tabular-nums",children:js(e.durationMs)}):null,e.tokens!=null?c.jsxs("span",{className:"tabular-nums",children:[e.tokens.toLocaleString()," tok"]}):null,e.toolCalls!=null?c.jsxs("span",{className:"tabular-nums",children:[e.toolCalls," calls"]}):null]}),e.lastToolSummary?c.jsx("span",{className:"truncate text-xs text-muted-foreground/80",children:e.lastToolSummary}):null,e.promptPreview?c.jsx(fK,{label:"Prompt",text:e.promptPreview}):null,e.resultPreview?c.jsx(fK,{label:"Result",text:e.resultPreview}):null]})]})}function Qae({run:e,onSelectAgent:t,title:n}){const r=GY(e.status),i=RXe(e.phases,e.agents);return c.jsxs("div",{className:"flex flex-col gap-5",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[n?c.jsx("h3",{className:"truncate text-base font-semibold text-foreground",children:n}):null,c.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[c.jsx(K3,{status:e.status,pulse:!0}),e.durationMs!=null?c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:js(e.durationMs)}):null,e.agentCount!=null?c.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.agentCount," ",e.agentCount===1?"agent":"agents"]}):null,e.totalTokens!=null?c.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.totalTokens.toLocaleString()," tokens"]}):null,e.totalToolCalls!=null?c.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[e.totalToolCalls," tool calls"]}):null]})]}),e.summary?c.jsxs("section",{className:"flex flex-col gap-1",children:[c.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Summary"}),c.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.summary})]}):null,i.length>0?c.jsx("section",{className:"flex flex-col gap-4","data-testid":"workflow-progress-tree",children:i.map(s=>c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[s.phaseIndex!=null?c.jsx("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center rounded bg-muted text-[10px] font-medium text-muted-foreground tabular-nums",children:s.phaseIndex}):null,c.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-foreground",children:s.title}),c.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[s.agents.length," ",s.agents.length===1?"agent":"agents"]})]}),s.detail?c.jsx("p",{className:"text-xs text-muted-foreground",children:s.detail}):null,s.agents.length>0?c.jsx("ul",{className:"ml-1.5 flex flex-col gap-0.5 border-l border-border pl-2.5",children:s.agents.map(o=>c.jsx(DXe,{agent:o,onSelectAgent:t},o.agentId??o.index))}):c.jsx("p",{className:"ml-1.5 border-l border-border pl-2.5 text-xs italic text-muted-foreground/70",children:"No agents yet"})]},s.key))}):null,e.result?c.jsxs("section",{className:"flex flex-col gap-1",children:[c.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Result"}),c.jsx("pre",{className:"max-h-80 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words",children:IXe(e.result)})]}):null,e.script?c.jsxs("details",{className:"flex flex-col gap-1",children:[c.jsx("summary",{className:"cursor-pointer text-xs font-medium uppercase tracking-wide text-muted-foreground hover:text-foreground",children:"Script"}),c.jsx("pre",{className:"mt-1.5 max-h-96 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words",children:e.script})]}):null,e.error&&e.status!=="completed"?c.jsxs("section",{className:"flex flex-col gap-1",children:[c.jsx("h4",{className:le("text-xs font-medium uppercase tracking-wide",zy(r)),children:"Error"}),c.jsx("p",{className:"rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-sm text-destructive whitespace-pre-wrap",children:e.error})]}):null]})}function LXe({runs:e,getRunDetail:t}){const n=Tg.useScopedStore(h=>h.selectedRun),r=Tg.useScopedStore(h=>h.selectedRunId),i=Tg.useScopedStore(h=>h.setSelectedRun),s=Tg.useScopedStore(h=>h.setSelectedRunId),o=Tg.useScopedStore(h=>h.clearSelection),a=n!==null,l=_.useRef(null),u=_.useCallback(async h=>{l.current=e,s(h),i("loading");const m=await t(h);i(m)},[t,e,i,s]),f=_.useCallback(()=>{o(),l.current=null},[o]);return _.useEffect(()=>{if(r===null||e===l.current)return;const h=e.find(g=>g.runId===r);if(!h||h.status!=="running")return;let m=!1;return t(r).then(g=>{m||g===null||i(g)}),()=>{m=!0}},[e,r,t,i]),c.jsxs(c.Fragment,{children:[c.jsx(Xae,{runs:e,onSelectRun:h=>{u(h)}}),c.jsx(OXe,{run:n==="loading"?null:n,open:a,onClose:f})]})}function $Xe(e){return c.jsx(Tg.Provider,{init:void 0,children:c.jsx(LXe,{...e})})}const FXe={done:{Icon:Ls,iconClass:"text-success",textClass:"text-muted-foreground"},running:{Icon:Mn,iconClass:"text-foreground animate-spin",textClass:"text-foreground font-medium"},pending:{Icon:Yj,iconClass:"text-muted-foreground",textClass:"text-muted-foreground"},failed:{Icon:kf,iconClass:"text-destructive",textClass:"text-muted-foreground line-through decoration-destructive/40"}};function BXe({loopProgress:e,onResume:t}){const{armed:n,rows:r,rateLimit:i}=e;return!n&&r.length===0?null:c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[c.jsx(dD,{className:"h-4 w-4 text-muted-foreground"}),"Progress",n?c.jsxs("span",{className:"ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground",children:[c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success animate-pulse"}),"Loop running"]}):null]}),i?c.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-amber-500/[0.06] border-b border-border",children:[c.jsx(zhe,{className:"h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400"}),c.jsxs("span",{className:"text-sm text-foreground",children:[i.scheduled?"Resumes":"Usage limit — resets"," ",tE(i.resetAt,i.tz)]}),!i.scheduled&&t?c.jsx(Re,{variant:"secondary",size:"sm",className:"ml-auto",onClick:()=>t(i.scheduleId,Date.now()),children:"Resume now"}):null]}):null,r.length===0?c.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground bg-background",children:"Waiting for the first chunk…"}):c.jsx("div",{children:r.map((s,o)=>{const a=o===r.length-1,{Icon:l,iconClass:u,textClass:f}=FXe[s.status];return c.jsxs("div",{className:le("flex items-center gap-3 px-4 py-2.5 bg-background",!a&&"border-b border-border"),children:[c.jsx(l,{className:le("h-4 w-4 flex-shrink-0",u)}),c.jsx("span",{className:le("text-sm truncate",f),children:s.label})]},s.runId)})})]})})}function zXe(e){return e?e.includes("bash")||e.includes("shell")?ZG:e.includes("agent")||e.includes("task")||e.includes("teammate")?Df:e.includes("workflow")?uE:Yj:Yj}function UXe({tasks:e}){const t=HN(1e3);return e.length===0?null:c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[c.jsx(OG,{className:"h-4 w-4 text-muted-foreground"}),"Background tasks",c.jsxs("span",{className:"ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground",children:[c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-warning"}),e.length," running"]})]}),c.jsx("div",{children:e.map((n,r)=>{const i=zXe(n.taskType),s=r===e.length-1;return c.jsxs("div",{className:le("flex items-center gap-3 px-4 py-2.5 bg-background",!s&&"border-b border-border"),children:[c.jsx(i,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-foreground truncate",children:n.description??"Background task"}),c.jsxs("span",{className:"ml-auto flex items-center gap-3 flex-shrink-0",children:[c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:n.id}),c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:Ep(Math.max(0,t-n.startedAt))})]})]},n.id)})})]})})}const HXe={askUserQuestionSurface:"footer"},hK={askUserQuestionSurface:"inline"};function WXe(e,t){const n=t.AskUserQuestion;if(!n)return null;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.id===n)return i.kind!=="tool"||i.toolKind!=="ask_user_question"||i.result?null:i}return null}function VXe(e){const t=Object.values(e??{}).filter(n=>n.pendingTool!==null);return t.sort((n,r)=>n.pendingTool.requestedAt-r.pendingTool.requestedAt||n.runId.localeCompare(r.runId)),t}const KXe=_.memo(({activeChatId:e,listRef:t,messages:n,queuedMessages:r,transcriptPaddingBottom:i,localPath:s,latestToolIds:o,isHistoryLoading:a,hasOlderHistory:l,isProcessing:u,runtimeStatus:f,isDraining:h,commandError:m,loadOlderHistory:g,onStopDraining:v,onSteerQueuedMessage:x,onRemoveQueuedMessage:y,onOpenLocalLink:w,onAskUserQuestionSubmit:k,onExitPlanModeConfirm:C,onToolRequestAnswer:E,onSubagentAskUserQuestionSubmit:N,onSubagentExitPlanModeSubmit:A,schedules:j,cronJobs:P=nE,onCronPause:M,onCronResume:F,onCronRemove:W,onAutoContinueAccept:D,onAutoContinueReschedule:B,onAutoContinueCancel:I,onRetryFailedTurn:V,tunnels:z,liveTunnelId:U,onTunnelAccept:H,onTunnelStop:$,onTunnelRetry:q,subagentRuns:O,onCancelSubagentRun:J,loopProgress:ne,workflowRuns:oe,backgroundTasks:he,getWorkflowRunDetail:ce,getSubagentTranscript:ae,showScrollButton:_e,onIsAtEndChange:te,scrollToBottom:ue,typedEmptyStateText:pe,isEmptyStateTypingComplete:Ne,isPageFileDragActive:je,showEmptyState:Ke,editorPreset:qe="cursor",editorCommandTemplate:We,platform:xt="darwin",headerOffsetPx:gt=OUe,ports:Ot})=>{const Tt=(Ot==null?void 0:Ot.dom)??Nt,wt=(Ot==null?void 0:Ot.timer)??ar,Zt=_.useRef(0),en=_.useRef(null),Et=br.useScopedStore(De=>De.toolGroupExpanded),ln=br.useScopedStore(De=>De.setToolGroupExpanded),xn=br.useScopedStore(De=>De.resetToolGroupExpanded),Bt=bs(De=>De.localLinkMenuTarget),tn=bs(De=>De.setLocalLinkMenuTarget),Yt=bs(De=>De.setLocalLinkMenuOpen),Ut=xt==="darwin",Ht=_.useMemo(()=>Mae(n,{isLoading:u,localPath:s??void 0,latestToolIds:o}),[u,o,s,n]),$t=wqe(Ht),ve=_.useMemo(()=>NXe($t),[$t]);_.useEffect(()=>{xn()},[e,xn]),_.useEffect(()=>{const De=Zt.current;if(Zt.current=$t.length,De>0||$t.length===0)return;te(!0);const nt=wt.requestAnimationFrame(()=>{var ke,ee;(ee=(ke=t.current)==null?void 0:ke.scrollToEnd)==null||ee.call(ke,{animated:!1})});return()=>wt.cancelAnimationFrame(nt)},[t,te,$t.length,wt]);const{runsByUserMessageId:Ie,childrenByParentRunId:Le}=_.useMemo(()=>{const De=new Map,nt=new Map;for(const ee of Object.values(O??{}))if(ee.parentRunId===null){const re=De.get(ee.parentUserMessageId)??[];re.push(ee),De.set(ee.parentUserMessageId,re)}else{const re=nt.get(ee.parentRunId)??[];re.push(ee),nt.set(ee.parentRunId,re)}const ke=(ee,re)=>ee.startedAt-re.startedAt||ee.runId.localeCompare(re.runId);for(const ee of De.values())ee.sort(ke);for(const ee of nt.values())ee.sort(ke);return{runsByUserMessageId:De,childrenByParentRunId:nt}},[O]),Qe=_.useMemo(()=>VXe(O),[O]),pt=_.useMemo(()=>WXe(n,o),[n,o]),sn=_.useCallback((De,nt)=>{const ke=Le.get(De.runId)??[];return c.jsxs(Dn.Fragment,{children:[c.jsx(Nae,{run:De,indentDepth:nt,localPath:s??"",onSubagentAskUserQuestionSubmit:N,onSubagentExitPlanModeSubmit:A,onCancelSubagentRun:J,suppressPendingTool:!0}),ke.map(ee=>sn(ee,nt+1))]},De.runId)},[Le,s,N,A,J]),At=_.useCallback((De,nt)=>{ln(ke=>ke[De]===nt?ke:{...ke,[De]:nt})},[ln]),nn=_.useCallback(De=>{var ee,re,xe,Q;const nt=typeof De=="object"&&De!==null&&"currentTarget"in De&&De.currentTarget instanceof HTMLElement?De.currentTarget:(re=(ee=t.current)==null?void 0:ee.getScrollableNode)==null?void 0:re.call(ee);if(nt instanceof HTMLElement){const Y=nt.scrollHeight-nt.clientHeight-nt.scrollTop;te(Y<=4);return}const ke=(Q=(xe=t.current)==null?void 0:xe.getState)==null?void 0:Q.call(xe);ke&&te(ke.isAtEnd)},[t,te]);_.useEffect(()=>{let De;const nt=wt.requestAnimationFrame(()=>{var re,xe;const ke=(xe=(re=t.current)==null?void 0:re.getScrollableNode)==null?void 0:xe.call(re);if(!(ke instanceof HTMLElement))return;const ee=()=>{nn({currentTarget:ke})};ke.addEventListener("scroll",ee,{passive:!0}),ee(),De=()=>{ke.removeEventListener("scroll",ee)}});return()=>{wt.cancelAnimationFrame(nt),De==null||De()}},[e,nn,t,$t.length,wt]);const qt=_.useCallback(()=>{a||!l||g()},[l,a,g]),rt=_.useCallback(De=>{if(De.trigger!=="contextmenu"){const nt=U3e(De.path)?"open_editor":"open_default";w(De,nt);return}tn(De),wt.requestAnimationFrame(()=>{const nt=en.current;if(!nt)return;const ke=De.clientX??Tt.getInnerWidth()/2,ee=De.clientY??Tt.getInnerHeight()/2;Tt.dispatchContextMenuEvent(nt,ke,ee)})},[Tt,w,tn,wt]),_t=_.useCallback(({item:De})=>{const nt=De.kind==="single"&&De.message.kind==="user_prompt"?De.message.id:null,ke=nt?Ie.get(nt)??[]:[];return c.jsxs("div",{className:le("mx-auto w-full max-w-[800px]",ve.get(De.id)??"pt-4"),"data-transcript-row-id":De.id,children:[c.jsx(Iae,{row:De,toolGroupExpanded:De.kind==="tool-group"?Et[De.id]??!1:void 0,onToolGroupExpandedChange:At,onAskUserQuestionSubmit:k,onExitPlanModeConfirm:C,onToolRequestAnswer:E,schedules:j,cronJobs:P,onAutoContinueAccept:D,onAutoContinueReschedule:B,onAutoContinueCancel:I,onRetryFailedTurn:V,chatId:e??void 0}),ke.map(ee=>sn(ee,0))]})},[At,k,C,E,j,P,D,B,I,V,Et,Ie,sn,e,ve]),Ze=c.jsx("div",{className:"mx-auto w-full max-w-[800px]",style:{paddingTop:`${gt}px`},children:a?c.jsx("div",{className:"flex justify-center pb-4",children:c.jsx("span",{className:"text-sm translate-y-[-0.5px]",children:c.jsx(V0,{animate:!0,shimmerWidth:Math.max(20,72),children:"Loading more messages..."})})}):null}),ot=U&&z?z[U]:void 0,ct=c.jsxs("div",{className:"mx-auto w-full max-w-[800px] pt-4",children:[ne&&(ne.armed||ne.rows.length>0)?c.jsx("div",{className:"pb-4",children:c.jsx(BXe,{loopProgress:ne,onResume:D})}):null,P.length>0&&M&&F&&W?c.jsx("div",{className:"pb-4",children:c.jsx(SXe,{jobs:P,onPause:M,onResume:F,onRemove:W})}):null,oe&&oe.length>0&&ce?c.jsx("div",{className:"pb-4",children:c.jsx($Xe,{runs:oe,getRunDetail:ce})}):null,ot&&H&&$&&q&&c.jsx("div",{className:"pb-4",children:c.jsx(AXe,{record:ot,onAccept:H,onStop:$,onRetry:q,onDismiss:$})}),he&&he.length>0?c.jsx("div",{className:"pb-4",children:c.jsx(UXe,{tasks:he})}):null,u?c.jsx(_Xe,{status:f??void 0}):null,r.map(De=>c.jsx(xXe,{message:De,onRemove:()=>void y(De.id),onSendNow:()=>void x(De.id)},De.id)),!u&&h?c.jsx(bXe,{onStop:()=>void v()}):null,m?c.jsx("div",{className:"rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap",children:bae(m)}):null,pt?c.jsxs("div",{className:"mb-3","data-testid":`main-pending-footer:${pt.toolId}`,children:[c.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c.jsx(hD,{className:"h-3.5 w-3.5 shrink-0"}),c.jsxs("span",{children:[c.jsx("span",{className:"text-foreground",children:"Claude"})," needs your input"]})]}),c.jsx(NO,{value:hK,children:c.jsx(Y3,{message:pt,onSubmit:k,isLatest:!0})})]}):null,Qe.length>0&&N&&A?Qe.map(De=>c.jsxs("div",{"data-testid":`subagent-pending-footer:${De.runId}`,className:"mb-3",children:[c.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c.jsx(Df,{className:"h-3.5 w-3.5 shrink-0"}),c.jsxs("span",{children:[c.jsx("span",{className:"text-foreground",children:De.subagentName})," needs your input"]})]}),c.jsx(Eae,{pendingTool:De.pendingTool,onAskUserQuestionSubmit:(nt,ke,ee)=>N(De.runId,nt,ke,ee),onExitPlanModeSubmit:(nt,ke)=>A(De.runId,nt,ke)})]},De.runId)):null]});return c.jsxs(c.Fragment,{children:[c.jsx(mae,{value:ae??null,children:c.jsx(oee,{onOpenLocalLink:rt,children:c.jsx(NO,{value:pt?HXe:hK,children:c.jsx(aJ,{ref:t,data:$t,extraData:{toolGroupExpanded:Et,schedules:j,tunnels:z,liveTunnelId:U},keyExtractor:GXe,renderItem:_t,estimatedItemSize:96,initialScrollAtEnd:!0,maintainScrollAtEnd:!0,maintainScrollAtEndThreshold:.1,maintainVisibleContentPosition:!0,onScroll:nn,onStartReached:qt,onStartReachedThreshold:.1,className:"h-full flex-1 overflow-x-hidden overscroll-y-contain px-3 scroll-pt-[72px] [scrollbar-gutter:auto]",contentContainerStyle:{paddingBottom:i+30},ListHeaderComponent:Ze,ListFooterComponent:ct})})})}),c.jsxs(em,{onOpenChange:Yt,children:[c.jsx(tm,{asChild:!0,children:c.jsx("span",{ref:en,"aria-hidden":"true",className:"pointer-events-none fixed size-px opacity-0",style:{left:(Bt==null?void 0:Bt.clientX)??0,top:(Bt==null?void 0:Bt.clientY)??0}})}),Bt?c.jsx(BVe,{isMac:Ut,editorPreset:qe,editorCommandTemplate:We,includeFinder:!0,includePreview:!0,includeDefault:!0,onOpenExternal:(De,nt)=>{w(Bt,De,nt)}}):null]}),Ke?c.jsx("div",{className:"pointer-events-none absolute inset-x-4 animate-fade-in",style:{top:gt,bottom:i},children:c.jsx("div",{className:"mx-auto flex h-full max-w-[800px] items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 text-muted-foreground opacity-70",children:[c.jsx(bf,{strokeWidth:1.5,className:"kanna-empty-state-flower size-8 text-muted-foreground"}),c.jsx("div",{className:"kanna-empty-state-text flex max-w-xs items-center text-center text-base font-normal text-muted-foreground","aria-label":qk,children:c.jsxs("span",{className:"relative inline-grid place-items-start",children:[c.jsxs("span",{className:"invisible col-start-1 row-start-1 flex items-center whitespace-pre",children:[c.jsx("span",{children:qk}),c.jsx("span",{className:"kanna-typewriter-cursor-slot","aria-hidden":"true"})]}),c.jsxs("span",{className:"col-start-1 row-start-1 flex items-center whitespace-pre",children:[c.jsx("span",{children:pe}),c.jsx("span",{className:"kanna-typewriter-cursor-slot","aria-hidden":"true",children:c.jsx("span",{className:"kanna-typewriter-cursor","data-typing-complete":Ne?"true":"false"})})]})]})})]})})}):null,je?c.jsxs("div",{className:"pointer-events-none absolute inset-0 z-30",children:[c.jsx("div",{className:"absolute inset-0 bg-background/70"}),c.jsx("div",{className:"absolute inset-6 ",children:c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 text-center",children:[c.jsx(AC,{className:"mx-auto size-14 text-foreground",strokeWidth:1.75}),c.jsx("div",{className:"text-xl font-medium text-foreground",children:"Drop up to 10 files"})]})})})]}):null,c.jsx("div",{style:{bottom:i-20},className:le("absolute left-1/2 z-10 -translate-x-1/2 transition-all",_e?"scale-100 opacity-100 duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]":"pointer-events-none scale-75 opacity-0 duration-200 ease-out"),children:c.jsx("button",{onClick:ue,className:"flex aspect-square cursor-pointer items-center gap-1.5 rounded-full border border-border bg-card px-2 text-sm text-foreground transition-colors hover:bg-muted",children:c.jsx(lhe,{className:"h-5 w-5"})})})]})});function GXe(e){return e.id}function qXe(){const e=_.useRef(null),t=br.useScopedStore(s=>s.inputHeight),n=br.useScopedStore(s=>s.setInputHeight),r=br.useScopedStoreApi(),i=_.useCallback(()=>{const s=e.current;if(!s)return;const o=s.getBoundingClientRect().height,a=r.getState().inputHeight,l=C7e(a,o);l!==a&&n(l)},[n,r]);return _.useLayoutEffect(()=>{const s=e.current;if(!s)return;const o=new ResizeObserver(()=>{i()});return o.observe(s),i(),()=>o.disconnect()},[i]),{inputRef:e,syncInputHeight:i,transcriptPaddingBottom:w7e(t)}}function YXe(e,t,n){const r=bs(l=>l.typedEmptyStateText),i=bs(l=>l.isEmptyStateTypingComplete),s=bs(l=>l.setTypedEmptyStateText),o=bs(l=>l.setIsEmptyStateTypingComplete),a=bs(l=>l.resetEmptyStateTyping);return _.useEffect(()=>{if(!e)return;a();let l=0;const u=n.setInterval(()=>{l+=1,s(qk.slice(0,l)),l>=qk.length&&(n.clearInterval(u),o(!0))},IUe);return()=>n.clearInterval(u)},[e,t,a,s,o,n]),{typedEmptyStateText:r,isEmptyStateTypingComplete:i}}function XXe(e){const t=bs(u=>u.isPageFileDragActive),n=bs(u=>u.setIsPageFileDragActive),r=_.useRef(0),i=_.useCallback(u=>{var f;return $Ue(((f=u.dataTransfer)==null?void 0:f.types)??[])},[]),s=_.useCallback(u=>{!i(u)||!e.hasSelectedProject||(u.preventDefault(),r.current+=1,n(!0))},[e.hasSelectedProject,i,n]),o=_.useCallback(u=>{!i(u)||!e.hasSelectedProject||(u.preventDefault(),u.dataTransfer.dropEffect="copy",t||n(!0))},[e.hasSelectedProject,i,t,n]),a=_.useCallback(u=>{!i(u)||!e.hasSelectedProject||(u.preventDefault(),r.current=Math.max(0,r.current-1),r.current===0&&n(!1))},[e.hasSelectedProject,i,n]),l=_.useCallback(u=>{!i(u)||!e.hasSelectedProject||(u.preventDefault(),r.current=0,n(!1),e.onFilesDropped([...u.dataTransfer.files]))},[e,i,n]);return{isPageFileDragActive:t,handleTranscriptDragEnter:s,handleTranscriptDragOver:o,handleTranscriptDragLeave:a,handleTranscriptDrop:l}}function pK({timer:e,dom:t,onToggleEmbeddedTerminal:n,onToggleRightSidebar:r}){var Yt,Ut,Ht,$t,ve,Ie,Le,Qe,pt,sn,At,nn,qt,rt,_t,Ze,ot,ct,De,nt,ke,ee;const i=E7e(),s=_.useRef(null),o=_.useRef(!0),a=_.useRef(null),l=_.useRef(null),u=_.useRef(null),f=_.useRef(null),{inputRef:h,syncInputHeight:m,transcriptPaddingBottom:g}=qXe(),v=br.useScopedStore(re=>re.showScrollToBottom),x=br.useScopedStore(re=>re.setShowScrollToBottom),y=mc(),w=_.useCallback(re=>{y(`/chat/${re}`)},[y]),k=i.activeProjectId,E=zh(re=>k?re.projects[k]:void 0)??gI,A=Ts(re=>k?re.projects[k]:void 0)??YZ,j=qs(re=>re.editorPreset),P=qs(re=>re.editorCommandTemplate),M=E.terminals.length>0,F=!!(k&&E.isVisible&&M),W=!!(k&&A.isVisible),D=_.useMemo(()=>DE(i.keybindings),[i.keybindings]),B=_.useMemo(()=>{var re;return eKe(((re=i.chatSnapshot)==null?void 0:re.messages)??[])},[(Yt=i.chatSnapshot)==null?void 0:Yt.messages]),I=_.useMemo(()=>{var re,xe;return nKe(((re=i.chatSnapshot)==null?void 0:re.messages)??[],Object.values(((xe=i.chatSnapshot)==null?void 0:xe.subagentRuns)??{}))},[(Ut=i.chatSnapshot)==null?void 0:Ut.messages,(Ht=i.chatSnapshot)==null?void 0:Ht.subagentRuns]),V=i.messages.length===0&&(($t=i.runtime)==null?void 0:$t.title)==="New Chat",z=_.useCallback(()=>{a.current!==null&&(e.clearTimeout(a.current),a.current=null)},[e]),U=_.useCallback(re=>{if(o.current!==re){if(o.current=re,re){z(),x(!1);return}z(),a.current=e.setTimeout(()=>{x(!0),a.current=null},150)}},[z,x,e]),H=_.useCallback(()=>{var xe,Q;const re=(Q=(xe=s.current)==null?void 0:xe.getState)==null?void 0:Q.call(xe);re&&U(re.isAtEnd)},[U]),$=_.useCallback(async(re=!0)=>{var xe,Q;o.current=!0,z(),x(!1),await((Q=(xe=s.current)==null?void 0:xe.scrollToEnd)==null?void 0:Q.call(xe,{animated:re}))},[z,x]),q=_.useCallback(async(re,xe)=>{await $(!1),await i.handleSend(re,xe)},[$,i]),O=_.useRef({messages:i.messages,submit:q});_.useEffect(()=>{O.current={messages:i.messages,submit:q}},[i.messages,q]);const J=_.useCallback(async re=>{const{messages:xe,submit:Q}=O.current,Y=Pqe(xe,re);Y&&await Q(Y.content,{attachments:Y.attachments})},[]),ne=_.useCallback((re,xe)=>{const Q=i.activeChatId;Q&&i.socket.command({type:"autoContinue.accept",chatId:Q,scheduleId:re,scheduledAt:xe}).catch(()=>{})},[i.activeChatId,i.socket]),oe=_.useCallback((re,xe)=>{const Q=i.activeChatId;Q&&i.socket.command({type:"autoContinue.reschedule",chatId:Q,scheduleId:re,scheduledAt:xe}).catch(()=>{})},[i.activeChatId,i.socket]),he=_.useCallback(re=>{const xe=i.activeChatId;xe&&i.socket.command({type:"cron.pause",chatId:xe,jobId:re}).catch(()=>{})},[i.activeChatId,i.socket]),ce=_.useCallback(re=>{const xe=i.activeChatId;xe&&i.socket.command({type:"cron.resume",chatId:xe,jobId:re}).catch(()=>{})},[i.activeChatId,i.socket]),ae=_.useCallback(re=>{const xe=i.activeChatId;xe&&i.socket.command({type:"cron.remove",chatId:xe,jobId:re}).catch(()=>{})},[i.activeChatId,i.socket]),_e=_.useCallback(re=>{const xe=i.activeChatId;xe&&i.socket.command({type:"autoContinue.cancel",chatId:xe,scheduleId:re}).catch(()=>{})},[i.activeChatId,i.socket]),te=_.useCallback(async re=>{const xe=i.activeChatId;xe&&await i.socket.command({type:"tunnel.accept",chatId:xe,tunnelId:re})},[i.activeChatId,i.socket]),ue=_.useCallback(async re=>{const xe=i.activeChatId;xe&&await i.socket.command({type:"tunnel.stop",chatId:xe,tunnelId:re})},[i.activeChatId,i.socket]),pe=_.useCallback(async re=>{const xe=i.activeChatId;xe&&await i.socket.command({type:"tunnel.retry",chatId:xe,tunnelId:re})},[i.activeChatId,i.socket]),Ne=_.useCallback((re,xe)=>{i.socket.command({type:"chat.cancelSubagentRun",chatId:re,runId:xe}).catch(()=>{})},[i.socket]),je=FN(bp(L3(i.activeChatId??""))),Ke=_.useCallback(async re=>{const xe=i.activeChatId;return xe?i.socket.command({type:"workflows.getRun",chatId:xe,runId:re}):null},[i.activeChatId,i.socket]),qe=_.useCallback(async re=>{const xe=i.activeChatId;return xe?i.socket.command({type:"subagents.getRun",chatId:xe,agentId:re}):[]},[i.activeChatId,i.socket]),We=gj(re=>re.listForChat(i.activeChatId??"")),xt=gj(re=>re.addShare),gt=gj(re=>re.removeShare),Ot=_.useCallback(async re=>{const xe=await i.socket.command({type:"share.mint",payload:{chatId:re}});xe.ok&&xe.kind==="mint"&&xt(re,xe.data.summary)},[xt,i.socket]),Tt=_.useCallback(async re=>{const xe=i.activeChatId;if(!xe)return;(await i.socket.command({type:"share.revoke",payload:{tokenId:re}})).ok&&gt(xe,re)},[gt,i.activeChatId,i.socket]);oKe({rootRef:l,fallbackRef:u,enabled:i.hasSelectedProject,canCancel:i.canCancel}),cKe({socket:i.socket,activeChatId:i.activeChatId});const wt=_.useCallback(re=>{var xe;!i.hasSelectedProject||re.length===0||(xe=f.current)==null||xe.enqueueFiles(re)},[i.hasSelectedProject]),{isPageFileDragActive:Zt,handleTranscriptDragEnter:en,handleTranscriptDragOver:Et,handleTranscriptDragLeave:ln,handleTranscriptDrop:xn}=XXe({hasSelectedProject:i.hasSelectedProject,onFilesDropped:wt}),{typedEmptyStateText:Bt,isEmptyStateTypingComplete:tn}=YXe(V,i.activeChatId,e);return _.useEffect(()=>()=>z(),[z]),_.useEffect(()=>{o.current=!0,z(),x(!1)},[z,x,i.activeChatId]),_.useEffect(()=>{const re=e.requestAnimationFrame(()=>{H()}),xe=e.setTimeout(()=>{H()},iKe);return()=>{e.cancelAnimationFrame(re),e.clearTimeout(xe)}},[F,H,e]),_.useEffect(()=>t.addWindowListener("resize",()=>{H()}),[t,H]),_.useEffect(()=>{if(!o.current)return;let re=null;const xe=e.requestAnimationFrame(()=>{var Q,Y;(Y=(Q=s.current)==null?void 0:Q.scrollToEnd)==null||Y.call(Q,{animated:!1}),re=e.requestAnimationFrame(()=>{var fe,ye;(ye=(fe=s.current)==null?void 0:fe.scrollToEnd)==null||ye.call(fe,{animated:!1})})});return()=>{e.cancelAnimationFrame(xe),re!==null&&e.cancelAnimationFrame(re)}},[i.commandError,i.isDraining,i.isProcessing,i.messages.length,i.queuedMessages.length,i.runtimeStatus,e]),c.jsxs($D,{ref:l,className:"bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative",onDragEnter:en,onDragOver:Et,onDragLeave:ln,onDrop:xn,children:[c.jsxs(BD,{className:"flex flex-1 min-h-0 flex-col overflow-hidden p-0 relative",children:[c.jsx(ZVe,{sidebarCollapsed:i.sidebarCollapsed,onOpenSidebar:i.openSidebar,onExpandSidebar:i.expandSidebar,onNewChat:i.handleCompose,localPath:i.navbarLocalPath,embeddedTerminalVisible:F,onToggleEmbeddedTerminal:k?n:void 0,rightSidebarVisible:W,onToggleRightSidebar:k?r:void 0,onOpenExternal:i.handleOpenExternal,editorPreset:j,editorCommandTemplate:P,platform:(ve=i.localProjects)==null?void 0:ve.machine.platform,finderShortcut:D.bindings.openInFinder,editorShortcut:D.bindings.openInEditor,terminalShortcut:D.bindings.toggleEmbeddedTerminal,rightSidebarShortcut:D.bindings.toggleRightSidebar,branchName:(Ie=i.chatDiffSnapshot)==null?void 0:Ie.branchName,homeDir:(Le=i.localProjects)==null?void 0:Le.machine.homeDir,hasGitRepo:((Qe=i.chatDiffSnapshot)==null?void 0:Qe.status)!=="no_repo",gitStatus:(pt=i.chatDiffSnapshot)==null?void 0:pt.status,timings:(sn=i.runtime)==null?void 0:sn.timings,status:(At=i.runtime)==null?void 0:At.status,socket:i.socket,onOpenPtyChat:w,currentChatId:i.activeChatId??void 0,shareShares:We,onShareMint:Ot,onShareRevoke:Tt}),c.jsx(KXe,{activeChatId:i.activeChatId,listRef:s,messages:i.messages,queuedMessages:i.queuedMessages,transcriptPaddingBottom:g,localPath:(nn=i.runtime)==null?void 0:nn.localPath,latestToolIds:i.latestToolIds,isHistoryLoading:i.isHistoryLoading,hasOlderHistory:i.hasOlderHistory,isProcessing:i.isProcessing,runtimeStatus:i.runtimeStatus,isDraining:i.isDraining,commandError:i.commandError,loadOlderHistory:i.loadOlderHistory,onStopDraining:i.handleStopDraining,onSteerQueuedMessage:i.handleSteerQueuedMessage,onRemoveQueuedMessage:i.handleRemoveQueuedMessage,onOpenLocalLink:i.handleOpenLocalLink,editorPreset:j,editorCommandTemplate:P,platform:(qt=i.localProjects)==null?void 0:qt.machine.platform,onAskUserQuestionSubmit:i.handleAskUserQuestion,onExitPlanModeConfirm:i.handleExitPlanMode,onToolRequestAnswer:i.handleToolRequestAnswer,onSubagentAskUserQuestionSubmit:i.handleSubagentAskUserQuestion,onSubagentExitPlanModeSubmit:i.handleSubagentExitPlanMode,schedules:((rt=i.chatSnapshot)==null?void 0:rt.schedules)??Oae,cronJobs:((_t=i.chatSnapshot)==null?void 0:_t.cronJobs)??nE,onCronPause:he,onCronResume:ce,onCronRemove:ae,onAutoContinueAccept:ne,onAutoContinueReschedule:oe,onAutoContinueCancel:_e,onRetryFailedTurn:J,tunnels:(Ze=i.chatSnapshot)==null?void 0:Ze.tunnels,liveTunnelId:(ot=i.chatSnapshot)==null?void 0:ot.liveTunnelId,onTunnelAccept:te,onTunnelStop:ue,onTunnelRetry:pe,subagentRuns:(ct=i.chatSnapshot)==null?void 0:ct.subagentRuns,onCancelSubagentRun:Ne,loopProgress:(De=i.chatSnapshot)==null?void 0:De.loopProgress,workflowRuns:je.length>0?je:void 0,backgroundTasks:(nt=i.runtime)==null?void 0:nt.backgroundTasks,getWorkflowRunDetail:Ke,getSubagentTranscript:qe,showScrollButton:v&&i.messages.length>0,onIsAtEndChange:U,scrollToBottom:()=>$(!0),typedEmptyStateText:Bt,isEmptyStateTypingComplete:tn,isPageFileDragActive:Zt,showEmptyState:V})]}),c.jsx(vXe,{inputRef:h,onLayoutChange:m,chatInputRef:f,chatInputElementRef:u,activeChatId:i.activeChatId,previousPrompt:i.previousPrompt,hasSelectedProject:i.hasSelectedProject,canCancel:i.canCancel,projectId:k,activeProvider:((ke=i.runtime)==null?void 0:ke.provider)??null,availableProviders:i.availableProviders,contextWindowSnapshot:B,sessionTotals:I,onSubmit:q,onCancel:i.handleCancel,hasUnpausedCronJob:(((ee=i.chatSnapshot)==null?void 0:ee.cronJobs)??nE).some(re=>!re.paused)})]})}const QXe="flex-1 flex flex-col min-h-0 min-w-0 relative";function JXe(e){const t=bs(r=>r.layoutWidth),n=bs(r=>r.setLayoutWidth);return _.useLayoutEffect(()=>{const r=e.current;if(!r)return;const i=()=>{const o=r.clientWidth,a=bs.getState().layoutWidth;Math.abs(a-o)>=1&&n(o)},s=new ResizeObserver(i);return s.observe(r),i(),()=>s.disconnect()},[e,n]),t}const ZXe=_.memo(e=>c.jsx(P4e,{...e,diffs:e.diffs??yoe}));function mK({ports:e={}}={}){var Q;const t=e.dom??Nt,n=e.timer??ar,r=q_(),i=CE(),s=_.useRef(null),o=r.activeProjectId,a=r.activeChatId,{boardId:l}=Gp(),u=mc(),f=r.sidebarData,h=nse().chatNavigator,m=r.handleOpenExternal,g=zh(Y=>Y.projects),v=ds(Y=>Y.boardsByOwner),x=ds(Y=>Y.viewByBoard),w=(o?g[o]:void 0)??gI,C=Ts(Y=>o?Y.projects[o]:void 0)??YZ,E=Ts(Y=>Y.size),N=zh(Y=>Y.addTerminal),A=zh(Y=>Y.removeTerminal),j=zh(Y=>Y.toggleVisibility),P=zh(Y=>Y.setTerminalSizes),M=Ts(Y=>Y.toggleVisibility),F=qs(Y=>Y.scrollbackLines),W=qs(Y=>Y.minColumnWidth),D=_.useMemo(()=>DE(r.keybindings),[r.keybindings]),B=w.terminals.length>0,I=!!(o&&C.isVisible),V=us(Y=>Y.layout),z=_.useMemo(()=>xs(V.root).some(Y=>Y.tabs.length>0),[V]),U=us(Y=>Y.seedFromLegacy),H=us(Y=>Y.focusPane),$=us(Y=>Y.focusTab),q=us(Y=>Y.closeTab),O=us(Y=>Y.splitPane),J=us(Y=>Y.setGroupSizes),ne=us(Y=>Y.focusAdjacentPane),oe=us(Y=>Y.resizeFocusedPane),he=us(Y=>Y.cycleFocusedPaneTab),ce=us(Y=>Y.closeFocusedTab),ae=us(Y=>Y.splitFocusedPane),_e=us(Y=>Y.moveTabToPane),te=us(Y=>Y.openTab),ue=us(Y=>Y.getLayout);_.useEffect(()=>{o&&U({terminals:w.terminals,mainSizes:w.mainSizes,terminalSizes:w.terminals.map(Y=>Y.size),changesVisible:C.isVisible,changesSizePercent:E??Xg})},[o,U,w,C,E]),_.useEffect(()=>{const Y=xs(ue().root).flatMap(ye=>ye.tabs);for(const ye of w.terminals)Y.some(ft=>ft.target.kind==="terminal"&&ft.target.terminalId===ye.id)||te({kind:"terminal",terminalId:ye.id});for(const ye of Y)ye.target.kind==="terminal"&&!OR(g,ye.target.terminalId)&&q(ye.tabId);const fe=Y.find(ye=>ye.target.kind==="changes");I&&!fe&&te({kind:"changes"}),!I&&fe&&q(fe.tabId),a&&te({kind:"chat",chatId:a}),l&&te({kind:"board",boardId:l})},[w.terminals,g,I,a,l,te,q,ue]);const pe=_.useCallback(()=>{const Y=ue(),fe=xs(Y.root).find(Ge=>Ge.id===Y.focusedPaneId),ye=fe==null?void 0:fe.tabs.find(Ge=>Ge.tabId===fe.focusedTabId);(ye==null?void 0:ye.target.kind)==="chat"&&ye.target.chatId!==a&&h.openChat(ye.target.chatId)},[ue,a,h]),Ne=_.useCallback(Y=>{$(Y),pe()},[$,pe]),je=_.useCallback(({tabId:Y,paneId:fe,position:ye})=>{O({tabId:Y,targetPaneId:fe,position:ye})},[O]),Ke=_.useCallback(Y=>{H(Y),pe()},[H,pe]),qe=_.useCallback((Y,fe)=>{J(Y,fe)},[J]),We=_.useCallback((Y,fe)=>{_e(Y,fe)},[_e]),xt=_.useCallback((Y,fe,ye)=>{O({tabId:Y,targetPaneId:fe,position:ye})},[O]),gt=_.useMemo(()=>yHe({terminalProjects:g,sidebarData:f,boardsByOwner:v,boardViews:x}),[g,f,v,x]),Ot=_.useMemo(()=>SHe(f),[f]);JXe(s);const{diffRenderMode:Tt,wrapDiffLines:wt,setDiffRenderMode:Zt,setWrapDiffLines:en,scheduleTerminalDiffRefresh:Et,handleOpenDiffFile:ln,handleCopyDiffFilePath:xn,handleCopyDiffRelativePath:Bt,handleLoadDiffPatch:tn,handleDiscardDiffFile:Yt,handleIgnoreDiffFile:Ut,handleIgnoreDiffFolder:Ht,handleOpenDiffInFinder:$t,handleCommitDiffs:ve,handleSyncBranch:Ie,handleGenerateCommitMessage:Le,handleInitializeGit:Qe,handleGetGitHubPublishInfo:pt,handleCheckGitHubRepoAvailability:sn,handleSetupGitHub:At,handleListBranches:nn,handleCheckoutBranch:qt,handlePreviewMergeBranch:rt,handleMergeBranch:_t,handleCreateBranch:Ze}=zUe({state:r,projectId:o,showRightSidebar:I}),ot=_.useCallback(()=>{if(o){if(B){j(o);return}N(o)}},[N,B,o,j]),ct=_.useCallback(()=>{o&&M(o)},[o,M]),De=_.useCallback(()=>{var Y;if(o){if(I){M(o);return}if(((Y=r.chatDiffSnapshot)==null?void 0:Y.status)==="no_repo"){(async()=>{if(!await i.confirm({title:"Initialize Git?",description:"Initialize a local git repository in this project?",confirmLabel:"Init Git",cancelLabel:"Cancel"}))return;const ye=await Qe();ye!=null&&ye.ok&&!I&&M(o)})();return}M(o)}},[i,Qe,o,I,(Q=r.chatDiffSnapshot)==null?void 0:Q.status,M]),nt=_.useCallback((Y,fe)=>{r.socket.command({type:"terminal.close",terminalId:fe}).catch(()=>{}),A(Y,fe)},[A,r.socket]),ke=_.useCallback(Y=>{var ye;const fe=xs(ue().root).flatMap(Ge=>Ge.tabs).find(Ge=>Ge.tabId===Y);if((fe==null?void 0:fe.target.kind)==="terminal"){const Ge=OR(g,fe.target.terminalId);Ge?nt(Ge.projectId,fe.target.terminalId):q(Y);return}if((fe==null?void 0:fe.target.kind)==="changes"){o&&M(o);return}if((fe==null?void 0:fe.target.kind)==="chat"){const Ge=fe.target.chatId,ft=(ye=xs(ue().root).flatMap(vt=>vt.tabs).find(vt=>vt.tabId!==Y&&vt.target.kind==="chat"&&vt.target.chatId!==Ge))==null?void 0:ye.target;q(Y),Ge===a&&((ft==null?void 0:ft.kind)==="chat"?h.openChat(ft.chatId):h.closeChat());return}q(Y)},[o,g,q,ue,nt,M,a,h]);_.useEffect(()=>{function Y(fe){if(o){if(_x(D,"toggleEmbeddedTerminal",fe)){fe.preventDefault(),ot();return}if(_x(D,"toggleRightSidebar",fe)){fe.preventDefault(),De();return}if(_x(D,"openInFinder",fe)){fe.preventDefault(),m("open_finder");return}if(_x(D,"openInEditor",fe)){fe.preventDefault(),m("open_editor");return}if(_x(D,"addSplitTerminal",fe)){fe.preventDefault(),N(o);return}}const ye=fe.target,Ge=mHe(D,fe,pHe(ye instanceof HTMLElement?ye:null));if(Ge)switch(fe.preventDefault(),Ge.kind){case"focus":ne(Ge.direction),pe();return;case"resize":oe(Ge.direction);return;case"split":ae(Ge.position);return;case"closeTab":ce(),pe();return;case"cycleTab":he(Ge.delta),pe()}}return t.addWindowListener("keydown",Y)},[N,ce,he,t,ne,m,ot,De,o,oe,D,ae,pe]);const ee=_.useMemo(()=>o?{projectId:o,diffs:r.chatDiffSnapshot??yoe,editorLabel:r.editorLabel,diffRenderMode:Tt,wrapLines:wt,onOpenFile:ln,onOpenInFinder:$t,onDiscardFile:Yt,onIgnoreFile:Ut,onIgnoreFolder:Ht,onCopyFilePath:xn,onCopyRelativePath:Bt,onLoadPatch:tn,onListBranches:nn,onPreviewMergeBranch:rt,onMergeBranch:_t,onCheckoutBranch:qt,onCreateBranch:Ze,onGenerateCommitMessage:Le,onInitializeGit:Qe,onGetGitHubPublishInfo:pt,onCheckGitHubRepoAvailability:sn,onSetupGitHub:At,onCommit:ve,onSyncWithRemote:Ie,onDiffRenderModeChange:Zt,onWrapLinesChange:en,onClose:ct}:null,[Tt,sn,qt,ct,ve,xn,Bt,Ze,Yt,Le,pt,Ut,Ht,Qe,nn,tn,_t,ln,$t,rt,At,Ie,o,Zt,en,r.chatDiffSnapshot,r.editorLabel,wt]),re=_.useCallback(Y=>{u(`/boards/${Y}`)},[u]),xe={board:(Y,fe,ye,Ge)=>Ge?c.jsx(xVe,{boardId:Y.boardId,socket:r.socket,chatFacts:Ot,onOpenBoards:re}):null,chat:Y=>c.jsx(K9,{chatId:Y.chatId,timer:n,dom:t,children:c.jsx(pK,{timer:n,dom:t,onToggleEmbeddedTerminal:ot,onToggleRightSidebar:De})}),changes:()=>ee?c.jsx(ZXe,{...ee}):null,terminal:(Y,fe,ye)=>{const Ge=OR(g,Y.terminalId);if(!Ge)return null;const ft=g[Ge.projectId]??gI;return c.jsx(PUe,{projectId:Ge.projectId,terminalLayout:{...ft,terminals:[Ge.terminal]},addTerminal:N,socket:r.socket,connectionStatus:r.connectionStatus,scrollback:F,minColumnWidth:W,splitTerminalShortcut:D.bindings.addSplitTerminal,focusRequestVersion:ye?1:0,onTerminalCommandSent:Et,onRemoveTerminal:nt,onTerminalLayout:P})}};return c.jsx("div",{ref:s,className:QXe,children:z?c.jsx(xHe,{onMoveTab:We,onSplitWithTab:xt,children:c.jsx(YUe,{layout:V,renderPane:(Y,fe)=>c.jsx(cHe,{pane:Y,isFocused:fe,registry:xe,presentation:gt,onSelectTab:Ne,onCloseTab:ke,onSplit:je}),onFocusPane:Ke,onResizeGroup:qe})}):c.jsx(K9,{chatId:r.activeChatId,timer:n,dom:t,children:c.jsx(pK,{timer:n,dom:t,onToggleEmbeddedTerminal:ot,onToggleRightSidebar:De})})})}const FO=Jt("CopyButton",()=>e=>({copied:!1,setCopied:t=>e({copied:t})}));function gK({narrow:e=!1,title:t,subtitle:n,icon:r=pD}){return c.jsxs("div",{className:le("w-full",e?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[c.jsxs("div",{className:le("flex items-center gap-1 mb-2",e&&"justify-center"),children:[c.jsx("div",{className:"p-2 pl-0 rounded-lg",children:c.jsx(r,{className:"h-6 w-6 text-muted-foreground"})}),c.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:t})]}),n&&c.jsx("p",{className:le("text-muted-foreground",e&&"mb-10 text-center"),children:n})]})}const ep=Qt()(e=>({tab:"new",name:"",existingPath:"",setTab:t=>e({tab:t}),setName:t=>e({name:t}),setExistingPath:t=>e({existingPath:t}),resetForOpen:()=>e({tab:"new",name:"",existingPath:""})})),eQe=()=>ep(e=>e.tab),tQe=()=>ep(e=>e.name),nQe=()=>ep(e=>e.existingPath);function rQe(e){return e.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function iQe({open:e,onOpenChange:t,onConfirm:n,ports:r={}}){const i=r.timer??ar,s=eQe(),o=tQe(),a=nQe(),l=ep(C=>C.setTab),u=ep(C=>C.setName),f=ep(C=>C.setExistingPath),h=ep(C=>C.resetForOpen),m=_.useRef(null),g=_.useRef(null);_.useEffect(()=>{e&&(h(),i.setTimeout(()=>{var C;return(C=m.current)==null?void 0:C.focus()},0))},[e,h,i]),_.useEffect(()=>{e&&i.setTimeout(()=>{var C,E;s==="new"?(C=m.current)==null||C.focus():(E=g.current)==null||E.focus()},0)},[s,e,i]);const v=rQe(o),x=v?`${p_e}/${v}`:"",y=a.trim(),w=s==="new"?!!v:!!y,k=()=>{if(w){if(s==="new")n({mode:"new",localPath:x,title:o.trim()});else{const C=y.split("/").pop()||y;n({mode:"existing",localPath:y,title:C})}t(!1)}};return c.jsx(Ma,{open:e,onOpenChange:t,children:c.jsxs(Xo,{size:"sm",children:[c.jsxs(fl,{className:"space-y-4",children:[c.jsx(Pa,{children:"Add Project"}),c.jsx(ms,{value:s,onValueChange:l,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full mb-2",optionClassName:"flex-1 justify-center"}),s==="new"?c.jsxs("div",{className:"space-y-2",children:[c.jsx(Lt,{ref:m,type:"text",value:o,onChange:C=>u(C.target.value),onKeyDown:C=>{C.key==="Enter"&&k(),C.key==="Escape"&&t(!1)},placeholder:"Project name"}),x&&c.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:x})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx(Lt,{ref:g,type:"text",value:a,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&k(),C.key==="Escape"&&t(!1)},placeholder:"~/Projects/my-app"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),c.jsxs(Eu,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),c.jsx(Re,{variant:"secondary",size:"sm",onClick:k,disabled:!w,children:"Create"})]})]})})}function sQe({text:e,ports:t={}}){const n=FO.useScopedStore(a=>a.copied),r=FO.useScopedStore(a=>a.setCopied),i=t.clipboard??Ua,s=t.timer??ar;async function o(){await i.writeText(e),r(!0),s.setTimeout(()=>r(!1),2e3)}return c.jsx(Re,{variant:"ghost",size:"icon-mobile","aria-label":n?"Copied":"Copy to clipboard",className:"text-muted-foreground hover:text-foreground",onClick:()=>void o(),children:n?c.jsx(Ls,{className:"h-4 w-4 text-success"}):c.jsx(ja,{className:"h-4 w-4"})})}function oQe({text:e}){return c.jsx(FO.Provider,{init:{},children:c.jsx(sQe,{text:e})})}function vK({children:e}){return c.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[c.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[c.jsx(Ra,{className:"inline h-4 w-4 opacity-40"}),c.jsx("code",{children:e})]}),c.jsx(oQe,{text:e})]})}function CC({children:e}){return c.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:e})}function Sj({children:e}){return c.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:e})}function wj({icon:e,title:t,subtitle:n,iconClassName:r}){return c.jsxs("div",{className:"flex flex-col items-start gap-1.5 min-w-0",children:[c.jsx(e,{className:r||"h-5 w-5 text-muted-foreground"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),c.jsx("span",{className:"text-xs text-muted-foreground leading-tight",children:n})]})}function bK(){return c.jsx("div",{"aria-hidden":!0,className:"mt-5 h-px w-6 shrink-0 bg-border"})}function xK({number:e,title:t,children:n}){return c.jsx("div",{className:"flex gap-4",children:c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[e,"."]}),c.jsx("h3",{className:"font-medium text-foreground mb-2",children:t})]}),c.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:n})]})})}function aQe({localPath:e,loading:t,onClick:n}){return c.jsxs(Ni,{children:[c.jsx(Ti,{asChild:!0,children:c.jsxs("button",{className:le("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",t&&"opacity-50 cursor-not-allowed"),disabled:t,onClick:n,children:[c.jsx(BG,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),c.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:a0(e)}),t?c.jsx(Mn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):c.jsx(gD,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),c.jsx(fi,{children:c.jsx("p",{children:e})})]})}function lQe({connectionStatus:e,ready:t,snapshot:n,startingLocalPath:r,commandError:i,newProjectOpen:s,onNewProjectOpenChange:o,onOpenProject:a,onCreateProject:l}){const u=_.useMemo(()=>(n==null?void 0:n.projects)??[],[n==null?void 0:n.projects]),f=e==="connecting"||!t,h=e==="connected"&&t;return c.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[h?c.jsxs(c.Fragment,{children:[c.jsx(gK,{title:(n==null?void 0:n.machine.displayName)??"Local Projects",subtitle:`${Hr} is connected, choose a project below to get started.`}),c.jsxs("div",{className:"w-full px-6 mb-10",children:[c.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[c.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider",children:"Projects"}),c.jsxs(Re,{variant:"default",size:"sm",onClick:()=>o(!0),children:[c.jsx(Co,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),u.length>0?c.jsx("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr))]",children:u.map(m=>c.jsx(aQe,{localPath:m.localPath,loading:r===m.localPath,onClick:()=>{a(m.localPath)}},m.localPath))}):c.jsx(CC,{children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No local projects discovered yet. Open one with Claude or Codex, or create a new project here."})}),i?c.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:i}):null]})]}):c.jsxs(c.Fragment,{children:[c.jsx(gK,{narrow:!0,icon:Xj,title:f?`Connecting ${Hr}`:`Connect ${Hr}`,subtitle:f?`${Hr} is starting up and loading your local projects.`:`Run ${Hr} directly on your machine with full access to your local files and agent project history.`}),c.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[c.jsx(Sj,{children:"Status"}),c.jsx("div",{className:"mb-8",children:c.jsx(CC,{children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Mn,{className:"h-4 w-4 text-muted-foreground animate-spin"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:f?`Connecting to your local ${Hr} server...`:c.jsxs(c.Fragment,{children:["Not connected. Run ",c.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:uw()})," from any terminal on this machine."]})})]})})}),f?null:c.jsxs("div",{className:"mb-10",children:[c.jsx(Sj,{children:"How it works"}),c.jsx(CC,{children:c.jsxs("div",{className:"flex items-start gap-4 py-2 px-2",children:[c.jsx(wj,{icon:lE,title:`${Hr} CLI`,subtitle:"On Your Machine"}),c.jsx(bK,{}),c.jsx(wj,{icon:pD,title:`${Hr} Server`,subtitle:"Local WebSocket"}),c.jsx(bK,{}),c.jsx(wj,{icon:Xj,title:`${Hr} UI`,subtitle:"Project Chat"})]})})]}),f?null:c.jsxs("div",{className:"mb-10",children:[c.jsx(Sj,{children:"Setup"}),c.jsx(CC,{children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs(xK,{number:1,title:`Start ${Hr}`,children:[c.jsx("p",{children:"Run this command in your terminal:"}),c.jsx(vK,{children:uw()})]}),c.jsxs(xK,{number:2,title:"Open the local UI",children:[c.jsxs("p",{children:[Hr," serves the app locally and opens the Local Projects page in an app-style browser window."]}),c.jsx(vK,{children:"http://localhost:3210/local"})]}),c.jsxs("div",{className:"mt-8",children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-4",children:"Notes"}),c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsxs("div",{className:"flex gap-4",children:[c.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:uw("").trim()}),c.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),c.jsxs("div",{className:"flex gap-4",children:[c.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:uw("--no-open")}),c.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),c.jsx(iQe,{open:s,onOpenChange:o,onConfirm:m=>{l(m)}}),c.jsx("div",{className:"py-4 text-center",children:c.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",zD.split("/")[1]]})})]})}function cQe(){const e=q_();return c.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 relative",children:c.jsx(lQe,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,newProjectOpen:e.addProjectModalOpen,onNewProjectOpenChange:t=>{if(t){e.openAddProjectModal();return}e.closeAddProjectModal()},onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}const uQe=[],Hh=Qt()(e=>({templates:uQe,openMenuId:null,picking:!1,renamingId:null,error:null,setTemplates:t=>e({templates:Array.isArray(t)?t:[]}),openMenu:t=>e({openMenuId:t}),closeMenu:()=>e({openMenuId:null}),openPicker:()=>e({picking:!0,error:null}),closePicker:()=>e({picking:!1}),startRename:t=>e({renamingId:t,picking:!1,openMenuId:null}),stopRename:()=>e({renamingId:null}),setError:t=>e({error:t})}));function dQe(e){return e.templates}function fQe({projectId:e,projectName:t,socket:n,onOpenBoard:r}){const i=U9("project",e),s=ds(CHe(i)),o=Hh(dQe),a=Hh(E=>E.picking),l=Hh(E=>E.renamingId),u=Hh(E=>E.error),{openPicker:f,closePicker:h,startRename:m,stopRename:g,setError:v,setTemplates:x}=Hh.getState();_.useEffect(()=>n.subscribe({type:"boards",ownerKind:"project",ownerId:e},E=>{ds.getState().setBoards(U9(E.ownerKind,E.ownerId),E.boards)}),[e,n]),_.useEffect(()=>{let E=!1;return n.command({type:"board.templates.list"}).then(N=>{E||x(N)}).catch(()=>{}),()=>{E=!0}},[n,x]);const y=_.useCallback(async E=>{try{await n.command(E),v(null)}catch(N){v(N instanceof Error?N.message:"That did not work.")}},[n,v]),w=_.useCallback(E=>{h(),y({type:"board.create",ownerKind:"project",ownerId:e,title:E?E.name:"Untitled board",templateId:(E==null?void 0:E.id)??null})},[h,e,y]),k=_.useCallback((E,N)=>{g();const A=N.trim();A!==""&&y({type:"board.update",boardId:E,title:A})},[y,g]),C=a||s.length===0;return c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-background",children:[c.jsxs("header",{className:"flex items-end justify-between gap-4 border-b border-border px-6 py-4",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h1",{className:"text-lg font-medium leading-tight tracking-[-0.01em] text-foreground",children:"Boards"}),c.jsxs("p",{className:"truncate text-[13px] text-muted-foreground",children:[t,s.length>0?c.jsxs("span",{className:"tabular-nums",children:[" · ",s.length," boards"]}):null]})]}),s.length>0?c.jsxs(Re,{size:"sm",onClick:f,children:[c.jsx(Co,{className:"size-3.5"}),"New board"]}):null]}),u?c.jsx("p",{className:"border-b border-border px-6 py-2 text-[13px] text-destructive-text",children:u}):null,c.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[C?c.jsx(mQe,{templates:o,firstRun:s.length===0,onPick:w,onCancel:h}):null,s.length>0?c.jsx("ul",{className:"px-4 py-1",children:s.map(E=>c.jsx(hQe,{board:E,renaming:l===E.id,onOpen:r,onStartRename:m,onRename:k,onCancelRename:g,onCommand:y},E.id))}):null]})]})}function hQe({board:e,renaming:t,onOpen:n,onStartRename:r,onRename:i,onCancelRename:s,onCommand:o}){const a=_.useCallback(()=>n(e.id),[e.id,n]),l=_.useCallback(f=>{f.key==="Enter"&&i(e.id,f.currentTarget.value),f.key==="Escape"&&s()},[e.id,s,i]),u=_.useCallback(f=>i(e.id,f.currentTarget.value),[e.id,i]);return c.jsxs("li",{className:"group grid grid-cols-[1fr_auto_auto] items-center gap-5 border-b border-border px-3 py-3 last:border-b-0 hover:bg-secondary",children:[c.jsx("div",{className:"min-w-0",children:t?c.jsx(Lt,{autoFocus:!0,defaultValue:e.title,onKeyDown:l,onBlur:u,className:"h-7 max-w-sm","aria-label":"Board name"}):c.jsxs("button",{type:"button",onClick:a,className:"block w-full text-left",children:[c.jsx("span",{className:"block truncate text-[15px] font-semibold tracking-[-0.005em] text-foreground",children:e.title}),e.description?c.jsx("span",{className:"mt-0.5 block truncate text-[13px] text-muted-foreground",children:e.description}):null]})}),c.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[c.jsxs("span",{children:[c.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.columnCount})," columns"]}),c.jsxs("span",{children:[c.jsx("b",{className:"font-medium tabular-nums text-foreground",children:e.cardCount})," cards"]})]}),c.jsx(pQe,{board:e,onStartRename:r,onCommand:o})]})}function pQe({board:e,onStartRename:t,onCommand:n}){const r=Hh(h=>h.openMenuId===e.id),{openMenu:i,closeMenu:s}=Hh.getState(),o=_.useCallback(h=>{h?i(e.id):s()},[e.id,s,i]),a=_.useCallback(()=>{s(),t(e.id)},[e.id,s,t]),l=_.useCallback(()=>{s(),n({type:"board.duplicate",boardId:e.id,title:`${e.title} copy`})},[e.id,e.title,s,n]),u=_.useCallback(()=>{s(),n({type:"board.saveAsTemplate",boardId:e.id,name:e.title})},[e.id,e.title,s,n]),f=_.useCallback(()=>{s(),n({type:"board.archive",boardId:e.id})},[e.id,s,n]);return c.jsxs(bc,{open:r,onOpenChange:o,children:[c.jsx(xc,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":`Actions for ${e.title}`,className:"rounded-md px-1.5 py-1 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",children:c.jsx(Sp,{className:"size-4"})})}),c.jsxs(_l,{align:"end",className:"w-56 p-1",children:[c.jsx(kC,{onClick:a,children:"Rename"}),c.jsx(kC,{onClick:l,children:"Duplicate structure"}),c.jsx(kC,{onClick:u,children:"Save as template"}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsx(kC,{onClick:f,tone:"destructive",children:"Archive"})]})]})}function kC({onClick:e,children:t,tone:n}){return c.jsx("button",{type:"button",onClick:e,className:le("flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-secondary",n==="destructive"&&"text-destructive-text"),children:t})}function mQe({templates:e,firstRun:t,onPick:n,onCancel:r}){const i=_.useCallback(()=>n(null),[n]);return c.jsxs("div",{className:"px-6 py-8",children:[t?c.jsxs(c.Fragment,{children:[c.jsx("h2",{className:"text-[15px] font-semibold text-foreground",children:"No boards in this project yet."}),c.jsx("p",{className:"mt-1 max-w-[58ch] text-sm text-muted-foreground",children:"A board turns issues into work your agents can pick up. Start from a shape, or import an existing tracker."})]}):c.jsx("h2",{className:"text-[15px] font-semibold text-foreground",children:"Start from a shape"}),c.jsxs("div",{className:"mt-4 max-w-xl rounded-lg border border-border",children:[e.map(s=>c.jsx(gQe,{template:s,onPick:n},s.id)),c.jsx("button",{type:"button",onClick:i,className:"flex w-full items-center border-t border-border px-3.5 py-2.5 text-left hover:bg-secondary",children:c.jsxs("span",{children:[c.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Empty board"}),c.jsx("span",{className:"block text-xs text-muted-foreground",children:"Name your own columns"})]})})]}),t?null:c.jsx(Re,{variant:"ghost",size:"sm",className:"mt-3",onClick:r,children:"Cancel"})]})}function gQe({template:e,onPick:t}){const n=_.useCallback(()=>t(e),[t,e]),r=e.definition.columns;return c.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 border-b border-border px-3.5 py-2.5 text-left last:border-b-0 hover:bg-secondary",children:[c.jsxs("span",{className:"min-w-0",children:[c.jsx("span",{className:"block text-sm font-medium text-foreground",children:e.name}),c.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:r.map(i=>i.title).join(" · ")})]}),c.jsx("span",{"aria-hidden":!0,className:"ml-auto flex shrink-0 gap-1",children:r.map((i,s)=>c.jsx("span",{className:le("size-1.5 rounded-full",i.colorToken?BN[i.colorToken]:"bg-muted-icon")},`${e.id}-${String(s)}`))})]})}function vQe(){const e=q_(),t=mc(),{projectId:n=""}=Gp(),i=[...e.sidebarData.starredProjectGroups,...e.sidebarData.projectGroups].find(a=>a.groupKey===n),s=i?a0(i.localPath):"Project",o=_.useCallback(a=>{t(`/boards/${n}/${a}`)},[t,n]);return c.jsx("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:c.jsx(fQe,{projectId:n,projectName:s,socket:e.socket,onOpenBoard:o})})}const bQe=["app_launch","project_opened","project_created","project_removed","chat_created","chat_deleted","message_sent","update_checked","update_installed","update_failed","analytics_enabled","analytics_disabled"],xQe=["current_version","environment","latest_version","custom_port_enabled","no_open_enabled","password_enabled","strict_port_enabled","remote_enabled","host_enabled","share_quick_enabled","share_token_enabled"];function yQe(){return{name:"",provider:"claude",model:Au("claude").defaultModel,modelOptions:{...Wo},systemPrompt:"",contextScope:"previous-assistant-reply",triggerMode:"auto"}}function _Qe(){return{draft:yQe(),error:null,pending:!1,confirmDelete:!1}}const ec=Qt()(e=>({editing:{kind:"list"},form:_Qe(),timeoutDraft:"",loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,pending:!1,confirmDelete:!1}}),patchForm:t=>e(n=>({form:{...n.form,...t}})),patchFormDraft:t=>e(n=>({form:{...n.form,draft:{...n.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function Cj(e){return"contextWindow"in e}function yK(e){return"fastMode"in e}function SQe(e){const t=e.editing,n=_.useMemo(()=>t.kind!=="edit"?null:e.subagents.find(o=>o.id===t.id)??null,[t,e.subagents]),r=t.kind,i=r!=="list",s=e.subagents.length===0;return s&&!i?c.jsx(wQe,{onStartCreate:e.onStartCreate}):c.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:gap-8",children:[s?null:c.jsx(kQe,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?c.jsx(RQe,{mode:r,subject:r==="edit"?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r==="edit"?(n==null?void 0:n.id)??"edit":"create"):c.jsx(CQe,{})]})}function wQe(e){return c.jsxs("div",{className:"flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center","data-testid":"subagent-empty",children:[c.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:c.jsx(Df,{className:"size-5","aria-hidden":!0})}),c.jsx("p",{className:"text-sm font-medium text-foreground",children:"No subagents yet"}),c.jsxs(Re,{variant:"default",size:"sm",onClick:e.onStartCreate,children:[c.jsx(Co,{className:"mr-1.5 size-4"})," Create subagent"]})]})}function CQe(){return c.jsx("div",{className:"hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex",children:"Select a subagent to edit, or create a new one."})}function kQe(e){const t=e.editing.kind==="edit"?e.editing.id:null;return c.jsxs("aside",{className:"flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",style:{fontVariantNumeric:"tabular-nums"},children:[e.subagents.length," ",e.subagents.length===1?"agent":"agents"]}),c.jsxs(Re,{variant:"ghost",size:"sm",onClick:e.onStartCreate,"data-testid":"subagent-create",children:[c.jsx(Co,{className:"size-4"}),c.jsx("span",{className:"sr-only",children:"Create subagent"})]})]}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:e.subagents.map(n=>{var i;const r=((i=n.description)==null?void 0:i.trim())||(n.contextScope==="previous-assistant-reply"?"Last reply":"Full transcript");return c.jsx("li",{children:c.jsxs("button",{type:"button","data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:le("flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted",t===n.id&&"bg-muted"),children:[c.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[c.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n.name}),c.jsx(EQe,{provider:n.provider})]}),c.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:r})]})},n.id)})})]})}function EQe({provider:e}){const t=Au(e).label;return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:[c.jsx(Df,{className:"size-3"})," ",t]})}const NQe=[{value:"claude",label:"Claude"},{value:"codex",label:"Codex"}],TQe=[{value:"previous-assistant-reply",label:"Last reply"},{value:"full-transcript",label:"Full transcript"}],AQe=[{value:"auto",label:"Auto"},{value:"manual",label:"Manual"}];function RQe(e){var P;const t=_.useMemo(()=>e.mode==="edit"&&e.subject?LQe(e.subject):_K("claude",e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=ec(M=>M.resetForm),r=ec(M=>M.form),i=ec(M=>M.patchFormDraft),s=ec(M=>M.patchForm);_.useEffect(()=>{n(t)},[]);const{draft:o,error:a,pending:l,confirmDelete:u}=r,f=(a==null?void 0:a.field)==="name"?a.message:null,h=(a==null?void 0:a.field)==="general"?a.message:null,m=FQe(o,t),g=o.name.trim().length>0&&(e.mode==="create"||m);function v(M){i(M),(a==null?void 0:a.field)==="name"&&"name"in M&&s({error:null})}function x(M){if(M===o.provider)return;const F=_K(M,e.providerDefaults,e.availableProviders);i({provider:M,model:F.model,modelOptions:F.modelOptions})}function y(M){if(o.provider!=="claude")return;const F=Cj(o.modelOptions)?o.modelOptions:Wo;i({modelOptions:{...Wo,...F,reasoningEffort:M}})}function w(M){if(o.provider!=="claude")return;const F=Cj(o.modelOptions)?o.modelOptions:Wo;i({modelOptions:{...Wo,...F,contextWindow:M}})}function k(M){if(o.provider!=="codex")return;const F=yK(o.modelOptions)?o.modelOptions:xf;i({modelOptions:{...xf,...F,reasoningEffort:M}})}async function C(){if(!(!g||l)){s({pending:!0,error:null});try{const M=e.mode==="create"?await e.handlers.onCreate(o):await e.handlers.onUpdate(e.subject.id,o);M.ok||s({error:zQe(M.error)})}finally{s({pending:!1})}}}async function E(){if(!(e.mode!=="edit"||!e.subject)){if(!u){s({confirmDelete:!0});return}s({pending:!0});try{await e.handlers.onDelete(e.subject.id)}finally{s({pending:!1,confirmDelete:!1})}}}const N=o.provider==="claude"?{...Wo,...Cj(o.modelOptions)?o.modelOptions:{}}:null,A=o.provider==="codex"?{...xf,...yK(o.modelOptions)?o.modelOptions:{}}:null,j=e.availableProviders.find(M=>M.id===o.provider)??Au(o.provider);return c.jsxs("section",{className:"flex w-full flex-1 flex-col gap-4",children:[c.jsxs("header",{className:"flex flex-col gap-1",children:[c.jsx("h3",{className:"text-base font-medium text-foreground",children:e.mode==="create"?"New subagent":o.name||"Subagent"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Mention with ",c.jsxs("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:["@agent/",o.name||"<name>"]})," in chat."]})]}),h?c.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:h}):null,c.jsx(Vs,{label:"Name",hint:f,hintTone:f?"destructive":"muted",children:c.jsx(Lt,{"data-testid":"subagent-form-name",value:o.name,onChange:M=>v({name:UQe(M.target.value)}),maxLength:Jae,placeholder:"reviewer",className:"font-mono"})}),c.jsx(Vs,{label:"Description",hint:"Optional. Shown next to the name.",children:c.jsx(Lt,{"data-testid":"subagent-form-description",value:o.description??"",onChange:M=>v({description:M.target.value}),placeholder:"Reviews diffs against the repo style"})}),c.jsx(Vs,{label:"Provider",children:c.jsx(ms,{value:o.provider,onValueChange:M=>{TQ(M)&&x(M)},options:NQe,size:"sm"})}),c.jsx(Vs,{label:"Model",children:c.jsxs(Vo,{value:o.model,onValueChange:M=>v({model:M}),children:[c.jsx(go,{"data-testid":"subagent-form-model",className:"w-full md:w-72",children:c.jsx(wa,{placeholder:"Select a model"})}),c.jsx(vo,{children:j.models.map(M=>c.jsx(Kr,{value:M.id,children:M.label},M.id))})]})}),N?c.jsxs(c.Fragment,{children:[c.jsx(Vs,{label:"Reasoning effort",children:c.jsx(ms,{value:N.reasoningEffort,onValueChange:M=>{H1(M)&&y(M)},options:Gy.map(M=>({value:M.id,label:M.label})),size:"sm"})}),c.jsx(Vs,{label:"Context window",children:c.jsx(ms,{value:N.contextWindow,onValueChange:M=>{SQ(M)&&w(M)},options:Kh.map(M=>({value:M.id,label:M.label})),size:"sm"})})]}):null,A?c.jsx(Vs,{label:"Reasoning effort",children:c.jsx(ms,{value:A.reasoningEffort,onValueChange:M=>{W1(M)&&k(M)},options:U1.map(M=>({value:M.id,label:M.label})),size:"sm"})}):null,c.jsx(Vs,{label:"Context scope",children:c.jsx(ms,{value:o.contextScope,onValueChange:M=>{$Ce(M)&&v({contextScope:M})},options:TQe,size:"sm"})}),c.jsx(Vs,{label:"Trigger",hint:"Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.",children:c.jsx(ms,{value:o.triggerMode??"auto",onValueChange:M=>{FCe(M)&&v({triggerMode:M})},options:AQe,size:"sm"})}),c.jsx(Vs,{label:"System prompt",hint:"What this persona should focus on. Plain text.",children:c.jsx(Ea,{"data-testid":"subagent-form-system-prompt",value:o.systemPrompt,onChange:M=>v({systemPrompt:M.target.value}),placeholder:"You are a careful code reviewer...",rows:6,className:"min-h-32"})}),c.jsx(Vs,{label:"Max turns",hint:"Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; PTY/Codex runs are aborted.",children:c.jsx(Lt,{"data-testid":"subagent-form-max-turns",type:"number",min:1,step:1,value:((P=o.maxTurns)==null?void 0:P.toString())??"",onChange:M=>{const F=Number.parseInt(M.target.value,10);v({maxTurns:Number.isInteger(F)&&F>0?F:void 0})},placeholder:"unbounded",className:"w-36"})}),o.provider==="claude"?c.jsxs(c.Fragment,{children:[c.jsx(Vs,{label:"Working directory",hint:"Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.",children:c.jsx(Lt,{"data-testid":"subagent-form-working-dir",value:o.workingDir??"",onChange:M=>{const F=M.target.value;v({workingDir:F.length>0?F:void 0})},placeholder:"docs"})}),c.jsx(Vs,{label:"Allowed paths",hint:"Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.",children:c.jsx(Ea,{"data-testid":"subagent-form-allowed-paths",value:(o.allowedPaths??[]).join(`
2828
2828
  `),onChange:M=>{const F=M.target.value.split(/\r?\n/).map(W=>W.trim()).filter(W=>W.length>0);v({allowedPaths:F.length>0?F:void 0})},placeholder:`docs
2829
2829
  wiki`,rows:3})})]}):null,c.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 pt-2",children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:e.onCancelEditing,children:"Cancel"}),e.mode==="edit"?c.jsx(Re,{variant:"destructive",size:"sm","data-testid":"subagent-form-delete",disabled:l,onClick:E,children:u?"Confirm delete":"Delete"}):null,c.jsx(Re,{variant:"default",size:"sm","data-testid":"subagent-form-save",disabled:!g||l,onClick:C,children:l?"Saving…":"Save"})]})]})}function Vs(e){return c.jsxs("div",{className:"grid gap-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-foreground",children:e.label}),e.children,e.hint?c.jsx("span",{className:le("text-xs",e.hintTone==="destructive"?"text-destructive":"text-muted-foreground"),children:e.hint}):null]})}const jQe=[],MQe={claude:{model:Au("claude").defaultModel,modelOptions:{...Wo},planMode:!1},codex:{model:Au("codex").defaultModel,modelOptions:{...xf},planMode:!1},openrouter:{model:IE,modelOptions:{},planMode:!1}};function PQe(e){const t=jr(h=>{var m;return((m=h.settings)==null?void 0:m.subagents)??jQe}),n=jr(h=>{var m;return((m=h.settings)==null?void 0:m.providerDefaults)??MQe}),r=jr(F0),i=_.useMemo(()=>dL([...qy],r),[r]),s=ec(h=>h.editing),o=ec(h=>h.setEditing),a=_.useMemo(()=>({onCreate:async h=>{const m=await e.state.socket.command({type:"subagent.create",input:h});return m.ok&&o({kind:"edit",id:m.subagent.id}),m},onUpdate:async(h,m)=>await e.state.socket.command({type:"subagent.update",id:h,patch:{...m,maxTurns:m.maxTurns??null}}),onDelete:async h=>{await e.state.socket.command({type:"subagent.delete",id:h}),o({kind:"list"})}}),[e.state.socket,o]),l=_.useCallback(h=>{o({kind:"edit",id:h})},[o]),u=_.useCallback(()=>{o({kind:"create"})},[o]),f=_.useCallback(()=>{o({kind:"list"})},[o]);return c.jsxs("div",{className:"flex flex-col gap-6 px-6 py-6",children:[c.jsx(OQe,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),c.jsx(SQe,{subagents:t,providerDefaults:n,availableProviders:i,editing:s,onSelect:l,onStartCreate:u,onCancelEditing:f,handlers:a})]})}const kj="__none__",Ej=30,Nj=86400,IQe=600;function OQe(e){const t=jr(f=>{var h;return(h=f.settings)==null?void 0:h.subagentRuntime}),n=t?Math.round(t.runTimeoutMs/1e3):IQe,r=(t==null?void 0:t.defaultLoopSubagentId)??null,i=ec(f=>f.timeoutDraft),s=ec(f=>f.setTimeoutDraft),o=ec(f=>f.loopError),a=ec(f=>f.setLoopError);_.useEffect(()=>{s(String(n))},[n]);function l(){const f=Number(i);if(!Number.isInteger(f)||f<Ej||f>Nj){s(String(n)),a(`Timeout must be a whole number of seconds between ${Ej} and ${Nj}.`);return}a(null),f!==n&&e.handleWriteAppSettings({subagentRuntime:{runTimeoutMs:f*1e3}}).catch(h=>a(h instanceof Error?h.message:"Unable to save subagent runtime settings."))}function u(f){a(null);const h=f===kj?null:f;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:h}}).catch(m=>a(m instanceof Error?m.message:"Unable to save default loop subagent."))}return c.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4",children:[c.jsxs("header",{className:"flex flex-col gap-1",children:[c.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Loop & runtime"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Applies to background subagent runs and the autonomous ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:"/loop"}),"."]})]}),o?c.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:o}):null,c.jsx(Vs,{label:"Stall timeout (seconds)",hint:"A subagent run is aborted only after this long with no streamed activity — not a total wall-clock cap. A steadily-working run is never killed.",children:c.jsx(Lt,{type:"number",inputMode:"numeric",min:Ej,max:Nj,value:i,onChange:f=>s(f.target.value),onBlur:l,onKeyDown:f=>{f.key==="Enter"&&(l(),f.currentTarget.blur())},className:"w-full md:w-48 tabular-nums"})}),c.jsx(Vs,{label:"Default loop subagent",hint:"The subagent setup_loop delegates each chunk to when no explicit id is given.",children:c.jsxs(Vo,{value:r??kj,onValueChange:u,children:[c.jsx(go,{className:"w-full md:w-72",children:c.jsx(wa,{placeholder:"None"})}),c.jsxs(vo,{children:[c.jsx(Kr,{value:kj,children:"None (require explicit id)"}),e.subagents.map(f=>c.jsx(Kr,{value:f.id,children:f.name},f.id))]})]})})]})}const Jae=64,DQe=new Set(["EMPTY_NAME","INVALID_CHAR","RESERVED_NAME","DUPLICATE_NAME","TOO_LONG"]);function _K(e,t,n){var o,a;if(e==="claude"){const l=t==null?void 0:t.claude,u=(l==null?void 0:l.model)??((o=n==null?void 0:n.find(h=>h.id==="claude"))==null?void 0:o.defaultModel)??Au("claude").defaultModel,f=(l==null?void 0:l.modelOptions)??{...Wo};return{name:"",provider:e,model:u,modelOptions:{...f},systemPrompt:"",contextScope:"previous-assistant-reply",triggerMode:"auto"}}const r=t==null?void 0:t.codex,i=(r==null?void 0:r.model)??((a=n==null?void 0:n.find(l=>l.id==="codex"))==null?void 0:a.defaultModel)??Au("codex").defaultModel,s=(r==null?void 0:r.modelOptions)??{...xf};return{name:"",provider:e,model:i,modelOptions:{...s},systemPrompt:"",contextScope:"previous-assistant-reply",triggerMode:"auto"}}function LQe(e){return{name:e.name,description:e.description,provider:e.provider,model:e.model,modelOptions:e.modelOptions,systemPrompt:e.systemPrompt,contextScope:e.contextScope,triggerMode:e.triggerMode,workingDir:e.workingDir,allowedPaths:e.allowedPaths,maxTurns:e.maxTurns}}const $Qe=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};function FQe(e,t){return e.name!==t.name||(e.description??"")!==(t.description??"")||e.provider!==t.provider||e.model!==t.model||e.systemPrompt!==t.systemPrompt||e.contextScope!==t.contextScope||(e.triggerMode??"auto")!==(t.triggerMode??"auto")||(e.workingDir??"")!==(t.workingDir??"")||!$Qe(e.allowedPaths,t.allowedPaths)||(e.maxTurns??null)!==(t.maxTurns??null)?!0:!BQe(e.modelOptions,t.modelOptions)}function BQe(e,t){if(!Pr(e)||!Pr(t))return!1;const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!1;return!0}function zQe(e){return DQe.has(e.code)?{field:"name",message:e.message}:{field:"general",message:e.message}}function UQe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").slice(0,Jae)}function Zae({icon:e,message:t}){return c.jsxs("div",{className:"flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center",children:[c.jsx(e,{className:"mb-3 h-8 w-8 text-muted-foreground","aria-hidden":!0}),c.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}function t$({children:e}){return c.jsx("ul",{className:"flex flex-col divide-y rounded-md border",children:e})}function n$({label:e,onEdit:t,onDelete:n}){return c.jsxs(c.Fragment,{children:[c.jsx(Re,{variant:"ghost",size:"sm",onClick:t,"aria-label":`Edit ${e}`,children:c.jsx(Xp,{className:"h-4 w-4"})}),c.jsx(Re,{variant:"ghost",size:"sm",onClick:n,"aria-label":`Delete ${e}`,children:c.jsx(Wu,{className:"h-4 w-4"})})]})}const SK=new Set;function wK(e){var t;return{name:(e==null?void 0:e.name)??"",transport:(e==null?void 0:e.transport)??"stdio",command:(e==null?void 0:e.transport)==="stdio"?e.command:"",argsText:(e==null?void 0:e.transport)==="stdio"?e.args.join(`