@jean2/client 1.0.3 → 1.0.5

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 (69) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/ServerContext-Dy9T5Mj8.js +1 -0
  3. package/dist/assets/SessionContent-DMPPyidM.js +11 -0
  4. package/dist/assets/{SessionMenuButton-Bg83zT6G.js → SessionMenuButton-DtN_qfRb.js} +3 -3
  5. package/dist/assets/_serverId-BOWHyoan.js +12 -0
  6. package/dist/assets/_serverId-DXVl_AFQ.js +1 -0
  7. package/dist/assets/_sessionId-BfVgqUBK.js +1 -0
  8. package/dist/assets/_sessionId-Bp7Qrc4O.js +1 -0
  9. package/dist/assets/add-server-BU3oc_j3.js +1 -0
  10. package/dist/assets/alert-BsN6ZzaK.js +31 -0
  11. package/dist/assets/archive-pL5uw9sg.js +1 -0
  12. package/dist/assets/arrow-left-DSvwF2mY.js +1 -0
  13. package/dist/assets/badge-Cjebg6Sp.js +1 -0
  14. package/dist/assets/button--1wnt03c.js +45 -0
  15. package/dist/assets/classPrivateFieldGet2-BGlEuFdn.js +1 -0
  16. package/dist/assets/confirmation-dialog-CFCxzDEX.js +1 -0
  17. package/dist/assets/dialog-BNCh4KEM.js +1 -0
  18. package/dist/assets/{dist-js-CnIJv7bh.js → dist-js-s36UjyQ4.js} +1 -1
  19. package/dist/assets/{event-Bg5mre8h.js → event-Crr43Eih.js} +1 -1
  20. package/dist/assets/index-Db3JxRbZ.js +10 -0
  21. package/dist/assets/index-DzEyMPKG.css +2 -0
  22. package/dist/assets/mutation-D4xtepYQ.js +1 -0
  23. package/dist/assets/overview-DbKX71kj.js +1 -0
  24. package/dist/assets/platform-cRBZ7eSy.js +1 -0
  25. package/dist/assets/popover-C8mm1NWm.js +1 -0
  26. package/dist/assets/preload-helper-D844vhe4.js +1 -0
  27. package/dist/assets/queries-C0JoQFZb.js +1 -0
  28. package/dist/assets/react-dom-DHWV5rS5.js +1 -0
  29. package/dist/assets/refresh-cw-BYRFQSBp.js +1 -0
  30. package/dist/assets/routes-Ck6V8B0w.js +1 -0
  31. package/dist/assets/sidebar-BqQ-fUFc.js +1 -0
  32. package/dist/assets/src-BALdofIU.js +1 -0
  33. package/dist/assets/{triangle-alert-BOCjiWM3.js → triangle-alert-Bil68MLf.js} +1 -1
  34. package/dist/assets/useNavigate-Ckup4lZi.js +1 -0
  35. package/dist/assets/useRouter-C67ywEA3.js +1 -0
  36. package/dist/assets/workspace-BzFUmInc.js +1 -0
  37. package/dist/cli.mjs +21 -9
  38. package/dist/index.html +11 -10
  39. package/package.json +1 -1
  40. package/dist/assets/ServerContext-CBFiY6IH.js +0 -1
  41. package/dist/assets/SessionContent-w-YQzt9T.js +0 -9
  42. package/dist/assets/_serverId-B4Rjk4iQ.js +0 -12
  43. package/dist/assets/_serverId-BwsJG6SV.js +0 -1
  44. package/dist/assets/_serverId-COhNW61b.js +0 -2
  45. package/dist/assets/_sessionId-CMkepspM.js +0 -1
  46. package/dist/assets/_sessionId-xZ5q7S0b.js +0 -1
  47. package/dist/assets/alert-qqwNRgnw.js +0 -31
  48. package/dist/assets/badge-CwZd07eA.js +0 -45
  49. package/dist/assets/confirmation-dialog-DGPNPL5O.js +0 -1
  50. package/dist/assets/index-BDTQdmk9.js +0 -10
  51. package/dist/assets/index-DF4q2PgJ.css +0 -2
  52. package/dist/assets/overview-CEkUAF73.js +0 -1
  53. package/dist/assets/platform-5d-ZQG2e.js +0 -1
  54. package/dist/assets/popover-BaZzl6-v.js +0 -1
  55. package/dist/assets/preload-helper-D-tEmku_.js +0 -1
  56. package/dist/assets/routes-WPmRqSvV.js +0 -1
  57. package/dist/assets/scroll-area-16Gq00WS.js +0 -1
  58. package/dist/assets/server-g7It7jLf.js +0 -1
  59. package/dist/assets/servers-GmYSnzvH.js +0 -1
  60. package/dist/assets/sidebar-DmGZgZwK.js +0 -1
  61. package/dist/assets/src-BiLzKNfl.js +0 -1
  62. package/dist/assets/useNavigate-Dxc8FNpV.js +0 -1
  63. package/dist/assets/useParams-RuFKFrOo.js +0 -1
  64. package/dist/assets/useRouterState-C1XfNwIo.js +0 -1
  65. package/dist/assets/workspace-B-9b8A58.js +0 -1
  66. /package/dist/assets/{core-B5tm5Pq5.js → core-BYcrozIP.js} +0 -0
  67. /package/dist/assets/{createLucideIcon-BYAVpx9Z.js → createLucideIcon-CuVT3KNW.js} +0 -0
  68. /package/dist/assets/{overview-B_ZDrH1J.js → overview-C91MPxfo.js} +0 -0
  69. /package/dist/assets/{workspace-_n12Hx4o.js → workspace-84xYPx6s.js} +0 -0
package/README.md CHANGED
@@ -176,9 +176,9 @@ packages/client/
176
176
 
177
177
  ## Architecture
178
178
 
179
- The client connects to a Jean2 server via WebSocket (`ws://host:port/ws?token=...`) for real-time events and REST (`http://host:port/api`) for initial data loading. All communication is authenticated with a bearer token.
179
+ The client connects to a Jean2 server via WebSocket (`ws://host:port/ws?token=...`) for real-time events and REST (`http://host:port/api`) for initial data loading. Authentication is optional when the server has `JEAN2_AUTH_TOKEN` set, all requests require the bearer token. When not set, all requests pass through without authentication.
180
180
 
181
- **WebSocket protocol** handles session CRUD, message streaming (including delta-based text append), part creation/updates, permission requests, queue management, usage tracking, and compaction events. The `App.tsx` handler dispatches all `ServerMessage` types into React state.
181
+ **WebSocket protocol** handles session CRUD, message streaming (including delta-based text append), part creation/updates, ask requests (permissions, questions, forms, client capabilities), permission responses, queue management, usage tracking, and compaction events. The `App.tsx` handler dispatches all `ServerMessage` types into React state.
182
182
 
183
183
  **Multi-server support** allows connecting to multiple Jean2 server instances. Servers are persisted in localStorage. Switching servers clears all session state and reconnects.
184
184
 
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{r as i}from"./src-BALdofIU.js";var a=t(n(),1),o=a.use,s=typeof window<`u`?a.useLayoutEffect:a.useEffect;function c(e){let t=a.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function l(e,t,n={},r={}){a.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function u(e){let t=a.useRef(null);return a.useImperativeHandle(e,()=>t.current,[]),t}var d=r(),f={SERVERS:`jean2_servers`,QUICK_CONNECTIONS:`jean2_quick_connections`};function p(){try{let e=localStorage.getItem(f.SERVERS);return e?JSON.parse(e):[]}catch(e){return console.error(`Error reading saved servers from localStorage:`,e),[]}}function m(e){try{let t=p();t.push(e),localStorage.setItem(f.SERVERS,JSON.stringify(t))}catch(e){console.error(`Error saving server to localStorage:`,e)}}function h(e,t){try{let n=p(),r=n.findIndex(t=>t.id===e);if(r===-1){console.error(`Server not found:`,e);return}n[r]={...n[r],...t},localStorage.setItem(f.SERVERS,JSON.stringify(n))}catch(e){console.error(`Error updating server in localStorage:`,e)}}function g(e){try{let t=p().filter(t=>t.id!==e);localStorage.setItem(f.SERVERS,JSON.stringify(t));let n=_().filter(t=>t.serverId!==e);localStorage.setItem(f.QUICK_CONNECTIONS,JSON.stringify(n))}catch(e){console.error(`Error deleting server from localStorage:`,e)}}function _(){try{let e=localStorage.getItem(f.QUICK_CONNECTIONS);return e?JSON.parse(e):[]}catch(e){return console.error(`Error reading quick connections from localStorage:`,e),[]}}function v(e){let t=_(),n=t.reduce((e,t)=>Math.max(e,t.order),-1),r={...e,id:crypto.randomUUID(),order:n+1};t.push(r);try{localStorage.setItem(f.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error saving quick connection to localStorage:`,e)}return r}function y(e){try{let t=_().filter(t=>t.id!==e);localStorage.setItem(f.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error removing quick connection from localStorage:`,e)}}function b(e){try{let t=_().filter(t=>t.workspaceId!==e);localStorage.setItem(f.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error removing quick connections for workspace from localStorage:`,e)}}function x(e){try{let t=_(),n=new Map(t.map(e=>[e.id,e]));e.forEach((e,t)=>{let r=n.get(e);r&&(r.order=t)}),localStorage.setItem(f.QUICK_CONNECTIONS,JSON.stringify(t))}catch(e){console.error(`Error reordering quick connections in localStorage:`,e)}}function S(e){return e.length<12?e:`${e.slice(0,4)}...${e.slice(-4)}`}function C(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 w=`localhost:8742`,T=2e3;async function E(e){try{var t,n;let r=new AbortController,i=setTimeout(()=>r.abort(),T),a=await fetch(`http://${w}/api/info`,{signal:e==null?r.signal:e});return clearTimeout(i),!a.ok||(t=(n=(await a.json()).features)==null?void 0:n.authentication)!=null&&t?{available:!1,url:w}:{available:!0,url:w}}catch{return{available:!1,url:w}}}async function D(e,t){let n=C(e),r;try{var a,o;let e=n.startsWith(`https`)?`https`:`http`,t=n.replace(/^https?:\/\//,``),i=await fetch(`${e}://${t}/api/info`);if(!i.ok)return{success:!1,error:`Server returned ${i.status}. Check the URL and try again.`};r=(a=(o=(await i.json()).features)==null?void 0:o.authentication)==null?!1:a}catch(e){return{success:!1,error:`Could not reach server: ${e instanceof Error?e.message:String(e)}`}}if(!r)return{success:!0,authEnabled:!1};if(!t)return{success:!1,authEnabled:!0,error:`This server requires an API token. Enable the token toggle and enter your token.`};try{if(!await i.verifyToken(n,t))return{success:!1,authEnabled:!0,error:`Invalid token. Check your API token and try again.`}}catch(e){return{success:!1,authEnabled:!0,error:`Could not verify token: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,authEnabled:!0}}var O=e(),k=(0,a.createContext)(null),A=e=>{let t=(0,d.c)(22),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,o]=(0,a.useState)(r),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[1]=s):s=t[1];let[c,l]=(0,a.useState)(s),[u,f]=(0,a.useState)(!1),S=(0,a.useRef)(!1),w,T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=p(),t=_();o(e),l(t),f(!0)},T=[],t[2]=w,t[3]=T):(w=t[2],T=t[3]),(0,a.useEffect)(w,T);let D,A;t[4]!==u||t[5]!==i.length?(D=()=>{if(!u||S.current)return;if(i.length>0){S.current=!0;return}S.current=!0;let e=new AbortController;return E(e.signal).then(e=>{e.available&&(m({id:crypto.randomUUID(),name:`Home`,url:C(e.url),createdAt:new Date().toISOString()}),o(p()))}),()=>e.abort()},A=[u,i.length],t[4]=u,t[5]=i.length,t[6]=D,t[7]=A):(D=t[6],A=t[7]),(0,a.useEffect)(D,A);let j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=(e,t,n)=>{let r=C(t),i={id:crypto.randomUUID(),name:e,url:r,...n?{token:n}:{},createdAt:new Date().toISOString()};return m(i),o(p()),i},t[8]=j):j=t[8];let M=j,N;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=(e,t)=>{h(e,{...t,...t.url&&{url:C(t.url)}}),o(p())},t[9]=N):N=t[9];let P=N,F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{g(e),o(p()),l(_())},t[10]=F):F=t[10];let I=F,L;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t,n,r)=>{v({serverId:e,serverName:t,workspaceId:n,workspaceName:r}),l(_())},t[11]=L):L=t[11];let R=L,z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{y(e),l(_())},t[12]=z):z=t[12];let B=z,V;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{b(e),l(_())},t[13]=V):V=t[13];let H=V,U;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{x(e),l(_())},t[14]=U):U=t[14];let W=U,G;t[15]!==u||t[16]!==c||t[17]!==i?(G={servers:i,quickConnections:c,isHydrated:u,addServer:M,editServer:P,removeServer:I,addToQuickConnections:R,removeFromQuickConnections:B,removeFromQuickConnectionsByWorkspace:H,reorderQuick:W},t[15]=u,t[16]=c,t[17]=i,t[18]=G):G=t[18];let K=G,q;return t[19]!==n||t[20]!==K?(q=(0,O.jsx)(k.Provider,{value:K,children:n}),t[19]=n,t[20]=K,t[21]=q):q=t[21],q},j=()=>{let e=(0,a.useContext)(k);if(e===null)throw Error(`useServerContext must be used within a ServerProvider`);return e};export{C as a,u as c,c as d,S as i,l,j as n,p as o,D as r,o as s,A as t,s as u};
@@ -0,0 +1,11 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{t as i}from"./react-dom-DHWV5rS5.js";import{n as a}from"./ThemeProvider-Da23NPAS.js";import{$ as o,A as s,B as c,C as l,D as u,G as d,H as f,J as p,K as m,O as h,S as g,T as _,U as v,Y as y,_ as b,a as x,b as S,c as C,d as w,f as T,h as E,i as D,l as O,m as k,n as A,p as j,q as M,r as N,s as P,t as F,u as I,v as L,x as R,y as z}from"./badge-Cjebg6Sp.js";import"./src-BALdofIU.js";import{t as B}from"./createLucideIcon-CuVT3KNW.js";import{t as V}from"./archive-pL5uw9sg.js";import{t as H}from"./arrow-left-DSvwF2mY.js";import{a as U,c as W,f as ee,i as G,l as K,m as te,n as ne,o as re,p as ie,r as q,s as ae,t as oe,u as J}from"./popover-C8mm1NWm.js";import{C as se,S as ce,_ as le,a as ue,b as de,c as fe,d as pe,f as me,g as he,h as ge,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,r as Ce,s as we,t as Te,u as Ee,v as De,w as Oe,x as ke,y as Ae}from"./alert-BsN6ZzaK.js";import{i as je,n as Me,r as Ne,t as Pe}from"./triangle-alert-Bil68MLf.js";import{C as Fe,F as Ie,M as Le,N as Re,P as ze,T as Be,b as Ve,j as He,r as Y,t as X,w as Ue,x as We}from"./button--1wnt03c.js";import{t as Ge}from"./refresh-cw-BYRFQSBp.js";import{t as Ke}from"./confirmation-dialog-CFCxzDEX.js";function qe(e){return e.role===`assistant`}var Je=B(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ye=B(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Xe=B(`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`}]]),Ze=B(`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`}]]),Qe=B(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),$e=B(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),et=B(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),tt=B(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),nt=B(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),rt=B(`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`}]]),it=B(`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`}]]),at=B(`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`}]]),ot=B(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),st=B(`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`}]]),ct=B(`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`}]]),lt=B(`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`}]]),ut=B(`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`}]]),dt=B(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),ft=B(`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`}]]),pt=B(`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`}]]),mt=B(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Z=t(n(),1),Q=e(),ht=`Checkbox`,[gt,_t]=Ue(ht),[vt,yt]=gt(ht);function bt(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=We({prop:n,defaultProp:i==null?!1:i,onChange:c,caller:ht}),[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useRef(!1),y=m?!!o||!!m.closest(`form`):!0,b={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,required:l,defaultChecked:kt(i)?!1:i,isFormControl:y,bubbleInput:g,setBubbleInput:_};return(0,Q.jsx)(vt,{scope:t,...b,children:Ot(d)?d(b):r})}var xt=`CheckboxTrigger`,St=Z.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=yt(xt,e),h=He(i,u),g=Z.useRef(c);return Z.useEffect(()=>{let e=a==null?void 0:a.form;if(e){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,Q.jsx)(Be.button,{type:`button`,role:`checkbox`,"aria-checked":kt(c)?`mixed`:c,"aria-required":l,"data-state":At(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:h,onKeyDown:Fe(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Fe(n,e=>{d(e=>kt(e)?!0:!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});St.displayName=xt;var Ct=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(bt,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(St,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(Dt,{__scopeCheckbox:n})]})})});Ct.displayName=ht;var wt=`CheckboxIndicator`,Tt=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=yt(wt,n);return(0,Q.jsx)(Ve,{present:r||kt(a.checked)||a.checked===!0,children:(0,Q.jsx)(Be.span,{"data-state":At(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});Tt.displayName=wt;var Et=`CheckboxBubbleInput`,Dt=Z.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=yt(Et,e),h=He(n,m),g=ve(a),_=c(r);Z.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(g!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=kt(a),n.call(e,kt(a)?!1:a),e.dispatchEvent(t)}},[p,g,a,i]);let v=Z.useRef(kt(a)?!1:a);return(0,Q.jsx)(Be.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o==null?v.current:o,required:s,disabled:l,name:u,value:d,form:f,...t,tabIndex:-1,ref:h,style:{...t.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Dt.displayName=Et;function Ot(e){return typeof e==`function`}function kt(e){return e===`indeterminate`}function At(e){return kt(e)?`indeterminate`:e?`checked`:`unchecked`}var $=r();function jt(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(v,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]}),e[0]=t):t=e[0],t}function Mt(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Connecting to server...`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(v,{className:`size-8 animate-spin`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[i,(0,Q.jsx)(`p`,{className:`text-sm`,children:r})]}),t[1]=r,t[2]=a),a}var Nt=e=>{let t=(0,$.c)(26),{serverUrl:n,authError:r,retryCount:i,nextRetryIn:a,onRetry:o,onLogout:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(pt,{className:`size-12 text-destructive mb-4`}),l=(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u=r||`Please check that the server is running.`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:u}),t[2]=u,t[3]=d);let f;t[4]===n?f=t[5]:(f=n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:n}),t[4]=n,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,a,`s...`]}),t[6]=a,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(Ge,{className:`size-4 mr-2`,"data-icon":`inline-start`}),t[8]=m):m=t[8];let h;t[9]===o?h=t[10]:(h=(0,Q.jsxs)(X,{onClick:o,variant:`default`,children:[m,`Retry Now`]}),t[9]=o,t[10]=h);let g;t[11]===s?g=t[12]:(g=(0,Q.jsx)(X,{onClick:s,variant:`ghost`,children:`Change Server`}),t[11]=s,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===i?v=t[17]:(v=i>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,i]}),t[16]=i,t[17]=v);let y;t[18]!==_||t[19]!==v||t[20]!==p?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[p,_,v]}),t[18]=_,t[19]=v,t[20]=p,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==d||t[24]!==f?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[c,l,d,f,y]}),t[22]=y,t[23]=d,t[24]=f,t[25]=b):b=t[25],b};function Pt(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Ft(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function It(e){let t=(0,$.c)(21),{totalTokens:n,contextWindow:r}=e,i=n===void 0?0:n,a=r===void 0?0:r,[o,s]=(0,Z.useState)(!1),c=i===0?0:a,l;t[0]!==c||t[1]!==i?(l=c===0?0:Math.min(100,Math.round(i/c*100)),t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d=Ft(u),f=2*Math.PI*8,p=f*(1-u/100),m=u===0?`text-muted-foreground/30`:d===`critical`?`text-destructive`:d===`warning`?`text-warning`:`text-primary`,h;t[3]===o?h=t[4]:(h=()=>s(!o),t[3]=o,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),t[5]=g):g=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_={transition:`stroke-dashoffset 0.3s ease`},t[6]=_):_=t[6];let v;t[7]!==m||t[8]!==p?(v=(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[g,(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:m,strokeWidth:`3`,strokeDasharray:f,strokeDashoffset:p,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:_})]}),t[7]=m,t[8]=p,t[9]=v):v=t[9];let y;t[10]!==c||t[11]!==u||t[12]!==o||t[13]!==i?(y=o?`${Pt(i)}/${Pt(c)}`:`${u}%`,t[10]=c,t[11]=u,t[12]=o,t[13]=i,t[14]=y):y=t[14];let b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:y}),t[15]=y,t[16]=b);let x;return t[17]!==h||t[18]!==v||t[19]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:h,children:[v,b]}),t[17]=h,t[18]=v,t[19]=b,t[20]=x):x=t[20],x}function Lt(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Rt(e){let t=(0,$.c)(79),{models:n,selectedModelId:r,onChangeModel:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,l=s===void 0?!1:s,[u,d]=(0,Z.useState)(!1),f,m,h,g,_,v,y,b,x,S,C,w,T;if(t[0]!==c||t[1]!==a||t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==u||t[6]!==r){v=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.reduce(zt,{}),o=e=>{let t=n.find(t=>t.id===e);t&&(i(e,t.providerId),d(!1))},s;if(t[20]!==n||t[21]!==r){let e;t[23]===r?e=t[24]:(e=e=>e.id===r,t[23]=r,t[24]=e),s=n.find(e),t[20]=n,t[21]=r,t[22]=s}else s=t[22];let E=s;if(l){let n;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(ce,{className:`size-4 text-muted-foreground`}),t[25]=n):n=t[25];let i;t[26]!==a||t[27]!==u?(i=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select model`,disabled:a,children:n})}),t[26]=a,t[27]=u,t[28]=i):i=t[28];let s;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[29]=s):s=t[29];let c;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(re,{children:`No model found.`}),t[30]=c):c=t[30];let l=(0,Q.jsxs)(J,{className:`max-h-[50vh] overflow-y-auto`,children:[c,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(ae,{heading:t,children:n.map(e=>(0,Q.jsxs)(K,{value:e.id,onSelect:()=>o(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:Lt(e.tier)})]}),(0,Q.jsx)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),f;t[31]===l?f=t[32]:(f=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[s,l]})}),t[31]=l,t[32]=f);let m;t[33]!==u||t[34]!==i||t[35]!==f?(m=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[i,f]}),t[33]=u,t[34]=i,t[35]=f,t[36]=m):m=t[36],v=m;break bb0}if(c){let n,i;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(ce,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[37]=n,t[38]=i):(n=t[37],i=t[38]);let s;t[39]!==a||t[40]!==u?(s=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[n,i]})}),t[39]=a,t[40]=u,t[41]=s):s=t[41];let c;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[42]=c):c=t[42];let l;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(re,{children:`No model found.`}),t[43]=l):l=t[43];let f=(0,Q.jsxs)(J,{className:`max-h-[50vh] overflow-y-auto`,children:[l,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(ae,{heading:t,children:n.map(e=>(0,Q.jsxs)(K,{value:e.id,onSelect:()=>o(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:Lt(e.tier)})]}),(0,Q.jsx)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),m;t[44]===f?m=t[45]:(m=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[c,f]})}),t[44]=f,t[45]=m);let h;t[46]!==u||t[47]!==s||t[48]!==m?(h=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[s,m]}),t[46]=u,t[47]=s,t[48]=m,t[49]=h):h=t[49],v=h;break bb0}g=oe,w=u,T=d;let D;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(ce,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[50]=D):D=t[50];let O=(E==null?void 0:E.name)||`Select model`,k;t[51]===O?k=t[52]:(k=(0,Q.jsx)(`span`,{className:`truncate`,children:O}),t[51]=O,t[52]=k);let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[53]=A):A=t[53],t[54]!==a||t[55]!==u||t[56]!==k?(_=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[D,k,A]})}),t[54]=a,t[55]=u,t[56]=k,t[57]=_):_=t[57],h=q,C=`w-[240px] p-0`,m=U,t[58]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(W,{placeholder:`Search model...`}),t[58]=S):S=t[58],f=J,y=`max-h-[50vh] overflow-y-auto`,t[59]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(re,{children:`No model found.`}),t[59]=b):b=t[59],x=Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(ae,{heading:t,children:n.map(e=>(0,Q.jsxs)(K,{value:e.id,onSelect:()=>o(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:Lt(e.tier)})]}),(0,Q.jsx)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})}t[0]=c,t[1]=a,t[2]=l,t[3]=n,t[4]=i,t[5]=u,t[6]=r,t[7]=f,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T}else f=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19];if(v!==Symbol.for(`react.early_return_sentinel`))return v;let E;t[60]!==f||t[61]!==y||t[62]!==b||t[63]!==x?(E=(0,Q.jsxs)(f,{className:y,children:[b,x]}),t[60]=f,t[61]=y,t[62]=b,t[63]=x,t[64]=E):E=t[64];let D;t[65]!==m||t[66]!==E||t[67]!==S?(D=(0,Q.jsxs)(m,{children:[S,E]}),t[65]=m,t[66]=E,t[67]=S,t[68]=D):D=t[68];let O;t[69]!==h||t[70]!==D||t[71]!==C?(O=(0,Q.jsx)(h,{className:C,children:D}),t[69]=h,t[70]=D,t[71]=C,t[72]=O):O=t[72];let k;return t[73]!==g||t[74]!==_||t[75]!==O||t[76]!==w||t[77]!==T?(k=(0,Q.jsxs)(g,{open:w,onOpenChange:T,children:[_,O]}),t[73]=g,t[74]=_,t[75]=O,t[76]=w,t[77]=T,t[78]=k):k=t[78],k}function zt(e,t){return e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e}var Bt={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function Vt(e){return Bt[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e){let t=(0,$.c)(69),{variants:n,selectedVariant:r,onChangeVariant:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,l=s===void 0?!1:s,[u,d]=(0,Z.useState)(!1);if(!n||Object.keys(n).length===0)return null;let f,m,h,g,_,v,y;if(t[0]!==i||t[1]!==r||t[2]!==n){let e=Object.keys(n),a;t[10]===i?a=t[11]:(a=e=>{i(e===`__none__`?null:e),d(!1)},t[10]=i,t[11]=a);let o=a,s;t[12]===r?s=t[13]:(s=r?Vt(r):`Default`,t[12]=r,t[13]=s),h=s,m=U,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(W,{placeholder:`Search...`}),t[14]=y):y=t[14],f=J,g=`max-h-[50vh] overflow-y-auto`;let c;t[15]===o?c=t[16]:(c=()=>o(`__none__`),t[15]=o,t[16]=c);let l;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{children:`Default`}),t[17]=l):l=t[17];let u=r===null?`opacity-100`:`opacity-0`,b;t[18]===u?b=t[19]:(b=Y(`size-4`,u),t[18]=u,t[19]=b);let x;t[20]===b?x=t[21]:(x=(0,Q.jsx)(p,{className:b}),t[20]=b,t[21]=x),t[22]!==x||t[23]!==c?(_=(0,Q.jsxs)(K,{value:`__none__`,onSelect:c,className:`justify-between`,children:[l,x]},`__none__`),t[22]=x,t[23]=c,t[24]=_):_=t[24],v=e.map(e=>(0,Q.jsxs)(K,{value:e,onSelect:()=>o(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:Vt(e)}),(0,Q.jsx)(p,{className:Y(`size-4`,r===e?`opacity-100`:`opacity-0`)})]},e)),t[0]=i,t[1]=r,t[2]=n,t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y}else f=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9];let b;t[25]!==f||t[26]!==g||t[27]!==_||t[28]!==v?(b=(0,Q.jsxs)(f,{className:g,children:[_,v]}),t[25]=f,t[26]=g,t[27]=_,t[28]=v,t[29]=b):b=t[29];let x;t[30]!==m||t[31]!==y||t[32]!==b?(x=(0,Q.jsxs)(m,{children:[y,b]}),t[30]=m,t[31]=y,t[32]=b,t[33]=x):x=t[33];let S=x;if(l){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ze,{className:`size-4 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]!==a||t[36]!==u?(n=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:e})}),t[35]=a,t[36]=u,t[37]=n):n=t[37];let r;t[38]===S?r=t[39]:(r=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:S}),t[38]=S,t[39]=r);let i;return t[40]!==u||t[41]!==n||t[42]!==r?(i=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[n,r]}),t[40]=u,t[41]=n,t[42]=r,t[43]=i):i=t[43],i}if(c){let e,n;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Ze,{className:`size-4 flex-shrink-0 text-muted-foreground`}),e=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[44]=e,t[45]=n):(e=t[44],n=t[45]);let r;t[46]!==a||t[47]!==u?(r=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:[n,e]})}),t[46]=a,t[47]=u,t[48]=r):r=t[48];let i;t[49]===S?i=t[50]:(i=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:S}),t[49]=S,t[50]=i);let o;return t[51]!==u||t[52]!==r||t[53]!==i?(o=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[r,i]}),t[51]=u,t[52]=r,t[53]=i,t[54]=o):o=t[54],o}let C;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Ze,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[55]=C):C=t[55];let w;t[56]===h?w=t[57]:(w=(0,Q.jsx)(`span`,{className:`truncate`,children:h}),t[56]=h,t[57]=w);let T;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[58]=T):T=t[58];let E;t[59]!==a||t[60]!==u||t[61]!==w?(E=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select variant`,disabled:a,children:[C,w,T]})}),t[59]=a,t[60]=u,t[61]=w,t[62]=E):E=t[62];let D;t[63]===S?D=t[64]:(D=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:S}),t[63]=S,t[64]=D);let O;return t[65]!==u||t[66]!==E||t[67]!==D?(O=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[E,D]}),t[65]=u,t[66]=E,t[67]=D,t[68]=O):O=t[68],O}function Ut(e){let t=(0,$.c)(66),{preconfigs:n,selectedPreconfigId:r,onChangePreconfig:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,l=s===void 0?!1:s,[u,d]=(0,Z.useState)(!1),f;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>e.id===r,t[3]=r,t[4]=e),f=n.find(e),t[0]=n,t[1]=r,t[2]=f}else f=t[2];let m=f,h;t[5]===i?h=t[6]:(h=e=>{i(e),d(!1)},t[5]=i,t[6]=h);let g=h;if(l){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ye,{className:`size-4 text-muted-foreground`}),t[7]=e):e=t[7];let i;t[8]!==a||t[9]!==u?(i=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:e})}),t[8]=a,t[9]=u,t[10]=i):i=t[10];let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[11]=o):o=t[11];let s;if(t[12]!==g||t[13]!==n||t[14]!==r){let e;t[16]!==g||t[17]!==r?(e=e=>(0,Q.jsxs)(K,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[16]=g,t[17]=r,t[18]=e):e=t[18],s=n.map(e),t[12]=g,t[13]=n,t[14]=r,t[15]=s}else s=t[15];let c;t[19]===s?c=t[20]:(c=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[o,(0,Q.jsx)(J,{className:`max-h-[50vh] overflow-y-auto`,children:s})]})}),t[19]=s,t[20]=c);let l;return t[21]!==u||t[22]!==i||t[23]!==c?(l=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[i,c]}),t[21]=u,t[22]=i,t[23]=c,t[24]=l):l=t[24],l}if(c){let e,i;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[25]=e,t[26]=i):(e=t[25],i=t[26]);let o;t[27]!==a||t[28]!==u?(o=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:[e,i]})}),t[27]=a,t[28]=u,t[29]=o):o=t[29];let s;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[30]=s):s=t[30];let c;if(t[31]!==g||t[32]!==n||t[33]!==r){let e;t[35]!==g||t[36]!==r?(e=e=>(0,Q.jsxs)(K,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[35]=g,t[36]=r,t[37]=e):e=t[37],c=n.map(e),t[31]=g,t[32]=n,t[33]=r,t[34]=c}else c=t[34];let l;t[38]===c?l=t[39]:(l=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[s,(0,Q.jsx)(J,{className:`max-h-[50vh] overflow-y-auto`,children:c})]})}),t[38]=c,t[39]=l);let f;return t[40]!==u||t[41]!==l||t[42]!==o?(f=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[o,l]}),t[40]=u,t[41]=l,t[42]=o,t[43]=f):f=t[43],f}let _;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[44]=_):_=t[44];let v=(m==null?void 0:m.name)||`Select config`,y;t[45]===v?y=t[46]:(y=(0,Q.jsx)(`span`,{className:`truncate`,children:v}),t[45]=v,t[46]=y);let b;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(te,{className:`size-3 shrink-0 opacity-50`}),t[47]=b):b=t[47];let x;t[48]!==a||t[49]!==u||t[50]!==y?(x=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":u,"aria-label":`Select config`,disabled:a,children:[_,y,b]})}),t[48]=a,t[49]=u,t[50]=y,t[51]=x):x=t[51];let S;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(W,{placeholder:`Search config...`}),t[52]=S):S=t[52];let C;if(t[53]!==g||t[54]!==n||t[55]!==r){let e;t[57]!==g||t[58]!==r?(e=e=>(0,Q.jsxs)(K,{onSelect:()=>g(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)(p,{className:Y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[57]=g,t[58]=r,t[59]=e):e=t[59],C=n.map(e),t[53]=g,t[54]=n,t[55]=r,t[56]=C}else C=t[56];let w;t[60]===C?w=t[61]:(w=(0,Q.jsx)(q,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(U,{children:[S,(0,Q.jsx)(J,{className:`max-h-[50vh] overflow-y-auto`,children:C})]})}),t[60]=C,t[61]=w);let T;return t[62]!==u||t[63]!==w||t[64]!==x?(T=(0,Q.jsxs)(oe,{open:u,onOpenChange:d,children:[x,w]}),t[62]=u,t[63]=w,t[64]=x,t[65]=T):T=t[65],T}function Wt(e){switch(e){case`uncontrolled`:return{icon:f,tooltip:`No active controller`,label:`No client currently controls this session.`,ariaLabel:`Session control: no active controller`,variant:`ghost`,iconClass:`text-muted-foreground/60`};case`controller`:return{icon:f,tooltip:`You control this session`,label:`You are controlling this session.`,ariaLabel:`Session control: you control this session`,variant:`ghost`,iconClass:`text-muted-foreground`};case`observer`:return{icon:de,tooltip:`Controlled on another device`,label:`Another client is controlling this session.`,ariaLabel:`Session control: controlled on another device`,variant:`ghost`,iconClass:`text-muted-foreground`};case`takeover_controller`:return{icon:ot,tooltip:`Another client requested control`,label:`Another client wants to take control of this session.`,ariaLabel:`Session control: takeover requested`,variant:`ghost`,iconClass:`text-orange-500`};case`takeover_requester`:return{icon:ot,tooltip:`Takeover request pending`,label:`Your control request is waiting for approval.`,ariaLabel:`Session control: takeover request pending`,variant:`ghost`,iconClass:`text-orange-500`};case`grace`:return{icon:mt,tooltip:`Waiting for previous controller to reconnect`,label:`The previous controller may still reconnect.`,ariaLabel:`Session control: waiting for reconnect`,variant:`ghost`,iconClass:`text-yellow-500`}}}function Gt(e){let t=(0,$.c)(54),{uiState:n,sessionId:r,pendingRequesterClientId:i,onClaimControl:a,onReleaseControl:o,onRequestTakeover:s,onRespondTakeover:c}=e,l;t[0]===n?l=t[1]:(l=Wt(n),t[0]=n,t[1]=l);let u=l,d=u.icon;if(!(n===`uncontrolled`&&a||n===`controller`&&o||n===`observer`&&s||n===`takeover_controller`&&c)){let e=`size-4 ${u.iconClass}`,n;t[2]!==d||t[3]!==e?(n=(0,Q.jsx)(d,{className:e}),t[2]=d,t[3]=e,t[4]=n):n=t[4];let r;t[5]!==u.ariaLabel||t[6]!==n?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:n})}),t[5]=u.ariaLabel,t[6]=n,t[7]=r):r=t[7];let i;t[8]===u.tooltip?i=t[9]:(i=(0,Q.jsx)(j,{children:u.tooltip}),t[8]=u.tooltip,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,Q.jsxs)(T,{children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let p=`size-4 ${u.iconClass}`,m;t[13]!==d||t[14]!==p?(m=(0,Q.jsx)(d,{className:p}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==u.ariaLabel||t[17]!==u.variant||t[18]!==m?(h=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(w,{asChild:!0,children:(0,Q.jsx)(X,{variant:u.variant,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:m})})}),t[16]=u.ariaLabel,t[17]=u.variant,t[18]=m,t[19]=h):h=t[19];let g;t[20]===u.tooltip?g=t[21]:(g=(0,Q.jsx)(j,{children:u.tooltip}),t[20]=u.tooltip,t[21]=g);let _;t[22]!==h||t[23]!==g?(_=(0,Q.jsxs)(T,{children:[h,g]}),t[22]=h,t[23]=g,t[24]=_):_=t[24];let v;t[25]===u.label?v=t[26]:(v=(0,Q.jsx)(O,{children:u.label}),t[25]=u.label,t[26]=v);let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(I,{}),t[27]=y):y=t[27];let b;t[28]!==a||t[29]!==r||t[30]!==n?(b=n===`uncontrolled`&&a&&(0,Q.jsxs)(C,{onClick:()=>a(r),children:[(0,Q.jsx)(f,{className:`size-4`}),`Claim control`]}),t[28]=a,t[29]=r,t[30]=n,t[31]=b):b=t[31];let S;t[32]!==o||t[33]!==r||t[34]!==n?(S=n===`controller`&&o&&(0,Q.jsxs)(C,{onClick:()=>o(r),children:[(0,Q.jsx)(f,{className:`size-4`}),`Release control`]}),t[32]=o,t[33]=r,t[34]=n,t[35]=S):S=t[35];let D;t[36]!==s||t[37]!==r||t[38]!==n?(D=n===`observer`&&s&&(0,Q.jsxs)(C,{onClick:()=>s(r),children:[(0,Q.jsx)(ot,{className:`size-4`}),`Request control`]}),t[36]=s,t[37]=r,t[38]=n,t[39]=D):D=t[39];let k;t[40]!==c||t[41]!==i||t[42]!==r||t[43]!==n?(k=n===`takeover_controller`&&c&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(C,{onClick:()=>c(r,i,`approve`),children:[(0,Q.jsx)(f,{className:`size-4 text-green-600`}),`Approve`]}),(0,Q.jsxs)(C,{variant:`destructive`,onClick:()=>c(r,i,`deny`),children:[(0,Q.jsx)(f,{className:`size-4`}),`Deny`]})]}),t[40]=c,t[41]=i,t[42]=r,t[43]=n,t[44]=k):k=t[44];let A;t[45]!==S||t[46]!==D||t[47]!==k||t[48]!==v||t[49]!==b?(A=(0,Q.jsxs)(P,{align:`end`,sideOffset:4,className:`w-56`,children:[v,y,b,S,D,k]}),t[45]=S,t[46]=D,t[47]=k,t[48]=v,t[49]=b,t[50]=A):A=t[50];let M;return t[51]!==A||t[52]!==_?(M=(0,Q.jsxs)(x,{children:[_,A]}),t[51]=A,t[52]=_,t[53]=M):M=t[53],M}function Kt(e,t){return!e||e===`uncontrolled`?`uncontrolled`:e===`grace`?`grace`:e===`takeover_requested`?t?`takeover_controller`:`takeover_requester`:e===`controlled`?t?`controller`:`observer`:`uncontrolled`}function qt(e){var t;let n=(0,$.c)(110),{session:r,preconfigs:i,models:a,usage:o,modelName:s,onChangePreconfig:c,onChangeModel:l,onChangeVariant:u,onRename:d,onNavigateBack:f,isStreaming:p,onInterrupt:m,onCompact:h,isCompacting:g,canCompact:_,selectedVariant:v,variants:y,onClaimControl:x,onReleaseControl:C,onRequestTakeover:w,onRespondTakeover:D}=e,[O,A]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(r.title||``),P=(0,Z.useRef)(null),I=S(),L=z(),R;n[0]===r.id?R=n[1]:(R=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=R);let B=we(R),U=fe(Jt),W=(B==null?void 0:B.status)===`controlled`||(B==null?void 0:B.status)===`takeover_requested`,ee=W&&B.controllerClientId===U,G=W&&B.controllerClientId!==U,K=B==null?void 0:B.status,te;n[2]!==ee||n[3]!==K?(te=Kt(K,ee),n[2]=ee,n[3]=K,n[4]=te):te=n[4];let ne=te,re,ie;n[5]===O?(re=n[6],ie=n[7]):(re=()=>{O&&P.current&&(P.current.focus(),P.current.select())},ie=[O],n[5]=O,n[6]=re,n[7]=ie),(0,Z.useEffect)(re,ie);let q;n[8]===r.title?q=n[9]:(q=()=>{N(r.title||``),A(!0)},n[8]=r.title,n[9]=q);let ae=q,oe;n[10]!==M||n[11]!==d||n[12]!==r.id||n[13]!==r.title?(oe=()=>{let e=M.trim();e&&e!==r.title&&d(r.id,e),A(!1)},n[10]=M,n[11]=d,n[12]=r.id,n[13]=r.title,n[14]=oe):oe=n[14];let J=oe,se;n[15]!==J||n[16]!==r.title?(se=e=>{e.key===`Enter`?J():e.key===`Escape`&&(N(r.title||``),A(!1))},n[15]=J,n[16]=r.title,n[17]=se):se=n[17];let ce=se,le;if(n[18]!==s||n[19]!==i||n[20]!==r.preconfigId||n[21]!==r.selectedModel){var ue;le=r.selectedModel||((ue=i.find(e=>e.id===r.preconfigId))==null?void 0:ue.model)||s,n[18]=s,n[19]=i,n[20]=r.preconfigId,n[21]=r.selectedModel,n[22]=le}else le=n[22];let de=le,pe;if(n[23]!==a||n[24]!==de){let e;n[26]===de?e=n[27]:(e=e=>e.id===de,n[26]=de,n[27]=e),pe=a.find(e),n[23]=a,n[24]=de,n[25]=pe}else pe=n[25];let me=pe,he=me==null?void 0:me.contextWindow,ge;n[28]!==f||n[29]!==r.parentId?(ge=r.parentId&&f&&(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:f,className:`h-7`,children:[(0,Q.jsx)(H,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),n[28]=f,n[29]=r.parentId,n[30]=ge):ge=n[30];let _e;n[31]!==M||n[32]!==ce||n[33]!==ae||n[34]!==J||n[35]!==O||n[36]!==r.title?(_e=O?(0,Q.jsx)(`input`,{ref:P,type:`text`,value:M,onChange:e=>N(e.target.value),onBlur:J,onKeyDown:ce,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:ae,children:r.title||`Untitled Session`}),n[31]=M,n[32]=ce,n[33]=ae,n[34]=J,n[35]=O,n[36]=r.title,n[37]=_e):_e=n[37];let ve;n[38]!==he||n[39]!==I||n[40]!==s||n[41]!==o.completionTokens||n[42]!==o.promptTokens||n[43]!==o.totalTokens?(ve=(0,Q.jsx)(It,{promptTokens:o.promptTokens,completionTokens:o.completionTokens,totalTokens:o.totalTokens,contextWindow:he,modelName:s,compact:I}),n[38]=he,n[39]=I,n[40]=s,n[41]=o.completionTokens,n[42]=o.promptTokens,n[43]=o.totalTokens,n[44]=ve):ve=n[44];let ye;n[45]===r.status?ye=n[46]:(ye=r.status===`closed`&&(0,Q.jsxs)(F,{variant:`secondary`,children:[(0,Q.jsx)(V,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]}),n[45]=r.status,n[46]=ye);let be;n[47]!==ge||n[48]!==_e||n[49]!==ve||n[50]!==ye?(be=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[ge,_e,ve,ye]}),n[47]=ge,n[48]=_e,n[49]=ve,n[50]=ye,n[51]=be):be=n[51];let xe;n[52]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Q.jsx)(b,{className:`md:hidden`}),n[52]=xe):xe=n[52];let Se=r.status===`closed`||!!r.parentId||G,Ce;n[53]!==L||n[54]!==I||n[55]!==a||n[56]!==l||n[57]!==de||n[58]!==Se?(Ce=(0,Q.jsx)(Rt,{models:a,selectedModelId:de,onChangeModel:l,disabled:Se,iconOnly:I,compact:L}),n[53]=L,n[54]=I,n[55]=a,n[56]=l,n[57]=de,n[58]=Se,n[59]=Ce):Ce=n[59];let Te=r.status===`closed`||!!r.parentId||G,Ee;n[60]!==L||n[61]!==I||n[62]!==u||n[63]!==v||n[64]!==Te||n[65]!==y?(Ee=(0,Q.jsx)(Ht,{variants:y,selectedVariant:v,onChangeVariant:u,disabled:Te,iconOnly:I,compact:L}),n[60]=L,n[61]=I,n[62]=u,n[63]=v,n[64]=Te,n[65]=y,n[66]=Ee):Ee=n[66];let De=r.status===`closed`||!!r.parentId||G,Oe;n[67]!==L||n[68]!==I||n[69]!==c||n[70]!==i||n[71]!==r.preconfigId||n[72]!==De?(Oe=(0,Q.jsx)(Ut,{preconfigs:i,selectedPreconfigId:r.preconfigId,onChangePreconfig:c,disabled:De,iconOnly:I,compact:L}),n[67]=L,n[68]=I,n[69]=c,n[70]=i,n[71]=r.preconfigId,n[72]=De,n[73]=Oe):Oe=n[73];let ke;n[74]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(b,{orientation:`vertical`,className:`hidden md:block`}),n[74]=ke):ke=n[74];let Ae;if(n[75]!==(B==null||(t=B.pendingTakeover)==null?void 0:t.requestedByClientId)||n[76]!==ne||n[77]!==U||n[78]!==x||n[79]!==C||n[80]!==w||n[81]!==D||n[82]!==r.id){var je,Ne;Ae=U&&(0,Q.jsx)(Gt,{uiState:ne,sessionId:r.id,pendingRequesterClientId:B==null||(je=B.pendingTakeover)==null?void 0:je.requestedByClientId,onClaimControl:x,onReleaseControl:C,onRequestTakeover:w,onRespondTakeover:D}),n[75]=B==null||(Ne=B.pendingTakeover)==null?void 0:Ne.requestedByClientId,n[76]=ne,n[77]=U,n[78]=x,n[79]=C,n[80]=w,n[81]=D,n[82]=r.id,n[83]=Ae}else Ae=n[83];let Pe;n[84]!==_||n[85]!==g||n[86]!==p||n[87]!==h?(Pe=h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(T,{children:[(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:h,disabled:p||g||!_,children:(0,Q.jsx)(lt,{className:`size-4`})})}),(0,Q.jsx)(j,{children:g?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(b,{orientation:`vertical`,className:`hidden md:block`})]}),n[84]=_,n[85]=g,n[86]=p,n[87]=h,n[88]=Pe):Pe=n[88];let Fe=p?`destructive`:`ghost`,Ie=`h-8 w-8 p-0 hover:bg-accent${p?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,Le=!m||G,Re;n[89]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,Q.jsx)(Me,{className:`size-4`}),n[89]=Re):Re=n[89];let ze;n[90]!==m||n[91]!==Fe||n[92]!==Ie||n[93]!==Le?(ze=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:Fe,size:`sm`,className:Ie,onClick:m,disabled:Le,children:Re})}),n[90]=m,n[91]=Fe,n[92]=Ie,n[93]=Le,n[94]=ze):ze=n[94];let Be=p?`Interrupt operation`:`Interrupt`,Ve;n[95]===Be?Ve=n[96]:(Ve=(0,Q.jsx)(j,{children:Be}),n[95]=Be,n[96]=Ve);let He;n[97]!==ze||n[98]!==Ve?(He=(0,Q.jsxs)(T,{children:[ze,Ve]}),n[97]=ze,n[98]=Ve,n[99]=He):He=n[99];let Y;n[100]!==Ce||n[101]!==Ee||n[102]!==Oe||n[103]!==Ae||n[104]!==Pe||n[105]!==He?(Y=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[Ce,Ee,Oe,ke,Ae,Pe,He]}),n[100]=Ce,n[101]=Ee,n[102]=Oe,n[103]=Ae,n[104]=Pe,n[105]=He,n[106]=Y):Y=n[106];let Ue;return n[107]!==be||n[108]!==Y?(Ue=(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:[be,xe,Y]})})}),n[107]=be,n[108]=Y,n[109]=Ue):Ue=n[109],Ue}function Jt(e){return e.clientId}function Yt(e){let t=(0,$.c)(25),{prompts:n,query:r,selectedIndex:i,onSelect:a}=e,o,s,c,l;if(t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[8]===r?e=t[9]:(e=e=>e.name.toLowerCase().includes(r.toLowerCase()),t[8]=r,t[9]=e),o=n.filter(e),o.length===0){let e;t[10]===r?e=t[11]:(e=(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,r,`"`]}),t[10]=r,t[11]=e),l=e;break bb0}s=`p-1`;let u;t[12]!==a||t[13]!==i?(u=(e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>a(e),className:Y(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===i&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(ct,{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),t[12]=a,t[13]=i,t[14]=u):u=t[14],c=o.map(u)}t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=o.length===1?``:`s`,d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),t[15]=d):d=t[15];let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),t[16]=f):f=t[16];let p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),t[17]=p):p=t[17];let m;t[18]!==o.length||t[19]!==u?(m=(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[o.length,` prompt`,u,` •`,d,` navigate`,f,` select`,p,` close`]}),t[18]=o.length,t[19]=u,t[20]=m):m=t[20];let h;return t[21]!==s||t[22]!==c||t[23]!==m?(h=(0,Q.jsxs)(`div`,{className:s,children:[c,m]}),t[21]=s,t[22]=c,t[23]=m,t[24]=h):h=t[24],h}function Xt(e){let t=(0,$.c)(26),{id:n,kind:r,filename:i,size:a,previewUrl:o,isUploading:s,onRemove:c}=e,l=s&&`opacity-50`,u;t[0]===l?u=t[1]:(u=Y(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,l),t[0]=l,t[1]=u);let d;t[2]!==i||t[3]!==r||t[4]!==o?(d=r===`image`&&o?(0,Q.jsx)(`img`,{src:o,alt:i,className:`size-8 rounded object-cover shrink-0`}):r===`image`?(0,Q.jsx)(st,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(De,{className:`size-4 text-muted-foreground shrink-0`}),t[2]=i,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f;t[6]===i?f=t[7]:(f=(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:i}),t[6]=i,t[7]=f);let p;t[8]===a?p=t[9]:(p=Zt(a),t[8]=a,t[9]=p);let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==n||t[16]!==c?(g=()=>c(n),t[15]=n,t[16]=c,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Le,{className:`size-3 text-muted-foreground`}),t[18]=_):_=t[18];let v;t[19]===g?v=t[20]:(v=(0,Q.jsx)(`button`,{type:`button`,onClick:g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:_}),t[19]=g,t[20]=v);let y;return t[21]!==v||t[22]!==u||t[23]!==d||t[24]!==h?(y=(0,Q.jsxs)(`div`,{className:u,children:[d,h,v]}),t[21]=v,t[22]=u,t[23]=d,t[24]=h,t[25]=y):y=t[25],y}function Zt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Qt(e){let t=(0,$.c)(28),{path:n,onRemove:r,onPreview:i}=e,a;t[0]===n?a=t[1]:(a=n.split(`/`).pop()||n,t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n.slice(0,n.lastIndexOf(`/`)+1),t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(De,{className:`size-4 text-primary shrink-0`}),t[4]=l):l=t[4];let u;t[5]!==i||t[6]!==n?(u=()=>i==null?void 0:i(n),t[5]=i,t[6]=n,t[7]=u):u=t[7];let d;t[8]===c?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:c}),t[8]=c,t[9]=d);let f;t[10]===o?f=t[11]:(f=(0,Q.jsx)(`span`,{children:o}),t[10]=o,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`min-w-0 flex-1 text-left cursor-pointer`,children:p}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let h;t[18]!==r||t[19]!==n?(h=()=>r(n),t[18]=r,t[19]=n,t[20]=h):h=t[20];let g=`Remove ${o}`,_;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Le,{className:`size-3 text-muted-foreground`}),t[21]=_):_=t[21];let v;t[22]!==g||t[23]!==h?(v=(0,Q.jsx)(`button`,{type:`button`,onClick:h,"aria-label":g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:_}),t[22]=g,t[23]=h,t[24]=v):v=t[24];let y;return t[25]!==v||t[26]!==m?(y=(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:[l,m,v]}),t[25]=v,t[26]=m,t[27]=y):y=t[27],y}var $t={off:{icon:dt,iconClass:`text-muted-foreground/60`,tooltip:`Auto-approve: Off`,label:`Always ask for approval.`,ariaLabel:`Auto-approve: off`},none:{icon:f,iconClass:`text-muted-foreground`,tooltip:`Auto-approve: None`,label:`Auto-approve permissions with none risk.`,ariaLabel:`Auto-approve: none risk`},low:{icon:me,iconClass:`text-success`,tooltip:`Auto-approve: Low`,label:`Auto-approve permissions with low risk and below.`,ariaLabel:`Auto-approve: low risk and below`},medium:{icon:me,iconClass:`text-warning`,tooltip:`Auto-approve: Medium`,label:`Auto-approve permissions with medium risk and below.`,ariaLabel:`Auto-approve: medium risk and below`},high:{icon:Se,iconClass:`text-destructive`,tooltip:`Auto-approve: High`,label:`Auto-approve permissions with high risk and below.`,ariaLabel:`Auto-approve: high risk and below`}},en=[`off`,`none`,`low`,`medium`,`high`];function tn(e){switch(e){case`off`:return``;case`none`:return`text-muted-foreground`;case`low`:return`text-success`;case`medium`:return`text-warning`;case`high`:return`text-destructive`}}function nn(e){var t;let n=(0,$.c)(35),{sessionId:r,disabled:i}=e,a=g(an),o=g(rn),s=(t=a[r])==null?`low`:t,c=$t[s],l=c.icon;if(i){let e=`size-4 ${c.iconClass}`,t;n[0]!==l||n[1]!==e?(t=(0,Q.jsx)(l,{className:e}),n[0]=l,n[1]=e,n[2]=t):t=n[2];let r;n[3]!==c.ariaLabel||n[4]!==t?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,disabled:!0,"aria-label":c.ariaLabel,children:t})}),n[3]=c.ariaLabel,n[4]=t,n[5]=r):r=n[5];let i;n[6]===c.tooltip?i=n[7]:(i=(0,Q.jsx)(j,{children:c.tooltip}),n[6]=c.tooltip,n[7]=i);let a;return n[8]!==r||n[9]!==i?(a=(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(T,{children:[r,i]})}),n[8]=r,n[9]=i,n[10]=a):a=n[10],a}let u=`size-4 ${c.iconClass}`,d;n[11]!==l||n[12]!==u?(d=(0,Q.jsx)(l,{className:u}),n[11]=l,n[12]=u,n[13]=d):d=n[13];let f;n[14]!==c.ariaLabel||n[15]!==d?(f=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(w,{asChild:!0,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":c.ariaLabel,children:d})})}),n[14]=c.ariaLabel,n[15]=d,n[16]=f):f=n[16];let p;n[17]===c.tooltip?p=n[18]:(p=(0,Q.jsx)(j,{children:c.tooltip}),n[17]=c.tooltip,n[18]=p);let m;n[19]!==f||n[20]!==p?(m=(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(T,{children:[f,p]})}),n[19]=f,n[20]=p,n[21]=m):m=n[21];let h;n[22]===c.label?h=n[23]:(h=(0,Q.jsx)(O,{children:c.label}),n[22]=c.label,n[23]=h);let _;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(I,{}),n[24]=_):_=n[24];let v;n[25]!==s||n[26]!==r||n[27]!==o?(v=en.map(e=>{let t=$t[e],n=t.icon;return(0,Q.jsxs)(C,{onClick:()=>o(r,e),className:e===s?`bg-accent`:``,children:[(0,Q.jsx)(n,{className:`size-4 ${tn(e)}`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:t.label})]},e)}),n[25]=s,n[26]=r,n[27]=o,n[28]=v):v=n[28];let y;n[29]!==h||n[30]!==v?(y=(0,Q.jsxs)(P,{align:`end`,sideOffset:4,className:`w-56`,children:[h,_,v]}),n[29]=h,n[30]=v,n[31]=y):y=n[31];let b;return n[32]!==m||n[33]!==y?(b=(0,Q.jsxs)(x,{children:[m,y]}),n[32]=m,n[33]=y,n[34]=b):b=n[34],b}function rn(e){return e.setAutoApproveMaxSeverity}function an(e){return e.autoApproveBySession}function on(e){let t=(0,$.c)(3),{debounceMs:n}=e,[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s=cn,c=sn,l;return t[0]!==r||t[1]!==a?(l={query:r,setQuery:i,showAutocomplete:a,setShowAutocomplete:o,handleFileSelect:s,insertMention:c},t[0]=r,t[1]=a,t[2]=l):l=t[2],l}function sn(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}}function cn(e){return{type:`file`,path:e.path,display:e.name}}function ln(e){let t=/@([^\s@]+)/g,n=new Set,r=[],i;for(;(i=t.exec(e))!==null;){let e=i[1];n.has(e)||(n.add(e),r.push({type:`file`,path:e,display:e.split(`/`).pop()||e}))}return r}function un(e){return`${y}${e}`}function dn(e,t){if(!(typeof window>`u`))try{localStorage.setItem(un(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function fn(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(un(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(un(e)),``):n.text}catch{return``}}function pn(e){if(!(typeof window>`u`))try{localStorage.removeItem(un(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function mn(){o()}function hn(e){let t=(0,$.c)(12),[n,r]=(0,Z.useState)(``),i=(0,Z.useRef)(void 0),a=(0,Z.useRef)(``),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0],(0,Z.useEffect)(gn,o);let s;t[1]===e?s=t[2]:(s=t=>{r(t),a.current=t,e!==void 0&&(t===``?pn(e):dn(e,t))},t[1]=e,t[2]=s);let c=s,l;t[3]===e?l=t[4]:(l=()=>{r(``),a.current=``,e!==void 0&&pn(e)},t[3]=e,t[4]=l);let u=l,d,f;t[5]===e?(d=t[6],f=t[7]):(d=()=>{let t=i.current;if(t!==void 0&&t!==e){let e=a.current;e!==``&&dn(t,e)}if(e!==void 0){let t=fn(e);a.current=t,r(t)}else a.current=``,r(``);i.current=e},f=[e],t[5]=e,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p;return t[8]!==u||t[9]!==n||t[10]!==c?(p={input:n,setInput:c,clearInput:u},t[8]=u,t[9]=n,t[10]=c,t[11]=p):p=t[11],p}function gn(){mn()}function _n(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function vn(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 yn=(0,Z.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:o,prompts:s=[],sessionId:c,modelSupportsImage:l},u){let{input:d,setInput:f,clearInput:p}=hn(c),[m,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)([]),[b,x]=(0,Z.useState)(0),[S,C]=(0,Z.useState)(`none`),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)(!1),N=(0,Z.useRef)(null),P=(0,Z.useRef)(null);(0,Z.useImperativeHandle)(u,()=>({focus:()=>{var e;return(e=N.current)==null?void 0:e.focus()}}),[]);let{query:F,setQuery:I,showAutocomplete:L,setShowAutocomplete:R,handleFileSelect:z,insertMention:B}=on({workspaceId:a||``}),V=(0,Z.useMemo)(()=>ln(d),[d]),H=g(e=>e.openFilePreview),U=h(e=>e.activeWorkspace);(0,Z.useEffect)(()=>{x(0),T(null)},[v,E,s]),(0,Z.useEffect)(()=>{let e=N.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[d]);let W=s.filter(e=>e.name.toLowerCase().includes(E.toLowerCase())),G=S===`prompts`&&s.length>0,K=S===`files`&&L&&!!a,te=(0,Z.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;f(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(` `)){D(i),C(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){I(e),R(!0),C(`files`);return}}C(`none`),R(!1)},[I,R,f]),re=(0,Z.useCallback)(e=>{let t=B(d,m,z(e));f(t.text),C(`none`),R(!1),y([]),setTimeout(()=>{N.current&&(N.current.focus(),N.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[d,m,z,B,R,f]),ie=(0,Z.useCallback)(e=>{let t=d.lastIndexOf(`/`,m),n=d.slice(0,t),r=d.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;f(o),C(`none`),setTimeout(()=>{N.current&&(N.current.focus(),N.current.setSelectionRange(s,s))},0)},[d,m,f]),ae=(0,Z.useCallback)(()=>{for(let e of O)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);A([]),p()},[O,p]),J=(0,Z.useCallback)(async e=>{if(!o||!c)return null;try{let t=await(o==null?void 0:o.http.attachments.upload(c,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}},[o,c]),se=(0,Z.useCallback)(e=>{A(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),ce=(0,Z.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);f(d.replace(n,``).replace(/\s+/g,` `).trim())},[d,f]),le=(0,Z.useCallback)(e=>{U!=null&&U.id&&H({workspaceId:U.id,path:e,name:e.split(`/`).pop()||e})},[U==null?void 0:U.id,H]),ue=(0,Z.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};A(e=>[...e,n]);let r=await J(e);A(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))}},[J]),de=(0,Z.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),ue(n))},[ue]),fe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),M(!0)},[]),pe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),M(!1)},[]),me=(0,Z.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),M(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&ue(n)},[ue]),he=async n=>{n==null||n.preventDefault();let r=d.trim();if(!r&&O.length===0||t)return;let i=vn(d);if(i){let t=s.find(e=>e.name===i.command);if(t){let n=_n(t,i.rest),r=O.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),ae();return}}let a=O.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),ae()},ge=e=>{if(!e.nativeEvent.isComposing){if(G&&W.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,W.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),W[b]&&ie(W[b]);return;case`Tab`:e.preventDefault(),W[b]&&ie(W[b]);return;case`Escape`:e.preventDefault(),C(`none`);return}if(K&&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]&&re(v[b]);return;case`ArrowRight`:e.preventDefault(),T(b);return;case`ArrowLeft`:e.preventDefault(),T(null);return;case`Escape`:e.preventDefault(),R(!1),C(`none`),T(null);return;case`Tab`:e.preventDefault(),v[b]&&re(v[b]),T(null);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())}},_e=(0,Z.useCallback)(e=>{y(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-background`,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)(X,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(Me,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let ve=d.trim(),ye=O.some(e=>e.isUploading),be=ve||O.length>0,Se=!be||t||ye;return(0,Q.jsx)(`form`,{onSubmit:he,onDragOver:fe,onDragLeave:pe,onDrop:me,className:Y(`px-4 pt-2 pb-3 bg-background`,j&&`ring-2 ring-primary`),children:(0,Q.jsxs)(`div`,{className:Y(`rounded-xl bg-input/30 overflow-hidden`,`focus-within:ring-1 focus-within:ring-ring/40`,`transition-shadow`,`border border-border`,j&&`ring-2 ring-primary border-primary`),children:[(O.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-3`,children:O.map(e=>(0,Q.jsx)(Xt,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:se},e.id))}),O.length>0&&l===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 pt-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(Pe,{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.`})]}),V.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-2`,children:V.map(e=>(0,Q.jsx)(Qt,{path:e.path,onRemove:ce,onPreview:le},e.path))}),(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(oe,{open:G||K,onOpenChange:e=>{e||(C(`none`),R(!1),T(null))},children:[(0,Q.jsx)(ne,{asChild:!0,children:(0,Q.jsx)(ee,{ref:N,value:d,onChange:te,onKeyDown:ge,onPaste:de,placeholder:i,disabled:t,className:Y(`min-h-[52px] max-h-[200px] resize-none border-0 bg-transparent dark:bg-transparent shadow-none`,`px-3 pt-3 pb-0 chat-input-scrollbar`,`focus-visible:ring-0 focus-visible:shadow-none`,`placeholder:text-muted-foreground/60`,`disabled:bg-transparent disabled:opacity-100 dark:disabled:bg-transparent`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(q,{className:Y(`p-0`,K?`w-96`:`w-72`),align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:K?(0,Q.jsx)(k,{children:(0,Q.jsx)(xe,{workspaceId:a||``,searchQuery:F,selectedIndex:b,tooltipIndex:w,onTooltipIndexChange:T,onSelect:re,onFilesChange:_e,sdkClient:o})}):(0,Q.jsx)(Yt,{prompts:s,query:E,selectedIndex:b,onSelect:ie})})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-2 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-8 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=P.current)==null?void 0:e.click()},disabled:t,"aria-label":`Attach file`,children:(0,Q.jsx)(ut,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:P,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&ue(e.target.files),e.target.value=``}}),c&&(0,Q.jsx)(nn,{sessionId:c,disabled:t})]}),(0,Q.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1 text-xs text-muted-foreground`,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-1`,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-1`,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-1`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`⇧ Enter`}),(0,Q.jsx)(`span`,{children:`new line`})]}),(0,Q.jsx)(X,{type:`submit`,disabled:Se,size:`icon`,className:Y(`size-8 rounded-full`,be&&!t?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground`),"aria-label":`Send message`,children:(0,Q.jsx)(Ye,{className:`size-4`})})]})]})})});function bn(e){return e.startsWith(`https://`)?`https`:`http`}function xn(e,t){return`${bn(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function Sn(e){let t=(0,$.c)(3),n=(0,Z.useRef)(e),r;t[0]===e?r=t[1]:(r=()=>{n.current=e},t[0]=e,t[1]=r),(0,Z.useLayoutEffect)(r);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(...e)=>{let t=e;return n.current(...t)},t[2]=i):i=t[2],i}var Cn=t(i(),1);function wn(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 Tn(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var En=(e,t)=>Math.abs(e-t)<1.01,Dn=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},On=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},kn=e=>e,An=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},jn=(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(On(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(On(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Mn={passive:!0},Nn=typeof window>`u`?!0:`onscrollend`in window,Pn=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Nn?()=>void 0:Dn(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,Mn);let l=e.options.useScrollendEvent&&Nn;return l&&n.addEventListener(`scrollend`,c,Mn),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Fn=(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`]},In=(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})},Ln=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:kn,rangeExtractor:An,onChange:()=>{},measureElement:Fn,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=wn(()=>(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=wn(()=>[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=wn(()=>[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=wn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?zn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=wn(()=>{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=wn(()=>[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 Tn(t[Rn(0,t.length-1,e=>Tn(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&&En(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()}},Rn=(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 zn({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=Rn(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 Bn=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function Vn({useFlushSync:e=!0,...t}){let n=Z.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Cn.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Z.useState(()=>new Ln(r));return i.setOptions(r),Bn(()=>i._didMount(),[]),Bn(()=>i._willUpdate()),i}function Hn(e){return Vn({observeElementRect:jn,observeElementOffset:Pn,scrollToFn:In,...e})}function Un(e){let t=(0,$.c)(49),{message:n,textContent:r,children:i,isQueued:a,onRemove:o,onRevert:s,canRevert:c,onFork:l,canFork:u,isClearAll:d}=e,f=a===void 0?!1:a,m=c===void 0?!1:c,h=u===void 0?!1:u,g=d===void 0?!1:d,[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=n.role===`user`,w;t[0]===r?w=t[1]:(w=async()=>{let e=r||``;await navigator.clipboard.writeText(e),v(!0),setTimeout(()=>v(!1),2e3)},t[0]=r,t[1]=w);let T=w,E=C?`items-end`:`items-stretch`,D;t[2]===E?D=t[3]:(D=Y(`flex flex-col gap-1 animate-slide-up min-w-0`,E),t[2]=E,t[3]=D);let O=C?`mr-3`:`ml-3`,k;t[4]===O?k=t[5]:(k=Y(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,O),t[4]=O,t[5]=k);let A;t[6]!==h||t[7]!==m||t[8]!==_||t[9]!==T||t[10]!==f||t[11]!==C||t[12]!==n.role||t[13]!==l||t[14]!==s?(A=C?(0,Q.jsxs)(Q.Fragment,{children:[!f&&(0,Q.jsxs)(Q.Fragment,{children:[m&&s&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>b(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(ft,{className:`size-3`})}),h&&l&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(at,{className:`size-3`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:T,className:`size-5 text-muted-foreground hover:text-foreground`,children:_?(0,Q.jsx)(p,{className:`size-3`}):(0,Q.jsx)(se,{className:`size-3`})})]}),(0,Q.jsx)(pe,{className:`size-3`}),n.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xe,{className:`size-3`}),n.role,(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:T,className:`size-5 text-muted-foreground hover:text-foreground`,children:_?(0,Q.jsx)(p,{className:`size-3`}):(0,Q.jsx)(se,{className:`size-3`})})]}),t[6]=h,t[7]=m,t[8]=_,t[9]=T,t[10]=f,t[11]=C,t[12]=n.role,t[13]=l,t[14]=s,t[15]=A):A=t[15];let j;t[16]!==A||t[17]!==k?(j=(0,Q.jsx)(`div`,{className:k,children:A}),t[16]=A,t[17]=k,t[18]=j):j=t[18];let M=C?f?`rounded-2xl px-4 py-3 max-w-[90%] bg-muted text-foreground border-2 border-dashed border-muted-foreground/30 opacity-80 rounded-br-md`:`rounded-2xl px-4 py-3 max-w-[90%] bg-primary text-primary-foreground rounded-br-md`:`w-full overflow-visible`,N;t[19]===M?N=t[20]:(N=Y(`relative group min-w-0 overflow-hidden`,M),t[19]=M,t[20]=N);let P;t[21]!==f||t[22]!==o?(P=f&&(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)(nt,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),o&&(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,onClick:o,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(Le,{className:`size-3`})})]}),t[21]=f,t[22]=o,t[23]=P):P=t[23];let F;t[24]===i?F=t[25]:(F=(0,Q.jsx)(`div`,{className:`min-w-0`,children:i}),t[24]=i,t[25]=F);let I;t[26]!==N||t[27]!==P||t[28]!==F?(I=(0,Q.jsxs)(`div`,{className:N,children:[P,F]}),t[26]=N,t[27]=P,t[28]=F,t[29]=I):I=t[29];let L=g?`Clear Conversation`:`Revert Conversation`,R=g?`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?`,z=g?`Clear All`:`Revert`,B;t[30]===s?B=t[31]:(B=()=>{s==null||s()},t[30]=s,t[31]=B);let V;t[32]!==y||t[33]!==L||t[34]!==R||t[35]!==z||t[36]!==B?(V=(0,Q.jsx)(Ke,{open:y,onOpenChange:b,title:L,description:R,confirmLabel:z,cancelLabel:`Cancel`,onConfirm:B,variant:`destructive`}),t[32]=y,t[33]=L,t[34]=R,t[35]=z,t[36]=B,t[37]=V):V=t[37];let H;t[38]===l?H=t[39]:(H=()=>{l==null||l()},t[38]=l,t[39]=H);let U;t[40]!==x||t[41]!==H?(U=(0,Q.jsx)(Ke,{open:x,onOpenChange:S,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:H}),t[40]=x,t[41]=H,t[42]=U):U=t[42];let W;return t[43]!==j||t[44]!==I||t[45]!==V||t[46]!==U||t[47]!==D?(W=(0,Q.jsxs)(`div`,{className:D,children:[j,I,V,U]}),t[43]=j,t[44]=I,t[45]=V,t[46]=U,t[47]=D,t[48]=W):W=t[48],W}var Wn={rate_limit:{label:`Rate Limited`,description:`Too many requests. Please wait a moment and try again.`,icon:(0,Q.jsx)(nt,{className:`size-3.5`})},server_error:{label:`Server Error`,description:`The AI provider encountered an error. Please try again.`,icon:(0,Q.jsx)(ze,{className:`size-3.5`})},timeout:{label:`Request Timed Out`,description:`The request took too long. Please try again.`,icon:(0,Q.jsx)(nt,{className:`size-3.5`})},authentication:{label:`Authentication Failed`,description:`Check your API key configuration.`,icon:(0,Q.jsx)(le,{className:`size-3.5`})},context_overflow:{label:`Context Overflow`,description:`The conversation is too long. Try compacting or starting a new session.`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`})},invalid_request:{label:`Invalid Request`,description:`The request was rejected by the provider.`,icon:(0,Q.jsx)(Se,{className:`size-3.5`})},unknown:{label:`Error`,description:`An unexpected error occurred.`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`})}};function Gn(e){if(!e)return`unknown`;let t=e.toLowerCase();return t.includes(`rate limit`)||t.includes(`429`)?`rate_limit`:t.includes(`timeout`)||t.includes(`timed out`)?`timeout`:t.includes(`auth`)||t.includes(`api key`)||t.includes(`401`)||t.includes(`403`)?`authentication`:t.includes(`context`)||t.includes(`overflow`)||t.includes(`too long`)||t.includes(`token limit`)?`context_overflow`:t.includes(`invalid request`)||t.includes(`400`)?`invalid_request`:t.includes(`server error`)||t.includes(`500`)||t.includes(`502`)||t.includes(`503`)?`server_error`:`unknown`}function Kn(e){let t=(0,$.c)(19),{message:n}=e,r=Wn[Gn(n.error)],i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Pe,{className:`size-3`}),t[0]=i):i=t[0];let a;t[1]===r.label?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[i,r.label]}),t[1]=r.label,t[2]=a);let o;t[3]===r.icon?o=t[4]:(o=(0,Q.jsx)(`div`,{className:`text-destructive mt-0.5 shrink-0`,children:r.icon}),t[3]=r.icon,t[4]=o);let s=n.error||r.description,c;t[5]===s?c=t[6]:(c=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:s}),t[5]=s,t[6]=c);let l;t[7]!==n.error||t[8]!==r.description?(l=n.error&&n.error!==r.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.description}),t[7]=n.error,t[8]=r.description,t[9]=l):l=t[9];let u;t[10]!==c||t[11]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==o||t[14]!==u?(d=(0,Q.jsx)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[o,u]})}),t[13]=o,t[14]=u,t[15]=d):d=t[15];let f;return t[16]!==a||t[17]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,d]}),t[16]=a,t[17]=d,t[18]=f):f=t[18],f}var qn=ue.oneDark,Jn=ue.oneLight;function Yn(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 Xn=(0,Z.memo)(function(e){let t=(0,$.c)(35),{type:n,content:r,lineNumber:i,newLineNumber:o,language:s,codeTheme:c}=e,{resolvedMode:l}=a(),u=l===`dark`,d=n===`added`&&(u?`bg-green-500/20`:`bg-green-500/15`),f=n===`removed`&&(u?`bg-red-500/20`:`bg-red-500/15`),p=n===`context`&&`bg-muted/30`,m;t[0]!==d||t[1]!==f||t[2]!==p?(m=Y(`flex font-mono text-xs`,d,f,p),t[0]=d,t[1]=f,t[2]=p,t[3]=m):m=t[3];let h=m,g=n===`added`&&(u?`text-green-400`:`text-green-600`),_=n===`removed`&&(u?`text-red-400`:`text-red-600`),v=n===`context`&&`text-muted-foreground/50`,y;t[4]!==g||t[5]!==_||t[6]!==v?(y=Y(`font-bold w-4 select-none`,g,_,v),t[4]=g,t[5]=_,t[6]=v,t[7]=y):y=t[7];let b=y,x=u?`border-white/10`:`border-border`,S;t[8]===x?S=t[9]:(S=Y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,x),t[8]=x,t[9]=S);let C=i==null?``:i,w;t[10]!==S||t[11]!==C?(w=(0,Q.jsx)(`span`,{className:S,children:C}),t[10]=S,t[11]=C,t[12]=w):w=t[12];let T=u?`border-white/10`:`border-border`,E;t[13]===T?E=t[14]:(E=Y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,T),t[13]=T,t[14]=E);let D=o==null?``:o,O;t[15]!==E||t[16]!==D?(O=(0,Q.jsx)(`span`,{className:E,children:D}),t[15]=E,t[16]=D,t[17]=O):O=t[17];let k=n===`added`&&`+`,A=n===`removed`&&`-`,j=n===`context`&&` `,M;t[18]!==b||t[19]!==k||t[20]!==A||t[21]!==j?(M=(0,Q.jsxs)(`span`,{className:b,children:[k,A,j]}),t[18]=b,t[19]=k,t[20]=A,t[21]=j,t[22]=M):M=t[22];let N;t[23]!==c||t[24]!==r||t[25]!==s?(N=(0,Q.jsx)(_e,{theme:c,code:r,language:s,children:Qn}),t[23]=c,t[24]=r,t[25]=s,t[26]=N):N=t[26];let P;t[27]!==M||t[28]!==N?(P=(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden flex`,children:[M,N]}),t[27]=M,t[28]=N,t[29]=P):P=t[29];let F;return t[30]!==w||t[31]!==O||t[32]!==P||t[33]!==h?(F=(0,Q.jsxs)(`div`,{className:h,children:[w,O,P]}),t[30]=w,t[31]=O,t[32]=P,t[33]=h,t[34]=F):F=t[34],F}),Zn=(0,Z.memo)(function(e){let t=(0,$.c)(35),{hunks:n,path:r,language:i,additions:o,deletions:s}=e,[c,l]=(0,Z.useState)(!0),u;t[0]!==r||t[1]!==i?(u=i||Yn(r),t[0]=r,t[1]=i,t[2]=u):u=t[2];let d=u,f=g($n),p=h(er),{resolvedMode:m}=a(),_=m===`dark`,v=_?qn:Jn,y;t[3]!==p||t[4]!==f||t[5]!==r?(y=()=>{p&&f({workspaceId:p.id,path:r,name:r.split(`/`).pop()||r})},t[3]=p,t[4]=f,t[5]=r,t[6]=y):y=t[6];let b=y,x;t[7]===c?x=t[8]:(x=()=>l(!c),t[7]=c,t[8]=x);let S;t[9]===c?S=t[10]:(S=c?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[9]=c,t[10]=S);let C;t[11]!==x||t[12]!==S?(C=(0,Q.jsx)(`button`,{onClick:x,className:`px-1 py-1 hover:bg-muted rounded`,children:S}),t[11]=x,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Ae,{className:`size-3`}),t[14]=w):w=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(ke,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[15]=T):T=t[15];let E;t[16]!==b||t[17]!==r?(E=(0,Q.jsxs)(`button`,{type:`button`,onClick:b,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 min-w-0 truncate`,title:r,children:[r,T]}),t[16]=b,t[17]=r,t[18]=E):E=t[18];let D;t[19]!==o||t[20]!==s?(D=o!==void 0&&s!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,o,` -`,s]}),t[19]=o,t[20]=s,t[21]=D):D=t[21];let O;t[22]!==C||t[23]!==E||t[24]!==D?(O=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[C,w,E,D]}),t[22]=C,t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==v||t[27]!==c||t[28]!==n||t[29]!==_||t[30]!==d?(k=c&&(0,Q.jsx)(`div`,{style:{backgroundColor:v.plain.backgroundColor||(_?`#282c34`:`#fafafa`)},children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:Y(`divide-y`,_?`divide-white/5`:`divide-border`),children:e.changes.map((e,t)=>(0,Q.jsx)(Xn,{...e,language:d,codeTheme:v},t))},t))}),t[26]=v,t[27]=c,t[28]=n,t[29]=_,t[30]=d,t[31]=k):k=t[31];let A;return t[32]!==O||t[33]!==k?(A=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[O,k]})}),t[32]=O,t[33]=k,t[34]=A):A=t[34],A});function Qn(e){let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:t.map((e,t)=>(0,Q.jsx)(`span`,{children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))},t))})}function $n(e){return e.openFilePreview}function er(e){return e.activeWorkspace}var tr=ue.oneDark,nr=ue.oneLight,rr=20;function ir(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 ar=(0,Z.memo)(e=>{let t=(0,$.c)(52),{content:n,path:r,language:i,created:o,highlightLines:s}=e,c;t[0]===s?c=t[1]:(c=s===void 0?[]:s,t[0]=s,t[1]=c);let l=c,[u,d]=(0,Z.useState)(!1),f=g(or),m=h(sr),{resolvedMode:_}=a(),v=_===`dark`,y=v?tr:nr,b;t[2]!==m||t[3]!==f||t[4]!==r?(b=()=>{m&&f({workspaceId:m.id,path:r,name:r.split(`/`).pop()||r})},t[2]=m,t[3]=f,t[4]=r,t[5]=b):b=t[5];let x=b,S;t[6]!==i||t[7]!==r?(S=i||ir(r),t[6]=i,t[7]=r,t[8]=S):S=t[8];let C=S,w;t[9]===l?w=t[10]:(w=new Set(l),t[9]=l,t[10]=w);let T=w,E;t[11]===n?E=t[12]:(E=n.split(`
7
+ `),t[11]=n,t[12]=E);let D=E.length,O;t[13]===u?O=t[14]:(O=()=>d(!u),t[13]=u,t[14]=O);let k;t[15]===u?k=t[16]:(k=u?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[15]=u,t[16]=k);let A;t[17]!==O||t[18]!==k?(A=(0,Q.jsx)(`button`,{onClick:O,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:k}),t[17]=O,t[18]=k,t[19]=A):A=t[19];let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Ae,{className:`size-3`}),t[20]=j):j=t[20];let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(ke,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[21]=N):N=t[21];let P;t[22]!==x||t[23]!==r?(P=(0,Q.jsxs)(`button`,{type:`button`,onClick:x,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 min-w-0 truncate`,title:r,children:[r,N]}),t[22]=x,t[23]=r,t[24]=P):P=t[24];let F;t[25]!==u||t[26]!==D?(F=!u&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[D,` lines`]}),t[25]=u,t[26]=D,t[27]=F):F=t[27];let I;t[28]===o?I=t[29]:(I=o===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(Oe,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(p,{className:`size-3`}),`Created`]}),t[28]=o,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I||t[33]!==A?(L=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[A,j,P,F,I]}),t[30]=P,t[31]=F,t[32]=I,t[33]=A,t[34]=L):L=t[34];let R;t[35]===y.plain.backgroundColor?R=t[36]:(R={backgroundColor:y.plain.backgroundColor},t[35]=y.plain.backgroundColor,t[36]=R);let z;t[37]!==u||t[38]!==T||t[39]!==v?(z=e=>{let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:(u?t:t.slice(0,rr)).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${T.has(t+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:Y(`w-10 text-right pr-2 select-none border-r`,v?`text-muted-foreground border-white/10`:`text-muted-foreground border-border`),children:t+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden`,children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))})]},t))})},t[37]=u,t[38]=T,t[39]=v,t[40]=z):z=t[40];let B;t[41]!==y||t[42]!==n||t[43]!==C||t[44]!==z?(B=(0,Q.jsx)(_e,{theme:y,code:n,language:C,children:z}),t[41]=y,t[42]=n,t[43]=C,t[44]=z,t[45]=B):B=t[45];let V;t[46]!==R||t[47]!==B?(V=(0,Q.jsx)(`div`,{style:R,children:B}),t[46]=R,t[47]=B,t[48]=V):V=t[48];let H;return t[49]!==L||t[50]!==V?(H=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[L,V]})}),t[49]=L,t[50]=V,t[51]=H):H=t[51],H});function or(e){return e.openFilePreview}function sr(e){return e.activeWorkspace}function cr(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Success`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(m,{className:`size-4`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[i,(0,Q.jsx)(`span`,{className:`break-all`,children:r})]}),t[1]=r,t[2]=a),a}var lr={edit:it,plus:Ie,trash:Re,search:ie};function ur(e){let t=(0,$.c)(7),{text:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)},t[0]=n,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(se,{className:`size-3`}),t[2]=r,t[3]=s);let c;return t[4]!==o||t[5]!==s?(c=(0,Q.jsx)(`button`,{onClick:o,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:s}),t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function dr(e){let t=(0,$.c)(16),{title:n,groups:r,files:i,total:a}=e,o;t[0]===i?o=t[1]:(o=i||[],t[0]=i,t[1]=o);let s;t[2]===o?s=t[3]:(s={label:`Files`,files:o,icon:void 0},t[2]=o,t[3]=s);let c=s,l;t[4]!==c||t[5]!==i||t[6]!==r?(l=r||(i?[c]:[]),t[4]=c,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l;if(u.length===0)return null;let d;t[8]!==n||t[9]!==a?(d=n&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n,a!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,a,` files)`]})]}),t[8]=n,t[9]=a,t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=u.map(fr),t[11]=u,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function fr(e,t){return(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=lr[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(pr)})]},t)}function pr(e,t){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(Ae,{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:Y(`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)(ur,{text:e.path})]},t)}function mr(e){let t=(0,$.c)(15),{command:n,stdout:r,stderr:i,exitCode:a}=e,o=a===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[s,(0,Q.jsx)(`span`,{className:`text-foreground`,children:n})]}),t[1]=n,t[2]=c);let l=`text-xs font-mono px-2 py-0.5 rounded ${o?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,u;t[3]!==a||t[4]!==l?(u=(0,Q.jsxs)(`span`,{className:l,children:[`[`,a,`]`]}),t[3]=a,t[4]=l,t[5]=u):u=t[5];let d;t[6]!==c||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==r?(f=(r||i)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[r&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:r}),i&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:i})]}),t[9]=i,t[10]=r,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`visualization-container border border-border rounded-md overflow-hidden`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var hr={pending:{icon:tt,color:`text-muted-foreground`},in_progress:{icon:v,color:`text-warning`,animate:!0},completed:{icon:m,color:`text-success`},cancelled:{icon:d,color:`text-destructive`}},gr={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function _r(e){let t=(0,$.c)(13),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===r?i=t[1]:(i=r.filter(xr),t[0]=r,t[1]=i);let a=i.length;r.filter(br),r.filter(yr);let o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=(n||r.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r.length,`)`]}),a>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[a,` completed`]})]}),t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r.map(vr),t[6]=r,t[7]=s);let c;t[8]===s?c=t[9]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:s}),t[8]=s,t[9]=c);let l;return t[10]!==o||t[11]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[o,c]}),t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function vr(e,t){let n=hr[e.status],r=n.icon,i=gr[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:Y(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:Y(`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:Y(`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)}function yr(e){return e.status===`pending`}function br(e){return e.status===`in_progress`}function xr(e){return e.status===`completed`}var Sr=(0,Z.memo)(function(e){let t=(0,$.c)(38),{visualization:n}=e;if(!n)return null;switch(n.type){case`diff`:{let e;return t[0]!==n.additions||t[1]!==n.deletions||t[2]!==n.hunks||t[3]!==n.language||t[4]!==n.matchInfo||t[5]!==n.path?(e=(0,Q.jsx)(Zn,{path:n.path,hunks:n.hunks,language:n.language,additions:n.additions,deletions:n.deletions,matchInfo:n.matchInfo}),t[0]=n.additions,t[1]=n.deletions,t[2]=n.hunks,t[3]=n.language,t[4]=n.matchInfo,t[5]=n.path,t[6]=e):e=t[6],e}case`diffs`:{let e;t[7]===n.items?e=t[8]:(e=n.items.map(Cr),t[7]=n.items,t[8]=e);let r;return t[9]===e?r=t[10]:(r=(0,Q.jsx)(`div`,{className:`space-y-3`,children:e}),t[9]=e,t[10]=r),r}case`code`:{let e;return t[11]!==n.content||t[12]!==n.created||t[13]!==n.highlightLines||t[14]!==n.language||t[15]!==n.path?(e=(0,Q.jsx)(ar,{path:n.path,content:n.content,language:n.language,created:n.created,highlightLines:n.highlightLines}),t[11]=n.content,t[12]=n.created,t[13]=n.highlightLines,t[14]=n.language,t[15]=n.path,t[16]=e):e=t[16],e}case`file-list`:{let e;return t[17]!==n.files||t[18]!==n.groups||t[19]!==n.title||t[20]!==n.total?(e=(0,Q.jsx)(dr,{title:n.title,groups:n.groups,files:n.files,total:n.total}),t[17]=n.files,t[18]=n.groups,t[19]=n.title,t[20]=n.total,t[21]=e):e=t[21],e}case`table`:{let e;t[22]===n.rows?e=t[23]:(e=JSON.stringify(n.rows,null,2),t[22]=n.rows,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:e}),t[24]=e,t[25]=r),r}case`markdown`:{let e;return t[26]===n.content?e=t[27]:(e=(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:n.content}),t[26]=n.content,t[27]=e),e}case`none`:{let e;return t[28]===n.message?e=t[29]:(e=(0,Q.jsx)(cr,{message:n.message}),t[28]=n.message,t[29]=e),e}case`shell-output`:{let e;return t[30]!==n.command||t[31]!==n.exitCode||t[32]!==n.stderr||t[33]!==n.stdout?(e=(0,Q.jsx)(mr,{command:n.command,stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}),t[30]=n.command,t[31]=n.exitCode,t[32]=n.stderr,t[33]=n.stdout,t[34]=e):e=t[34],e}case`todo-list`:{let e;return t[35]!==n.items||t[36]!==n.title?(e=(0,Q.jsx)(_r,{title:n.title,items:n.items}),t[35]=n.items,t[36]=n.title,t[37]=e):e=t[37],e}default:return null}});function Cr(e,t){return(0,Q.jsx)(Zn,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`)}function wr(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Tt,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(p,{})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Q.jsx)(Ct,{"data-slot":`checkbox`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function Tr(e){let t=(0,$.c)(16),{question:n,onSelect:r}=e,[i,a]=(0,Z.useState)(null),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;if(t[2]!==n.options||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.value),className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${i===e.value?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(`div`,{className:`size-4 rounded-full border-2 flex items-center justify-center transition-colors ${i===e.value?`border-primary bg-primary`:`border-muted-foreground`}`,children:i===e.value&&(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary-foreground`})}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value),t[5]=i,t[6]=e),s=n.options.map(e),t[2]=n.options,t[3]=i,t[4]=s}else s=t[4];let c;t[7]===s?c=t[8]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==r||t[10]!==i?(l=i!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(X,{size:`sm`,onClick:()=>r(i),children:`Confirm`})}),t[9]=r,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function Er(e){let t=(0,$.c)(36),{question:n,onSelect:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;t[1]===n.max?s=t[2]:(s=e=>{o(t=>{let r=new Set(t);if(r.has(e))r.delete(e);else{if(n.max&&r.size>=n.max)return t;r.add(e)}return r})},t[1]=n.max,t[2]=s);let c=s,l;t[3]!==r||t[4]!==n.min||t[5]!==a?(l=()=>{let e=Array.from(a);n.min&&e.length<n.min||r(e)},t[3]=r,t[4]=n.min,t[5]=a,t[6]=l):l=t[6];let u=l,d=!n.min||a.size>=n.min,f=n.max?a.size>=n.max:!1,p;t[7]===n.description?p=t[8]:(p=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[7]=n.description,t[8]=p);let m;if(t[9]!==f||t[10]!==n.options||t[11]!==a||t[12]!==c){let e;t[14]!==f||t[15]!==a||t[16]!==c?(e=e=>{let t=f&&!a.has(e.value);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e.value),disabled:t,className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${t?`border-border opacity-50 cursor-not-allowed`:a.has(e.value)?`border-primary bg-primary/5 hover:bg-primary/10`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(wr,{checked:a.has(e.value),disabled:t,onCheckedChange:()=>c(e.value),className:`pointer-events-none`}),(0,Q.jsx)(`span`,{className:`font-medium pointer-events-none`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value)},t[14]=f,t[15]=a,t[16]=c,t[17]=e):e=t[17],m=n.options.map(e),t[9]=f,t[10]=n.options,t[11]=a,t[12]=c,t[13]=m}else m=t[13];let h;t[18]===m?h=t[19]:(h=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==n.max||t[21]!==n.min?(g=n.min!==void 0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select at least `,n.min,` option`,n.min>1?`s`:``,n.max!==void 0&&` (up to ${n.max})`]}),t[20]=n.max,t[21]=n.min,t[22]=g):g=t[22];let _;t[23]!==n.max||t[24]!==n.min?(_=n.max!==void 0&&!n.min&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select up to `,n.max,` option`,n.max>1?`s`:``]}),t[23]=n.max,t[24]=n.min,t[25]=_):_=t[25];let v=!d,y;t[26]!==u||t[27]!==a.size||t[28]!==v?(y=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(X,{size:`sm`,onClick:u,disabled:v,children:[`Confirm Selection (`,a.size,`)`]})}),t[26]=u,t[27]=a.size,t[28]=v,t[29]=y):y=t[29];let b;return t[30]!==y||t[31]!==p||t[32]!==h||t[33]!==g||t[34]!==_?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p,h,g,_,y]}),t[30]=y,t[31]=p,t[32]=h,t[33]=g,t[34]=_,t[35]=b):b=t[35],b}function Dr(e){let t=(0,$.c)(26),{question:n,onSubmit:r}=e,[i,a]=(0,Z.useState)(n.defaultValue||``),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>a(e.target.value),t[2]=s):s=t[2];let c;t[3]!==n.placeholder||t[4]!==i?(c=(0,Q.jsx)(L,{type:`text`,value:i,onChange:s,placeholder:n.placeholder}),t[3]=n.placeholder,t[4]=i,t[5]=c):c=t[5];let l;t[6]!==r||t[7]!==i?(l=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>r(i),children:`Skip`}),t[6]=r,t[7]=i,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==i?(u=()=>r(i),t[9]=r,t[10]=i,t[11]=u):u=t[11];let d;t[12]===i?d=t[13]:(d=i.trim(),t[12]=i,t[13]=d);let f=d.length===0,p;t[14]!==u||t[15]!==f?(p=(0,Q.jsx)(X,{size:`sm`,onClick:u,disabled:f,children:`Submit`}),t[14]=u,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==l||t[18]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[l,p]}),t[17]=l,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==o||t[24]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,h]}),t[23]=o,t[24]=h,t[25]=g):g=t[25],g}function Or(e){var t;let n=(0,$.c)(22),{question:r,onConfirm:i}=e,a=(t=r.defaultValue)==null?!1:t,[o,s]=(0,Z.useState)(null),c;n[0]===r.description?c=n[1]:(c=r.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.description}),n[0]=r.description,n[1]=c);let l=o===!1?`default`:`outline`,u;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!1),n[2]=u):u=n[2];let d=a?`No`:`Cancel`,f;n[3]!==l||n[4]!==d?(f=(0,Q.jsx)(X,{variant:l,size:`sm`,onClick:u,children:d}),n[3]=l,n[4]=d,n[5]=f):f=n[5];let p=o===!0?`default`:`outline`,m;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>s(!0),n[6]=m):m=n[6];let h=a?`Yes`:`Confirm`,g;n[7]!==p||n[8]!==h?(g=(0,Q.jsx)(X,{variant:p,size:`sm`,onClick:m,children:h}),n[7]=p,n[8]=h,n[9]=g):g=n[9];let _;n[10]!==f||n[11]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[f,g]}),n[10]=f,n[11]=g,n[12]=_):_=n[12];let v;n[13]!==i||n[14]!==o?(v=o!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(X,{size:`sm`,onClick:()=>i(o),children:`Submit`})}),n[13]=i,n[14]=o,n[15]=v):v=n[15];let y;n[16]!==_||n[17]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v]}),n[16]=_,n[17]=v,n[18]=y):y=n[18];let b;return n[19]!==c||n[20]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[c,y]}),n[19]=c,n[20]=y,n[21]=b):b=n[21],b}function kr(e){let t=(0,$.c)(29),{question:n,onSubmit:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;if(t[1]!==a||t[2]!==n.questions){let e;t[4]===a?e=t[5]:(e=(e,t)=>a[t]!==void 0,t[4]=a,t[5]=e),s=n.questions.every(e),t[1]=a,t[2]=n.questions,t[3]=s}else s=t[3];let c=s,l;t[6]!==a||t[7]!==r||t[8]!==n.questions?(l=()=>{r({type:`form`,answers:n.questions.map((e,t)=>({question:e.question,answer:a[t]}))})},t[6]=a,t[7]=r,t[8]=n.questions,t[9]=l):l=t[9];let u=l,d;t[10]===n.description?d=t[11]:(d=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[10]=n.description,t[11]=d);let f;if(t[12]!==n.questions){let e;t[14]===n.questions.length?e=t[15]:(e=(e,t)=>(0,Q.jsxs)(`div`,{className:`border-l-2 border-primary/30 pl-3`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:[`Question `,t+1,` of `,n.questions.length]}),(0,Q.jsx)(Ar,{question:e,onAnswer:e=>o(n=>({...n,[t]:e}))})]},t),t[14]=n.questions.length,t[15]=e),f=n.questions.map(e),t[12]=n.questions,t[13]=f}else f=t[13];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:f}),t[16]=f,t[17]=p);let m=!c,h;t[18]===a?h=t[19]:(h=Object.keys(a),t[18]=a,t[19]=h);let g;t[20]!==u||t[21]!==n.questions.length||t[22]!==m||t[23]!==h.length?(g=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(X,{size:`sm`,onClick:u,disabled:m,children:[`Submit All (`,h.length,`/`,n.questions.length,`)`]})}),t[20]=u,t[21]=n.questions.length,t[22]=m,t[23]=h.length,t[24]=g):g=t[24];let _;return t[25]!==d||t[26]!==p||t[27]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,p,g]}),t[25]=d,t[26]=p,t[27]=g,t[28]=_):_=t[28],_}function Ar(e){let t=(0,$.c)(61),{question:n,onAnswer:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),[s,c]=(0,Z.useState)(null);switch(n.type){case`single_select`:{let e;t[1]===n.question?e=t[2]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[1]=n.question,t[2]=e);let i;if(t[3]!==r||t[4]!==n.options||t[5]!==a){let e;t[7]!==r||t[8]!==a?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{o(new Set([e.value])),r(e.value)},className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[7]=r,t[8]=a,t[9]=e):e=t[9],i=n.options.map(e),t[3]=r,t[4]=n.options,t[5]=a,t[6]=i}else i=t[6];let s;t[10]===i?s=t[11]:(s=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i}),t[10]=i,t[11]=s);let c;return t[12]!==e||t[13]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,s]}),t[12]=e,t[13]=s,t[14]=c):c=t[14],c}case`multi_select`:{let e;t[15]!==r||t[16]!==n.max?(e=e=>{o(t=>{let i=new Set(t);if(i.has(e))i.delete(e);else if(!n.max||i.size<n.max)i.add(e);else return t;return r(Array.from(i)),i})},t[15]=r,t[16]=n.max,t[17]=e):e=t[17];let i=e,s;t[18]===n.question?s=t[19]:(s=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[18]=n.question,t[19]=s);let c;if(t[20]!==n.options||t[21]!==a||t[22]!==i){let e;t[24]!==a||t[25]!==i?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[24]=a,t[25]=i,t[26]=e):e=t[26],c=n.options.map(e),t[20]=n.options,t[21]=a,t[22]=i,t[23]=c}else c=t[23];let l;t[27]===c?l=t[28]:(l=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c}),t[27]=c,t[28]=l);let u;return t[29]!==s||t[30]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s,l]}),t[29]=s,t[30]=l,t[31]=u):u=t[31],u}case`text`:{let e;t[32]===n.question?e=t[33]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[32]=n.question,t[33]=e);let i;t[34]===r?i=t[35]:(i=e=>r(e.target.value),t[34]=r,t[35]=i);let a;t[36]!==n.defaultValue||t[37]!==n.placeholder||t[38]!==i?(a=(0,Q.jsx)(L,{type:`text`,placeholder:n.placeholder,defaultValue:n.defaultValue,onChange:i}),t[36]=n.defaultValue,t[37]=n.placeholder,t[38]=i,t[39]=a):a=t[39];let o;return t[40]!==e||t[41]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,a]}),t[40]=e,t[41]=a,t[42]=o):o=t[42],o}case`confirm`:{let e;t[43]===n.question?e=t[44]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[43]=n.question,t[44]=e);let i=s===!1?`default`:`outline`,a;t[45]===r?a=t[46]:(a=()=>{c(!1),r(!1)},t[45]=r,t[46]=a);let o;t[47]!==i||t[48]!==a?(o=(0,Q.jsx)(X,{variant:i,size:`sm`,onClick:a,children:`No`}),t[47]=i,t[48]=a,t[49]=o):o=t[49];let l=s===!0?`default`:`outline`,u;t[50]===r?u=t[51]:(u=()=>{c(!0),r(!0)},t[50]=r,t[51]=u);let d;t[52]!==l||t[53]!==u?(d=(0,Q.jsx)(X,{variant:l,size:`sm`,onClick:u,children:`Yes`}),t[52]=l,t[53]=u,t[54]=d):d=t[54];let f;t[55]!==o||t[56]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[o,d]}),t[55]=o,t[56]=d,t[57]=f):f=t[57];let p;return t[58]!==e||t[59]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,f]}),t[58]=e,t[59]=f,t[60]=p):p=t[60],p}}}function jr(e){var t,n,r,i;let a=(0,$.c)(79),{ask:o,onRespond:s}=e,c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={none:`text-muted-foreground`,low:`text-success`,medium:`text-warning`,high:`text-destructive`,critical:`text-destructive`},a[0]=c):c=a[0];let l=c,u=(t=o.intents)==null?void 0:t[0],d=(n=o.action)==null?u==null?void 0:u.action:n,f=(r=(i=o.resource)==null?u==null?void 0:u.resource:i)==null?`shell-command`:r,p=d===`read`?`Reading`:d===`write`?`Writing to`:d===`delete`?`Deleting`:d===`request`?`Requesting`:d===`execute`?`Executing`:null,m,h,g,_,v,y,b,x,S,C,w,T;if(a[1]!==o.allowedScopes||a[2]!==o.description||a[3]!==o.metadata||a[4]!==o.paths||a[5]!==o.risk||a[6]!==d||a[7]!==f||a[8]!==s||a[9]!==p||a[10]!==u){var E;let e=(E=o.allowedScopes)==null?[`once`,`session`,`workspace`]:E,t=(u==null?void 0:u.persistable)===!1?u.nonPersistableReason:void 0,n={};f===`file`&&d===`read`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Reading This File`):f===`file`&&d===`write`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Writing This File`):f===`file`&&d===`delete`?n.session=`Allow for This Session`:f===`network`?(n.session=`Allow for This Session`,n.workspace=`Always Allow This Network Request`):f===`shell-command`&&(n.session=`Allow for This Session`);let r=e=>{if(n[e])return n[e];switch(e){case`once`:return`Allow Once`;case`session`:return`Allow for This Session`;case`workspace`:return`Allow for Workspace`;case`always`:return`Allow for Workspace`;default:return`Allow (${e})`}};if(a[23]!==o.description||a[24]!==o.metadata||a[25]!==o.paths||a[26]!==o.risk||a[27]!==f||a[28]!==p||a[29]!==(u==null?void 0:u.targets)){var D;let e=(D=u==null?void 0:u.targets)==null?[]:D,t=e.length>0?e.map(Nr):[],n;a[37]!==o.metadata||a[38]!==f?(n=()=>{var e;return f!==`shell-command`||typeof((e=o.metadata)==null?void 0:e.command)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Command`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.command})]})},a[37]=o.metadata,a[38]=f,a[39]=n):n=a[39];let r=n,i;a[40]!==o.paths||a[41]!==f||a[42]!==p?(i=()=>{let e=o.paths,t=f===`file`||f===`path`||f===`directory`;return!e||e.length===0||!t?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:p==null?`Accessing`:p}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:e.join(`
8
+ `)})]})},a[40]=o.paths,a[41]=f,a[42]=p,a[43]=i):i=a[43];let s=i,c;a[44]!==o.metadata||a[45]!==f?(c=()=>{var e;return f!==`network`||typeof((e=o.metadata)==null?void 0:e.url)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`URL`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.url})]})},a[44]=o.metadata,a[45]=f,a[46]=c):c=a[46];let d=c,g=()=>t.length===0||f===`shell-command`?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(Mr)});if(x=`flex flex-col gap-3`,a[47]===o.description?S=a[48]:(S=o.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.description}),a[47]=o.description,a[48]=S),a[49]!==o.risk){var O,k;C=o.risk&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-xs font-medium uppercase ${(O=l[(k=o.risk)==null?`none`:k])==null?`text-muted-foreground`:O}`,children:[`Risk: `,o.risk]})}),a[49]=o.risk,a[50]=C}else C=a[50];a[51]===r?w=a[52]:(w=r(),a[51]=r,a[52]=w),a[53]===s?T=a[54]:(T=s(),a[53]=s,a[54]=T),a[55]===d?m=a[56]:(m=d(),a[55]=d,a[56]=m),h=g(),a[23]=o.description,a[24]=o.metadata,a[25]=o.paths,a[26]=o.risk,a[27]=f,a[28]=p,a[29]=u==null?void 0:u.targets,a[30]=m,a[31]=h,a[32]=x,a[33]=S,a[34]=C,a[35]=w,a[36]=T}else m=a[30],h=a[31],x=a[32],S=a[33],C=a[34],w=a[35],T=a[36];if(a[57]!==o.description||a[58]!==o.metadata){var A;g=(A=o.metadata)!=null&&A.description&&typeof o.metadata.description==`string`&&!o.description?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.metadata.description}):null,a[57]=o.description,a[58]=o.metadata,a[59]=g}else g=a[59];a[60]===t?_=a[61]:(_=t&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`This command is too dynamic to save as a reusable permission (`,t,`).`]}),a[60]=t,a[61]=_),v=`flex flex-wrap gap-2`,a[62]===s?y=a[63]:(y=(0,Q.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>s({type:`permission`,grant:`deny`}),children:`Block`}),a[62]=s,a[63]=y),b=e.map(e=>(0,Q.jsx)(X,{variant:e===`workspace`?`default`:`outline`,size:`sm`,onClick:()=>s({type:`permission`,grant:e}),children:r(e)},e)),a[1]=o.allowedScopes,a[2]=o.description,a[3]=o.metadata,a[4]=o.paths,a[5]=o.risk,a[6]=d,a[7]=f,a[8]=s,a[9]=p,a[10]=u,a[11]=m,a[12]=h,a[13]=g,a[14]=_,a[15]=v,a[16]=y,a[17]=b,a[18]=x,a[19]=S,a[20]=C,a[21]=w,a[22]=T}else m=a[11],h=a[12],g=a[13],_=a[14],v=a[15],y=a[16],b=a[17],x=a[18],S=a[19],C=a[20],w=a[21],T=a[22];let j;a[64]!==v||a[65]!==y||a[66]!==b?(j=(0,Q.jsxs)(`div`,{className:v,children:[y,b]}),a[64]=v,a[65]=y,a[66]=b,a[67]=j):j=a[67];let M;return a[68]!==m||a[69]!==h||a[70]!==g||a[71]!==_||a[72]!==j||a[73]!==x||a[74]!==S||a[75]!==C||a[76]!==w||a[77]!==T?(M=(0,Q.jsxs)(`div`,{className:x,children:[S,C,w,T,m,h,g,_,j]}),a[68]=m,a[69]=h,a[70]=g,a[71]=_,a[72]=j,a[73]=x,a[74]=S,a[75]=C,a[76]=w,a[77]=T,a[78]=M):M=a[78],M}function Mr(e,t){return(0,Q.jsx)(`code`,{className:`text-xs bg-muted/50 border rounded px-1.5 py-0.5 font-mono`,children:e},t)}function Nr(e){return e.target.split(`/`).pop()||e.target}function Pr(e){let t=(0,$.c)(15),{ask:n,onRespond:r}=e,i;t[0]===n.capability?i=t[1]:(i=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Client capability request: `,(0,Q.jsx)(`code`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:n.capability})]}),t[0]=n.capability,t[1]=i);let a;t[2]===n.metadata?a=t[3]:(a=n.metadata&&(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(n.metadata,null,2)}),t[2]=n.metadata,t[3]=a);let o;t[4]===r?o=t[5]:(o=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>r(void 0),children:`Not Available`}),t[4]=r,t[5]=o);let s;t[6]===r?s=t[7]:(s=(0,Q.jsx)(X,{size:`sm`,onClick:()=>r(null),children:`Confirm`}),t[6]=r,t[7]=s);let c;t[8]!==o||t[9]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10];let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i,a,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function Fr(e){let t=(0,$.c)(78),{request:n,onRespond:r}=e,{toolCallId:i,toolName:a,ask:o,requestId:s}=n,c;t[0]!==r||t[1]!==s||t[2]!==i?(c=e=>{r(i,{type:`single_select`,value:e},s)},t[0]=r,t[1]=s,t[2]=i,t[3]=c):c=t[3];let l=c,u;t[4]!==r||t[5]!==s||t[6]!==i?(u=e=>{r(i,{type:`multi_select`,values:e},s)},t[4]=r,t[5]=s,t[6]=i,t[7]=u):u=t[7];let d=u,p;t[8]!==r||t[9]!==s||t[10]!==i?(p=e=>{r(i,{type:`text`,value:e},s)},t[8]=r,t[9]=s,t[10]=i,t[11]=p):p=t[11];let m=p,h;t[12]!==r||t[13]!==s||t[14]!==i?(h=e=>{r(i,{type:`confirm`,confirmed:e},s)},t[12]=r,t[13]=s,t[14]=i,t[15]=h):h=t[15];let g=h,_;t[16]!==r||t[17]!==s||t[18]!==i?(_=e=>{r(i,e,s)},t[16]=r,t[17]=s,t[18]=i,t[19]=_):_=t[19];let v=_,y;t[20]!==r||t[21]!==s||t[22]!==i?(y=e=>{r(i,e,s)},t[20]=r,t[21]=s,t[22]=i,t[23]=y):y=t[23];let b=y,x;t[24]!==o.capability||t[25]!==o.type||t[26]!==r||t[27]!==s||t[28]!==i?(x=e=>{r(i,{type:`client_capability`,capability:o.type===`client_capability`?o.capability:``,result:e},s)},t[24]=o.capability,t[25]=o.type,t[26]=r,t[27]=s,t[28]=i,t[29]=x):x=t[29];let S=x,C;bb0:{if(`type`in o)switch(o.type){case`single_select`:case`multi_select`:case`text`:case`confirm`:case`form`:{let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:et,borderClass:`border-primary/30 bg-primary/5`,iconClass:`text-primary`},t[30]=e):e=t[30],C=e;break bb0}case`permission`:{let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:f,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[31]=e):e=t[31],C=e;break bb0}case`client_capability`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:ge,borderClass:`border-info/30 bg-info/5`,iconClass:`text-info`},t[32]=e):e=t[32],C=e;break bb0}}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:f,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[33]=e):e=t[33],C=e}let w=C,T=w.icon,E=`border ${w.borderClass} rounded-lg p-4 flex flex-col gap-4`,D=`flex items-start gap-2 ${w.iconClass}`,O;t[34]===T?O=t[35]:(O=(0,Q.jsx)(T,{className:`size-4 mt-0.5 shrink-0`}),t[34]=T,t[35]=O);let k;t[36]===a?k=t[37]:(k=(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:a}),t[36]=a,t[37]=k);let A;t[38]===o?A=t[39]:(A=`question`in o&&(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:o.question}),t[38]=o,t[39]=A);let j;t[40]!==k||t[41]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[k,A]}),t[40]=k,t[41]=A,t[42]=j):j=t[42];let M;t[43]!==D||t[44]!==O||t[45]!==j?(M=(0,Q.jsxs)(`div`,{className:D,children:[O,j]}),t[43]=D,t[44]=O,t[45]=j,t[46]=M):M=t[46];let N;t[47]!==o||t[48]!==l?(N=o.type===`single_select`&&(0,Q.jsx)(Tr,{question:o,onSelect:l}),t[47]=o,t[48]=l,t[49]=N):N=t[49];let P;t[50]!==o||t[51]!==d?(P=o.type===`multi_select`&&(0,Q.jsx)(Er,{question:o,onSelect:d}),t[50]=o,t[51]=d,t[52]=P):P=t[52];let F;t[53]!==o||t[54]!==m?(F=o.type===`text`&&(0,Q.jsx)(Dr,{question:o,onSubmit:m}),t[53]=o,t[54]=m,t[55]=F):F=t[55];let I;t[56]!==o||t[57]!==g?(I=o.type===`confirm`&&(0,Q.jsx)(Or,{question:o,onConfirm:g}),t[56]=o,t[57]=g,t[58]=I):I=t[58];let L;t[59]!==o||t[60]!==v?(L=o.type===`form`&&(0,Q.jsx)(kr,{question:o,onSubmit:v}),t[59]=o,t[60]=v,t[61]=L):L=t[61];let R;t[62]!==o||t[63]!==b?(R=(o.type===`permission`||!(`type`in o))&&(0,Q.jsx)(jr,{ask:o,onRespond:b}),t[62]=o,t[63]=b,t[64]=R):R=t[64];let z;t[65]!==o||t[66]!==S?(z=o.type===`client_capability`&&(0,Q.jsx)(Pr,{ask:o,onRespond:S}),t[65]=o,t[66]=S,t[67]=z):z=t[67];let B;return t[68]!==M||t[69]!==N||t[70]!==P||t[71]!==F||t[72]!==I||t[73]!==L||t[74]!==R||t[75]!==z||t[76]!==E?(B=(0,Q.jsxs)(`div`,{className:E,children:[M,N,P,F,I,L,R,z]}),t[68]=M,t[69]=N,t[70]=P,t[71]=F,t[72]=I,t[73]=L,t[74]=R,t[75]=z,t[76]=E,t[77]=B):B=t[77],B}var Ir=1536,Lr=(0,Z.memo)(function(e){let t=(0,$.c)(16),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=new Blob([n]),t[0]=n,t[1]=o);let s=o.size,c=s>Ir,l=c?n.slice(0,Ir)+`
9
+ ...`:null;if(!c){let e;return t[2]!==r||t[3]!==n?(e=(0,Q.jsx)(`pre`,{className:r,children:n}),t[2]=r,t[3]=n,t[4]=e):e=t[4],e}let u;t[5]===s?u=t[6]:(u=s>1048576?`${(s/1048576).toFixed(1)} MB`:s>1024?`${(s/1024).toFixed(1)} KB`:`${s} bytes`,t[5]=s,t[6]=u);let d=u,f=i?n:l,p;t[7]!==r||t[8]!==f?(p=(0,Q.jsx)(`pre`,{className:r,children:f}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>a(Ur),t[10]=m):m=t[10];let h=i?`Show less`:`Show full output (${d})`,g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:m,children:h}),t[11]=h,t[12]=g);let _;return t[13]!==p||t[14]!==g?(_=(0,Q.jsxs)(`div`,{children:[p,g]}),t[13]=p,t[14]=g,t[15]=_):_=t[15],_});function Rr(e){switch(e){case`pending`:return(0,Q.jsx)(nt,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(v,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(m,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(d,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(je,{className:`size-3 text-warning`});default:return null}}function zr(e){if(e.name!==`task`)return null;let t=e.state;if(`childSessionId`in t&&t.childSessionId)return t.childSessionId;let n=`output`in t?t.output:`partialOutput`in t?t.partialOutput:null;if(n&&typeof n==`string`){let e=n.match(/task_id:\s*([a-f0-9-]{36})/i);if(e)return e[1]}return null}function Br(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}function Vr(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.shift();for(let i of t)i.parentId===e&&!n.has(i.id)&&(n.add(i.id),r.push(i.id))}return n}var Hr=(0,Z.memo)(function({part:e,pendingAskRequests:t,onAskResponse:n,onNavigateToSubagent:r}){let[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),l=e.state,u=l.status,d=(0,Z.useMemo)(()=>{if(!i)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,i]),f=(0,Z.useMemo)(()=>!i||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,i]),m=u===`completed`&&`output`in l?Br(l.output):void 0,h=zr(e),g=s(e=>e.sessions),_=[];if(u===`pending`||u===`running`){let n=t.find(t=>t.toolCallId===e.callId);if(n&&_.push(n),h){let n=Vr(h,g);n.add(h);let r=t.filter(t=>{let r=t.originSessionId&&n.has(t.originSessionId),i=t.sessionId===h;return(r||i)&&t.toolCallId!==e.callId});_.push(...r)}}let v=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)}},y=(()=>{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)(A,{open:i,onOpenChange:a,children:[(0,Q.jsx)(D,{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:[Rr(u),i?(0,Q.jsx)(Qe,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(M,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Ee,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!i&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 hidden sm:block`,children:y}),h&&r&&(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`ml-auto h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(h)},title:`View session`,children:[(0,Q.jsx)(ke,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})}),i&&(0,Q.jsx)(N,{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)(Lr,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`||u===`interrupted`)&&h&&r&&(0,Q.jsxs)(X,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(h),children:[(0,Q.jsx)(ke,{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)(X,{variant:`ghost`,size:`icon`,onClick:v,className:`size-6`,children:o?(0,Q.jsx)(p,{className:`size-3 text-success`}):(0,Q.jsx)(se,{className:`size-3`})})]}),(0,Q.jsx)(Lr,{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})]})]})})]}),_.length>0&&(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:_.map(e=>{var t;return(0,Q.jsx)(Fr,{request:e,onRespond:n},(t=e.requestId)==null?e.toolCallId:t)})}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(Sr,{visualization:m})})]})},(e,t)=>{if(e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.onAskResponse!==t.onAskResponse||e.pendingAskRequests.find(t=>t.toolCallId===e.part.callId)!==t.pendingAskRequests.find(e=>e.toolCallId===t.part.callId))return!1;let n=zr(e.part),r=zr(t.part);if(n||r){let i=e.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r),a=t.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return!1}return!0});function Ur(e){return!e}var Wr=60,Gr=300,Kr=16;function qr(e){if(e.length===0)return!1;let t=e[e.length-1];return qe(t.message)&&t.message.status===`streaming`}function Jr(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Yr(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 Xr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(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)(lt,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]}),e[0]=t):t=e[0],t}function Zr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(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)($e,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]}),e[0]=t):t=e[0],t}function Qr(e){let t=(0,$.c)(8),{message:n,textContent:r,onRetry:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(Pe,{className:`size-3`}),`Compaction Failed`]}),t[0]=a):a=t[0];let o=r||n.error||`Compaction failed. The conversation could not be summarized.`,s;t[1]===o?s=t[2]:(s=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:o}),t[1]=o,t[2]=s);let c;t[3]===i?c=t[4]:(c=i&&(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:i,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(Ne,{className:`size-3`}),`Retry`]}),t[3]=i,t[4]=c);let l;return t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,(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:[s,c]})]}),t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function $r(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function ei(e){let t=(0,$.c)(15),{part:n}=e,[r,i]=(0,Z.useState)(!1),a=n.overflow?`overflow`:n.auto?`auto`:`manual`,o;t[0]===r?o=t[1]:(o=()=>i(!r),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(Qe,{className:`size-3`}):(0,Q.jsx)(M,{className:`size-3`}),t[2]=r,t[3]=s);let c=a===`overflow`?`Context overflow`:a===`auto`?`Auto`:`Manual`,l;t[4]===c?l=t[5]:(l=(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[c,` compaction`]}),t[4]=c,t[5]=l);let u;t[6]!==o||t[7]!==s||t[8]!==l?(u=(0,Q.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[s,l]}),t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`}),t[10]=r,t[11]=d);let f;return t[12]!==u||t[13]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14],f}var ti=(0,Z.memo)(function(e){let t=(0,$.c)(15),{parts:n,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a,inverted:o,serverUrl:s}=e,c=o===void 0?!1:o,l;if(t[0]!==c||t[1]!==i||t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==s){let e=[...n].sort(ii),o;t[7]!==c||t[8]!==i||t[9]!==a||t[10]!==r||t[11]!==s?(o=e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(Ce,{inverted:c,children:c&&e.text?e.text.replace(/\n(?!\n)/g,`
10
+
11
+ `):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)(Hr,{part:e,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a},e.id);case`image`:return(0,Q.jsx)(`img`,{src:s?xn(s,e.url):e.url,alt:``,className:Y(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,c&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=s?xn(s,e.url):e.url,n=$r(e.mimeType,e.filename),r=e.filename||``,i=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:Y(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,c?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(De,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),n&&(0,Q.jsx)(`span`,{className:Y(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,c?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(rt,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}},t[7]=c,t[8]=i,t[9]=a,t[10]=r,t[11]=s,t[12]=o):o=t[12],l=e.map(o),t[0]=c,t[1]=i,t[2]=a,t[3]=n,t[4]=r,t[5]=s,t[6]=l}else l=t[6];let u;return t[13]===l?u=t[14]:(u=(0,Q.jsx)(Q.Fragment,{children:l}),t[13]=l,t[14]=u),u},(e,t)=>!(e.parts!==t.parts||e.inverted!==t.inverted||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl||e.pendingAskRequests!==t.pendingAskRequests)),ni=(0,Z.memo)(function(e){let t=(0,$.c)(49),{item:n,messagesWithParts:r,sessionId:i,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,onRemoveFromQueue:c,onRevert:l,onFork:u,isMainActiveSession:d,isCompacting:f,onCompact:p,serverUrl:m}=e,h=d===void 0?!1:d,g=f===void 0?!1:f,_;t[0]===n.parts?_=t[1]:(_=n.parts.find(ai),t[0]=n.parts,t[1]=_);let v=_;if(qe(n.message)&&n.message.mode===`compact_failed`){let e=n.message,r;t[2]===n.parts?r=t[3]:(r=Jr(n.parts),t[2]=n.parts,t[3]=r);let i=h&&!g?p:void 0,a;return t[4]!==e||t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Qr,{message:e,textContent:r,onRetry:i}),t[4]=e,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}if(qe(n.message)&&n.message.status===`error`){let e=n.message,r;return t[8]===e?r=t[9]:(r=(0,Q.jsx)(Kn,{message:e}),t[8]=e,t[9]=r),r}if(v){let e;return t[10]===v?e=t[11]:(e=(0,Q.jsx)(ei,{part:v}),t[10]=v,t[11]=e),e}let y=!n.isQueued&&n.message.role===`user`,b;t[12]!==y||t[13]!==n.message.id||t[14]!==r?(b=y?Yr(n.message.id,r):null,t[12]=y,t[13]=n.message.id,t[14]=r,t[15]=b):b=t[15];let x=b,S=x===n.message.id,C=n.message,w;t[16]===n.parts?w=t[17]:(w=Jr(n.parts),t[16]=n.parts,t[17]=w);let T;t[18]!==n.isQueued||t[19]!==n.queueId||t[20]!==c?(T=n.isQueued?()=>c(n.queueId):void 0,t[18]=n.isQueued,t[19]=n.queueId,t[20]=c,t[21]=T):T=t[21];let E=y&&x!==null,D;t[22]!==l||t[23]!==x||t[24]!==i?(D=x?()=>l==null?void 0:l(i,x):void 0,t[22]=l,t[23]=x,t[24]=i,t[25]=D):D=t[25];let O=y&&x!==null,k;t[26]!==n.message.id||t[27]!==u||t[28]!==x||t[29]!==i?(k=x?()=>u==null?void 0:u(i,n.message.id):void 0,t[26]=n.message.id,t[27]=u,t[28]=x,t[29]=i,t[30]=k):k=t[30];let A;t[31]!==n.message.role||t[32]!==n.parts||t[33]!==o||t[34]!==s||t[35]!==a||t[36]!==m?(A=n.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(ti,{parts:n.parts,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,inverted:n.message.role===`user`,serverUrl:m}),t[31]=n.message.role,t[32]=n.parts,t[33]=o,t[34]=s,t[35]=a,t[36]=m,t[37]=A):A=t[37];let j;return t[38]!==S||t[39]!==n.isQueued||t[40]!==n.message||t[41]!==O||t[42]!==k||t[43]!==A||t[44]!==w||t[45]!==T||t[46]!==E||t[47]!==D?(j=(0,Q.jsx)(Un,{message:C,textContent:w,isQueued:n.isQueued,onRemove:T,canRevert:E,onRevert:D,canFork:O,onFork:k,isClearAll:S,children:A}),t[38]=S,t[39]=n.isQueued,t[40]=n.message,t[41]=O,t[42]=k,t[43]=A,t[44]=w,t[45]=T,t[46]=E,t[47]=D,t[48]=j):j=t[48],j});function ri({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingAskRequests:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onAskResponse: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,Z.useRef)(null),[S,C]=(0,Z.useState)(!1),w=(0,Z.useRef)(h),T=(0,Z.useRef)(e.length),E=(0,Z.useRef)(0),D=(0,Z.useRef)(!1),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(``),A=(0,Z.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}:${qe(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(new Map),P=(0,Z.useRef)(e);P.current=e;let F=(0,Z.useCallback)(e=>{let t=P.current[e];if(!t)return Wr+Kr;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),t.message.status===`error`&&(e=100),Math.min(Math.max(e+Kr,Wr+Kr),Gr+Kr)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+Kr,Wr+Kr),Gr+Kr)},[]);(0,Z.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 I=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let e=x.current;if(!e)return;I.current&&I.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 I.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let L=Hn({count:e.length,getScrollElement:()=>x.current,estimateSize:F,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,Z.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(L.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,Z.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 R=Sn(()=>{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,Z.useLayoutEffect)(()=>{C(a)},[a]);let z=A(e);(0,Z.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=z,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){L.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,z,L]),(0,Z.useEffect)(()=>{var t;let n=L.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,!(!qr(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&qr(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,L]),(0,Z.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,Z.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,Z.useLayoutEffect)(()=>{w.current=h},[h]);let B=L.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:R,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)(Xr,{})}),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)(Zr,{})}),r===`closed`&&(0,Q.jsx)(Te,{className:`mx-4 mt-4`,children:(0,Q.jsx)(be,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${L.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=B[0])==null?void 0:b.start)==null?0:y}px)`},children:B.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:L.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(ni,{item:o,messagesWithParts:t,sessionId:n,pendingAskRequests:i,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function ii(e,t){return e.createdAt-t.createdAt}function ai(e){return e.type===`compaction`}function oi(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 si(e){var t;let n=(0,$.c)(97),{session:r,messagesWithParts:i,queuedMessages:a,preconfigs:o,prompts:s,models:c,defaultModel:l,onSendMessage:u,onRemoveFromQueue:d,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,pendingAskRequests:h,onAskResponse:g,onRename:_,usage:v,modelName:y,modelSupportsImage:b,onNavigateToSubagent:x,onNavigateBack:S,isStreaming:C,onInterrupt:w,onRevert:T,onFork:E,onCompact:D,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,serverUrl:j,sdkClient:M,selectedVariant:N,variants:P,inputRef:F,scrollToBottomRef:I,autoFollowToggleRef:L,onClaimControl:R,onReleaseControl:z,onRequestTakeover:B,onRespondTakeover:V}=e,H=!r.parentId&&r.status===`active`,U;n[0]===r.id?U=n[1]:(U=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=U);let W=we(U),ee=fe(li),G=(W==null?void 0:W.status)===`controlled`&&W.controllerClientId!==ee,K=(W==null?void 0:W.status)===`grace`,te=G||K,[ne,re]=(0,Z.useState)(null),ie=(0,Z.useRef)(null),q;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>{ie.current&&clearTimeout(ie.current),re(e),ie.current=setTimeout(()=>{re(null),ie.current=null},4e3)},n[2]=q):q=n[2];let ae=q,oe,J;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>()=>{ie.current&&clearTimeout(ie.current)},J=[],n[3]=oe,n[4]=J):(oe=n[3],J=n[4]),(0,Z.useEffect)(oe,J);let se,ce;n[5]===r.id?(se=n[6],ce=n[7]):(se=()=>{let e=null;return we.subscribe(t=>{t.lastActionRejection!==e&&(e=t.lastActionRejection,e&&e.sessionId===r.id&&ae(e.message))})},ce=[r.id,ae],n[5]=r.id,n[6]=se,n[7]=ce),(0,Z.useEffect)(se,ce);let[le,ue]=(0,Z.useState)(!0),pe;n[8]===I?pe=n[9]:(pe=()=>{ue(e=>{let t=!e;if(t){var n;I==null||(n=I.current)==null||n.call(I)}return t})},n[8]=I,n[9]=pe);let me=pe,ge,_e;n[10]!==L||n[11]!==me?(ge=()=>{L&&(L.current={toggle:()=>{me()}})},_e=[L,me],n[10]=L,n[11]=me,n[12]=ge,n[13]=_e):(ge=n[12],_e=n[13]),(0,Z.useEffect)(ge,_e);let ve=(t=M==null?void 0:M.http.attachments.getUrl)==null?ci:t,ye;n[14]!==i||n[15]!==a||n[16]!==ve?(ye=oi(i,a,ve),n[14]=i,n[15]=a,n[16]=ve,n[17]=ye):ye=n[17];let be=ye,xe=i.length>=2,Se;n[18]!==l||n[19]!==O||n[20]!==C||n[21]!==y||n[22]!==c||n[23]!==p||n[24]!==f||n[25]!==m||n[26]!==R||n[27]!==D||n[28]!==w||n[29]!==S||n[30]!==z||n[31]!==_||n[32]!==B||n[33]!==V||n[34]!==o||n[35]!==N||n[36]!==r||n[37]!==xe||n[38]!==v||n[39]!==P?(Se=(0,Q.jsx)(qt,{session:r,preconfigs:o,models:c,defaultModel:l,usage:v,modelName:y,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,onRename:_,onNavigateBack:S,isStreaming:C,onInterrupt:w,onCompact:D,isCompacting:O,canCompact:xe,selectedVariant:N,variants:P,onClaimControl:R,onReleaseControl:z,onRequestTakeover:B,onRespondTakeover:V}),n[18]=l,n[19]=O,n[20]=C,n[21]=y,n[22]=c,n[23]=p,n[24]=f,n[25]=m,n[26]=R,n[27]=D,n[28]=w,n[29]=S,n[30]=z,n[31]=_,n[32]=B,n[33]=V,n[34]=o,n[35]=N,n[36]=r,n[37]=xe,n[38]=v,n[39]=P,n[40]=Se):Se=n[40];let Ce;n[41]!==E||n[42]!==T||n[43]!==le||n[44]!==k||n[45]!==be||n[46]!==O||n[47]!==H||n[48]!==i||n[49]!==g||n[50]!==A||n[51]!==D||n[52]!==x||n[53]!==d||n[54]!==h||n[55]!==I||n[56]!==j||n[57]!==r.id||n[58]!==r.status?(Ce=(0,Q.jsx)(ri,{displayItems:be,messagesWithParts:i,sessionId:r.id,sessionStatus:r.status,pendingAskRequests:h,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,onAskResponse:g,onNavigateToSubagent:x,onRemoveFromQueue:d,onRevert:T,onFork:E,onCompact:D,isMainActiveSession:H,autoFollow:le,onAutoScrollChange:ue,scrollToBottomRef:I,serverUrl:j}),n[41]=E,n[42]=T,n[43]=le,n[44]=k,n[45]=be,n[46]=O,n[47]=H,n[48]=i,n[49]=g,n[50]=A,n[51]=D,n[52]=x,n[53]=d,n[54]=h,n[55]=I,n[56]=j,n[57]=r.id,n[58]=r.status,n[59]=Ce):Ce=n[59];let Te=le?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,Ee;n[60]===le?Ee=n[61]:(Ee=le?(0,Q.jsx)(Je,{className:`size-3.5`}):(0,Q.jsx)(de,{className:`size-3.5`}),n[60]=le,n[61]=Ee);let De;n[62]!==me||n[63]!==Te||n[64]!==Ee?(De=(0,Q.jsx)(`button`,{onClick:me,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:Te,children:Ee}),n[62]=me,n[63]=Te,n[64]=Ee,n[65]=De):De=n[65];let Oe;n[66]!==Ce||n[67]!==De?(Oe=(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[Ce,De]}),n[66]=Ce,n[67]=De,n[68]=Oe):Oe=n[68];let ke;n[69]!==F||n[70]!==O||n[71]!==te||n[72]!==b||n[73]!==u||n[74]!==s||n[75]!==M||n[76]!==r.id||n[77]!==r.parentId||n[78]!==r.status||n[79]!==r.workspaceId?(ke=r.status===`active`&&!r.parentId&&(0,Q.jsx)(yn,{ref:F,onSendMessage:u,disabled:O||te,workspaceId:r.workspaceId,sdkClient:M,prompts:s,sessionId:r.id,modelSupportsImage:b}),n[69]=F,n[70]=O,n[71]=te,n[72]=b,n[73]=u,n[74]=s,n[75]=M,n[76]=r.id,n[77]=r.parentId,n[78]=r.status,n[79]=r.workspaceId,n[80]=ke):ke=n[80];let Ae;n[81]===r.parentId?Ae=n[82]:(Ae=r.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)(he,{className:`size-4`}),`This is a subagent session (read-only)`]}),n[81]=r.parentId,n[82]=Ae);let je;n[83]===G?je=n[84]:(je=G&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-border bg-muted/30 text-center flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(dt,{className:`size-3.5`}),`You are observing this session. Input is disabled.`]}),n[83]=G,n[84]=je);let Me;n[85]===K?Me=n[86]:(Me=K&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-yellow-500/30 bg-yellow-50 dark:bg-yellow-950/30 text-center flex items-center justify-center gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,Q.jsx)(mt,{className:`size-3.5`}),`Reconnecting to session… waiting for control to be restored.`]}),n[85]=K,n[86]=Me);let Ne;n[87]===ne?Ne=n[88]:(Ne=ne&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-orange-500/30 bg-orange-50 dark:bg-orange-950/30 text-center flex items-center justify-center gap-2 text-xs text-orange-600 dark:text-orange-400`,children:[(0,Q.jsx)(dt,{className:`size-3.5`}),ne]}),n[87]=ne,n[88]=Ne);let Pe;return n[89]!==Se||n[90]!==Oe||n[91]!==ke||n[92]!==Ae||n[93]!==je||n[94]!==Me||n[95]!==Ne?(Pe=(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[Se,Oe,ke,Ae,je,Me,Ne]}),n[89]=Se,n[90]=Oe,n[91]=ke,n[92]=Ae,n[93]=je,n[94]=Me,n[95]=Ne,n[96]=Pe):Pe=n[96],Pe}function ci(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}function li(e){return e.clientId}function ui(e){var t,n,r;let i=(0,$.c)(77),{serverUrl:a,messagesWithParts:o,inputRef:c,sdkClient:u,onRetry:d,onLogout:f,onSendMessage:p,onRemoveFromQueue:m,onChangePreconfig:g,onChangeModel:_,onChangeVariant:v,onAskResponse:y,onRename:b,onNavigateToSubagent:x,onNavigateBack:S,onInterrupt:C,onRevert:w,onFork:T,onCompact:E,onClearCompactionSuccess:D,scrollToBottomRef:O,autoFollowToggleRef:k,onClaimControl:A,onReleaseControl:j,onRequestTakeover:M,onRespondTakeover:N}=e,P=R(ki),F=R(Oi),I=R(Di),L=R(Ei),z=R(Ti),B=R(wi),V=s(Ci),H=s(Si),U=s(xi),W=s(bi),ee=s(yi),G=s(vi),K=h(_i),te=h(gi),ne=h(hi),re=h(mi),ie=l(pi),q;i[0]===K?q=i[1]:(q=K.filter(fi),i[0]=K,i[1]=q);let ae=q,oe=!(V!=null&&V.parentId),J=(t=V==null?void 0:V.compacting)==null?!1:t,se;i[2]===g?se=i[3]:(se=e=>{g(e)},i[2]=g,i[3]=se);let ce=se,le;i[4]===v?le=i[5]:(le=e=>{v(e)},i[4]=v,i[5]=le);let ue=le,de;i[6]===C?de=i[7]:(de=()=>{C()},i[6]=C,i[7]=de);let fe=de;if(!P){if(I){let e;return i[8]!==F||i[9]!==z||i[10]!==f||i[11]!==d||i[12]!==L||i[13]!==a?(e=(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Nt,{serverUrl:a,authError:F,retryCount:L,nextRetryIn:z,onRetry:d,onLogout:f})}),i[8]=F,i[9]=z,i[10]=f,i[11]=d,i[12]=L,i[13]=a,i[14]=e):e=i[14],e}let e;i[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Mt,{}),i[15]=e):e=i[15];let t;return i[16]===f?t=i[17]:(t=(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[e,(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:f,className:`text-muted-foreground`,children:`Change Server`})]}),i[16]=f,i[17]=t),t}if(!V){let e;return i[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(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.`})]}),i[18]=e):e=i[18],e}let pe;i[19]===o?pe=i[20]:(pe=o.filter(di),i[19]=o,i[20]=pe);let me=pe.length>=2,he;if(i[21]!==W||i[22]!==ne){let e;i[24]===W?e=i[25]:(e=e=>e.id===W,i[24]=W,i[25]=e),he=ne.find(e),i[21]=W,i[22]=ne,i[23]=he}else he=i[23];let ge=he,_e;i[26]!==V.id||i[27]!==H?(_e=H[V.id]||[],i[26]=V.id,i[27]=H,i[28]=_e):_e=i[28];let ve=oe?ae:K,ye=ge==null?void 0:ge.variants,be=(n=ge==null||(r=ge.capabilities)==null||(r=r.input)==null?void 0:r.image)==null?!1:n,xe;i[29]!==V.id||i[30]!==V.runningAt||i[31]!==B?(xe=B.has(V.id)||!!V.runningAt,i[29]=V.id,i[30]=V.runningAt,i[31]=B,i[32]=xe):xe=i[32];let Se;i[33]!==me||i[34]!==V.id||i[35]!==E?(Se=me?()=>E(V.id):void 0,i[33]=me,i[34]=V.id,i[35]=E,i[36]=Se):Se=i[36];let Ce=a==null?void 0:a,we;return i[37]!==k||i[38]!==G||i[39]!==W||i[40]!==V||i[41]!==re||i[42]!==ce||i[43]!==ue||i[44]!==fe||i[45]!==c||i[46]!==J||i[47]!==o||i[48]!==ne||i[49]!==y||i[50]!==_||i[51]!==A||i[52]!==D||i[53]!==T||i[54]!==S||i[55]!==x||i[56]!==j||i[57]!==m||i[58]!==b||i[59]!==M||i[60]!==N||i[61]!==w||i[62]!==p||i[63]!==ie||i[64]!==te||i[65]!==O||i[66]!==u||i[67]!==ee||i[68]!==U||i[69]!==be||i[70]!==xe||i[71]!==Se||i[72]!==Ce||i[73]!==_e||i[74]!==ve||i[75]!==ye?(we=(0,Q.jsx)(si,{inputRef:c,session:V,messagesWithParts:o,queuedMessages:_e,preconfigs:ve,prompts:te,models:ne,defaultModel:re,onSendMessage:p,onRemoveFromQueue:m,onChangePreconfig:ce,onChangeModel:_,onChangeVariant:ue,selectedVariant:ee,variants:ye,pendingAskRequests:ie,onAskResponse:y,onRename:b,usage:U,modelName:W,modelSupportsImage:be,onNavigateToSubagent:x,onNavigateBack:S,isStreaming:xe,onInterrupt:fe,onRevert:w,onFork:T,onCompact:Se,isCompacting:J,compactionSuccess:G,onClearCompactionSuccess:D,serverUrl:Ce,sdkClient:u,scrollToBottomRef:O,autoFollowToggleRef:k,onClaimControl:A,onReleaseControl:j,onRequestTakeover:M,onRespondTakeover:N}),i[37]=k,i[38]=G,i[39]=W,i[40]=V,i[41]=re,i[42]=ce,i[43]=ue,i[44]=fe,i[45]=c,i[46]=J,i[47]=o,i[48]=ne,i[49]=y,i[50]=_,i[51]=A,i[52]=D,i[53]=T,i[54]=S,i[55]=x,i[56]=j,i[57]=m,i[58]=b,i[59]=M,i[60]=N,i[61]=w,i[62]=p,i[63]=ie,i[64]=te,i[65]=O,i[66]=u,i[67]=ee,i[68]=U,i[69]=be,i[70]=xe,i[71]=Se,i[72]=Ce,i[73]=_e,i[74]=ve,i[75]=ye,i[76]=we):we=i[76],we}function di(e){return e.message.role!==`system`}function fi(e){return e.mode!==`subagent`}function pi(e){return e.pendingRequests}function mi(e){return e.defaultModel}function hi(e){return e.models}function gi(e){return e.prompts}function _i(e){return e.preconfigs}function vi(e){return e.compactionSuccess}function yi(e){return e.selectedVariant}function bi(e){return e.currentModel}function xi(e){return e.sessionUsage}function Si(e){return e.queuedMessages}function Ci(e){return e.currentSession}function wi(e){return e.streamingSessionIds}function Ti(e){return e.nextRetryIn}function Ei(e){return e.retryCount}function Di(e){return e.connectionTimedOut}function Oi(e){return e.authError}function ki(e){return e.connected}function Ai(){let e=(0,$.c)(30),t=_(),{chatInputRef:n,scrollToBottomRef:r,autoFollowToggleRef:i}=u(),{sdkClient:a,messagesWithParts:o,serverUrl:s,currentSession:c,isSessionLoading:l,resumeSession:d,revertSession:f,forkSession:p,compactSession:m,removeFromQueue:h,sendChatMessage:g,handleAskResponse:v,handleInterruptSession:y,updateSessionPreconfig:b,updateSessionModel:x,updateSessionVariant:S,handleNavigateBack:C,handleRenameSession:w,setCompactionSuccess:T}=t;if(l){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(jt,{}),e[0]=t):t=e[0],t}if(!c)return null;let E;e[1]===T?E=e[2]:(E=()=>T(!1),e[1]=T,e[2]=E);let D;return e[3]!==i||e[4]!==n||e[5]!==m||e[6]!==p||e[7]!==v||e[8]!==y||e[9]!==C||e[10]!==w||e[11]!==o||e[12]!==h||e[13]!==d||e[14]!==f||e[15]!==r||e[16]!==a||e[17]!==g||e[18]!==s||e[19]!==t.claimControl||e[20]!==t.handleLogout||e[21]!==t.handleRetry||e[22]!==t.releaseControl||e[23]!==t.requestTakeover||e[24]!==t.respondTakeover||e[25]!==E||e[26]!==x||e[27]!==b||e[28]!==S?(D=(0,Q.jsx)(ui,{sdkClient:a,inputRef:n,messagesWithParts:o,serverUrl:s,onRetry:t.handleRetry,onLogout:t.handleLogout,onSendMessage:g,onRemoveFromQueue:h,onChangePreconfig:b,onChangeModel:x,onChangeVariant:S,onAskResponse:v,onRename:w,onNavigateToSubagent:d,onNavigateBack:C,onInterrupt:y,onRevert:f,onFork:p,onCompact:m,onClearCompactionSuccess:E,scrollToBottomRef:r,autoFollowToggleRef:i,onClaimControl:t.claimControl,onReleaseControl:t.releaseControl,onRequestTakeover:t.requestTakeover,onRespondTakeover:t.respondTakeover}),e[3]=i,e[4]=n,e[5]=m,e[6]=p,e[7]=v,e[8]=y,e[9]=C,e[10]=w,e[11]=o,e[12]=h,e[13]=d,e[14]=f,e[15]=r,e[16]=a,e[17]=g,e[18]=s,e[19]=t.claimControl,e[20]=t.handleLogout,e[21]=t.handleRetry,e[22]=t.releaseControl,e[23]=t.requestTakeover,e[24]=t.respondTakeover,e[25]=E,e[26]=x,e[27]=b,e[28]=S,e[29]=D):D=e[29],D}export{Ai as t};