tarsk 0.5.32 → 0.5.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +17709 -13937
- package/dist/public/assets/account-view-Ds03urJE.js +1 -0
- package/dist/public/assets/api-BHfaVqlR.js +1 -0
- package/dist/public/assets/browser-tab-Qs8cnQkf.js +1 -0
- package/dist/public/assets/commit-dialog-D4suPxEe.js +1 -0
- package/dist/public/assets/context-menu-S8y0c1Fx.js +1 -0
- package/dist/public/assets/create-repo-dialog-DPKIg1mY.js +1 -0
- package/dist/public/assets/{css.worker-DyDu5ynT.js → css.worker-CvXBzhp8.js} +2 -2
- package/dist/public/assets/dialogs-config-Ct6i8Iij.js +51 -0
- package/dist/public/assets/diff-view-rKDEnBLg.js +3 -0
- package/dist/public/assets/{dist-2eORHB3M.js → dist-oojFghRi.js} +5 -5
- package/dist/public/assets/explorer-tab-view-JbLbPVAn.js +2 -0
- package/dist/public/assets/explorer-tree-Dq44yA1j.js +1 -0
- package/dist/public/assets/explorer-view-BMrlX2hb.js +1 -0
- package/dist/public/assets/git-history-dialog-CDwIqSZQ.js +1 -0
- package/dist/public/assets/git-ops-button-B6rEla5u.js +2 -0
- package/dist/public/assets/history-view-CFot099O.js +7 -0
- package/dist/public/assets/{html.worker-IWNXhnIC.js → html.worker-BO6WuOEO.js} +3 -3
- package/dist/public/assets/index-6DhhjIBL.js +65 -0
- package/dist/public/assets/index-sEZ3wJXu.css +1 -0
- package/dist/public/assets/{json.worker-c4h5s80L.js → json.worker-BkJRGcCJ.js} +2 -2
- package/dist/public/assets/mcp-server-card-DQY1RUPX.js +1 -0
- package/dist/public/assets/merged-pr-dialog-H_fuSmiF.js +1 -0
- package/dist/public/assets/{monaco-BGyhgQtx.js → monaco-CZnIWXyV.js} +198 -198
- package/dist/public/assets/onboarding-DHCR18iU.js +1 -0
- package/dist/public/assets/project-settings-view-CiefnK73.js +1 -0
- package/dist/public/assets/providers-list-view-DVopskGo.js +1 -0
- package/dist/public/assets/pull-request-dialog-Csql6eob.js +1 -0
- package/dist/public/assets/pull-with-changes-dialog-DN0kE6os.js +1 -0
- package/dist/public/assets/push-before-pr-dialog-IhdlLvWt.js +1 -0
- package/dist/public/assets/radio-group-BaKkAEZR.js +1 -0
- package/dist/public/assets/react-vendor-CjZZeCRj.js +16 -0
- package/dist/public/assets/rolldown-runtime-aKtaBQYM.js +1 -0
- package/dist/public/assets/settings-general-view-BMTxN35t.js +1 -0
- package/dist/public/assets/settings-instructions-view-DULFg6dU.js +1 -0
- package/dist/public/assets/settings-list-Bdeuh4bJ.js +1 -0
- package/dist/public/assets/settings-mcp-servers-view-CRCtWjP2.js +5 -0
- package/dist/public/assets/settings-models-skeleton-CN2JkqZh.js +1 -0
- package/dist/public/assets/settings-models-view-DosllhVB.js +1 -0
- package/dist/public/assets/settings-rules-view-BVWuGrnB.js +8 -0
- package/dist/public/assets/settings-skills-view-DYtcAu9-.js +2 -0
- package/dist/public/assets/settings-slash-commands-view-DFyL1W2n.js +1 -0
- package/dist/public/assets/settings-subagents-view-aCbK95Sk.js +2 -0
- package/dist/public/assets/settings-system-prompt-view-BNM_15ry.js +1 -0
- package/dist/public/assets/settings-view-D5GE_CYR.js +2 -0
- package/dist/public/assets/skeleton-pSKdmWyJ.js +1 -0
- package/dist/public/assets/terminal-panel-Ds1tCgQA.js +2 -0
- package/dist/public/assets/{ts.worker-BwM5Ha3L.js → ts.worker-B0J26iPs.js} +33 -18
- package/dist/public/assets/ui-components-Di-9yNr4.js +1 -0
- package/dist/public/assets/{utils-Dt4Hs5eF.js → utils-DDDR42pW.js} +1 -1
- package/dist/public/assets/{whisper-wasm-BCJQtWoU.js → whisper-wasm-Cq5Ofwpd.js} +1 -1
- package/dist/public/index.html +10 -24
- package/dist/recommended-models.txt +13 -0
- package/package.json +8 -7
- package/dist/public/assets/account-view-DjLjq8T6.js +0 -1
- package/dist/public/assets/alert-dialog-BWqb8ENe.js +0 -1
- package/dist/public/assets/api-BbUzw5rb.js +0 -1
- package/dist/public/assets/browser-tab-BVsBMyo3.js +0 -1
- package/dist/public/assets/chat-input-container-Dh5eJPNP.js +0 -22
- package/dist/public/assets/commit-dialog-CfjW1f6P.js +0 -1
- package/dist/public/assets/context-menu-D_gX85jr.js +0 -1
- package/dist/public/assets/conversation-history-view-CKiv8CxD.js +0 -1
- package/dist/public/assets/create-repo-dialog-ByvOv7em.js +0 -1
- package/dist/public/assets/dialogs-config-CV8HzCCA.js +0 -51
- package/dist/public/assets/diff-view-CuEdnFtI.js +0 -3
- package/dist/public/assets/explorer-tab-view-CiDUcvE2.js +0 -2
- package/dist/public/assets/explorer-tree-cxPx2HiW.js +0 -1
- package/dist/public/assets/explorer-view-BCQNEBOZ.js +0 -1
- package/dist/public/assets/git-history-dialog-DKey5IQa.js +0 -1
- package/dist/public/assets/history-view-DDpROJvQ.js +0 -1
- package/dist/public/assets/index-BZwvl9X4.js +0 -29
- package/dist/public/assets/index-CihB-pLh.css +0 -1
- package/dist/public/assets/markdown-renderer-B1teF28W.js +0 -10
- package/dist/public/assets/mcp-server-card-CY-VLPhS.js +0 -1
- package/dist/public/assets/merged-pr-dialog-BfwdsytN.js +0 -1
- package/dist/public/assets/onboarding-BEy4bi0g.js +0 -1
- package/dist/public/assets/onboarding-dialog-GjczsXqi.js +0 -1
- package/dist/public/assets/page-toolbar-rWocuukR.js +0 -1
- package/dist/public/assets/project-settings-view-wlaXVds9.js +0 -1
- package/dist/public/assets/providers-list-view-BJsp9sta.js +0 -1
- package/dist/public/assets/pull-request-dialog-DDxX2W8n.js +0 -1
- package/dist/public/assets/pull-with-changes-dialog-BtXHWQ3k.js +0 -1
- package/dist/public/assets/push-before-pr-dialog-Cs54Vb76.js +0 -1
- package/dist/public/assets/radio-group-D2kNbZM6.js +0 -1
- package/dist/public/assets/react-vendor-DV_DP0Qd.js +0 -22
- package/dist/public/assets/resizable-jxPFsLog.js +0 -1
- package/dist/public/assets/rolldown-runtime-B1FJdls4.js +0 -1
- package/dist/public/assets/run-stop-button-N1JNjOlD.js +0 -2
- package/dist/public/assets/settings-general-view-BKcgxF5z.js +0 -1
- package/dist/public/assets/settings-instructions-view-DbQ3c3f1.js +0 -1
- package/dist/public/assets/settings-mcp-servers-view-D2_Brac1.js +0 -5
- package/dist/public/assets/settings-models-skeleton-BSV1GmZQ.js +0 -1
- package/dist/public/assets/settings-models-view-BhFuBHAE.js +0 -1
- package/dist/public/assets/settings-rules-view-qL__Zcav.js +0 -8
- package/dist/public/assets/settings-skills-view-Ccj8tTR9.js +0 -2
- package/dist/public/assets/settings-slash-commands-view-DyXAbQIp.js +0 -1
- package/dist/public/assets/settings-subagents-view-LcaON0Dq.js +0 -2
- package/dist/public/assets/settings-view-cLrxaSw4.js +0 -2
- package/dist/public/assets/side-panel-container-CCaF3ZtX.js +0 -2
- package/dist/public/assets/skeleton-DNfHG6mv.js +0 -1
- package/dist/public/assets/standard-list-item-PWOXi212.js +0 -1
- package/dist/public/assets/store-9Wm6Zyve.js +0 -4
- package/dist/public/assets/tab-context-BdML89mQ.js +0 -1
- package/dist/public/assets/tabs-BVcV8raO.js +0 -1
- package/dist/public/assets/terminal-panel-BG8UFUSX.js +0 -2
- package/dist/public/assets/textarea-CU-XhvgE.js +0 -1
- package/dist/public/assets/todos-view-DLC_0wx_.js +0 -1
- package/dist/public/assets/use-font-size-Bqn2rvp_.js +0 -1
- package/dist/public/assets/use-toast-CGSBJJb0.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-oojFghRi.js","assets/rolldown-runtime-aKtaBQYM.js","assets/git-ops-button-B6rEla5u.js","assets/monaco-CZnIWXyV.js","assets/monaco-Br_kD0ds.css","assets/dialogs-config-Ct6i8Iij.js","assets/diff-view-rKDEnBLg.js","assets/history-view-CFot099O.js","assets/onboarding-DHCR18iU.js","assets/context-menu-S8y0c1Fx.js","assets/react-vendor-CjZZeCRj.js","assets/utils-DDDR42pW.js","assets/terminal-panel-Ds1tCgQA.js","assets/explorer-tab-view-JbLbPVAn.js","assets/browser-tab-Qs8cnQkf.js","assets/settings-view-D5GE_CYR.js","assets/settings-models-skeleton-CN2JkqZh.js","assets/skeleton-pSKdmWyJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{$i as n,$n as r,$r as i,A as a,Ai as o,An as s,B as c,Ba as l,Bn as u,Bt as d,Ca as f,D as p,Da as m,Di as h,Dn as g,Ei as _,En as v,Et as y,Fa as b,Ft as x,Gn as S,Hi as C,Hn as w,I as T,Ja as E,Ji as D,Jn as O,Jt as k,K as A,Ka as j,Ki as M,Kn as N,L as P,La as F,Li as I,Ln as L,Lt as R,M as ee,Ma as z,Mi as B,Mn as V,Mt as te,Nn as ne,Oa as re,Oi as H,On as ie,P as ae,Pi as oe,Pn as se,Q as ce,Qa as le,Qi as ue,Qn as U,Qr as W,Qt as de,R as fe,Ra as pe,Ri as me,S as he,Sa as ge,St as _e,T as ve,Ta as ye,Tn as be,Tt as xe,U as Se,Ua as Ce,Ui as we,Un as Te,Ut as Ee,V as De,Va as Oe,Vi as ke,Wa as Ae,Wn as je,Wt as Me,Xr as G,Xt as Ne,Y as Pe,Yi as Fe,Yn as Ie,Yt as Le,Za as Re,Zi as ze,Zn as K,_ as Be,_a as Ve,_n as He,_r as Ue,_t as We,ba as Ge,bi as Ke,br as qe,c as Je,ca as Ye,cn as Xe,da as Ze,di as Qe,dn as $e,ea as et,ei as tt,er as q,et as nt,f as rt,fi as it,fn as at,fr as ot,g as st,ga as ct,gi as lt,gr as ut,gt as dt,ha as ft,hn as pt,hr as mt,ht,ia as gt,io as _t,ja as vt,jn as yt,k as bt,ki as xt,kn as St,l as Ct,la as wt,li as J,lr as Tt,lt as Et,m as Dt,mr as Ot,mt as kt,na as At,ni as jt,no as Mt,oa as Nt,oi as Pt,p as Ft,pa as It,pi as Lt,pn as Rt,pt as zt,q as Bt,qa as Vt,qi as Ht,qn as Ut,qt as Wt,ro as Gt,sa as Kt,si as qt,sn as Jt,ti as Yt,tn as Xt,to as Zt,ua as Qt,ui as $t,un as en,v as tn,vn as nn,vr as rn,vt as an,w as on,wa as sn,wn as cn,x as ln,xi as un,yi as dn,yn as fn,yr as pn,za as mn,zi as hn,zn as gn,zt as _n}from"./dialogs-config-Ct6i8Iij.js";import{$ as vn,A as yn,B as bn,D as xn,E as Sn,F as Cn,G as wn,H as Tn,I as En,J as Dn,K as On,L as kn,M as An,N as jn,O as Mn,P as Nn,Q as Pn,R as Fn,T as In,U as Ln,V as Rn,W as zn,X as Bn,Y as Vn,Z as Hn,at as Un,ct as Wn,et as Gn,it as Kn,j as qn,k as Jn,nt as Yn,ot as Xn,q as Zn,rt as Qn,st as $n,tt as er,ut as tr,w as nr,z as rr}from"./react-vendor-CjZZeCRj.js";import{r as ir}from"./monaco-CZnIWXyV.js";import{c as ar,l as or,r as sr,u as cr}from"./onboarding-DHCR18iU.js";import{A as lr,F as ur,M as dr,N as fr,O as pr,P as mr,a as hr,j as gr,k as _r,l as vr,n as yr,o as br,s as xr,x as Sr}from"./history-view-CFot099O.js";import{i as Cr,n as wr,r as Tr,t as Er}from"./whisper-wasm-Cq5Ofwpd.js";import{n as Dr,t as Or}from"./utils-DDDR42pW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=e(_t(),1),kr=tr(),X=Mt(),Ar=1e10,jr=1e3;function Mr(e,t){let n=e.map(e=>`"${e}"`).join(`, `);return Error(`This RPC instance cannot ${t} because the transport did not provide one or more of these methods: ${n}`)}function Nr(e={}){let t={},n={},r;function i(e){n.unregisterHandler&&n.unregisterHandler(),n=e,n.registerHandler?.(x)}function a(e){if(typeof e==`function`){r=e;return}r=(t,n)=>{let r=e[t];if(r)return r(n);let i=e._;if(!i)throw Error(`The requested method has no handler: ${String(t)}`);return i(t,n)}}let{maxRequestTime:o=jr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Ar?++s:s=0}let l=new Map,u=new Map;function d(e,...r){let i=r[0];return new Promise((r,a)=>{if(!n.send)throw Mr([`send`],`make requests`);let s=c(),d={type:`request`,id:s,method:e,params:i};l.set(s,{resolve:r,reject:a}),o!==1/0&&u.set(s,setTimeout(()=>{u.delete(s),l.delete(s),a(Error(`RPC request timed out.`))},o)),t.onSend?.(d),n.send(d)})}let f=new Proxy(d,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>d(t,e)}),p=f;function m(e,...r){let i=r[0];if(!n.send)throw Mr([`send`],`send messages`);let a={type:`message`,id:e,payload:i};t.onSend?.(a),n.send(a)}let h=new Proxy(m,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>m(t,e)}),g=h,_=new Map,v=new Set;function y(e,t){if(!n.registerHandler)throw Mr([`registerHandler`],`register message listeners`);if(e===`*`){v.add(t);return}_.has(e)||_.set(e,new Set),_.get(e).add(t)}function b(e,t){if(e===`*`){v.delete(t);return}_.get(e)?.delete(t),_.get(e)?.size===0&&_.delete(e)}async function x(e){if(t.onReceive?.(e),!(`type`in e))throw Error(`Message does not contain a type.`);if(e.type===`request`){if(!n.send||!r)throw Mr([`send`,`requestHandler`],`handle requests`);let{id:i,method:a,params:o}=e,s;try{s={type:`response`,id:i,success:!0,payload:await r(a,o)}}catch(e){if(!(e instanceof Error))throw e;s={type:`response`,id:i,success:!1,error:e.message}}t.onSend?.(s),n.send(s);return}if(e.type===`response`){let t=u.get(e.id);t!=null&&clearTimeout(t),u.delete(e.id);let{resolve:n,reject:r}=l.get(e.id)??{};l.delete(e.id),e.success?n?.(e.payload):r?.(Error(e.error));return}if(e.type===`message`){for(let t of v)t(e.id,e.payload);let t=_.get(e.id);if(!t)return;for(let n of t)n(e.payload);return}throw Error(`Unexpected RPC message type: ${e.type}`)}return{setTransport:i,setRequestHandler:a,request:f,requestProxy:p,send:h,sendProxy:g,addMessageListener:y,removeMessageListener:b,proxy:{send:g,request:p}}}function Pr(e,t){let n=Nr({maxRequestTime:t.maxRequestTime,requestHandler:{...t.handlers.requests,...t.extraRequestHandlers},transport:{registerHandler:()=>{}}}),r=t.handlers.messages;return r&&n.addMessageListener(`*`,((e,t)=>{let n=r[`*`];n&&n(e,t);let i=r[e];i&&i(t)})),n}var Fr=window.__electrobunWebviewId,Ir=window.__electrobunRpcSocketPort,Lr=class{bunSocket;rpc;rpcHandler;constructor(e){this.rpc=e.rpc,this.init()}init(){this.initSocketToBun(),window.__electrobun.receiveMessageFromBun=this.receiveMessageFromBun.bind(this),this.rpc&&this.rpc.setTransport(this.createTransport())}initSocketToBun(){let e=new WebSocket(`ws://localhost:${Ir}/socket?webviewId=${Fr}`);this.bunSocket=e,e.addEventListener(`open`,()=>{}),e.addEventListener(`message`,async e=>{let t=e.data;if(typeof t==`string`)try{let e=JSON.parse(t),n=await window.__electrobun_decrypt(e.encryptedData,e.iv,e.tag);this.rpcHandler?.(JSON.parse(n))}catch(e){console.error(`Error parsing bun message:`,e)}else t instanceof Blob||console.error(`UNKNOWN DATA TYPE RECEIVED:`,e.data)}),e.addEventListener(`error`,e=>{console.error(`Socket error:`,e)}),e.addEventListener(`close`,e=>{})}createTransport(){let e=this;return{send(t){try{let n=JSON.stringify(t);e.bunBridge(n)}catch(e){console.error(`bun: failed to serialize message to webview`,e)}},registerHandler(t){e.rpcHandler=t}}}async bunBridge(e){if(this.bunSocket?.readyState===WebSocket.OPEN)try{let{encryptedData:t,iv:n,tag:r}=await window.__electrobun_encrypt(e),i=JSON.stringify({encryptedData:t,iv:n,tag:r});this.bunSocket.send(i);return}catch(e){console.error(`Error sending message to bun via socket:`,e)}window.__electrobunBunBridge?.postMessage(e)}receiveMessageFromBun(e){this.rpcHandler&&this.rpcHandler(e)}static defineRPC(e){return Pr(`webview`,{...e,extraRequestHandlers:{evaluateJavascriptWithResponse:({script:e})=>new Promise(t=>{try{let n=Function(e)();n instanceof Promise?n.then(e=>{t(e)}).catch(e=>{console.error(`bun: async script execution failed`,e),t(String(e))}):t(n)}catch(e){console.error(`bun: failed to eval script`,e),t(String(e))}})}})}};function Rr(e){return typeof e==`string`?e.replace(/\\n/g,`
|
|
3
|
+
`).replace(/✅/g,`✓`):``}function zr(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=/\[([A-Za-z]+)\]\s*/g,r,i=0;for(let e of t.matchAll(n))r=e[1],i=e.index+e[0].length;let a=r,o=a?t.slice(i):t;if(a&&o)return[{type:`reasoning`,text:o,label:a}];let s=[],c=0;for(;c<t.length;){let e=t.indexOf(`[`,c);if(e===-1){let e=t.slice(c).trim();e&&s.push({type:`reasoning`,text:e});break}let n=t.slice(c,e).trim();n&&s.push({type:`reasoning`,text:n});let r=0,i=-1;for(let n=e;n<t.length;n++)if(t[n]===`[`)r++;else if(t[n]===`]`&&(r--,r===0)){i=n;break}if(i===-1){let n=t.slice(e).trim();n&&s.push({type:`reasoning`,text:n});break}try{let n=JSON.parse(t.slice(e,i+1));if(Array.isArray(n)){for(let e of n)if(e&&typeof e==`object`&&`type`in e){let t=e.type;(t===`tool-result`||t===`tool_use`)&&s.push(e)}}}catch{let n=t.slice(e,i+1).trim();n&&s.push({type:`reasoning`,text:n})}c=i+1}return s.length>0?s:null}function Br(e){return e.map(e=>{if(typeof e==`object`&&e&&!(`type`in e)){let t=e;if(t.reasoning)return{type:`reasoning`,text:typeof t.reasoning==`string`?t.reasoning:JSON.stringify(t.reasoning)};let n=t.text??t.content??t.answer;if(n)return{type:`text`,text:typeof n==`string`?n:JSON.stringify(n)}}return e})}function Vr(e){let t=[];if(e.type===`long_running_confirmation`&&typeof e.prompt==`object`&&e.prompt!==null&&typeof e.prompt.question==`string`&&Array.isArray(e.prompt.options)){let n=e.prompt;return t.push({type:`long_running_confirmation`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:void 0,question:n.question,options:n.options.filter(e=>typeof e==`string`),context:typeof n.context==`string`?n.context:void 0}}),t}if(e.type===`shell_permission`&&typeof e.shellPermission==`object`&&e.shellPermission!==null&&typeof e.shellPermission.command==`string`){let n=e.shellPermission;return t.push({type:`shell_permission`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:`shell-permission`,command:n.command,source:n.source===`bash`||n.source===`skill_script`||n.source===`browser_js`?n.source:`bash`,wildcardOptions:Array.isArray(n.wildcardOptions)?n.wildcardOptions.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`&&typeof e.pattern==`string`&&(e.scope===`session`||e.scope===`project`)):[]}}),t}if(e.type===`web_fetch_permission`&&typeof e.webFetchPermission==`object`&&e.webFetchPermission!==null&&typeof e.webFetchPermission.hostname==`string`){let n=e.webFetchPermission;return t.push({type:`web_fetch_permission`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:`web-fetch-permission`,hostname:n.hostname,url:typeof n.url==`string`?n.url:``,wildcardOptions:Array.isArray(n.wildcardOptions)?n.wildcardOptions.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`&&typeof e.pattern==`string`&&(e.scope===`session`||e.scope===`project`)):[]}}),t}e.reasoning&&typeof e.reasoning==`string`&&t.push({type:`reasoning`,text:e.reasoning});let n=(typeof e.text==`string`?e.text:null)??(typeof e.content==`string`?e.content:null)??(typeof e.answer==`string`?e.answer:null);return n&&t.push({type:`text`,text:n}),t.length===0&&Object.keys(e).length>0&&t.push({type:`text`,text:JSON.stringify(e,null,2)}),t}function Hr(e){if(!e)return null;let t=e.trim();if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return Br(e);if(typeof e==`object`&&e)return Vr(e)}catch{}let n=[],r=e.indexOf(`{`),i=e.indexOf(`[`),a=r===-1?i:i===-1?r:Math.min(r,i);if(a!==-1){let t=e.slice(a),r=Math.max(t.lastIndexOf(`]`),t.lastIndexOf(`}`));if(r!==-1){let e=t.substring(0,r+1);try{let i=JSON.parse(e);Array.isArray(i)?n.push(...Br(i)):n.push(...Vr(i));let a=t.substring(r+1).trim();return a&&n.push({type:`text`,text:a}),n}catch{}}}return null}function Ur(e,t,n){let r=e[e.length-1];return r?.type===t?[...e.slice(0,-1),{type:t,chunks:[...r.chunks,n]}]:[...e,{type:t,chunks:[n]}]}function Wr(e,t){return e[e.length-1]?.type===`content`?[...e.slice(0,-1),{type:`content`,chunks:[t]}]:[...e,{type:`content`,chunks:[t]}]}function Gr(e,t){return[...e,{type:`long_running_confirmation`,prompt:t}]}function Kr(e,t){return[...e,{type:`shell_permission`,prompt:t}]}function qr(e,t){return[...e,{type:`web_fetch_permission`,prompt:t}]}function Jr(e){let t=[];for(let n of e){if(n.type===`long_running_confirmation`){t.push({type:`long_running_confirmation`,prompt:n.prompt});continue}if(n.type===`shell_permission`){t.push({type:`shell_permission`,prompt:n.prompt});continue}if(n.type===`web_fetch_permission`){t.push({type:`web_fetch_permission`,prompt:n.prompt});continue}let e=n.chunks.join(``);if(n.type===`thinking`){let n=zr(e)??[];t.push(...n)}else{let n=Hr(e)??(e.trim()?[{type:`text`,text:e}]:[]);t.push(...n)}}return t}function Yr(e,t=!1){let n=[],r=[],i,a=()=>{r.length>0&&(n.push({type:`thinking-group`,text:r.join(`
|
|
4
|
+
|
|
5
|
+
`),label:i,isCurrentlyStreaming:!1}),r=[],i=void 0)};for(let t of e)if(t.type===`reasoning`&&`text`in t){let e=t;r.push(e.text),e.label&&(i=e.label)}else a(),n.push(t);if(a(),t&&n.length>0){let e=n[n.length-1];if(e.type===`thinking-group`){let t=e;t.label!==`Validated`&&(t.isCurrentlyStreaming=!0)}}return n}function Xr(e){let t=Jr(e);return t.length===0?`...`:t.length===1&&t[0]?.type===`text`&&`text`in t[0]?t[0].text:JSON.stringify(t)}var Z=function(e){return e.SetProjects=`SET_PROJECTS`,e.SetProjectsLoading=`SET_PROJECTS_LOADING`,e.SelectThread=`SELECT_THREAD`,e.SetMessages=`SET_MESSAGES`,e.AddMessage=`ADD_MESSAGE`,e.EnqueueChatMessage=`ENQUEUE_CHAT_MESSAGE`,e.RemoveQueuedChatMessage=`REMOVE_QUEUED_CHAT_MESSAGE`,e.SetStreaming=`SET_STREAMING`,e.AppendStreamContent=`APPEND_STREAM_CONTENT`,e.SetStreamContent=`SET_STREAM_CONTENT`,e.AppendStreamThinking=`APPEND_STREAM_THINKING`,e.AppendStreamChunk=`APPEND_STREAM_CHUNK`,e.SetStreamModel=`SET_STREAM_MODEL`,e.SetProjectModel=`SET_PROJECT_MODEL`,e.ResetStream=`RESET_STREAM`,e.StopStream=`STOP_STREAM`,e.ToggleSidebar=`TOGGLE_SIDEBAR`,e.SetCreatingProject=`SET_CREATING_PROJECT`,e.ConfigUpdated=`CONFIG_UPDATED`,e.SetProcessingThreads=`SET_PROCESSING_THREADS`,e.AddProcessingThread=`ADD_PROCESSING_THREAD`,e.RemoveProcessingThread=`REMOVE_PROCESSING_THREAD`,e.AddCreatingProject=`ADD_CREATING_PROJECT`,e.AddCreatingThread=`ADD_CREATING_THREAD`,e.RemoveCreatingProject=`REMOVE_CREATING_PROJECT`,e.RemoveCreatingThread=`REMOVE_CREATING_THREAD`,e.MarkThreadCompleted=`MARK_THREAD_COMPLETED`,e.ClearThreadCompleted=`CLEAR_THREAD_COMPLETED`,e.AddDeletingThread=`ADD_DELETING_THREAD`,e.RemoveDeletingThread=`REMOVE_DELETING_THREAD`,e.AddDeletingProject=`ADD_DELETING_PROJECT`,e.RemoveDeletingProject=`REMOVE_DELETING_PROJECT`,e.AppendCommandOutput=`APPEND_COMMAND_OUTPUT`,e.SetRunningCommand=`SET_RUNNING_COMMAND`,e.ClearCommandOutput=`CLEAR_COMMAND_OUTPUT`,e.ToggleTerminal=`TOGGLE_TERMINAL`,e.SetTerminalOpen=`SET_TERMINAL_OPEN`,e.QueueTerminalCommand=`QUEUE_TERMINAL_COMMAND`,e.ClearQueuedTerminalCommand=`CLEAR_QUEUED_TERMINAL_COMMAND`,e.AppendTerminalLine=`APPEND_TERMINAL_LINE`,e.ClearTerminalOutput=`CLEAR_TERMINAL_OUTPUT`,e.SetTerminalHeight=`SET_TERMINAL_HEIGHT`,e.SetTerminalCwd=`SET_TERMINAL_CWD`,e.SetTerminalRunning=`SET_TERMINAL_RUNNING`,e.SetTerminalHistory=`SET_TERMINAL_HISTORY`,e.SetTerminalHistoryIndex=`SET_TERMINAL_HISTORY_INDEX`,e.UpdateThreadTitle=`UPDATE_THREAD_TITLE`,e.ClearFocusChatInput=`CLEAR_FOCUS_CHAT_INPUT`,e.ClearMessages=`CLEAR_MESSAGES`,e.UpdateToolCallProgress=`UPDATE_TOOL_CALL_PROGRESS`,e.UpdateToolExecutionOutput=`UPDATE_TOOL_EXECUTION_OUTPUT`,e.ClearToolCallProgress=`CLEAR_TOOL_CALL_PROGRESS`,e.SetPendingChatMessage=`SET_PENDING_CHAT_MESSAGE`,e.ClearPendingChatMessage=`CLEAR_PENDING_CHAT_MESSAGE`,e.IncrementStreamEventCount=`INCREMENT_STREAM_EVENT_COUNT`,e.SetDiffComments=`SET_DIFF_COMMENTS`,e.ClearSelection=`CLEAR_SELECTION`,e.SetChatInputDraft=`SET_CHAT_INPUT_DRAFT`,e.ClearChatInputDraft=`CLEAR_CHAT_INPUT_DRAFT`,e}({}),Zr={isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0};function Qr(){return{...Zr,streamingSegments:[]}}function $r(e,t){return t?e[t]??Qr():Qr()}function ei(e,t){return t.threadId??e.selectedThreadId}function ti(e,t,n,r=!1){if(!t)return{...e,...n,toolCallProgress:r?{}:e.toolCallProgress};let i={...e.threadStreamingStates,[t]:n};return t===e.selectedThreadId?{...e,...n,threadStreamingStates:i,toolCallProgress:r?{}:e.toolCallProgress}:{...e,threadStreamingStates:i}}var ni={projects:[],projectsLoading:!0,selectedThreadId:null,selectedProjectId:null,messages:[],messagesLoaded:!1,queuedChatMessages:[],isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0,threadStreamingStates:{},projectModelSelections:{},sidebarOpen:!0,isCreatingProject:!1,configUpdatedAt:0,processingThreadIds:[],completedThreadIds:[],deletingThreadIds:[],deletingProjectIds:[],commandOutput:``,isRunningCommand:!1,terminalStates:{},focusChatInput:!1,toolCallProgress:{},pendingChatMessage:null,diffComments:{},chatInputDrafts:{}};function ri(e,t){switch(t.type){case`SET_PROJECTS`:{let n={...e.projectModelSelections};for(let e of t.projects)for(let t of e.threads){if(!t.model)continue;let e=n[t.threadId];n[t.threadId]={id:t.model,provider:t.modelProvider,name:e?.name??t.model,description:e?.description??``,context_length:e?.context_length,contextWindow:e?.contextWindow,features:e?.features,input_modalities:e?.input_modalities,max_output:e?.max_output,pricing:e?.pricing,tarsk_use:e?.tarsk_use,coding_index:e?.coding_index,supportsImages:e?.supportsImages}}return{...e,projects:t.projects,projectModelSelections:n}}case`SET_PROJECTS_LOADING`:return{...e,projectsLoading:t.projectsLoading};case`SELECT_THREAD`:{let n=$r(e.threadStreamingStates,t.threadId);return{...e,...n,selectedThreadId:t.threadId,selectedProjectId:t.projectId,messages:t.initialMessages??[],messagesLoaded:!1,focusChatInput:t.focusInput??!1}}case`CLEAR_SELECTION`:return{...e,...Qr(),selectedThreadId:null,selectedProjectId:null,messages:[],messagesLoaded:!1};case`SET_MESSAGES`:return{...e,messages:t.messages,messagesLoaded:!0};case`ADD_MESSAGE`:return t.threadId&&t.threadId!==e.selectedThreadId?e:{...e,messages:[...e.messages,t.message]};case`ENQUEUE_CHAT_MESSAGE`:return{...e,queuedChatMessages:[...e.queuedChatMessages,t.message]};case`REMOVE_QUEUED_CHAT_MESSAGE`:return{...e,queuedChatMessages:e.queuedChatMessages.filter(e=>e.id!==t.queuedMessageId)};case`SET_STREAMING`:{let n=ei(e,t);return ti(e,n,{...$r(e.threadStreamingStates,n),isStreaming:t.isStreaming})}case`APPEND_STREAM_CONTENT`:{let n=ei(e,t),r=$r(e.threadStreamingStates,n);return ti(e,n,{...r,streamingContent:r.streamingContent+t.content})}case`SET_STREAM_CONTENT`:{let n=ei(e,t),r=$r(e.threadStreamingStates,n),i=Wr(r.streamingSegments,t.content);return ti(e,n,{...r,streamingContent:t.content,streamingSegments:i})}case`APPEND_STREAM_THINKING`:{let n=ei(e,t),r=$r(e.threadStreamingStates,n);return ti(e,n,{...r,streamingThinking:r.streamingThinking+t.content})}case`INCREMENT_STREAM_EVENT_COUNT`:{let n=ei(e,t),r=$r(e.threadStreamingStates,n);return ti(e,n,{...r,streamingEventCount:r.streamingEventCount+1})}case`APPEND_STREAM_CHUNK`:{let n=ei(e,t),r=$r(e.threadStreamingStates,n);return ti(e,n,{...r,streamingSegments:t.segments,streamingContent:t.chunkType===`content`?r.streamingContent+t.content:r.streamingContent,streamingThinking:t.chunkType===`thinking`?r.streamingThinking+t.content:r.streamingThinking})}case`SET_STREAM_MODEL`:{let n=ei(e,t);return ti(e,n,{...$r(e.threadStreamingStates,n),streamingModel:t.model})}case`SET_PROJECT_MODEL`:return console.log(`[Store] SetProjectModel action:`,{threadId:t.threadId,model:{id:t.model.id,provider:t.model.provider}}),{...e,projects:e.projects.map(e=>({...e,threads:e.threads.map(e=>e.threadId===t.threadId?{...e,model:t.model.id,modelProvider:t.model.provider}:e)})),projectModelSelections:{...e.projectModelSelections,[t.threadId]:t.model}};case`RESET_STREAM`:return ti(e,ei(e,t),Qr(),!0);case`STOP_STREAM`:{let n=ei(e,t);return ti(e,n,{...$r(e.threadStreamingStates,n),isStreaming:!1})}case`TOGGLE_SIDEBAR`:return{...e,sidebarOpen:!e.sidebarOpen};case`SET_CREATING_PROJECT`:return{...e,isCreatingProject:t.isCreating};case`CONFIG_UPDATED`:return{...e,configUpdatedAt:Date.now()};case`SET_PROCESSING_THREADS`:return{...e,processingThreadIds:t.threadIds};case`ADD_PROCESSING_THREAD`:return{...e,processingThreadIds:e.processingThreadIds.includes(t.threadId)?e.processingThreadIds:[...e.processingThreadIds,t.threadId]};case`REMOVE_PROCESSING_THREAD`:return{...e,processingThreadIds:e.processingThreadIds.filter(e=>e!==t.threadId)};case`ADD_CREATING_PROJECT`:return{...e,projects:[...e.projects,{projectId:t.projectId,name:t.projectName,gitUrl:t.gitUrl,threads:[{threadId:t.threadId,title:`thread-1`,path:``,currentBranch:``}]}]};case`ADD_CREATING_THREAD`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:[...e.threads,{threadId:t.threadId,title:t.title,path:``,currentBranch:``}]}:e)};case`REMOVE_CREATING_PROJECT`:return{...e,projects:e.projects.filter(e=>e.projectId!==t.projectId)};case`REMOVE_CREATING_THREAD`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:e.threads.filter(e=>e.threadId!==t.threadId)}:e)};case`MARK_THREAD_COMPLETED`:return{...e,completedThreadIds:e.completedThreadIds.includes(t.threadId)?e.completedThreadIds:[...e.completedThreadIds,t.threadId]};case`CLEAR_THREAD_COMPLETED`:return{...e,completedThreadIds:e.completedThreadIds.filter(e=>e!==t.threadId)};case`ADD_DELETING_THREAD`:return{...e,deletingThreadIds:e.deletingThreadIds.includes(t.threadId)?e.deletingThreadIds:[...e.deletingThreadIds,t.threadId]};case`REMOVE_DELETING_THREAD`:return{...e,deletingThreadIds:e.deletingThreadIds.filter(e=>e!==t.threadId)};case`ADD_DELETING_PROJECT`:return{...e,deletingProjectIds:e.deletingProjectIds.includes(t.projectId)?e.deletingProjectIds:[...e.deletingProjectIds,t.projectId]};case`REMOVE_DELETING_PROJECT`:return{...e,deletingProjectIds:e.deletingProjectIds.filter(e=>e!==t.projectId)};case`APPEND_COMMAND_OUTPUT`:return{...e,commandOutput:e.commandOutput+t.content};case`SET_RUNNING_COMMAND`:return{...e,isRunningCommand:t.isRunning};case`CLEAR_COMMAND_OUTPUT`:return{...e,commandOutput:``};case`TOGGLE_TERMINAL`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,open:!r.open}}}}case`SET_TERMINAL_OPEN`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,open:t.open}}}}case`QUEUE_TERMINAL_COMMAND`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,queuedCommand:t.command,queuedRelativeFolder:t.relativeFolder??null,open:!0}}}}case`CLEAR_QUEUED_TERMINAL_COMMAND`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,queuedCommand:null}}}}case`APPEND_TERMINAL_LINE`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,outputLines:[...r.outputLines,t.line]}}}}case`CLEAR_TERMINAL_OUTPUT`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,outputLines:[]}}}}case`SET_TERMINAL_HEIGHT`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,height:t.height}}}}case`SET_TERMINAL_CWD`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,cwd:t.cwd}}}}case`SET_TERMINAL_RUNNING`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,isRunning:t.isRunning}}}}case`SET_TERMINAL_HISTORY`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,history:t.history}}}}case`SET_TERMINAL_HISTORY_INDEX`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,historyIndex:t.index}}}}case`UPDATE_THREAD_TITLE`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:e.threads.map(e=>e.threadId===t.threadId?{...e,title:t.title}:e)}:e)};case`CLEAR_FOCUS_CHAT_INPUT`:return{...e,focusChatInput:!1};case`CLEAR_MESSAGES`:return{...e,messages:[]};case`UPDATE_TOOL_CALL_PROGRESS`:{let n=e.toolCallProgress[t.toolCallId];return{...e,toolCallProgress:{...e.toolCallProgress,[t.toolCallId]:{...n,...t.progress}}}}case`UPDATE_TOOL_EXECUTION_OUTPUT`:{let n=e.toolCallProgress[t.toolCallId];return{...e,toolCallProgress:{...e.toolCallProgress,[t.toolCallId]:{toolCallId:t.toolCallId,toolName:t.toolName??n?.toolName??``,delta:n?.delta??``,partial:n?.partial??{role:`tool`,content:[]},executionOutput:t.executionOutput}}}}case`CLEAR_TOOL_CALL_PROGRESS`:{if(!t.toolCallId)return{...e,toolCallProgress:{}};let{[t.toolCallId]:n,...r}=e.toolCallProgress;return{...e,toolCallProgress:r}}case`SET_PENDING_CHAT_MESSAGE`:return{...e,pendingChatMessage:t.message};case`CLEAR_PENDING_CHAT_MESSAGE`:return{...e,pendingChatMessage:null};case`SET_DIFF_COMMENTS`:return{...e,diffComments:{...e.diffComments,[t.threadId]:t.comments}};case`SET_CHAT_INPUT_DRAFT`:return{...e,chatInputDrafts:{...e.chatInputDrafts,[t.threadId]:t.draft}};case`CLEAR_CHAT_INPUT_DRAFT`:{let{[t.threadId]:n,...r}=e.chatInputDrafts;return{...e,chatInputDrafts:r}}default:return e}}function ii(e=ni){let t=e,n=new Set;function r(){return t}function i(e){let r=ri(t,e);if(r!==t){t=r;for(let e of n)e()}}function a(e){return n.add(e),function(){n.delete(e)}}return{getState:r,dispatch:i,subscribe:a}}var ai=(0,Y.createContext)(null);function oi(){let e=(0,Y.useContext)(ai);if(!e)throw Error(`useAppStore must be used within an AppStoreContext.Provider`);return e}function Q(e){let t=(0,X.c)(3),n=oi(),r;t[0]!==e||t[1]!==n?(r=function(){return e(n.getState())},t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r;return(0,Y.useSyncExternalStore)(n.subscribe,i,i)}function si(){return oi().dispatch}var ci={open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};function li(e){let t=(0,X.c)(8),n=si(),r;t[0]===e?r=t[1]:(r=t=>(e?t.terminalStates[e]:void 0)??ci,t[0]=e,t[1]=r);let i=Q(r),a;t[2]!==n||t[3]!==e?(a=t=>{e&&n({...t,threadId:e})},t[2]=n,t[3]=e,t[4]=a):a=t[4];let o=a,s;return t[5]!==o||t[6]!==i?(s={terminalState:i,dispatch:o},t[5]=o,t[6]=i,t[7]=s):s=t[7],s}var $=lt(),ui=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(`textarea`,{className:a,ref:t,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ui.displayName=`Textarea`;function di(e){let t=(0,X.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:l,loadingFeedbackUser:u,submittingFeedback:d,onSubmit:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsxs)(pn,{children:[(0,$.jsx)(qe,{children:`Send Feedback`}),(0,$.jsx)(Ue,{children:`Share feedback about Tarsk.`})]}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(ot,{htmlFor:`feedback-name`,children:`Name`}),t[1]=m):m=t[1];let h;t[2]===a?h=t[3]:(h=e=>a(e.target.value),t[2]=a,t[3]=h);let g=d||u,_;t[4]!==i||t[5]!==h||t[6]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[m,(0,$.jsx)(Ot,{id:`feedback-name`,value:i,onChange:h,placeholder:`Your name`,disabled:g})]}),t[4]=i,t[5]=h,t[6]=g,t[7]=_):_=t[7];let v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ot,{htmlFor:`feedback-email`,children:`Email`}),t[8]=v):v=t[8];let y;t[9]===s?y=t[10]:(y=e=>s(e.target.value),t[9]=s,t[10]=y);let b=d||u,x;t[11]!==o||t[12]!==y||t[13]!==b?(x=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(Ot,{id:`feedback-email`,type:`email`,value:o,onChange:y,placeholder:`you@example.com`,disabled:b})]}),t[11]=o,t[12]=y,t[13]=b,t[14]=x):x=t[14];let S;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(ot,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=S):S=t[15];let C;t[16]===l?C=t[17]:(C=e=>l(e.target.value),t[16]=l,t[17]=C);let w;t[18]!==c||t[19]!==d||t[20]!==C?(w=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsx)(ui,{id:`feedback-text`,value:c,onChange:C,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:d})]}),t[18]=c,t[19]=d,t[20]=C,t[21]=w):w=t[21];let T;t[22]!==w||t[23]!==_||t[24]!==x?(T=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[_,x,w]}),t[22]=w,t[23]=_,t[24]=x,t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=()=>r(!1),t[26]=r,t[27]=E);let D;t[28]!==d||t[29]!==E?(D=(0,$.jsx)(G,{variant:`outline`,onClick:E,disabled:d,children:`Cancel`}),t[28]=d,t[29]=E,t[30]=D):D=t[30];let O;t[31]===d?O=t[32]:(O=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wt,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send`,t[31]=d,t[32]=O);let k;t[33]!==f||t[34]!==d||t[35]!==O?(k=(0,$.jsx)(G,{onClick:f,disabled:d,children:O}),t[33]=f,t[34]=d,t[35]=O,t[36]=k):k=t[36];let A;t[37]!==D||t[38]!==k?(A=(0,$.jsxs)(rn,{children:[D,k]}),t[37]=D,t[38]=k,t[39]=A):A=t[39];let j;t[40]!==T||t[41]!==A?(j=(0,$.jsxs)(ut,{className:`max-w-xl`,children:[p,T,A]}),t[40]=T,t[41]=A,t[42]=j):j=t[42];let M;return t[43]!==r||t[44]!==n||t[45]!==j?(M=(0,$.jsx)(mt,{open:n,onOpenChange:r,children:j}),t[43]=r,t[44]=n,t[45]=j,t[46]=M):M=t[46],M}function fi(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(fi,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function pi(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Y.useState)(f),[h,g]=(0,Y.useState)(i);i!==h&&(g(i),m({}));let _;t[1]===o?_=t[2]:(_=o?new Set(o):void 0,t[1]=o,t[2]=_);let v=_,y;t[3]===u?y=t[4]:(y=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=y);let b=y,x;t[5]===l?x=t[6]:(x=W(`min-w-0`,l),t[5]=l,t[6]=x);let S;if(t[7]!==c||t[8]!==u||t[9]!==v||t[10]!==b||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==v||t[19]!==b||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,$.jsx)(fi,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:b,forceOpenIds:v},e.id),t[16]=c,t[17]=u,t[18]=v,t[19]=b,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],S=n.map(e),t[7]=c,t[8]=u,t[9]=v,t[10]=b,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=S}else S=t[15];let C;return t[24]!==x||t[25]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[24]=x,t[25]=S,t[26]=C):C=t[26],C}var mi=1,hi=1e6,gi=0;function _i(){return gi=(gi+1)%(2**53-1),gi.toString()}var vi=new Map,yi=e=>{if(vi.has(e))return;let t=setTimeout(()=>{vi.delete(e),Ci({type:`REMOVE_TOAST`,toastId:e})},hi);vi.set(e,t)},bi=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,mi)};case`UPDATE_TOAST`:return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case`DISMISS_TOAST`:{let{toastId:n}=t;return n?yi(n):e.toasts.forEach(e=>{yi(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||n===void 0?{...e,open:!1}:e)}}case`REMOVE_TOAST`:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},xi=[],Si={toasts:[]};function Ci(e){Si=bi(Si,e),xi.forEach(e=>{e(Si)})}function wi({...e}){let t=_i(),n=e=>Ci({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>Ci({type:`DISMISS_TOAST`,toastId:t});return Ci({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function Ti(){let e=(0,X.c)(4),[t,n]=Y.useState(Si),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(xi.push(n),()=>{let e=xi.indexOf(n);e>-1&&xi.splice(e,1)}),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i);let a;return e[2]===t?a=e[3]:(a={...t,toast:wi,dismiss:Ei},e[2]=t,e[3]=a),a}function Ei(e){return Ci({type:`DISMISS_TOAST`,toastId:e})}function Di(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),_e().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&wi({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){wi({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await Ie(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),wi({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){wi({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Oi(e){let t=(0,X.c)(28),{children:n,collapsed:r,title:i,onTitleClose:a,subtitle:o,headerAction:s,footer:c,onLogoClick:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={containerType:`inline-size`,height:`calc(100% - 32px)`},t[0]=u):u=t[0];let d=l&&`cursor-pointer`,f;t[1]===d?f=t[2]:(f=W(`h-full w-full`,d),t[1]=d,t[2]=f);let p;t[3]!==l||t[4]!==f?(p=(0,$.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center overflow-hidden rounded-md border border-sidebar-border shadow-sm`,children:(0,$.jsx)(`img`,{src:`/tarsk.svg`,alt:`Tarsk`,className:f,onClick:l})}),t[3]=l,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==r||t[7]!==o?(m=!r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:J.sectionTitle,children:`Tarsk`}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{className:`h-3 w-3 text-sidebar-foreground/60`}),(0,$.jsx)(`span`,{className:W(J.label,`text-sidebar-foreground/80`),children:o})]})]}),t[6]=r,t[7]=o,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==r||t[13]!==s||t[14]!==a||t[15]!==i?(g=(i??a??s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[s&&!r&&s,i&&(0,$.jsx)(`span`,{className:W(J.compact,`font-medium text-sidebar-foreground/80`),children:i}),a&&(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-sidebar-foreground`,onClick:a,children:[(0,$.jsx)(un,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),t[12]=r,t[13]=s,t[14]=a,t[15]=i,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-3 h-[61px]`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]===n?v=t[21]:(v=(0,$.jsx)(Tt,{className:`flex-1`,children:n}),t[20]=n,t[21]=v);let y;t[22]===c?y=t[23]:(y=c&&(0,$.jsx)(`div`,{className:`border-t border-sidebar-border`,children:c}),t[22]=c,t[23]=y);let b;return t[24]!==y||t[25]!==_||t[26]!==v?(b=(0,$.jsxs)(`div`,{className:`flex flex-col select-none bg-sidebar text-sidebar-foreground mx-2.5 mt-8 mr-10 rounded-3xl shadow-2xl overflow-hidden`,style:u,children:[_,v,y]}),t[24]=y,t[25]=_,t[26]=v,t[27]=b):b=t[27],b}function ki(e){let t=(0,X.c)(80),{projects:n,selectedThreadId:i,selectedProjectId:a,processingThreadIds:o,completedThreadIds:s,deletingThreadIds:c,deletingProjectIds:l,onSelectThread:u,onCreateProject:d,onCreateThread:f,onDeleteThread:p,onDeleteProject:m,onDeselect:h,collapsed:g,updateAvailable:_,updatingApp:v,onUpdateApp:y,expandProjectId:b}=e,x=Wn(),{showFeedback:S,feedbackName:C,setFeedbackName:w,feedbackEmail:T,setFeedbackEmail:E,feedbackText:O,setFeedbackText:k,loadingFeedbackUser:A,submittingFeedback:j,handleFeedbackDialogChange:M,handleSubmitFeedback:N}=Di(),P;t[0]===n?P=t[1]:(P=n.map(Ai),t[0]=n,t[1]=P);let F=P,I;t[2]!==g||t[3]!==d?(I=!g&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:d,children:[(0,$.jsx)(D,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=d,t[4]=I):I=t[4];let L;t[5]!==g||t[6]!==y||t[7]!==_||t[8]!==v?(L=_&&(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:y,disabled:v,children:[v?(0,$.jsx)(wt,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(z,{className:`h-4 w-4`}),!g&&(0,$.jsx)(`span`,{className:`truncate`,children:v?`Updating...`:`Update to Latest`})]}),t[5]=g,t[6]=y,t[7]=_,t[8]=v,t[9]=L):L=t[9];let R;t[10]===x?R=t[11]:(R=()=>void x(`/settings/general`),t[10]=x,t[11]=R);let ee;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(me,{className:`h-4 w-4`}),t[12]=ee):ee=t[12];let B;t[13]===g?B=t[14]:(B=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=g,t[14]=B);let V;t[15]!==R||t[16]!==B?(V=(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:R,children:[ee,B]}),t[15]=R,t[16]=B,t[17]=V):V=t[17];let te;t[18]===M?te=t[19]:(te=()=>M(!0),t[18]=M,t[19]=te);let ne,re;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Kt,{className:`h-4 w-4`}),ne=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=ne,t[21]=re):(ne=t[20],re=t[21]);let H;t[22]===te?H=t[23]:(H=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:te,children:[re,ne]})}),t[22]=te,t[23]=H);let ie;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(U,{children:`Send feedback to the Tarsk team`}),t[24]=ie):ie=t[24];let ae;t[25]===H?ae=t[26]:(ae=(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[H,ie]})}),t[25]=H,t[26]=ae);let oe;t[27]!==ae||t[28]!==V?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[V,ae]}),t[27]=ae,t[28]=V,t[29]=oe):oe=t[29];let se;t[30]!==oe||t[31]!==L?(se=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[L,oe]}),t[30]=oe,t[31]=L,t[32]=se):se=t[32];let ce;t[33]===n.length?ce=t[34]:(ce=n.length===0&&(0,$.jsx)(`p`,{className:W(J.compact,`px-3 py-6 text-center text-muted-foreground`),children:`No projects yet. Clone a repository to get started.`}),t[33]=n.length,t[34]=ce);let le;t[35]===b?le=t[36]:(le=b?[b]:void 0,t[35]=b,t[36]=le);let ue;t[37]!==s||t[38]!==l||t[39]!==c||t[40]!==x||t[41]!==f||t[42]!==m||t[43]!==p||t[44]!==u||t[45]!==o||t[46]!==n||t[47]!==a||t[48]!==i?(ue=(e,t)=>{let{isOpen:r,toggle:d}=t;return e.kind===`project`?(0,$.jsx)(ji,{project:e.project,isOpen:r,onToggle:d,isDeletingProject:l.includes(e.project.projectId),isSelected:a?e.project.projectId===a:!1,onCreateThread:f,onDeleteProject:m,onProjectSettings:e=>void x(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===i)}):(0,$.jsx)(Mi,{thread:e.thread,projectId:e.projectId,selectedThreadId:i,isProcessing:o.includes(e.thread.threadId),isDeleting:c.includes(e.thread.threadId),isCompleted:s.includes(e.thread.threadId),projectTitlePrefix:`${tt(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:u,onDeleteThread:p})},t[37]=s,t[38]=l,t[39]=c,t[40]=x,t[41]=f,t[42]=m,t[43]=p,t[44]=u,t[45]=o,t[46]=n,t[47]=a,t[48]=i,t[49]=ue):ue=t[49];let de;t[50]!==F||t[51]!==le||t[52]!==ue?(de=(0,$.jsx)(pi,{nodes:F,defaultOpen:!0,forceOpenIds:le,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ue}),t[50]=F,t[51]=le,t[52]=ue,t[53]=de):de=t[53];let fe;t[54]!==ce||t[55]!==de?(fe=(0,$.jsx)(Tt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ce,de]})}),t[54]=ce,t[55]=de,t[56]=fe):fe=t[56];let pe;t[57]!==g||t[58]!==h||t[59]!==se||t[60]!==I||t[61]!==fe?(pe=(0,$.jsx)(Oi,{collapsed:g,onLogoClick:h,headerAction:I,footer:se,children:fe}),t[57]=g,t[58]=h,t[59]=se,t[60]=I,t[61]=fe,t[62]=pe):pe=t[62];let he;t[63]===N?he=t[64]:(he=()=>void N(),t[63]=N,t[64]=he);let ge;t[65]!==T||t[66]!==C||t[67]!==O||t[68]!==M||t[69]!==A||t[70]!==E||t[71]!==w||t[72]!==k||t[73]!==S||t[74]!==j||t[75]!==he?(ge=(0,$.jsx)(di,{open:S,onOpenChange:M,feedbackName:C,onFeedbackNameChange:w,feedbackEmail:T,onFeedbackEmailChange:E,feedbackText:O,onFeedbackTextChange:k,loadingFeedbackUser:A,submittingFeedback:j,onSubmit:he}),t[65]=T,t[66]=C,t[67]=O,t[68]=M,t[69]=A,t[70]=E,t[71]=w,t[72]=k,t[73]=S,t[74]=j,t[75]=he,t[76]=ge):ge=t[76];let _e;return t[77]!==pe||t[78]!==ge?(_e=(0,$.jsxs)($.Fragment,{children:[pe,ge]}),t[77]=pe,t[78]=ge,t[79]=_e):_e=t[79],_e}function Ai(e,t){return{id:e.projectId||e.gitUrl||`project-${t}`,kind:`project`,project:e,children:e.threads.map((t,n)=>({id:t.threadId||`${e.projectId}-${t.title||n}`,kind:`thread`,thread:t,projectId:e.projectId}))}}function ji(e){let t=(0,X.c)(29),{project:n,isOpen:i,onToggle:a,isDeletingProject:o,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,p;t[0]===n?p=t[1]:(p=tt(n),t[0]=n,t[1]=p);let m=p,h=s||c,g=i&&`rotate-90`,_;t[2]===g?_=t[3]:(_=W(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,g),t[2]=g,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,$.jsx)(Ae,{className:_}),t[4]=_,t[5]=v);let y;t[6]===n.gitUrl?y=t[7]:(y=n.gitUrl?(0,$.jsx)(ye,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(f,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=n.gitUrl,t[7]=y);let b=(s||c)&&`font-bold text-foreground`,x;t[8]===b?x=t[9]:(x=W(`min-w-0 truncate transition-all block`,b),t[8]=b,t[9]=x);let S;t[10]!==m||t[11]!==x?(S=(0,$.jsx)(`span`,{className:x,children:m}),t[10]=m,t[11]=x,t[12]=S):S=t[12];let C;t[13]!==v||t[14]!==y||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[v,y,S]}),t[13]=v,t[14]=y,t[15]=S,t[16]=C):C=t[16];let w;t[17]!==o||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==n.projectId||t[22]!==n.threads?(w=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:o?(0,$.jsx)(wt,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(r,{children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(n.projectId)},children:[(0,$.jsx)(me,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(U,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(D,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(U,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(H,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(U,{side:`right`,children:`Delete project`})]})]})}),t[17]=o,t[18]=l,t[19]=u,t[20]=d,t[21]=n.projectId,t[22]=n.threads,t[23]=w):w=t[23];let T;return t[24]!==a||t[25]!==C||t[26]!==w||t[27]!==h?(T=(0,$.jsxs)(cr,{selected:h,noBackground:!0,className:`mb-1 h-9`,onClick:a,children:[C,w]}),t[24]=a,t[25]=C,t[26]=w,t[27]=h,t[28]=T):T=t[28],T}function Mi(e){let t=(0,X.c)(51),{thread:n,projectId:r,selectedThreadId:i,isProcessing:a,isDeleting:o,isCompleted:s,projectTitlePrefix:c,onSelectThread:l,onDeleteThread:u}=e,[d,f]=(0,Y.useState)(!1),p=(0,Y.useRef)(null),m=n.threadId===i,h,g;t[0]===a?(h=t[1],g=t[2]):(h=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},g=[a],t[0]=a,t[1]=h,t[2]=g),(0,Y.useEffect)(h,g);let _;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(_=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[3]=u,t[4]=r,t[5]=n.gitStatusDot,t[6]=n.threadId,t[7]=_):_=t[7];let v=_,y;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(y=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[8]=c,t[9]=n.threadId,t[10]=n.title,t[11]=y):y=t[11];let b=y,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ur,{children:`Delete Thread`}),t[12]=x):x=t[12];let S;t[13]===b?S=t[14]:(S=(0,$.jsxs)(dr,{children:[`Are you sure you want to delete "`,b,`" and all its files? This action cannot be undone.`]}),t[13]=b,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(lr,{children:`Cancel`}),t[15]=C):C=t[15];let w;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(w=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[C,(0,$.jsx)(_r,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[16]=u,t[17]=r,t[18]=n.threadId,t[19]=w):w=t[19];let T;t[20]!==S||t[21]!==w?(T=(0,$.jsxs)(gr,{children:[x,S,w]}),t[20]=S,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==d||t[24]!==T?(E=(0,$.jsx)(pr,{open:d,onOpenChange:f,children:T}),t[23]=d,t[24]=T,t[25]=E):E=t[25];let D,O;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(D=()=>l(r,n.threadId),O=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=D,t[30]=O):(D=t[29],O=t[30]);let k;t[31]===n.gitStatusDot?k=t[32]:(k=n.gitStatusDot?(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0`,viewBox:`0 0 12 12`,fill:`hsl(var(--brand))`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})}):(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-muted-foreground`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`})}),t[31]=n.gitStatusDot,t[32]=k);let A;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(A=W(J.body,`truncate block`),t[33]=A):A=t[33];let j;t[34]===b?j=t[35]:(j=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:A,children:b})}),t[34]=b,t[35]=j);let M;t[36]!==v||t[37]!==s||t[38]!==o||t[39]!==a?(M=a||o?(0,$.jsx)(wt,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(Vt,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):(0,$.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 group-hover:opacity-100 flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-opacity transition-colors`,onClick:v,children:[(0,$.jsx)(H,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(U,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[36]=v,t[37]=s,t[38]=o,t[39]=a,t[40]=M):M=t[40];let N;t[41]!==m||t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==j||t[46]!==M?(N=(0,$.jsxs)(cr,{ref:p,selected:m,onClick:D,onKeyDown:O,role:`button`,tabIndex:0,children:[k,j,M]}),t[41]=m,t[42]=D,t[43]=O,t[44]=k,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,$.jsxs)($.Fragment,{children:[E,N]}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}var Ni=e(Gt(),1),Pi=.1,Fi=10,Ii=1.25,Li=.001;function Ri(){let e=(0,X.c)(15),[t,n]=(0,Y.useState)(1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={x:0,y:0},e[0]=r):r=e[0];let[i,a]=(0,Y.useState)(r),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=zi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*Ii)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/Ii)),e[2]=f):f=e[2];let p=f,m;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{n(1),a({x:0,y:0})},e[3]=m):m=e[3];let h=m,g;e[4]===i?g=e[5]:(g=e=>{e.preventDefault(),s(!0),c.current={x:e.clientX,y:e.clientY,ox:i.x,oy:i.y}},e[4]=i,e[5]=g);let _=g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{c.current&&a({x:c.current.ox+(e.clientX-c.current.x),y:c.current.oy+(e.clientY-c.current.y)})},e[6]=v):v=e[6];let y=v,b;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{s(!1),c.current=null},e[7]=b):b=e[7];let x=b,S=(0,Y.useRef)(null),C,w;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=S.current;if(!e)return;let t=function(e){e.preventDefault();let t=-e.deltaY*Li;n(e=>l(e*(1+t)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},w=[],e[8]=C,e[9]=w):(C=e[8],w=e[9]),(0,Y.useEffect)(C,w);let T;return e[10]!==o||e[11]!==i||e[12]!==_||e[13]!==t?(T={scale:t,offset:i,isDragging:o,containerRef:S,zoomIn:d,zoomOut:p,reset:h,onMouseDown:_,onMouseMove:y,onMouseUp:x},e[10]=o,e[11]=i,e[12]=_,e[13]=t,e[14]=T):T=e[14],T}function zi(e){return Math.min(Math.max(e,Pi),Fi)}function Bi(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(!1),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){n(document.documentElement.classList.contains(`dark`))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Y.useEffect)(r,i),t}function Vi(e,t){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let n=!1;async function i(){try{let{renderMermaidSVG:i}=await ir(async()=>{let{renderMermaidSVG:e}=await import(`./dist-oojFghRi.js`);return{renderMermaidSVG:e}},__vite__mapDeps([0,1])),o=i(e,{bg:t?`#18181B`:`#FFFFFF`,fg:t?`#FAFAFA`:`#27272A`,transparent:!1,padding:32});n||(r(o),a(!1))}catch(e){console.error(`Mermaid render error:`,e),n||a(!0)}}return i(),()=>{n=!0}},[e,t]),{svgOutput:n,renderError:i}}function Hi(e){let t=(0,X.c)(70),{svgOutput:n,onClose:i}=e,{scale:a,offset:o,isDragging:s,containerRef:c,zoomIn:l,zoomOut:u,reset:d,onMouseDown:f,onMouseMove:p,onMouseUp:m}=Ri(),h,g;t[0]===i?(h=t[1],g=t[2]):(h=()=>{let e=function(e){e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[i],t[0]=i,t[1]=h,t[2]=g),(0,Y.useEffect)(h,g);let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],t[3]=_):_=t[3],(0,Y.useEffect)(Ui,_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:W(J.compact,`font-mono text-muted-foreground`),children:`mermaid diagram`}),t[4]=v):v=t[4];let y,b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(gt,{className:`h-3.5 w-3.5`}),b=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=y,t[6]=b):(y=t[5],b=t[6]);let x;t[7]===u?x=t[8]:(x=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[y,b]})}),t[7]=u,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(U,{children:`Zoom out`}),t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsxs)(K,{children:[x,S]}),t[10]=x,t[11]=C);let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=W(J.compact,`min-w-[3rem] px-2 py-1 font-mono text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`),t[12]=w):w=t[12];let T;t[13]===a?T=t[14]:(T=Math.round(a*100),t[13]=a,t[14]=T);let E;t[15]!==d||t[16]!==T?(E=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:w,children:[T,`%`]})}),t[15]=d,t[16]=T,t[17]=E):E=t[17];let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(U,{children:`Reset zoom`}),t[18]=O):O=t[18];let k;t[19]===E?k=t[20]:(k=(0,$.jsxs)(K,{children:[E,O]}),t[19]=E,t[20]=k);let A,j;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),j=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[21]=A,t[22]=j):(A=t[21],j=t[22]);let N;t[23]===l?N=t[24]:(N=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[A,j]})}),t[23]=l,t[24]=N);let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(U,{children:`Zoom in`}),t[25]=P):P=t[25];let F;t[26]===N?F=t[27]:(F=(0,$.jsxs)(K,{children:[N,P]}),t[26]=N,t[27]=F);let I,L;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),L=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[28]=I,t[29]=L):(I=t[28],L=t[29]);let R;t[30]===d?R=t[31]:(R=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:d,children:[I,L]})}),t[30]=d,t[31]=R);let ee;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(U,{children:`Reset view`}),t[32]=ee):ee=t[32];let z;t[33]===R?z=t[34]:(z=(0,$.jsxs)(K,{children:[R,ee]}),t[33]=R,t[34]=z);let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[35]=B):B=t[35];let V,te;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(un,{className:`h-3.5 w-3.5`}),te=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[36]=V,t[37]=te):(V=t[36],te=t[37]);let ne;t[38]===i?ne=t[39]:(ne=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:i,children:[V,te]})}),t[38]=i,t[39]=ne);let re;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(U,{children:`Close (Esc)`}),t[40]=re):re=t[40];let H;t[41]===ne?H=t[42]:(H=(0,$.jsxs)(K,{children:[ne,re]}),t[41]=ne,t[42]=H);let ie;t[43]!==k||t[44]!==F||t[45]!==z||t[46]!==H||t[47]!==C?(ie=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[v,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[C,k,F,z,B,H]})]}),t[43]=k,t[44]=F,t[45]=z,t[46]=H,t[47]=C,t[48]=ie):ie=t[48];let ae=s?`cursor-grabbing`:`cursor-grab`,oe;t[49]===ae?oe=t[50]:(oe=W(`flex-1 overflow-hidden select-none`,ae),t[49]=ae,t[50]=oe);let se=`translate(${o.x}px, ${o.y}px) scale(${a})`,ce=s?`none`:`transform 0.1s ease-out`,le;t[51]!==se||t[52]!==ce?(le={transform:se,transformOrigin:`center center`,transition:ce},t[51]=se,t[52]=ce,t[53]=le):le=t[53];let ue;t[54]===n?ue=t[55]:(ue={__html:n},t[54]=n,t[55]=ue);let de;t[56]!==le||t[57]!==ue?(de=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:le,dangerouslySetInnerHTML:ue}),t[56]=le,t[57]=ue,t[58]=de):de=t[58];let fe;t[59]!==c||t[60]!==f||t[61]!==p||t[62]!==m||t[63]!==oe||t[64]!==de?(fe=(0,$.jsx)(`div`,{ref:c,className:oe,onMouseDown:f,onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:de}),t[59]=c,t[60]=f,t[61]=p,t[62]=m,t[63]=oe,t[64]=de,t[65]=fe):fe=t[65];let pe;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(`div`,{className:W(J.compact,`shrink-0 px-4 py-2 text-center text-muted-foreground/60 bg-background/60 border-t border-border`),children:`Scroll to zoom · Drag to pan · Esc to close`}),t[66]=pe):pe=t[66];let me;return t[67]!==ie||t[68]!==fe?(me=(0,Ni.createPortal)((0,$.jsx)(r,{children:(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Diagram fullscreen view`,children:[ie,fe,pe]})}),document.body),t[67]=ie,t[68]=fe,t[69]=me):me=t[69],me}function Ui(){return document.body.style.overflow=`hidden`,Wi}function Wi(){document.body.style.overflow=``}function Gi(e){let t=(0,X.c)(53),{content:n,className:i}=e,[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),{svgOutput:l,renderError:u}=Vi(n,Bi()),d;t[0]===n?d=t[1]:(d=async function(){await navigator.clipboard.writeText(n),o(!0),setTimeout(()=>o(!1),2e3)},t[0]=n,t[1]=d);let f=d,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=W(J.compact,`font-mono text-muted-foreground`),t[2]=p):p=t[2];let m=u?`mermaid (render error)`:`mermaid diagram`,h;t[3]===m?h=t[4]:(h=(0,$.jsx)(`span`,{className:p,children:m}),t[3]=m,t[4]=h);let g;t[5]!==u||t[6]!==l?(g=l&&!u&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:()=>c(!0),children:[(0,$.jsx)(Ye,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(U,{children:`View fullscreen`})]}),t[5]=u,t[6]=l,t[7]=g):g=t[7];let _;t[8]===a?_=t[9]:(_=a?(0,$.jsx)(Vt,{}):(0,$.jsx)(F,{}),t[8]=a,t[9]=_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[10]=v):v=t[10];let y;t[11]!==f||t[12]!==_?(y=(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:f,children:[_,v]}),t[11]=f,t[12]=_,t[13]=y):y=t[13];let b;t[14]!==g||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==h||t[18]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[h,b]}),t[17]=h,t[18]=b,t[19]=x):x=t[19];let S=x;if(u){let e;t[20]===i?e=t[21]:(e=W(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),t[20]=i,t[21]=e);let r;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(r=W(J.compact,`font-mono text-foreground leading-relaxed`),t[22]=r):r=t[22];let a;t[23]===n?a=t[24]:(a=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:r,children:n})}),t[23]=n,t[24]=a);let o;return t[25]!==S||t[26]!==e||t[27]!==a?(o=(0,$.jsxs)(`div`,{className:e,children:[S,a]}),t[25]=S,t[26]=e,t[27]=a,t[28]=o):o=t[28],o}if(!l){let e;t[29]===i?e=t[30]:(e=W(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),t[29]=i,t[30]=e);let n;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:W(J.compact,`p-4 text-muted-foreground`),children:`Rendering diagram…`}),t[31]=n):n=t[31];let r;return t[32]!==S||t[33]!==e?(r=(0,$.jsxs)(`div`,{className:e,children:[S,n]}),t[32]=S,t[33]=e,t[34]=r):r=t[34],r}let C;t[35]===i?C=t[36]:(C=W(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),t[35]=i,t[36]=C);let w;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>c(!0),t[37]=w):w=t[37];let T;t[38]===l?T=t[39]:(T=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`block w-full text-left cursor-zoom-in p-4 max-w-full overflow-hidden [&_svg]:max-w-full [&_svg]:h-auto hover:bg-muted/70 transition-colors`,onClick:w,dangerouslySetInnerHTML:{__html:l}})}),t[38]=l,t[39]=T);let E;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(U,{children:`Click to view fullscreen`}),t[40]=E):E=t[40];let D;t[41]===T?D=t[42]:(D=(0,$.jsxs)(K,{children:[T,E]}),t[41]=T,t[42]=D);let O;t[43]!==S||t[44]!==C||t[45]!==D?(O=(0,$.jsxs)(`div`,{className:C,children:[S,D]}),t[43]=S,t[44]=C,t[45]=D,t[46]=O):O=t[46];let k;t[47]!==s||t[48]!==l?(k=s&&(0,$.jsx)(Hi,{svgOutput:l,onClose:()=>c(!1)}),t[47]=s,t[48]=l,t[49]=k):k=t[49];let A;return t[50]!==O||t[51]!==k?(A=(0,$.jsxs)(r,{children:[O,k]}),t[50]=O,t[51]=k,t[52]=A):A=t[52],A}var Ki=`graph.flowchart.sequenceDiagram.classDiagram.stateDiagram.erDiagram.journey.gantt.pie.quadrantChart.requirementDiagram.gitgraph.mindmap.timeline.zenuml.sankey.block.architecture.c4.packet.circuit.flowchart LR.flowchart TD.flowchart BT.flowchart RL.graph LR.graph TD.graph BT.graph RL`.split(`.`),qi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\w+\[\w+\]/,/\w+\(\w+\)/,/\w+\{\w+\}/,/\w+>\w+\]/,/\w+\(\w+\)/,/\w+\[\(\w+\)\]/,/participant\s+\w+/,/actor\s+\w+/,/Note over \w+/,/loop\s+/,/alt\s+/,/opt\s+/,/class\s+\w+/,/interface\s+\w+/,/enum\s+\w+/,/\[\*\]/,/\[\*\]/,/title\s+/,/direction\s+/,/subgraph\s+/];function Ji(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);if(t.length===0)return!1;if(/```mermaid\s*\n([\s\S]*?)\n```/.test(e))return!0;let n=t[0].toLowerCase();if(Ki.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of qi)t.test(e)&&r++;return r>=2}function Yi(e){if(!Ji(e))return null;let t=/```mermaid\s*\n([\s\S]*?)\n```/.exec(e);if(t)return t[1].trim();let n=e.split(`
|
|
7
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)[0].toLowerCase();return Ki.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var Xi=(0,Y.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Y.useMemo)(()=>!e||typeof e!=`string`?[]:Zi(e,n),[e,n]),i=(0,Y.useMemo)(()=>{let e=0;return r.map(t=>{if(t.type===`list`&&t.ordered){let n=e+1;return e+=t.items.length,n}else if(t.type===`list`&&!t.ordered)return 1;else return e=0,1})},[r]);return r.length===0?null:(0,$.jsx)(`div`,{className:W(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(Qi,{block:e,start:i[t]},t))})});function Zi(e,t=!1){let n=e.split(`
|
|
8
|
+
`),r=[],i=0;for(;i<n.length;){let e=n[i];if(e.trimStart().startsWith("```")){let a=e.trimStart().slice(3).trim(),o=[];for(i++;i<n.length&&!n[i].trimStart().startsWith("```");)o.push(n[i]),i++;t&&(a===`mermaid`||Ji(o.join(`
|
|
9
|
+
`)))?r.push({type:`mermaid`,code:o.join(`
|
|
10
|
+
`)}):r.push({type:`code`,language:a,code:o.join(`
|
|
11
|
+
`)}),i++;continue}let a=e.match(/^(#{1,6})(\s.*)?$/);if(a){r.push({type:`heading`,level:a[1].length,text:a[2]?a[2].trim():``}),i++;continue}if(/^(---|\*\*\*|___)/.test(e.trim())){r.push({type:`hr`}),i++;continue}if(e.includes(`|`)&&i+1<n.length&&n[i+1].match(/^\|?\s*[-:]+/)){let t=e.split(`|`).map(e=>e.trim()).filter(Boolean);i+=2;let a=[];for(;i<n.length&&n[i].includes(`|`);)a.push(n[i].split(`|`).map(e=>e.trim()).filter(Boolean)),i++;r.push({type:`table`,headers:t,rows:a});continue}if(e.startsWith(`> `)){let e=[];for(;i<n.length&&n[i].startsWith(`> `);)e.push(n[i].slice(2)),i++;r.push({type:`blockquote`,text:e.join(`
|
|
12
|
+
`)});continue}if(/^\s*[-*+]\s/.test(e)){let e=[];for(;i<n.length&&/^\s*[-*+]\s/.test(n[i]);)e.push(n[i].replace(/^\s*[-*+]\s/,``)),i++;r.push({type:`list`,ordered:!1,items:e});continue}if(/^\s*\d+\.\s/.test(e)){let e=[];for(;i<n.length&&/^\s*\d+\.\s/.test(n[i]);)e.push(n[i].replace(/^\s*\d+\.\s/,``)),i++;r.push({type:`list`,ordered:!0,items:e});continue}if(e.trim()===``){i++;continue}let o=[];for(;i<n.length&&n[i].trim()!==``&&!n[i].startsWith(`#`)&&!n[i].startsWith("```")&&!n[i].startsWith(`> `)&&!/^\s*[-*+]\s/.test(n[i])&&!/^\s*\d+\.\s/.test(n[i]);)o.push(n[i]),i++;if(o.length>0){let e=o.join(`
|
|
13
|
+
`);if(t&&Ji(e)){let t=Yi(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var Qi=(0,Y.memo)(function(e){let t=(0,X.c)(46),{block:n,start:r}=e,i=r===void 0?1:r;switch(n.type){case`heading`:{let e=`h${n.level}`,r,i;if(t[0]!==e||t[1]!==n.level){let a={1:J.sectionTitle,2:W(J.body,`font-semibold`),3:W(J.body,`font-semibold`),4:J.sectionSubtitle,5:J.sectionSubtitle,6:J.sectionSubtitle};r=e,i=W(a[n.level]),t[0]=e,t[1]=n.level,t[2]=r,t[3]=i}else r=t[2],i=t[3];let a;t[4]===n.text?a=t[5]:(a=(0,$.jsx)($i,{text:n.text}),t[4]=n.text,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(r,{className:i,children:a}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}case`code`:{let e;return t[10]!==n.code||t[11]!==n.language?(e=(0,$.jsx)(ta,{language:n.language,code:n.code}),t[10]=n.code,t[11]=n.language,t[12]=e):e=t[12],e}case`blockquote`:{let e;return t[13]===n.text?e=t[14]:(e=(0,$.jsx)(`blockquote`,{className:`border-l-2 border-border pl-4 text-muted-foreground italic`,children:(0,$.jsx)($i,{text:n.text})}),t[13]=n.text,t[14]=e),e}case`list`:{if(n.ordered){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.body,`space-y-1`),t[15]=e):e=t[15];let r;if(t[16]!==n.items||t[17]!==i){let e;t[19]===i?e=t[20]:(e=(e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 select-none tabular-nums`,children:[i+t,`.`]}),(0,$.jsx)(`span`,{children:(0,$.jsx)($i,{text:e})})]},t),t[19]=i,t[20]=e),r=n.items.map(e),t[16]=n.items,t[17]=i,t[18]=r}else r=t[18];let a;return t[21]===r?a=t[22]:(a=(0,$.jsx)(`ol`,{className:e,children:r}),t[21]=r,t[22]=a),a}let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.body,`space-y-1 pl-5 list-outside overflow-visible list-disc`),t[23]=e):e=t[23];let r;t[24]===n.items?r=t[25]:(r=n.items.map(na),t[24]=n.items,t[25]=r);let a;return t[26]===r?a=t[27]:(a=(0,$.jsx)(`ul`,{className:e,children:r}),t[26]=r,t[27]=a),a}case`paragraph`:{let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.body,`leading-relaxed whitespace-pre-wrap break-words`),t[28]=e):e=t[28];let r;return t[29]===n.text?r=t[30]:(r=(0,$.jsx)(`p`,{className:e,children:(0,$.jsx)($i,{text:n.text})}),t[29]=n.text,t[30]=r),r}case`hr`:{let e;return t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`hr`,{className:`border-border`}),t[31]=e):e=t[31],e}case`table`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.body,`w-full`),t[32]=e):e=t[32];let r;t[33]===n.headers?r=t[34]:(r=n.headers.map(ra),t[33]=n.headers,t[34]=r);let i;t[35]===r?i=t[36]:(i=(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-b border-border bg-muted/50`,children:r})}),t[35]=r,t[36]=i);let a;t[37]===n.rows?a=t[38]:(a=n.rows.map(aa),t[37]=n.rows,t[38]=a);let o;t[39]===a?o=t[40]:(o=(0,$.jsx)(`tbody`,{children:a}),t[39]=a,t[40]=o);let s;return t[41]!==i||t[42]!==o?(s=(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border max-w-full`,children:(0,$.jsxs)(`table`,{className:e,children:[i,o]})}),t[41]=i,t[42]=o,t[43]=s):s=t[43],s}case`mermaid`:{let e;return t[44]===n.code?e=t[45]:(e=(0,$.jsx)(Gi,{content:n.code}),t[44]=n.code,t[45]=e),e}default:return null}}),$i=(0,Y.memo)(function(e){let t=(0,X.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=ea(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(oa),t[2]=i,t[3]=a);let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)($.Fragment,{children:a}),t[4]=a,t[5]=o),o});function ea(e){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(__[^_]+__)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)]+\))/g,r=0,i;for(;(i=n.exec(e))!==null;){i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)});let n=i[0];if(n.startsWith("`"))t.push({type:`code`,text:n.slice(1,-1)});else if(n.startsWith(`**`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`__`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`~~`))t.push({type:`strikethrough`,text:n.slice(2,-2)});else if(n.startsWith(`*`)||n.startsWith(`_`))t.push({type:`italic`,text:n.slice(1,-1)});else if(n.startsWith(`[`)){let e=n.match(/\[([^\]]+)\]\(([^)]+)\)/);e&&t.push({type:`link`,text:e[1],href:e[2]})}r=i.index+n.length}return r<e.length&&t.push({type:`text`,text:e.slice(r)}),t.length>0?t:[{type:`text`,text:e}]}function ta(e){let t=(0,X.c)(20),{language:n,code:r}=e,[i,a]=(0,Y.useState)(!1),o;t[0]===r?o=t[1]:(o=async()=>{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=r,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=W(J.compact,`text-muted-foreground font-mono`),t[2]=c):c=t[2];let l=n||`text`,u;t[3]===l?u=t[4]:(u=(0,$.jsx)(`span`,{className:c,children:l}),t[3]=l,t[4]=u);let d;t[5]===i?d=t[6]:(d=i?(0,$.jsx)(Vt,{}):(0,$.jsx)(F,{}),t[5]=i,t[6]=d);let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[7]=f):f=t[7];let p;t[8]!==s||t[9]!==d?(p=(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:s,children:[d,f]}),t[8]=s,t[9]=d,t[10]=p):p=t[10];let m;t[11]!==u||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[u,p]}),t[11]=u,t[12]=p,t[13]=m):m=t[13];let h;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=W(J.mono,`text-foreground leading-relaxed`),t[14]=h):h=t[14];let g;t[15]===r?g=t[16]:(g=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:h,children:r})}),t[15]=r,t[16]=g);let _;return t[17]!==g||t[18]!==m?(_=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[m,g]}),t[17]=g,t[18]=m,t[19]=_):_=t[19],_}function na(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)($i,{text:e})},t)}function ra(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)($i,{text:e})},t)}function ia(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)($i,{text:e})},t)}function aa(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ia)},t)}function oa(e,t){switch(e.type){case`bold`:return(0,$.jsx)(`strong`,{className:`font-semibold`,children:e.text},t);case`italic`:return(0,$.jsx)(`em`,{children:e.text},t);case`strikethrough`:return(0,$.jsx)(`del`,{className:`text-muted-foreground`,children:e.text},t);case`code`:return(0,$.jsx)(`code`,{className:W(J.mono,`rounded bg-muted/20 px-1.5 py-0.5`),children:e.text},t);case`link`:return(0,$.jsx)(`a`,{href:e.href,className:`text-primary underline underline-offset-2 hover:text-primary/80`,target:`_blank`,rel:`noopener noreferrer`,children:e.text},t);default:return(0,$.jsx)(`span`,{children:e.text},t)}}var sa=(0,Y.createContext)({activeMainTab:`chat`,setActiveMainTab:()=>{},devServerUrl:null,setDevServerUrl:()=>{},devServerRunning:!1,setDevServerRunning:()=>{},devServerLoading:!1,setDevServerLoading:()=>{},terminalNotification:!1,setTerminalNotification:()=>{},pendingExplorerPath:null,setPendingExplorerPath:()=>{},explorerRefreshTick:0,triggerExplorerRefresh:()=>{},explorerClearPath:null,setExplorerClearPath:()=>{},browserResetTrigger:0,triggerBrowserReset:()=>{}});function ca(){return(0,Y.useContext)(sa)}var la=new RegExp(String.raw`\x1B\[[0-?]*[ -/]*[@-~]`,`g`),ua=new RegExp(String.raw`\x1B\].*?(?:\x07|\x1B\\)`,`g`),da=new RegExp(String.raw`\x1B[@-_]`,`g`),fa=/\r(?!\n)/g,pa=/\\n/g;function ma(e){return e.replace(ua,``).replace(la,``).replace(da,``)}function ha(e){return ma(e).replace(pa,`
|
|
14
|
+
`).replace(fa,`
|
|
15
|
+
`)}function ga(e){return qt(e)}function _a(e,t){if(!t||!e||typeof e!=`string`)return e;try{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(new RegExp(n,`g`),`.`)}catch{return e}}function va(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function ya(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t)}catch{return e}return e}function ba(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(ba);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=ya(r);t[n]=typeof e==`object`?ba(e):r}else t[n]=ba(r);return t}function xa(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
|
|
16
|
+
`),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
|
|
17
|
+
`),t=t.replace(/\\"/g,`"`),t}function Sa(e){if(e==null)return``;let t=typeof e==`object`&&e?ba(e):e;return ha(xa(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2)))}function Ca(e,t){let n=e.name??`Unknown Tool`,r=e.id??`unknown`,i=e.input,a=i&&typeof i==`object`?i:null,o=i&&typeof i==`object`&&`description`in i,s=o?i.subagent_type:void 0,c=s==null?null:JSON.stringify(s),l=n===`agent`&&a&&typeof a.agentName==`string`?a.agentName:null,u=o?null:_a(va(i),t),d=_a(o?String(i.prompt):null,t),f=_a(a&&typeof a.command==`string`?a.command:null,t),p=n===`fetch`&&a&&typeof a.url==`string`?a.url:null,m=a&&typeof a.pattern==`string`?a.pattern:null,h=a&&typeof a.lang==`string`?a.lang:null,g=n===`code_search`,_=g&&a&&typeof a.query==`string`?a.query:null,v=g&&a&&typeof a.filePath==`string`?a.filePath:null,y=g&&a&&typeof a.fileGlob==`string`?a.fileGlob:null,b=_a(a&&typeof a.path==`string`?a.path:null,t),x=a&&typeof a.offset==`number`?a.offset:null,S=a&&typeof a.limit==`number`?a.limit:null,C=n.toLowerCase(),w=C.includes(`read`)||C.includes(`write`)||C.includes(`edit`),T=C.includes(`edit`),E=w&&a&&typeof a.path==`string`?a.path:null,D=E?E.split(`/`).pop()??E:null,O=T&&a&&typeof a.oldText==`string`?a.oldText:null,k=T&&a&&typeof a.newText==`string`?a.newText:null,A=O===null?null:O.split(`
|
|
18
|
+
`).length,j=k===null?null:k.split(`
|
|
19
|
+
`).length,M=O!==null&&k!==null,N=n===`generate_image`&&a&&typeof a.prompt==`string`?a.prompt:null,P=n===`todo`&&a?a.status:void 0,F=e.displayName??qt(n),I=e.activeDisplayName??Pt(n),L=`default`;return C===`bash`||C.includes(`terminal`)||C.includes(`shell`)?L=`bash`:C===`fetch`?L=`fetch`:w?L=`file`:g||C===`find`||C.includes(`search`)||C.includes(`grep`)?L=`search`:C===`agent`||C.includes(`subagent`)||o?L=`agent`:C===`todo`?L=`todo`:C===`generate_image`&&(L=`imageGen`),{toolType:L,toolName:n,toolId:r,displayName:F,activeDisplayName:I,inputObj:a,toolInput:u,command:f,fetchUrl:p,pattern:m,codeSearchQuery:_,codeSearchFilePath:v,codeSearchFileGlob:y,isFileTool:w,isEditTool:T,filePath:E,fileDisplayName:D,editOldText:O,editNewText:k,editDeletedLineCount:A,editAddedLineCount:j,hasEditDiff:M,path:b,offset:x,limit:S,prompt:d,agentName:l,subagentType:c,lang:h,imageGenPrompt:N,todoStatus:P}}var wa=new Map;function Ta(e){return e.trim()}function Ea(){let e=Be(Je.BASH_COMMAND_DURATIONS);if(!e)return{};try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`number`&&Number.isFinite(r)&&r>0&&(n[Ta(e)]=r);return n}catch{return{}}}function Da(e){ve(Je.BASH_COMMAND_DURATIONS,JSON.stringify(e))}function Oa(e){return Ea()[Ta(e)]??null}function ka(e,t){let n=Ta(e);if(!n||!Number.isFinite(t)||t<=0)return;let r=Ea();r[n]=Math.round(t),Da(r)}function Aa(e,t){!t?.trim()||wa.has(e)||wa.set(e,{command:Ta(t),startedAt:Date.now()})}function ja(e){let t=wa.get(e);if(!t)return;let n=Date.now()-t.startedAt;ka(t.command,n),wa.delete(e)}function Ma(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function Na(e,t){return t!==null&&t>0?`${Math.min(99,Math.round(e/t*100))}% complete`:Ma(e)}var Pa=1e3;function Fa(e,t,n){let[r,i]=(0,Y.useState)(0),[a,o]=(0,Y.useState)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(!1),l=(0,Y.useRef)(n);return l.current=n,(0,Y.useEffect)(()=>{if(n&&!c.current){let n=e?.trim()??``;o(n?Oa(n):null),Aa(t,e),s.current=Date.now(),i(0)}else !n&&c.current&&(ja(t),s.current=null,i(0),o(null));c.current=n},[n,e,t]),(0,Y.useEffect)(()=>()=>{l.current&&ja(t)},[t]),(0,Y.useEffect)(()=>{if(!n)return;let e=()=>{s.current===null&&(s.current=Date.now()),i(Date.now()-s.current)};e();let t=setInterval(e,Pa);return()=>clearInterval(t)},[n]),n?Na(r,a):null}function Ia(e){let{maxHeight:t=`48`,padding:n=`2`,leading:r=!1,className:i}=e??{};return W(J.mono,n===`3`?`p-3`:`p-2`,`bg-muted rounded whitespace-pre-wrap overflow-auto text-foreground`,t===`64`?`max-h-64`:`max-h-48`,r&&`leading-relaxed`,i)}function La(e){let t=(0,X.c)(12),{open:n,onOpenChange:r,title:i,content:a}=e,o;t[0]===i?o=t[1]:(o=(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:(0,$.jsx)(`code`,{className:J.mono,children:i})})}),t[0]=i,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Ia({padding:`3`,className:`flex-1 max-h-none`}),t[2]=s):s=t[2];let c;t[3]===a?c=t[4]:(c=(0,$.jsx)(`pre`,{className:s,children:a}),t[3]=a,t[4]=c);let l;t[5]!==o||t[6]!==c?(l=(0,$.jsxs)(ut,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[o,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,$.jsx)(mt,{open:n,onOpenChange:r,children:l}),t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function Ra(e){let t=(0,X.c)(10),{oldText:n,newText:r}=e,i,a,o;if(t[0]!==r||t[1]!==n){let e=n.split(`
|
|
20
|
+
`),s=r.split(`
|
|
21
|
+
`);t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=W(J.caption,`font-mono whitespace-pre-wrap overflow-auto`),t[5]=i):i=t[5],a=e.map(Ba),o=s.map(za),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o}else i=t[2],a=t[3],o=t[4];let s;return t[6]!==i||t[7]!==a||t[8]!==o?(s=(0,$.jsxs)(`pre`,{className:i,children:[a,o]}),t[6]=i,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function za(e,t){return(0,$.jsxs)(`div`,{className:`bg-green-500/10 text-green-600 dark:text-green-400`,children:[(0,$.jsx)(`span`,{className:`select-none opacity-50 mr-2`,children:`+`}),e]},`new-${t}`)}function Ba(e,t){return(0,$.jsxs)(`div`,{className:`bg-red-500/10 text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{className:`select-none opacity-50 mr-2`,children:`-`}),e]},`old-${t}`)}function Va(e){let t=(0,X.c)(3),{name:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=W(J.caption,`px-1.5 py-0.5 rounded bg-muted font-mono`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:r,children:n}),t[1]=n,t[2]=i),i}function Ha(e){let t=(0,X.c)(3),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=W(J.caption,`px-2 py-0.5 rounded bg-muted`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:r,children:n}),t[1]=n,t[2]=i),i}function Ua(e){let t=(0,X.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=W(J.caption,`font-mono break-all rounded bg-muted/60 px-1 py-0.5`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`code`,{className:r,children:n}),t[1]=n,t[2]=i),i}function Wa(e){let t=(0,X.c)(5),{className:n,size:r}=e,i=(r===void 0?`sm`:r)===`sm`?`h-7 w-7`:`h-8 w-8`,a;t[0]!==n||t[1]!==i?(a=W(`shrink-0`,i,n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(`img`,{src:`/busy.svg`,alt:``,className:a,"aria-hidden":!0}),t[3]=a,t[4]=o),o}function Ga(e){let t=(0,X.c)(15),{toolName:n,displayName:r,muted:i,size:a,className:o}=e,s=i===void 0?!0:i,c;t[0]===o?c=t[1]:(c=W(`inline-flex items-center gap-1`,o),t[0]=o,t[1]=c);let l=!s&&`text-foreground`,u;t[2]===l?u=t[3]:(u=W(J.caption,l),t[2]=l,t[3]=u);let d;t[4]!==r||t[5]!==u?(d=(0,$.jsx)(`span`,{className:u,children:r}),t[4]=r,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==d?(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:c,children:d})}),t[7]=c,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,$.jsx)(U,{children:n}),t[10]=n,t[11]=p);let m;return t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(K,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m}function Ka(e){let t=(0,X.c)(102),{data:n,inline:r,resultContent:i,isActive:a}=e,o=(0,Y.useRef)(null),[s,c]=(0,Y.useState)(!!a),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(!!a),f;t[0]===n.toolId?f=t[1]:(f=e=>e.toolCallProgress[n.toolId]?.executionOutput,t[0]=n.toolId,t[1]=f);let p=Q(f),m=a?p??i??``:i??``,h;t[2]===m?h=t[3]:(h=m?ha(m):``,t[2]=m,t[3]=h);let g=h,_=a?g:``,v=Fa(n.command,n.toolId,!!a),y,b;t[4]===a?(y=t[5],b=t[6]):(y=()=>{a&&!d.current?c(!0):!a&&d.current&&c(!1),d.current=!!a},b=[a],t[4]=a,t[5]=y,t[6]=b),(0,Y.useEffect)(y,b);let x;t[7]!==a||t[8]!==s?(x=()=>{s&&a&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},t[7]=a,t[8]=s,t[9]=x):x=t[9];let S;if(t[10]!==a||t[11]!==s||t[12]!==_?(S=[s,a,_],t[10]=a,t[11]=s,t[12]=_,t[13]=S):S=t[13],(0,Y.useEffect)(x,S),r){if(a){let e;t[14]===s?e=t[15]:(e=()=>c(!s),t[14]=s,t[15]=e);let r;t[16]!==n.activeDisplayName||t[17]!==n.toolName?(r=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.activeDisplayName,isActive:!1}),t[16]=n.activeDisplayName,t[17]=n.toolName,t[18]=r):r=t[18];let i;t[19]===n.command?i=t[20]:(i=n.command!==null&&(0,$.jsx)(`span`,{className:W(J.caption,`break-all`),children:n.command}),t[19]=n.command,t[20]=i);let a;t[21]===v?a=t[22]:(a=v&&(0,$.jsx)(`span`,{className:W(J.caption,`tabular-nums shrink-0`),children:v}),t[21]=v,t[22]=a);let l;t[23]===s?l=t[24]:(l=s?(0,$.jsx)(j,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(Ae,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[23]=s,t[24]=l);let u;t[25]!==s||t[26]!==a||t[27]!==l||t[28]!==e||t[29]!==r||t[30]!==i?(u=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:e,"aria-expanded":s,children:[r,i,a,l]}),t[25]=s,t[26]=a,t[27]=l,t[28]=e,t[29]=r,t[30]=i,t[31]=u):u=t[31];let d=s?`grid-rows-[1fr]`:`grid-rows-[0fr]`,f;t[32]===d?f=t[33]:(f=W(`grid transition-[grid-template-rows] duration-200 ease-in-out`,d),t[32]=d,t[33]=f);let p,m;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(p=W(J.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),m={maxHeight:`7.5em`},t[34]=p,t[35]=m):(p=t[34],m=t[35]);let h;t[36]===_?h=t[37]:(h=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:o,className:p,style:m,children:_})}),t[36]=_,t[37]=h);let g;t[38]!==f||t[39]!==h?(g=(0,$.jsx)(`div`,{className:f,children:h}),t[38]=f,t[39]=h,t[40]=g):g=t[40];let y;return t[41]!==u||t[42]!==g?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[u,g]}),t[41]=u,t[42]=g,t[43]=y):y=t[43],y}if(n.command!==null&&g){let e;t[44]!==n.displayName||t[45]!==n.toolName?(e=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[44]=n.displayName,t[45]=n.toolName,t[46]=e):e=t[46];let r,i;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>u(!0),i=W(J.caption,`font-mono hover:underline break-all cursor-pointer`),t[47]=r,t[48]=i):(r=t[47],i=t[48]);let a;t[49]===n.command?a=t[50]:(a=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:i,children:n.command})}),t[49]=n.command,t[50]=a);let o;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(U,{children:`View output`}),t[51]=o):o=t[51];let s;t[52]===a?s=t[53]:(s=(0,$.jsxs)(K,{children:[a,o]}),t[52]=a,t[53]=s);let c;t[54]!==s||t[55]!==e?(c=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,s]}),t[54]=s,t[55]=e,t[56]=c):c=t[56];let d;t[57]!==n.command||t[58]!==l||t[59]!==g?(d=(0,$.jsx)(La,{open:l,onOpenChange:u,title:n.command,content:g}),t[57]=n.command,t[58]=l,t[59]=g,t[60]=d):d=t[60];let f;return t[61]!==c||t[62]!==d?(f=(0,$.jsxs)($.Fragment,{children:[c,d]}),t[61]=c,t[62]=d,t[63]=f):f=t[63],f}let e;t[64]!==n.displayName||t[65]!==n.toolName?(e=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[64]=n.displayName,t[65]=n.toolName,t[66]=e):e=t[66];let r;t[67]===n.command?r=t[68]:(r=n.command!==null&&(0,$.jsx)(`code`,{className:W(J.caption,`font-mono break-all rounded bg-muted/60 px-1 py-0.5`),children:n.command}),t[67]=n.command,t[68]=r);let i;return t[69]!==e||t[70]!==r?(i=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[69]=e,t[70]=r,t[71]=i):i=t[71],i}let C;t[72]===s?C=t[73]:(C=()=>c(!s),t[72]=s,t[73]=C);let w;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(w=W(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[74]=w):w=t[74];let T;t[75]!==n.activeDisplayName||t[76]!==n.displayName||t[77]!==a||t[78]!==v?(T=a?(0,$.jsxs)($.Fragment,{children:[n.activeDisplayName,v&&(0,$.jsx)(`span`,{className:`ml-2 text-muted-foreground tabular-nums`,children:v})]}):n.displayName,t[75]=n.activeDisplayName,t[76]=n.displayName,t[77]=a,t[78]=v,t[79]=T):T=t[79];let E;t[80]===T?E=t[81]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:T}),t[80]=T,t[81]=E);let D;t[82]===s?D=t[83]:(D=s?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[82]=s,t[83]=D);let O;t[84]!==E||t[85]!==D||t[86]!==C?(O=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:C,className:w,children:[E,D]})}),t[84]=E,t[85]=D,t[86]=C,t[87]=O):O=t[87];let k;t[88]===n.toolName?k=t[89]:(k=(0,$.jsx)(U,{children:n.toolName}),t[88]=n.toolName,t[89]=k);let A;t[90]!==O||t[91]!==k?(A=(0,$.jsxs)(K,{children:[O,k]}),t[90]=O,t[91]=k,t[92]=A):A=t[92];let M;t[93]!==n.toolId||t[94]!==n.toolInput||t[95]!==a||t[96]!==s||t[97]!==_?(M=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),a?(0,$.jsx)(`div`,{ref:o,className:W(J.caption,`text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),style:{maxHeight:`7.5em`},children:_}):n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[93]=n.toolId,t[94]=n.toolInput,t[95]=a,t[96]=s,t[97]=_,t[98]=M):M=t[98];let N;return t[99]!==A||t[100]!==M?(N=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[A,M]}),t[99]=A,t[100]=M,t[101]=N):N=t[101],N}function qa(e){let t=(0,X.c)(50),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Y.useState)(!!a),[c,l]=(0,Y.useState)(!1),u=n.fetchUrl,d;t[0]===i?d=t[1]:(d=i?Ja(i):null,t[0]=i,t[1]=d);let f=d;if(r){let e;t[2]===o?e=t[3]:(e=()=>s(!o),t[2]=o,t[3]=e);let r=n.toolName,c=n.activeDisplayName,l=!!a,d;t[4]!==n.activeDisplayName||t[5]!==n.toolName||t[6]!==l?(d=(0,$.jsx)(Ga,{toolName:r,displayName:c,isActive:l}),t[4]=n.activeDisplayName,t[5]=n.toolName,t[6]=l,t[7]=d):d=t[7];let p;t[8]===u?p=t[9]:(p=u!==null&&(0,$.jsx)(`span`,{className:W(J.caption,`break-all`),children:u}),t[8]=u,t[9]=p);let m;t[10]===f?m=t[11]:(m=f&&(0,$.jsxs)(`span`,{className:W(J.caption,`text-muted-foreground shrink-0`),children:[f.bytes,` bytes · HTTP `,f.code]}),t[10]=f,t[11]=m);let h;t[12]===o?h=t[13]:(h=o?(0,$.jsx)(j,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(Ae,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[12]=o,t[13]=h);let g;t[14]!==o||t[15]!==e||t[16]!==d||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:e,"aria-expanded":o,children:[d,p,m,h]}),t[14]=o,t[15]=e,t[16]=d,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]!==o||t[22]!==i?(_=o&&i&&(0,$.jsx)(`pre`,{className:W(J.mono,J.caption,`whitespace-pre-wrap break-all rounded bg-muted/40 p-2 max-h-48 overflow-auto`),children:Ya(i)}),t[21]=o,t[22]=i,t[23]=_):_=t[23];let v;return t[24]!==g||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[24]=g,t[25]=_,t[26]=v):v=t[26],v}let p=n.toolName,m=n.displayName,h=!!a,g;t[27]!==n.displayName||t[28]!==n.toolName||t[29]!==h?(g=(0,$.jsx)(Ga,{toolName:p,displayName:m,isActive:h}),t[27]=n.displayName,t[28]=n.toolName,t[29]=h,t[30]=g):g=t[30];let _;t[31]===u?_=t[32]:(_=u!==null&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`code`,{className:W(J.mono,J.caption,`break-all`),children:u})}),(0,$.jsx)(U,{children:u})]}),t[31]=u,t[32]=_);let v;t[33]===f?v=t[34]:(v=f&&(0,$.jsxs)(`span`,{className:W(J.caption,`text-muted-foreground`),children:[f.bytes,` bytes · HTTP `,f.code,` · `,f.durationMs,`ms`]}),t[33]=f,t[34]=v);let y;t[35]===i?y=t[36]:(y=i&&(0,$.jsx)(`button`,{type:`button`,className:W(J.caption,`text-brand hover:underline ml-auto`),onClick:()=>l(!0),children:`View result`}),t[35]=i,t[36]=y);let b;t[37]!==g||t[38]!==_||t[39]!==v||t[40]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[g,_,v,y]}),t[37]=g,t[38]=_,t[39]=v,t[40]=y,t[41]=b):b=t[41];let x;t[42]===i?x=t[43]:(x=i?Ya(i):``,t[42]=i,t[43]=x);let S;t[44]!==c||t[45]!==x?(S=(0,$.jsx)(La,{open:c,onOpenChange:l,title:`Fetch result`,content:x}),t[44]=c,t[45]=x,t[46]=S):S=t[46];let C;return t[47]!==S||t[48]!==b?(C=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 my-1`,children:[b,S]}),t[47]=S,t[48]=b,t[49]=C):C=t[49],C}function Ja(e){try{let t=JSON.parse(e);if(typeof t.bytes==`number`&&typeof t.code==`number`)return{bytes:t.bytes,code:t.code,durationMs:typeof t.durationMs==`number`?t.durationMs:0}}catch{}return null}function Ya(e){try{let t=JSON.parse(e);if(typeof t.result==`string`)return t.result}catch{}return e}var Xa=er,Za=Yn,Qa=Y.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,align:a,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a===void 0?`center`:a,c=o===void 0?4:o,l;n[5]===r?l=n[6]:(l=W(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=l);let u;return n[7]!==s||n[8]!==i||n[9]!==t||n[10]!==c||n[11]!==l?(u=(0,$.jsx)(Gn,{children:(0,$.jsx)(vn,{ref:t,align:s,sideOffset:c,className:l,...i})}),n[7]=s,n[8]=i,n[9]=t,n[10]=c,n[11]=l,n[12]=u):u=n[12],u});Qa.displayName=vn.displayName;function $a(e){let t=(0,X.c)(6),{type:n,count:r}=e,i=n===`added`?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,a;t[0]===i?a=t[1]:(a=W(J.compact,`font-mono tabular-nums`,i),t[0]=i,t[1]=a);let o=n===`added`?`+`:`-`,s;return t[2]!==r||t[3]!==a||t[4]!==o?(s=(0,$.jsxs)(`span`,{className:a,children:[o,r]}),t[2]=r,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}function eo(e){let t=(0,X.c)(3),{offset:n,limit:r}=e;if(n===null&&r===null)return null;let i;i=n!==null&&r!==null?`${n}-${n+r}`:n===null?`${r}`:`${n}-`;let a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=W(J.compact,`font-mono tabular-nums text-muted-foreground`),t[0]=a):a=t[0];let o;return t[1]===i?o=t[2]:(o=(0,$.jsx)(`span`,{className:a,children:i}),t[1]=i,t[2]=o),o}function to(e){let t=(0,X.c)(51),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(u=function(){!n.filePath||!a||a(i&&n.filePath.startsWith(i)?n.filePath.slice(i.length+1):n.filePath)},t[0]=n.filePath,t[1]=a,t[2]=i,t[3]=u):u=t[3];let d=u;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.toolId||t[6]!==n.toolInput||t[7]!==n.toolName||t[8]!==e?(r=e?(0,$.jsxs)(Xa,{children:[(0,$.jsx)(Za,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:!1,muted:!1})})})}),(0,$.jsx)(Qa,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:W(J.caption,`space-y-2`),children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput})]})})]}):(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[4]=n.displayName,t[5]=n.toolId,t[6]=n.toolInput,t[7]=n.toolName,t[8]=e,t[9]=r):r=t[9];let a;t[10]!==n.editAddedLineCount||t[11]!==n.editDeletedLineCount||t[12]!==n.editNewText||t[13]!==n.editOldText||t[14]!==n.fileDisplayName||t[15]!==n.filePath||t[16]!==n.hasEditDiff||t[17]!==n.limit||t[18]!==n.offset||t[19]!==n.path||t[20]!==n.toolName||t[21]!==c||t[22]!==d||t[23]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:W(`inline-flex max-w-full items-center gap-2 cursor-pointer`,J.caption,`font-mono hover:underline`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[200px] sm:max-w-[320px]`,children:n.fileDisplayName}),n.toolName===`read`?(0,$.jsx)(eo,{offset:n.offset,limit:n.limit}):null,n.hasEditDiff?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 shrink-0`,children:[n.editAddedLineCount===null?null:(0,$.jsx)($a,{type:`added`,count:n.editAddedLineCount}),n.editDeletedLineCount===null?null:(0,$.jsx)($a,{type:`deleted`,count:n.editDeletedLineCount})]}):null]})}),(0,$.jsx)(U,{children:n.hasEditDiff?`View diff`:n.filePath?_a(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(mt,{open:c,onOpenChange:l,children:(0,$.jsxs)(ut,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:(0,$.jsx)(`code`,{className:W(J.caption,`font-mono`),children:_a(n.filePath,i)??n.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(Ra,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:W(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(U,{children:n.path})]}),t[10]=n.editAddedLineCount,t[11]=n.editDeletedLineCount,t[12]=n.editNewText,t[13]=n.editOldText,t[14]=n.fileDisplayName,t[15]=n.filePath,t[16]=n.hasEditDiff,t[17]=n.limit,t[18]=n.offset,t[19]=n.path,t[20]=n.toolName,t[21]=c,t[22]=d,t[23]=i,t[24]=a):a=t[24];let o;return t[25]!==r||t[26]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[25]=r,t[26]=a,t[27]=o):o=t[27],o}let f;t[28]===o?f=t[29]:(f=()=>s(!o),t[28]=o,t[29]=f);let p;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=W(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[30]=p):p=t[30];let m;t[31]===n.displayName?m=t[32]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[31]=n.displayName,t[32]=m);let h;t[33]===o?h=t[34]:(h=o?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[33]=o,t[34]=h);let g;t[35]!==f||t[36]!==m||t[37]!==h?(g=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[m,h]})}),t[35]=f,t[36]=m,t[37]=h,t[38]=g):g=t[38];let _;t[39]===n.toolName?_=t[40]:(_=(0,$.jsx)(U,{children:n.toolName}),t[39]=n.toolName,t[40]=_);let v;t[41]!==g||t[42]!==_?(v=(0,$.jsxs)(K,{children:[g,_]}),t[41]=g,t[42]=_,t[43]=v):v=t[43];let y;t[44]!==n.toolId||t[45]!==n.toolInput||t[46]!==o?(y=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[44]=n.toolId,t[45]=n.toolInput,t[46]=o,t[47]=y):y=t[47];let b;return t[48]!==v||t[49]!==y?(b=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[v,y]}),t[48]=v,t[49]=y,t[50]=b):b=t[50],b}function no(e){let t=(0,X.c)(8),{data:n}=e,r=n.toolName===`code_search`,i;t[0]!==n.codeSearchFileGlob||t[1]!==n.codeSearchFilePath||t[2]!==n.codeSearchQuery||t[3]!==n.pattern||t[4]!==r?(i=r?(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(Ua,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Ua,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Ua,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Ua,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Ua,{children:n.pattern}),t[0]=n.codeSearchFileGlob,t[1]=n.codeSearchFilePath,t[2]=n.codeSearchQuery,t[3]=n.pattern,t[4]=r,t[5]=i):i=t[5];let a;return t[6]===i?a=t[7]:(a=(0,$.jsx)($.Fragment,{children:i}),t[6]=i,t[7]=a),a}function ro(e){let t=(0,X.c)(68),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=n.toolName===`code_search`,d=n.codeSearchQuery??n.pattern??n.codeSearchFilePath??n.codeSearchFileGlob??`search`;if(r){if(i&&(u||n.toolName===`find`||n.pattern!==null)){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==a?(e=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[0]=n.displayName,t[1]=n.toolName,t[2]=a,t[3]=e):e=t[3];let r,o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>l(!0),o=W(J.caption,`font-mono hover:underline break-all cursor-pointer`),t[4]=r,t[5]=o):(r=t[4],o=t[5]);let s;t[6]===d?s=t[7]:(s=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:o,children:d})}),t[6]=d,t[7]=s);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(U,{children:`View results`}),t[8]=u):u=t[8];let f;t[9]===s?f=t[10]:(f=(0,$.jsxs)(K,{children:[s,u]}),t[9]=s,t[10]=f);let p;t[11]!==e||t[12]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,f]}),t[11]=e,t[12]=f,t[13]=p):p=t[13];let m;t[14]!==c||t[15]!==i||t[16]!==d?(m=(0,$.jsx)(La,{open:c,onOpenChange:l,title:d,content:i}),t[14]=c,t[15]=i,t[16]=d,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)($.Fragment,{children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}let e;t[21]!==n.displayName||t[22]!==n.toolName||t[23]!==a?(e=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[21]=n.displayName,t[22]=n.toolName,t[23]=a,t[24]=e):e=t[24];let r;t[25]===n?r=t[26]:(r=(0,$.jsx)(no,{data:n}),t[25]=n,t[26]=r);let o;t[27]===n.lang?o=t[28]:(o=n.lang!==null&&(0,$.jsx)(`span`,{className:W(J.caption,`px-1.5 py-0.5 rounded bg-muted`),children:n.lang}),t[27]=n.lang,t[28]=o);let s;return t[29]!==e||t[30]!==r||t[31]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,o]}),t[29]=e,t[30]=r,t[31]=o,t[32]=s):s=t[32],s}let f;t[33]===o?f=t[34]:(f=()=>s(!o),t[33]=o,t[34]=f);let p;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(p=W(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[35]=p):p=t[35];let m;t[36]===a?m=t[37]:(m=a&&(0,$.jsx)(Wa,{size:`md`}),t[36]=a,t[37]=m);let h;t[38]===n.displayName?h=t[39]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=h);let g;t[40]!==n.codeSearchFileGlob||t[41]!==n.codeSearchFilePath||t[42]!==n.codeSearchQuery||t[43]!==n.pattern||t[44]!==u?(g=u&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:W(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(`code`,{className:W(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(`code`,{className:W(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(`code`,{className:W(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchFileGlob})]}),t[40]=n.codeSearchFileGlob,t[41]=n.codeSearchFilePath,t[42]=n.codeSearchQuery,t[43]=n.pattern,t[44]=u,t[45]=g):g=t[45];let _;t[46]===o?_=t[47]:(_=o?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[46]=o,t[47]=_);let v;t[48]!==f||t[49]!==m||t[50]!==h||t[51]!==g||t[52]!==_?(v=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[m,h,g,_]})}),t[48]=f,t[49]=m,t[50]=h,t[51]=g,t[52]=_,t[53]=v):v=t[53];let y;t[54]===n.toolName?y=t[55]:(y=(0,$.jsx)(U,{children:n.toolName}),t[54]=n.toolName,t[55]=y);let b;t[56]!==v||t[57]!==y?(b=(0,$.jsxs)(K,{children:[v,y]}),t[56]=v,t[57]=y,t[58]=b):b=t[58];let x;t[59]!==n.toolId||t[60]!==n.toolInput||t[61]!==o||t[62]!==u||t[63]!==i?(x=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:Ia({maxHeight:`64`,className:`mt-2`}),children:i})]}),t[59]=n.toolId,t[60]=n.toolInput,t[61]=o,t[62]=u,t[63]=i,t[64]=x):x=t[64];let S;return t[65]!==x||t[66]!==b?(S=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[b,x]}),t[65]=x,t[66]=b,t[67]=S):S=t[67],S}function io(e){let t=(0,X.c)(57),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(Za,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),t[0]=n.displayName,t[1]=n.toolName,t[2]=i,t[3]=e):e=t[3];let r;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=W(J.caption,`space-y-2`),t[4]=r):r=t[4];let a;t[5]===n.toolId?a=t[6]:(a=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[5]=n.toolId,t[6]=a);let o;t[7]!==n.prompt||t[8]!==n.toolInput?(o=n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,t[7]=n.prompt,t[8]=n.toolInput,t[9]=o):o=t[9];let s;t[10]!==a||t[11]!==o?(s=(0,$.jsx)(Qa,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:r,children:[a,o]})}),t[10]=a,t[11]=o,t[12]=s):s=t[12];let c;t[13]!==e||t[14]!==s?(c=(0,$.jsxs)(Xa,{children:[e,s]}),t[13]=e,t[14]=s,t[15]=c):c=t[15];let l;t[16]===n.agentName?l=t[17]:(l=n.agentName&&(0,$.jsx)(Va,{name:n.agentName}),t[16]=n.agentName,t[17]=l);let u;t[18]===n.subagentType?u=t[19]:(u=n.subagentType&&(0,$.jsx)(Ha,{type:n.subagentType}),t[18]=n.subagentType,t[19]=u);let d;return t[20]!==c||t[21]!==l||t[22]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[c,l,u]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d):d=t[23],d}let s;t[24]===a?s=t[25]:(s=()=>o(!a),t[24]=a,t[25]=s);let c;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(c=W(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[26]=c):c=t[26];let l;t[27]===i?l=t[28]:(l=i&&(0,$.jsx)(Wa,{size:`md`}),t[27]=i,t[28]=l);let u;t[29]===n.displayName?u=t[30]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[29]=n.displayName,t[30]=u);let d;t[31]===n.agentName?d=t[32]:(d=n.agentName&&(0,$.jsx)(Va,{name:n.agentName}),t[31]=n.agentName,t[32]=d);let f;t[33]===n.subagentType?f=t[34]:(f=n.subagentType&&(0,$.jsx)(Ha,{type:n.subagentType}),t[33]=n.subagentType,t[34]=f);let p;t[35]===a?p=t[36]:(p=a?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[35]=a,t[36]=p);let m;t[37]!==s||t[38]!==l||t[39]!==u||t[40]!==d||t[41]!==f||t[42]!==p?(m=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d,f,p]})}),t[37]=s,t[38]=l,t[39]=u,t[40]=d,t[41]=f,t[42]=p,t[43]=m):m=t[43];let h;t[44]===n.toolName?h=t[45]:(h=(0,$.jsx)(U,{children:n.toolName}),t[44]=n.toolName,t[45]=h);let g;t[46]!==m||t[47]!==h?(g=(0,$.jsxs)(K,{children:[m,h]}),t[46]=m,t[47]=h,t[48]=g):g=t[48];let _;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==a?(_=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ia({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=a,t[53]=_):_=t[53];let v;return t[54]!==g||t[55]!==_?(v=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[g,_]}),t[54]=g,t[55]=_,t[56]=v):v=t[56],v}function ao(e){let t=(0,X.c)(26),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r)return null;let s;t[0]===a?s=t[1]:(s=()=>o(!a),t[0]=a,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=W(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),t[2]=c):c=t[2];let l;t[3]===i?l=t[4]:(l=i&&(0,$.jsx)(Wa,{size:`md`}),t[3]=i,t[4]=l);let u;t[5]===n.displayName?u=t[6]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[5]=n.displayName,t[6]=u);let d;t[7]===a?d=t[8]:(d=a?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[7]=a,t[8]=d);let f;t[9]!==s||t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[9]=s,t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.toolName?p=t[15]:(p=(0,$.jsx)(U,{children:n.toolName}),t[14]=n.toolName,t[15]=p);let m;t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(K,{children:[f,p]}),t[16]=f,t[17]=p,t[18]=m):m=t[18];let h;t[19]!==n.toolId||t[20]!==n.toolInput||t[21]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[19]=n.toolId,t[20]=n.toolInput,t[21]=a,t[22]=h):h=t[22];let g;return t[23]!==m||t[24]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[23]=m,t[24]=h,t[25]=g):g=t[25],g}function oo(e){let t=(0,X.c)(35),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:i}),t[0]=n.displayName,t[1]=n.toolName,t[2]=i,t[3]=e):e=t[3];let r;t[4]===n.imageGenPrompt?r=t[5]:(r=n.imageGenPrompt!==null&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:W(J.caption,`truncate max-w-[200px] sm:max-w-[320px]`),children:n.imageGenPrompt})}),(0,$.jsx)(U,{children:n.imageGenPrompt})]}),t[4]=n.imageGenPrompt,t[5]=r);let a;return t[6]!==e||t[7]!==r?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[6]=e,t[7]=r,t[8]=a):a=t[8],a}let s;t[9]===a?s=t[10]:(s=()=>o(!a),t[9]=a,t[10]=s);let c;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(c=W(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),t[11]=c):c=t[11];let l;t[12]===i?l=t[13]:(l=i&&(0,$.jsx)(Wa,{size:`md`}),t[12]=i,t[13]=l);let u;t[14]===n.displayName?u=t[15]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[14]=n.displayName,t[15]=u);let d;t[16]===a?d=t[17]:(d=a?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[16]=a,t[17]=d);let f;t[18]!==s||t[19]!==l||t[20]!==u||t[21]!==d?(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[18]=s,t[19]=l,t[20]=u,t[21]=d,t[22]=f):f=t[22];let p;t[23]===n.toolName?p=t[24]:(p=(0,$.jsx)(U,{children:n.toolName}),t[23]=n.toolName,t[24]=p);let m;t[25]!==f||t[26]!==p?(m=(0,$.jsxs)(K,{children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[28]=n.toolId,t[29]=n.toolInput,t[30]=a,t[31]=h):h=t[31];let g;return t[32]!==m||t[33]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[32]=m,t[33]=h,t[34]=g):g=t[34],g}function so(e){let t=(0,X.c)(40),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r){let e=!!(n.prompt??(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName)),r;t[0]!==n.displayName||t[1]!==n.prompt||t[2]!==n.toolId||t[3]!==n.toolInput||t[4]!==n.toolName||t[5]!==e||t[6]!==i?(r=e?(0,$.jsxs)(Xa,{children:[(0,$.jsx)(Za,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(Qa,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:W(J.bodyMuted,`space-y-2`),children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]})})]}):(0,$.jsx)(Ga,{toolName:n.toolName,displayName:n.displayName,isActive:i}),t[0]=n.displayName,t[1]=n.prompt,t[2]=n.toolId,t[3]=n.toolInput,t[4]=n.toolName,t[5]=e,t[6]=i,t[7]=r):r=t[7];let a;t[8]===n.path?a=t[9]:(a=n.path!==null&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:W(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(U,{children:n.path})]}),t[8]=n.path,t[9]=a);let o;return t[10]!==r||t[11]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[10]=r,t[11]=a,t[12]=o):o=t[12],o}let s;t[13]===a?s=t[14]:(s=()=>o(!a),t[13]=a,t[14]=s);let c;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(c=W(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[15]=c):c=t[15];let l;t[16]===i?l=t[17]:(l=i&&(0,$.jsx)(Wa,{size:`md`}),t[16]=i,t[17]=l);let u;t[18]===n.displayName?u=t[19]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[18]=n.displayName,t[19]=u);let d;t[20]===a?d=t[21]:(d=a?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[20]=a,t[21]=d);let f;t[22]!==s||t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[22]=s,t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26];let p;t[27]===n.toolName?p=t[28]:(p=(0,$.jsx)(U,{children:n.toolName}),t[27]=n.toolName,t[28]=p);let m;t[29]!==f||t[30]!==p?(m=(0,$.jsxs)(K,{children:[f,p]}),t[29]=f,t[30]=p,t[31]=m):m=t[31];let h;t[32]!==n.prompt||t[33]!==n.toolId||t[34]!==n.toolInput||t[35]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ia({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ia(),children:n.toolInput}):null]}),t[32]=n.prompt,t[33]=n.toolId,t[34]=n.toolInput,t[35]=a,t[36]=h):h=t[36];let g;return t[37]!==m||t[38]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[37]=m,t[38]=h,t[39]=g):g=t[39],g}function co(e){let t=(0,X.c)(40),{block:n,inline:r,resultContent:i,isActive:a}=e,{setPendingExplorerPath:o,setActiveMainTab:s}=ca(),c=Q(lo),l=Ca(n,c),u=!!a,d;t[0]!==s||t[1]!==o?(d=function(e){o(e),s(`explorer`)},t[0]=s,t[1]=o,t[2]=d):d=t[2];let f=d;switch(l.toolType){case`bash`:{let e;return t[3]!==l||t[4]!==r||t[5]!==u||t[6]!==i?(e=(0,$.jsx)(Ka,{data:l,inline:r,resultContent:i,isActive:u}),t[3]=l,t[4]=r,t[5]=u,t[6]=i,t[7]=e):e=t[7],e}case`fetch`:{let e;return t[8]!==l||t[9]!==r||t[10]!==u||t[11]!==i?(e=(0,$.jsx)(qa,{data:l,inline:r,resultContent:i,isActive:u}),t[8]=l,t[9]=r,t[10]=u,t[11]=i,t[12]=e):e=t[12],e}case`file`:{let e;return t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==u||t[17]!==c?(e=(0,$.jsx)(to,{data:l,inline:r,rootPath:c,onOpenFile:f,isActive:u}),t[13]=l,t[14]=f,t[15]=r,t[16]=u,t[17]=c,t[18]=e):e=t[18],e}case`search`:{let e;return t[19]!==l||t[20]!==r||t[21]!==u||t[22]!==i?(e=(0,$.jsx)(ro,{data:l,inline:r,resultContent:i,isActive:u}),t[19]=l,t[20]=r,t[21]=u,t[22]=i,t[23]=e):e=t[23],e}case`agent`:{let e;return t[24]!==l||t[25]!==r||t[26]!==u?(e=(0,$.jsx)(io,{data:l,inline:r,isActive:u}),t[24]=l,t[25]=r,t[26]=u,t[27]=e):e=t[27],e}case`todo`:{let e;return t[28]!==l||t[29]!==r||t[30]!==u?(e=(0,$.jsx)(ao,{data:l,inline:r,isActive:u}),t[28]=l,t[29]=r,t[30]=u,t[31]=e):e=t[31],e}case`imageGen`:{let e;return t[32]!==l||t[33]!==r||t[34]!==u?(e=(0,$.jsx)(oo,{data:l,inline:r,isActive:u}),t[32]=l,t[33]=r,t[34]=u,t[35]=e):e=t[35],e}default:{let e;return t[36]!==l||t[37]!==r||t[38]!==u?(e=(0,$.jsx)(so,{data:l,inline:r,isActive:u}),t[36]=l,t[37]=r,t[38]=u,t[39]=e):e=t[39],e}}}function lo(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}var uo=(0,Y.createContext)({todos:[],setTodos:()=>{}});function fo(e){let t=(0,X.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Y.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,$.jsx)(uo.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function po(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function mo(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Y.useContext)(uo),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Y.useEffect)(a,o),null}function ho(e){let t=$t(e);if(!t?.imageUrl&&!t?.imageData)return null;let n;if(typeof e==`object`&&e){let t=e;if(typeof t.model==`string`)n=t.model;else if(typeof t.content==`string`)try{let e=JSON.parse(t.content);typeof e.model==`string`&&(n=e.model)}catch{}}else if(typeof e==`string`)try{let t=JSON.parse(e.trim());typeof t.model==`string`&&(n=t.model)}catch{}return{imageUrl:t.imageUrl,imageData:t.imageData,model:n}}function go(e){let t=(0,X.c)(29),{imageUrl:n,imageData:i}=e,[a,o]=(0,Y.useState)(!1),s=i?`data:image/png;base64,${i}`:n??``,c;t[0]===s?c=t[1]:(c=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await fn(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:s,filename:e});wi({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=async()=>{await T(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:s}),o(!0),setTimeout(()=>o(!1),2e3)},t[2]=s,t[3]=u);let d=u;if(!s)return null;let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={maxHeight:`512px`},t[4]=f):f=t[4];let p;t[5]===s?p=t[6]:(p=(0,$.jsx)(`img`,{src:s,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:f}),t[5]=s,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(z,{className:`h-3.5 w-3.5`}),t[7]=m):m=t[7];let h;t[8]===l?h=t[9]:(h=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:m})}),t[8]=l,t[9]=h);let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(U,{children:`Save image`}),t[10]=g):g=t[10];let _;t[11]===h?_=t[12]:(_=(0,$.jsxs)(K,{children:[h,g]}),t[11]=h,t[12]=_);let v;t[13]===a?v=t[14]:(v=a?(0,$.jsx)(Vt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),t[13]=a,t[14]=v);let y;t[15]!==d||t[16]!==v?(y=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:d,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:v})}),t[15]=d,t[16]=v,t[17]=y):y=t[17];let b=a?`Copied!`:`Copy to clipboard`,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(U,{children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(K,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==_?(C=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(r,{children:[_,S]})}),t[23]=S,t[24]=_,t[25]=C):C=t[25];let w;return t[26]!==C||t[27]!==p?(w=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[p,C]}),t[26]=C,t[27]=p,t[28]=w):w=t[28],w}function _o(e){let t=(0,X.c)(79),{block:n,inline:r,sequence:i}=e,a=i===void 0?0:i,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=Q(vo),d=n.toolName??`Unknown Tool`,f=n.toolCallId??`unknown`,p=n,m=n.result??p.content,h;t[0]!==p||t[1]!==d?(h=d===`todo`?po(p):null,t[0]=p,t[1]=d,t[2]=h):h=t[2];let g=h,_,v,y,b,x,S;if(t[3]!==p||t[4]!==r||t[5]!==m||t[6]!==u||t[7]!==a||t[8]!==g||t[9]!==d){S=Symbol.for(`react.early_return_sentinel`);bb0:{if(y=_a(Sa(m),u),!(y.length>0)&&g===null){S=null;break bb0}let e;if(t[16]!==m||t[17]!==u||t[18]!==d){if(_=ga(d),typeof m==`object`&&m){let e=m,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[21]===n?e=t[22]:(e=n.trim(),t[21]=n,t[22]=e),_=e}else if(d===`read`||d===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[23]===n?e=t[24]:(e=n.split(`/`).pop()??n,t[23]=n,t[24]=e),_=`Completed ${e}`}}}else if(m==null){let e;t[25]===d?e=t[26]:(e=ga(d),t[25]=d,t[26]=e),_=`${e} (no result)`}e=_a(_,u),t[16]=m,t[17]=u,t[18]=d,t[19]=_,t[20]=e}else _=t[19],e=t[20];if(_=e,g!==null){let e;t[27]!==a||t[28]!==g?(e=(0,$.jsx)(mo,{todos:g,sequence:a}),t[27]=a,t[28]=g,t[29]=e):e=t[29],S=e;break bb0}if(d===`generate_image`){let e;t[30]!==p||t[31]!==m?(e=ho(m)??ho(p),t[30]=p,t[31]=m,t[32]=e):e=t[32];let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[33]!==n.imageData||t[34]!==n.imageUrl?(e=(0,$.jsx)(go,{imageUrl:n.imageUrl,imageData:n.imageData}),t[33]=n.imageData,t[34]=n.imageUrl,t[35]=e):e=t[35],S=e;break bb0}}if(r){S=null;break bb0}let n;t[36]===d?n=t[37]:(n=d.toLowerCase().includes(`bash`),t[36]=d,t[37]=n),v=n,b=y?y.split(`
|
|
22
|
+
`):[],x=v?b.slice(0,3).join(`
|
|
23
|
+
`):y}t[3]=p,t[4]=r,t[5]=m,t[6]=u,t[7]=a,t[8]=g,t[9]=d,t[10]=_,t[11]=v,t[12]=y,t[13]=b,t[14]=x,t[15]=S}else _=t[10],v=t[11],y=t[12],b=t[13],x=t[14],S=t[15];if(S!==Symbol.for(`react.early_return_sentinel`))return S;let C=x,w=v&&b.length>3;if(v){let e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.body,`px-3 py-2 flex items-center gap-2 font-medium text-foreground`),t[38]=e):e=t[38];let n;t[39]===_?n=t[40]:(n=(0,$.jsx)(`div`,{className:e,children:(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:_})}),t[39]=_,t[40]=n);let r;t[41]!==w||t[42]!==C||t[43]!==y||t[44]!==b?(r=y&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[w?(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`pre`,{className:W(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2 cursor-pointer hover:bg-muted/80`),onClick:()=>l(!0),children:[C,(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
24
|
+
`,`...`]})]})}),(0,$.jsx)(U,{children:`Click to see full output`})]}):(0,$.jsx)(`pre`,{className:W(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2`),children:C}),w&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:W(J.caption,`mt-1 text-brand hover:underline`),children:[`Show full output (`,b.length,` lines)`]})]}),t[41]=w,t[42]=C,t[43]=y,t[44]=b,t[45]=r):r=t[45];let i;t[46]!==n||t[47]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[46]=n,t[47]=r,t[48]=i):i=t[48];let a;t[49]!==c||t[50]!==w||t[51]!==y?(a=w&&(0,$.jsx)(mt,{open:c,onOpenChange:l,children:(0,$.jsxs)(ut,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:W(J.caption,`bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`),children:y})]})}),t[49]=c,t[50]=w,t[51]=y,t[52]=a):a=t[52];let o;return t[53]!==i||t[54]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[53]=i,t[54]=a,t[55]=o):o=t[55],o}let T;t[56]===o?T=t[57]:(T=()=>s(!o),t[56]=o,t[57]=T);let E;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(E=W(J.body,`w-full px-3 py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted transition-colors text-left`),t[58]=E):E=t[58];let D;t[59]===_?D=t[60]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:_}),t[59]=_,t[60]=D);let O;t[61]===o?O=t[62]:(O=o?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[61]=o,t[62]=O);let k;t[63]!==T||t[64]!==D||t[65]!==O?(k=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:T,className:E,children:[D,O]})}),t[63]=T,t[64]=D,t[65]=O,t[66]=k):k=t[66];let A=`${d} result`,M;t[67]===A?M=t[68]:(M=(0,$.jsx)(U,{children:A}),t[67]=A,t[68]=M);let N;t[69]!==M||t[70]!==k?(N=(0,$.jsxs)(K,{children:[k,M]}),t[69]=M,t[70]=k,t[71]=N):N=t[71];let P;t[72]!==o||t[73]!==y||t[74]!==f?(P=o&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`Call ID: `,f]}),y&&(0,$.jsx)(`pre`,{className:W(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`),children:y})]}),t[72]=o,t[73]=y,t[74]=f,t[75]=P):P=t[75];let F;return t[76]!==N||t[77]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[N,P]}),t[76]=N,t[77]=P,t[78]=F):F=t[78],F}function vo(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}function yo(e){if(e<1e3){let t=Math.max(1,Math.round(e));return`${t} millisecond${t===1?``:`s`}`}let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t} second${t===1?``:`s`}`;let n=Math.floor(t/60),r=t%60;return r===0?`${n} minute${n===1?``:`s`}`:`${n} minute${n===1?``:`s`} ${r} second${r===1?``:`s`}`}function bo(e,t,n){return e?t===`MCP`?`Connecting MCP servers...`:t===`Validating`?`Validating...`:`Thinking...`:t===`MCP`?`MCP setup complete.`:t===`Validated`?`Validated`:n<=0?`Thought complete.`:`Thought for ${yo(n)}.`}function xo(e){let t=(0,X.c)(40),{text:n,isStreaming:r,label:i}=e,a=n===void 0?``:n,o=r===void 0?!1:r,s=(0,Y.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Date.now(),t[0]=c):c=t[0];let l=(0,Y.useRef)(c),[u,d]=(0,Y.useState)(0),[f,p]=(0,Y.useState)(o),m=(0,Y.useRef)(o),h,g;t[1]===o?(h=t[2],g=t[3]):(h=()=>{o&&!m.current?(l.current=Date.now(),d(0),p(!0)):o?p(!0):m.current&&!o&&(d(Date.now()-l.current),p(!1)),m.current=o},g=[o],t[1]=o,t[2]=h,t[3]=g),(0,Y.useEffect)(h,g);let _;t[4]!==f||t[5]!==o?(_=()=>{f&&o&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},t[4]=f,t[5]=o,t[6]=_):_=t[6];let v;if(t[7]!==f||t[8]!==o||t[9]!==a?(v=[a,f,o],t[7]=f,t[8]=o,t[9]=a,t[10]=v):v=t[10],(0,Y.useEffect)(_,v),!a&&!o)return null;let y=!o&&i===`Validated`,b;t[11]!==u||t[12]!==o||t[13]!==i?(b=bo(o,i,u),t[11]=u,t[12]=o,t[13]=i,t[14]=b):b=t[14];let x=b,S;t[15]===a?S=t[16]:(S=a?ha(a):``,t[15]=a,t[16]=S);let C=S,w;t[17]===f?w=t[18]:(w=()=>p(!f),t[17]=f,t[18]=w);let T;t[19]===y?T=t[20]:(T=y?(0,$.jsx)(Oe,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):null,t[19]=y,t[20]=T);let E;t[21]===x?E=t[22]:(E=(0,$.jsx)(`span`,{className:J.caption,children:x}),t[21]=x,t[22]=E);let D;t[23]!==f||t[24]!==w||t[25]!==T||t[26]!==E?(D=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:w,"aria-expanded":f,children:[T,E]}),t[23]=f,t[24]=w,t[25]=T,t[26]=E,t[27]=D):D=t[27];let O=f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,k;t[28]===O?k=t[29]:(k=[`grid transition-[grid-template-rows] duration-200 ease-in-out`,O],t[28]=O,t[29]=k);let A=k.join(` `),j,M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=W(J.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`),M={maxHeight:`7.5em`},t[30]=j,t[31]=M):(j=t[30],M=t[31]);let N;t[32]===C?N=t[33]:(N=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:s,className:j,style:M,children:C})}),t[32]=C,t[33]=N);let P;t[34]!==A||t[35]!==N?(P=(0,$.jsx)(`div`,{className:A,children:N}),t[34]=A,t[35]=N,t[36]=P):P=t[36];let F;return t[37]!==D||t[38]!==P?(F=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D,P]}),t[37]=D,t[38]=P,t[39]=F):F=t[39],F}function So(e){let t=(0,X.c)(63),{toolCall:n,className:r}=e,i=si(),[a,o]=(0,Y.useState)(!1),s;t[0]===n.id?s=t[1]:(s=e=>e.toolCallProgress[n.id],t[0]=n.id,t[1]=s);let c=Q(s),l=Q(Eo),u=Q(To),d;t[2]!==n.activeDisplayName||t[3]!==n.name?(d=n.activeDisplayName??Pt(n.name),t[2]=n.activeDisplayName,t[3]=n.name,t[4]=d):d=t[4];let f=d;if(!l)return null;let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{o(wo)},t[5]=p):p=t[5];let m=p,h;t[6]!==i||t[7]!==u||t[8]!==n.id||t[9]!==n.name?(h=()=>{i({type:Z.StopStream});let e={type:`tool-result`,toolCallId:n.id,toolName:n.name,result:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`,isError:!0,content:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`};i({type:Z.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([e]),segments:u})},t[6]=i,t[7]=u,t[8]=n.id,t[9]=n.name,t[10]=h):h=t[10];let g=h,_=Co,v=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,y=n.name===`fetch`&&typeof n.input?.url==`string`?n.input.url:null,b=!v&&typeof n.input?.description==`string`?n.input.description:null,x;t[11]===r?x=t[12]:(x=W(`overflow-hidden mb-2`,r),t[11]=r,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Wa,{}),t[13]=S):S=t[13];let C;t[14]===f?C=t[15]:(C=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[S,(0,$.jsx)(`span`,{className:J.bodyMuted,children:f})]})}),t[14]=f,t[15]=C);let w;t[16]===n.name?w=t[17]:(w=(0,$.jsx)(U,{children:n.name}),t[16]=n.name,t[17]=w);let T;t[18]!==C||t[19]!==w?(T=(0,$.jsxs)(K,{children:[C,w]}),t[18]=C,t[19]=w,t[20]=T):T=t[20];let E;t[21]===v?E=t[22]:(E=v!==null&&(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:v}),t[21]=v,t[22]=E);let D;t[23]===y?D=t[24]:(D=y!==null&&(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:y.length>60?`${y.slice(0,59)}…`:y}),t[23]=y,t[24]=D);let O;t[25]===b?O=t[26]:(O=b!==null&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:b}),t[25]=b,t[26]=O);let k;t[27]!==v||t[28]!==b||t[29]!==y?(k=!v&&!y&&!b&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:`running`}),t[27]=v,t[28]=b,t[29]=y,t[30]=k):k=t[30];let A;t[31]===a?A=t[32]:(A=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:m,className:`p-1 hover:bg-muted/50 rounded transition-colors`,children:a?(0,$.jsx)(Ce,{className:`h-3 w-3`}):(0,$.jsx)(j,{className:`h-3 w-3`})})}),t[31]=a,t[32]=A);let M=a?`Collapse`:`Expand`,N;t[33]===M?N=t[34]:(N=(0,$.jsx)(U,{children:M}),t[33]=M,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsxs)(K,{children:[A,N]}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let F;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(un,{className:`h-3 w-3`}),t[38]=F):F=t[38];let I;t[39]===g?I=t[40]:(I=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:g,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:F})}),t[39]=g,t[40]=I);let L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(U,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[41]=L):L=t[41];let R;t[42]===I?R=t[43]:(R=(0,$.jsxs)(K,{children:[I,L]}),t[42]=I,t[43]=R);let ee;t[44]!==P||t[45]!==R?(ee=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[P,R]}),t[44]=P,t[45]=R,t[46]=ee):ee=t[46];let z;t[47]!==E||t[48]!==D||t[49]!==O||t[50]!==k||t[51]!==ee||t[52]!==T?(z=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[T,E,D,O,k,ee]}),t[47]=E,t[48]=D,t[49]=O,t[50]=k,t[51]=ee,t[52]=T,t[53]=z):z=t[53];let B;t[54]!==a||t[55]!==n.id||t[56]!==n.input||t[57]!==c?(B=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:W(J.compact,J.bodyMuted,`mb-2 font-mono`),children:[`ID: `,n.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:W(J.compact,J.label,`text-muted-foreground mb-1`),children:`Input:`}),(0,$.jsx)(`pre`,{className:Ia({className:`border border-border`}),children:_(n.input)})]}),c&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:W(J.compact,J.label,`text-muted-foreground mb-1`),children:`Progress:`}),(0,$.jsxs)(`div`,{className:W(J.body,`bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800`),children:[(0,$.jsx)(`div`,{className:W(J.mono,`text-green-700 dark:text-green-300`),children:c.delta}),c.partial?.content?.[0]?.arguments&&typeof c.partial.content[0].arguments==`object`&&`content`in c.partial.content[0].arguments&&typeof c.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:W(J.mono,`mt-1 text-green-600 dark:text-green-400`),children:[`Building: `,c.partial.content[0].arguments.content.slice(-50),c.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:W(J.compact,`flex items-center gap-1.5 text-muted-foreground`),children:[(0,$.jsx)(Wa,{}),`Executing`,c&&` with progress`,`...`]})]}),t[54]=a,t[55]=n.id,t[56]=n.input,t[57]=c,t[58]=B):B=t[58];let V;return t[59]!==z||t[60]!==B||t[61]!==x?(V=(0,$.jsxs)(`div`,{className:x,children:[z,B]}),t[59]=z,t[60]=B,t[61]=x,t[62]=V):V=t[62],V}function Co(e){return JSON.stringify(e,null,2)}function wo(e){return!e}function To(e){return e.streamingSegments}function Eo(e){return e.isStreaming}function Do(e){let t=(0,X.c)(70),{toolCallId:n,question:r,options:i,context:a,answeredText:o,answeredLabel:c}=e,[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!!o),[m,h]=(0,Y.useState)(o??``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(null),b,x;t[0]===o?(b=t[1],x=t[2]):(b=()=>{let e=o?.trim();if(e){p(!0),h(e),_(!1),y(null);return}p(!1),h(``)},x=[o],t[0]=o,t[1]=b,t[2]=x),(0,Y.useEffect)(b,x);let S;t[3]!==g||t[4]!==n?(S=async e=>{if(!(!e.trim()||g)){_(!0);try{await s(n,e.trim()),h(e.trim()),p(!0)}catch(e){console.error(`Failed to submit answer:`,e),_(!1),y(null)}}},t[3]=g,t[4]=n,t[5]=S):S=t[5];let C=S,w;t[6]!==C||t[7]!==g||t[8]!==f?(w=e=>{f||g||(y(e),C(e))},t[6]=C,t[7]=g,t[8]=f,t[9]=w):w=t[9];let T=w,E;t[10]!==u||t[11]!==C||t[12]!==g||t[13]!==f?(E=()=>{if(f||g)return;let e=u.trim();e&&C(e)},t[10]=u,t[11]=C,t[12]=g,t[13]=f,t[14]=E):E=t[14];let D=E,O;t[15]===D?O=t[16]:(O=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D())},t[15]=D,t[16]=O);let k=O;if(f){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Vt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[17]=e):e=t[17];let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=W(J.label,`text-foreground`),t[18]=n):n=t[18];let i;t[19]===r?i=t[20]:(i=(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(Xi,{content:r})}),t[19]=r,t[20]=i);let o;t[21]===a?o=t[22]:(o=a&&(0,$.jsx)(`p`,{className:W(J.bodyMuted,`mt-1`),children:a}),t[21]=a,t[22]=o);let s;t[23]!==o||t[24]!==i?(s=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[e,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i,o]})]}),t[23]=o,t[24]=i,t[25]=s):s=t[25];let l=c??`You answered`,u;t[26]===l?u=t[27]:(u=(0,$.jsxs)(`span`,{className:`font-medium`,children:[l,`:`]}),t[26]=l,t[27]=u);let d;t[28]===m?d=t[29]:(d=(0,$.jsx)(`span`,{children:m}),t[28]=m,t[29]=d);let f;t[30]!==u||t[31]!==d?(f=(0,$.jsxs)(`div`,{className:J.bodyMuted,children:[u,` `,d]}),t[30]=u,t[31]=d,t[32]=f):f=t[32];let p;return t[33]!==s||t[34]!==f?(p=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[s,f]}),t[33]=s,t[34]=f,t[35]=p):p=t[35],p}let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(l,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[36]=A):A=t[36];let j;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(j=W(J.label,`text-foreground`),t[37]=j):j=t[37];let M;t[38]===r?M=t[39]:(M=(0,$.jsx)(`div`,{className:j,children:(0,$.jsx)(Xi,{content:r})}),t[38]=r,t[39]=M);let N;t[40]===a?N=t[41]:(N=a&&(0,$.jsx)(`p`,{className:W(J.bodyMuted,`mt-1`),children:a}),t[40]=a,t[41]=N);let P;t[42]!==N||t[43]!==M?(P=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[A,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[M,N]})]}),t[42]=N,t[43]=M,t[44]=P):P=t[44];let F;t[45]!==T||t[46]!==g||t[47]!==i||t[48]!==v?(F=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=v===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T(e),disabled:g,className:W(`rounded-md border px-3 py-1.5 transition-colors disabled:opacity-50 flex items-center gap-1.5`,J.label,t?`border-foreground/20 bg-accent text-accent-foreground`:`border-foreground/20 bg-background text-foreground hover:bg-accent hover:text-accent-foreground`),children:[t&&(0,$.jsx)(Vt,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[45]=T,t[46]=g,t[47]=i,t[48]=v,t[49]=F):F=t[49];let I;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>d(e.target.value),t[50]=I):I=t[50];let L=i?.length?`Or type a custom answer...`:`Type your answer...`,R;t[51]!==u||t[52]!==k||t[53]!==g||t[54]!==L?(R=(0,$.jsx)(`input`,{type:`text`,value:u,onChange:I,onKeyDown:k,placeholder:L,disabled:g,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-base text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),t[51]=u,t[52]=k,t[53]=g,t[54]=L,t[55]=R):R=t[55];let ee;t[56]!==u||t[57]!==g?(ee=g||!u.trim(),t[56]=u,t[57]=g,t[58]=ee):ee=t[58];let z;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(le,{className:`h-3 w-3`}),t[59]=z):z=t[59];let B;t[60]!==D||t[61]!==ee?(B=(0,$.jsx)(`button`,{type:`button`,onClick:D,disabled:ee,className:`h-7 w-7 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center justify-center shrink-0`,children:z}),t[60]=D,t[61]=ee,t[62]=B):B=t[62];let V;t[63]!==R||t[64]!==B?(V=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[R,B]}),t[63]=R,t[64]=B,t[65]=V):V=t[65];let te;return t[66]!==P||t[67]!==F||t[68]!==V?(te=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[P,F,V]}),t[66]=P,t[67]=F,t[68]=V,t[69]=te):te=t[69],te}var Oo=Zn,ko=Pn,Ao=Vn,jo=Y.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==i||n[6]!==a?(s=W(W(J.body,`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`),a&&`pl-8`,i),n[5]=i,n[6]=a,n[7]=s):s=n[7];let c;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ae,{className:`ml-auto`}),n[8]=c):c=n[8];let l;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(Hn,{ref:t,className:s,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});jo.displayName=Hn.displayName;var Mo=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Bn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Mo.displayName=Bn.displayName;var No=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=W(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(wn,{children:(0,$.jsx)(Rn,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});No.displayName=Rn.displayName;var Po=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==i?(o=W(W(J.body,`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`),i&&`pl-8`,r),n[4]=r,n[5]=i,n[6]=o):o=n[6];let s;return n[7]!==a||n[8]!==t||n[9]!==o?(s=(0,$.jsx)(Tn,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Po.displayName=Tn.displayName;var Fo=Y.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=W(W(J.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Ln,{children:(0,$.jsx)(Vt,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(bn,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});Fo.displayName=bn.displayName;var Io=Y.forwardRef((e,t)=>{let n=(0,X.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=W(W(J.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Ln,{children:(0,$.jsx)(mn,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(On,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});Io.displayName=On.displayName;var Lo=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=W(J.body,`px-2 py-1.5 font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(zn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Lo.displayName=zn.displayName;var Ro=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Dn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ro.displayName=Dn.displayName;var zo=e=>{let t=(0,X.c)(8),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=W(J.compact,`ml-auto tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};zo.displayName=`DropdownMenuShortcut`;function Bo({toolCallId:e,command:t,projectId:n,wildcardOptions:r,resolvedDecision:i}){let[a,o]=(0,Y.useState)(!!i),[s,c]=(0,Y.useState)(i??null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{i&&(o(!0),c(i),u(!1))},[i]);async function d(t,r){if(!(l||a)){u(!0);try{await V(e,t,{pattern:r,projectId:n??void 0}),o(!0),c(t===`skip`?`skipped`:`allowed`)}catch(e){console.error(`Failed to submit shell permission response:`,e),u(!1)}}}return a&&s!==`skipped`?null:a?(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,$.jsx)(Vt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Shell command permission`}),(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:`Skipped`})]}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,$.jsx)(I,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Allow the agent to run this command?`}),(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Oo,{children:[(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,className:W(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(j,{className:`h-4 w-4`})})}),(0,$.jsx)(No,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Po,{onClick:()=>void d(e.scope===`project`?`allow_pattern_project`:`allow_pattern_session`,e.pattern),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Skip`})]})]})}function Vo({toolCallId:e,hostname:t,url:n,wildcardOptions:r,resolvedDecision:i}){let[a,o]=(0,Y.useState)(!!i),[s,c]=(0,Y.useState)(i??null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{i&&(o(!0),c(i),u(!1))},[i]);async function d(t){if(!(l||a)){u(!0);try{await ne(e,t),o(!0),c(t===`skip`?`skipped`:`allowed`)}catch(e){console.error(`Failed to submit web fetch permission response:`,e),u(!1)}}}return a&&s!==`skipped`?null:a?(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,$.jsx)(Vt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Web fetch permission`}),(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:`Skipped`})]}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[(0,$.jsx)(Ve,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Allow the agent to fetch from this domain?`}),(0,$.jsx)(`code`,{className:W(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t}),(0,$.jsx)(`div`,{className:W(J.caption,J.bodyMuted,`mt-1 break-all`),children:n})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Oo,{children:[(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,className:W(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(j,{className:`h-4 w-4`})})}),(0,$.jsx)(No,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Po,{onClick:()=>void d(e.scope===`project`?`allow_domain_project`:`allow_domain_session`),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Deny`})]})]})}var Ho=new Map,Uo=new Map;function Wo(e){return Ho.get(e)}function Go(e,t){let n=Uo.get(e);return n||(n=new Set,Uo.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Uo.delete(e)}}function Ko(e){let t=Uo.get(e);if(t)for(let e of t)e()}function qo(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function Jo(e,t,n){if(Ho.has(e))return;Ho.set(e,{status:`running`}),Ko(e);let r=Ut();(async()=>{try{let i=qo(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;Ho.set(e,{status:`success`,result:s}),Ko(e),await yt(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);Ho.set(e,{status:`error`,error:n}),Ko(e);try{await yt(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function Yo(e){let t=(0,X.c)(49),{toolCallId:n,intention:r,code:i}=e,a=Q(Zo),o;t[0]===n?o=t[1]:(o=Wo(n),t[0]=n,t[1]=o);let s=o,[c,l]=(0,Y.useState)(s?.status??`running`),u;t[2]===s?u=t[3]:(u=()=>{if(!s||s.status!==`success`)return null;let e=s.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},t[2]=s,t[3]=u);let[d,f]=(0,Y.useState)(u),[p,m]=(0,Y.useState)(s?.error??null),h,g;t[4]===n?(h=t[5],g=t[6]):(h=()=>Go(n,()=>{let e=Wo(n);if(e)if(l(e.status),e.status===`success`){let t=e.result;f(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&m(e.error??null)}),g=[n],t[4]=n,t[5]=h,t[6]=g),(0,Y.useEffect)(h,g);let _,v;t[7]!==i||t[8]!==a||t[9]!==n?(_=()=>{a&&Jo(n,i,a)},v=[n,i,a],t[7]=i,t[8]=a,t[9]=n,t[10]=_,t[11]=v):(_=t[10],v=t[11]),(0,Y.useEffect)(_,v);let[y,x]=(0,Y.useState)(!1),S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>x(Xo),t[12]=S):S=t[12];let C=S;if(c===`running`){let e,n;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.label,`w-full py-2 flex items-center gap-2`),n=(0,$.jsx)(b,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[13]=e,t[14]=n):(e=t[13],n=t[14]);let i=r||`Executing Browser JS...`,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:i})]})}),t[15]=i,t[16]=a),a}if(c===`success`){let e,n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=W(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),n=(0,$.jsx)(b,{className:`h-4 w-4 shrink-0 text-brand`}),t[17]=e,t[18]=n):(e=t[17],n=t[18]);let a=r||`Browser JS Executed Successfully`,o;t[19]===a?o=t[20]:(o=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:a}),t[19]=a,t[20]=o);let s;t[21]===y?s=t[22]:(s=y?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[21]=y,t[22]=s);let c;t[23]!==o||t[24]!==s?(c=(0,$.jsxs)(`button`,{onClick:C,className:e,children:[n,o,s]}),t[23]=o,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==y||t[28]!==d?(l=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:W(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i}),d!=null&&(0,$.jsx)(`pre`,{className:W(J.body,`leading-relaxed whitespace-pre-wrap border-t border-border pt-2`),children:d})]}),t[26]=i,t[27]=y,t[28]=d,t[29]=l):l=t[29];let u;return t[30]!==c||t[31]!==l?(u=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[c,l]}),t[30]=c,t[31]=l,t[32]=u):u=t[32],u}let w,T;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(w=W(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),T=(0,$.jsx)(b,{className:`h-4 w-4 shrink-0 text-destructive`}),t[33]=w,t[34]=T):(w=t[33],T=t[34]);let E=r||`Browser JS Execution Failed`,D;t[35]===E?D=t[36]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),t[35]=E,t[36]=D);let O;t[37]===y?O=t[38]:(O=y?(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),t[37]=y,t[38]=O);let k;t[39]!==D||t[40]!==O?(k=(0,$.jsxs)(`button`,{onClick:C,className:w,children:[T,D,O]}),t[39]=D,t[40]=O,t[41]=k):k=t[41];let A;t[42]!==i||t[43]!==p||t[44]!==y?(A=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:W(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:p}),(0,$.jsx)(`pre`,{className:W(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i})]}),t[42]=i,t[43]=p,t[44]=y,t[45]=A):A=t[45];let M;return t[46]!==k||t[47]!==A?(M=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),t[46]=k,t[47]=A,t[48]=M):M=t[48],M}function Xo(e){return!e}function Zo(e){return e.selectedThreadId}function Qo(e){let t=(0,X.c)(29),{src:n}=e,[i,a]=(0,Y.useState)(!1),o;t[0]===n?o=t[1]:(o=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await fn(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});wi({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=n,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=async()=>{await T(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:n}),a(!0),setTimeout(()=>a(!1),2e3)},t[2]=n,t[3]=c);let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={maxHeight:`512px`},t[4]=u):u=t[4];let d;t[5]===n?d=t[6]:(d=(0,$.jsx)(`img`,{src:n,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:u}),t[5]=n,t[6]=d);let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(z,{className:`h-3.5 w-3.5`}),t[7]=f):f=t[7];let p;t[8]===s?p=t[9]:(p=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:f})}),t[8]=s,t[9]=p);let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(U,{children:`Save image`}),t[10]=m):m=t[10];let h;t[11]===p?h=t[12]:(h=(0,$.jsxs)(K,{children:[p,m]}),t[11]=p,t[12]=h);let g;t[13]===i?g=t[14]:(g=i?(0,$.jsx)(Vt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=g);let _;t[15]!==l||t[16]!==g?(_=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:g})}),t[15]=l,t[16]=g,t[17]=_):_=t[17];let v=i?`Copied!`:`Copy to clipboard`,y;t[18]===v?y=t[19]:(y=(0,$.jsx)(U,{children:v}),t[18]=v,t[19]=y);let b;t[20]!==_||t[21]!==y?(b=(0,$.jsxs)(K,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(r,{children:[h,b]})}),t[23]=b,t[24]=h,t[25]=x):x=t[25];let S;return t[26]!==x||t[27]!==d?(S=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[d,x]}),t[26]=x,t[27]=d,t[28]=S):S=t[28],S}function $o(e){if(typeof e.executionOutput==`string`)return e.executionOutput;let t=e.partial?.content?.[0]?.arguments;if(!(!t||typeof t!=`object`)&&`content`in t&&typeof t.content==`string`)return t.content}function es(e,t){let n=e.find(e=>e.type===`tool-result`&&e.toolCallId===t);if(!n)return;let r=n,i=r.result??r.content;if(i!=null)return typeof i==`string`?i:JSON.stringify(i,null,2)}function ts(e,t){return e.some(e=>e.type===`tool-result`&&e.toolCallId===t)}function ns(e,t){if(t)return es(e,t)}function rs(e,t,n){return(0,$.jsx)(Do,{toolCallId:e.toolCallId??`long-running-confirmation`,question:e.question,options:e.options,context:e.context,answeredText:n,answeredLabel:`You answered`},t)}function is(e,t,n){return(0,$.jsx)(Bo,{toolCallId:e.toolCallId,command:e.command,projectId:n,wildcardOptions:e.wildcardOptions},t)}function as(e,t,n){return(0,$.jsx)(Vo,{toolCallId:e.toolCallId,hostname:e.hostname,url:e.url,projectId:n,wildcardOptions:e.wildcardOptions},t)}function os(e,t,n,r,i){if(e.name===`ask_user`)return(0,$.jsx)(Do,{toolCallId:e.id,question:typeof e.input?.question==`string`?e.input.question:``,options:e.input?.options,context:e.input?.context,answeredText:r},t);if(e.name===`run_js`||e.name===`run_web_worker`)return(0,$.jsx)(Yo,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t);let a=n===!0&&r===void 0;return a&&e.name!==`bash`&&e.name!==`read`&&e.name!==`file_read`?(0,$.jsx)(So,{toolCall:e},t):(0,$.jsx)(co,{inline:!0,block:e,resultContent:a?i:r,isActive:a},t)}function ss({message:e,threadId:t,messageIndex:n=0,showCheckpointRestore:i=!1,checkpointRestoreTooltip:a}){let o=e.sender===`user`,s=o?null:Hr(e.content),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),f=o&&(i||!!a),p=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function m(){if(!(!e.checkpointRef||!t||c)){l(!0);try{let n=await pt(t,e.checkpointRef);n.success?wi({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):wi({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){wi({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{l(!1)}}}async function h(){try{await navigator.clipboard.writeText(e.content),d(!0),setTimeout(()=>d(!1),2e3)}catch(e){wi({title:`Copy failed`,description:e instanceof Error?e.message:`Could not copy prompt.`,variant:`destructive`})}}return(0,$.jsx)(`div`,{className:W(`group px-4 py-4`,o&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:W(`flex flex-col gap-1 min-w-0 max-w-full`,o&&`items-end`),children:[(0,$.jsxs)(`div`,{className:W(`flex items-center gap-2`,o&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:W(J.compact,`font-medium text-foreground`),children:o?`You`:`Agent`}),o&&(0,$.jsx)(r,{children:(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:h,"aria-label":u?`Prompt copied`:`Copy prompt`,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-muted`,children:u?(0,$.jsx)(Vt,{className:`h-3 w-3 text-green-500`}):(0,$.jsx)(F,{className:`h-3 w-3`})})})}),(0,$.jsx)(U,{side:`left`,children:u?`Copied prompt`:`Copy prompt`})]}),f&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:i?m:void 0,disabled:!i||c,"aria-label":a??`Restore checkpoint`,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-muted disabled:opacity-50 disabled:hover:text-muted-foreground disabled:hover:bg-transparent`,children:(0,$.jsx)(M,{className:W(`h-3 w-3`,c&&`animate-spin`)})})})}),(0,$.jsx)(U,{side:`left`,children:a??`Restore checkpoint`})]})]})}),p&&(0,$.jsxs)(`span`,{className:W(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(pe,{className:`h-2.5 w-2.5`}),p]}),e.model&&(0,$.jsxs)(`span`,{className:W(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(b,{className:`h-2.5 w-2.5`}),or(e.model)]}),e.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:W(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(xt,{className:`h-2.5 w-2.5`}),e.metadata.processingTimeMs>=6e4?`${Math.floor(e.metadata.processingTimeMs/6e4)}m ${Math.round(e.metadata.processingTimeMs%6e4/1e3)}s`:`${Math.round(e.metadata.processingTimeMs/1e3)}s`]}),(e.metadata?.tokenCount||e.metadata?.estimatedCost)&&(0,$.jsxs)(`span`,{className:W(J.compact,`text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[e.metadata.tokenCount?`${e.metadata.tokenCount.toLocaleString()} tokens`:null,e.metadata.tokenCount&&e.metadata.estimatedCost?` · `:null,e.metadata.estimatedCost?Lt(e.metadata.estimatedCost):null]})]}),(0,$.jsx)(`div`,{className:W(`flex flex-col gap-0.5 min-w-0 text-base`,o&&`rounded-xl px-4 py-3 bg-foreground text-background`),children:e.isThinking?(()=>{let t=zr(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:Yr(t,!1).map((e,n)=>{if(e.type===`thinking-group`){let t=e;return(0,$.jsx)(xo,{text:t.text,label:t.label,isStreaming:!1},`tg-${n}`)}let r=e;if(r.type===`tool_use`)return os(r,n,!1,es(t,r.id));if(r.type===`long_running_confirmation`){let e=r.prompt;return rs(e,n,ns(t,e.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return is(e,n)}if(r.type===`web_fetch_permission`){let e=r.prompt;return as(e,n)}return r.type===`tool-result`?(0,$.jsx)(_o,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:W(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:(0,$.jsx)(Xi,{content:Rr(e.content),enableMermaid:!0})})})():s?(0,$.jsx)($.Fragment,{children:Yr(s,!1).map((e,t)=>{if(e.type===`thinking-group`){let n=e;return(0,$.jsx)(xo,{text:n.text,label:n.label,isStreaming:!1},`tg-${t}`)}let r=e;if(r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`)return r.type===`tool-result`?(0,$.jsx)(_o,{inline:!0,sequence:n,block:r},t):null;if(r.type===`tool-result`&&r.toolName===`ask_user`)return null;if(r.type===`long_running_confirmation`){let e=r.prompt;return rs(e,t,ns(s,e.toolCallId))}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(Xi,{content:Rr(r.text),enableMermaid:!0}):r.type===`tool_use`?os(r,void 0,!1,es(s,r.id)):r.type===`tool-result`?(0,$.jsx)(_o,{inline:!0,block:r}):null},t)})}):(0,$.jsx)(Xi,{content:Rr(e.content),enableMermaid:!0,className:J.body})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Qo,{src:e.generatedImageData?`data:image/png;base64,${e.generatedImageData}`:e.generatedImageUrl}),e.attachments&&e.attachments.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((e,t)=>(0,$.jsxs)(`span`,{className:W(J.compact,`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-muted-foreground`),children:[(0,$.jsx)(ue,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}function cs(e){let t=(0,X.c)(26),{segments:n,model:r,projectId:i,isCreatingProject:a,isProcessingThread:o,totalMessages:s,showProcessingLine:c}=e,l=s===void 0?0:s,u=c===void 0?!1:c,d=Q(ls),f,p,m,h;if(t[0]!==a||t[1]!==o||t[2]!==r||t[3]!==i||t[4]!==n||t[5]!==u||t[6]!==d||t[7]!==l){let e=Jr(n),s=u?`pb-0`:`pb-4`;t[12]===s?h=t[13]:(h=W(`group px-4 pt-4`,s),t[12]=s,t[13]=h),f=`flex flex-col gap-1 min-w-0`;let c;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:W(J.compact,`font-medium text-foreground`),children:`Agent`}),t[14]=c):c=t[14];let g;t[15]===r?g=t[16]:(g=r&&(0,$.jsxs)(`span`,{className:W(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(b,{className:`h-2.5 w-2.5`}),or(r)]}),t[15]=r,t[16]=g),t[17]===g?p=t[18]:(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,g]}),t[17]=g,t[18]=p),m=e.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-base`,children:Yr(e,!0).map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(xo,{text:e.text,label:e.label,isStreaming:e.isCurrentlyStreaming},`tg-${n}`)}let r=t;if(r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`)return r.type===`tool-result`?(0,$.jsx)(_o,{inline:!0,sequence:l,block:r},`b-${n}`):null;if(r.type===`tool-result`&&r.toolName===`ask_user`)return null;if(r.type===`long_running_confirmation`){let t=r.prompt;return rs(t,`stream-${n}`,ns(e,t.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return is(e,`stream-${n}`,i)}if(r.type===`web_fetch_permission`){let e=r.prompt;return as(e,`stream-${n}`,i)}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(Xi,{content:Rr(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=r.id,n=es(e,t),i=$o(d[t]??{});return os(r,void 0,!ts(e,t),n,i)})():r.type===`tool-result`?(0,$.jsx)(_o,{inline:!0,block:r}):null},`b-${n}`)})}):a||o?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(xo,{isStreaming:!0})}):null,t[0]=a,t[1]=o,t[2]=r,t[3]=i,t[4]=n,t[5]=u,t[6]=d,t[7]=l,t[8]=f,t[9]=p,t[10]=m,t[11]=h}else f=t[8],p=t[9],m=t[10],h=t[11];let g;t[19]!==f||t[20]!==p||t[21]!==m?(g=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[19]=f,t[20]=p,t[21]=m,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g?(_=(0,$.jsx)(`div`,{className:h,children:g}),t[23]=h,t[24]=g,t[25]=_):_=t[25],_}function ls(e){return e.toolCallProgress}var us=(0,Y.memo)(cs,(e,t)=>{if(e.model!==t.model||e.isCreatingProject!==t.isCreatingProject||e.isProcessingThread!==t.isProcessingThread||e.showProcessingLine!==t.showProcessingLine||e.totalMessages!==t.totalMessages||e.segments.length!==t.segments.length)return!1;for(let n=0;n<e.segments.length;n++){let r=e.segments[n],i=t.segments[n];if(r.type!==i.type)return!1;if(r.type===`long_running_confirmation`){if(i.type!==`long_running_confirmation`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(r.type===`shell_permission`){if(i.type!==`shell_permission`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(r.type===`web_fetch_permission`){if(i.type!==`web_fetch_permission`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(i.type===`long_running_confirmation`||i.type===`shell_permission`||i.type===`web_fetch_permission`||r.chunks.length!==i.chunks.length)return!1;for(let e=0;e<r.chunks.length;e++)if(r.chunks[e]!==i.chunks[e])return!1}return!0}),ds=3e3;function fs(e){let t=[...it],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function ps(e){let t=(0,X.c)(3),[n,r]=(0,Y.useState)(Qe),i=(0,Y.useRef)(Qe),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(Qe),i.current=Qe;return}let t=setInterval(()=>{let e=i.current===`Processing...`?fs():fs(i.current);i.current=e,r(e)},ds);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Y.useEffect)(a,o),n}var ms=`w-7`,hs=`-ml-9`;function gs(e){let t=(0,X.c)(11),{active:n,className:r}=e,i=n===void 0?!0:n,a=ps(i),o;t[0]===r?o=t[1]:(o=W(`flex items-center gap-2`,hs,r),t[0]=r,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Wa,{className:ms}),t[2]=s):s=t[2];let c=i?`animate-shimmer`:void 0,l;t[3]===c?l=t[4]:(l=W(J.caption,c),t[3]=c,t[4]=l);let u;t[5]!==a||t[6]!==l?(u=(0,$.jsx)(`span`,{className:l,children:a}),t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==u?(d=(0,$.jsxs)(`div`,{className:o,"aria-live":`polite`,"aria-busy":`true`,children:[s,u]}),t[8]=o,t[9]=u,t[10]=d):d=t[10],d}function _s(e){let t=(0,X.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`h1`,{className:W(J.pageTitle,`tracking-tight text-balance`),children:`Let's build it!`}),t[1]=l):l=t[1];let u=n.length===0?`Start or connect your first project`:`Select a project to start coding`,d;t[2]===u?d=t[3]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[l,(0,$.jsx)(`p`,{className:`mt-1 ${J.pageSubtitle}`,children:u})]})]}),t[2]=u,t[3]=d);let f;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(ye,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:J.caption,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[8]=i,t[9]=r,t[10]=e):e=t[10],f=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=f}else f=t[7];let p,m,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ge,{className:`h-5 w-5 text-muted-foreground`}),m=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`Connect a repo`}),h=(0,$.jsx)(`span`,{className:J.caption,children:`Clone an existing repository`}),t[11]=p,t[12]=m,t[13]=h):(p=t[11],m=t[12],h=t[13]);let g;t[14]===a?g=t[15]:(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:a,children:[p,m,h]}),t[14]=a,t[15]=g);let _,v,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ze,{className:`h-5 w-5 text-muted-foreground`}),v=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`New App`}),y=(0,$.jsx)(`span`,{className:J.caption,children:`Create a new project from template`}),t[16]=_,t[17]=v,t[18]=y):(_=t[16],v=t[17],y=t[18]);let b;t[19]===o?b=t[20]:(b=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[_,v,y]}),t[19]=o,t[20]=b);let x,S,C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(sn,{className:`h-5 w-5 text-muted-foreground`}),S=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`Open Folder`}),C=(0,$.jsx)(`span`,{className:J.caption,children:`Use an existing local folder`}),t[21]=x,t[22]=S,t[23]=C):(x=t[21],S=t[22],C=t[23]);let w;t[24]===s?w=t[25]:(w=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[x,S,C]}),t[24]=s,t[25]=w);let T;t[26]!==b||t[27]!==w||t[28]!==f||t[29]!==g?(T=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[f,g,b,w]}),t[26]=b,t[27]=w,t[28]=f,t[29]=g,t[30]=T):T=t[30];let E;return t[31]!==T||t[32]!==d?(E=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[d,T]}),t[31]=T,t[32]=d,t[33]=E):E=t[33],E}function vs(){let e=Q(e=>e.selectedThreadId),{dispatch:t}=li(e),{setActiveMainTab:n,setDevServerUrl:r,setDevServerRunning:i,setDevServerLoading:a}=ca();return{startServer:async o=>{if(!o?.runCommand||!o?.projectId)return;a(!0),t({type:Z.ClearTerminalOutput}),t({type:Z.SetTerminalOpen,open:!1}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Starting dev server: ${o.runCommand}`}});let s=!1,c=setTimeout(()=>{s=!0,t({type:Z.SetTerminalOpen,open:!0})},3e3);try{let l=await v(o.projectId,e??void 0);if(!l){clearTimeout(c),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to start dev server`}}),a(!1);return}let u=l.getReader(),d=new TextDecoder;i(!0),a(!1);let f=!1,p=!1;for(;;){let{done:e,value:i}=await u.read();if(e)break;let o=d.decode(i,{stream:!0});try{let e=o.split(`
|
|
25
|
+
`).filter(e=>e.trim());for(let i of e)try{let e=JSON.parse(i);p||(p=!0,a(!1)),e.type===`url`&&e.url&&(clearTimeout(c),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`✓ Server running at: ${e.url}`}}),r(e.url),n(`browser`),s&&setTimeout(()=>{t({type:Z.SetTerminalOpen,open:!1})},100),f=!0)}catch{}}catch{}}f||t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Server is running but URL could not be detected`}})}catch(e){console.error(`Failed to start dev server:`,e),a(!1),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to start dev server`}})}},setServerUrl:r}}function ys(e){let t=[`What would you like to add to ${e}?`,`What should we build in ${e}?`,`What changes do you want to make to ${e}?`,`What feature should we add to ${e}?`,`What would you like to fix in ${e}?`,`What are we working on in ${e}?`,`What's next for ${e}?`,`What should we improve in ${e}?`,`How can we make ${e} better?`,`What would you like to change in ${e}?`,`What should we ship in ${e} next?`];return t[Math.floor(Math.random()*t.length)]}function bs(e){let t=(0,X.c)(26),{project:n}=e,{setDevServerRunning:r}=ca(),[i,a]=(0,Y.useState)(!1),{startServer:o}=vs(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Xe(n.projectId);a(e.isRunning),r(e.isRunning)}catch{a(!1),r(!1)}};e();let t=setInterval(e,2e3);return()=>clearInterval(t)},t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=n?.projectId,l;t[3]===c?l=t[4]:(l=[c],t[3]=c,t[4]=l),(0,Y.useEffect)(s,l),n?.name;let u=n?.name??`your project`,d;t[5]===u?d=t[6]:(d=ys(u),t[5]=u,t[6]=d);let f=d,p=!i&&n?.runCommand,m;t[7]!==n||t[8]!==o?(m=()=>{n&&o(n)},t[7]=n,t[8]=o,t[9]=m):m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=W(J.pageTitle,`tracking-tight text-foreground text-balance`),t[11]=_):_=t[11];let v=n?.name??`Project`,y;t[12]===v?y=t[13]:(y=(0,$.jsx)(`h1`,{className:_,children:v}),t[12]=v,t[13]=y);let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=W(J.pageSubtitle,`mt-2`),t[14]=b):b=t[14];let x;t[15]===f?x=t[16]:(x=(0,$.jsx)(`p`,{className:b,children:f}),t[15]=f,t[16]=x);let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`text-center`,children:[y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==h||t[21]!==p?(C=p&&(0,$.jsx)(`button`,{type:`button`,onClick:h,className:W(J.label,`inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90 transition-colors`),children:`Start App`}),t[20]=h,t[21]=p,t[22]=C):C=t[22];let w;return t[23]!==S||t[24]!==C?(w=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6 px-4`,children:[g,S,C]})}),t[23]=S,t[24]=C,t[25]=w):w=t[25],w}var xs=(0,Y.forwardRef)((e,t)=>{let n=(0,X.c)(9),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({style:a,children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;return n[4]!==r||n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(`div`,{ref:t,style:a,...i,className:`mx-auto max-w-3xl w-full min-w-0`,children:r}),n[4]=r,n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xs.displayName=`MessageList`;function Ss(e){let t=(0,X.c)(20),{context:n}=e;if(!n)return null;let{isStreaming:r,isCreatingProject:i,isProcessingThread:a,hasPendingMessage:o,hasActiveBlockingPrompt:s,selectedProjectId:c,streamingSegments:l,streamingModel:u,totalMessages:d,error:f,onClearError:p}=n,m=l.length>0||i||a&&(r||o),h=(r||o)&&!s,g;t[0]!==m||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==c||t[5]!==h||t[6]!==u||t[7]!==l||t[8]!==d?(g=m&&(r||i||a)&&(0,$.jsx)(us,{segments:l,model:u,projectId:c,isCreatingProject:i,isProcessingThread:a,totalMessages:d,showProcessingLine:h}),t[0]=m,t[1]=i,t[2]=a,t[3]=r,t[4]=c,t[5]=h,t[6]=u,t[7]=l,t[8]=d,t[9]=g):g=t[9];let _;t[10]!==m||t[11]!==h?(_=h&&(0,$.jsx)(`div`,{className:W(`px-4 pb-4`,m?`pt-0`:`pt-2`),children:(0,$.jsx)(gs,{active:h})}),t[10]=m,t[11]=h,t[12]=_):_=t[12];let v;t[13]!==f||t[14]!==p?(v=f&&(0,$.jsxs)(`div`,{className:`mx-4 my-2`,children:[(0,$.jsx)(Sr,{variant:`error`,className:`mb-0`,children:f}),(0,$.jsx)(`button`,{type:`button`,className:W(J.compact,`mt-1 text-destructive underline underline-offset-2 hover:text-destructive/80`),onClick:p,children:`Dismiss`})]}),t[13]=f,t[14]=p,t[15]=v):v=t[15];let y;return t[16]!==g||t[17]!==_||t[18]!==v?(y=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-48`,children:[g,_,v]}),t[16]=g,t[17]=_,t[18]=v,t[19]=y):y=t[19],y}var Cs={List:xs,Footer:Ss};function ws(e){if(e.isUser)return e.hasCheckpointRef?e.isStreaming||e.hasPendingMessage||e.isCreatingProject||e.isProcessingThread?`Restore unavailable while this thread is still processing.`:`Restore checkpoint`:`Restore unavailable: no checkpoint was created for this prompt.`}function Ts(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`long_running_confirmation`||n.type===`shell_permission`||n.type===`web_fetch_permission`)return t}return-1}function Es(e){let t=e.some(e=>e.type!==`long_running_confirmation`&&e.type!==`shell_permission`&&e.type!==`web_fetch_permission`&&`chunks`in e&&e.chunks.some(e=>e.includes(`"type":"tool_use"`)&&e.includes(`"name":"ask_user"`))),n=e.some(e=>e.type!==`long_running_confirmation`&&e.type!==`shell_permission`&&e.type!==`web_fetch_permission`&&`chunks`in e&&e.chunks.some(e=>e.includes(`"type":"tool-result"`)&&e.includes(`"toolName":"ask_user"`)));if(t&&!n)return!0;let r=Ts(e);return r===-1?!1:!e.slice(r+1).some(e=>e.type===`content`||e.type===`thinking`?e.chunks.some(e=>e.trim().length>0):!1)}function Ds(e){let t=(0,X.c)(68),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:c,selectedThreadId:l,selectedProjectId:u,projects:d,projectsLoading:f,messagesLoaded:p,onSelectThread:m,onCreateThread:h,onConnectRepo:g,onNewApp:_,onOpenFolder:v,error:y,onClearError:b}=e,x=(0,Y.useRef)(null),S=(0,Y.useRef)(0),C=(0,Y.useRef)(!1),w=(0,Y.useRef)(!1),T;t[0]===l?T=t[1]:(T=()=>{l&&x.current?.getState(e=>{on(l,e.scrollTop)})},t[0]=l,t[1]=T);let E=T,D,O;t[2]===E?(D=t[3],O=t[4]):(D=()=>{let e=()=>{E()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),E()}},O=[E],t[2]=E,t[3]=D,t[4]=O),(0,Y.useEffect)(D,O);let k,A;t[5]===E?(k=t[6],A=t[7]):(k=()=>{let e=setInterval(()=>{E()},5e3);return()=>clearInterval(e)},A=[E],t[5]=E,t[6]=k,t[7]=A),(0,Y.useEffect)(k,A);let j,M;t[8]!==n.length||t[9]!==p||t[10]!==l?(j=()=>{if(!l||!p||w.current||(w.current=!0,n.length===0))return;let e=st(l);e!==null&&e>0&&requestAnimationFrame(()=>{x.current?.scrollTo({top:e})})},M=[l,p,n.length],t[8]=n.length,t[9]=p,t[10]=l,t[11]=j,t[12]=M):(j=t[11],M=t[12]),(0,Y.useEffect)(j,M);let N;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{w.current=!1,S.current=0},t[13]=N):N=t[13];let P;t[14]===l?P=t[15]:(P=[l],t[14]=l,t[15]=P),(0,Y.useEffect)(N,P);let F;t[16]!==c||t[17]!==r||t[18]!==n.length?(F=()=>{if(!w.current)return;let e=n.length>S.current,t=C.current&&!r;(r||c||e||t)&&requestAnimationFrame(()=>{x.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),S.current=n.length,C.current=r},t[16]=c,t[17]=r,t[18]=n.length,t[19]=F):F=t[19];let I;t[20]!==c||t[21]!==r||t[22]!==n||t[23]!==i.length?(I=[r,c,n,i.length],t[20]=c,t[21]=r,t[22]=n,t[23]=i.length,t[24]=I):I=t[24],(0,Y.useEffect)(F,I);let L=n.length===0&&!r&&!o&&!l,R=p&&n.length===0&&!r&&!o&&!s&&!c&&l,ee;if(t[25]!==d||t[26]!==u){let e;t[28]===u?e=t[29]:(e=e=>e.projectId===u,t[28]=u,t[29]=e),ee=d.find(e),t[25]=d,t[26]=u,t[27]=ee}else ee=t[27];let z=ee;if(L){let e=`transition-opacity duration-500 ease-in-out ${f?`opacity-0`:`opacity-100`}`,n;t[30]!==g||t[31]!==h||t[32]!==_||t[33]!==v||t[34]!==m||t[35]!==d?(n=(0,$.jsx)(_s,{projects:d,onSelectProject:m,onCreateThread:h,onConnectRepo:g,onNewApp:_,onOpenFolder:v}),t[30]=g,t[31]=h,t[32]=_,t[33]=v,t[34]=m,t[35]=d,t[36]=n):n=t[36];let r;return t[37]!==e||t[38]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[37]=e,t[38]=n,t[39]=r):r=t[39],r}if(R){let e;return t[40]===z?e=t[41]:(e=(0,$.jsx)(bs,{project:z}),t[40]=z,t[41]=e),e}let B;t[42]===i?B=t[43]:(B=Es(i),t[42]=i,t[43]=B);let V;t[44]!==y||t[45]!==c||t[46]!==o||t[47]!==s||t[48]!==r||t[49]!==n.length||t[50]!==b||t[51]!==u||t[52]!==a||t[53]!==i||t[54]!==B?(V={isStreaming:r,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:c,hasActiveBlockingPrompt:B,selectedProjectId:u,streamingSegments:i,streamingModel:a,totalMessages:n.length,error:y,onClearError:b},t[44]=y,t[45]=c,t[46]=o,t[47]=s,t[48]=r,t[49]=n.length,t[50]=b,t[51]=u,t[52]=a,t[53]=i,t[54]=B,t[55]=V):V=t[55];let te=V,ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ne=W(`h-full overflow-hidden`),t[56]=ne):ne=t[56];let re;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(re={height:`100%`},t[57]=re):re=t[57];let H;t[58]!==c||t[59]!==o||t[60]!==s||t[61]!==r||t[62]!==l?(H=(e,t)=>{let n=ws({isUser:t.sender===`user`,hasCheckpointRef:!!t.checkpointRef,isStreaming:r,hasPendingMessage:c,isCreatingProject:o,isProcessingThread:s});return(0,$.jsx)(ss,{message:t,threadId:l,messageIndex:e,showCheckpointRestore:t.sender===`user`&&!!t.checkpointRef&&!r&&!c&&!o&&!s,checkpointRestoreTooltip:n})},t[58]=c,t[59]=o,t[60]=s,t[61]=r,t[62]=l,t[63]=H):H=t[63];let ie;return t[64]!==te||t[65]!==n||t[66]!==H?(ie=(0,$.jsx)(`div`,{className:ne,children:(0,$.jsx)(Qn,{ref:x,style:re,data:n,context:te,itemContent:H,overscan:500,components:Cs})}),t[64]=te,t[65]=n,t[66]=H,t[67]=ie):ie=t[67],ie}function Os({initialValue:e}={}){let t=si(),n=Q(e=>e.selectedThreadId),r=Q(e=>e.selectedProjectId),i=Q(e=>e.projects),a=Q(e=>e.projectModelSelections),o=Q(e=>e.chatInputDrafts),s=Q(e=>e.configUpdatedAt),c=Q(e=>e.focusChatInput),l=Q(e=>e.isStreaming),[u,d]=(0,Y.useState)(()=>n&&o[n]?o[n]:e??``),[f,p]=(0,Y.useState)(-1),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(0),v=(0,Y.useRef)(u);(0,Y.useEffect)(()=>{v.current=u},[u]);let y=(0,Y.useRef)(o);(0,Y.useEffect)(()=>{y.current=o},[o]);let b=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]);let[x,S]=(0,Y.useState)([]),[C,T]=(0,Y.useState)(()=>(n?a[n]:void 0)??null),E=(0,Y.useRef)(C?.id??``),D=(0,Y.useRef)(C?.provider??``),O=(0,Y.useRef)(null),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)([]),[F,I]=(0,Y.useState)(!1),[L,R]=(0,Y.useState)(!1),[z,B]=(0,Y.useState)(!1),[V,te]=(0,Y.useState)([]),[ne,re]=(0,Y.useState)(null),[H,ie]=(0,Y.useState)([]),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(``),[le,ue]=(0,Y.useState)(0),[U,W]=(0,Y.useState)([]),[de,fe]=(0,Y.useState)([]),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)(``),_e=(0,Y.useRef)(null),ve=(0,Y.useRef)(null),ye=(0,Y.useRef)(null),be=(0,Y.useRef)(null),xe=(0,Y.useRef)(null),Se=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{E.current=C?.id??``,D.current=C?.provider??``},[C?.id,C?.provider]);let Ce=(0,Y.useCallback)((e,r)=>{T(e);let i=n;if(!i||(t({type:Z.SetProjectModel,threadId:i,model:e}),r?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;O.current!==a&&(O.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),w(i,{model:e.id,modelProvider:e.provider}).then(()=>{O.current===a&&(O.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{O.current===a&&(O.current=null),console.error(`Failed to save model to thread:`,e)}))},[n,t]);(0,Y.useEffect)(()=>{(async()=>{let e=r?i.find(e=>e.projectId===r)?.threads.find(e=>e.threadId===n):void 0,t=n?a[n]:void 0,o=e?.model??t?.id??null,s=e?.modelProvider??t?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n,projectId:r,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:t?{id:t.id,provider:t.provider}:void 0,savedModelId:o,savedModelProvider:s});try{let e=await kt(),t=Object.values(e).flat();if(t.length===0){S([]),T(null);return}S(t);let n=o&&s?t.find(e=>e.id===o&&e.provider===s)??null:null,r=t[0],i=n??r,a=!n&&!!(o||s),c=E.current===i.id&&D.current===i.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:r.id},modelToSelect:{id:i.id},shouldPersistFallback:a,hasSameSelection:c,currentSelected:{id:E.current,provider:D.current}}),c||Ce(i,{persist:a})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n,r,i,a,Ce]);let we=(0,Y.useRef)(Ce);(0,Y.useEffect)(()=>{we.current=Ce},[Ce]),(0,Y.useEffect)(()=>{s!==0&&(async()=>{try{let e=await kt(),t=Object.values(e).flat();if(t.length>0){S(t);let e=E.current,n=D.current;t.some(t=>t.id===e&&t.provider===n)||we.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[s]),(0,Y.useEffect)(()=>{!z||V.length>0||(async()=>{try{let e=await zt(),t=Object.values(e).flat();t.length>0&&(te(t),re(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[z,V.length]);let[Te,De]=(0,Y.useState)(n);(0,Y.useEffect)(()=>{if(n!==Te){Te&&v.current.trim()&&y.current[Te]!==v.current&&t({type:Z.SetChatInputDraft,threadId:Te,draft:v.current});let e=!1;return queueMicrotask(()=>{e||!b.current||(De(n),d(n?y.current[n]??``:``),ie([]),oe(!1),W([]),fe([]),me(!1),I(!1),B(!1),R(!1))}),()=>{e=!0}}},[n,Te]),(0,Y.useEffect)(()=>{n&&Ee(n).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),W(e),fe(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n]);let Oe=n?o[n]??``:``;return(0,Y.useEffect)(()=>{n&&d(Oe)},[n,Oe]),(0,Y.useLayoutEffect)(()=>{let e=ve.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[u]),(0,Y.useEffect)(()=>{c&&n&&!l&&(ve.current?.focus(),t({type:Z.ClearFocusChatInput}))},[c,n,l,t]),(0,Y.useEffect)(()=>{let e=n;return()=>{e&&v.current.trim()&&y.current[e]!==v.current&&t({type:Z.SetChatInputDraft,threadId:e,draft:v.current})}},[n,t]),(0,Y.useEffect)(()=>{let e=e=>{ye.current&&!ye.current.contains(e.target)&&A(!1),be.current&&!be.current.contains(e.target)&&M(!1)};if(k||j)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[k,j]),{message:u,setMessage:d,historyIndex:f,setHistoryIndex:p,draftMessage:m,setDraftMessage:h,cursorPosition:g,setCursorPosition:_,availableModels:x,setAvailableModels:S,selectedModel:C,setSelectedModel:Ce,selectedModelIdRef:E,showModelMenu:k,setShowModelMenu:A,showPlusMenu:j,setShowPlusMenu:M,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:B,availableImageModels:V,setAvailableImageModels:te,selectedImageModel:ne,setSelectedImageModel:re,allFiles:H,setAllFiles:ie,showSuggestions:ae,setShowSuggestions:oe,suggestionQuery:se,setSuggestionQuery:ce,selectedIndex:le,setSelectedIndex:ue,slashCommands:U,setSlashCommands:W,skills:de,setSkills:fe,showCommandSuggestions:pe,setShowCommandSuggestions:me,commandQuery:he,setCommandQuery:ge,fileInputRef:_e,textareaRef:ve,modelMenuRef:ye,plusMenuRef:be,suggestionsRef:xe,commandSuggestionsRef:Se,handleNewChat:async()=>{if(n)try{let e=await ee(n);t({type:Z.ClearMessages}),console.log(`New conversation started:`,e);let r=await dt(n);t({type:Z.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},selectedThreadId:n,dispatch:t}}var ks=e=>{Ct(e)};function As(e){let t=(0,X.c)(107),{message:n,setMessage:r,userTasks:i,onMatchedUserTaskSend:a,attachments:o,selectedModel:s,onSend:c,isStreaming:l,selectedThreadId:u,isListening:d,stopListening:f,resetTranscript:p,dispatch:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:x,setShowSuggestions:S,suggestionQuery:C,setSuggestionQuery:w,allFiles:T,setAllFiles:E,selectedIndex:D,setSelectedIndex:O,showCommandSuggestions:k,setShowCommandSuggestions:A,commandQuery:j,setCommandQuery:M,slashCommands:N,skills:P,textareaRef:F,setAttachments:I,planMode:L,setPlanMode:R,ralphMode:ee,setRalphMode:z,imageMode:B,setImageMode:V,selectedImageModel:te,hasConversationMessages:ne}=e,re;t[0]!==o||t[1]!==m||t[2]!==B||t[3]!==d||t[4]!==l||t[5]!==n||t[6]!==a||t[7]!==c||t[8]!==L||t[9]!==ee||t[10]!==p||t[11]!==te||t[12]!==s||t[13]!==u||t[14]!==I||t[15]!==v||t[16]!==g||t[17]!==r||t[18]!==f||t[19]!==F||t[20]!==i?(re=()=>{if(!n.trim()&&o.length===0||!u)return;let e=B?te:s;if(!e)return;d&&(f(),p()),l?m({type:Z.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:u,message:n,model:e.id,attachments:o,provider:e.provider,planMode:L,imageMode:B,ralphMode:ee}}):c(n,e.id,o,e.provider,L,B,ee);let t=n,h=i.find(e=>e.content===t);ks(n),r(``),I([]),h&&a?.(h),g(-1),v(``),u&&m({type:Z.ClearChatInputDraft,threadId:u}),F.current&&(F.current.style.height=`auto`)},t[0]=o,t[1]=m,t[2]=B,t[3]=d,t[4]=l,t[5]=n,t[6]=a,t[7]=c,t[8]=L,t[9]=ee,t[10]=p,t[11]=te,t[12]=s,t[13]=u,t[14]=I,t[15]=v,t[16]=g,t[17]=r,t[18]=f,t[19]=F,t[20]=i,t[21]=re):re=t[21];let H=re,ie;t[22]!==y||t[23]!==n||t[24]!==r||t[25]!==S||t[26]!==C||t[27]!==F?(ie=e=>{let t=n.substring(0,y-C.length-1);r(`${t}${e} ${n.substring(y)}`),S(!1),setTimeout(()=>{if(F.current){F.current.focus();let n=t.length+e.length+1;F.current.setSelectionRange(n,n)}},0)},t[22]=y,t[23]=n,t[24]=r,t[25]=S,t[26]=C,t[27]=F,t[28]=ie):ie=t[28];let ae=ie,oe;t[29]!==j||t[30]!==y||t[31]!==n||t[32]!==V||t[33]!==r||t[34]!==R||t[35]!==z||t[36]!==A||t[37]!==F?(oe=e=>{let t=e.metadata.action===`compact`?`/compact`:e.content,i=n.substring(0,y-j.length-1);r(`${i}${t}${n.substring(y)}`),A(!1),setTimeout(()=>{if(F.current){F.current.focus();let e=i.length+t.length;F.current.setSelectionRange(e,e)}},0),e.metadata.mode===`plan`?(R(!0),z(!1),V(!1)):e.metadata.mode===`ralph`&&(z(!0),R(!1),V(!1))},t[29]=j,t[30]=y,t[31]=n,t[32]=V,t[33]=r,t[34]=R,t[35]=z,t[36]=A,t[37]=F,t[38]=oe):oe=t[38];let se=oe,ce;t[39]!==j||t[40]!==y||t[41]!==n||t[42]!==r||t[43]!==A||t[44]!==F?(ce=e=>{let t=n.substring(0,y-j.length-1),i=n.substring(y),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),A(!1),setTimeout(()=>{if(F.current){F.current.focus();let e=t.length+a.length;F.current.setSelectionRange(e,e)}},0)},t[39]=j,t[40]=y,t[41]=n,t[42]=r,t[43]=A,t[44]=F,t[45]=ce):ce=t[45];let le=ce,ue,U,W,de;if(t[46]!==T||t[47]!==j||t[48]!==_||t[49]!==H||t[50]!==ne||t[51]!==h||t[52]!==se||t[53]!==ae||t[54]!==le||t[55]!==n||t[56]!==D||t[57]!==u||t[58]!==E||t[59]!==M||t[60]!==b||t[61]!==v||t[62]!==g||t[63]!==r||t[64]!==O||t[65]!==A||t[66]!==S||t[67]!==w||t[68]!==k||t[69]!==x||t[70]!==P||t[71]!==N||t[72]!==C){W=e=>{if(k){if(e.key===`ArrowDown`){e.preventDefault(),O((D+1)%ue.length);return}if(e.key===`ArrowUp`){e.preventDefault(),O((D-1+ue.length)%ue.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=ue[D];t&&(t.type===`command`?se(t.data):le(t.data));return}if(e.key===`Escape`){A(!1);return}}if(x){let t=U.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),O((D+1)%U.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),O((D-1+U.length)%U.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),U[D]&&ae(U[D]);return}if(e.key===`Escape`){S(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),H();return}let t=Ft();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),h===-1?(v(n),g(t.length-1),r(t[t.length-1])):h>0&&(g(h-1),r(t[h-1]))):e.key===`ArrowDown`&&(e.preventDefault(),h>0?(g(h-1),r(t[h-1])):h===0&&(g(-1),r(_))))};let e;t[77]!==T||t[78]!==u||t[79]!==E||t[80]!==M||t[81]!==b||t[82]!==r||t[83]!==O||t[84]!==A||t[85]!==S||t[86]!==w?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),b(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?A(!1):(M(e),A(!0),S(!1),O(0))}else A(!1)}else{A(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?S(!1):(w(t),S(!0),O(0),T.length===0&&u&&Wt(u).then(e=>{E(e)}).catch(Ns))}else S(!1)}else S(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[77]=T,t[78]=u,t[79]=E,t[80]=M,t[81]=b,t[82]=r,t[83]=O,t[84]=A,t[85]=S,t[86]=w,t[87]=e):e=t[87],de=e;let i;if(t[88]!==j||t[89]!==ne||t[90]!==P||t[91]!==N){let e;t[93]!==j||t[94]!==ne?(e=e=>e.metadata.action===`compact`&&!ne?!1:e.name.toLowerCase().includes(j.toLowerCase()),t[93]=j,t[94]=ne,t[95]=e):e=t[95];let n=N.filter(e),r;t[96]===j?r=t[97]:(r=e=>e.name.toLowerCase().includes(j.toLowerCase()),t[96]=j,t[97]=r);let a=P.filter(r);i=[...n.map(Ms),...a.map(js)],t[88]=j,t[89]=ne,t[90]=P,t[91]=N,t[92]=i}else i=t[92];ue=i.slice(0,10),U=x?T.filter(e=>e.toLowerCase().includes(C.toLowerCase())).slice(0,10):[],t[46]=T,t[47]=j,t[48]=_,t[49]=H,t[50]=ne,t[51]=h,t[52]=se,t[53]=ae,t[54]=le,t[55]=n,t[56]=D,t[57]=u,t[58]=E,t[59]=M,t[60]=b,t[61]=v,t[62]=g,t[63]=r,t[64]=O,t[65]=A,t[66]=S,t[67]=w,t[68]=k,t[69]=x,t[70]=P,t[71]=N,t[72]=C,t[73]=ue,t[74]=U,t[75]=W,t[76]=de}else ue=t[73],U=t[74],W=t[75],de=t[76];let fe;return t[98]!==ue||t[99]!==U||t[100]!==W||t[101]!==H||t[102]!==de||t[103]!==se||t[104]!==ae||t[105]!==le?(fe={handleSend:H,handleKeyDown:W,handleTextareaInput:de,insertFileReference:ae,insertCommand:se,insertSkill:le,allSuggestions:ue,fileSuggestions:U},t[98]=ue,t[99]=U,t[100]=W,t[101]=H,t[102]=de,t[103]=se,t[104]=ae,t[105]=le,t[106]=fe):fe=t[106],fe}function js(e){return{type:`skill`,data:e}}function Ms(e){return{type:`command`,data:e}}function Ns(e){return console.error(`Failed to fetch files:`,e)}function Ps(e){let t=(0,X.c)(22),{visible:n,commands:r,skills:i,query:a,selectedIndex:s,onSelectCommand:c,onSelectSkill:l,onMouseEnterSuggestion:u,containerRef:d}=e;if(!n)return null;let f;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);f=[...n.map(Is),...s.map(Fs)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=f}else f=t[3];let p=f,m,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=W(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),h=(0,$.jsx)(o,{className:`h-3 w-3`}),t[8]=m,t[9]=h):(m=t[8],h=t[9]);let g=a&&` matching "${a}"`,_;t[10]===g?_=t[11]:(_=(0,$.jsxs)(`div`,{className:m,children:[h,`Commands & Skills`,g]}),t[10]=g,t[11]=_);let v;t[12]!==p||t[13]!==u||t[14]!==c||t[15]!==l||t[16]!==s?(v=p.length>0?p.map((e,t)=>{let n=t===s;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:W(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>u(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(o,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:J.compact,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:W(J.compact,`ml-auto rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`),children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:J.compact,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:W(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>l(r),onMouseEnter:()=>u(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ke,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:W(J.compact,`ml-auto rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`),children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:W(J.compact,`rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`),children:`project`})]}),(0,$.jsx)(`span`,{className:J.compact,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:W(J.compact,`px-3 py-4 text-center text-muted-foreground`),children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:J.compact,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[12]=p,t[13]=u,t[14]=c,t[15]=l,t[16]=s,t[17]=v):v=t[17];let y;return t[18]!==d||t[19]!==_||t[20]!==v?(y=(0,$.jsxs)(`div`,{ref:d,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[_,v]}),t[18]=d,t[19]=_,t[20]=v,t[21]=y):y=t[21],y}function Fs(e){return{type:`skill`,data:e}}function Is(e){return{type:`command`,data:e}}function Ls(e){return e.startsWith(`image/`)}function Rs(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:W(J.compact,`group relative flex items-center gap-1 rounded-md bg-muted text-muted-foreground`),children:Ls(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(un,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(ue,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(un,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function zs(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function Bs(e){let t=(0,X.c)(17),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:s,containerRef:c}=e;if(!n||r.length===0)return null;let l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=W(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),u=(0,$.jsx)(C,{className:`h-3 w-3`}),t[0]=l,t[1]=u):(l=t[0],u=t[1]);let d;t[2]===i?d=t[3]:(d=(0,$.jsxs)(`div`,{className:l,children:[u,`Files matching "`,i,`"`]}),t[2]=i,t[3]=d);let f;if(t[4]!==r||t[5]!==s||t[6]!==o||t[7]!==a){let e;t[9]!==s||t[10]!==o||t[11]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e,r=t===a;return(0,$.jsxs)(`button`,{type:`button`,className:W(J.body,`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>s(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(re,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:W(J.compact,`truncate text-muted-foreground opacity-70`),children:e})]})]},e)},t[9]=s,t[10]=o,t[11]=a,t[12]=e):e=t[12],f=r.map(e),t[4]=r,t[5]=s,t[6]=o,t[7]=a,t[8]=f}else f=t[8];let p;return t[13]!==c||t[14]!==d||t[15]!==f?(p=(0,$.jsxs)(`div`,{ref:c,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[d,f]}),t[13]=c,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function Vs(e){let t=(0,X.c)(5),{providerSlug:n}=e;if(!n)return null;let r;t[0]===n?r=t[1]:(r=_n(n),t[0]=n,t[1]=r);let i=`${n} logo`,a;return t[2]!==r||t[3]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Hs}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Hs(e){e.currentTarget.style.visibility=`hidden`}function Us(e){let t=(0,X.c)(9),{providerSlug:n,providerData:r}=e,i=r?.name??n,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=W(J.dropdownGroupHeading,`flex items-center gap-1.5 px-3 py-1.5 uppercase tracking-wide`),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,$.jsx)(Vs,{providerSlug:n}),t[1]=n,t[2]=o);let s;t[3]!==i||t[4]!==r?(s=r?.url?(0,$.jsx)(sr,{url:r.url,showIcon:!1,variant:`inline`,children:i}):i,t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:a,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ws(e){let t=e.pricing?.prompt;return t==null?null:Math.ceil(t*3)}function Gs(e){return`$${i(e)}`}function Ks(e,t){return e.pricing?(0,$.jsxs)(`div`,{className:`max-w-64 whitespace-normal break-words text-left leading-relaxed`,children:[(0,$.jsx)(`div`,{children:`${Gs(e.pricing.prompt??0)} input per million tokens`}),(0,$.jsx)(`div`,{children:`${Gs(e.pricing.completion??0)} output per million tokens`}),(0,$.jsx)(`div`,{children:`Displayed value of ${t} is a relative price.`})]}):null}function qs(e,t){return[...e].sort((e,n)=>{let r=(e.provider??`Other`).localeCompare(n.provider??`Other`);if(r!==0)return r;if(t===`relative-price`){let t=(Ws(e)??2**53-1)-(Ws(n)??2**53-1);if(t!==0)return t}return or(e.id).localeCompare(or(n.id))})}function Js(e){let t=(0,X.c)(37),{availableModels:n,selectedModel:i,onModelSelect:a}=e,[o,s]=Y.useState(!1),[c,l]=Y.useState(`relative-price`),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Map,t[0]=u):u=t[0];let[f,p]=Y.useState(u),m=Y.useRef(null),h,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{d().then(function(e){p(new Map(e.map(Xs)))})},g=[],t[1]=h,t[2]=g):(h=t[1],g=t[2]),Y.useEffect(h,g);let _,v;t[3]===o?(_=t[4],v=t[5]):(_=()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&s(!1)};if(o)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},v=[o],t[3]=o,t[4]=_,t[5]=v),Y.useEffect(_,v);let y;t[6]===a?y=t[7]:(y=e=>{a(e),s(!1)},t[6]=a,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{l(function(e){return e===`relative-price`?`alphabetical`:`relative-price`})},t[8]=x):x=t[8];let S=x,C;t[9]!==n||t[10]!==c?(C=qs(n,c),t[9]=n,t[10]=c,t[11]=C):C=t[11];let w=C,T=c===`relative-price`?Re:Zt,E=c===`relative-price`?`Sort by relative price`:`Sort alphabetically`,D;t[12]===o?D=t[13]:(D=()=>s(!o),t[12]=o,t[13]=D);let O=i?.provider,k;t[14]===O?k=t[15]:(k=(0,$.jsx)(Vs,{providerSlug:O}),t[14]=O,t[15]=k);let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=W(J.body,`font-normal`),t[16]=A):A=t[16];let j;t[17]===i?j=t[18]:(j=i?or(i.id):`No model`,t[17]=i,t[18]=j);let M;t[19]===j?M=t[20]:(M=(0,$.jsx)(`span`,{className:A,children:j}),t[19]=j,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Ce,{className:`h-3 w-3`}),t[21]=N):N=t[21];let P;t[22]!==k||t[23]!==M||t[24]!==D?(P=(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:D,children:[k,M,N]}),t[22]=k,t[23]=M,t[24]=D,t[25]=P):P=t[25];let F;t[26]!==T||t[27]!==b||t[28]!==f||t[29]!==i?.id||t[30]!==o||t[31]!==E||t[32]!==w?(F=o&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,$.jsxs)(r,{children:[(0,$.jsx)(`div`,{className:`-mb-3 flex justify-end px-1 pb-1`,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":E,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:S,children:(0,$.jsx)(T,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(U,{side:`left`,align:`start`,sideOffset:8,children:E})]})}),Object.entries(w.reduce(Ys,{})).map((e,t)=>{let[n,r]=e;return(0,$.jsxs)(`div`,{children:[t>0&&(0,$.jsx)(ar,{className:`my-1`}),(0,$.jsx)(Us,{providerSlug:n,providerData:f.get(n)}),r.map(e=>{let t=Ws(e),n=t==null?null:Ks(e,t);return(0,$.jsx)(`div`,{children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`button`,{type:`button`,className:W(J.body,`flex w-full items-center justify-between gap-3 whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-popover-foreground hover:bg-accent`,e.id===i?.id&&`bg-accent font-medium`),onClick:()=>b(e),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:or(e.id)}),t!=null&&n&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:t})}),(0,$.jsx)(U,{side:`left`,align:`end`,sideOffset:8,className:`max-w-64`,children:n})]})]})})},e.id)})]},n)})]})}),t[26]=T,t[27]=b,t[28]=f,t[29]=i?.id,t[30]=o,t[31]=E,t[32]=w,t[33]=F):F=t[33];let I;return t[34]!==P||t[35]!==F?(I=(0,$.jsxs)(`div`,{className:`relative`,ref:m,children:[P,F]}),t[34]=P,t[35]=F,t[36]=I):I=t[36],I}function Ys(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}function Xs(e){return[e.slug,e]}var Zs=[{value:`build`,label:`Build`,icon:ft},{value:`plan`,label:`Plan`,icon:Ze},{value:`image`,label:`Image`,icon:It},{value:`ralph`,label:`Ralph`,icon:Ht}];function Qs(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function $s({planMode:e,imageMode:t,ralphMode:n,setPlanMode:r,setImageMode:i,setRalphMode:a,projectId:o}){let s=si(),c=Q(function(e){if(o)return e.projects.find(e=>e.projectId===o)}),[l,u]=Y.useState(!1),[d,f]=Y.useState(!0),[p,m]=Y.useState(!1),h=Y.useRef(null),g=Qs(e,t,n),_=Zs.find(e=>e.value===g),v=_.icon;Y.useEffect(()=>{function e(e){h.current&&!h.current.contains(e.target)&&u(!1)}if(l)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[l]),Y.useEffect(()=>{c&&f(c.allowAllCommands===!1)},[c]);async function y(){if(!o||p)return;let e=!d;f(e),m(!0);try{await L(o,{allowAllCommands:!e}),Jt(o);let t=await R();s({type:Z.SetProjects,projects:t.projects})}catch(t){f(!e),console.error(`Failed to update command confirmation setting:`,t)}finally{m(!1)}}function b(e){r(e===`plan`),i(e===`image`),a(e===`ralph`),u(!1)}return(0,$.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:()=>u(!l),children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:W(J.body,`font-normal`),children:_.label}),(0,$.jsx)(Ce,{className:`h-3 w-3`})]}),l&&(0,$.jsxs)(`div`,{className:`absolute bottom-full right-0 z-50 mb-1 w-56 rounded-lg border border-border bg-popover p-1 shadow-md`,children:[o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:W(J.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent disabled:opacity-50`),onClick:()=>{y()},disabled:p,children:[`Confirm Commands`,d&&(0,$.jsx)(Vt,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),Zs.map(e=>{let t=e.icon,n=e.value===g;return(0,$.jsxs)(`button`,{type:`button`,className:W(J.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent`),onClick:()=>b(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(Vt,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]})]})}function ec(e){let t=(0,X.c)(19),{disabled:n,canAddTask:r,onFileAttach:i,onAddTask:a}=e,o=n===void 0?!1:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=function(e){e()},t[0]=s):s=t[0];let c=s,l,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(D,{}),u=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[1]=l,t[2]=u):(l=t[1],u=t[2]);let d;t[3]===o?d=t[4]:(d=(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,disabled:o,children:[l,u]})}),t[3]=o,t[4]=d);let f;t[5]===i?f=t[6]:(f=()=>c(i),t[5]=i,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ue,{className:`mr-2 h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===f?m=t[9]:(m=(0,$.jsxs)(Po,{onClick:f,children:[p,`Attach File`]}),t[8]=f,t[9]=m);let h;t[10]!==r||t[11]!==a?(h=r&&(0,$.jsxs)(Po,{onClick:()=>c(a),children:[(0,$.jsx)(Qt,{className:`mr-2 h-3.5 w-3.5`}),`Add to Pending Tasks`]}),t[10]=r,t[11]=a,t[12]=h):h=t[12];let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(No,{align:`start`,side:`top`,className:`w-56`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==g||t[17]!==d?(_=(0,$.jsxs)(Oo,{children:[d,g]}),t[16]=g,t[17]=d,t[18]=_):_=t[18],_}var tc=Cr(`useWhisperSpeech`),nc=150;function rc(e){let t=new URLSearchParams;return t.set(`model`,e),`/api/voice-model/download?${t.toString()}`}function ic(){if(typeof SharedArrayBuffer>`u`)return 1;let e=navigator.hardwareConcurrency;return!e||e<=2?1:e<=4?2:Math.min(4,e-2)}function ac(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function oc(){let[e,t]=(0,Y.useState)(`idle`),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(0),[m,h]=(0,Y.useState)(()=>tn()),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(!1),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(!1),T=(0,Y.useCallback)(e=>{w.current=e,a(e)},[]);(0,Y.useEffect)(()=>{if(typeof window>`u`)return;function e(e){e.key===`tarsk.general.voiceModel`&&h(tn())}function t(){h(tn())}return window.addEventListener(`storage`,e),window.addEventListener(`tarsk:voice-model-changed`,t),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(`tarsk:voice-model-changed`,t)}},[]),(0,Y.useEffect)(()=>{g.current=null,_.current=null,C.current=null,T(!1),p(0),d(null),t(`idle`)},[m,T]),(0,Y.useEffect)(()=>()=>{S.current!==null&&window.clearTimeout(S.current),v.current&&v.current.getTracks().forEach(e=>e.stop())},[]);let E=(0,Y.useCallback)(async()=>{if(e===`ready`||e===`needs-model`||e===`error`)return e;if(C.current)return C.current;let n=rc(m);async function i(){t(`checking-support`),T(!1),p(0),d(null),tc.separator(`VOICE SESSION START`),tc.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform,model:m,url:n});try{let e=new Tr;g.current=e;let i=await e.checkWasmSupport();if(tc.info(`WASM SIMD support check result`,{supported:i}),r(i),!i)return tc.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`),`error`;let a=new wr;_.current=a,tc.info(`Checking IndexedDB model cache`,{url:n});try{let r=await a.loadModelByUrl(n);return tc.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2),model:m}),T(!0),t(`initializing`),await e.initModel(r),tc.info(`WASM model initialized from cache — ready`),t(`ready`),`ready`}catch(e){return tc.info(`Model not in cache — download required`,{reason:e instanceof Error?e.message:String(e),model:m}),t(`needs-model`),`needs-model`}}catch(e){let n=e instanceof Error?e.message:`Unknown error`;return tc.error(`Failed to check speech recognition support`,{error:n}),t(`error`),d(`Failed to check speech recognition support: ${n}`),`error`}}let a=i();C.current=a;try{return await a}finally{C.current=null}},[e,m,T]),D=(0,Y.useCallback)(async()=>{if(!g.current||!_.current)return;let e=rc(m);t(`downloading-model`),p(0),d(null),tc.info(`Model download requested`,{url:e,model:m});try{let n=await _.current.loadModelByUrl(e,e=>{p(e),e%10==0&&tc.debug(`Model download progress`,{progress:e,model:m})});tc.info(`Model download complete — initializing WASM`,{sizeBytes:n.byteLength,sizeMB:(n.byteLength/1024/1024).toFixed(2),model:m}),t(`initializing`),await g.current.initModel(n),tc.info(`WASM model initialized after download — ready`),T(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;tc.error(`Model download or initialization failed`,{error:n,model:m}),t(`needs-model`),d(n)}},[m,T]),O=(0,Y.useCallback)(async()=>{if(!(!g.current||!w.current)){if(x.current=!1,t(`requesting-mic`),d(null),l(``),tc.separator(`RECORDING START`),tc.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){tc.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=ac(),n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),r=n.getAudioTracks();tc.info(`Microphone access granted`,{durationMs:Math.round(ac()-e),trackCount:r.length,tracks:r.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),v.current=n,s(!0);let i=new AbortController;y.current=i,t(`recording`),tc.info(`Recording started`),b.current=Er(n,{signal:i.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{tc.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)tc.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)tc.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;tc.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[]),k=(0,Y.useCallback)(async()=>{if(!b.current){tc.info(`stopListening called but no active recording`),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null),w.current&&t(`ready`);return}tc.info(`Stopping recording — waiting for audio data`);let e=ac();y.current?.abort(),t(`transcribing`);try{let n=ac(),r=await b.current;if(x.current){tc.info(`Transcription cancelled by user`),t(`ready`);return}let i=(r.audioData.length/16e3).toFixed(2),a=Math.round(ac()-n);tc.info(`Audio capture complete — starting transcription`,{sampleCount:r.audioData.length,durationSec:i,sampleRate:16e3,conversionDurationMs:a,stopToConversionReadyMs:Math.round(ac()-e)}),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null);let o=ac(),s=ic(),c=g.current.createSession(),u=``,d=``,f=null;function p(e=!1){if(!d)return;let t=d.trim();if(e){S.current!==null&&(window.clearTimeout(S.current),S.current=null),d=``,l(t);return}S.current===null&&(S.current=window.setTimeout(()=>{S.current=null;let e=d.trim();d=``,e&&l(e)},nc))}let m=c.streaming(r.audioData,{language:`en`,threads:s,translate:!1}),h=``,_=0;for await(let e of m){if(x.current)break;_++,f===null&&(f=Math.round(ac()-o)),u+=e.text.trim()+` `,h=u,d=h,tc.debug(`Transcription segment received`,{index:_,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),p()}p(!0),tc.info(`Transcription complete`,{segmentCount:_,durationMs:Math.round(ac()-o),timeToFirstSegmentMs:f,threadCount:s,totalStopToReadyMs:Math.round(ac()-e),textLength:h.trim().length,text:h.trim().slice(0,100)}),t(`ready`)}catch(e){if(x.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if(tc.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
|
|
26
|
+
`).slice(0,5).join(` | `):void 0}),g.current&&n.includes(`Aborted`)){tc.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await g.current.restartModel(),tc.info(`WASM reinitialized successfully`)}catch(e){tc.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{S.current!==null&&(window.clearTimeout(S.current),S.current=null),b.current=null,y.current=null}},[]),A=(0,Y.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:O,stopListening:k,requestModelDownload:D,ensureReady:E,resetTranscript:A}}var sc=Y.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,value:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=W(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=o);let s=`translateX(-${100-(a||0)}%)`,c;n[6]===s?c=n[7]:(c=(0,$.jsx)(Fn,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:s}}),n[6]=s,n[7]=c);let l;return n[8]!==i||n[9]!==t||n[10]!==o||n[11]!==c?(l=(0,$.jsx)(rr,{ref:t,className:o,...i,children:c}),n[8]=i,n[9]=t,n[10]=o,n[11]=c,n[12]=l):l=n[12],l});sc.displayName=rr.displayName;var cc=75;function lc(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(pn,{children:[(0,$.jsx)(qe,{children:`Download Voice Model`}),(0,$.jsxs)(Ue,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,cc,`MB. The model will be cached locally for future use.`]})]}),t[0]=c):c=t[0];let l;t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==r||t[5]!==o?(l=(0,$.jsxs)(ut,{children:[c,a?(0,$.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,$.jsx)(sc,{value:o,className:`w-full`}),(0,$.jsx)(`p`,{className:W(J.bodyMuted,`text-center`),children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):s?(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsx)(Sr,{variant:`error`,className:`mb-0`,children:s}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(G,{onClick:i,children:`Try Again`})]})]}):(0,$.jsxs)(rn,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(G,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=s,t[3]=i,t[4]=r,t[5]=o,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==n||t[9]!==l?(u=(0,$.jsx)(mt,{open:n,onOpenChange:r,children:l}),t[7]=r,t[8]=n,t[9]=l,t[10]=u):u=t[10],u}function uc(e){let t=(0,X.c)(67),{onTranscript:n,children:r}=e,{state:i,isWasmSupported:a,transcript:o,error:s,downloadProgress:c,startListening:l,stopListening:u,requestModelDownload:d,ensureReady:f,resetTranscript:p}=oc(),{toast:m}=Ti(),[h,g]=(0,Y.useState)(!1),_=(0,Y.useRef)(``),v=(0,Y.useRef)(null),y=i===`recording`,b=i===`transcribing`,x=y||b,S=i===`needs-model`,C=i===`downloading-model`||i===`initializing`,w=i===`checking-support`,T,E;t[0]!==h||t[1]!==s||t[2]!==m?(T=()=>{s&&s!==v.current&&!h&&m({title:`Voice Input Error`,description:s,variant:`destructive`}),v.current=s},E=[s,h,m],t[0]=h,t[1]=s,t[2]=m,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,Y.useEffect)(T,E);let D,O;t[5]!==n||t[6]!==o?(D=()=>{if(o&&o!==_.current){let e=o.substring(_.current.length);_.current=o,n(e)}},O=[o,n],t[5]=n,t[6]=o,t[7]=D,t[8]=O):(D=t[7],O=t[8]),(0,Y.useEffect)(D,O);let k,A;t[9]===o?(k=t[10],A=t[11]):(k=()=>{o||(_.current=``)},A=[o],t[9]=o,t[10]=k,t[11]=A),(0,Y.useEffect)(k,A);let j;t[12]!==f||t[13]!==x||t[14]!==S||t[15]!==p||t[16]!==l||t[17]!==i||t[18]!==u?(j=async()=>{if(x){u();return}if(S){g(!0);return}if(i===`ready`){p(),l();return}if(i===`idle`){let e=await f();e===`needs-model`?g(!0):e===`ready`&&(p(),l())}},t[12]=f,t[13]=x,t[14]=S,t[15]=p,t[16]=l,t[17]=i,t[18]=u,t[19]=j):j=t[19];let M=j,N;t[20]===d?N=t[21]:(N=()=>{d()},t[20]=d,t[21]=N);let P=N,F,I;t[22]!==h||t[23]!==i?(I=()=>{i===`ready`&&h&&g(!1)},F=[i,h],t[22]=h,t[23]=i,t[24]=F,t[25]=I):(F=t[24],I=t[25]),(0,Y.useEffect)(I,F);let L;t[26]!==s||t[27]!==w||t[28]!==C||t[29]!==y||t[30]!==b||t[31]!==a||t[32]!==S?(L=()=>w?`Checking voice input support...`:a===!1?`Voice input not supported in this browser`:s||(C?`Downloading speech model...`:b?`Transcribing...`:y?`Stop listening`:S?`Click to download speech model`:`Start listening`),t[26]=s,t[27]=w,t[28]=C,t[29]=y,t[30]=b,t[31]=a,t[32]=S,t[33]=L):L=t[33];let R=L,ee;t[34]!==C||t[35]!==y||t[36]!==b?(ee=()=>C||b?(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin`}):y?(0,$.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,$.jsx)(Nt,{className:`h-3 w-3`}),t[34]=C,t[35]=y,t[36]=b,t[37]=ee):ee=t[37];let z=ee,B,V;t[38]!==r||t[39]!==z||t[40]!==R||t[41]!==M||t[42]!==w||t[43]!==C||t[44]!==y||t[45]!==b||t[46]!==a||t[47]!==S?(B=R(),V=r({onClick:M,disabled:w||C||b||a===!1,icon:z(),label:B,isRecording:y,isTranscribing:b,isDownloading:C,needsModel:S,isSupported:a!==!1}),t[38]=r,t[39]=z,t[40]=R,t[41]=M,t[42]=w,t[43]=C,t[44]=y,t[45]=b,t[46]=a,t[47]=S,t[48]=B,t[49]=V):(B=t[48],V=t[49]);let te=V,ne;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`style`,{children:`
|
|
27
|
+
.recording-waveform {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: 2px;
|
|
31
|
+
height: 16px;
|
|
32
|
+
}
|
|
33
|
+
.recording-waveform-bar {
|
|
34
|
+
display: block;
|
|
35
|
+
width: 3px;
|
|
36
|
+
height: 4px;
|
|
37
|
+
border-radius: 2px;
|
|
38
|
+
background: currentColor;
|
|
39
|
+
animation: waveform-bounce 0.7s ease-in-out infinite alternate;
|
|
40
|
+
}
|
|
41
|
+
@keyframes waveform-bounce {
|
|
42
|
+
from { height: 3px; }
|
|
43
|
+
to { height: 14px; }
|
|
44
|
+
}
|
|
45
|
+
`}),t[50]=ne):ne=t[50];let re;t[51]===te?re=t[52]:(re=(0,$.jsx)(q,{asChild:!0,children:te}),t[51]=te,t[52]=re);let H;t[53]===B?H=t[54]:(H=(0,$.jsx)(U,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:B}),t[53]=B,t[54]=H);let ie;t[55]!==re||t[56]!==H?(ie=(0,$.jsxs)(K,{children:[re,H]}),t[55]=re,t[56]=H,t[57]=ie):ie=t[57];let ae;t[58]!==h||t[59]!==c||t[60]!==s||t[61]!==P||t[62]!==C?(ae=(0,$.jsx)(lc,{open:h,onOpenChange:g,onConfirm:P,downloading:C,progress:c,error:s}),t[58]=h,t[59]=c,t[60]=s,t[61]=P,t[62]=C,t[63]=ae):ae=t[63];let oe;return t[64]!==ie||t[65]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[ne,ie,ae]}),t[64]=ie,t[65]=ae,t[66]=oe):oe=t[66],oe}function dc(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:W(J.compact,J.label,`text-muted-foreground`),children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:W(J.body,`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2`),children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(un,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(Sr,{className:`mb-3 border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function fc(e){let t=(0,X.c)(28),{onSpeechClick:n,speechDisabled:r,icon:i,label:a,isRecording:o,isTranscribing:s,isDownloading:c,isSupported:l,hasMessageText:u,setIsVoiceActive:d,isStreaming:f,disabled:p,canSubmitMessage:m,attachmentsLength:h,effectiveModel:g,onStop:_,onSend:v}=e,y,b;t[0]!==u||t[1]!==c||t[2]!==o||t[3]!==s||t[4]!==d?(y=()=>{u||d(o||s||c)},b=[u,c,o,s,d],t[0]=u,t[1]=c,t[2]=o,t[3]=s,t[4]=d,t[5]=y,t[6]=b):(y=t[5],b=t[6]),(0,Y.useEffect)(y,b);let x=!f&&((p??!1)||!m&&r||!u&&h>0&&!g||u&&!g),S;t[7]!==m||t[8]!==f||t[9]!==v||t[10]!==n||t[11]!==_?(S=function(){if(f){_?.();return}if(m){v();return}n()},t[7]=m,t[8]=f,t[9]=v,t[10]=n,t[11]=_,t[12]=S):S=t[12];let C=S,w=f?`Stop generation`:m?`Send message`:a,T=`relative h-7 w-7 rounded-full ${o?`bg-primary text-primary-foreground hover:bg-primary/90`:``} ${f?`before:absolute before:inset-[-1px] before:rounded-full before:border before:border-primary/60 before:animate-ping-subtle before:content-['']`:``}`,E;t[13]!==m||t[14]!==i||t[15]!==f?(E=f?(0,$.jsx)(`span`,{className:`block h-3 w-3 shrink-0 rounded-[2px] bg-current`,"aria-hidden":`true`}):m?(0,$.jsx)(le,{className:`h-3 w-3`}):i,t[13]=m,t[14]=i,t[15]=f,t[16]=E):E=t[16];let D;t[17]===w?D=t[18]:(D=(0,$.jsx)(`span`,{className:`sr-only`,children:w}),t[17]=w,t[18]=D);let O;t[19]===l?O=t[20]:(O=!l&&(0,$.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`}),t[19]=l,t[20]=O);let k;return t[21]!==C||t[22]!==x||t[23]!==T||t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(G,{size:`icon`,className:T,onClick:C,disabled:x,children:[E,D,O]}),t[21]=C,t[22]=x,t[23]=T,t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27],k}function pc(e){let t=(0,X.c)(160),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l,userTasks:u,onMatchedUserTaskSend:d,onUserTaskCreated:f}=e,p=i===void 0?!1:i,m=l===void 0?!1:l,h;t[0]===u?h=t[1]:(h=u===void 0?[]:u,t[0]=u,t[1]=h);let g=h,v;t[2]===o?v=t[3]:(v={initialValue:o},t[2]=o,t[3]=v);let{message:y,setMessage:b,historyIndex:x,setHistoryIndex:S,draftMessage:C,setDraftMessage:w,cursorPosition:T,setCursorPosition:E,availableModels:D,selectedModel:O,setSelectedModel:k,attachments:j,setAttachments:M,planMode:N,setPlanMode:P,ralphMode:F,setRalphMode:I,imageMode:L,setImageMode:R,availableImageModels:ee,selectedImageModel:z,setSelectedImageModel:B,allFiles:V,setAllFiles:te,showSuggestions:ne,setShowSuggestions:re,suggestionQuery:H,setSuggestionQuery:ie,selectedIndex:ae,setSelectedIndex:oe,slashCommands:se,skills:ce,showCommandSuggestions:le,setShowCommandSuggestions:ue,commandQuery:U,setCommandQuery:de,fileInputRef:fe,textareaRef:pe,suggestionsRef:me,commandSuggestionsRef:he,selectedThreadId:ge,dispatch:_e}=Os(v),ve=Q(xc),ye=Q(bc),be;t[4]===ve?be=t[5]:(be=ve.some(yc),t[4]=ve,t[5]=be);let xe=be,Se=L?z:O,Ce=L?ee:D,we;t[6]===y?we=t[7]:(we=y.trim(),t[6]=y,t[7]=we);let Te=we.length>0,Ee=Te||j.length>0,[De,Oe]=Y.useState(!1),ke,Ae;t[8]===Te?(ke=t[9],Ae=t[10]):(ke=()=>{Te&&Oe(!1)},Ae=[Te],t[8]=Te,t[9]=ke,t[10]=Ae),(0,Y.useEffect)(ke,Ae);let je=ge??void 0,Me;t[11]!==V||t[12]!==j||t[13]!==U||t[14]!==T||t[15]!==_e||t[16]!==C||t[17]!==xe||t[18]!==x||t[19]!==L||t[20]!==p||t[21]!==y||t[22]!==d||t[23]!==n||t[24]!==N||t[25]!==F||t[26]!==z||t[27]!==ae||t[28]!==O||t[29]!==te||t[30]!==M||t[31]!==de||t[32]!==E||t[33]!==w||t[34]!==S||t[35]!==R||t[36]!==b||t[37]!==P||t[38]!==I||t[39]!==oe||t[40]!==ue||t[41]!==re||t[42]!==ie||t[43]!==le||t[44]!==ne||t[45]!==ce||t[46]!==se||t[47]!==H||t[48]!==je||t[49]!==pe||t[50]!==g?(Me={message:y,setMessage:b,userTasks:g,onMatchedUserTaskSend:d,attachments:j,selectedModel:O,onSend:n,isStreaming:p,selectedThreadId:je,isListening:!1,stopListening:vc,resetTranscript:_c,dispatch:_e,historyIndex:x,setHistoryIndex:S,draftMessage:C,setDraftMessage:w,cursorPosition:T,setCursorPosition:E,showSuggestions:ne,setShowSuggestions:re,suggestionQuery:H,setSuggestionQuery:ie,allFiles:V,setAllFiles:te,selectedIndex:ae,setSelectedIndex:oe,showCommandSuggestions:le,setShowCommandSuggestions:ue,commandQuery:U,setCommandQuery:de,slashCommands:se,skills:ce,textareaRef:pe,setAttachments:M,planMode:N,setPlanMode:P,ralphMode:F,setRalphMode:I,imageMode:L,setImageMode:R,selectedImageModel:z,hasConversationMessages:xe},t[11]=V,t[12]=j,t[13]=U,t[14]=T,t[15]=_e,t[16]=C,t[17]=xe,t[18]=x,t[19]=L,t[20]=p,t[21]=y,t[22]=d,t[23]=n,t[24]=N,t[25]=F,t[26]=z,t[27]=ae,t[28]=O,t[29]=te,t[30]=M,t[31]=de,t[32]=E,t[33]=w,t[34]=S,t[35]=R,t[36]=b,t[37]=P,t[38]=I,t[39]=oe,t[40]=ue,t[41]=re,t[42]=ie,t[43]=le,t[44]=ne,t[45]=ce,t[46]=se,t[47]=H,t[48]=je,t[49]=pe,t[50]=g,t[51]=Me):Me=t[51];let{handleSend:G,handleKeyDown:Ne,handleTextareaInput:Pe,insertFileReference:Fe,insertCommand:Ie,insertSkill:Le,fileSuggestions:Re}=As(Me),ze;t[52]===b?ze=t[53]:(ze=e=>{b(t=>(t.endsWith(` `),t+e))},t[52]=b,t[53]=ze);let K=ze,Be;t[54]===M?Be=t[55]:(Be=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(gc);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];M(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[54]=M,t[55]=Be);let Ve=Be,He=m?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Ue=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${m?`border-border/50 shadow-lg backdrop-blur-sm`:`border-border shadow-2xl`}`,We=m?`linear-gradient(to right, transparent 0, transparent 40px, hsl(var(--background) / 0.8) 40px)`:`linear-gradient(to right, transparent 0, transparent 40px, hsl(var(--background)) 40px)`,Ge;t[56]===We?Ge=t[57]:(Ge={backgroundImage:We},t[56]=We,t[57]=Ge);let Ke;t[58]!==c||t[59]!==s?(Ke=(0,$.jsx)(dc,{queuedMessages:s,onRemoveQueuedMessage:c}),t[58]=c,t[59]=s,t[60]=Ke):Ke=t[60];let qe=F?`Describe stories for Ralph to implement autonomously...`:N?`Describe what you want Tarsk to plan...`:L?`Describe the image you want to generate...`:De?`Dictate your message...`:`Ask Tarsk anything, # for files, / for commands & skills`,Je;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(Je=W(J.body,`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-foreground placeholder:text-muted-foreground focus:outline-none`),t[61]=Je):Je=t[61];let Ye;t[62]!==a||t[63]!==Ne||t[64]!==Ve||t[65]!==Pe||t[66]!==y||t[67]!==qe||t[68]!==pe?(Ye=(0,$.jsx)(`textarea`,{ref:pe,value:y,onChange:Pe,onKeyDown:Ne,onPaste:Ve,placeholder:qe,rows:1,className:Je,disabled:a}),t[62]=a,t[63]=Ne,t[64]=Ve,t[65]=Pe,t[66]=y,t[67]=qe,t[68]=pe,t[69]=Ye):Ye=t[69];let Xe;t[70]!==U||t[71]!==he||t[72]!==Ie||t[73]!==Le||t[74]!==ae||t[75]!==oe||t[76]!==le||t[77]!==ce||t[78]!==se?(Xe=(0,$.jsx)(Ps,{visible:le,commands:se,skills:ce,query:U,selectedIndex:ae,onSelectCommand:Ie,onSelectSkill:Le,onMouseEnterSuggestion:oe,containerRef:he}),t[70]=U,t[71]=he,t[72]=Ie,t[73]=Le,t[74]=ae,t[75]=oe,t[76]=le,t[77]=ce,t[78]=se,t[79]=Xe):Xe=t[79];let Ze;t[80]!==Re||t[81]!==Fe||t[82]!==ae||t[83]!==oe||t[84]!==ne||t[85]!==H||t[86]!==me?(Ze=(0,$.jsx)(Bs,{showSuggestions:ne,fileSuggestions:Re,suggestionQuery:H,selectedIndex:ae,onSelectFile:Fe,onMouseEnterSuggestion:oe,containerRef:me}),t[80]=Re,t[81]=Fe,t[82]=ae,t[83]=oe,t[84]=ne,t[85]=H,t[86]=me,t[87]=Ze):Ze=t[87];let Qe;t[88]!==j||t[89]!==O?.id||t[90]!==O?.name||t[91]!==O?.supportsImages||t[92]!==M?(Qe=j.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(Rs,{attachments:j,onRemove:e=>M(t=>t.filter((t,n)=>n!==e))}),j.some(hc)&&O?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:W(J.compact,`mb-2 flex items-center gap-1.5 text-amber-500`),children:[(0,$.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,O?.name||O?.id]})]})]}),t[88]=j,t[89]=O?.id,t[90]=O?.name,t[91]=O?.supportsImages,t[92]=M,t[93]=Qe):Qe=t[93];let $e;t[94]===fe?$e=t[95]:($e=()=>fe.current?.click(),t[94]=fe,t[95]=$e);let et;t[96]!==_e||t[97]!==y||t[98]!==f||t[99]!==M||t[100]!==b||t[101]!==ge||t[102]!==pe?(et=()=>{let e=ge;if(!e)return;let t=y.trim();t&&A(e,t).then(t=>{f?.(t),b(``),M([]),_e({type:Z.ClearChatInputDraft,threadId:e}),pe.current&&(pe.current.style.height=`auto`)}).catch(mc)},t[96]=_e,t[97]=y,t[98]=f,t[99]=M,t[100]=b,t[101]=ge,t[102]=pe,t[103]=et):et=t[103];let tt;t[104]!==a||t[105]!==Te||t[106]!==$e||t[107]!==et?(tt=(0,$.jsx)(ec,{disabled:a,canAddTask:Te,onFileAttach:$e,onAddTask:et}),t[104]=a,t[105]=Te,t[106]=$e,t[107]=et,t[108]=tt):tt=t[108];let q=L?B:k,nt;t[109]!==Ce||t[110]!==Se||t[111]!==q?(nt=(0,$.jsx)(Js,{availableModels:Ce,selectedModel:Se,onModelSelect:q}),t[109]=Ce,t[110]=Se,t[111]=q,t[112]=nt):nt=t[112];let rt;t[113]!==tt||t[114]!==nt?(rt=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[tt,nt]}),t[113]=tt,t[114]=nt,t[115]=rt):rt=t[115];let it;t[116]!==L||t[117]!==N||t[118]!==F||t[119]!==ye||t[120]!==R||t[121]!==P||t[122]!==I?(it=(0,$.jsx)($s,{planMode:N,imageMode:L,ralphMode:F,setPlanMode:P,setImageMode:R,setRalphMode:I,projectId:ye}),t[116]=L,t[117]=N,t[118]=F,t[119]=ye,t[120]=R,t[121]=P,t[122]=I,t[123]=it):it=t[123];let at;t[124]!==j.length||t[125]!==Ee||t[126]!==a||t[127]!==Se||t[128]!==G||t[129]!==Te||t[130]!==p||t[131]!==r?(at=e=>{let{onClick:t,disabled:n,icon:i,label:o,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u}=e;return(0,$.jsx)(fc,{onSpeechClick:t,speechDisabled:n,icon:i,label:o,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u,hasMessageText:Te,setIsVoiceActive:Oe,isStreaming:p,disabled:a,canSubmitMessage:Ee,attachmentsLength:j.length,effectiveModel:Se,onStop:r,onSend:G})},t[124]=j.length,t[125]=Ee,t[126]=a,t[127]=Se,t[128]=G,t[129]=Te,t[130]=p,t[131]=r,t[132]=at):at=t[132];let ot;t[133]!==K||t[134]!==at?(ot=(0,$.jsx)(uc,{onTranscript:K,children:at}),t[133]=K,t[134]=at,t[135]=ot):ot=t[135];let st;t[136]!==it||t[137]!==ot?(st=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[it,ot]}),t[136]=it,t[137]=ot,t[138]=st):st=t[138];let ct;t[139]!==rt||t[140]!==st?(ct=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[rt,st]}),t[139]=rt,t[140]=st,t[141]=ct):ct=t[141];let lt;t[142]!==Ue||t[143]!==Ge||t[144]!==Ke||t[145]!==Ye||t[146]!==Xe||t[147]!==Ze||t[148]!==Qe||t[149]!==ct?(lt=(0,$.jsxs)(`div`,{className:Ue,style:Ge,children:[Ke,Ye,Xe,Ze,Qe,ct]}),t[142]=Ue,t[143]=Ge,t[144]=Ke,t[145]=Ye,t[146]=Xe,t[147]=Ze,t[148]=Qe,t[149]=ct,t[150]=lt):lt=t[150];let ut;t[151]===M?ut=t[152]:(ut=e=>zs(e,e=>M(t=>[...t,...e])),t[151]=M,t[152]=ut);let dt;t[153]!==fe||t[154]!==ut?(dt=(0,$.jsx)(`input`,{ref:fe,type:`file`,multiple:!0,className:`hidden`,onChange:ut}),t[153]=fe,t[154]=ut,t[155]=dt):dt=t[155];let ft;return t[156]!==He||t[157]!==lt||t[158]!==dt?(ft=(0,$.jsxs)(`div`,{className:He,children:[lt,dt]}),t[156]=He,t[157]=lt,t[158]=dt,t[159]=ft):ft=t[159],ft}function mc(e){console.error(`Failed to create user task:`,e)}function hc(e){return e.mimeType.startsWith(`image/`)}function gc(e){return e.type.startsWith(`image/`)}function _c(){}function vc(){}function yc(e){return e.sender===`agent`}function bc(e){return e.selectedProjectId}function xc(e){return e.messages}function Sc(e){let t=(0,X.c)(25),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s,onCreateBranch:c}=e,l;t[0]===o?l=t[1]:(l=e=>{e&&o()},t[0]=o,t[1]=l);let u,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=W(J.compact,`h-7 px-2 bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`),d=(0,$.jsx)(ge,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=u,t[3]=d):(u=t[2],d=t[3]);let f=n||`Unknown`,p;t[4]===f?p=t[5]:(p=(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:u,children:[d,f]})}),t[4]=f,t[5]=p);let m,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(D,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),h=(0,$.jsx)(`span`,{children:`Create branch`}),t[6]=m,t[7]=h):(m=t[6],h=t[7]);let g;t[8]!==a||t[9]!==c?(g=(0,$.jsxs)(Po,{onClick:c,disabled:a,children:[m,h]}),t[8]=a,t[9]=c,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ro,{}),t[11]=_):_=t[11];let v;t[12]!==r||t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==s?(v=i?(0,$.jsxs)(`div`,{className:W(J.compact,`px-2 py-1.5 text-muted-foreground flex items-center gap-2`),children:[(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:W(J.compact,`px-2 py-1.5 text-muted-foreground`),children:`No branches found`}):r.map(e=>(0,$.jsxs)(Po,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(ge,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,$.jsx)(`span`,{className:W(J.compact,`ml-auto text-muted-foreground`),children:`current`})]},e)),t[12]=r,t[13]=n,t[14]=a,t[15]=i,t[16]=s,t[17]=v):v=t[17];let y;t[18]!==v||t[19]!==g?(y=(0,$.jsxs)(No,{align:`start`,children:[g,_,v]}),t[18]=v,t[19]=g,t[20]=y):y=t[20];let b;return t[21]!==l||t[22]!==y||t[23]!==p?(b=(0,$.jsxs)(Oo,{onOpenChange:l,children:[p,y]}),t[21]=l,t[22]=y,t[23]=p,t[24]=b):b=t[24],b}function Cc(e){let t=(0,X.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,c;t[0]!==i||t[1]!==o||t[2]!==s?(c=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(pn,{children:[(0,$.jsx)(qe,{children:`New Branch`}),(0,$.jsx)(Ue,{children:`Enter a name for the new branch. It will be created from the default branch.`})]}),t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ot,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=d):d=t[5];let f;t[6]===a?f=t[7]:(f=e=>a(e.target.value),t[6]=a,t[7]=f);let p;t[8]!==i||t[9]!==l||t[10]!==o||t[11]!==f?(p=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[d,(0,$.jsx)(Ot,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:f,onKeyDown:l,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=l,t[10]=o,t[11]=f,t[12]=p):p=t[12];let m;t[13]===r?m=t[14]:(m=()=>r(!1),t[13]=r,t[14]=m);let h;t[15]!==o||t[16]!==m?(h=(0,$.jsx)(G,{variant:`outline`,onClick:m,disabled:o,children:`Cancel`}),t[15]=o,t[16]=m,t[17]=h):h=t[17];let g;t[18]!==i||t[19]!==o?(g=o||!i.trim(),t[18]=i,t[19]=o,t[20]=g):g=t[20];let _=o?`Creating...`:`Create Branch`,v;t[21]!==s||t[22]!==g||t[23]!==_?(v=(0,$.jsx)(G,{onClick:s,disabled:g,children:_}),t[21]=s,t[22]=g,t[23]=_,t[24]=v):v=t[24];let y;t[25]!==v||t[26]!==h?(y=(0,$.jsxs)(rn,{children:[h,v]}),t[25]=v,t[26]=h,t[27]=y):y=t[27];let b;t[28]!==y||t[29]!==p?(b=(0,$.jsxs)(ut,{children:[u,p,y]}),t[28]=y,t[29]=p,t[30]=b):b=t[30];let x;return t[31]!==r||t[32]!==n||t[33]!==b?(x=(0,$.jsx)(mt,{open:n,onOpenChange:r,children:b}),t[31]=r,t[32]=n,t[33]=b,t[34]=x):x=t[34],x}function wc(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=Dr();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(B,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(At,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}var Tc=[{key:`systemPrompt`,label:`System prompt`,color:`#9CA3AF`},{key:`toolDefinitions`,label:`Tool definitions`,color:`#B088F0`},{key:`rules`,label:`Rules`,color:`#88D088`},{key:`skills`,label:`Skills`,color:`#D0A000`},{key:`subagentDefinitions`,label:`Subagent definitions`,color:`#2080D0`},{key:`conversation`,label:`Conversation`,color:`#E09030`}];function Ec(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Dc(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function Oc(e){let t=(0,X.c)(50),{breakdown:n,onClose:r}=e,{categories:i,totalTokens:a,contextWindow:o,percentageFull:s}=n,c,l,u,d,f,p;if(t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==s||t[4]!==a){let e;t[11]===i?e=t[12]:(e=e=>i[e.key]>0,t[11]=i,t[12]=e);let n=Tc.filter(e);d=`w-72 space-y-3`;let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`h3`,{className:J.label,children:`Context`}),t[13]=m):m=t[13];let h;t[14]===r?h=t[15]:(h=r&&(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,$.jsx)(un,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[14]=r,t[15]=h),t[16]===h?f=t[17]:(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[m,h]}),t[16]=h,t[17]=f);let g;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(g=W(J.compact,`flex items-center justify-between text-muted-foreground`),t[18]=g):g=t[18];let _;t[19]===s?_=t[20]:(_=(0,$.jsxs)(`span`,{children:[s,`% Full`]}),t[19]=s,t[20]=_);let v;t[21]===a?v=t[22]:(v=Ec(a),t[21]=a,t[22]=v);let y;t[23]===o?y=t[24]:(y=Dc(o),t[23]=o,t[24]=y);let b;t[25]!==v||t[26]!==y?(b=(0,$.jsxs)(`span`,{children:[`~`,v,` / `,y,` Tokens`]}),t[25]=v,t[26]=y,t[27]=b):b=t[27],t[28]!==_||t[29]!==b?(p=(0,$.jsxs)(`div`,{className:g,children:[_,b]}),t[28]=_,t[29]=b,t[30]=p):p=t[30],u=`h-2 w-full overflow-hidden rounded-full bg-muted/60`,c=`flex h-full w-full`;let x;t[31]!==i||t[32]!==o?(x=e=>{let t=i[e.key],n=o>0?t/o*100:0;return(0,$.jsx)(`div`,{style:{width:`${Math.max(n,t>0?.5:0)}%`,backgroundColor:e.color}},e.key)},t[31]=i,t[32]=o,t[33]=x):x=t[33],l=n.map(x),t[0]=i,t[1]=o,t[2]=r,t[3]=s,t[4]=a,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];let m;t[34]!==c||t[35]!==l?(m=(0,$.jsx)(`div`,{className:c,children:l}),t[34]=c,t[35]=l,t[36]=m):m=t[36];let h;t[37]!==u||t[38]!==m?(h=(0,$.jsx)(`div`,{className:u,children:m}),t[37]=u,t[38]=m,t[39]=h):h=t[39];let g;t[40]===i?g=t[41]:(g=Tc.map(e=>(0,$.jsxs)(`div`,{className:W(J.compact,`flex items-center justify-between text-muted-foreground`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{children:e.label})]}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:Ec(i[e.key])})]},e.key)),t[40]=i,t[41]=g);let _;t[42]===g?_=t[43]:(_=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[42]=g,t[43]=_);let v;return t[44]!==_||t[45]!==d||t[46]!==f||t[47]!==p||t[48]!==h?(v=(0,$.jsxs)(`div`,{className:d,children:[f,p,h,_]}),t[44]=_,t[45]=d,t[46]=f,t[47]=p,t[48]=h,t[49]=v):v=t[49],v}function kc({threadId:e,currentConversationId:t,initialBreakdown:n,refreshKey:r,children:i}){let[a,o]=(0,Y.useState)(n??null),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(n?t:void 0);return(0,Y.useEffect)(()=>{if(n){o(n),m(t),u(null);return}t!==p&&(o(null),m(void 0),u(null))},[n,t,p,r]),(0,Y.useEffect)(()=>{if(!d||!e||!t||p===t)return;let n=!1;async function r(){let r=t;if(r){c(!0),u(null);try{let t=await We(e,r);if(n)return;o(t),m(r)}catch(e){if(console.error(`[TokenUsageTooltip] Failed to load context data:`,e),n)return;o(e=>(e||u(`Failed to load context data`),e))}finally{n||c(!1)}}}return r(),()=>{n=!0}},[d,e,t,p]),!e||e===``?(0,$.jsx)($.Fragment,{children:i}):(0,$.jsxs)(Xa,{open:d,onOpenChange:f,children:[(0,$.jsx)(Za,{asChild:!0,children:i}),(0,$.jsxs)(Qa,{side:`top`,align:`end`,className:`w-auto p-4`,children:[s&&(0,$.jsxs)(`div`,{className:W(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(E,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading context...`})]}),l&&!s&&(0,$.jsxs)(`div`,{className:W(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(E,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:l})]}),!s&&!l&&a&&(0,$.jsx)(Oc,{breakdown:a,onClose:()=>f(!1)})]})]})}function Ac(e){return e.filter(e=>e.sender===`agent`).length}function jc(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function Mc(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=jc(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,$.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function Nc(e){let t=(0,X.c)(21),{threadId:n,messages:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?[]:r,t[0]=r,t[1]=i);let a=i,[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),u;t[2]===a?u=t[3]:(u=Ac(a),t[2]=a,t[3]=u);let d=u,f;t[4]===n?f=t[5]:(f=()=>{(async function(){if(!n){s(void 0),l(void 0);return}try{let e=(await Me(n)).currentConversationId;if(s(e),!e){l(void 0);return}l(await We(n,e))}catch(e){console.error(`Failed to fetch thread usage data:`,e)}})()},t[4]=n,t[5]=f);let p;if(t[6]!==n||t[7]!==d?(p=[n,d],t[6]=n,t[7]=d,t[8]=p):p=t[8],(0,Y.useEffect)(f,p),!n||n===``)return null;let m=c?.percentageFull,g=typeof m==`number`&&m>25,_=String(d),v;t[9]!==m||t[10]!==g?(v=g?(0,$.jsx)(Mc,{percentage:m}):(0,$.jsx)(h,{className:`h-4 w-4`}),t[9]=m,t[10]=g,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[12]=y):y=t[12];let b;t[13]===v?b=t[14]:(b=(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[v,y]}),t[13]=v,t[14]=b);let x;return t[15]!==c||t[16]!==o||t[17]!==_||t[18]!==b||t[19]!==n?(x=(0,$.jsx)(kc,{threadId:n,currentConversationId:o,initialBreakdown:c,refreshKey:_,children:b}),t[15]=c,t[16]=o,t[17]=_,t[18]=b,t[19]=n,t[20]=x):x=t[20],x}var Pc=`[gitops-timing]`;function Fc(e){let t=[],n=performance.now();async function r(n,r){let i=performance.now();try{return await r()}finally{let r=Math.round(performance.now()-i);t.push({step:n,ms:r}),console.log(`${Pc} ${e} step=${n} ${r}ms`)}}function i(n,r,i){t.push({step:n,ms:r}),console.log(`${Pc} ${e} step=${n} ${r}ms${i?` ${i}`:``}`)}function a(r){let i=Math.round(performance.now()-n),a=t.reduce((e,t)=>t.ms>=e.ms?t:e,{step:`none`,ms:0}),o=t.map(e=>`${e.step}:${e.ms}`).join(` `);console.log(`${Pc} ${e} summary total=${i}ms slowest=${a.step}@${a.ms}ms breakdown=[${o}]${r?` ${r}`:``}`)}return{step:r,record:i,summary:a}}var Ic=3e4,Lc={hasChanges:!1,changedFilesCount:0,hasUnpushedCommits:!1,currentBranch:``,hasRemoteBranch:!1,isOnGitHub:!1,remoteUrl:``,canCreateRepo:!1,repoUrl:void 0,status:`Up to date`,defaultBranch:null,prExists:!1,prUrl:void 0,prState:void 0,commitsAheadOfDefault:!1},Rc=new Map,zc=new Map;function Bc(e,t){let n=Rc.get(e);if(n)for(let e of n)e(t)}function Vc(e,t){let n=Rc.get(e);return n||(n=new Set,Rc.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Rc.delete(e)}}function Hc(e){return`unified-git-status-${e}`}function Uc(e){return Te.getSync(Hc(e))}function Wc(e){let[t,n]=(0,Y.useState)(Lc),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(void 0),o=(0,Y.useRef)(0),s=(0,Y.useCallback)(e=>{(0,Y.startTransition)(()=>{n(e)})},[]),c=(0,Y.useRef)(s);c.current=s;let l=(0,Y.useCallback)(async(t=!1)=>{if(!e)return;let n=++o.current,r=Fc(`hook fetch thread=${e} force=${t}`),a=setTimeout(()=>{o.current===n&&i(!0)},100);try{let i=Hc(e),a=performance.now(),c=Uc(e);r.record(`local-cache-check`,Math.round(performance.now()-a),`result=${c?`hit`:`miss`}`),t&&(Te.invalidate(i),r.record(`invalidate-local-cache`,0));let l=await r.step(`ttl-cache-get`,()=>Te.get(i,()=>k(e,t,!1),Ic));if(o.current!==n){r.summary(`stale-request`);return}await r.step(`update-state`,async()=>{s(l),Bc(e,l)}),r.summary(`branch=${l.currentBranch} changes=${l.changedFilesCount} prExists=${l.prExists}`)}catch(e){if(o.current!==n)return;console.error(`Failed to fetch unified git status:`,e),r.summary(`error`)}finally{clearTimeout(a),o.current===n&&i(!1)}},[e,s]),u=(0,Y.useRef)(l);return u.current=l,(0,Y.useEffect)(()=>{if(e)return Vc(e,e=>{c.current(e)})},[e]),(0,Y.useEffect)(()=>{if(!e)return;let t=e;function n(){document.visibilityState===`visible`&&(Te.invalidate(Hc(t)),u.current(!1))}return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[e]),(0,Y.useEffect)(()=>{if(o.current+=1,i(!1),!e){a.current=void 0,(0,Y.startTransition)(()=>{n(Lc)});return}let t=a.current!==e,r=Uc(e);t&&(console.log(`[gitops-timing] hook thread changed ${a.current??`none`} -> ${e}`),a.current=e,Te.invalidate(Hc(e))),(0,Y.startTransition)(()=>{n(r??Lc)}),console.log(r?`[gitops-timing] hook load thread=${e} local cache=hit`:`[gitops-timing] hook load thread=${e} local cache=miss`);let s=e,l=!1;function d(){if(l)return;let e=zc.get(s);if(e){console.log(`[gitops-timing] hook initial fetch already in flight thread=${s}`),e.then(()=>{if(l)return;let e=Uc(s);e&&c.current(e)});return}console.log(`[gitops-timing] hook starting initial fetch thread=${s}`);let t=u.current(!1).finally(()=>{console.log(`[gitops-timing] hook initial fetch settled thread=${s}`),zc.delete(s)});zc.set(s,t)}return d(),()=>{l=!0}},[e]),{hasChanges:t.hasChanges,changedFilesCount:t.changedFilesCount,hasUnpushedCommits:t.hasUnpushedCommits,hasRemoteBranch:t.hasRemoteBranch,currentBranch:t.currentBranch,isOnGitHub:t.isOnGitHub,remoteUrl:t.remoteUrl,canCreateRepo:t.canCreateRepo,repoUrl:t.repoUrl,status:t.status,defaultBranch:t.defaultBranch,prExists:t.prExists,prUrl:t.prUrl,prState:t.prState,commitsAheadOfDefault:t.commitsAheadOfDefault,isRefreshing:r,fetchUnifiedStatus:l}}var Gc=(0,Y.createContext)(void 0);function Kc(e){let t=(0,X.c)(8),{threadId:n,fetchUnifiedStatus:r}=e,i=si(),a=Q(Yc),o=Q(Jc),s=Q(qc),c,l;return t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==a||t[4]!==s||t[5]!==n?(c=()=>{if(!(!n||n!==s)&&!a&&o.includes(n)){let e=setTimeout(()=>{r(!0),i({type:Z.ClearThreadCompleted,threadId:n})},1e3);return()=>clearTimeout(e)}},l=[n,s,a,o,r,i],t[0]=o,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=n,t[6]=c,t[7]=l):(c=t[6],l=t[7]),(0,Y.useEffect)(c,l),null}function qc(e){return e.selectedThreadId}function Jc(e){return e.completedThreadIds}function Yc(e){return e.isStreaming}function Xc(e){let t=(0,X.c)(7),{threadId:n,children:r}=e,i=Wc(n),a;t[0]!==n||t[1]!==i.fetchUnifiedStatus?(a=(0,$.jsx)(Kc,{threadId:n,fetchUnifiedStatus:i.fetchUnifiedStatus}),t[0]=n,t[1]=i.fetchUnifiedStatus,t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==a||t[5]!==i?(o=(0,$.jsxs)(Gc.Provider,{value:i,children:[a,r]}),t[3]=r,t[4]=a,t[5]=i,t[6]=o):o=t[6],o}function Zc(){let e=(0,Y.useContext)(Gc);if(e===void 0)throw Error(`useGitStatus must be used within a GitStatusProvider`);return e}var Qc=`panda.koala.penguin.bunny.kitten.puppy.hamster.otter.hedgehog.sloth.dolphin.owl.fox.deer.koala.walrus.bouncy.sparkly.fluffy.jolly.zesty.peppy.snappy.perky.breezy.chirpy.dizzy.fizzy.glossy.groggy.loopy.quirky.umbrella.taco.pickle.waffle.bubble.puzzle.rocket.tornado.volcano.rainbow.diamond.crystal.lantern.treasure.whisper.echo.boing.splat.whoosh.crunch.splash.jingle.wiggle.giggle.scramble.tumble.fumble.jumble.rumble.mumble.stumble.hustle.castle.island.mountain.forest.meadow.lagoon.canyon.geyser.oasis.glacier.waterfall.volcano.tundra.savanna.jungle.desert.magic.dream.wonder.spark.glow.shimmer.twinkle.radiance.harmony.melody.rhythm.symphony.adventure.journey.quest.odyssey`.split(`.`);function $c(){return Qc[Math.floor(Math.random()*Qc.length)]??`branch`}function el(){let e=$c(),t=$c();for(;t===e;)t=$c();return`${e}-${t}`}function tl(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(`main`),h=Zc();(0,Y.useEffect)(()=>{if(!s){u(``);return}u(el())},[s]),(0,Y.useEffect)(()=>{h.defaultBranch&&m(h.defaultBranch)},[h.defaultBranch]);async function g(){if(!(!e||r)){i(!0);try{n((await Xt(e)).branches)}catch{n([])}finally{i(!1)}}}async function _(t){if(!(!e||t===h.currentBranch)){o(!0);try{await Ne(e,t),await h.fetchUnifiedStatus(!0),wi({title:`Switched to branch "${t}"`})}catch(e){wi({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}function v(){c(!0)}async function y(){if(!(!e||!l.trim()||d)){f(!0);try{let t=await de(e,p,l);c(!1),await g(),await h.fetchUnifiedStatus(!0),wi({title:`Branch created`,description:`Created branch "${t.branchName}" from ${p}`})}catch(e){wi({title:`Failed to create branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{f(!1)}}}return{currentBranch:h.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:g,checkoutBranch:_,fetchUnifiedStatus:h.fetchUnifiedStatus,isCreateDialogOpen:s,setIsCreateDialogOpen:c,newBranchName:l,setNewBranchName:u,isCreatingBranch:d,createBranch:y,openCreateBranchDialog:v,defaultBranch:p}}function nl({threadId:e,messages:t=[]}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(null),o=tl(e);return(0,Y.useEffect)(()=>{e&&an(e).then(a).catch(()=>{})},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,$.jsx)(Sc,{currentBranch:o.currentBranch,availableBranches:o.availableBranches,isLoadingBranches:o.isLoadingBranches,isCheckingOut:o.isCheckingOut,onLoadBranches:o.loadBranches,onCheckoutBranch:o.checkoutBranch,onCreateBranch:o.openCreateBranchDialog}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wc,{collapsed:!1}),(0,$.jsx)(Nc,{threadId:e,messages:t}),e&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||n)){r(!0);try{let t=await an(e);await navigator.clipboard.writeText(t)}finally{r(!1)}}},disabled:n,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(sn,{className:`h-4 w-4`})})}),(0,$.jsxs)(U,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),i&&(0,$.jsx)(`div`,{className:W(J.compact,`opacity-70`),children:i})]})]})]})]}),(0,$.jsx)(Cc,{open:o.isCreateDialogOpen,onOpenChange:o.setIsCreateDialogOpen,branchName:o.newBranchName,onBranchNameChange:o.setNewBranchName,isLoading:o.isCreatingBranch,onCreateBranch:()=>void o.createBranch()})]})}var rl=40,il=4,al=10,ol=2*Math.PI*al;function sl(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(ll),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,$.jsx)(`p`,{className:J.compact,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(cl),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:W(J.compact,`pt-1`),children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function cl(e){return(0,$.jsxs)(`div`,{className:W(J.caption,`flex items-start gap-2`),children:[e.status===`done`?(0,$.jsx)(Oe,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(pe,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(mn,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function ll(e){return e.status===`done`}function ul(e){let t=(0,X.c)(3),{completedCount:n,totalCount:r}=e,i=ol*(1-(r>0?n/r:0)),a=rl/2,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:a,cy:a,r:al,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:il}),t[0]=o):o=t[0];let s;return t[1]===i?s=t[2]:(s=(0,$.jsxs)(`svg`,{"aria-hidden":`true`,width:rl,height:rl,viewBox:`0 0 ${rl} ${rl}`,className:`size-10 shrink-0`,children:[o,(0,$.jsx)(`circle`,{cx:a,cy:a,r:al,fill:`none`,stroke:`currentColor`,strokeWidth:il,strokeDasharray:ol,strokeDashoffset:i,strokeLinecap:`round`,transform:`rotate(-90 ${a} ${a})`,className:`transition-[stroke-dashoffset] duration-300 ease-out`})]}),t[1]=i,t[2]=s),s}function dl(){let e=(0,X.c)(25),{todos:t}=(0,Y.useContext)(uo),[n,i]=(0,Y.useState)(!1),a;e[0]===t?a=e[1]:(a=t.filter(fl),e[0]=t,e[1]=a);let o=a.length,s=t.length-o,c=`${o} of ${t.length} complete`;if(s<=0)return null;let l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>i(!0),e[2]=l):l=e[2];let u;e[3]!==o||e[4]!==t.length?(u=(0,$.jsx)(ul,{completedCount:o,totalCount:t.length}),e[3]=o,e[4]=t.length,e[5]=u):u=e[5];let d;e[6]===c?d=e[7]:(d=(0,$.jsx)(`span`,{className:`sr-only`,children:c}),e[6]=c,e[7]=d);let f;e[8]!==u||e[9]!==d?(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`ml-2 rounded-full [&_svg]:!size-10`,onClick:l,children:[u,d]})}),e[8]=u,e[9]=d,e[10]=f):f=e[10];let p;e[11]===c?p=e[12]:(p=(0,$.jsx)(U,{children:c}),e[11]=c,e[12]=p);let m;e[13]!==f||e[14]!==p?(m=(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[f,p]})}),e[13]=f,e[14]=p,e[15]=m):m=e[15];let h;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:`Agent Todos`})}),e[16]=h):h=e[16];let g;e[17]===t?g=e[18]:(g=(0,$.jsxs)(ut,{className:`max-w-md`,children:[h,(0,$.jsx)(sl,{todos:t})]}),e[17]=t,e[18]=g);let _;e[19]!==n||e[20]!==g?(_=(0,$.jsx)(mt,{open:n,onOpenChange:i,children:g}),e[19]=n,e[20]=g,e[21]=_):_=e[21];let v;return e[22]!==m||e[23]!==_?(v=(0,$.jsxs)($.Fragment,{children:[m,_]}),e[22]=m,e[23]=_,e[24]=v):v=e[24],v}function fl(e){return e.status===`done`}function pl(e){let t=(0,X.c)(25),{tasks:n,disabled:r,onSelectTask:i,onRemoveTask:a}=e,o=r===void 0?!1:r,[s,c]=(0,Y.useState)(!1),l=n.length,u=`${l} Pending ${l===1?`Task`:`Tasks`}`;if(l===0)return null;let d;t[0]===i?d=t[1]:(d=function(e){i(e),c(!1)},t[0]=i,t[1]=d);let f=d,p;t[2]!==a||t[3]!==l?(p=function(e){a(e),l===1&&c(!1)},t[2]=a,t[3]=l,t[4]=p):p=t[4];let m=p,h;t[5]===u?h=t[6]:(h=(0,$.jsx)(`span`,{children:u}),t[5]=u,t[6]=h);let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}),t[7]=g):g=t[7];let _;t[8]!==o||t[9]!==h?(_=(0,$.jsx)(Za,{asChild:!0,children:(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`gap-2 bg-background`,disabled:o,children:[h,g]})}),t[8]=o,t[9]=h,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:W(J.compact,J.label,`px-2 pb-1 pt-1 text-muted-foreground`),children:`Tasks`}),t[11]=v):v=t[11];let y;if(t[12]!==m||t[13]!==f||t[14]!==n){let e;t[16]!==m||t[17]!==f?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-transparent px-2 py-2 hover:bg-accent`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-2 text-left`,onClick:()=>f(e),children:[(0,$.jsx)(ke,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:W(J.body,`line-clamp-3 text-foreground`),children:e.content})]}),(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>m(e.id),children:[(0,$.jsx)(un,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove task`})]})]},e.id),t[16]=m,t[17]=f,t[18]=e):e=t[18],y=n.map(e),t[12]=m,t[13]=f,t[14]=n,t[15]=y}else y=t[15];let b;t[19]===y?b=t[20]:(b=(0,$.jsx)(Qa,{align:`start`,className:`w-96 p-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[v,y]})}),t[19]=y,t[20]=b);let x;return t[21]!==s||t[22]!==_||t[23]!==b?(x=(0,$.jsxs)(Xa,{open:s,onOpenChange:c,children:[_,b]}),t[21]=s,t[22]=_,t[23]=b,t[24]=x):x=t[24],x}var ml=(0,Y.lazy)(()=>ir(()=>import(`./git-ops-button-B6rEla5u.js`).then(e=>({default:e.GitOpsButton})),__vite__mapDeps([2,1,3,4,5])));function hl(e){let t=(0,X.c)(25),{threadId:n,projectId:r,messages:i,userTasks:a,effectiveIsStreaming:o,isCreatingProject:s,onNewChat:c,onSelectUserTask:l,onRemoveUserTask:u}=e,d=i.length>0,{hasChanges:f,changedFilesCount:p}=Zc(),{setActiveMainTab:m}=ca();if(!d&&!f&&a.length===0&&!(n&&r))return null;let h;t[0]!==d||t[1]!==c?(h=d&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:c,children:[(0,$.jsx)(D,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),t[0]=d,t[1]=c,t[2]=h):h=t[2];let g;t[3]!==p||t[4]!==f||t[5]!==m?(g=f&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>m(`review`),children:[(0,$.jsx)(Ge,{className:`h-4 w-4 shrink-0`}),p,` `,p===1?`File`:`Files`,` Changed`]}),t[3]=p,t[4]=f,t[5]=m,t[6]=g):g=t[6];let _;t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==l||t[11]!==n||t[12]!==a?(_=a.length>0&&(0,$.jsx)(pl,{tasks:a,disabled:o||!n&&!s,onSelectTask:l,onRemoveTask:u}),t[7]=o,t[8]=s,t[9]=u,t[10]=l,t[11]=n,t[12]=a,t[13]=_):_=t[13];let v;t[14]!==r||t[15]!==n?(v=n&&r&&(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(ml,{projectId:r,threadId:n},n)}),t[14]=r,t[15]=n,t[16]=v):v=t[16];let y;t[17]===d?y=t[18]:(y=d&&(0,$.jsx)(dl,{}),t[17]=d,t[18]=y);let b;return t[19]!==h||t[20]!==g||t[21]!==_||t[22]!==v||t[23]!==y?(b=(0,$.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex flex-wrap items-center gap-2`,children:[h,g,_,v,y]}),t[19]=h,t[20]=g,t[21]=_,t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function gl(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(hl,{...e}),t[0]=e,t[1]=n),n}function _l(e){let t=(0,X.c)(3),{threadId:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(Xc,{threadId:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var vl=new Set,yl=new Map,bl=5e3;function xl(e){vl.add(e);let t=yl.get(e);t&&clearTimeout(t),yl.set(e,setTimeout(()=>{vl.delete(e),yl.delete(e)},bl))}function Sl(e){return vl.has(e)}function Cl(e){return e.filter(e=>!vl.has(e))}function wl(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&Jo(e.id,e.input.code,t)}catch{}}function Tl(e){if(!(!e.includes(`"tool_use"`)||!e.includes(`"bash"`)))try{let t=JSON.parse(e.trim());if(!Array.isArray(t))return;for(let e of t)e?.type===`tool_use`&&e?.id&&typeof e.name==`string`&&e.name.toLowerCase()===`bash`&&typeof e.input?.command==`string`&&Aa(e.id,e.input.command)}catch{}}function El(e){if(!(!e.includes(`"tool-result"`)||!e.includes(`"bash"`)))try{let t=JSON.parse(e.trim());if(!Array.isArray(t))return;for(let e of t)e?.type===`tool-result`&&e?.toolCallId&&typeof e.toolName==`string`&&e.toolName.toLowerCase()===`bash`&&ja(e.toolCallId)}catch{}}function Dl(e,t,n){let r={type:`thinking`,content:kl,model:n};e({type:Z.SetStreaming,isStreaming:!0,threadId:t}),e({type:Z.SetStreamModel,model:n,threadId:t}),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:r.content??``,segments:Ur([],`thinking`,r.content??``),threadId:t})}var Ol=/^\/compact(?:\s+(.*))?$/i,kl=`[Compact] Compaction in progress...`;function Al(){let e=si(),{toast:t}=Ti(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(new Map),u=Q(e=>e.selectedThreadId),d=Q(e=>e.selectedProjectId),f=Q(e=>e.messages),m=Q(e=>e.queuedChatMessages),h=Q(e=>e.isStreaming),_=Q(e=>e.processingThreadIds),v=Q(e=>e.streamingModel),y=Q(e=>e.threadStreamingStates),b=Q(e=>e.pendingChatMessage);c.current=u;let x=(0,Y.useCallback)((t,n,r)=>{if(l.current.get(t)!==r){l.current.has(t)||(xl(t),e({type:Z.ResetStream,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t}));return}if(l.current.delete(t),e({type:Z.ClearToolCallProgress}),r.stopHandled)return;xl(t);let i=Xr(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};e({type:Z.AddMessage,message:i,threadId:t}),e({type:Z.ResetStream,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t});return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};async function o(){for(let n=0;n<4;n++){n>0&&await new Promise(e=>setTimeout(e,150*n));try{let n=await dt(t);if(t===c.current){e({type:Z.SetMessages,messages:n.messages});return}}catch(e){console.error(`Failed to reload chat history after stream:`,e);break}}e({type:Z.AddMessage,message:a,threadId:t})}o(),e({type:Z.ResetStream,threadId:t}),e({type:Z.MarkThreadCompleted,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t})},[e]),S=(0,Y.useCallback)(()=>{if(!u)return;s(u);let t=l.current.get(u);t&&(t.stopHandled=!0,t.controller.abort(),t.cancel?.(),l.current.delete(u)),g(u);let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:v||`default`,isThinking:!1};e({type:Z.AddMessage,message:n,threadId:u}),e({type:Z.ClearToolCallProgress}),e({type:Z.ResetStream,threadId:u}),e({type:Z.MarkThreadCompleted,threadId:u}),e({type:Z.RemoveProcessingThread,threadId:u}),xl(u)},[u,e,v]);(0,Y.useEffect)(()=>()=>{for(let[t,n]of l.current.entries())n.controller.abort(),n.cancel?.(),e({type:Z.ResetStream,threadId:t});l.current.clear()},[e]);let C=(0,Y.useCallback)((t,n,i)=>{let o=l.current.get(t);o&&(o.controller.abort(),o.cancel?.());let s=new AbortController,u={controller:s,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return l.current.set(t,u),e({type:Z.ResetStream,threadId:t}),e({type:Z.SetStreaming,isStreaming:!0,threadId:t}),n(s.signal).then(n=>{if(!n||s.signal.aborted){x(t,i,u);return}u.cancel=Rt(n,n=>{if(e({type:Z.IncrementStreamEventCount,threadId:t}),n.type===`error`){let e=n.content||`Unknown error occurred`;u.error=e,t===c.current&&r(e);return}if(n.type!==`message`){if(n.type===`long_running_confirmation`){let r=n.prompt;if(!r)return;u.segments=Gr(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`shell_permission`){let r=n.shellPermission;if(!r)return;u.segments=Kr(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`web_fetch_permission`){let r=n.webFetchPermission;if(!r)return;u.segments=qr(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&e({type:Z.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.type===`tool_execution_update`){n.toolCallId&&n.executionOutput!==void 0&&e({type:Z.UpdateToolExecutionOutput,toolCallId:n.toolCallId,toolName:n.toolName,executionOutput:n.executionOutput});return}if(n.model&&e({type:Z.SetStreamModel,model:n.model,threadId:t}),n.type===`thinking`||n.isThinking){let r=n.content??``;wl(r,t),u.assistantThinking+=r,u.segments=Ur(u.segments,`thinking`,r),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:r,segments:u.segments,threadId:t})}else if(n.type===`result`){u.hasStructuredContent=!0;let r=n.content??``;u.assistantMessage=r,u.segments=Wr(u.segments,r),e({type:Z.SetStreamContent,content:r,threadId:t}),typeof r==`string`&&wl(r,t)}else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=Ur(u.segments,`content`,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:r,segments:u.segments,threadId:t})}}},()=>{x(t,i,u)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){x(t,i,u);return}u.error=e,t===c.current&&r(e)},n=>{if(e({type:Z.IncrementStreamEventCount,threadId:t}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){u.assistantThinking+=i,u.segments=Ur(u.segments,`thinking`,i),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:i,segments:u.segments,threadId:t});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(u.hasStructuredContent=!0,u.assistantMessage=i,u.segments=Wr(u.segments,i),e({type:Z.SetStreamContent,content:i,threadId:t}),wl(i,t)):(u.assistantMessage+=i,u.segments=Ur(u.segments,`content`,i),e({type:Z.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:t}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(Tl(i),El(i),u.assistantMessage+=i,u.segments=Ur(u.segments,`content`,i),e({type:Z.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:t}))}})}).catch(n=>{if(l.current.delete(t),n instanceof Error&&n.name===`AbortError`){e({type:Z.ResetStream,threadId:t});return}if(n instanceof p){e({type:Z.ResetStream,threadId:t}),a(!0);return}if(n instanceof Error&&n.message.includes(`not currently processing`)){e({type:Z.ResetStream,threadId:t});return}let i=n instanceof Error?n.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;t===c.current&&r(i),console.error(`Failed to subscribe to chat stream:`,n),e({type:Z.ResetStream,threadId:t})}),s},[e,x]);(0,Y.useEffect)(()=>{for(let e of _)l.current.has(e)||y[e]?.isStreaming||Sl(e)||C(e,t=>se(e,t),`default`)},[C,_,y]);let T=(0,Y.useCallback)(async(n,i,a,o,c,l,p)=>{if(!u)return;let m=u;r(null),s(null);let g=n.trim().match(Ol);if(g){if(f.filter(e=>e.sender===`agent`).length<2){t({title:`Nothing to compact`,description:`Start a conversation with at least two exchanges first.`});return}if(_.includes(m)||h&&u===m){t({title:`Agent is busy`,description:`Wait for the agent to finish before compacting.`});return}let n=g[1]?.trim();Dl(e,m,i);try{let r=await ae(m,{model:i,provider:o,instructions:n});e({type:Z.SetMessages,messages:r.messages}),e({type:Z.ResetStream,threadId:m}),t({title:`Conversation compacted`,description:`${r.messagesBefore} messages → ${r.messagesAfter} summary`})}catch(n){e({type:Z.ResetStream,threadId:m}),t({title:`Compaction failed`,description:n instanceof Error?n.message:`Failed to compact conversation`,variant:`destructive`})}return}let v=`msg-${Date.now()}`,y;try{let e=await fe(m,v);e.success&&e.stashed&&e.checkpointRef&&(y=e.checkpointRef)}catch{}let b={messageId:v,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:a.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:y};e({type:Z.AddMessage,message:b,threadId:m});let x=n.trim().replace(/\n/g,` `).slice(0,100);if(d&&(w(m,{title:x}).catch(e=>{console.error(`Failed to update thread title:`,e)}),e({type:Z.UpdateThreadTitle,projectId:d,threadId:m,title:x})),l){let t=o??void 0;if(!t&&typeof i==`string`){let e=i.split(/[:/]/)[0]?.trim();e&&(t=e)}if(!t){let t={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};e({type:Z.AddMessage,message:t,threadId:m}),e({type:Z.ResetStream,threadId:m});return}e({type:Z.SetStreaming,isStreaming:!0,threadId:m});try{let r=await Et(n,i,t,m),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};e({type:Z.AddMessage,message:a,threadId:m})}catch(t){let n=t instanceof Error?t.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};e({type:Z.AddMessage,message:r,threadId:m})}finally{e({type:Z.ResetStream,threadId:m})}return}C(m,e=>be(m,n,i,a,e,o,c,p,y),i)},[u,d,e,C,f,_,h,t]);(0,Y.useEffect)(()=>{let t=b;if(!t||h||t.threadId!==u)return;let n=setTimeout(()=>{e({type:Z.ClearPendingChatMessage}),T(t.message,t.model,[],t.provider)},100);return()=>clearTimeout(n)},[b,h,u,e,T]);let E=(0,Y.useMemo)(()=>u?m.filter(e=>e.threadId===u):[],[u,m]),D=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{if(h||!u||E.length===0||D.current)return;let[t]=E;D.current=!0,e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t.id});let n=setTimeout(()=>{T(t.message,t.model,t.attachments,t.provider,t.planMode,t.imageMode,t.ralphMode),D.current=!1},0);return()=>{clearTimeout(n),D.current=!1}},[e,T,h,E,u]),{error:n,setError:r,handleSend:T,handleStop:S,isStreaming:h,selectedThreadId:u,queuedMessagesForThread:E,handleRemoveQueuedMessage:(0,Y.useCallback)(t=>{let n=E.find(e=>e.id===t);e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t}),!(!n||h||f.length>0||!u)&&T(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[e,T,h,f.length,E,u]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function jl(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Wn(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(mr,{children:[(0,$.jsx)(ur,{children:`Balance empty`}),(0,$.jsx)(dr,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(gr,{children:[o,(0,$.jsx)(fr,{children:(0,$.jsx)(G,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(pr,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ml(e){let t=(0,X.c)(4),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,a;return t[2]===i?a=t[3]:(a=(0,$.jsx)(Nl,{messages:i}),t[2]=i,t[3]=a),a}function Nl(e){let t=(0,X.c)(55),{messages:n}=e,r=si(),i=Q(Ll),a=Q(Il),o=Q(Fl),s=Q(Pl),{handleSend:c,handleStop:l,isStreaming:u,queuedMessagesForThread:d,handleRemoveQueuedMessage:f,showEmptyBalanceDialog:p,setShowEmptyBalanceDialog:m}=Al(),h=s?.threadId===a,g=u||h,{toast:_}=Ti(),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=(0,Y.useState)(v),x,S;t[1]!==a||t[2]!==_?(x=()=>{if(!a){b([]);return}let e=!1;return(async function(){try{let t=await Le(a);e||b(t)}catch(t){e||(console.error(`Failed to load user tasks:`,t),_({title:`Could not load tasks`,description:`Failed to load UserTasks for this thread.`,variant:`destructive`}))}})(),()=>{e=!0}},S=[a,_],t[1]=a,t[2]=_,t[3]=x,t[4]=S):(x=t[3],S=t[4]),(0,Y.useEffect)(x,S);let C;t[5]!==r||t[6]!==a?(C=async()=>{if(a)try{let e=await ee(a);r({type:Z.ClearMessages}),console.log(`New conversation started:`,e),setTimeout(()=>{(async()=>{try{let e=await dt(a);r({type:Z.SetMessages,messages:e.messages})}catch(e){console.error(`Failed to refresh chat history after starting new chat:`,e)}})()},0)}catch(e){console.error(`Failed to start new chat:`,e)}},t[5]=r,t[6]=a,t[7]=C):C=t[7];let w=C,T;t[8]!==a||t[9]!==_?(T=async function(e){if(a)try{await nt(a,e),b(t=>t.filter(t=>t.id!==e))}catch(e){console.error(`Failed to delete user task:`,e),_({title:`Could not remove task`,description:`Failed to delete the selected task.`,variant:`destructive`})}},t[8]=a,t[9]=_,t[10]=T):T=t[10];let E=T,D;t[11]!==r||t[12]!==a?(D=function(e){a&&r({type:Z.SetChatInputDraft,threadId:a,draft:e.content})},t[11]=r,t[12]=a,t[13]=D):D=t[13];let O=D,k;t[14]===m?k=t[15]:(k=()=>m(!1),t[14]=m,t[15]=k);let A;t[16]!==p||t[17]!==k?(A=(0,$.jsx)(jl,{open:p,onClose:k}),t[16]=p,t[17]=k,t[18]=A):A=t[18];let j=a??`no-thread`,M=a??void 0,N;t[19]!==g||t[20]!==w||t[21]!==E||t[22]!==O||t[23]!==i||t[24]!==n||t[25]!==o||t[26]!==a||t[27]!==y?(N=a&&(o||n.length>0||y.length>0)&&(0,$.jsx)(gl,{threadId:a,projectId:o??``,messages:n,userTasks:y,effectiveIsStreaming:g,isCreatingProject:i,onNewChat:()=>{w()},onSelectUserTask:O,onRemoveUserTask:e=>{E(e)}}),t[19]=g,t[20]=w,t[21]=E,t[22]=O,t[23]=i,t[24]=n,t[25]=o,t[26]=a,t[27]=y,t[28]=N):N=t[28];let P=!a&&!i,F;t[29]===E?F=t[30]:(F=e=>{E(e.id)},t[29]=E,t[30]=F);let I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{b(t=>[...t,e])},t[31]=I):I=t[31];let L;t[32]!==g||t[33]!==f||t[34]!==c||t[35]!==l||t[36]!==d||t[37]!==P||t[38]!==F||t[39]!==y?(L=(0,$.jsx)(pc,{onSend:c,onStop:l,isStreaming:g,disabled:P,initialValue:``,queuedMessages:d,onRemoveQueuedMessage:f,isOverlay:!1,userTasks:y,onMatchedUserTaskSend:F,onUserTaskCreated:I}),t[32]=g,t[33]=f,t[34]=c,t[35]=l,t[36]=d,t[37]=P,t[38]=F,t[39]=y,t[40]=L):L=t[40];let R;t[41]!==N||t[42]!==L?(R=(0,$.jsxs)(`div`,{className:`relative`,children:[N,L]}),t[41]=N,t[42]=L,t[43]=R):R=t[43];let z=a??void 0,B;t[44]!==n||t[45]!==z?(B=(0,$.jsx)(nl,{threadId:z,messages:n}),t[44]=n,t[45]=z,t[46]=B):B=t[46];let V;t[47]!==M||t[48]!==R||t[49]!==B||t[50]!==j?(V=(0,$.jsx)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:(0,$.jsxs)(_l,{threadId:M,children:[R,B]},j)}),t[47]=M,t[48]=R,t[49]=B,t[50]=j,t[51]=V):V=t[51];let te;return t[52]!==V||t[53]!==A?(te=(0,$.jsxs)($.Fragment,{children:[A,V]}),t[52]=V,t[53]=A,t[54]=te):te=t[54],te}function Pl(e){return e.pendingChatMessage}function Fl(e){return e.selectedProjectId}function Il(e){return e.selectedThreadId}function Ll(e){return e.isCreatingProject}function Rl(){let e=(0,X.c)(7),t=si(),n=Q(Bl),r=Q(zl),i;e[0]!==t||e[1]!==n?(i=()=>{if(!n)return;let e=n,r=!1;return(async function(){try{let n=await dt(e);r||t({type:Z.SetMessages,messages:n.messages})}catch(e){console.error(`Failed to load chat history:`,e),r||t({type:Z.SetMessages,messages:[]})}})(),()=>{r=!0}},e[0]=t,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==t||e[4]!==r||e[5]!==n?(a=[n,r,t],e[3]=t,e[4]=r,e[5]=n,e[6]=a):a=e[6],(0,Y.useEffect)(i,a)}function zl(e){return e.selectedProjectId}function Bl(e){return e.selectedThreadId}async function Vl(e){return N(`api/projects/${S(e)}/todos`)}async function Hl(e,t){return Ie(`api/projects/${S(e)}/todos`,{description:t})}async function Ul(e,t,n){return O(`api/projects/${S(e)}/todos/${S(t)}`,n)}async function Wl(e,t){await je(`api/projects/${S(e)}/todos/${S(t)}`)}var Gl={Ready:[{label:`Plan`,target:`Plan`},{label:`Build`,target:`Build`}],Plan:[{label:`Build`,target:`Build`}],Build:[{label:`Test`,target:`Test`},{label:`Review`,target:`Review`}],Test:[{label:`Review`,target:`Review`}],Review:[{label:`Done`,target:`Done`}],Done:[]};function Kl({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Y.useState)(!1),c=Gl[e.status]??[];function l(t){t.stopPropagation(),e.threadId&&a&&a(e.threadId)}async function u(r,a){r.stopPropagation(),s(!0);try{i?await i(e,a):n(await Ul(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:W(`rounded-lg border bg-card p-3 shadow-sm space-y-2 cursor-pointer hover:bg-accent/50 transition-colors`,e.working&&`border-primary/50 bg-primary/5`),onClick:t=>{t.stopPropagation(),r(e)},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:W(J.label,`leading-tight`),children:e.title}),e.working&&(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin text-primary shrink-0`})]}),(c.length>0||e.status!==`Ready`&&e.threadId&&a)&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center pt-1`,children:[c.map(t=>(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-base`,onClick:e=>void u(e,t.target),disabled:o||e.working,children:t.label})}),(0,$.jsx)(U,{side:`top`,children:e.status===`Ready`&&t.target===`Build`?`Implement this on a new branch of the project`:t.target===`Review`?`Review the code changes for this task`:t.target===`Done`?`Mark the task as done`:t.label})]},t.target)),e.status!==`Ready`&&e.threadId&&a&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(vt,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(U,{side:`right`,children:`Open thread`})]})]})]})}var ql=`Please analyze this task and create a detailed implementation plan.
|
|
46
|
+
|
|
47
|
+
Task description:
|
|
48
|
+
{description}`,Jl="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Yl=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Xl=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
|
|
49
|
+
Directions:
|
|
50
|
+
Carefully read through the list of code changes creating a todo list of code to review.
|
|
51
|
+
Analyze the code structure, variable names, functions, and logic flow
|
|
52
|
+
Look for any syntax errors, bugs, or inefficiencies
|
|
53
|
+
Consider best practices for the specific programming language used
|
|
54
|
+
Provide clear and constructive feedback on areas that could be improved
|
|
55
|
+
If applicable, include examples of how to refactor problematic code
|
|
56
|
+
Offer praise for portions of the code that are well-written and follow best practices
|
|
57
|
+
|
|
58
|
+
Task description:
|
|
59
|
+
{description}`,Zl={plan:ql,test:Yl,review:Xl},Ql={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function $l(e,t){let n=e?.[Ql[t]];return n&&n.trim()?n:Zl[t]}function eu(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Jl.replace(/\{todoId\}/g,n)),i}var tu=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],nu={Ready:`border-t-slate-400`,Plan:`border-t-blue-400`,Build:`border-t-orange-400`,Test:`border-t-yellow-400`,Review:`border-t-purple-400`,Done:`border-t-green-400`};async function ru(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a=null;try{for(;;){let{done:e,value:o}=await n.read();if(e)break;i+=r.decode(o,{stream:!0});let s=i.split(`
|
|
60
|
+
`);i=s.pop()??``;for(let e of s){let n=e.trim();if(n)try{let e=JSON.parse(n);e.type===`progress`&&typeof e.threadId==`string`&&!a&&(a=e.threadId,t(a))}catch{}}}}catch{}return a}async function iu(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function au(e){let t=e.getReader(),n=new TextDecoder,r=``,i=``;try{for(;;){let{done:e,value:a}=await t.read();if(e)break;r+=n.decode(a,{stream:!0});let o=r.split(`
|
|
61
|
+
`);r=o.pop()??``;for(let e of o){let t=e.trim();if(t)try{let e=JSON.parse(t);e.type===`token`&&e.content?i+=e.content:e.type===`result`&&e.content&&(i=e.content)}catch{}}}}catch{}return i}async function ou(e){let t=await Vl(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];return await Promise.all(n.map(async t=>{try{await Me(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ul(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n)}}})),r}function su(e,t){return`project-todos:${e}:${t}`}function cu({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r,initialTodos:i}){let a=si(),o=Q(e=>e.selectedThreadId),s=Q(e=>e.projectModelSelections),c=Q(e=>e.projects),[l,u]=(0,Y.useState)(i),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(``),[C,T]=(0,Y.useState)(!1),[E,O]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!l.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Vl(e);u(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[l,e]),(0,Y.useEffect)(()=>{t&&m(``)},[t]);function k(e){m(e.description),f({todo:e})}function A(){f(null),m(``)}async function j(){if(p.trim()){g(!0);try{let t=await Hl(e,p);u(e=>[...e,t]),n(!1),m(``)}finally{g(!1)}}}async function M(){if(!(!p.trim()||!d)){g(!0);try{let t=await Ul(e,d.todo.id,{description:p});u(e=>e.map(e=>e.id===t.id?t:e)),A()}finally{g(!1)}}}async function P(){if(d){g(!0);try{await Wl(e,d.todo.id),u(e=>e.filter(e=>e.id!==d.todo.id)),A()}finally{g(!1)}}}function F(e){u(t=>t.map(t=>t.id===e.id?e:t))}async function I(t){let n=o?s[o]:void 0,r=c.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===o),l=n?.id??i?.model,u=n?.provider??i?.modelProvider;if(!l||!u)throw console.error(`No model or provider found for project`,e,i),Error(`No model configuration found. Please configure a model and provider for this project first.`);let d=await Se(e);if(!d)return;let f=null,p=await ru(d,n=>{Ul(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{f=e,F(e)})});if(!p)return;f||F(await Ul(e,t.id,{status:`Plan`,working:!0,threadId:p}));let m=n??{id:l,provider:u,name:l,description:``};a({type:Z.SetProjectModel,threadId:p,model:m}),w(p,{model:l,modelProvider:u});let h=await be(p,eu($l(r,`plan`),`plan`,t.id,t.description),l,[],void 0,u);h&&iu(h)}async function L(t){let n=await Se(e);if(!n)return;let r=null,i=await ru(n,n=>{Ul(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Ul(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await Me(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await N(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,c=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!c)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Z.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),w(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await be(i,t.description,s,[],void 0,c);l&&iu(l)}async function R(t){try{let n=await Se(e);if(!n){v(!1),b(null);return}let r=null;if(r=await ru(n,e=>{r=e}),!r){v(!1),b(null);return}let i=await Me(r),a=i.model,o=i.modelProvider;if(!a||!o)try{let t=(await N(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(a=t.model,o=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!a||!o){ce(e,r),v(!1),b(null);return}let s=eu($l(c.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await be(r,s,a,[],void 0,o);l&&S(await au(l)),ce(e,r)}catch(e){console.error(`Failed to generate test case:`,e),v(!1),b(null)}finally{T(!1)}}function ee(e){b(e),S(``),T(!0),v(!0),R(e)}function z(){v(!1),b(null),S(``)}async function B(){if(!y||!x.trim())return;let t=y,n=x;z(),O(!0);try{let r=await Se(e);if(!r)return;let i=null,o=await ru(r,n=>{Ul(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,F(e)})});if(!o)return;i||F(await Ul(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await Me(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await N(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Z.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),w(o,{model:c,modelProvider:l});let u=await be(o,n,c,[],void 0,l);u&&iu(u)}finally{O(!1)}}async function V(t){let n=await Se(e);if(!n)return;let r=null,i=await ru(n,n=>{Ul(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Ul(e,t.id,{status:`Review`,working:!0,threadId:i}));let o=await Me(i),s=o.model,l=o.modelProvider;if(!s||!l)try{let t=(await N(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Z.SetProjectModel,threadId:i,model:{id:s,provider:l,name:s,description:``}}),w(i,{model:s,modelProvider:l});let u=await be(i,eu($l(c.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),s,[],void 0,l);u&&iu(u)}async function te(t,n){n===`Plan`?await I(t):n===`Build`?await L(t):n===`Test`?ee(t):n===`Review`?await V(t):F(await Ul(e,t.id,{status:n,working:n!==`Done`}))}return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,$.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-8 flex-1 min-h-0`,children:tu.map(t=>{let i=l.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:W(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,nu[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:W(J.dropdownGroupHeading,`uppercase tracking-wide`),children:t}),(0,$.jsx)(`span`,{className:W(J.compact,`text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`),children:i.length})]}),(0,$.jsx)(Tt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(D,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Kl,{todo:t,projectId:e,onUpdate:F,onEdit:k,onAction:te,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(mt,{open:t,onOpenChange:n,children:(0,$.jsxs)(ut,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(ui,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&j()}}),(0,$.jsx)(`p`,{className:W(J.caption,`mt-1.5`),children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(rn,{children:(0,$.jsx)(G,{onClick:()=>void j(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(mt,{open:_,onOpenChange:e=>!e&&z(),children:(0,$.jsxs)(ut,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:C?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(wt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:J.body,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ui,{value:x,onChange:e=>S(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0}),(0,$.jsx)(`p`,{className:W(J.caption,`mt-1.5`),children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(rn,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:z,disabled:C,children:`Cancel`}),(0,$.jsx)(G,{onClick:()=>void B(),disabled:C||!x.trim()||E,children:E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(mt,{open:d!==null,onOpenChange:e=>!e&&A(),children:(0,$.jsxs)(ut,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(pn,{children:(0,$.jsx)(qe,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(ui,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}})}),(0,$.jsxs)(rn,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(G,{variant:`destructive`,onClick:()=>void P(),disabled:h,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(G,{onClick:()=>void M(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}function lu(e){let t=(0,X.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({projectId:r,loadVersion:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=su(r,n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;t[7]===r?o=t[8]:(o=()=>ou(r),t[7]=r,t[8]=o);let s=hr(a,o),c;return t[9]!==s||t[10]!==r||t[11]!==i?(c=(0,$.jsx)(cu,{projectId:r,initialTodos:s,...i}),t[9]=s,t[10]=r,t[11]=i,t[12]=c):c=t[12],c}function uu(e){let t=(0,X.c)(11),[n,r]=(0,Y.useState)(0),i;t[0]!==n||t[1]!==e.projectId?(i=function(){br(su(e.projectId,n)),r(du)},t[0]=n,t[1]=e.projectId,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(vr,{className:`h-64`}),t[3]=o):o=t[3];let s=`${e.projectId}:${n}`,c;t[4]!==n||t[5]!==e||t[6]!==s?(c=(0,$.jsx)(Y.Suspense,{fallback:o,children:(0,$.jsx)(lu,{...e,loadVersion:n},s)}),t[4]=n,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==c?(l=(0,$.jsx)(yr,{fallbackTitle:`Failed to load tasks`,onRetry:a,children:c}),t[8]=a,t[9]=c,t[10]=l):l=t[10],l}function du(e){return e+1}var fu=En,pu=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Cn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});pu.displayName=Cn.displayName;var mu=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-base font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(kn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});mu.displayName=kn.displayName;var hu=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Nn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});hu.displayName=Nn.displayName;var gu=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:ql},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Xl},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Yl}];function _u({open:e,onOpenChange:t,projectId:n}){let r=Q(e=>e.projects),[i,a]=(0,Y.useState)({plan:``,review:``,test:``}),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!e)return;let t=r.find(e=>e.projectId===n);a({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,n,r]);async function c(){s(!0);try{await L(n,{planPrompt:i.plan.trim()===ql?null:i.plan.trim()||null,testPrompt:i.test.trim()===Yl?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Xl?null:i.review.trim()||null}),Jt(),wi({title:`AI prompt settings saved`}),t(!1)}catch(e){wi({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(mt,{open:e,onOpenChange:t,children:(0,$.jsxs)(ut,{className:`max-w-2xl`,children:[(0,$.jsxs)(pn,{children:[(0,$.jsx)(qe,{children:`AI Prompt Settings`}),(0,$.jsx)(Ue,{children:`Customize the prompts used when running Plan, Code Review, and Test actions from the task board. Leave empty to use the default prompt.`})]}),(0,$.jsxs)(fu,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(pu,{className:`w-full`,children:gu.map(e=>(0,$.jsx)(mu,{value:e.value,className:`flex-1`,children:e.label},e.value))}),gu.map(e=>(0,$.jsxs)(hu,{value:e.value,children:[(0,$.jsx)(ui,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(e.value,t.target.value),className:`min-h-[250px] font-mono resize-none`,placeholder:e.defaultPrompt,disabled:o}),(0,$.jsxs)(`p`,{className:W(J.bodyMuted,`mt-1.5`),children:[`Use `,(0,$.jsx)(`code`,{className:J.mono,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(rn,{children:(0,$.jsx)(G,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}var vu=t({TodosView:()=>yu});function yu({projectId:e}){let t=si(),n=Q(e=>e.projects),r=Q(e=>e.selectedThreadId),i=Q(e=>e.selectedProjectId),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=Wn(),{setActiveMainTab:u}=ca();async function d(a){if(n.find(t=>t.projectId===e)){l(`/`),u(`chat`);try{let{getProjects:n,invalidateProjectsCache:o}=await ir(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-Ct6i8Iij.js`).then(e=>e.O);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([5,1]));o();let s=await n();t({type:Z.SetProjects,projects:s.projects});let c=s.projects.find(t=>t.projectId===e);if(c&&c.threads.find(e=>e.threadId===a)){(r!==a||i!==e)&&t({type:Z.SelectThread,threadId:a,projectId:e});try{let e=await te();t({type:Z.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after thread selection:`,e)}}}catch(n){console.error(`Failed to refresh projects for thread selection:`,n),(r!==a||i!==e)&&t({type:Z.SelectThread,threadId:a,projectId:e});try{let e=await te();t({type:Z.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after fallback thread selection:`,e)}}}}return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden pt-8 pl-4`,children:(0,$.jsx)(uu,{projectId:e,addOpen:a,onAddOpenChange:o,onThreadSelect:d})}),(0,$.jsx)(G,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>c(!0),children:(0,$.jsx)(me,{className:`h-4 w-4`})}),(0,$.jsx)(_u,{open:s,onOpenChange:c,projectId:e})]})}var bu=(0,Y.lazy)(()=>ir(()=>import(`./diff-view-rKDEnBLg.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),xu=(0,Y.lazy)(()=>ir(()=>import(`./dialogs-config-Ct6i8Iij.js`).then(e=>e.t),__vite__mapDeps([5,1]))),Su=40,Cu=`linear-gradient(to right, transparent 0, transparent ${Su}px, hsl(var(--background)) ${Su}px)`,wu=`linear-gradient(to top, hsl(var(--background)) 0, hsl(var(--background)) calc(100% - ${Su}px), transparent calc(100% - ${Su}px), transparent 100%), linear-gradient(to right, transparent 0, transparent ${Su}px, hsl(var(--background)) ${Su}px)`;function Tu(e){let t=(0,X.c)(55),{onCreateThread:n}=e,r=si(),i=Wn(),a=$n(),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=Q(zu),f=Q(Ru),p=Q(Lu),m=Q(Iu),h=Q(Fu),g=Q(Pu),_=Q(Nu),v=Q(Mu),y=Q(ju),b=Q(Au),x=Q(ku),S=Q(Ou),C=Q(Du),w;t[0]!==m||t[1]!==d?(w=d&&m.includes(d),t[0]=m,t[1]=d,t[2]=w):w=t[2];let T=!!w,E=x?.threadId===d,D;t[3]!==r||t[4]!==S?(D=()=>{S&&r({type:Z.ToggleSidebar})},t[3]=r,t[4]=S,t[5]=D):D=t[5];let O=D,k;t[6]===O?k=t[7]:(k=()=>{O(),u(`clone`),s(!0)},t[6]=O,t[7]=k);let A=k,j;t[8]===O?j=t[9]:(j=()=>{O(),u(`webapp`),s(!0)},t[8]=O,t[9]=j);let M=j,N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=async(e,t)=>{try{await c(e,t),s(!1),u(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=N):N=t[10];let F=N,I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=async(e,t,n)=>{try{await De(e,t,n),s(!1),u(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=I):I=t[11];let L=I,R;t[12]===O?R=t[13]:(R=async()=>{O();try{await en(),s(!1),u(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=O,t[13]=R);let ee=R,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=async e=>{try{await P(e),s(!1),u(null)}catch(e){console.error(`Failed to create folder:`,e)}},t[14]=z):z=t[14];let B=z,V=a.pathname===`/review`,te=a.pathname===`/todos`,ne;t[15]===i?ne=t[16]:(ne=()=>{i(`/`)},t[15]=i,t[16]=ne);let re=ne;Rl();let H;t[17]!==O||t[18]!==r||t[19]!==A||t[20]!==re||t[21]!==M||t[22]!==ee||t[23]!==E||t[24]!==p||t[25]!==T||t[26]!==v||t[27]!==f||t[28]!==_||t[29]!==n||t[30]!==h||t[31]!==g||t[32]!==V||t[33]!==C||t[34]!==d||t[35]!==b||t[36]!==y||t[37]!==te?(H=te&&C?(0,$.jsx)(yu,{projectId:C}):V&&d?(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(vr,{}),children:(0,$.jsx)(bu,{threadId:d,onExit:re})}):(0,$.jsx)(Ds,{messages:f,isStreaming:v,streamingSegments:y,streamingModel:b,isCreatingProject:p,isProcessingThread:T,hasPendingMessage:E,selectedThreadId:d,selectedProjectId:C,projects:h,projectsLoading:g,messagesLoaded:_,onSelectThread:(e,t)=>{O(),r({type:Z.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:A,onNewApp:M,onOpenFolder:ee,error:null,onClearError:Eu}),t[17]=O,t[18]=r,t[19]=A,t[20]=re,t[21]=M,t[22]=ee,t[23]=E,t[24]=p,t[25]=T,t[26]=v,t[27]=f,t[28]=_,t[29]=n,t[30]=h,t[31]=g,t[32]=V,t[33]=C,t[34]=d,t[35]=b,t[36]=y,t[37]=te,t[38]=H):H=t[38];let ie;t[39]!==f||t[40]!==V||t[41]!==d||t[42]!==te?(ie=!V&&!te&&d&&(0,$.jsxs)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pr-4`,children:[(0,$.jsx)(`div`,{className:`h-6`,style:{backgroundImage:wu}}),(0,$.jsx)(`div`,{className:`h-8`,style:{backgroundImage:Cu}}),(0,$.jsx)(`div`,{style:{backgroundImage:Cu},children:(0,$.jsx)(Ml,{messages:f})})]}),t[39]=f,t[40]=V,t[41]=d,t[42]=te,t[43]=ie):ie=t[43];let ae=l??void 0,oe;t[44]!==o||t[45]!==ee||t[46]!==ae?(oe=(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(xu,{open:o,onOpenChange:s,initialMode:ae,onSubmitClone:F,onSubmitWebApp:L,onSubmitFolder:B,onOpenFolder:ee})}),t[44]=o,t[45]=ee,t[46]=ae,t[47]=oe):oe=t[47];let se;t[48]!==H||t[49]!==ie||t[50]!==oe?(se=(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[H,ie,oe]}),t[48]=H,t[49]=ie,t[50]=oe,t[51]=se):se=t[51];let ce;return t[52]!==d||t[53]!==se?(ce=(0,$.jsx)(fo,{threadId:d,children:se}),t[52]=d,t[53]=se,t[54]=ce):ce=t[54],ce}function Eu(){}function Du(e){return e.selectedProjectId}function Ou(e){return e.sidebarOpen}function ku(e){return e.pendingChatMessage}function Au(e){return e.streamingModel}function ju(e){return e.streamingSegments}function Mu(e){return e.isStreaming}function Nu(e){return e.messagesLoaded}function Pu(e){return e.projectsLoading}function Fu(e){return e.projects}function Iu(e){return e.processingThreadIds}function Lu(e){return e.isCreatingProject}function Ru(e){return e.messages}function zu(e){return e.selectedThreadId}function Bu(e){let t=(0,X.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=W(`flex min-h-[71px] shrink-0 items-center gap-2 px-4 py-2 electrobun-webkit-app-region-drag`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`header`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}var Vu=`VS Code`;function Hu(e){return e||Dt(Vu)}var Uu={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Wu({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)([]),[s,c]=(0,Y.useState)(()=>Hu(n)),[l,u]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{(async()=>{try{let e=await ht();o(e);let t=Hu(n);e.includes(t)?c(t):e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([Vu])}finally{u(!1)}})()},[]),(0,Y.useEffect)(()=>{if(n&&a.includes(n)){c(n);return}let e=Dt(Vu);!n&&a.includes(e)&&c(e)},[n,a]);async function d(t){c(t),he(t),await gn(e,t)}let f=async n=>{try{i(!0),await d(n),t?await at(t,n):await $e(e,n),wi({title:`Success`,description:`Opened project in ${n}`})}catch(e){console.error(`Failed to open project in ${n}:`,e);let t=`Failed to open project in ${n}`;if(e instanceof Error){let n=e;t=n.details?n.details:e.message}wi({title:`Error`,description:t,variant:`destructive`})}finally{i(!1)}};async function p(e){try{await d(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),wi({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}return l?(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await f(s)},children:(0,$.jsx)(`img`,{src:`/ide/${Uu[s]||Uu[Vu]}.svg`,alt:s,className:`h-4 w-4`})})}),(0,$.jsx)(U,{children:`Open in ${s}`})]}),(0,$.jsxs)(Oo,{children:[(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(j,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(No,{align:`end`,children:a.map(e=>(0,$.jsxs)(Po,{onClick:()=>void p(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Uu[e]||Uu[Vu]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}var Gu=`Play.Square.RotateCcw.Terminal.Bug.TestTube.FlaskConical.Wrench.Hammer.Zap.Search.FileCode.Code2.History.Settings.Activity.Cpu.Server.Database.Package.Box.GitBranch.Layers.ExternalLink.Eye.Shield.Flag.Star.Monitor.Smartphone`.split(`.`);function Ku({open:e,onOpenChange:t,projectId:n,commands:i,onRefresh:a}){let[o,s]=(0,Y.useState)(null),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)([]),[h,g]=(0,Y.useState)(0),[_,v]=(0,Y.useState)(!1),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=()=>{s({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),f(!1),m([])},C=e=>{s({...e}),f(!1),m([])},w=async()=>{try{v(!0);let e=await y(n);m(e.scripts),g(0),f(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),wi({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{v(!1)}},T=e=>{s(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),f(!1),m([]),b.current?.focus()},E=e=>{d&&(e.key===`ArrowDown`?(e.preventDefault(),g(e=>e<p.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),g(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),h<p.length&&T(p[h])):e.key===`Escape`&&(e.preventDefault(),f(!1),m([])))};(0,Y.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(f(!1),m([]))};return d&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[d]);let O=async e=>{try{await Bt(n,e),wi({title:`Success`,description:`Command deleted`}),a()}catch{wi({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(mt,{open:e,onOpenChange:t,children:(0,$.jsxs)(ut,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(pn,{children:[(0,$.jsx)(qe,{children:`Project Commands`}),(0,$.jsx)(Ue,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:o?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(ot,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(Ot,{id:`name`,value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(ot,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ui,{ref:b,id:`commandLine`,value:o.commandLine,onChange:e=>s({...o,commandLine:e.target.value}),onKeyDown:E,placeholder:`e.g. npm test`,className:`font-mono text-base min-h-[100px] resize-none pr-10`}),(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void w(),disabled:_,children:(0,$.jsx)(j,{className:`h-4 w-4`})})}),(0,$.jsx)(U,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),d&&(0,$.jsx)(`div`,{ref:x,className:`absolute bottom-full left-0 right-0 mb-2 max-h-60 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg z-50`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsxs)(`div`,{className:W(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),children:[(0,$.jsx)(j,{className:`h-3 w-3`}),`Available Scripts `,_&&`(loading...)`]}),p.length>0?(()=>{let e={};p.forEach(t=>{e[t.relativePath]||(e[t.relativePath]=[]),e[t.relativePath].push(t)});let t=Object.keys(e).sort(),n=0;return t.map(t=>{let r=e[t].sort((e,t)=>e.name.localeCompare(t.name));return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:W(J.dropdownGroupHeading,`px-3 py-1.5 text-muted-foreground/70 bg-muted/30`),children:t}),r.map(e=>{let t=n===h;return n++,(0,$.jsxs)(`button`,{type:`button`,className:W(`flex w-full flex-col gap-1 rounded-lg mx-1 px-3 py-2 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>T(e),onMouseEnter:()=>g(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:W(J.caption,`font-mono`),children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:W(J.caption,`px-3 py-4 text-center`),children:_?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(ot,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(Ot,{id:`relativeFolder`,value:o.relativeFolder??``,onChange:e=>s({...o,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:J.bodyMuted,children:`Folder path relative to project root where the command will be executed. Leave empty to run from project root.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(ot,{children:`Icon`}),(0,$.jsx)(r,{children:(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Gu.map(e=>{let t=dn[e]||l;return(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:o.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>s({...o,icon:e}),children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),(0,$.jsx)(U,{children:e})]},e)})})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>s(null),children:[(0,$.jsx)(un,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(G,{size:`sm`,onClick:async()=>{if(!o?.name||!o?.commandLine){wi({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{u(!0),await nn(n,o),wi({title:`Success`,description:`Command saved`}),s(null),a()}catch{wi({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{u(!1)}},disabled:c,children:[(0,$.jsx)(Vt,{className:`h-4 w-4 mr-2`}),` `,c?`Saving...`:`Save Command`]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2`,children:[i.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>C(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(dn[e.icon]||Fe,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:J.label,children:e.name}),(0,$.jsx)(`span`,{className:W(J.caption,`line-clamp-1 font-mono`),children:e.commandLine})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),O(e.id)},children:(0,$.jsx)(H,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(G,{variant:`outline`,className:`w-full border-dashed`,onClick:S,children:[(0,$.jsx)(D,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function qu(){let e=(0,X.c)(27),t=Q(Zu),n=Q(Xu),i=Q(Yu),a=Q(Ju),{dispatch:o}=li(n),[s,c]=(0,Y.useState)(!1),l,u,d,f,p;if(e[0]!==o||e[1]!==a||e[2]!==i||e[3]!==t||e[4]!==n){p=Symbol.for(`react.early_return_sentinel`);bb0:{let s;e[10]===t?s=e[11]:(s=e=>e.projectId===t,e[10]=t,e[11]=s),l=i.find(s)?.commands??[];let m;e[12]!==o||e[13]!==t||e[14]!==n?(m=e=>{!t||!n||o({type:Z.QueueTerminalCommand,threadId:n,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=o,e[13]=t,e[14]=n,e[15]=m):m=e[15];let h=m,g;if(e[16]===o?g=e[17]:(g=async()=>{o({type:Z.ConfigUpdated})},e[16]=o,e[17]=g),u=g,!t){p=null;break bb0}d=`flex items-center gap-1`,f=l.length===0?(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,onClick:()=>c(!0),children:(0,$.jsx)(hn,{})})}),(0,$.jsx)(U,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(r,{children:[l.map(e=>(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,onClick:()=>h({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:a,children:(0,$.jsx)(dn[e.icon]||Fe,{})})}),(0,$.jsx)(U,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 font-mono whitespace-pre-wrap max-w-[300px] max-h-[100px] overflow-y-auto`,children:e.commandLine})]})})]},e.id)),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>c(!0),children:(0,$.jsx)(hn,{})})}),(0,$.jsx)(U,{children:`Manage commands`})]})]})})}e[0]=o,e[1]=a,e[2]=i,e[3]=t,e[4]=n,e[5]=l,e[6]=u,e[7]=d,e[8]=f,e[9]=p}else l=e[5],u=e[6],d=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;e[18]!==l||e[19]!==u||e[20]!==t||e[21]!==s?(m=(0,$.jsx)(Ku,{open:s,onOpenChange:c,projectId:t,commands:l,onRefresh:u}),e[18]=l,e[19]=u,e[20]=t,e[21]=s,e[22]=m):m=e[22];let h;return e[23]!==d||e[24]!==f||e[25]!==m?(h=(0,$.jsxs)(`div`,{className:d,children:[f,m]}),e[23]=d,e[24]=f,e[25]=m,e[26]=h):h=e[26],h}function Ju(e){return e.isRunningCommand}function Yu(e){return e.projects}function Xu(e){return e.selectedThreadId}function Zu(e){return e.selectedProjectId}function Qu({projectId:e,runCommand:t,large:n}){let{dispatch:i}=li(Q(e=>e.selectedThreadId)),{setDevServerUrl:a,devServerRunning:o,setDevServerRunning:s,devServerLoading:c,setDevServerLoading:l}=ca(),{startServer:u}=vs(),d=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{(async()=>{try{s((await Xe(e)).isRunning)}catch{s(!1)}})()},[e]);let f=()=>{u({projectId:e,runCommand:t||``})},p=async()=>{d.current=!0,l(!0);try{await ie(e),s(!1),a(null),i({type:Z.AppendTerminalLine,line:{type:`system`,content:`Server stopped`}})}catch(e){let t=e instanceof Error?e.message:`Failed to stop dev server`;i({type:Z.AppendTerminalLine,line:{type:`error`,content:t}}),wi({title:`Error`,description:t,variant:`destructive`})}finally{l(!1)}},m=!!t;return n?(0,$.jsxs)(`button`,{onClick:o?p:f,disabled:c||!o&&!m,className:`flex flex-col items-center gap-3 group disabled:opacity-40 disabled:cursor-not-allowed ${o?`text-orange-500`:`text-muted-foreground`}`,children:[c?(0,$.jsx)(wt,{className:`h-10 w-10 animate-spin`}):o?(0,$.jsx)(oe,{className:`h-10 w-10 fill-current`}):(0,$.jsx)(Fe,{className:`h-10 w-10 fill-current group-hover:text-foreground transition-colors`}),(0,$.jsx)(`span`,{className:W(J.body,`group-hover:text-foreground transition-colors`),children:c?`Starting...`:o?`Stop dev server`:`Start dev server`})]}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-8 w-8 ${o?`text-orange-500 bg-orange-500/10`:`text-muted-foreground`}`,onClick:o?p:f,disabled:c||!o&&!m,children:[c?(0,$.jsx)(wt,{className:`h-4 w-4 animate-spin`}):o?(0,$.jsx)(oe,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(Fe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:o?`Stop dev server`:`Start dev server`})]})}),(0,$.jsx)(U,{children:o?`Stop dev server`:m?`Start dev server: ${t}`:`Set run command in project settings`})]})})})}function $u(e){let t=(0,X.c)(3),{children:n,className:r}=e,i=`flex items-center gap-2 rounded-full shadow-md ${r===void 0?``:r}`,a;return t[0]!==n||t[1]!==i?(a=(0,$.jsx)(`div`,{className:i,children:n}),t[0]=n,t[1]=i,t[2]=a):a=t[2],a}function ed({threadId:e}){let t=si(),{setTerminalNotification:n}=ca(),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(new Set),c=(0,Y.useRef)(new Map);(0,Y.useEffect)(()=>((async()=>{try{let t=await x(e);if(t.length===0){a(null);return}a(t),s(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{a(null)}})(),()=>{for(let e of c.current.values())e.abort();c.current.clear()}),[e]);let l=async r=>{if(o.has(r.name)){let n=c.current.get(r.name);n&&(n.abort(),c.current.delete(r.name));try{await St(e,r.name)}catch{}t({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${r.friendlyName} stopped`}}),s(e=>{let t=new Set(e);return t.delete(r.name),t})}else{let i=new AbortController;c.current.set(r.name,i),s(e=>new Set([...e,r.name])),n(!0),t({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${r.friendlyName}`}});try{let n=await He(e,r.name,r.command,{signal:i.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
62
|
+
`);a=s.pop()??``;for(let n of s)if(n.trim())try{let r=JSON.parse(n);typeof r==`string`?t({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&t({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{t({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}})}}if(a.trim())try{let n=JSON.parse(a);typeof n==`string`?t({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:n.message}})}catch{t({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{r.releaseLock()}}t({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${r.friendlyName} done`}})}catch{}finally{c.current.delete(r.name),s(e=>{let t=new Set(e);return t.delete(r.name),t})}}};if(!i)return null;let u=i.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),d=Object.entries(u).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),f=d.length>1;return(0,$.jsxs)(Oo,{children:[(0,$.jsx)(r,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(ko,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(we,{})})})}),(0,$.jsx)(U,{children:`Project Scripts`})]})}),(0,$.jsx)(No,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(Ao,{children:[(0,$.jsx)(jo,{children:e}),(0,$.jsx)(Mo,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Po,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):d[0]?.[1].map(e=>(0,$.jsxs)(Po,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(wt,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}function td(){let e=(0,X.c)(40),t=si(),r=Q(ad),i=Q(id),a=Q(rd),o=Q(nd),s;if(e[0]!==a||e[1]!==i){let t;e[3]===i?t=e[4]:(t=e=>e.projectId===i,e[3]=i,e[4]=t),s=a.find(t),e[0]=a,e[1]=i,e[2]=s}else s=e[2];let c=s,l=!o,u=l&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2`,d;e[5]===u?d=e[6]:(d=W(u),e[5]=u,e[6]=d);let f;e[7]===t?f=e[8]:(f=()=>t({type:Z.ToggleSidebar}),e[7]=t,e[8]=f);let p;e[9]===o?p=e[10]:(p=o?(0,$.jsx)(et,{className:`h-4 w-4`}):(0,$.jsx)(n,{className:`h-4 w-4`}),e[9]=o,e[10]=p);let m;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=m):m=e[11];let h;e[12]!==f||e[13]!==p?(h=(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,onClick:f,children:[p,m]}),e[12]=f,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==a||e[16]!==i||e[17]!==r?(g=r&&(0,$.jsx)(`div`,{className:`flex flex-col`,children:(0,$.jsx)(`span`,{className:W(J.sectionSubtitle,`text-foreground`),children:Yt(a,i)})}),e[15]=a,e[16]=i,e[17]=r,e[18]=g):g=e[18];let _;e[19]!==h||e[20]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),e[19]=h,e[20]=g,e[21]=_):_=e[21];let v=l?`ml-0`:`ml-auto`,y;e[22]===v?y=e[23]:(y=W(`flex flex-wrap items-center justify-end gap-2`,v,`md:ml-auto`),e[22]=v,e[23]=y);let b;e[24]!==c?.runCommand||e[25]!==i||e[26]!==r?(b=i&&(0,$.jsxs)($u,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Qu,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ed,{threadId:r}),(0,$.jsx)(qu,{})]})]}),e[24]=c?.runCommand,e[25]=i,e[26]=r,e[27]=b):b=e[27];let x;e[28]!==c?.openWith||e[29]!==i||e[30]!==r?(x=r&&i&&(0,$.jsx)($u,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Wu,{projectId:i,threadId:r,openWith:c?.openWith})}),e[28]=c?.openWith,e[29]=i,e[30]=r,e[31]=x):x=e[31];let S;e[32]!==y||e[33]!==b||e[34]!==x?(S=(0,$.jsxs)(`div`,{className:y,children:[b,x]}),e[32]=y,e[33]=b,e[34]=x,e[35]=S):S=e[35];let C;return e[36]!==S||e[37]!==d||e[38]!==_?(C=(0,$.jsxs)(Bu,{className:d,children:[_,S]}),e[36]=S,e[37]=d,e[38]=_,e[39]=C):C=e[39],C}function nd(e){return e.sidebarOpen}function rd(e){return e.projects}function id(e){return e.selectedProjectId}function ad(e){return e.selectedThreadId}function od(e){let t=(0,X.c)(14),{open:n,projectName:r,onOpenChange:i,onConfirm:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(ur,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=W(J.body,`font-semibold text-foreground`),t[1]=s):s=t[1];let c;t[2]===r?c=t[3]:(c=(0,$.jsxs)(mr,{children:[o,(0,$.jsxs)(dr,{children:[`Are you sure you want to delete`,` `,(0,$.jsxs)(`span`,{className:s,children:[`"`,r,`"`]}),`? This will remove the project and all its data. This action cannot be undone.`]})]}),t[2]=r,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(lr,{children:`Cancel`}),t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=(0,$.jsxs)(fr,{children:[l,(0,$.jsx)(_r,{onClick:a,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[5]=a,t[6]=u);let d;t[7]!==c||t[8]!==u?(d=(0,$.jsxs)(gr,{children:[c,u]}),t[7]=c,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==i||t[11]!==n||t[12]!==d?(f=(0,$.jsx)(pr,{open:n,onOpenChange:i,children:d}),t[10]=i,t[11]=n,t[12]=d,t[13]=f):f=t[13],f}function sd(e){let t=(0,X.c)(28),{open:n,setupScripts:r,onConfirm:i}=e;if(r.length===0)return null;let a;t[0]===i?a=t[1]:(a=e=>{e||i(!1)},t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(ur,{children:`Install dependencies?`}),t[2]=o):o=t[2];let s=r.length===1?``:`s`,c;t[3]!==r.length||t[4]!==s?(c=(0,$.jsxs)(mr,{children:[o,(0,$.jsxs)(dr,{children:[`Found `,r.length,` package`,s,` with dependencies to install:`]})]}),t[3]=r.length,t[4]=s,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=r.map(cd),t[6]=r,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,$.jsx)(`div`,{className:`my-4 max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`space-y-2`,children:l})}),t[8]=l,t[9]=u);let d;t[10]===i?d=t[11]:(d=(0,$.jsx)(lr,{onClick:()=>i(!1),children:`No`}),t[10]=i,t[11]=d);let f;t[12]===i?f=t[13]:(f=()=>i(!0),t[12]=i,t[13]=f);let p;t[14]!==r.length||t[15]!==f?(p=(0,$.jsxs)(_r,{onClick:f,children:[`Install All (`,r.length,`)`]}),t[14]=r.length,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==d||t[18]!==p?(m=(0,$.jsxs)(fr,{children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==m||t[21]!==c||t[22]!==u?(h=(0,$.jsxs)(gr,{className:`max-w-2xl`,children:[c,u,m]}),t[20]=m,t[21]=c,t[22]=u,t[23]=h):h=t[23];let g;return t[24]!==n||t[25]!==a||t[26]!==h?(g=(0,$.jsx)(pr,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function cd(e,t){let n=e.match(/^cd "([^"]+)" && (.+)$/),r=n?n[1]:`root`,i=n?n[2]:e;return(0,$.jsx)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border bg-muted/50`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-blue-500`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:J.label,children:r||`root`}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:i})]})]})},t)}function ld(){let e=(0,X.c)(6),[t,n]=(0,Y.useState)(!0),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=!0;return(async()=>{try{let t=await fetch(`${Ut()}/health`,{method:`GET`});e&&n(t.ok)}catch{e&&n(!1)}})(),()=>{e=!1}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Y.useEffect)(r,i);let a=ud;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Ut(),e[2]=o):o=e[2];let s=o,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(mr,{children:[(0,$.jsx)(ur,{children:`Service unavailable`}),(0,$.jsx)(dr,{children:`Service is not currently up. Please ensure the backend is running at the address below, then retry.`})]}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Sr,{variant:`hint`,className:W(J.mono,J.compact,`mb-0`),children:s}),e[4]=l):l=e[4];let u;return e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(pr,{open:!0,children:(0,$.jsxs)(gr,{children:[c,l,(0,$.jsx)(fr,{children:(0,$.jsx)(G,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function ud(){window.location.assign(window.location.href)}var dd=e=>{let t=(0,X.c)(8),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=W(`flex h-full w-full data-[panel-group-direction=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(An,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},fd=qn,pd=e=>{let t=(0,X.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=W(`relative flex w-px items-center justify-center bg-transparent after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,$.jsx)(`div`,{className:`hidden z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border`,children:(0,$.jsx)(ct,{className:`h-2.5 w-2.5`})}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,$.jsx)(jn,{className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s},md=xn,hd=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(yn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});hd.displayName=yn.displayName;var gd=jt(`group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full`,{variants:{variant:{default:`border bg-background text-foreground`,destructive:`destructive group border-destructive bg-destructive text-destructive-foreground`}},defaultVariants:{variant:`default`}}),_d=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==a?(o=W(gd({variant:a}),r),n[4]=r,n[5]=a,n[6]=o):o=n[6];let s;return n[7]!==i||n[8]!==t||n[9]!==o?(s=(0,$.jsx)(Mn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});_d.displayName=Mn.displayName;var vd=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive`,J.body,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(nr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vd.displayName=nr.displayName;var yd=Y.forwardRef((e,t)=>{let n=(0,X.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(`absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(un,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(In,{ref:t,className:a,"toast-close":``,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});yd.displayName=In.displayName;var bd=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(J.dialogTitle,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});bd.displayName=Jn.displayName;var xd=Y.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=W(J.body,`opacity-90 text-muted-foreground group-[.destructive]:text-destructive-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Sn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xd.displayName=Sn.displayName;function Sd(){let e=(0,X.c)(5),{toasts:t}=Ti(),n;e[0]===t?n=e[1]:(n=t.map(Cd),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(hd,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(md,{children:[n,r]}),e[3]=n,e[4]=i),i}function Cd(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(_d,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(bd,{children:n}),r&&(0,$.jsx)(xd,{children:r})]}),i,(0,$.jsx)(yd,{})]},t)}function wd(){let e=(0,X.c)(4),{resolvedTheme:t,theme:n}=Dr(),r,i;return e[0]!==t||e[1]!==n?(r=()=>{if(window.tarsk?.setNativeTheme){let e=n===`system`?`system`:t||`system`;window.tarsk.setNativeTheme(e)}},i=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=i):(r=e[2],i=e[3]),(0,Y.useEffect)(r,i),null}function Td(e){let t=(0,X.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(wd,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Or,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Ed(){let e=(0,X.c)(14),t=si(),n=Q(kd),r=hr(`projects:bootstrap:${Q(Od)}`,R),i;e[0]!==r.projects||e[1]!==t?(i=()=>{t({type:Z.SetProjects,projects:r.projects}),t({type:Z.SetProjectsLoading,projectsLoading:!1})},e[0]=r.projects,e[1]=t,e[2]=i):i=e[2];let a;e[3]!==r||e[4]!==t?(a=[r,t],e[3]=r,e[4]=t,e[5]=a):a=e[5],(0,Y.useLayoutEffect)(i,a);let o;e[6]!==r.projects||e[7]!==t||e[8]!==n?(o=()=>{if(!n)for(let e of r.projects){let n=e.threads.find(Dd);if(n){t({type:Z.SelectThread,threadId:n.threadId,projectId:e.projectId});break}}},e[6]=r.projects,e[7]=t,e[8]=n,e[9]=o):o=e[9];let s;return e[10]!==r||e[11]!==t||e[12]!==n?(s=[r,t,n],e[10]=r,e[11]=t,e[12]=n,e[13]=s):s=e[13],(0,Y.useLayoutEffect)(o,s),null}function Dd(e){return e.isSelected}function Od(e){return e.configUpdatedAt}function kd(e){return e.selectedThreadId}function Ad(e){let t=si(),n=Q(e=>e.projects),r=Q(e=>e.selectedProjectId),i=Q(e=>e.selectedThreadId),{toast:a}=Ti(),o=li(`project-creation`).dispatch,[s,l]=(0,Y.useState)(null),d=(0,Y.useCallback)(async()=>{try{t({type:Z.SetProjectsLoading,projectsLoading:!0}),Jt(),xr(`projects:bootstrap:`);let e=await R();t({type:Z.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:Z.SetProjectsLoading,projectsLoading:!1})}},[t]),f=(0,Y.useCallback)((e,n)=>{(i!==n||r!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e}),cn(e,n).catch(e=>{console.error(`Failed to select thread:`,e)})},[t,i,r]),p=(0,Y.useCallback)(async n=>{t({type:Z.SetCreatingProject,isCreating:!0});try{let r=await n.apiCall();if(!r){t({type:Z.SetCreatingProject,isCreating:!1}),await d();return}let i=n.useTerminalDispatch?o:t;i({type:Z.ClearTerminalOutput}),i({type:Z.SetTerminalOpen,open:!0}),i({type:Z.AppendTerminalLine,line:{type:`system`,content:n.initialMessage}});let a=r.getReader(),s=new TextDecoder,c=``,u=null,f=!1,p=null,m=null;for(;;){let{done:e,value:r}=await a.read();if(e)break;c+=s.decode(r,{stream:!0});let o=c.split(`
|
|
63
|
+
`);c=o.pop()??``;for(let e of o){let r=e.trim();if(r)try{let e=JSON.parse(r);if(e.type===`progress`)!f&&e.threadId&&e.projectId&&(f=!0,p=e.projectId,m=e.threadId,t({type:Z.AddCreatingProject,projectId:e.projectId,threadId:e.threadId,projectName:n.optimisticProjectName,gitUrl:n.gitUrl??``}),t({type:Z.AddProcessingThread,threadId:e.threadId})),t({type:Z.AppendTerminalLine,...n.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`output`,content:e.message}});else if(e.type===`complete`){if(e.project){u=e.project.id;let r=n.includeThreadPath&&e.project.threads?.length>0?`${e.project.path}/${e.project.threads[0]}`:e.project.path;i({type:Z.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),t({type:Z.SetTerminalOpen,open:!1}),n.handleSetupScript&&e.suggestedSetupScript&&l({projectId:e.project.id,command:e.suggestedSetupScript,remainingScripts:e.project.pendingSetupScripts??[]})}}else e.type===`error`&&(f&&p&&(t({type:Z.RemoveCreatingProject,projectId:p}),m&&t({type:Z.RemoveProcessingThread,threadId:m})),t({type:Z.AppendTerminalLine,...n.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`error`,content:`Error: ${e.message}`}}))}catch(e){console.error(`Failed to parse ${n.logTag} event`,e)}}}t({type:Z.SetCreatingProject,isCreating:!1}),f&&m&&t({type:Z.RemoveProcessingThread,threadId:m}),Jt();let h=await R();if(t({type:Z.SetProjects,projects:h.projects}),t({type:Z.SetProjectsLoading,projectsLoading:!1}),u){let n=h.projects.find(e=>e.projectId===u);if(n&&n.threads.length>0){let e=n.threads[0].threadId;t({type:Z.SelectThread,threadId:e,projectId:u,focusInput:!0})}e?.onProjectCreated?.(u)}}catch(e){console.error(`Failed to ${n.logTag}:`,e),t({type:Z.SetCreatingProject,isCreating:!1}),(n.useTerminalDispatch?o:t)({type:Z.AppendTerminalLine,line:{type:`error`,content:`${n.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[t,d,o,e?.onProjectCreated]),m=(0,Y.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await p({apiCall:()=>c(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[p]),h=(0,Y.useCallback)(async(e,t,n)=>{await p({apiCall:()=>De(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[p]),g=(0,Y.useCallback)(async e=>{await p({apiCall:()=>P(e),initialMessage:`Creating folder "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create folder`,catchErrorPrefix:`Failed to create folder`})},[p]),_=(0,Y.useCallback)(async(e,r)=>{try{let i=r??(()=>{let t=n.find(t=>t.projectId===e)?.threads.map(e=>e.title)??[],r=/^thread-(\d+)$/i,i=0;for(let e of t){let t=e.match(r);t&&(i=Math.max(i,parseInt(t[1],10)))}return`thread-${i+1}`})(),o=await Se(e,r);if(!o){await d();return}let s=o.getReader(),c=new TextDecoder,l=``,u=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${i}"...`}];try{for(;;){let{done:n,value:r}=await s.read();if(n)break;l+=c.decode(r,{stream:!0});let o=l.split(`
|
|
64
|
+
`);l=o.pop()??``;for(let n of o){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`){if(!u&&n.threadId){u=!0,f=n.threadId,t({type:Z.AddCreatingThread,projectId:e,threadId:n.threadId,title:i}),t({type:Z.AddProcessingThread,threadId:n.threadId}),t({type:Z.ClearTerminalOutput,threadId:f});for(let e of m)t({type:Z.AppendTerminalLine,threadId:f,line:e});m.length=0}let r={type:`output`,content:n.message};f?t({type:Z.AppendTerminalLine,threadId:f,line:r}):m.push(r)}else if(n.type===`error`){u&&f&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:f}),t({type:Z.RemoveProcessingThread,threadId:f}));let r={type:`error`,content:`Error: ${n.message}`};f?t({type:Z.AppendTerminalLine,threadId:f,line:r}):m.push(r),console.error(`Thread creation error:`,n.message),a({title:`Thread Creation Failed`,description:n.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}u&&f&&t({type:Z.RemoveProcessingThread,threadId:f}),Jt(),await d(),f&&p&&t({type:Z.SelectThread,threadId:f,projectId:e,focusInput:!0})}catch(n){throw u&&f&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:f}),t({type:Z.RemoveProcessingThread,threadId:f})),a({title:`Thread Creation Failed`,description:n instanceof Error?n.message:String(n),variant:`destructive`}),n}}catch(e){console.error(`Failed to create thread:`,e);let n=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw t({type:Z.AppendTerminalLine,line:{type:`error`,content:n}}),a({variant:`destructive`,title:`Thread Creation Failed`,description:n}),e}},[d,t,n,a]),v=(0,Y.useCallback)(async(e,n)=>{t({type:Z.AddDeletingThread,threadId:n}),t({type:Z.ClearChatInputDraft,threadId:n});try{await ce(e,n),i===n&&t({type:Z.SelectThread,threadId:``,projectId:``}),await d(),t({type:Z.ConfigUpdated})}catch(e){console.error(`Failed to delete thread:`,e),a({variant:`destructive`,title:`Failed to delete thread`,description:e instanceof Error?e.message:`Unknown error`})}finally{t({type:Z.RemoveDeletingThread,threadId:n})}},[d,i,t,a]),y=(0,Y.useCallback)(async e=>{t({type:Z.AddDeletingProject,projectId:e});let i=n.find(t=>t.projectId===e)?.threads.map(e=>e.threadId)??[];for(let e of i)t({type:Z.AddDeletingThread,threadId:e}),t({type:Z.ClearChatInputDraft,threadId:e});try{await Pe(e),r===e&&t({type:Z.SelectThread,threadId:``,projectId:``}),await d(),t({type:Z.ConfigUpdated})}catch(e){console.error(`Failed to delete project:`,e)}finally{t({type:Z.RemoveDeletingProject,projectId:e});for(let e of i)t({type:Z.RemoveDeletingThread,threadId:e})}},[d,r,n,t]),b=(0,Y.useCallback)(async e=>{let n=s;if(l(null),!n||!e)return;let{projectId:r,command:i,remainingScripts:a}=n,o=[i,...a||[]];try{t({type:Z.SetCreatingProject,isCreating:!0}),t({type:Z.SetTerminalOpen,open:!0}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${o.length} package${o.length===1?``:`s`}...`}});for(let e=0;e<o.length;e++){let n=o[e],i=n.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${o.length} in ${a}...`}}),t({type:Z.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${n}`}});let s=await u(r,n,!0);if(s){let e=s.getReader(),n=new TextDecoder,r=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;r+=n.decode(a,{stream:!0});let o=r.split(`
|
|
65
|
+
`);r=o.pop()??``;for(let e of o)if(e.trim())try{let n=JSON.parse(e);typeof n==`string`?t({type:Z.AppendTerminalLine,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Z.AppendTerminalLine,line:{type:`error`,content:n.message}})}catch{t({type:Z.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?t({type:Z.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&t({type:Z.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{t({type:Z.AppendTerminalLine,line:{type:`output`,content:r}})}}e<o.length-1&&(t({type:Z.AppendTerminalLine,line:{type:`system`,content:``}}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`---`}}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:``}}))}t({type:Z.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),t({type:Z.SetCreatingProject,isCreating:!1}),await d()}catch(e){t({type:Z.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[s,t,d]);return{projects:n,selectedProjectId:r,selectedThreadId:i,refreshProjects:d,handleSelectThread:f,handleCreateProject:m,handleCreateWebApp:h,handleCreateFolder:g,handleOpenFolder:(0,Y.useCallback)(async()=>{await p({apiCall:en,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[p]),handleCreateThread:_,handleDeleteThread:v,confirmDeleteProject:y,pendingSetupScriptConfirmation:s,resolveSetupScriptConfirmation:b}}function jd(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(Md),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>n(!0),t=()=>n(!1);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,t)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Y.useEffect)(r,i),t}function Md(){return document.hasFocus()}var Nd=null;function Pd(){Nd??=new Audio(`/pop.wav`),Nd.currentTime=0,Nd.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Fd(){let e=si(),t=oi(),n=Q(e=>e.processingThreadIds),r=Q(e=>e.completedThreadIds),i=Q(e=>e.isCreatingProject),a=Q(e=>Object.values(e.threadStreamingStates).some(e=>e.isStreaming)),o=jd(),s=(0,Y.useRef)(null),c=(0,Y.useRef)(!1),l=(0,Y.useRef)([]),u=(0,Y.useRef)(o);(0,Y.useEffect)(()=>{u.current=o},[o]);let d=(0,Y.useCallback)(async()=>{try{let n=Cl(await te()),r=l.current.filter(e=>!n.includes(e));for(let n of r)n!==t.getState().selectedThreadId&&e({type:Z.MarkThreadCompleted,threadId:n});return r.length>0&&!u.current&&Pd(),l.current=n,e({type:Z.SetProcessingThreads,threadIds:n}),n}catch(e){return console.error(`Failed to fetch processing threads:`,e),[]}},[e,t]);return(0,Y.useEffect)(()=>{let e=()=>{if(s.current||c.current)return;c.current=!0;let e=async()=>{let n=await d(),r=t.getState(),i=Object.values(r.threadStreamingStates).some(e=>e.isStreaming);n.length>0||i||r.isCreatingProject?s.current=setTimeout(e,1e3):(s.current=null,c.current=!1)};e()},n=()=>{s.current&&=(clearTimeout(s.current),null),c.current=!1};return e(),()=>{n()}},[n.length,a,i,d]),{processingThreadIds:n,completedThreadIds:r,isThreadProcessing:e=>n.includes(e),isThreadCompleted:e=>r.includes(e),clearCompleted:(0,Y.useCallback)(t=>{e({type:Z.ClearThreadCompleted,threadId:t})},[e])}}var Id=768;function Ld(){let e=(0,X.c)(2),[t,n]=Y.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Id-1}px)`),t=()=>{n(window.innerWidth<Id)};return e.addEventListener(`change`,t),n(window.innerWidth<Id),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),!!t}var Rd=(0,Y.lazy)(()=>ir(()=>import(`./terminal-panel-Ds1tCgQA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([12,1,5]))),zd=(0,Y.lazy)(()=>ir(()=>Promise.resolve().then(()=>vu).then(e=>({default:e.TodosView})),void 0)),Bd=(0,Y.lazy)(()=>ir(()=>import(`./diff-view-rKDEnBLg.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),Vd=(0,Y.lazy)(()=>ir(()=>import(`./explorer-tab-view-JbLbPVAn.js`),__vite__mapDeps([13,1,3,4,7,5]))),Hd=(0,Y.lazy)(()=>ir(()=>import(`./browser-tab-Qs8cnQkf.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([14,1,5]))),Ud=(0,Y.lazy)(()=>ir(()=>import(`./dialogs-config-Ct6i8Iij.js`).then(e=>e.t),__vite__mapDeps([5,1]))),Wd=(0,Y.lazy)(()=>ir(()=>import(`./onboarding-DHCR18iU.js`).then(e=>e.t),__vite__mapDeps([8,1,7,5]))),Gd=(0,Y.lazy)(()=>ir(()=>import(`./settings-view-D5GE_CYR.js`),__vite__mapDeps([15,1,3,4,7,5,8,16,17,10])));function Kd(e){return e.startsWith(`/settings`)||e===`/review`||e===`/todos`}function qd(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background`,children:(0,$.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-muted border-t-primary`})}),e[0]=t):t=e[0],t}function Jd(){let e=si(),t=Q(e=>e.selectedThreadId),n=Q(e=>e.selectedProjectId),i=Q(e=>e.sidebarOpen),o=Q(e=>e.deletingThreadIds),s=Q(e=>e.deletingProjectIds);(0,Y.useEffect)(()=>{window.__electrobunWebviewId&&new Lr({})},[]);let c=Wn(),l=$n(),u=Ld(),[d,f]=(0,Y.useState)(null),{projects:p,handleSelectThread:m,handleCreateProject:h,handleCreateWebApp:g,handleCreateFolder:_,handleOpenFolder:v,handleCreateThread:y,handleDeleteThread:b,confirmDeleteProject:x,refreshProjects:S,pendingSetupScriptConfirmation:C,resolveSetupScriptConfirmation:w}=Ad({onProjectCreated:f}),{processingThreadIds:T,completedThreadIds:E,clearCompleted:D}=Fd(),[O,k]=(0,Y.useState)(`chat`),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,ee]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(0),[V,te]=(0,Y.useState)(null),[ne,re]=(0,Y.useState)(0),{terminalState:H}=li(t),ie=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{H.open&&t===ie.current&&!Kd(l.pathname)&&k(`terminal`),ie.current=t},[H.open,t,l.pathname]);let[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(!1),[U,W]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),he=(0,Y.useRef)(null),ge=l.pathname.startsWith(`/settings`),_e=l.pathname===`/review`,ve=l.pathname===`/todos`;(0,Y.useEffect)(()=>{l.pathname===`/`&&O===`tasks`&&k(`chat`)},[l.pathname]);let ye=(0,Y.useRef)(O),be=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(ge){if(be.current===null){be.current=Date.now(),ye.current=O;return}ye.current!==O&&c(`/`)}else be.current=null;ye.current=O},[O,ge,c]);let Se=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=ge||_e||ve;if(t&&Se.current===null)Se.current=i,i&&e({type:Z.ToggleSidebar});else if(!t&&Se.current!==null){let t=Se.current;Se.current=null,t&&!i&&e({type:Z.ToggleSidebar})}},[ge,_e,ve]),(0,Y.useEffect)(()=>{(async()=>{try{(await a()).updateAvailable&&fe(!0)}catch{}})()},[]);let Ce=(0,Y.useCallback)(async()=>{me(!0);try{await bt()}catch{me(!1)}},[]);(0,Y.useEffect)(()=>{le||(async()=>{try{(await xe()).onboardingCompleted||ce(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ue(!0)}})()},[le]),(0,Y.useEffect)(()=>{se||e({type:Z.ConfigUpdated})},[se,e]);let we=(0,Y.useCallback)(e=>{let t=p.find(t=>t.projectId===e);t&&W({id:t.projectId,name:tt(t)})},[p]),Te=(0,Y.useCallback)(e=>{f(e),y(e,void 0)},[y]);(0,Y.useEffect)(()=>{d&&n===d&&t&&f(null)},[d,n,t]);let Ee=(0,Y.useCallback)(async(n,r)=>{f(null),D(r),l.pathname!==`/`&&c(`/`),k(`chat`),t!==r&&re(e=>e+1),m(n,r),u&&i&&e({type:Z.ToggleSidebar})},[m,u,i,t,e,D,l.pathname,c]);(0,Y.useEffect)(()=>{i?he.current?.expand():he.current?.collapse()},[i]);let De={activeMainTab:O,setActiveMainTab:k,devServerUrl:A,setDevServerUrl:j,devServerRunning:M,setDevServerRunning:N,devServerLoading:P,setDevServerLoading:F,terminalNotification:I,setTerminalNotification:L,pendingExplorerPath:R,setPendingExplorerPath:ee,explorerRefreshTick:z,triggerExplorerRefresh:()=>B(e=>e+1),explorerClearPath:V,setExplorerClearPath:te,browserResetTrigger:ne,triggerBrowserReset:()=>re(e=>e+1)};return(0,$.jsxs)(sa.Provider,{value:De,children:[(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Ed,{})}),(0,$.jsxs)(r,{delayDuration:200,children:[(0,$.jsxs)(dd,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(fd,{ref:he,defaultSize:u?100:25,minSize:u?50:12,maxSize:u?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(ki,{projects:p,selectedThreadId:t,selectedProjectId:n,processingThreadIds:T,completedThreadIds:E,deletingThreadIds:o,deletingProjectIds:s,onSelectThread:Ee,onCreateProject:()=>oe(!0),onCreateThread:Te,onDeleteThread:b,onDeleteProject:we,onDeselect:()=>e({type:Z.ClearSelection}),collapsed:!i,updateAvailable:de,updatingApp:pe,onUpdateApp:Ce,expandProjectId:d})})}),!u&&(0,$.jsx)(pd,{withHandle:!0,className:i?`ml-[-40px]`:``}),(0,$.jsx)(fd,{minSize:40,className:`overflow-hidden ${u&&i?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!_e&&!ge&&!ve&&(0,$.jsx)(td,{}),!_e&&!ge&&!ve&&t&&(0,$.jsx)(`div`,{className:`flex border-b border-border shrink-0 select-none`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{onClick:()=>{k(t),t===`terminal`&&L(!1)},className:`relative px-4 py-2 text-base font-medium transition-colors ${O===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&I&&O!==`terminal`&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1 h-1.5 w-1.5 rounded-full bg-brand`})]},t)})}),(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden${!_e&&!ge&&!ve&&O!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(Xn,{children:[(0,$.jsx)(Un,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(qd,{}),children:(0,$.jsx)(Gd,{})})}),(0,$.jsx)(Un,{path:`/settings/:tab?`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(qd,{}),children:(0,$.jsx)(Gd,{})})}),(0,$.jsx)(Un,{path:`*`,element:(0,$.jsx)(Tu,{onCreateThread:Te})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${O===`terminal`&&!_e&&!ge&&!ve?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Rd,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${O===`browser`&&!_e&&!ge&&!ve?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Hd,{})})}),!_e&&!ge&&!ve&&O!==`chat`&&O!==`terminal`&&O!==`browser`&&(O===`explorer`?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Vd,{})}):O===`tasks`&&n?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(zd,{projectId:n})}):O===`review`&&t?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Bd,{threadId:t,onExit:()=>k(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Ud,{open:ae,onOpenChange:oe,onSubmitClone:h,onSubmitWebApp:g,onSubmitFolder:_,onOpenFolder:v})}),(0,$.jsx)(od,{open:U!==null,projectName:U?.name,onOpenChange:e=>!e&&W(null),onConfirm:()=>{U&&(x(U.id),W(null))}}),(0,$.jsx)(sd,{open:C!==null,setupScripts:C?[C.command,...C.remainingScripts||[]]:[],onConfirm:w}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Wd,{open:se,onOpenChange:ce,onComplete:()=>{ue(!0),S()}})}),(0,$.jsx)(ld,{})]}),(0,$.jsx)(Sd,{})]})]})}function Yd(){let e=(0,X.c)(3),[t]=(0,Y.useState)(ii),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Jd,{}),e[0]=n):n=e[0];let r;return e[1]===t?r=e[2]:(r=(0,$.jsx)(Td,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(ai.Provider,{value:t,children:n})}),e[1]=t,e[2]=r),r}var Xd=75,Zd=125,Qd=100;function $d(e){document.documentElement.style.fontSize=`${e}%`}function ef(){let[e,t]=(0,Y.useState)(()=>rt(Qd));(0,Y.useEffect)(()=>{$d(e)},[e]);function n(e){let n=Math.max(Xd,Math.min(Zd,Math.round(e)));t(n),ln(n)}return{scale:e,updateScale:n,resetScale:(0,Y.useCallback)(()=>{n(Qd)},[]),min:Xd,max:Zd,default:Qd}}function tf(){$d(rt(Qd))}tf();var nf=!1;window.addEventListener(`resize`,()=>{nf||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,kr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Y.StrictMode,{children:(0,$.jsx)(Kn,{children:(0,$.jsx)(Yd,{})})}));export{Q as A,Xi as C,ui as D,pi as E,Z as O,ca as S,wi as T,ko as _,Qu as a,Za as b,hu as c,Ml as d,Zc as f,Ro as g,Po as h,dd as i,li as j,si as k,pu as l,No as m,pd as n,Bu as o,Oo as p,fd as r,fu as s,ef as t,mu as u,Xa as v,Oi as w,ha as x,Qa as y};
|