@jean2/client 0.7.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/assets/ServerContext-D9RfmQC6.js +1 -0
  2. package/dist/assets/SessionContent-Jo9ZEids.js +8 -0
  3. package/dist/assets/SessionMenuButton-B9RQW_iM.css +1 -0
  4. package/dist/assets/SessionMenuButton-DsDEHbLS.js +9 -0
  5. package/dist/assets/ThemeProvider-JPllbGvS.js +1 -0
  6. package/dist/assets/_serverId-9odzanEM.js +1 -0
  7. package/dist/assets/_serverId-C6rV90xS.js +12 -0
  8. package/dist/assets/_serverId-DGlEu8Js.js +2 -0
  9. package/dist/assets/_sessionId-64IyNquX.js +1 -0
  10. package/dist/assets/_sessionId-Dr4YSGzN.js +1 -0
  11. package/dist/assets/alert-DI_4Lgs2.js +31 -0
  12. package/dist/assets/badge-Dpu7ORAu.js +45 -0
  13. package/dist/assets/confirmation-dialog-CdeOkc9q.js +1 -0
  14. package/dist/assets/core-CblztWA2.js +1 -0
  15. package/dist/assets/createLucideIcon-BaO6wACO.js +1 -0
  16. package/dist/assets/dropdown-menu-BJDf5ta_.js +1 -0
  17. package/dist/assets/event-qUXFERHS.js +1 -0
  18. package/dist/assets/index-CgtwzRvf.js +10 -0
  19. package/dist/assets/index-D36xySN9.css +2 -0
  20. package/dist/assets/jsx-runtime-D-oznMWL.js +1 -0
  21. package/dist/assets/overview-BhzPeIBE.js +1 -0
  22. package/dist/assets/overview-ZVTPIcDN.js +1 -0
  23. package/dist/assets/platform-Bn4qAxt4.js +1 -0
  24. package/dist/assets/popover-BTq6RtKc.js +1 -0
  25. package/dist/assets/preload-helper-CYlqXMwt.js +1 -0
  26. package/dist/assets/react-DcCgrBX5.js +1 -0
  27. package/dist/assets/routes-BbfnvJnQ.js +1 -0
  28. package/dist/assets/scroll-area-CdXB1yRx.js +1 -0
  29. package/dist/assets/server-BNi58bIU.js +1 -0
  30. package/dist/assets/servers-CGl9kUR2.js +1 -0
  31. package/dist/assets/src-BF-fktl3.js +1 -0
  32. package/dist/assets/triangle-alert-DxjucLze.js +1 -0
  33. package/dist/assets/useNavigate-5b_LZg00.js +1 -0
  34. package/dist/assets/useParams-BODsv_8k.js +1 -0
  35. package/dist/assets/useRouterState-FezJSBQO.js +1 -0
  36. package/dist/assets/workspace-6up_4yL-.js +1 -0
  37. package/dist/assets/workspace-B2-0-561.js +1 -0
  38. package/dist/index.html +13 -2
  39. package/package.json +1 -1
  40. package/dist/assets/index-BNhWCBsz.css +0 -32
  41. package/dist/assets/index-fvI9OPHD.js +0 -630
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./servers-CGl9kUR2.js";var f=e(n(),1);function p(e){return/^[a-f0-9]{64}$/.test(e)}function m(e){return e.length<12?e:`${e.slice(0,4)}...${e.slice(-4)}`}function h(e){let t=e.trim(),n=/^https:\/\//i.test(t),r=t.replace(/^(https?:\/\/|wss?:\/\/)/i,``);return r=r.replace(/\/+$/,``),n&&(r=`https://${r}`),r}var g=t(),_=(0,f.createContext)(null),v=({children:e})=>{let[t,n]=(0,f.useState)([]),[p,m]=(0,f.useState)([]),[v,y]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=a(),t=l();n(e),m(t),y(!0)},[]);let b={servers:t,quickConnections:p,isHydrated:v,addServer:(0,f.useCallback)((e,t,r)=>{let o=h(t),s={id:crypto.randomUUID(),name:e,url:o,token:r,createdAt:new Date().toISOString()};return i(s),n(a()),s},[]),editServer:(0,f.useCallback)((e,t)=>{o(e,{...t,...t.url&&{url:h(t.url)}}),n(a())},[]),removeServer:(0,f.useCallback)(e=>{s(e),n(a()),m(l())},[]),addToQuickConnections:(0,f.useCallback)((e,t,n,r)=>{d({serverId:e,serverName:t,workspaceId:n,workspaceName:r}),m(l())},[]),removeFromQuickConnections:(0,f.useCallback)(e=>{r(e),m(l())},[]),removeFromQuickConnectionsByWorkspace:(0,f.useCallback)(e=>{c(e),m(l())},[]),reorderQuick:(0,f.useCallback)(e=>{u(e),m(l())},[])};return(0,g.jsx)(_.Provider,{value:b,children:e})},y=()=>{let e=(0,f.useContext)(_);if(e===null)throw Error(`useServerContext must be used within a ServerProvider`);return e};export{h as a,m as i,y as n,p as r,v as t};
@@ -0,0 +1,8 @@
1
+ import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{i as r}from"./src-BF-fktl3.js";import{Q as i,X as a,Z as o,a as s,at as c,bt as l,c as u,ct as d,et as f,f as p,ft as m,gt as h,h as g,ht as _,i as v,lt as y,m as b,mt as x,n as S,nt as C,o as w,p as T,pt as E,r as D,rt as O,s as k,st as A,t as j,u as M,ut as N}from"./badge-Dpu7ORAu.js";import{t as P}from"./createLucideIcon-BaO6wACO.js";import{n as ee,t as F}from"./confirmation-dialog-CdeOkc9q.js";import{_ as I,a as L,c as R,d as z,f as te,g as ne,h as B,i as V,l as re,m as H,n as ie,o as ae,p as U,r as oe,s as se,t as ce,u as le}from"./alert-DI_4Lgs2.js";import{a as W,b as ue,c as G,f as de,i as K,l as q,n as fe,o as pe,r as J,s as me,t as Y,u as X,x as Z}from"./popover-BTq6RtKc.js";import{i as he,n as ge,r as _e,t as ve}from"./triangle-alert-DxjucLze.js";function ye(e){return e.role===`assistant`}var be=P(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xe=P(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Se=P(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=P(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),we=P(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=P(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ee=P(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),De=P(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Oe=P(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ke=P(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Ae=P(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),je=P(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Me=P(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Ne=P(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Pe=P(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Fe=P(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ie=P(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Le=P(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Re=P(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Q=t();function ze(){return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]})}function Be({message:e=`Connecting to server...`}){return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e})]})}var Ve=({serverUrl:e,authError:t,retryCount:n,nextRetryIn:r,onRetry:i,onLogout:a})=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[(0,Q.jsx)(Le,{className:`size-12 text-destructive mb-4`}),(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:t||`Please check that the server is running.`}),e&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:e}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,r,`s...`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(p,{onClick:i,variant:`default`,children:[(0,Q.jsx)(re,{className:`size-4 mr-2`,"data-icon":`inline-start`}),`Retry Now`]}),(0,Q.jsx)(p,{onClick:a,variant:`ghost`,children:`Change Server`})]}),n>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,n]})]})]}),$=e(n(),1);function He(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Ue(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function We({totalTokens:e=0,contextWindow:t=0,modelName:n,compact:r}){let[i,a]=(0,$.useState)(!1),o=e===0?0:t,s=o===0?0:Math.min(100,Math.round(e/o*100)),c=Ue(s),l=2*Math.PI*8,u=l*(1-s/100);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>a(!i),children:[(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:s===0?`text-muted-foreground/30`:c===`critical`?`text-destructive`:c===`warning`?`text-warning`:`text-primary`,strokeWidth:`3`,strokeDasharray:l,strokeDashoffset:u,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:{transition:`stroke-dashoffset 0.3s ease`}})]}),(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:i?`${He(e)}/${He(o)}`:`${s}%`})]})}function Ge(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Ke({models:e,selectedModelId:t,onChangeModel:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.reduce((e,t)=>(e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e),{}),l=t=>{let r=e.find(e=>e.id===t);r&&(n(t,r.providerId),s(!1))},u=e.find(e=>e.id===t);return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,disabled:r,children:(0,Q.jsx)(H,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(H,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(H,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(u==null?void 0:u.name)||`Select model`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]})}var qe={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function Je(e){return qe[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Ye({variants:e,selectedVariant:t,onChangeVariant:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1);if(!e||Object.keys(e).length===0)return null;let c=Object.keys(e),l=e=>{n(e===`__none__`?null:e),s(!1)},u=t?Je(t):`Default`,d=(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsxs)(q,{value:`__none__`,onSelect:()=>l(`__none__`),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:`Default`}),(0,Q.jsx)(_,{className:T(`size-4`,t===null?`opacity-100`:`opacity-0`)})]},`__none__`),c.map(e=>(0,Q.jsxs)(q,{value:e,onSelect:()=>l(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:Je(e)}),(0,Q.jsx)(_,{className:T(`size-4`,t===e?`opacity-100`:`opacity-0`)})]},e))]})]});return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:(0,Q.jsx)(Se,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:u}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]})}function Xe({preconfigs:e,selectedPreconfigId:t,onChangePreconfig:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.find(e=>e.id===t),l=e=>{n(e),s(!1)};return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:(0,Q.jsx)(R,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(c==null?void 0:c.name)||`Select config`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]})}function Ze({session:e,preconfigs:t,models:n,usage:r,modelName:i,onChangePreconfig:a,onChangeModel:o,onChangeVariant:c,onRename:l,onNavigateBack:d,isStreaming:f,onInterrupt:m,onCompact:h,isCompacting:_,canCompact:v,selectedVariant:y,variants:x}){var S;let[C,T]=(0,$.useState)(!1),[E,D]=(0,$.useState)(e.title||``),O=(0,$.useRef)(null),A=g(),N=b();(0,$.useEffect)(()=>{C&&O.current&&(O.current.focus(),O.current.select())},[C]);let P=()=>{D(e.title||``),T(!0)},F=()=>{let t=E.trim();t&&t!==e.title&&l(e.id,t),T(!1)},L=t=>{t.key===`Enter`?F():t.key===`Escape`&&(D(e.title||``),T(!1))},R=e.selectedModel||((S=t.find(t=>t.id===e.preconfigId))==null?void 0:S.model)||i,z=n.find(e=>e.id===R),te=z==null?void 0:z.contextWindow;return(0,Q.jsx)(`header`,{className:`flex flex-col border-b border-border bg-card`,children:(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center md:justify-between px-4 py-1 gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[e.parentId&&d&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:d,className:`h-7`,children:[(0,Q.jsx)(I,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),C?(0,Q.jsx)(`input`,{ref:O,type:`text`,value:E,onChange:e=>D(e.target.value),onBlur:F,onKeyDown:L,className:`text-base font-semibold bg-background border border-primary rounded px-2 py-0.5 outline-none min-w-0 flex-1`,autoFocus:!0}):(0,Q.jsx)(`h2`,{className:`text-base font-semibold cursor-pointer px-2 py-0.5 -mx-2 rounded hover:bg-accent transition-colors truncate min-w-0`,onDoubleClick:P,children:e.title||`Untitled Session`}),(0,Q.jsx)(We,{promptTokens:r.promptTokens,completionTokens:r.completionTokens,totalTokens:r.totalTokens,contextWindow:te,modelName:i,compact:A}),e.status===`closed`&&(0,Q.jsxs)(j,{variant:`secondary`,children:[(0,Q.jsx)(ee,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]})]}),(0,Q.jsx)(M,{className:`md:hidden`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[(0,Q.jsx)(Ke,{models:n,selectedModelId:R,onChangeModel:o,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Ye,{variants:x,selectedVariant:y,onChangeVariant:c,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Xe,{preconfigs:t,selectedPreconfigId:e.preconfigId,onChangePreconfig:a,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:h,disabled:f||_||!v,children:(0,Q.jsx)(Ne,{className:`size-4`})})}),(0,Q.jsx)(w,{children:_?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`})]}),(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:f?`destructive`:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent${f?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,onClick:m,disabled:!m,children:(0,Q.jsx)(ge,{className:`size-4`})})}),(0,Q.jsx)(w,{children:f?`Interrupt operation`:`Interrupt`})]})]})]})})})}function Qe({prompts:e,query:t,selectedIndex:n,onSelect:r}){let i=e.filter(e=>e.name.toLowerCase().includes(t.toLowerCase()));return i.length===0?(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,t,`"`]}):(0,Q.jsxs)(`div`,{className:`p-1`,children:[i.map((e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>r(e),className:T(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===n&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(Me,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs`,children:[`/`,e.name]}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]},e.name)),(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[i.length,` prompt`,i.length===1?``:`s`,` •`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),` navigate`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),` select`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),` close`]})]})}function $e({id:e,kind:t,filename:n,size:r,previewUrl:i,isUploading:a,onRemove:o}){return(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,a&&`opacity-50`),children:[t===`image`&&i?(0,Q.jsx)(`img`,{src:i,alt:n,className:`size-8 rounded object-cover shrink-0`}):t===`image`?(0,Q.jsx)(Ae,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(le,{className:`size-4 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:n}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:et(r)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function et(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function tt({content:e,mentions:t,textareaRef:n}){let r=(0,$.useRef)(null),i=(0,$.useMemo)(()=>{if(!e)return[];let n=new Set(t),r=/@([^\s@]+)/g,i=[],a=0,o;for(;(o=r.exec(e))!==null;){let t=o[1];n.has(t)&&(o.index>a&&i.push({type:`text`,value:e.slice(a,o.index)}),i.push({type:`mention`,value:o[0],path:t}),a=o.index+o[0].length)}return a<e.length&&i.push({type:`text`,value:e.slice(a)}),i},[e,t]);return(0,$.useEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;let i=()=>{t.style.height=`${e.offsetHeight}px`,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft};i(),e.addEventListener(`scroll`,i);let a=new ResizeObserver(i);return a.observe(e),()=>{e.removeEventListener(`scroll`,i),a.disconnect()}},[n]),(0,Q.jsx)(`div`,{ref:r,className:`mirror-textarea`,"aria-hidden":`true`,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,pointerEvents:`none`,zIndex:0,color:`var(--foreground)`,fontFamily:`inherit`,fontSize:`0.875rem`,lineHeight:`1.25rem`,letterSpacing:`normal`,padding:`0.5rem 0.625rem`,paddingRight:`3rem`,minHeight:`44px`,border:`1px solid transparent`,borderRadius:`0.5rem`,maxHeight:`150px`,overflow:`hidden`,whiteSpace:`pre-wrap`,wordWrap:`break-word`,wordBreak:`break-word`,boxSizing:`border-box`,backgroundColor:`transparent`},children:i.map((e,t)=>e.type===`mention`&&e.path?(0,Q.jsx)(`span`,{className:`mention-highlight`,"data-mention-path":e.path,children:e.value},t):(0,Q.jsx)(`span`,{children:e.value},t))})}function nt({path:e,onRemove:t,onPreview:n}){let r=e.split(`/`).pop()||e,i=e.slice(0,e.lastIndexOf(`/`)+1);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 bg-primary/15 rounded-lg border border-primary/30 max-w-[220px]`,children:[(0,Q.jsx)(le,{className:`size-4 text-primary shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n==null?void 0:n(e),className:`min-w-0 flex-1 text-left cursor-pointer`,children:(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,Q.jsx)(`span`,{children:r})]})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Remove ${r}`,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function rt({workspaceId:e,debounceMs:t=150}){let[n,r]=(0,$.useState)(``),[i,a]=(0,$.useState)(!1),[o,s]=(0,$.useState)([]);return{query:n,setQuery:r,showAutocomplete:i,setShowAutocomplete:a,mentions:o,handleFileSelect:(0,$.useCallback)(e=>{let t={type:`file`,path:e.path,display:e.name};return s(e=>[...e,t]),a(!1),r(``),t},[]),insertMention:(0,$.useCallback)((e,t,n)=>{let r=e.lastIndexOf(`@`,t);return r===-1?{text:e,cursorPos:t}:{text:e.slice(0,r)+`@${n.path}`+e.slice(t),cursorPos:r+n.path.length+1}},[]),extractMentions:(0,$.useCallback)(e=>{let t=/@([^\s@]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1];o.some(t=>t.path===e)&&!n.some(t=>t.path===e)&&n.push({type:`file`,path:e,display:e.split(`/`).pop()||e})}return n},[o]),clearMentions:(0,$.useCallback)(()=>s([]),[]),removeMention:(0,$.useCallback)(e=>{s(t=>t.filter(t=>t.path!==e))},[])}}function it(e){return`${h}${e}`}function at(e,t){if(!(typeof window>`u`))try{localStorage.setItem(it(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function ot(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(it(e));if(t===null)return``;let n=JSON.parse(t);return typeof n.text!=`string`||typeof n.updatedAt!=`number`||Date.now()-n.updatedAt>2592e6?(localStorage.removeItem(it(e)),``):n.text}catch{return``}}function st(e){if(!(typeof window>`u`))try{localStorage.removeItem(it(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function ct(){l()}function lt(e){let[t,n]=(0,$.useState)(``),r=(0,$.useRef)(void 0),i=(0,$.useRef)(``);(0,$.useEffect)(()=>{ct()},[]);let a=(0,$.useCallback)(t=>{n(t),i.current=t,e!==void 0&&(t===``?st(e):at(e,t))},[e]),o=(0,$.useCallback)(()=>{n(``),i.current=``,e!==void 0&&st(e)},[e]);return(0,$.useEffect)(()=>{let t=r.current;if(t!==void 0&&t!==e){let e=i.current;e!==``&&at(t,e)}if(e!==void 0){let t=ot(e);i.current=t,n(t)}else i.current=``,n(``);r.current=e},[e]),{input:t,setInput:a,clearInput:o}}function ut(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function dt(e){let t=e.trimStart();if(!t.startsWith(`/`))return null;let n=t.indexOf(` `);return n===-1?{command:t.slice(1),rest:``}:{command:t.slice(1,n),rest:t.slice(n+1).trim()}}var ft=(0,$.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:s,prompts:c=[],sessionId:l,modelSupportsImage:u},d){let{input:f,setInput:m,clearInput:h}=lt(l),[g,_]=(0,$.useState)(0),[v,y]=(0,$.useState)([]),[b,x]=(0,$.useState)(0),[S,C]=(0,$.useState)(`none`),[w,E]=(0,$.useState)(``),[D,k]=(0,$.useState)([]),[A,j]=(0,$.useState)(!1),M=(0,$.useRef)(null),N=(0,$.useRef)(null);(0,$.useImperativeHandle)(d,()=>({focus:()=>{var e;return(e=M.current)==null?void 0:e.focus()}}),[]);let{query:P,setQuery:ee,showAutocomplete:F,setShowAutocomplete:I,mentions:L,handleFileSelect:R,insertMention:z,clearMentions:te,removeMention:ne}=rt({workspaceId:a||``}),B=o(e=>e.openFilePreview),V=O(e=>e.activeWorkspace),re=(0,$.useMemo)(()=>L.map(e=>e.path),[L]);(0,$.useEffect)(()=>{if(L.length===0)return;let e=new Set(L.map(e=>e.path)),t=/@([^\s@]+)/g,n,r=new Set;for(;(n=t.exec(f))!==null;)e.has(n[1])&&r.add(n[1]);for(let e of L)r.has(e.path)||ne(e.path)},[f,L,ne]),(0,$.useEffect)(()=>{x(0)},[v,w,c]),(0,$.useEffect)(()=>{let e=M.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[f]);let H=c.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())),ie=S===`prompts`&&c.length>0,U=S===`files`&&F&&!!a,oe=(0,$.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;m(t),_(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
2
+ `,i=t.slice(r+1,n);if((e===`
3
+ `||e===` `||e===``)&&!i.includes(` `)){E(i),C(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){ee(e),I(!0),C(`files`);return}}C(`none`),I(!1)},[ee,I,m]),se=(0,$.useCallback)(e=>{let t=z(f,g,R(e));m(t.text),C(`none`),I(!1),y([]),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[f,g,R,z,I,m]),ce=(0,$.useCallback)(e=>{let t=f.lastIndexOf(`/`,g),n=f.slice(0,t),r=f.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;m(o),C(`none`),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(s,s))},0)},[f,g,m]),le=(0,$.useCallback)(()=>{for(let e of D)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);k([]),h(),te()},[D,h,te]),W=(0,$.useCallback)(async e=>{if(!s||!l)return null;try{let t=await(s==null?void 0:s.http.attachments.upload(l,e));return{id:crypto.randomUUID(),kind:t.kind,filename:t.filename,size:t.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploadedId:t.id,uploadedKind:t.kind}}catch(e){return console.error(`Upload error:`,e),null}},[s,l]),ue=(0,$.useCallback)(e=>{k(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),G=(0,$.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);m(f.replace(n,``).replace(/\s+/g,` `).trim()),ne(e)},[f,m,ne]),K=(0,$.useCallback)(e=>{V!=null&&V.id&&B({workspaceId:V.id,path:e,name:e.split(`/`).pop()||e})},[V==null?void 0:V.id,B]),q=(0,$.useCallback)(async e=>{let t=Array.from(e);for(let e of t){if(e.size>20*1024*1024)continue;let t=e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`,n={id:crypto.randomUUID(),kind:t,filename:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,isUploading:!0};k(e=>[...e,n]);let r=await W(e);k(r?e=>e.map(e=>e.id===n.id?(e.previewUrl&&e.previewUrl!==r.previewUrl&&URL.revokeObjectURL(e.previewUrl),{...r,isUploading:!1}):e):e=>e.filter(e=>e.id!==n.id))}},[W]),pe=(0,$.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),q(n))},[q]),me=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!0)},[]),X=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),Z=(0,$.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),j(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&q(n)},[q]),he=async n=>{n==null||n.preventDefault();let r=f.trim();if(!r&&D.length===0||t)return;let i=dt(f);if(i){let t=c.find(e=>e.name===i.command);if(t){let n=ut(t,i.rest),r=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),le();return}}let a=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),le()},_e=e=>{if(!e.nativeEvent.isComposing){if(ie&&H.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,H.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),H[b]&&ce(H[b]);return;case`Tab`:e.preventDefault(),H[b]&&ce(H[b]);return;case`Escape`:e.preventDefault(),C(`none`);return}if(U&&v.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,v.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:e.preventDefault(),v[b]&&se(v[b]);return;case`Escape`:e.preventDefault(),I(!1),C(`none`);return;case`Tab`:e.preventDefault(),v[b]&&se(v[b]);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())}},ye=(0,$.useCallback)(e=>{y(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-card`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`animate-pulse flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.1s]`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.2s]`}),(0,Q.jsx)(`span`,{className:`text-sm ml-2`,children:`Generating...`})]}),(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(ge,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let be=f.trim(),xe=D.some(e=>e.isUploading),Se=!(be||D.length>0)||t||xe;return(0,Q.jsxs)(`form`,{onSubmit:he,onDragOver:me,onDragLeave:X,onDrop:Z,className:T(`p-4 border-t border-border bg-card`,A&&`ring-2 ring-primary`),children:[(D.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:D.map(e=>(0,Q.jsx)($e,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:ue},e.id))}),D.length>0&&u===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(ve,{className:`size-3 shrink-0`}),(0,Q.jsx)(`span`,{children:`This model will not inspect images directly. They will be sent as file paths instead.`})]}),L.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:L.map(e=>(0,Q.jsx)(nt,{path:e.path,onRemove:G,onPreview:K},e.path))}),(0,Q.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,Q.jsx)(tt,{content:f,mentions:re,textareaRef:M}),(0,Q.jsxs)(Y,{open:ie||U,onOpenChange:e=>{e||(C(`none`),I(!1))},children:[(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(de,{ref:M,value:f,onChange:oe,onKeyDown:_e,onPaste:pe,placeholder:i,disabled:t,className:T(`min-h-[44px] max-h-[150px] resize-none pr-12 chat-input-scrollbar`,`focus-visible:ring-1`,`relative z-[1] text-transparent caret-foreground placeholder:text-muted-foreground`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(J,{className:`w-72 p-0`,align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:U?(0,Q.jsx)(ae,{workspaceId:a||``,searchQuery:P,selectedIndex:b,onSelect:se,onFilesChange:ye,sdkClient:s}):(0,Q.jsx)(Qe,{prompts:c,query:w,selectedIndex:b,onSelect:ce})})]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-11 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>{var e;return(e=N.current)==null?void 0:e.click()},disabled:t,children:(0,Q.jsx)(Pe,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:N,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&q(e.target.files),e.target.value=``}}),(0,Q.jsx)(p,{type:`submit`,disabled:Se,size:`default`,className:`h-11`,children:(0,Q.jsx)(Fe,{className:`size-4`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground text-center hidden sm:flex items-center justify-center gap-1`,children:[(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`/`}),(0,Q.jsx)(`span`,{children:`prompts`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`@`}),(0,Q.jsx)(`span`,{children:`files`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Enter`}),(0,Q.jsx)(`span`,{children:`to send`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Shift + Enter`}),(0,Q.jsx)(`span`,{children:`for new line`})]})]})});function pt(e){return e.startsWith(`https://`)?`https`:`http`}function mt(e,t){return`${pt(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function ht(e){let t=(0,$.useRef)(e);return(0,$.useLayoutEffect)(()=>{t.current=e}),(0,$.useCallback)((...e)=>t.current(...e),[])}var gt=e(r(),1);function _t(e,t,n){var r;let i=(r=n.initialDeps)==null?[]:r,a,o=!0;function s(){var r,s,c;let l;n.key&&(r=n.debug)!=null&&r.call(n)&&(l=Date.now());let u=e();if(!(u.length!==i.length||u.some((e,t)=>i[t]!==e)))return a;i=u;let d;if(n.key&&(s=n.debug)!=null&&s.call(n)&&(d=Date.now()),a=t(...u),n.key&&(c=n.debug)!=null&&c.call(n)){let e=Math.round((Date.now()-l)*100)/100,t=Math.round((Date.now()-d)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
4
+ font-size: .6rem;
5
+ font-weight: bold;
6
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return s.updateDeps=e=>{i=e},s}function vt(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var yt=(e,t)=>Math.abs(e-t)<1.01,bt=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},xt=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},St=e=>e,Ct=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},wt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(xt(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e!=null&&e.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(xt(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Tt={passive:!0},Et=typeof window>`u`?!0:`onscrollend`in window,Dt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Et?()=>void 0:bt(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Tt);let l=e.options.useScrollendEvent&&Et;return l&&n.addEventListener(`scrollend`,c,Tt),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Ot=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},kt=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},At=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e,t,n,r;return(e=(r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))==null?Date.now():e},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>{var n;return(n=t())==null?void 0:n.observe(e,{box:`border-box`})},unobserve:e=>{var n;return(n=t())==null?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:St,rangeExtractor:Ct,onChange:()=>{},measureElement:Ot,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=_t(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&`ownerDocument`in this.scrollElement)this.targetWindow=this.scrollElement.ownerDocument.defaultView;else{var n;this.targetWindow=(n=(e=this.scrollElement)==null?void 0:e.window)==null?null:n}this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>{var e;return this.options.enabled?(this.scrollRect=(e=this.scrollRect)==null?this.options.initialRect:e,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0)},this.getScrollOffset=()=>{var e;return this.options.enabled?(this.scrollOffset=(e=this.scrollOffset)==null?typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset:e,this.scrollOffset):(this.scrollOffset=null,0)},this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=_t(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=_t(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_t(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Mt({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_t(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t,n;if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let r=(t=this.scrollState.index)==null?(n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index:t;if(r!==void 0&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,r-t),i=Math.min(this.options.count-1,r+t);return e>=n&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n,r;let i=this.measurementsCache[e];if(!i)return;let a=t-((n=this.itemSizeCache.get(i.key))==null?i.size:n);a!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?i.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(i,a,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,t)),this.notify(!1))},this.getVirtualItems=_t(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return vt(t[jt(0,t.length-1,e=>vt(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){var r;n=(r=(e=t[t.length-1])==null?void 0:e.end)==null?0:r}else{let e=Array(this.options.lanes).fill(null),r=t.length-1;for(;r>=0&&e.some(e=>e===null);){let n=t[r];e[n.lane]===null&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>e!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&yt(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},jt=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Mt({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=jt(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Nt=typeof document<`u`?$.useLayoutEffect:$.useEffect;function Pt({useFlushSync:e=!0,...t}){let n=$.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,gt.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=$.useState(()=>new At(r));return i.setOptions(r),Nt(()=>i._didMount(),[]),Nt(()=>i._willUpdate()),i}function Ft(e){return Pt({observeElementRect:wt,observeElementOffset:Dt,scrollToFn:kt,...e})}function It({message:e,textContent:t,children:n,isQueued:r=!1,onRemove:i,onRevert:a,canRevert:o=!1,onFork:s,canFork:c=!1,isClearAll:l=!1}){let[u,d]=(0,$.useState)(!1),[f,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(!1),v=e.role===`user`,y=async()=>{let e=t||``;await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3)};return(0,Q.jsxs)(`div`,{className:T(`flex flex-col gap-1 animate-slide-up min-w-0`,v?`items-end`:`items-start`),children:[(0,Q.jsx)(`div`,{className:T(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,v?`mr-3`:`ml-3`),children:v?(0,Q.jsxs)(Q.Fragment,{children:[!r&&(0,Q.jsxs)(Q.Fragment,{children:[o&&a&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>m(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(Ie,{className:`size-3`})}),c&&s&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>g(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(ke,{className:`size-3`})}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(B,{className:`size-3`})})]}),(0,Q.jsx)(se,{className:`size-3`}),e.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xe,{className:`size-3`}),e.role,(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(B,{className:`size-3`})})]})}),(0,Q.jsxs)(`div`,{className:T(`rounded-2xl px-4 py-3 relative group min-w-0 overflow-hidden`,v?`max-w-[90%]`:`max-w-full`,r?`bg-muted border-2 border-dashed border-muted-foreground/30 opacity-80`:v?`bg-primary text-primary-foreground rounded-br-md`:`bg-card text-card-foreground border border-border rounded-bl-md`),children:[r&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2 pb-2 border-b border-muted-foreground/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),i&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:i,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(A,{className:`size-3`})})]}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:n})]}),(0,Q.jsx)(F,{open:f,onOpenChange:m,title:l?`Clear Conversation`:`Revert Conversation`,description:l?`This will delete all messages in this session, leaving it completely empty. Are you sure you want to continue?`:`This will delete this message and all messages after it. Are you sure you want to continue?`,confirmLabel:l?`Clear All`:`Revert`,cancelLabel:`Cancel`,onConfirm:()=>{a==null||a()},variant:`destructive`}),(0,Q.jsx)(F,{open:h,onOpenChange:g,title:`Fork Conversation`,description:`This will create a new session with messages up to and including this point. The original session will be unchanged.`,confirmLabel:`Fork`,cancelLabel:`Cancel`,onConfirm:()=>{s==null||s()}})]})}var Lt=L.oneDark;function Rt(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var zt=(0,$.memo)(function({type:e,content:t,lineNumber:n,newLineNumber:r,language:i}){let a=T(`flex font-mono text-xs`,e===`added`&&`bg-green-500/20`,e===`removed`&&`bg-red-500/20`,e===`context`&&`bg-muted/30`),o=T(`font-bold w-4 select-none`,e===`added`&&`text-green-400`,e===`removed`&&`text-red-400`,e===`context`&&`text-muted-foreground/50`);return(0,Q.jsxs)(`div`,{className:a,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n==null?``:n}),(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:r==null?``:r}),(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre flex`,children:[(0,Q.jsxs)(`span`,{className:o,children:[e===`added`&&`+`,e===`removed`&&`-`,e===`context`&&` `]}),(0,Q.jsx)(V,{theme:Lt,code:t,language:i,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))},n))})})]})]})}),Bt=(0,$.memo)(function({hunks:e,path:t,language:n,additions:r,deletions:i}){let[a,s]=(0,$.useState)(!0),c=n||Rt(t),l=o(e=>e.openFilePreview),u=O(e=>e.activeWorkspace);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`px-1 py-1 hover:bg-muted rounded`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{u&&l({workspaceId:u.id,path:t,name:t.split(`/`).pop()||t})},className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(U,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),r!==void 0&&i!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,r,` -`,i]})]}),a&&(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:e.map((e,t)=>(0,Q.jsx)(`div`,{className:`divide-y divide-white/5`,children:e.changes.map((e,t)=>(0,Q.jsx)(zt,{...e,language:c},t))},t))})]})})}),Vt=L.oneDark,Ht=20;function Ut(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Wt=(0,$.memo)(({content:e,path:t,language:n,created:r,highlightLines:i=[]})=>{let[a,s]=(0,$.useState)(!1),c=o(e=>e.openFilePreview),l=O(e=>e.activeWorkspace),u=()=>{l&&c({workspaceId:l.id,path:t,name:t.split(`/`).pop()||t})},d=n||Ut(t),f=(0,$.useMemo)(()=>new Set(i),[i]),p=(0,$.useMemo)(()=>e.split(`
7
+ `).length,[e]);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(U,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),!a&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[p,` lines`]}),r===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(ne,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(_,{className:`size-3`}),`Created`]})]}),(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:(0,Q.jsx)(V,{theme:Vt,code:e,language:d,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:(a?e:e.slice(0,Ht)).map((e,n)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${f.has(n+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre`,children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))})]},n))})})})]})})});function Gt({message:e=`Success`}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`break-all`,children:e})]})}var Kt={edit:Oe,plus:y,trash:d,search:ue};function qt({text:e}){let[t,n]=(0,$.useState)(!1);return(0,Q.jsx)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:t?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(B,{className:`size-3`})})}function Jt({title:e,groups:t,files:n,total:r}){let i=t||(n?[{label:`Files`,files:n||[],icon:void 0}]:[]);return i.length===0?null:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e,r!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r,` files)`]})]}),i.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`flex items-center`,children:(()=>{let t=Kt[e.icon];return(0,Q.jsx)(t,{className:`size-3`})})()}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[`(`,e.files.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 pl-5`,children:e.files.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(z,{className:`size-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80 truncate`,children:e.path}),e.line!==void 0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`:`,e.line]}),e.action&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1 rounded shrink-0`,e.action===`created`&&`bg-success/20 text-success`,e.action===`modified`&&`bg-warning/20 text-warning`,e.action===`deleted`&&`bg-destructive/20 text-destructive`),children:e.action}),(0,Q.jsx)(qt,{text:e.path})]},t))})]},t))]})}function Yt({command:e,stdout:t,stderr:n,exitCode:r}){return(0,Q.jsxs)(`div`,{className:`visualization-container border border-white/10 rounded-md overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded ${r===0?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,children:[`[`,r,`]`]})]}),(t||n)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[t&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:t}),n&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:n})]})]})}var Xt={pending:{icon:Te,color:`text-muted-foreground`},in_progress:{icon:N,color:`text-warning`,animate:!0},completed:{icon:E,color:`text-success`},cancelled:{icon:m,color:`text-destructive`}},Zt={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function Qt({title:e,items:t}){if(t.length===0)return null;let n=t.filter(e=>e.status===`completed`).length;return t.filter(e=>e.status===`in_progress`).length,t.filter(e=>e.status===`pending`).length,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[(e||t.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,t.length,`)`]}),n>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[n,` completed`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:t.map((e,t)=>{let n=Xt[e.status],r=n.icon,i=Zt[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:T(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:T(`flex-1 break-all`,e.status===`completed`&&`line-through text-muted-foreground`,e.status===`cancelled`&&`text-muted-foreground`),children:e.content}),i.label&&e.priority===`high`&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1.5 py-0.5 rounded shrink-0`,i.className),children:i.label}),e.priority===`low`&&e.status!==`completed`&&e.status!==`cancelled`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:i.label})]},t)})})]})}var $t=(0,$.memo)(function({visualization:e}){if(!e)return null;switch(e.type){case`diff`:return(0,Q.jsx)(Bt,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo});case`diffs`:return(0,Q.jsx)(`div`,{className:`space-y-3`,children:e.items.map((e,t)=>(0,Q.jsx)(Bt,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`))});case`code`:return(0,Q.jsx)(Wt,{path:e.path,content:e.content,language:e.language,created:e.created,highlightLines:e.highlightLines});case`file-list`:return(0,Q.jsx)(Jt,{title:e.title,groups:e.groups,files:e.files,total:e.total});case`table`:return(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(e.rows,null,2)});case`markdown`:return(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:e.content});case`none`:return(0,Q.jsx)(Gt,{message:e.message});case`shell-output`:return(0,Q.jsx)(Yt,{command:e.command,stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode});case`todo-list`:return(0,Q.jsx)(Qt,{title:e.title,items:e.items});default:return null}}),en=1536,tn=(0,$.memo)(function({content:e,className:t}){let[n,r]=(0,$.useState)(!1),i=new Blob([e]).size,a=i>en,o=a?e.slice(0,en)+`
8
+ ...`:null;if(!a)return(0,Q.jsx)(`pre`,{className:t,children:e});let s=i>1024*1024?`${(i/(1024*1024)).toFixed(1)} MB`:i>1024?`${(i/1024).toFixed(1)} KB`:`${i} bytes`;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`pre`,{className:t,children:n?e:o}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show full output (${s})`})]})});function nn(e){switch(e){case`pending`:return(0,Q.jsx)(Ee,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(N,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(E,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(m,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(he,{className:`size-3 text-warning`});default:return null}}function rn(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}var an=(0,$.memo)(function({part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r}){var i;let[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(!1),l=e.state,u=l.status,d=(0,$.useMemo)(()=>{if(!a)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,a]),f=(0,$.useMemo)(()=>!a||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,a]),m=u===`completed`&&`output`in l?rn(l.output):void 0,h=u===`pending`?t.find(t=>t.toolCallId===e.callId):void 0,g=h?typeof((i=h.args)==null?void 0:i.command)==`string`?h.args.command:JSON.stringify(h.args,null,2):null,y=null;if(e.name===`task`){if(`childSessionId`in l&&l.childSessionId)y=l.childSessionId;else if(u===`completed`&&`output`in l){let e=(typeof l.output==`string`?l.output:``).match(/task_id:\s*([a-f0-9-]{36})/i);e&&(y=e[1])}}let b=async()=>{if(`output`in l){let e=typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2);await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}},C=(()=>{try{let e=JSON.stringify(l.input);return e.length>50?e.slice(0,47)+`...`:e}catch{return String(l.input)}})();return(0,Q.jsxs)(`div`,{className:`my-1`,children:[(0,Q.jsxs)(S,{open:a,onOpenChange:o,children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 cursor-pointer hover:text-foreground transition-colors text-muted-foreground`,children:[a?(0,Q.jsx)(Ce,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(x,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Re,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!a&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 sm:max-w-[200px] hidden sm:block`,children:C}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[nn(u),y&&r&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(y)},title:`View session`,children:[(0,Q.jsx)(U,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})]})}),a&&(0,Q.jsx)(D,{children:(0,Q.jsxs)(`div`,{className:`pl-5 pb-2 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Input`}),(0,Q.jsx)(tn,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`)&&y&&r&&(0,Q.jsxs)(p,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(y),children:[(0,Q.jsx)(U,{className:`size-4`,"data-icon":`inline-start`}),u===`running`?`Watch Subagent`:`View Session`]}),u===`completed`&&f!==null&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Output`}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:b,className:`size-6`,children:s?(0,Q.jsx)(_,{className:`size-3 text-success`}):(0,Q.jsx)(B,{className:`size-3`})})]}),(0,Q.jsx)(tn,{content:f,className:`text-xs bg-success/10 border border-success/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),u===`error`&&`error`in l&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Error`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-destructive/10 border border-destructive/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words text-destructive`,children:l.error})]})]})})]}),u===`pending`&&h&&(0,Q.jsxs)(`div`,{className:`border border-warning/50 bg-warning/10 rounded-md p-3 flex flex-col gap-3 mt-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ve,{className:`size-4 text-warning`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Permission Required`})]}),h.message&&(0,Q.jsx)(`p`,{className:`text-sm`,children:h.message}),h.dangerous&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive font-medium`,children:[(0,Q.jsx)(ve,{className:`size-4`}),`This operation is marked as dangerous`]}),g&&(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words overflow-wrap-break`,children:g})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>n(e.callId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>n(e.callId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>n(e.callId,!0,!0),children:`Always Allow`})]})]}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)($t,{visualization:m})})]})},(e,t)=>e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent?!1:e.part.state.status===`pending`?e.pendingPermissions.find(t=>t.toolCallId===e.part.callId)===t.pendingPermissions.find(e=>e.toolCallId===t.part.callId):!0),on=60,sn=300,cn=16;function ln(e){if(e.length===0)return!1;let t=e[e.length-1];return ye(t.message)&&t.message.status===`streaming`}function un(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function dn(e,t){let n=t.findIndex(t=>t.message.id===e);if(n<0)return null;if(n===0)return e;for(let e=n-1;e>=0;e--){let n=t[e];if(n.message.role===`assistant`&&n.message.status!==`streaming`)return n.message.id}return null}function fn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground bg-muted rounded-lg px-3 py-2 border border-border shadow-sm`,children:[(0,Q.jsx)(Ne,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]})}function pn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-green-700 dark:text-green-400 bg-green-500/15 rounded-lg px-3 py-2 border border-green-500/30 shadow-sm`,children:[(0,Q.jsx)(we,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]})}function mn({message:e,textContent:t,onRetry:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(ve,{className:`size-3`}),`Compaction Failed`]}),(0,Q.jsxs)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:t||e.error||`Compaction failed. The conversation could not be summarized.`}),n&&(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:n,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(_e,{className:`size-3`}),`Retry`]})]})]})}function hn(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function gn({part:e}){let[t,n]=(0,$.useState)(!1),r=e.overflow?`overflow`:e.auto?`auto`:`manual`;return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[(0,Q.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[t?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[r===`overflow`?`Context overflow`:r===`auto`?`Auto`:`Manual`,` compaction`]})]}),t&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`})]})}var _n=(0,$.memo)(function({parts:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r,inverted:i=!1,serverUrl:a}){return(0,Q.jsx)(Q.Fragment,{children:[...e].sort((e,t)=>e.createdAt-t.createdAt).map(e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(oe,{inverted:i,children:e.text||`...`})},e.id);case`reasoning`:return(0,Q.jsx)(`div`,{className:`visualization-container text-muted-foreground text-sm italic border-l-2 border-muted-foreground/30 pl-3 my-2 wrap-break-word`,children:e.text},e.id);case`tool`:return(0,Q.jsx)(an,{part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r},e.id);case`image`:return(0,Q.jsx)(`img`,{src:a?mt(a,e.url):e.url,alt:``,className:T(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,i&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=a?mt(a,e.url):e.url,n=hn(e.mimeType,e.filename),r=e.filename||``,o=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:T(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,i?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(le,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:o}),n&&(0,Q.jsx)(`span`,{className:T(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,i?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(De,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}})})},(e,t)=>{if(e.parts!==t.parts||e.inverted!==t.inverted||e.onPermissionResponse!==t.onPermissionResponse||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl)return!1;if(!e.parts.some(e=>e.type===`tool`&&e.state.status===`pending`))return!0;let n=new Set(e.parts.filter(e=>e.type===`tool`).map(e=>e.callId)),r=e.pendingPermissions.filter(e=>n.has(e.toolCallId)),i=t.pendingPermissions.filter(e=>n.has(e.toolCallId));if(r.length!==i.length)return!1;for(let e=0;e<r.length;e++)if(r[e].toolCallId!==i[e].toolCallId)return!1;return!0}),vn=(0,$.memo)(function({item:e,messagesWithParts:t,sessionId:n,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,onRemoveFromQueue:o,onRevert:s,onFork:c,isMainActiveSession:l=!1,isCompacting:u=!1,onCompact:d,serverUrl:f}){let p=e.parts.find(e=>e.type===`compaction`);if(ye(e.message)&&e.message.mode===`compact_failed`)return(0,Q.jsx)(mn,{message:e.message,textContent:un(e.parts),onRetry:l&&!u?d:void 0});if(p)return(0,Q.jsx)(gn,{part:p});let m=!e.isQueued&&e.message.role===`user`,h=m?dn(e.message.id,t):null,g=h===e.message.id;return(0,Q.jsx)(It,{message:e.message,textContent:un(e.parts),isQueued:e.isQueued,onRemove:e.isQueued?()=>o(e.queueId):void 0,canRevert:m&&h!==null,onRevert:h?()=>s==null?void 0:s(n,h):void 0,canFork:m&&h!==null,onFork:h?()=>c==null?void 0:c(n,e.message.id):void 0,isClearAll:g,children:e.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(_n,{parts:e.parts,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,inverted:e.message.role===`user`,serverUrl:f})})});function yn({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingPermissions:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){var y,b;let x=(0,$.useRef)(null),[S,C]=(0,$.useState)(!1),w=(0,$.useRef)(h),T=(0,$.useRef)(e.length),E=(0,$.useRef)(0),D=(0,$.useRef)(!1),O=(0,$.useRef)(!1),k=(0,$.useRef)(``),A=(0,$.useCallback)(e=>{if(e.length===0)return``;let t=e[e.length-1],n=t.parts.filter(e=>e.type===`text`).reduce((e,t)=>e+t.text.length,0);return`${t.message.id}:${ye(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,$.useRef)(null),M=(0,$.useRef)(null),N=(0,$.useRef)(new Map),P=(0,$.useRef)(e);P.current=e;let ee=(0,$.useCallback)(e=>{let t=P.current[e];if(!t)return on+cn;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>{var t,n;return e.type===`text`&&((t=e.text)==null?void 0:t.includes("```"))||e.type===`tool`&&((n=e.state.input)==null?void 0:n.command)})&&(e=180),t.parts.some(e=>e.type===`tool`)&&(e=Math.max(e,150)),t.parts.some(e=>e.type===`compaction`)&&(e=60),t.message.mode===`compact_failed`&&(e=100),Math.min(Math.max(e+cn,on+cn),sn+cn)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+cn,on+cn),sn+cn)},[]);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=requestAnimationFrame(()=>{e.querySelectorAll(`[data-index]`).forEach(e=>{let t=e.getAttribute(`data-index`);if(t===null)return;let n=parseInt(t,10);N.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let F=(0,$.useRef)(null);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;F.current&&F.current.disconnect();let t=new ResizeObserver(e=>{e.forEach(e=>{let t=e.target,n=t.getAttribute(`data-index`);if(n===null)return;let r=parseInt(n,10),i=t.offsetHeight;N.current.set(r,i)})});return F.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let I=Ft({count:e.length,getScrollElement:()=>x.current,estimateSize:ee,overscan:5,getItemKey:t=>{var n,r;let i=e[t];return(n=i==null||(r=i.message)==null?void 0:r.id)==null?`fallback-${t}`:n}});(0,$.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(I.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,$.useEffect)(()=>{let e=x.current;if(!e)return;let t=e=>{w.current&&e.deltaY<0&&(w.current=!1,g==null||g(!1))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[g]);let L=ht(()=>{if(O.current)return;let e=x.current;if(e)if(w.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(O.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{O.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(w.current=!0,g==null||g(!0))}});(0,$.useLayoutEffect)(()=>{C(a)},[a]);let R=A(e);(0,$.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=R,a=i!==k.current;k.current=i;let o=t-1,s=0;if(o>=0){var c;s=(c=N.current.get(o))==null?0:c}let l=E.current,u=o>=0&&s>l&&l>0;if(T.current=t,E.current=s,!(t===0||!r&&!a&&!u)){if(n===0&&t>0&&l===0&&!D.current){I.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,R,I]),(0,$.useEffect)(()=>{var t;let n=I.getVirtualItems(),r=n.length-1;if(r<0)return;let i=n[r],a=(t=x.current)==null?void 0:t.querySelector(`[data-index="${i.index}"]`);if(j.current&&j.current.disconnect(),a&&(M.current=a,!(!ln(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&ln(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,I]),(0,$.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,$.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,$.useLayoutEffect)(()=>{w.current=h},[h]);let z=I.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:x,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:L,children:[S&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(fn,{})}),o&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(pn,{})}),r===`closed`&&(0,Q.jsx)(ce,{className:`mx-4 mt-4`,children:(0,Q.jsx)(ie,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${I.getTotalSize()}px`},children:e.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground px-4`,children:[(0,Q.jsx)(`p`,{className:`text-lg mb-2`,children:`Start a conversation`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Send a message below to begin.`})]}):(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full`,style:{transform:`translateY(${(y=(b=z[0])==null?void 0:b.start)==null?0:y}px)`},children:z.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:I.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(vn,{item:o,messagesWithParts:t,sessionId:n,pendingPermissions:i,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function bn(e,t,n){let r=e.map(e=>({message:e.message,parts:e.parts,isQueued:!1})),i=t.map(e=>{let t=(e.attachments||[]).map(t=>{var r;let i=n(e.sessionId,t.id,(r=t.accessKey)==null?``:r);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:i,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:i,mimeType:t.mimeType||``,filename:t.filename}});return{message:{id:e.id,role:`user`,sessionId:e.sessionId,createdAt:e.createdAt},parts:[...t,...e.content.trim()?[{id:`${e.id}-part`,messageId:e.id,createdAt:e.createdAt,type:`text`,text:e.content}]:[]],isQueued:!0,queueId:e.id}}),a=[...r].sort((e,t)=>e.message.createdAt-t.message.createdAt),o=[...i].sort((e,t)=>e.message.createdAt-t.message.createdAt);return[...a,...o]}function xn({permissions:e,onPermissionResponse:t}){return e.length===0?null:(0,Q.jsxs)(`div`,{className:`border-t border-border bg-muted/30 flex flex-col gap-2 p-4`,style:{overflow:`overlay`},children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground uppercase tracking-wide font-medium`,children:`Pending Requests`}),e.map(e=>{var n;let r=typeof((n=e.args)==null?void 0:n.command)==`string`?e.args.command:JSON.stringify(e.args,null,2);return(0,Q.jsxs)(`div`,{className:`p-3 bg-warning/10 border border-warning/30 rounded-lg flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:e.toolName})}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e.message}),(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words`,children:r})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>t(e.toolCallId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>t(e.toolCallId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>t(e.toolCallId,!0,!0),children:`Always Allow`})]})]},e.toolCallId)})]})}function Sn({session:e,messagesWithParts:t,queuedMessages:n,preconfigs:r,prompts:i,models:a,defaultModel:o,onSendMessage:s,onRemoveFromQueue:c,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,pendingPermissions:f,onPermissionResponse:p,onRename:m,usage:h,modelName:g,modelSupportsImage:_,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:b,onInterrupt:x,onRevert:S,onFork:C,onCompact:w,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,serverUrl:O,sdkClient:k,selectedVariant:A,variants:j,inputRef:M,scrollToBottomRef:N,autoFollowToggleRef:P}){let ee=!e.parentId&&e.status===`active`,[F,I]=(0,$.useState)(!0),L=(0,$.useCallback)(()=>{I(e=>{let t=!e;if(t){var n;N==null||(n=N.current)==null||n.call(N)}return t})},[N]);(0,$.useEffect)(()=>{P&&(P.current={toggle:()=>{L()}})},[P,L]);let R=(0,$.useMemo)(()=>{var e;return bn(t,n,(e=k==null?void 0:k.http.attachments.getUrl)==null?((e,t,n)=>`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`):e)},[t,n,k]),z=(0,$.useMemo)(()=>f.filter(n=>n.sessionId===e.id?!t.some(e=>e.parts.some(e=>e.type===`tool`&&e.callId===n.toolCallId)):!1),[f,e.id,t]);return(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[(0,Q.jsx)(Ze,{session:e,preconfigs:r,models:a,defaultModel:o,usage:h,modelName:g,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,onRename:m,onNavigateBack:y,isStreaming:b,onInterrupt:x,onCompact:w,isCompacting:T,canCompact:t.length>=2,selectedVariant:A,variants:j}),(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(yn,{displayItems:R,messagesWithParts:t,sessionId:e.id,sessionStatus:e.status,pendingPermissions:f,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,onPermissionResponse:p,onNavigateToSubagent:v,onRemoveFromQueue:c,onRevert:S,onFork:C,onCompact:w,isMainActiveSession:ee,autoFollow:F,onAutoScrollChange:I,scrollToBottomRef:N,serverUrl:O}),(0,Q.jsx)(`button`,{onClick:L,className:`absolute bottom-4 right-4 z-50 flex items-center p-1.5 text-xs rounded-full transition-colors cursor-pointer bg-background/80 backdrop-blur-sm hover:bg-background border border-border/50 shadow-sm pointer-events-auto`,title:F?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,children:F?(0,Q.jsx)(be,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5`})})]}),z.length>0&&(0,Q.jsx)(xn,{permissions:z,onPermissionResponse:p}),e.status===`active`&&!e.parentId&&(0,Q.jsx)(ft,{ref:M,onSendMessage:s,disabled:T,workspaceId:e.workspaceId,sdkClient:k,prompts:i,sessionId:e.id,modelSupportsImage:_}),e.parentId&&(0,Q.jsxs)(`div`,{className:`p-4 border-t border-border bg-muted/50 text-center flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(je,{className:`size-4`}),`This is a subagent session (read-only)`]})]})}function Cn({serverUrl:e,messagesWithParts:t,inputRef:n,sdkClient:r,onRetry:o,onLogout:s,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:d,onChangeModel:f,onChangeVariant:m,onPermissionResponse:h,onRename:g,onNavigateToSubagent:_,onNavigateBack:v,onInterrupt:y,onRevert:b,onFork:x,onCompact:S,onClearCompactionSuccess:C,scrollToBottomRef:w,autoFollowToggleRef:T}){var E,D,k;let A=a(e=>e.connected),j=a(e=>e.authError),M=a(e=>e.connectionTimedOut),N=a(e=>e.retryCount),P=a(e=>e.nextRetryIn),ee=a(e=>e.streamingSessionIds),F=c(e=>e.currentSession),I=c(e=>e.queuedMessages),L=c(e=>e.sessionUsage),R=c(e=>e.currentModel),z=c(e=>e.selectedVariant),te=c(e=>e.compactionSuccess),ne=O(e=>e.preconfigs),B=O(e=>e.prompts),V=O(e=>e.models),re=O(e=>e.defaultModel),H=i(e=>e.pendingPermissions),ie=ne.filter(e=>e.mode!==`subagent`),ae=!(F!=null&&F.parentId),U=(E=F==null?void 0:F.compacting)==null?!1:E,oe=e=>{d(e)},se=e=>{m(e)},ce=()=>{y()};if(!A)return M?(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Ve,{serverUrl:e,authError:j,retryCount:N,nextRetryIn:P,onRetry:o,onLogout:s})}):(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[(0,Q.jsx)(Be,{}),(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,onClick:s,className:`text-muted-foreground`,children:`Change Server`})]});if(!F)return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-muted-foreground px-6`,children:[(0,Q.jsx)(`h2`,{className:`mb-2`,children:`Select or create a session`}),(0,Q.jsx)(`p`,{children:`Choose a session from the sidebar or create a new one to start chatting.`})]});let le=t.filter(e=>e.message.role!==`system`).length>=2,W=V.find(e=>e.id===R);return(0,Q.jsx)(Sn,{inputRef:n,session:F,messagesWithParts:t,queuedMessages:I[F.id]||[],preconfigs:ae?ie:ne,prompts:B,models:V,defaultModel:re,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:oe,onChangeModel:f,onChangeVariant:se,selectedVariant:z,variants:W==null?void 0:W.variants,pendingPermissions:H,onPermissionResponse:h,onRename:g,usage:L,modelName:R,modelSupportsImage:(D=W==null||(k=W.capabilities)==null||(k=k.input)==null?void 0:k.image)==null?!1:D,onNavigateToSubagent:_,onNavigateBack:v,isStreaming:ee.has(F.id)||!!F.runningAt,onInterrupt:ce,onRevert:b,onFork:x,onCompact:le?()=>S(F.id):void 0,isCompacting:U,compactionSuccess:te,onClearCompactionSuccess:C,serverUrl:e==null?void 0:e,sdkClient:r,scrollToBottomRef:w,autoFollowToggleRef:T})}function wn(){let e=f(),{chatInputRef:t,scrollToBottomRef:n,autoFollowToggleRef:r}=C(),{sdkClient:i,messagesWithParts:a,serverUrl:o,currentSession:s,isSessionLoading:c,resumeSession:l,revertSession:u,forkSession:d,compactSession:p,removeFromQueue:m,sendChatMessage:h,handlePermissionResponse:g,handleInterruptSession:_,updateSessionPreconfig:v,updateSessionModel:y,updateSessionVariant:b,handleNavigateBack:x,handleRenameSession:S,setCompactionSuccess:w}=e;return c?(0,Q.jsx)(ze,{}):s?(0,Q.jsx)(Cn,{sdkClient:i,inputRef:t,messagesWithParts:a,serverUrl:o,onRetry:e.handleRetry,onLogout:e.handleLogout,onSendMessage:h,onRemoveFromQueue:m,onChangePreconfig:v,onChangeModel:y,onChangeVariant:b,onPermissionResponse:g,onRename:S,onNavigateToSubagent:l,onNavigateBack:x,onInterrupt:_,onRevert:u,onFork:d,onCompact:p,onClearCompactionSuccess:()=>w(!1),scrollToBottomRef:n,autoFollowToggleRef:r}):null}export{wn as t};
@@ -0,0 +1 @@
1
+ .xterm{cursor:text;-webkit-user-select:none;user-select:none;position:relative}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{z-index:5;position:absolute;top:0}.xterm .xterm-helper-textarea{opacity:0;z-index:-5;white-space:nowrap;resize:none;border:0;width:0;height:0;margin:0;padding:0;position:absolute;top:0;left:-9999em;overflow:hidden}.xterm .composition-view{color:#fff;white-space:nowrap;z-index:1;background:#000;display:none;position:absolute}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{cursor:default;background-color:#000;position:absolute;top:0;bottom:0;left:0;right:0;overflow-y:scroll}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;top:0;left:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{visibility:hidden;line-height:normal;display:inline-block;position:absolute;top:0;left:-9999em}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{z-index:10;color:#0000;pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}.xterm .xterm-accessibility-tree:not(.debug) ::selection{color:#0000}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{width:1px;height:1px;position:absolute;left:-9999px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:underline double;text-decoration:underline double}.xterm-underline-3{-webkit-text-decoration:underline wavy;text-decoration:underline wavy}.xterm-underline-4{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.xterm-underline-5{-webkit-text-decoration:underline dashed;text-decoration:underline dashed}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:underline overline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;pointer-events:none;position:absolute;top:0;right:0}.xterm-decoration-top{z-index:2;position:relative}