tarsk 0.5.34 → 0.5.36
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/README.md +2 -0
- package/dist/index.js +1283 -790
- package/dist/public/assets/account-view-BB-ze5ek.js +1 -0
- package/dist/public/assets/api-DzFQRz0u.js +1 -0
- package/dist/public/assets/browser-tab-B3bYbBws.js +1 -0
- package/dist/public/assets/commit-dialog-CJRMd4oA.js +1 -0
- package/dist/public/assets/context-menu-86TNA1D0.js +1 -0
- package/dist/public/assets/create-repo-dialog-nLnVNRqq.js +1 -0
- package/dist/public/assets/{dialogs-config-Ct6i8Iij.js → dialogs-config-I0_cSU2z.js} +14 -14
- package/dist/public/assets/diff-view-B8vWYa_2.js +3 -0
- package/dist/public/assets/explorer-tab-view-BGWQPnkw.js +2 -0
- package/dist/public/assets/explorer-tree-DrLoiF9t.js +1 -0
- package/dist/public/assets/explorer-view-Clm-RCAB.js +1 -0
- package/dist/public/assets/git-history-dialog-CcdMtW0o.js +1 -0
- package/dist/public/assets/git-ops-button-D9m2nmhO.js +2 -0
- package/dist/public/assets/history-view-Be-1C1tJ.js +7 -0
- package/dist/public/assets/index-DVXbmgHY.js +65 -0
- package/dist/public/assets/index-jIBJk8xl.css +1 -0
- package/dist/public/assets/mcp-server-card-bNNoXKsW.js +1 -0
- package/dist/public/assets/merged-pr-dialog-Fj8II9Bt.js +1 -0
- package/dist/public/assets/onboarding-CgP4bJ5F.js +1 -0
- package/dist/public/assets/project-settings-view-DixzP7KH.js +1 -0
- package/dist/public/assets/providers-list-view-BzSUZZyq.js +1 -0
- package/dist/public/assets/pull-request-dialog-ChuHHY3J.js +1 -0
- package/dist/public/assets/{pull-with-changes-dialog-DN0kE6os.js → pull-with-changes-dialog-Ck6aK6Q7.js} +1 -1
- package/dist/public/assets/push-before-pr-dialog-CbtHXjDH.js +1 -0
- package/dist/public/assets/radio-group-ZjNXbvW6.js +1 -0
- package/dist/public/assets/react-vendor-Do-APsQ6.js +16 -0
- package/dist/public/assets/settings-general-view-FwrdJbys.js +1 -0
- package/dist/public/assets/{settings-instructions-view-DULFg6dU.js → settings-instructions-view-BHzMtSvN.js} +1 -1
- package/dist/public/assets/settings-list-BCoqXa_X.js +1 -0
- package/dist/public/assets/settings-mcp-servers-view-DBD-NhPx.js +5 -0
- package/dist/public/assets/{settings-models-skeleton-CN2JkqZh.js → settings-models-skeleton-DsWpzWOw.js} +1 -1
- package/dist/public/assets/settings-models-view-vgV5YHRx.js +1 -0
- package/dist/public/assets/settings-rules-view-DcSXrmaq.js +8 -0
- package/dist/public/assets/settings-skills-view-DVGGs16n.js +2 -0
- package/dist/public/assets/settings-slash-commands-view-BsJw1F4p.js +1 -0
- package/dist/public/assets/settings-subagents-view-BgWhQ9bf.js +2 -0
- package/dist/public/assets/{settings-system-prompt-view-BNM_15ry.js → settings-system-prompt-view-DAAbMucD.js} +1 -1
- package/dist/public/assets/settings-view-DLzrbu69.js +2 -0
- package/dist/public/assets/skeleton-iEZ-dj1s.js +1 -0
- package/dist/public/assets/terminal-panel-C5qj1ctH.js +2 -0
- package/dist/public/assets/{ui-components-Di-9yNr4.js → ui-components-BN8dp4Bi.js} +1 -1
- package/dist/public/assets/{utils-DDDR42pW.js → utils-CU0c_yCM.js} +1 -1
- package/dist/public/assets/{whisper-wasm-Cq5Ofwpd.js → whisper-wasm-EGutPGND.js} +2 -2
- package/dist/public/index.html +12 -9
- package/package.json +1 -1
- package/dist/public/assets/account-view-Ds03urJE.js +0 -1
- package/dist/public/assets/api-BHfaVqlR.js +0 -1
- package/dist/public/assets/browser-tab-Qs8cnQkf.js +0 -1
- package/dist/public/assets/commit-dialog-D4suPxEe.js +0 -1
- package/dist/public/assets/context-menu-S8y0c1Fx.js +0 -1
- package/dist/public/assets/create-repo-dialog-DPKIg1mY.js +0 -1
- package/dist/public/assets/diff-view-rKDEnBLg.js +0 -3
- package/dist/public/assets/explorer-tab-view-JbLbPVAn.js +0 -2
- package/dist/public/assets/explorer-tree-Dq44yA1j.js +0 -1
- package/dist/public/assets/explorer-view-BMrlX2hb.js +0 -1
- package/dist/public/assets/git-history-dialog-CDwIqSZQ.js +0 -1
- package/dist/public/assets/git-ops-button-B6rEla5u.js +0 -2
- package/dist/public/assets/history-view-CFot099O.js +0 -7
- package/dist/public/assets/index-6DhhjIBL.js +0 -65
- package/dist/public/assets/index-sEZ3wJXu.css +0 -1
- package/dist/public/assets/mcp-server-card-DQY1RUPX.js +0 -1
- package/dist/public/assets/merged-pr-dialog-H_fuSmiF.js +0 -1
- package/dist/public/assets/onboarding-DHCR18iU.js +0 -1
- package/dist/public/assets/project-settings-view-CiefnK73.js +0 -1
- package/dist/public/assets/providers-list-view-DVopskGo.js +0 -1
- package/dist/public/assets/pull-request-dialog-Csql6eob.js +0 -1
- package/dist/public/assets/push-before-pr-dialog-IhdlLvWt.js +0 -1
- package/dist/public/assets/radio-group-BaKkAEZR.js +0 -1
- package/dist/public/assets/react-vendor-CjZZeCRj.js +0 -16
- package/dist/public/assets/settings-general-view-BMTxN35t.js +0 -1
- package/dist/public/assets/settings-list-Bdeuh4bJ.js +0 -1
- package/dist/public/assets/settings-mcp-servers-view-CRCtWjP2.js +0 -5
- package/dist/public/assets/settings-models-view-DosllhVB.js +0 -1
- package/dist/public/assets/settings-rules-view-BVWuGrnB.js +0 -8
- package/dist/public/assets/settings-skills-view-DYtcAu9-.js +0 -2
- package/dist/public/assets/settings-slash-commands-view-DFyL1W2n.js +0 -1
- package/dist/public/assets/settings-subagents-view-aCbK95Sk.js +0 -2
- package/dist/public/assets/settings-view-D5GE_CYR.js +0 -2
- package/dist/public/assets/skeleton-pSKdmWyJ.js +0 -1
- package/dist/public/assets/terminal-panel-Ds1tCgQA.js +0 -2
|
@@ -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-D9m2nmhO.js","assets/monaco-CZnIWXyV.js","assets/monaco-Br_kD0ds.css","assets/dialogs-config-I0_cSU2z.js","assets/diff-view-B8vWYa_2.js","assets/history-view-Be-1C1tJ.js","assets/onboarding-CgP4bJ5F.js","assets/context-menu-86TNA1D0.js","assets/react-vendor-Do-APsQ6.js","assets/utils-CU0c_yCM.js","assets/terminal-panel-C5qj1ctH.js","assets/explorer-tab-view-BGWQPnkw.js","assets/browser-tab-B3bYbBws.js","assets/settings-view-DLzrbu69.js","assets/settings-models-skeleton-DsWpzWOw.js","assets/skeleton-iEZ-dj1s.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{$ as t,$a as n,$i as r,A as i,Aa as a,Ai as o,An as s,Ar as c,Ba as l,Bi as u,Bn as d,Bt as f,Ca as p,Ci as m,Cn as h,Cr as g,D as _,Di as v,Dr as y,Ea as b,Ei as x,En as S,Er as C,Fa as w,Fi as T,Ft as E,Gn as D,Ha as O,Hi as k,Hn as A,I as j,In as M,Ji as N,Ka as P,Ki as F,Kn as I,Kt as L,La as R,Ln as z,Lt as B,Ma as V,Mn as H,Mt as ee,N as te,Ni as ne,Nn as U,Nt as re,Oa as ie,On as ae,Or as oe,Ot as se,Pi as ce,Pn as le,Pt as ue,Q as de,Qa as fe,Qi as pe,Qn as me,Qt as he,R as ge,Ra as _e,S as ve,Sa as ye,St as be,T as xe,Ta as Se,Ti as Ce,Tn as we,Tr as Te,Tt as Ee,Ua as De,Ui as Oe,Un as ke,Vi as Ae,Vn as je,Wi as Me,Wn as Ne,Xa as Pe,Xn as Fe,Xt as Ie,Yt as Le,Z as Re,Zi as ze,Zn as Be,Zt as Ve,_n as He,_o as Ue,ao as We,ar as Ge,b as Ke,ba as qe,bi as Je,bt as Ye,c as Xe,ca as Ze,co as Qe,cr as $e,d as et,da as tt,di as nt,dn as rt,dr as W,en as it,eo as at,er as ot,et as st,fa as ct,fi as lt,fn as ut,fo as dt,fr as G,g as ft,ga as pt,gn as mt,go as ht,gt,hn as _t,in as vt,io as yt,j as bt,ja as xt,jn as St,jr as Ct,kr as wt,kt as Tt,la as Et,li as K,ln as Dt,lo as Ot,lr as kt,lt as At,m as jt,ma as Mt,mn as Nt,mr as q,na as Pt,nn as Ft,no as It,nr as Lt,nt as Rt,oa as zt,or as Bt,ot as Vt,p as Ht,pa as Ut,pi as Wt,pn as Gt,po as Kt,pr as qt,q as Jt,qa as Yt,qn as Xt,qt as Zt,ra as Qt,rn as $t,sa as en,si as J,so as tn,ta as nn,to as rn,tr as an,tt as on,ui as sn,un as cn,ut as ln,v as un,va as dn,vn as fn,vo as pn,w as mn,wa as hn,wi as gn,wt as _n,x as vn,xa as yn,xi as bn,yi as xn,yn as Sn,yo as Cn,za as wn,zn as Tn}from"./dialogs-config-I0_cSU2z.js";import{$ as En,A as Dn,B as On,D as kn,E as An,F as jn,G as Mn,H as Nn,I as Pn,J as Fn,K as In,L as Ln,M as Rn,N as zn,O as Bn,P as Vn,Q as Hn,R as Un,T as Wn,U as Gn,V as Kn,W as qn,X as Jn,Y as Yn,Z as Xn,at as Zn,ct as Qn,et as $n,it as er,j as tr,k as nr,nt as rr,ot as ir,q as ar,rt as or,st as sr,tt as cr,ut as lr,w as ur,z as dr}from"./react-vendor-Do-APsQ6.js";import{r as fr}from"./monaco-CZnIWXyV.js";import{c as pr,l as mr,r as hr,u as gr}from"./onboarding-CgP4bJ5F.js";import{A as _r,F as vr,M as yr,N as br,O as xr,P as Sr,a as Cr,j as wr,k as Tr,l as Er,n as Dr,o as Or,s as kr,x as Ar}from"./history-view-Be-1C1tJ.js";import{a as jr,i as Mr,n as Nr,o as Pr,r as Fr,t as Ir}from"./whisper-wasm-EGutPGND.js";import{n as Lr,t as Rr}from"./utils-CU0c_yCM.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(Cn(),1),zr=lr(),X=Ue(),Br=1e10,Vr=1e3;function Hr(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 Ur(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=Vr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Br?++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 Hr([`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 Hr([`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 Hr([`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 Hr([`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 Wr(e,t){let n=Ur({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 Gr=window.__electrobunWebviewId,Kr=window.__electrobunRpcSocketPort,qr=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:${Kr}/socket?webviewId=${Gr}`);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 Wr(`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 Jr(e){return typeof e==`string`?e.replace(/\\n/g,`
|
|
3
|
+
`).replace(/✅/g,`✓`):``}function Yr(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 Xr(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 Zr(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 Qr(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 Xr(e);if(typeof e==`object`&&e)return Zr(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(...Xr(i)):n.push(...Zr(i));let a=t.substring(r+1).trim();return a&&n.push({type:`text`,text:a}),n}catch{}}}return null}function $r(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 ei(e,t){return e[e.length-1]?.type===`content`?[...e.slice(0,-1),{type:`content`,chunks:[t]}]:[...e,{type:`content`,chunks:[t]}]}function ti(e,t){return[...e,{type:`long_running_confirmation`,prompt:t}]}function ni(e,t){return[...e,{type:`shell_permission`,prompt:t}]}function ri(e,t){return[...e,{type:`web_fetch_permission`,prompt:t}]}function ii(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=Yr(e)??[];t.push(...n)}else{let n=Qr(e)??(e.trim()?[{type:`text`,text:e}]:[]);t.push(...n)}}return t}function ai(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 oi(e){let t=ii(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.CloseSidebar=`CLOSE_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}({}),si={isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0};function ci(){return{...si,streamingSegments:[]}}function li(e,t){return t?e[t]??ci():ci()}function ui(e,t){return t.threadId??e.selectedThreadId}function di(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 fi={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 pi(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=li(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,...ci(),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=ui(e,t);return di(e,n,{...li(e.threadStreamingStates,n),isStreaming:t.isStreaming})}case`APPEND_STREAM_CONTENT`:{let n=ui(e,t),r=li(e.threadStreamingStates,n);return di(e,n,{...r,streamingContent:r.streamingContent+t.content})}case`SET_STREAM_CONTENT`:{let n=ui(e,t),r=li(e.threadStreamingStates,n),i=ei(r.streamingSegments,t.content);return di(e,n,{...r,streamingContent:t.content,streamingSegments:i})}case`APPEND_STREAM_THINKING`:{let n=ui(e,t),r=li(e.threadStreamingStates,n);return di(e,n,{...r,streamingThinking:r.streamingThinking+t.content})}case`INCREMENT_STREAM_EVENT_COUNT`:{let n=ui(e,t),r=li(e.threadStreamingStates,n);return di(e,n,{...r,streamingEventCount:r.streamingEventCount+1})}case`APPEND_STREAM_CHUNK`:{let n=ui(e,t),r=li(e.threadStreamingStates,n);return di(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=ui(e,t);return di(e,n,{...li(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 di(e,ui(e,t),ci(),!0);case`STOP_STREAM`:{let n=ui(e,t);return di(e,n,{...li(e.threadStreamingStates,n),isStreaming:!1})}case`TOGGLE_SIDEBAR`:return{...e,sidebarOpen:!e.sidebarOpen};case`CLOSE_SIDEBAR`:return e.sidebarOpen?{...e,sidebarOpen:!1}:e;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 mi(e=fi){let t=e,n=new Set;function r(){return t}function i(e){let r=pi(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 hi=(0,Y.createContext)(null);function gi(){let e=(0,Y.useContext)(hi);if(!e)throw Error(`useAppStore must be used within an AppStoreContext.Provider`);return e}function Q(e){let t=(0,X.c)(3),n=gi(),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 _i(){return gi().dispatch}var vi={open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};function yi(e){let t=(0,X.c)(8),n=_i(),r;t[0]===e?r=t[1]:(r=t=>(e?t.terminalStates[e]:void 0)??vi,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 $=o(),bi=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=K(`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});bi.displayName=`Textarea`;function xi(e){let t=(0,X.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:l,onFeedbackTextChange:u,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(c,{children:[(0,$.jsx)(Ct,{children:`Send Feedback`}),(0,$.jsx)(oe,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(g,{htmlFor:`feedback-name`,children:`Name`}),t[1]=h):h=t[1];let _;t[2]===a?_=t[3]:(_=e=>a(e.target.value),t[2]=a,t[3]=_);let v=f||d,b;t[4]!==i||t[5]!==_||t[6]!==v?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(Te,{id:`feedback-name`,value:i,onChange:_,placeholder:`Your name`,disabled:v})]}),t[4]=i,t[5]=_,t[6]=v,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(g,{htmlFor:`feedback-email`,children:`Email`}),t[8]=x):x=t[8];let S;t[9]===s?S=t[10]:(S=e=>s(e.target.value),t[9]=s,t[10]=S);let w=f||d,T;t[11]!==o||t[12]!==S||t[13]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[x,(0,$.jsx)(Te,{id:`feedback-email`,type:`email`,value:o,onChange:S,placeholder:`you@example.com`,disabled:w})]}),t[11]=o,t[12]=S,t[13]=w,t[14]=T):T=t[14];let E;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(g,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=E):E=t[15];let D;t[16]===u?D=t[17]:(D=e=>u(e.target.value),t[16]=u,t[17]=D);let O;t[18]!==l||t[19]!==f||t[20]!==D?(O=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[E,(0,$.jsx)(bi,{id:`feedback-text`,value:l,onChange:D,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=l,t[19]=f,t[20]=D,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==b||t[24]!==T?(k=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[b,T,O]}),t[22]=O,t[23]=b,t[24]=T,t[25]=k):k=t[25];let A;t[26]===r?A=t[27]:(A=()=>r(!1),t[26]=r,t[27]=A);let j;t[28]!==f||t[29]!==A?(j=(0,$.jsx)(J,{variant:`outline`,onClick:A,disabled:f,children:`Cancel`}),t[28]=f,t[29]=A,t[30]=j):j=t[30];let M;t[31]===f?M=t[32]:(M=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send`,t[31]=f,t[32]=M);let N;t[33]!==p||t[34]!==f||t[35]!==M?(N=(0,$.jsx)(J,{onClick:p,disabled:f,children:M}),t[33]=p,t[34]=f,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==j||t[38]!==N?(P=(0,$.jsxs)(wt,{children:[j,N]}),t[37]=j,t[38]=N,t[39]=P):P=t[39];let F;t[40]!==k||t[41]!==P?(F=(0,$.jsxs)(y,{className:`max-w-xl`,children:[m,k,P]}),t[40]=k,t[41]=P,t[42]=F):F=t[42];let I;return t[43]!==r||t[44]!==n||t[45]!==F?(I=(0,$.jsx)(C,{open:n,onOpenChange:r,children:F}),t[43]=r,t[44]=n,t[45]=F,t[46]=I):I=t[46],I}function Si(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)(Si,{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 Ci(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=K(`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)(Si,{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 wi=1,Ti=1e6,Ei=0;function Di(){return Ei=(Ei+1)%(2**53-1),Ei.toString()}var Oi=new Map,ki=e=>{if(Oi.has(e))return;let t=setTimeout(()=>{Oi.delete(e),Ni({type:`REMOVE_TOAST`,toastId:e})},Ti);Oi.set(e,t)},Ai=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,wi)};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?ki(n):e.toasts.forEach(e=>{ki(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)}}},ji=[],Mi={toasts:[]};function Ni(e){Mi=Ai(Mi,e),ji.forEach(e=>{e(Mi)})}function Pi({...e}){let t=Di(),n=e=>Ni({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>Ni({type:`DISMISS_TOAST`,toastId:t});return Ni({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function Fi(){let e=(0,X.c)(4),[t,n]=Y.useState(Mi),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(ji.push(n),()=>{let e=ji.indexOf(n);e>-1&&ji.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:Pi,dismiss:Ii},e[2]=t,e[3]=a),a}function Ii(e){return Ni({type:`DISMISS_TOAST`,toastId:e})}function Li(){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),Vt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&Pi({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){Pi({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await z(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),Pi({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){Pi({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Ri(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% - 42px)`},t[0]=u):u=t[0];let d=l&&`cursor-pointer`,f;t[1]===d?f=t[2]:(f=K(`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 h;t[6]!==r||t[7]!==o?(h=!r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:m.sectionTitle,children:`Tarsk`}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(We,{className:`h-3 w-3 text-sidebar-foreground/60`}),(0,$.jsx)(`span`,{className:K(m.label,`text-sidebar-foreground/80`),children:o})]})]}),t[6]=r,t[7]=o,t[8]=h):h=t[8];let g;t[9]!==p||t[10]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,h]}),t[9]=p,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==s||t[14]!==a||t[15]!==i?(_=(i??a??s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[s&&!r&&s,i&&(0,$.jsx)(`span`,{className:K(m.compact,`font-medium text-sidebar-foreground/80`),children:i}),a&&(0,$.jsxs)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-sidebar-foreground`,onClick:a,children:[(0,$.jsx)(T,{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]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-3 h-[61px]`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]===n?y=t[21]:(y=(0,$.jsx)(Xe,{className:`flex-1`,children:n}),t[20]=n,t[21]=y);let b;t[22]===c?b=t[23]:(b=c&&(0,$.jsx)(`div`,{className:`border-t border-sidebar-border`,children:c}),t[22]=c,t[23]=b);let x;return t[24]!==b||t[25]!==v||t[26]!==y?(x=(0,$.jsxs)(`div`,{className:`flex flex-col select-none bg-sidebar text-sidebar-foreground mx-2.5 mt-8 md:mr-10 rounded-3xl shadow-2xl overflow-hidden`,style:u,children:[v,y,b]}),t[24]=b,t[25]=v,t[26]=y,t[27]=x):x=t[27],x}function zi(e){let t=(0,X.c)(80),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onDeselect:h,collapsed:g,updateAvailable:_,updatingApp:v,onUpdateApp:y,expandProjectId:b}=e,x=Qn(),{showFeedback:S,feedbackName:C,setFeedbackName:w,feedbackEmail:T,setFeedbackEmail:E,feedbackText:D,setFeedbackText:O,loadingFeedbackUser:k,submittingFeedback:A,handleFeedbackDialogChange:j,handleSubmitFeedback:M}=Li(),N;t[0]===n?N=t[1]:(N=n.map(Bi),t[0]=n,t[1]=N);let P=N,F;t[2]!==g||t[3]!==u?(F=!g&&(0,$.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=u,t[4]=F):F=t[4];let I;t[5]!==g||t[6]!==y||t[7]!==_||t[8]!==v?(I=_&&(0,$.jsxs)(J,{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)(hn,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(Yt,{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]=I):I=t[9];let L;t[10]===x?L=t[11]:(L=()=>void x(`/settings/general`),t[10]=x,t[11]=L);let R;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(pe,{className:`h-4 w-4`}),t[12]=R):R=t[12];let z;t[13]===g?z=t[14]:(z=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=g,t[14]=z);let B;t[15]!==L||t[16]!==z?(B=(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:L,children:[R,z]}),t[15]=L,t[16]=z,t[17]=B):B=t[17];let V;t[18]===j?V=t[19]:(V=()=>j(!0),t[18]=j,t[19]=V);let H,ee;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(yn,{className:`h-4 w-4`}),H=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=H,t[21]=ee):(H=t[20],ee=t[21]);let te;t[22]===V?te=t[23]:(te=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:V,children:[ee,H]})}),t[22]=V,t[23]=te);let ne;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(G,{children:`Send feedback to the Tarsk team`}),t[24]=ne):ne=t[24];let U;t[25]===te?U=t[26]:(U=(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[te,ne]})}),t[25]=te,t[26]=U);let re;t[27]!==U||t[28]!==B?(re=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[B,U]}),t[27]=U,t[28]=B,t[29]=re):re=t[29];let ie;t[30]!==re||t[31]!==I?(ie=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[I,re]}),t[30]=re,t[31]=I,t[32]=ie):ie=t[32];let ae;t[33]===n.length?ae=t[34]:(ae=n.length===0&&(0,$.jsx)(`p`,{className:K(m.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]=ae);let oe;t[35]===b?oe=t[36]:(oe=b?[b]:void 0,t[35]=b,t[36]=oe);let se;t[37]!==o||t[38]!==c||t[39]!==s||t[40]!==x||t[41]!==d||t[42]!==p||t[43]!==f||t[44]!==l||t[45]!==a||t[46]!==n||t[47]!==i||t[48]!==r?(se=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(Vi,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:e=>void x(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(Hi,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${nt(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[37]=o,t[38]=c,t[39]=s,t[40]=x,t[41]=d,t[42]=p,t[43]=f,t[44]=l,t[45]=a,t[46]=n,t[47]=i,t[48]=r,t[49]=se):se=t[49];let ce;t[50]!==P||t[51]!==oe||t[52]!==se?(ce=(0,$.jsx)(Ci,{nodes:P,defaultOpen:!0,forceOpenIds:oe,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:se}),t[50]=P,t[51]=oe,t[52]=se,t[53]=ce):ce=t[53];let le;t[54]!==ae||t[55]!==ce?(le=(0,$.jsx)(`div`,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ae,ce]})}),t[54]=ae,t[55]=ce,t[56]=le):le=t[56];let ue;t[57]!==g||t[58]!==h||t[59]!==ie||t[60]!==F||t[61]!==le?(ue=(0,$.jsx)(Ri,{collapsed:g,onLogoClick:h,headerAction:F,footer:ie,children:le}),t[57]=g,t[58]=h,t[59]=ie,t[60]=F,t[61]=le,t[62]=ue):ue=t[62];let de;t[63]===M?de=t[64]:(de=()=>void M(),t[63]=M,t[64]=de);let fe;t[65]!==T||t[66]!==C||t[67]!==D||t[68]!==j||t[69]!==k||t[70]!==E||t[71]!==w||t[72]!==O||t[73]!==S||t[74]!==A||t[75]!==de?(fe=(0,$.jsx)(xi,{open:S,onOpenChange:j,feedbackName:C,onFeedbackNameChange:w,feedbackEmail:T,onFeedbackEmailChange:E,feedbackText:D,onFeedbackTextChange:O,loadingFeedbackUser:k,submittingFeedback:A,onSubmit:de}),t[65]=T,t[66]=C,t[67]=D,t[68]=j,t[69]=k,t[70]=E,t[71]=w,t[72]=O,t[73]=S,t[74]=A,t[75]=de,t[76]=fe):fe=t[76];let me;return t[77]!==ue||t[78]!==fe?(me=(0,$.jsxs)($.Fragment,{children:[ue,fe]}),t[77]=ue,t[78]=fe,t[79]=me):me=t[79],me}function Bi(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 Vi(e){let t=(0,X.c)(33),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:o,isSelected:s,onCreateThread:c,onDeleteProject:u,onProjectSettings:d}=e,f;t[0]===n?f=t[1]:(f=nt(n),t[0]=n,t[1]=f);let p=f,m=o||s,h=r&&`rotate-90`,g;t[2]===h?g=t[3]:(g=K(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,h),t[2]=h,t[3]=g);let _;t[4]===g?_=t[5]:(_=(0,$.jsx)(We,{className:g}),t[4]=g,t[5]=_);let v;t[6]===n.gitUrl?v=t[7]:(v=n.gitUrl?(0,$.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=n.gitUrl,t[7]=v);let y=(o||s)&&`font-bold text-foreground`,b;t[8]===y?b=t[9]:(b=K(`min-w-0 truncate transition-all block`,y),t[8]=y,t[9]=b);let x;t[10]!==p||t[11]!==b?(x=(0,$.jsx)(`span`,{className:b,children:p}),t[10]=p,t[11]=b,t[12]=x):x=t[12];let S;t[13]!==_||t[14]!==v||t[15]!==x?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,v,x]}),t[13]=_,t[14]=v,t[15]=x,t[16]=S):S=t[16];let C;t[17]!==i||t[18]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:`min-w-0`,onClick:i,children:S}),t[17]=i,t[18]=S,t[19]=C):C=t[19];let w;t[20]!==C||t[21]!==m?(w=(0,$.jsx)(gr,{selected:m,noBackground:!0,className:`h-9 min-w-0 flex-1`,asChild:!0,children:C}),t[20]=C,t[21]=m,t[22]=w):w=t[22];let T;t[23]!==a||t[24]!==c||t[25]!==u||t[26]!==d||t[27]!==n.projectId||t[28]!==n.threads?(T=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center`,children:a?(0,$.jsx)(hn,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(qt,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden can-hover:group-hover:flex items-center justify-center`,onClick:()=>d(n.projectId),children:[(0,$.jsx)(pe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(G,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden can-hover:group-hover:flex items-center justify-center`,onClick:()=>c(n.projectId),children:[(0,$.jsx)(Ze,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(G,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden can-hover:group-hover:flex items-center justify-center text-muted-foreground can-hover:hover:bg-destructive can-hover:hover:text-destructive-foreground transition-colors`,onClick:()=>u(n.projectId),children:[(0,$.jsx)(k,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(G,{side:`right`,children:`Delete project`})]})]})}),t[23]=a,t[24]=c,t[25]=u,t[26]=d,t[27]=n.projectId,t[28]=n.threads,t[29]=T):T=t[29];let E;return t[30]!==w||t[31]!==T?(E=(0,$.jsxs)(`div`,{className:`group mb-1 flex min-w-0 items-center`,children:[w,T]}),t[30]=w,t[31]=T,t[32]=E):E=t[32],E}function Hi(e){let t=(0,X.c)(58),{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),h=n.threadId===i,g,_;t[0]===a?(g=t[1],_=t[2]):(g=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},_=[a],t[0]=a,t[1]=g,t[2]=_),(0,Y.useEffect)(g,_);let v;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(v=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]=v):v=t[7];let y=v,b;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(b=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]=b):b=t[11];let x=b,S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(vr,{children:`Delete Thread`}),t[12]=S):S=t[12];let C;t[13]===x?C=t[14]:(C=(0,$.jsxs)(yr,{children:[`Are you sure you want to delete "`,x,`" and all its files? This action cannot be undone.`]}),t[13]=x,t[14]=C);let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(_r,{children:`Cancel`}),t[15]=w):w=t[15];let T;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(T=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[w,(0,$.jsx)(Tr,{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]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,$.jsxs)(wr,{children:[S,C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==d||t[24]!==E?(D=(0,$.jsx)(xr,{open:d,onOpenChange:f,children:E}),t[23]=d,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(O=()=>l(r,n.threadId),t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=O):O=t[29];let A;t[30]===n.gitStatusDot?A=t[31]:(A=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[30]=n.gitStatusDot,t[31]=A);let j;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(j=K(m.body,`truncate block`),t[32]=j):j=t[32];let M;t[33]===x?M=t[34]:(M=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:j,children:x})}),t[33]=x,t[34]=M);let N;t[35]!==s||t[36]!==o||t[37]!==a?(N=a||o?(0,$.jsx)(hn,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(Qe,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):null,t[35]=s,t[36]=o,t[37]=a,t[38]=N):N=t[38];let P;t[39]!==O||t[40]!==A||t[41]!==M||t[42]!==N?(P=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 w-full`,onClick:O,children:[A,M,N]}),t[39]=O,t[40]=A,t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==h||t[45]!==P?(F=(0,$.jsx)(gr,{selected:h,className:`min-w-0 flex-1`,asChild:!0,children:P}),t[44]=h,t[45]=P,t[46]=F):F=t[46];let I;t[47]!==y||t[48]!==s||t[49]!==o||t[50]!==a?(I=!a&&!o&&!s&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`hidden can-hover:group-hover:flex shrink-0 items-center justify-center text-muted-foreground can-hover:hover:bg-destructive can-hover:hover:text-destructive-foreground transition-colors`,onClick:y,children:[(0,$.jsx)(k,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(G,{side:`right`,children:`Delete thread and files from the repo`})]}),t[47]=y,t[48]=s,t[49]=o,t[50]=a,t[51]=I):I=t[51];let L;t[52]!==F||t[53]!==I?(L=(0,$.jsxs)(`div`,{ref:p,className:`group flex min-w-0 items-center`,children:[F,I]}),t[52]=F,t[53]=I,t[54]=L):L=t[54];let R;return t[55]!==D||t[56]!==L?(R=(0,$.jsxs)($.Fragment,{children:[D,L]}),t[55]=D,t[56]=L,t[57]=R):R=t[57],R}var Ui=e(pn(),1),Wi=.1,Gi=10,Ki=1.25,qi=.001;function Ji(){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=Yi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*Ki)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/Ki)),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*qi;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 Yi(e){return Math.min(Math.max(e,Wi),Gi)}function Xi(){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 Zi(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 fr(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 Qi(e){let t=(0,X.c)(70),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:s,zoomIn:c,zoomOut:l,reset:u,onMouseDown:d,onMouseMove:f,onMouseUp:p}=Ji(),h,g;t[0]===r?(h=t[1],g=t[2]):(h=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[r],t[0]=r,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)($i,_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:K(m.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)(dn,{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]===l?x=t[8]:(x=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[y,b]})}),t[7]=l,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(G,{children:`Zoom out`}),t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsxs)(W,{children:[x,S]}),t[10]=x,t[11]=C);let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=K(m.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 E;t[13]===i?E=t[14]:(E=Math.round(i*100),t[13]=i,t[14]=E);let D;t[15]!==u||t[16]!==E?(D=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:u,className:w,children:[E,`%`]})}),t[15]=u,t[16]=E,t[17]=D):D=t[17];let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(G,{children:`Reset zoom`}),t[18]=O):O=t[18];let k;t[19]===D?k=t[20]:(k=(0,$.jsxs)(W,{children:[D,O]}),t[19]=D,t[20]=k);let A,j;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Ze,{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 M;t[23]===c?M=t[24]:(M=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[A,j]})}),t[23]=c,t[24]=M);let N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(G,{children:`Zoom in`}),t[25]=N):N=t[25];let P;t[26]===M?P=t[27]:(P=(0,$.jsxs)(W,{children:[M,N]}),t[26]=M,t[27]=P);let F,I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(zt,{className:`h-3.5 w-3.5`}),I=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[28]=F,t[29]=I):(F=t[28],I=t[29]);let L;t[30]===u?L=t[31]:(L=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[F,I]})}),t[30]=u,t[31]=L);let R;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(G,{children:`Reset view`}),t[32]=R):R=t[32];let z;t[33]===L?z=t[34]:(z=(0,$.jsxs)(W,{children:[L,R]}),t[33]=L,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,H;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),H=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[36]=V,t[37]=H):(V=t[36],H=t[37]);let ee;t[38]===r?ee=t[39]:(ee=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[V,H]})}),t[38]=r,t[39]=ee);let te;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(G,{children:`Close (Esc)`}),t[40]=te):te=t[40];let ne;t[41]===ee?ne=t[42]:(ne=(0,$.jsxs)(W,{children:[ee,te]}),t[41]=ee,t[42]=ne);let U;t[43]!==k||t[44]!==P||t[45]!==z||t[46]!==ne||t[47]!==C?(U=(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,P,z,B,ne]})]}),t[43]=k,t[44]=P,t[45]=z,t[46]=ne,t[47]=C,t[48]=U):U=t[48];let re=o?`cursor-grabbing`:`cursor-grab`,ie;t[49]===re?ie=t[50]:(ie=K(`flex-1 overflow-hidden select-none`,re),t[49]=re,t[50]=ie);let ae=`translate(${a.x}px, ${a.y}px) scale(${i})`,oe=o?`none`:`transform 0.1s ease-out`,se;t[51]!==ae||t[52]!==oe?(se={transform:ae,transformOrigin:`center center`,transition:oe},t[51]=ae,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===n?ce=t[55]:(ce={__html:n},t[54]=n,t[55]=ce);let le;t[56]!==se||t[57]!==ce?(le=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:se,dangerouslySetInnerHTML:ce}),t[56]=se,t[57]=ce,t[58]=le):le=t[58];let ue;t[59]!==s||t[60]!==d||t[61]!==f||t[62]!==p||t[63]!==ie||t[64]!==le?(ue=(0,$.jsx)(`div`,{ref:s,className:ie,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:le}),t[59]=s,t[60]=d,t[61]=f,t[62]=p,t[63]=ie,t[64]=le,t[65]=ue):ue=t[65];let de;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`div`,{className:K(m.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]=de):de=t[66];let fe;return t[67]!==U||t[68]!==ue?(fe=(0,Ui.createPortal)((0,$.jsx)(qt,{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:[U,ue,de]})}),document.body),t[67]=U,t[68]=ue,t[69]=fe):fe=t[69],fe}function $i(){return document.body.style.overflow=`hidden`,ea}function ea(){document.body.style.overflow=``}function ta(e){let t=(0,X.c)(53),{content:n,className:r}=e,[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),{svgOutput:c,renderError:l}=Zi(n,Xi()),u;t[0]===n?u=t[1]:(u=async function(){await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=n,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=K(m.compact,`font-mono text-muted-foreground`),t[2]=f):f=t[2];let h=l?`mermaid (render error)`:`mermaid diagram`,g;t[3]===h?g=t[4]:(g=(0,$.jsx)(`span`,{className:f,children:h}),t[3]=h,t[4]=g);let _;t[5]!==l||t[6]!==c?(_=c&&!l&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`action`,size:`icon-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(p,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(G,{children:`View fullscreen`})]}),t[5]=l,t[6]=c,t[7]=_):_=t[7];let v;t[8]===i?v=t[9]:(v=i?(0,$.jsx)(Qe,{}):(0,$.jsx)(fe,{}),t[8]=i,t[9]=v);let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[10]=y):y=t[10];let b;t[11]!==d||t[12]!==v?(b=(0,$.jsxs)(J,{variant:`action`,size:`icon-xs`,onClick:d,children:[v,y]}),t[11]=d,t[12]=v,t[13]=b):b=t[13];let x;t[14]!==_||t[15]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_,b]}),t[14]=_,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==g||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[g,x]}),t[17]=g,t[18]=x,t[19]=S):S=t[19];let C=S;if(l){let e;t[20]===r?e=t[21]:(e=K(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[20]=r,t[21]=e);let i;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(i=K(m.compact,`font-mono text-foreground leading-relaxed`),t[22]=i):i=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:i,children:n})}),t[23]=n,t[24]=a);let o;return t[25]!==C||t[26]!==e||t[27]!==a?(o=(0,$.jsxs)(`div`,{className:e,children:[C,a]}),t[25]=C,t[26]=e,t[27]=a,t[28]=o):o=t[28],o}if(!c){let e;t[29]===r?e=t[30]:(e=K(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[29]=r,t[30]=e);let n;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:K(m.compact,`p-4 text-muted-foreground`),children:`Rendering diagram…`}),t[31]=n):n=t[31];let i;return t[32]!==C||t[33]!==e?(i=(0,$.jsxs)(`div`,{className:e,children:[C,n]}),t[32]=C,t[33]=e,t[34]=i):i=t[34],i}let w;t[35]===r?w=t[36]:(w=K(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[35]=r,t[36]=w);let T;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>s(!0),t[37]=T):T=t[37];let E;t[38]===c?E=t[39]:(E=(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:T,dangerouslySetInnerHTML:{__html:c}})}),t[38]=c,t[39]=E);let D;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(G,{children:`Click to view fullscreen`}),t[40]=D):D=t[40];let O;t[41]===E?O=t[42]:(O=(0,$.jsxs)(W,{children:[E,D]}),t[41]=E,t[42]=O);let k;t[43]!==C||t[44]!==w||t[45]!==O?(k=(0,$.jsxs)(`div`,{className:w,children:[C,O]}),t[43]=C,t[44]=w,t[45]=O,t[46]=k):k=t[46];let A;t[47]!==o||t[48]!==c?(A=o&&(0,$.jsx)(Qi,{svgOutput:c,onClose:()=>s(!1)}),t[47]=o,t[48]=c,t[49]=A):A=t[49];let j;return t[50]!==k||t[51]!==A?(j=(0,$.jsxs)(qt,{children:[k,A]}),t[50]=k,t[51]=A,t[52]=j):j=t[52],j}var na=`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(`.`),ra=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 ia(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(na.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of ra)t.test(e)&&r++;return r>=2}function aa(e){if(!ia(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 na.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var oa=(0,Y.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Y.useMemo)(()=>!e||typeof e!=`string`?[]:sa(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:K(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(ca,{block:e,start:i[t]},t))})});function sa(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`||ia(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&&ia(e)){let t=aa(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var ca=(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:m.sectionTitle,2:K(m.body,`font-semibold`),3:K(m.body,`font-semibold`),4:m.sectionSubtitle,5:m.sectionSubtitle,6:m.sectionSubtitle};r=e,i=K(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)(la,{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)(da,{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)(la,{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=K(m.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)(la,{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=K(m.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(fa),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=K(m.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)(la,{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=K(m.body,`w-full`),t[32]=e):e=t[32];let r;t[33]===n.headers?r=t[34]:(r=n.headers.map(pa),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(ha),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)(ta,{content:n.code}),t[44]=n.code,t[45]=e),e}default:return null}}),la=(0,Y.memo)(function(e){let t=(0,X.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=ua(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(ga),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 ua(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 da(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=K(m.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)(Qe,{}):(0,$.jsx)(fe,{}),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)(J,{variant:`action`,size:`icon-xs`,onClick:s,children:[d,f]}),t[8]=s,t[9]=d,t[10]=p):p=t[10];let h;t[11]!==u||t[12]!==p?(h=(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]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=K(m.mono,`text-foreground leading-relaxed`),t[14]=g):g=t[14];let _;t[15]===r?_=t[16]:(_=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:g,children:r})}),t[15]=r,t[16]=_);let v;return t[17]!==_||t[18]!==h?(v=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[h,_]}),t[17]=_,t[18]=h,t[19]=v):v=t[19],v}function fa(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(la,{text:e})},t)}function pa(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(la,{text:e})},t)}function ma(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(la,{text:e})},t)}function ha(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ma)},t)}function ga(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:K(m.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 _a=(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 va(){return(0,Y.useContext)(_a)}var ya=new RegExp(String.raw`\x1B\[[0-?]*[ -/]*[@-~]`,`g`),ba=new RegExp(String.raw`\x1B\].*?(?:\x07|\x1B\\)`,`g`),xa=new RegExp(String.raw`\x1B[@-_]`,`g`),Sa=/\r(?!\n)/g,Ca=/\\n/g;function wa(e){return e.replace(ba,``).replace(ya,``).replace(xa,``)}function Ta(e){return wa(e).replace(Ca,`
|
|
14
|
+
`).replace(Sa,`
|
|
15
|
+
`)}function Ea(e){return Je(e)}function Da(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 Oa(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function ka(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 Aa(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Aa);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=ka(r);t[n]=typeof e==`object`?Aa(e):r}else t[n]=Aa(r);return t}function ja(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 Ma(e){if(e==null)return``;let t=typeof e==`object`&&e?Aa(e):e;return Ta(ja(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2)))}function Na(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:Da(Oa(i),t),d=Da(o?String(i.prompt):null,t),f=Da(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=Da(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??Je(n),I=e.activeDisplayName??xn(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 Pa=new Map;function Fa(e){return e.trim()}function Ia(){let e=an(I.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[Fa(e)]=r);return n}catch{return{}}}function La(e){kt(I.BASH_COMMAND_DURATIONS,JSON.stringify(e))}function Ra(e){return Ia()[Fa(e)]??null}function za(e,t){let n=Fa(e);if(!n||!Number.isFinite(t)||t<=0)return;let r=Ia();r[n]=Math.round(t),La(r)}function Ba(e,t){!t?.trim()||Pa.has(e)||Pa.set(e,{command:Fa(t),startedAt:Date.now()})}function Va(e){let t=Pa.get(e);if(!t)return;let n=Date.now()-t.startedAt;za(t.command,n),Pa.delete(e)}function Ha(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 Ua(e,t){return t!==null&&t>0?`${Math.min(99,Math.round(e/t*100))}% complete`:Ha(e)}var Wa=1e3;function Ga(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?Ra(n):null),Ba(t,e),s.current=Date.now(),i(0)}else !n&&c.current&&(Va(t),s.current=null,i(0),o(null));c.current=n},[n,e,t]),(0,Y.useEffect)(()=>()=>{l.current&&Va(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,Wa);return()=>clearInterval(t)},[n]),n?Ua(r,a):null}function Ka(e){let{maxHeight:t=`48`,padding:n=`2`,leading:r=!1,className:i}=e??{};return K(m.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 qa(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)(c,{children:(0,$.jsx)(Ct,{children:(0,$.jsx)(`code`,{className:m.mono,children:i})})}),t[0]=i,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Ka({padding:`3`,className:`flex-1 max-h-none`}),t[2]=s):s=t[2];let l;t[3]===a?l=t[4]:(l=(0,$.jsx)(`pre`,{className:s,children:a}),t[3]=a,t[4]=l);let u;t[5]!==o||t[6]!==l?(u=(0,$.jsxs)(y,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[o,l]}),t[5]=o,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==r||t[9]!==n||t[10]!==u?(d=(0,$.jsx)(C,{open:n,onOpenChange:r,children:u}),t[8]=r,t[9]=n,t[10]=u,t[11]=d):d=t[11],d}function Ja(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=K(m.caption,`font-mono whitespace-pre-wrap overflow-auto`),t[5]=i):i=t[5],a=e.map(Xa),o=s.map(Ya),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 Ya(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 Xa(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 Za(e){let t=(0,X.c)(3),{name:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=K(m.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 Qa(e){let t=(0,X.c)(3),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=K(m.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 $a(e){let t=(0,X.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=K(m.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 eo(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=K(`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 to(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=K(`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=K(m.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)(G,{children:n}),t[10]=n,t[11]=p);let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(W,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}function no(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),h=a?p??i??``:i??``,g;t[2]===h?g=t[3]:(g=h?Ta(h):``,t[2]=h,t[3]=g);let _=g,v=a?_:``,y=Ga(n.command,n.toolId,!!a),b,x;t[4]===a?(b=t[5],x=t[6]):(b=()=>{a&&!d.current?c(!0):!a&&d.current&&c(!1),d.current=!!a},x=[a],t[4]=a,t[5]=b,t[6]=x),(0,Y.useEffect)(b,x);let S;t[7]!==a||t[8]!==s?(S=()=>{s&&a&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},t[7]=a,t[8]=s,t[9]=S):S=t[9];let C;if(t[10]!==a||t[11]!==s||t[12]!==v?(C=[s,a,v],t[10]=a,t[11]=s,t[12]=v,t[13]=C):C=t[13],(0,Y.useEffect)(S,C),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)(to,{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:K(m.caption,`break-all`),children:n.command}),t[19]=n.command,t[20]=i);let a;t[21]===y?a=t[22]:(a=y&&(0,$.jsx)(`span`,{className:K(m.caption,`tabular-nums shrink-0`),children:y}),t[21]=y,t[22]=a);let l;t[23]===s?l=t[24]:(l=s?(0,$.jsx)(tn,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(We,{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=K(`grid transition-[grid-template-rows] duration-200 ease-in-out`,d),t[32]=d,t[33]=f);let p,h;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(p=K(m.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),h={maxHeight:`7.5em`},t[34]=p,t[35]=h):(p=t[34],h=t[35]);let g;t[36]===v?g=t[37]:(g=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:o,className:p,style:h,children:v})}),t[36]=v,t[37]=g);let _;t[38]!==f||t[39]!==g?(_=(0,$.jsx)(`div`,{className:f,children:g}),t[38]=f,t[39]=g,t[40]=_):_=t[40];let b;return t[41]!==u||t[42]!==_?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[u,_]}),t[41]=u,t[42]=_,t[43]=b):b=t[43],b}if(n.command!==null&&_){let e;t[44]!==n.displayName||t[45]!==n.toolName?(e=(0,$.jsx)(to,{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=K(m.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)(G,{children:`View output`}),t[51]=o):o=t[51];let s;t[52]===a?s=t[53]:(s=(0,$.jsxs)(W,{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]!==_?(d=(0,$.jsx)(qa,{open:l,onOpenChange:u,title:n.command,content:_}),t[57]=n.command,t[58]=l,t[59]=_,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)(to,{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:K(m.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 w;t[72]===s?w=t[73]:(w=()=>c(!s),t[72]=s,t[73]=w);let T;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(T=K(m.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[74]=T):T=t[74];let E;t[75]!==n.activeDisplayName||t[76]!==n.displayName||t[77]!==a||t[78]!==y?(E=a?(0,$.jsxs)($.Fragment,{children:[n.activeDisplayName,y&&(0,$.jsx)(`span`,{className:`ml-2 text-muted-foreground tabular-nums`,children:y})]}):n.displayName,t[75]=n.activeDisplayName,t[76]=n.displayName,t[77]=a,t[78]=y,t[79]=E):E=t[79];let D;t[80]===E?D=t[81]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),t[80]=E,t[81]=D);let O;t[82]===s?O=t[83]:(O=s?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[82]=s,t[83]=O);let k;t[84]!==D||t[85]!==O||t[86]!==w?(k=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:w,className:T,children:[D,O]})}),t[84]=D,t[85]=O,t[86]=w,t[87]=k):k=t[87];let A;t[88]===n.toolName?A=t[89]:(A=(0,$.jsx)(G,{children:n.toolName}),t[88]=n.toolName,t[89]=A);let j;t[90]!==k||t[91]!==A?(j=(0,$.jsxs)(W,{children:[k,A]}),t[90]=k,t[91]=A,t[92]=j):j=t[92];let M;t[93]!==n.toolId||t[94]!==n.toolInput||t[95]!==a||t[96]!==s||t[97]!==v?(M=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),a?(0,$.jsx)(`div`,{ref:o,className:K(m.caption,`text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),style:{maxHeight:`7.5em`},children:v}):n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[93]=n.toolId,t[94]=n.toolInput,t[95]=a,t[96]=s,t[97]=v,t[98]=M):M=t[98];let N;return t[99]!==j||t[100]!==M?(N=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[j,M]}),t[99]=j,t[100]=M,t[101]=N):N=t[101],N}function ro(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?io(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)(to,{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:K(m.caption,`break-all`),children:u}),t[8]=u,t[9]=p);let h;t[10]===f?h=t[11]:(h=f&&(0,$.jsxs)(`span`,{className:K(m.caption,`text-muted-foreground shrink-0`),children:[f.bytes,` bytes · HTTP `,f.code]}),t[10]=f,t[11]=h);let g;t[12]===o?g=t[13]:(g=o?(0,$.jsx)(tn,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(We,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[12]=o,t[13]=g);let _;t[14]!==o||t[15]!==e||t[16]!==d||t[17]!==p||t[18]!==h||t[19]!==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,h,g]}),t[14]=o,t[15]=e,t[16]=d,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]!==o||t[22]!==i?(v=o&&i&&(0,$.jsx)(`pre`,{className:K(m.mono,m.caption,`whitespace-pre-wrap break-all rounded bg-muted/40 p-2 max-h-48 overflow-auto`),children:ao(i)}),t[21]=o,t[22]=i,t[23]=v):v=t[23];let y;return t[24]!==_||t[25]!==v?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[_,v]}),t[24]=_,t[25]=v,t[26]=y):y=t[26],y}let p=n.toolName,h=n.displayName,g=!!a,_;t[27]!==n.displayName||t[28]!==n.toolName||t[29]!==g?(_=(0,$.jsx)(to,{toolName:p,displayName:h,isActive:g}),t[27]=n.displayName,t[28]=n.toolName,t[29]=g,t[30]=_):_=t[30];let v;t[31]===u?v=t[32]:(v=u!==null&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`code`,{className:K(m.mono,m.caption,`break-all`),children:u})}),(0,$.jsx)(G,{children:u})]}),t[31]=u,t[32]=v);let y;t[33]===f?y=t[34]:(y=f&&(0,$.jsxs)(`span`,{className:K(m.caption,`text-muted-foreground`),children:[f.bytes,` bytes · HTTP `,f.code,` · `,f.durationMs,`ms`]}),t[33]=f,t[34]=y);let b;t[35]===i?b=t[36]:(b=i&&(0,$.jsx)(`button`,{type:`button`,className:K(m.caption,`text-brand hover:underline ml-auto`),onClick:()=>l(!0),children:`View result`}),t[35]=i,t[36]=b);let x;t[37]!==_||t[38]!==v||t[39]!==y||t[40]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[_,v,y,b]}),t[37]=_,t[38]=v,t[39]=y,t[40]=b,t[41]=x):x=t[41];let S;t[42]===i?S=t[43]:(S=i?ao(i):``,t[42]=i,t[43]=S);let C;t[44]!==c||t[45]!==S?(C=(0,$.jsx)(qa,{open:c,onOpenChange:l,title:`Fetch result`,content:S}),t[44]=c,t[45]=S,t[46]=C):C=t[46];let w;return t[47]!==C||t[48]!==x?(w=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 my-1`,children:[x,C]}),t[47]=C,t[48]=x,t[49]=w):w=t[49],w}function io(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 ao(e){try{let t=JSON.parse(e);if(typeof t.result==`string`)return t.result}catch{}return e}var oo=cr,so=rr,co=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=K(`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)($n,{children:(0,$.jsx)(En,{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});co.displayName=En.displayName;function lo(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=K(m.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 uo(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=K(m.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 fo(e){let t=(0,X.c)(51),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(d=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]=d):d=t[3];let f=d;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)(oo,{children:[(0,$.jsx)(so,{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)(to,{toolName:n.toolName,displayName:n.displayName,isActive:!1,muted:!1})})})}),(0,$.jsx)(co,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:K(m.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)(to,{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]!==l||t[22]!==f||t[23]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>u(!0):f,className:K(`inline-flex max-w-full items-center gap-2 cursor-pointer`,m.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)(uo,{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)(lo,{type:`added`,count:n.editAddedLineCount}),n.editDeletedLineCount===null?null:(0,$.jsx)(lo,{type:`deleted`,count:n.editDeletedLineCount})]}):null]})}),(0,$.jsx)(G,{children:n.hasEditDiff?`View diff`:n.filePath?Da(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(C,{open:l,onOpenChange:u,children:(0,$.jsxs)(y,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:(0,$.jsx)(`code`,{className:K(m.caption,`font-mono`),children:Da(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)(Ja,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:K(m.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(G,{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]=l,t[22]=f,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 p;t[28]===o?p=t[29]:(p=()=>s(!o),t[28]=o,t[29]=p);let h;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(h=K(m.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[30]=h):h=t[30];let g;t[31]===n.displayName?g=t[32]:(g=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[31]=n.displayName,t[32]=g);let _;t[33]===o?_=t[34]:(_=o?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[33]=o,t[34]=_);let v;t[35]!==p||t[36]!==g||t[37]!==_?(v=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:p,className:h,children:[g,_]})}),t[35]=p,t[36]=g,t[37]=_,t[38]=v):v=t[38];let b;t[39]===n.toolName?b=t[40]:(b=(0,$.jsx)(G,{children:n.toolName}),t[39]=n.toolName,t[40]=b);let x;t[41]!==v||t[42]!==b?(x=(0,$.jsxs)(W,{children:[v,b]}),t[41]=v,t[42]=b,t[43]=x):x=t[43];let S;t[44]!==n.toolId||t[45]!==n.toolInput||t[46]!==o?(S=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[44]=n.toolId,t[45]=n.toolInput,t[46]=o,t[47]=S):S=t[47];let w;return t[48]!==x||t[49]!==S?(w=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[x,S]}),t[48]=x,t[49]=S,t[50]=w):w=t[50],w}function po(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)($a,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)($a,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)($a,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)($a,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)($a,{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 mo(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)(to,{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=K(m.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)(G,{children:`View results`}),t[8]=u):u=t[8];let f;t[9]===s?f=t[10]:(f=(0,$.jsxs)(W,{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 h;t[14]!==c||t[15]!==i||t[16]!==d?(h=(0,$.jsx)(qa,{open:c,onOpenChange:l,title:d,content:i}),t[14]=c,t[15]=i,t[16]=d,t[17]=h):h=t[17];let g;return t[18]!==p||t[19]!==h?(g=(0,$.jsxs)($.Fragment,{children:[p,h]}),t[18]=p,t[19]=h,t[20]=g):g=t[20],g}let e;t[21]!==n.displayName||t[22]!==n.toolName||t[23]!==a?(e=(0,$.jsx)(to,{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)(po,{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:K(m.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=K(m.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 h;t[36]===a?h=t[37]:(h=a&&(0,$.jsx)(eo,{size:`md`}),t[36]=a,t[37]=h);let g;t[38]===n.displayName?g=t[39]:(g=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=g);let _;t[40]!==n.codeSearchFileGlob||t[41]!==n.codeSearchFilePath||t[42]!==n.codeSearchQuery||t[43]!==n.pattern||t[44]!==u?(_=u&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:K(m.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:K(m.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:K(m.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:K(m.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]=_):_=t[45];let v;t[46]===o?v=t[47]:(v=o?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[46]=o,t[47]=v);let y;t[48]!==f||t[49]!==h||t[50]!==g||t[51]!==_||t[52]!==v?(y=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[h,g,_,v]})}),t[48]=f,t[49]=h,t[50]=g,t[51]=_,t[52]=v,t[53]=y):y=t[53];let b;t[54]===n.toolName?b=t[55]:(b=(0,$.jsx)(G,{children:n.toolName}),t[54]=n.toolName,t[55]=b);let x;t[56]!==y||t[57]!==b?(x=(0,$.jsxs)(W,{children:[y,b]}),t[56]=y,t[57]=b,t[58]=x):x=t[58];let S;t[59]!==n.toolId||t[60]!==n.toolInput||t[61]!==o||t[62]!==u||t[63]!==i?(S=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:Ka({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]=S):S=t[64];let C;return t[65]!==S||t[66]!==x?(C=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[x,S]}),t[65]=S,t[66]=x,t[67]=C):C=t[67],C}function ho(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)(so,{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)(to,{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=K(m.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)(co,{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)(oo,{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)(Za,{name:n.agentName}),t[16]=n.agentName,t[17]=l);let u;t[18]===n.subagentType?u=t[19]:(u=n.subagentType&&(0,$.jsx)(Qa,{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=K(m.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)(eo,{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)(Za,{name:n.agentName}),t[31]=n.agentName,t[32]=d);let f;t[33]===n.subagentType?f=t[34]:(f=n.subagentType&&(0,$.jsx)(Qa,{type:n.subagentType}),t[33]=n.subagentType,t[34]=f);let p;t[35]===a?p=t[36]:(p=a?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[35]=a,t[36]=p);let h;t[37]!==s||t[38]!==l||t[39]!==u||t[40]!==d||t[41]!==f||t[42]!==p?(h=(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]=h):h=t[43];let g;t[44]===n.toolName?g=t[45]:(g=(0,$.jsx)(G,{children:n.toolName}),t[44]=n.toolName,t[45]=g);let _;t[46]!==h||t[47]!==g?(_=(0,$.jsxs)(W,{children:[h,g]}),t[46]=h,t[47]=g,t[48]=_):_=t[48];let v;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==a?(v=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ka({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=a,t[53]=v):v=t[53];let y;return t[54]!==_||t[55]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[54]=_,t[55]=v,t[56]=y):y=t[56],y}function go(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=K(m.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)(eo,{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)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{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)(G,{children:n.toolName}),t[14]=n.toolName,t[15]=p);let h;t[16]!==f||t[17]!==p?(h=(0,$.jsxs)(W,{children:[f,p]}),t[16]=f,t[17]=p,t[18]=h):h=t[18];let g;t[19]!==n.toolId||t[20]!==n.toolInput||t[21]!==a?(g=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[19]=n.toolId,t[20]=n.toolInput,t[21]=a,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g?(_=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[h,g]}),t[23]=h,t[24]=g,t[25]=_):_=t[25],_}function _o(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)(to,{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)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:K(m.caption,`truncate max-w-[200px] sm:max-w-[320px]`),children:n.imageGenPrompt})}),(0,$.jsx)(G,{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=K(m.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)(eo,{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)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{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)(G,{children:n.toolName}),t[23]=n.toolName,t[24]=p);let h;t[25]!==f||t[26]!==p?(h=(0,$.jsxs)(W,{children:[f,p]}),t[25]=f,t[26]=p,t[27]=h):h=t[27];let g;t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==a?(g=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[28]=n.toolId,t[29]=n.toolInput,t[30]=a,t[31]=g):g=t[31];let _;return t[32]!==h||t[33]!==g?(_=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[h,g]}),t[32]=h,t[33]=g,t[34]=_):_=t[34],_}function vo(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)(oo,{children:[(0,$.jsx)(so,{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)(to,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(co,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:K(m.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)(to,{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)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:K(m.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(G,{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=K(m.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)(eo,{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)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{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)(G,{children:n.toolName}),t[27]=n.toolName,t[28]=p);let h;t[29]!==f||t[30]!==p?(h=(0,$.jsxs)(W,{children:[f,p]}),t[29]=f,t[30]=p,t[31]=h):h=t[31];let g;t[32]!==n.prompt||t[33]!==n.toolId||t[34]!==n.toolInput||t[35]!==a?(g=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ka({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ka(),children:n.toolInput}):null]}),t[32]=n.prompt,t[33]=n.toolId,t[34]=n.toolInput,t[35]=a,t[36]=g):g=t[36];let _;return t[37]!==h||t[38]!==g?(_=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[h,g]}),t[37]=h,t[38]=g,t[39]=_):_=t[39],_}function yo(e){let t=(0,X.c)(40),{block:n,inline:r,resultContent:i,isActive:a}=e,{setPendingExplorerPath:o,setActiveMainTab:s}=va(),c=Q(bo),l=Na(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)(no,{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)(ro,{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)(fo,{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)(mo,{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)(ho,{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)(go,{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)(_o,{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)(vo,{data:l,inline:r,isActive:u}),t[36]=l,t[37]=r,t[38]=u,t[39]=e):e=t[39],e}}}function bo(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}var xo=(0,Y.createContext)({todos:[],setTodos:()=>{}});function So(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)(xo.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function Co(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 wo(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Y.useContext)(xo),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 To(e){let t=gn(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 Eo(e){let t=(0,X.c)(29),{imageUrl:n,imageData:r}=e,[i,a]=(0,Y.useState)(!1),o=r?`data:image/png;base64,${r}`:n??``,s;t[0]===o?s=t[1]:(s=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await vt(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:o,filename:e});Pi({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=o,t[1]=s);let c=s,l;t[2]===o?l=t[3]:(l=async()=>{await Ke(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:o}),a(!0),setTimeout(()=>a(!1),2e3)},t[2]=o,t[3]=l);let u=l;if(!o)return null;let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d={maxHeight:`512px`},t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=(0,$.jsx)(`img`,{src:o,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:d}),t[5]=o,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Yt,{className:`h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===c?m=t[9]:(m=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,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:p})}),t[8]=c,t[9]=m);let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(G,{children:`Save image`}),t[10]=h):h=t[10];let g;t[11]===m?g=t[12]:(g=(0,$.jsxs)(W,{children:[m,h]}),t[11]=m,t[12]=g);let _;t[13]===i?_=t[14]:(_=i?(0,$.jsx)(Qe,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(fe,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=_);let v;t[15]!==u||t[16]!==_?(v=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:u,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:_})}),t[15]=u,t[16]=_,t[17]=v):v=t[17];let y=i?`Copied!`:`Copy to clipboard`,b;t[18]===y?b=t[19]:(b=(0,$.jsx)(G,{children:y}),t[18]=y,t[19]=b);let x;t[20]!==v||t[21]!==b?(x=(0,$.jsxs)(W,{children:[v,b]}),t[20]=v,t[21]=b,t[22]=x):x=t[22];let S;t[23]!==x||t[24]!==g?(S=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(qt,{children:[g,x]})}),t[23]=x,t[24]=g,t[25]=S):S=t[25];let C;return t[26]!==S||t[27]!==f?(C=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[f,S]}),t[26]=S,t[27]=f,t[28]=C):C=t[28],C}function Do(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),[l,u]=(0,Y.useState)(!1),d=Q(Oo),f=n.toolName??`Unknown Tool`,p=n.toolCallId??`unknown`,h=n,g=n.result??h.content,_;t[0]!==h||t[1]!==f?(_=f===`todo`?Co(h):null,t[0]=h,t[1]=f,t[2]=_):_=t[2];let v=_,b,x,S,w,T,E;if(t[3]!==h||t[4]!==r||t[5]!==g||t[6]!==d||t[7]!==a||t[8]!==v||t[9]!==f){E=Symbol.for(`react.early_return_sentinel`);bb0:{if(S=Da(Ma(g),d),!(S.length>0)&&v===null){E=null;break bb0}let e;if(t[16]!==g||t[17]!==d||t[18]!==f){if(b=Ea(f),typeof g==`object`&&g){let e=g,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),b=e}else if(f===`read`||f===`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),b=`Completed ${e}`}}}else if(g==null){let e;t[25]===f?e=t[26]:(e=Ea(f),t[25]=f,t[26]=e),b=`${e} (no result)`}e=Da(b,d),t[16]=g,t[17]=d,t[18]=f,t[19]=b,t[20]=e}else b=t[19],e=t[20];if(b=e,v!==null){let e;t[27]!==a||t[28]!==v?(e=(0,$.jsx)(wo,{todos:v,sequence:a}),t[27]=a,t[28]=v,t[29]=e):e=t[29],E=e;break bb0}if(f===`generate_image`){let e;t[30]!==h||t[31]!==g?(e=To(g)??To(h),t[30]=h,t[31]=g,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)(Eo,{imageUrl:n.imageUrl,imageData:n.imageData}),t[33]=n.imageData,t[34]=n.imageUrl,t[35]=e):e=t[35],E=e;break bb0}}if(r){E=null;break bb0}let n;t[36]===f?n=t[37]:(n=f.toLowerCase().includes(`bash`),t[36]=f,t[37]=n),x=n,w=S?S.split(`
|
|
22
|
+
`):[],T=x?w.slice(0,3).join(`
|
|
23
|
+
`):S}t[3]=h,t[4]=r,t[5]=g,t[6]=d,t[7]=a,t[8]=v,t[9]=f,t[10]=b,t[11]=x,t[12]=S,t[13]=w,t[14]=T,t[15]=E}else b=t[10],x=t[11],S=t[12],w=t[13],T=t[14],E=t[15];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let D=T,O=x&&w.length>3;if(x){let e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(e=K(m.body,`px-3 py-2 flex items-center gap-2 font-medium text-foreground`),t[38]=e):e=t[38];let n;t[39]===b?n=t[40]:(n=(0,$.jsx)(`div`,{className:e,children:(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:b})}),t[39]=b,t[40]=n);let r;t[41]!==O||t[42]!==D||t[43]!==S||t[44]!==w?(r=S&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[O?(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`pre`,{className:K(m.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:()=>u(!0),children:[D,(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
24
|
+
`,`...`]})]})}),(0,$.jsx)(G,{children:`Click to see full output`})]}):(0,$.jsx)(`pre`,{className:K(m.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2`),children:D}),O&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:K(m.caption,`mt-1 text-brand hover:underline`),children:[`Show full output (`,w.length,` lines)`]})]}),t[41]=O,t[42]=D,t[43]=S,t[44]=w,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]!==l||t[50]!==O||t[51]!==S?(a=O&&(0,$.jsx)(C,{open:l,onOpenChange:u,children:(0,$.jsxs)(y,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:K(m.caption,`bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`),children:S})]})}),t[49]=l,t[50]=O,t[51]=S,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 k;t[56]===o?k=t[57]:(k=()=>s(!o),t[56]=o,t[57]=k);let A;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(A=K(m.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]=A):A=t[58];let j;t[59]===b?j=t[60]:(j=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:b}),t[59]=b,t[60]=j);let M;t[61]===o?M=t[62]:(M=o?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[61]=o,t[62]=M);let N;t[63]!==k||t[64]!==j||t[65]!==M?(N=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:k,className:A,children:[j,M]})}),t[63]=k,t[64]=j,t[65]=M,t[66]=N):N=t[66];let P=`${f} result`,F;t[67]===P?F=t[68]:(F=(0,$.jsx)(G,{children:P}),t[67]=P,t[68]=F);let I;t[69]!==F||t[70]!==N?(I=(0,$.jsxs)(W,{children:[N,F]}),t[69]=F,t[70]=N,t[71]=I):I=t[71];let L;t[72]!==o||t[73]!==S||t[74]!==p?(L=o&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,`text-muted-foreground mb-2 font-mono`),children:[`Call ID: `,p]}),S&&(0,$.jsx)(`pre`,{className:K(m.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`),children:S})]}),t[72]=o,t[73]=S,t[74]=p,t[75]=L):L=t[75];let R;return t[76]!==I||t[77]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[I,L]}),t[76]=I,t[77]=L,t[78]=R):R=t[78],R}function Oo(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}function ko(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 Ao(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 ${ko(n)}.`}function jo(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),h=(0,Y.useRef)(o),g,_;t[1]===o?(g=t[2],_=t[3]):(g=()=>{o&&!h.current?(l.current=Date.now(),d(0),p(!0)):o?p(!0):h.current&&!o&&(d(Date.now()-l.current),p(!1)),h.current=o},_=[o],t[1]=o,t[2]=g,t[3]=_),(0,Y.useEffect)(g,_);let v;t[4]!==f||t[5]!==o?(v=()=>{f&&o&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},t[4]=f,t[5]=o,t[6]=v):v=t[6];let y;if(t[7]!==f||t[8]!==o||t[9]!==a?(y=[a,f,o],t[7]=f,t[8]=o,t[9]=a,t[10]=y):y=t[10],(0,Y.useEffect)(v,y),!a&&!o)return null;let b=!o&&i===`Validated`,x;t[11]!==u||t[12]!==o||t[13]!==i?(x=Ao(o,i,u),t[11]=u,t[12]=o,t[13]=i,t[14]=x):x=t[14];let S=x,C;t[15]===a?C=t[16]:(C=a?Ta(a):``,t[15]=a,t[16]=C);let w=C,T;t[17]===f?T=t[18]:(T=()=>p(!f),t[17]=f,t[18]=T);let E;t[19]===b?E=t[20]:(E=b?(0,$.jsx)(It,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):null,t[19]=b,t[20]=E);let D;t[21]===S?D=t[22]:(D=(0,$.jsx)(`span`,{className:m.caption,children:S}),t[21]=S,t[22]=D);let O;t[23]!==f||t[24]!==T||t[25]!==E||t[26]!==D?(O=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:T,"aria-expanded":f,children:[E,D]}),t[23]=f,t[24]=T,t[25]=E,t[26]=D,t[27]=O):O=t[27];let k=f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,A;t[28]===k?A=t[29]:(A=[`grid transition-[grid-template-rows] duration-200 ease-in-out`,k],t[28]=k,t[29]=A);let j=A.join(` `),M,N;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=K(m.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`),N={maxHeight:`7.5em`},t[30]=M,t[31]=N):(M=t[30],N=t[31]);let P;t[32]===w?P=t[33]:(P=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:s,className:M,style:N,children:w})}),t[32]=w,t[33]=P);let F;t[34]!==j||t[35]!==P?(F=(0,$.jsx)(`div`,{className:j,children:P}),t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;return t[37]!==O||t[38]!==F?(I=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[O,F]}),t[37]=O,t[38]=F,t[39]=I):I=t[39],I}function Mo(e){let t=(0,X.c)(63),{toolCall:n,className:r}=e,i=_i(),[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(Io),u=Q(Fo),d;t[2]!==n.activeDisplayName||t[3]!==n.name?(d=n.activeDisplayName??xn(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(Po)},t[5]=p):p=t[5];let h=p,g;t[6]!==i||t[7]!==u||t[8]!==n.id||t[9]!==n.name?(g=()=>{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]=g):g=t[10];let _=g,v=No,y=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,b=n.name===`fetch`&&typeof n.input?.url==`string`?n.input.url:null,x=!y&&typeof n.input?.description==`string`?n.input.description:null,S;t[11]===r?S=t[12]:(S=K(`overflow-hidden mb-2`,r),t[11]=r,t[12]=S);let C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(eo,{}),t[13]=C):C=t[13];let w;t[14]===f?w=t[15]:(w=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[C,(0,$.jsx)(`span`,{className:m.bodyMuted,children:f})]})}),t[14]=f,t[15]=w);let E;t[16]===n.name?E=t[17]:(E=(0,$.jsx)(G,{children:n.name}),t[16]=n.name,t[17]=E);let D;t[18]!==w||t[19]!==E?(D=(0,$.jsxs)(W,{children:[w,E]}),t[18]=w,t[19]=E,t[20]=D):D=t[20];let O;t[21]===y?O=t[22]:(O=y!==null&&(0,$.jsx)(`code`,{className:K(m.mono,m.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:y}),t[21]=y,t[22]=O);let k;t[23]===b?k=t[24]:(k=b!==null&&(0,$.jsx)(`code`,{className:K(m.mono,m.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:b.length>60?`${b.slice(0,59)}…`:b}),t[23]=b,t[24]=k);let A;t[25]===x?A=t[26]:(A=x!==null&&(0,$.jsx)(`span`,{className:m.bodyMuted,children:x}),t[25]=x,t[26]=A);let j;t[27]!==y||t[28]!==x||t[29]!==b?(j=!y&&!b&&!x&&(0,$.jsx)(`span`,{className:m.bodyMuted,children:`running`}),t[27]=y,t[28]=x,t[29]=b,t[30]=j):j=t[30];let M;t[31]===a?M=t[32]:(M=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:h,className:`p-1 hover:bg-muted/50 rounded transition-colors`,children:a?(0,$.jsx)(yt,{className:`h-3 w-3`}):(0,$.jsx)(tn,{className:`h-3 w-3`})})}),t[31]=a,t[32]=M);let N=a?`Collapse`:`Expand`,P;t[33]===N?P=t[34]:(P=(0,$.jsx)(G,{children:N}),t[33]=N,t[34]=P);let F;t[35]!==M||t[36]!==P?(F=(0,$.jsxs)(W,{children:[M,P]}),t[35]=M,t[36]=P,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(T,{className:`h-3 w-3`}),t[38]=I):I=t[38];let L;t[39]===_?L=t[40]:(L=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:_,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:I})}),t[39]=_,t[40]=L);let R;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(G,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[41]=R):R=t[41];let z;t[42]===L?z=t[43]:(z=(0,$.jsxs)(W,{children:[L,R]}),t[42]=L,t[43]=z);let B;t[44]!==F||t[45]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[F,z]}),t[44]=F,t[45]=z,t[46]=B):B=t[46];let V;t[47]!==O||t[48]!==k||t[49]!==A||t[50]!==j||t[51]!==B||t[52]!==D?(V=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[D,O,k,A,j,B]}),t[47]=O,t[48]=k,t[49]=A,t[50]=j,t[51]=B,t[52]=D,t[53]=V):V=t[53];let H;t[54]!==a||t[55]!==n.id||t[56]!==n.input||t[57]!==c?(H=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:K(m.compact,m.bodyMuted,`mb-2 font-mono`),children:[`ID: `,n.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:K(m.compact,m.label,`text-muted-foreground mb-1`),children:`Input:`}),(0,$.jsx)(`pre`,{className:Ka({className:`border border-border`}),children:v(n.input)})]}),c&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:K(m.compact,m.label,`text-muted-foreground mb-1`),children:`Progress:`}),(0,$.jsxs)(`div`,{className:K(m.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:K(m.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:K(m.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:K(m.compact,`flex items-center gap-1.5 text-muted-foreground`),children:[(0,$.jsx)(eo,{}),`Executing`,c&&` with progress`,`...`]})]}),t[54]=a,t[55]=n.id,t[56]=n.input,t[57]=c,t[58]=H):H=t[58];let ee;return t[59]!==V||t[60]!==H||t[61]!==S?(ee=(0,$.jsxs)(`div`,{className:S,children:[V,H]}),t[59]=V,t[60]=H,t[61]=S,t[62]=ee):ee=t[62],ee}function No(e){return JSON.stringify(e,null,2)}function Po(e){return!e}function Fo(e){return e.streamingSegments}function Io(e){return e.isStreaming}function Lo(e){let t=(0,X.c)(70),{toolCallId:n,question:r,options:i,context:a,answeredText:o,answeredLabel:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!!o),[f,p]=(0,Y.useState)(o??``),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),y,b;t[0]===o?(y=t[1],b=t[2]):(y=()=>{let e=o?.trim();if(e){d(!0),p(e),g(!1),v(null);return}d(!1),p(``)},b=[o],t[0]=o,t[1]=y,t[2]=b),(0,Y.useEffect)(y,b);let x;t[3]!==h||t[4]!==n?(x=async e=>{if(!(!e.trim()||h)){g(!0);try{await _t(n,e.trim()),p(e.trim()),d(!0)}catch(e){console.error(`Failed to submit answer:`,e),g(!1),v(null)}}},t[3]=h,t[4]=n,t[5]=x):x=t[5];let S=x,C;t[6]!==S||t[7]!==h||t[8]!==u?(C=e=>{u||h||(v(e),S(e))},t[6]=S,t[7]=h,t[8]=u,t[9]=C):C=t[9];let w=C,T;t[10]!==c||t[11]!==S||t[12]!==h||t[13]!==u?(T=()=>{if(u||h)return;let e=c.trim();e&&S(e)},t[10]=c,t[11]=S,t[12]=h,t[13]=u,t[14]=T):T=t[14];let E=T,D;t[15]===E?D=t[16]:(D=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),E())},t[15]=E,t[16]=D);let O=D;if(u){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Qe,{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=K(m.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)(oa,{content:r})}),t[19]=r,t[20]=i);let o;t[21]===a?o=t[22]:(o=a&&(0,$.jsx)(`p`,{className:K(m.bodyMuted,`mt-1`),children:a}),t[21]=a,t[22]=o);let c;t[23]!==o||t[24]!==i?(c=(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]=c):c=t[25];let l=s??`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]===f?d=t[29]:(d=(0,$.jsx)(`span`,{children:f}),t[28]=f,t[29]=d);let p;t[30]!==u||t[31]!==d?(p=(0,$.jsxs)(`div`,{className:m.bodyMuted,children:[u,` `,d]}),t[30]=u,t[31]=d,t[32]=p):p=t[32];let h;return t[33]!==c||t[34]!==p?(h=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[c,p]}),t[33]=c,t[34]=p,t[35]=h):h=t[35],h}let k;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(rn,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[36]=k):k=t[36];let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=K(m.label,`text-foreground`),t[37]=A):A=t[37];let j;t[38]===r?j=t[39]:(j=(0,$.jsx)(`div`,{className:A,children:(0,$.jsx)(oa,{content:r})}),t[38]=r,t[39]=j);let M;t[40]===a?M=t[41]:(M=a&&(0,$.jsx)(`p`,{className:K(m.bodyMuted,`mt-1`),children:a}),t[40]=a,t[41]=M);let N;t[42]!==M||t[43]!==j?(N=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[k,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[j,M]})]}),t[42]=M,t[43]=j,t[44]=N):N=t[44];let P;t[45]!==w||t[46]!==h||t[47]!==i||t[48]!==_?(P=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=_===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(e),disabled:h,className:K(`rounded-md border px-3 py-1.5 transition-colors disabled:opacity-50 flex items-center gap-1.5`,m.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)(Qe,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[45]=w,t[46]=h,t[47]=i,t[48]=_,t[49]=P):P=t[49];let F;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>l(e.target.value),t[50]=F):F=t[50];let I=i?.length?`Or type a custom answer...`:`Type your answer...`,L;t[51]!==c||t[52]!==O||t[53]!==h||t[54]!==I?(L=(0,$.jsx)(`input`,{type:`text`,value:c,onChange:F,onKeyDown:O,placeholder:I,disabled:h,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]=c,t[52]=O,t[53]=h,t[54]=I,t[55]=L):L=t[55];let R;t[56]!==c||t[57]!==h?(R=h||!c.trim(),t[56]=c,t[57]=h,t[58]=R):R=t[58];let z;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Kt,{className:`h-3 w-3`}),t[59]=z):z=t[59];let B;t[60]!==E||t[61]!==R?(B=(0,$.jsx)(`button`,{type:`button`,onClick:E,disabled:R,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]=E,t[61]=R,t[62]=B):B=t[62];let V;t[63]!==L||t[64]!==B?(V=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[L,B]}),t[63]=L,t[64]=B,t[65]=V):V=t[65];let H;return t[66]!==N||t[67]!==P||t[68]!==V?(H=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[N,P,V]}),t[66]=N,t[67]=P,t[68]=V,t[69]=H):H=t[69],H}var Ro=ar,zo=Hn,Bo=Yn,Vo=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=K(K(m.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)(We,{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)(Xn,{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});Vo.displayName=Xn.displayName;var Ho=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=K(`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)(Jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ho.displayName=Jn.displayName;var Uo=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=K(`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)(Mn,{children:(0,$.jsx)(Kn,{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});Uo.displayName=Kn.displayName;var Wo=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=K(K(m.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)(Nn,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Wo.displayName=Nn.displayName;var Go=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=K(K(m.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)(Gn,{children:(0,$.jsx)(Qe,{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)(On,{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});Go.displayName=On.displayName;var Ko=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=K(K(m.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)(Gn,{children:(0,$.jsx)(at,{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)(In,{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});Ko.displayName=In.displayName;var qo=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=K(m.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)(qn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});qo.displayName=qn.displayName;var Jo=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=K(`-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)(Fn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Jo.displayName=Fn.displayName;var Yo=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=K(m.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};Yo.displayName=`DropdownMenuShortcut`;function Xo({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 He(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)(Qe,{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:m.label,children:`Shell command permission`}),(0,$.jsx)(`code`,{className:K(m.mono,m.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:m.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)(ze,{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:m.label,children:`Allow the agent to run this command?`}),(0,$.jsx)(`code`,{className:K(m.mono,m.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)(J,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Ro,{children:[(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,size:`sm`,disabled:l,className:K(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(tn,{className:`h-4 w-4`})})}),(0,$.jsx)(Uo,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Wo,{onClick:()=>void d(e.scope===`project`?`allow_pattern_project`:`allow_pattern_session`,e.pattern),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Skip`})]})]})}function Zo({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 fn(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)(Qe,{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:m.label,children:`Web fetch permission`}),(0,$.jsx)(`code`,{className:K(m.mono,m.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:m.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)(V,{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:m.label,children:`Allow the agent to fetch from this domain?`}),(0,$.jsx)(`code`,{className:K(m.mono,m.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t}),(0,$.jsx)(`div`,{className:K(m.caption,m.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)(J,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Ro,{children:[(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,size:`sm`,disabled:l,className:K(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(tn,{className:`h-4 w-4`})})}),(0,$.jsx)(Uo,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Wo,{onClick:()=>void d(e.scope===`project`?`allow_domain_project`:`allow_domain_session`),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Deny`})]})]})}var Qo=new Map,$o=new Map;function es(e){return Qo.get(e)}function ts(e,t){let n=$o.get(e);return n||(n=new Set,$o.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&$o.delete(e)}}function ns(e){let t=$o.get(e);if(t)for(let e of t)e()}function rs(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 is(e,t,n){if(Qo.has(e))return;Qo.set(e,{status:`running`}),ns(e);let r=le();(async()=>{try{let i=rs(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;Qo.set(e,{status:`success`,result:s}),ns(e),await mt(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);Qo.set(e,{status:`error`,error:n}),ns(e);try{await mt(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function as(e){let t=(0,X.c)(49),{toolCallId:n,intention:r,code:i}=e,a=Q(ss),o;t[0]===n?o=t[1]:(o=es(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,h]=(0,Y.useState)(s?.error??null),g,_;t[4]===n?(g=t[5],_=t[6]):(g=()=>ts(n,()=>{let e=es(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`&&h(e.error??null)}),_=[n],t[4]=n,t[5]=g,t[6]=_),(0,Y.useEffect)(g,_);let v,y;t[7]!==i||t[8]!==a||t[9]!==n?(v=()=>{a&&is(n,i,a)},y=[n,i,a],t[7]=i,t[8]=a,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Y.useEffect)(v,y);let[b,x]=(0,Y.useState)(!1),S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>x(os),t[12]=S):S=t[12];let C=S;if(c===`running`){let e,n;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=K(m.label,`w-full py-2 flex items-center gap-2`),n=(0,$.jsx)(Pe,{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=K(m.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),n=(0,$.jsx)(Pe,{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]===b?s=t[22]:(s=b?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[21]=b,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]!==b||t[28]!==d?(l=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:K(m.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i}),d!=null&&(0,$.jsx)(`pre`,{className:K(m.body,`leading-relaxed whitespace-pre-wrap border-t border-border pt-2`),children:d})]}),t[26]=i,t[27]=b,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=K(m.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),T=(0,$.jsx)(Pe,{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]===b?O=t[38]:(O=b?(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),t[37]=b,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]!==b?(A=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:K(m.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:p}),(0,$.jsx)(`pre`,{className:K(m.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i})]}),t[42]=i,t[43]=p,t[44]=b,t[45]=A):A=t[45];let j;return t[46]!==k||t[47]!==A?(j=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),t[46]=k,t[47]=A,t[48]=j):j=t[48],j}function os(e){return!e}function ss(e){return e.selectedThreadId}function cs(e){let t=(0,X.c)(29),{src:n}=e,[r,i]=(0,Y.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await vt(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});Pi({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=async()=>{await Ke(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:n}),i(!0),setTimeout(()=>i(!1),2e3)},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={maxHeight:`512px`},t[4]=l):l=t[4];let u;t[5]===n?u=t[6]:(u=(0,$.jsx)(`img`,{src:n,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:l}),t[5]=n,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Yt,{className:`h-3.5 w-3.5`}),t[7]=d):d=t[7];let f;t[8]===o?f=t[9]:(f=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:o,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:d})}),t[8]=o,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(G,{children:`Save image`}),t[10]=p):p=t[10];let m;t[11]===f?m=t[12]:(m=(0,$.jsxs)(W,{children:[f,p]}),t[11]=f,t[12]=m);let h;t[13]===r?h=t[14]:(h=r?(0,$.jsx)(Qe,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(fe,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=h);let g;t[15]!==c||t[16]!==h?(g=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,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:h})}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _=r?`Copied!`:`Copy to clipboard`,v;t[18]===_?v=t[19]:(v=(0,$.jsx)(G,{children:_}),t[18]=_,t[19]=v);let y;t[20]!==g||t[21]!==v?(y=(0,$.jsxs)(W,{children:[g,v]}),t[20]=g,t[21]=v,t[22]=y):y=t[22];let b;t[23]!==y||t[24]!==m?(b=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(qt,{children:[m,y]})}),t[23]=y,t[24]=m,t[25]=b):b=t[25];let x;return t[26]!==b||t[27]!==u?(x=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[u,b]}),t[26]=b,t[27]=u,t[28]=x):x=t[28],x}function ls(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 us(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 ds(e,t){return e.some(e=>e.type===`tool-result`&&e.toolCallId===t)}function fs(e,t){if(t)return us(e,t)}function ps(e,t,n){return(0,$.jsx)(Lo,{toolCallId:e.toolCallId??`long-running-confirmation`,question:e.question,options:e.options,context:e.context,answeredText:n,answeredLabel:`You answered`},t)}function ms(e,t,n){return(0,$.jsx)(Xo,{toolCallId:e.toolCallId,command:e.command,projectId:n,wildcardOptions:e.wildcardOptions},t)}function hs(e,t,n){return(0,$.jsx)(Zo,{toolCallId:e.toolCallId,hostname:e.hostname,url:e.url,projectId:n,wildcardOptions:e.wildcardOptions},t)}function gs(e,t,n,r,i){if(e.name===`ask_user`)return(0,$.jsx)(Lo,{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)(as,{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)(Mo,{toolCall:e},t):(0,$.jsx)(yo,{inline:!0,block:e,resultContent:a?i:r,isActive:a},t)}function _s({message:e,threadId:t,messageIndex:r=0,showCheckpointRestore:i=!1,checkpointRestoreTooltip:a}){let o=e.sender===`user`,s=o?null:Qr(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 h(){if(!(!e.checkpointRef||!t||c)){l(!0);try{let n=await it(t,e.checkpointRef);n.success?Pi({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):Pi({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){Pi({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{l(!1)}}}async function g(){try{await navigator.clipboard.writeText(e.content),d(!0),setTimeout(()=>d(!1),2e3)}catch(e){Pi({title:`Copy failed`,description:e instanceof Error?e.message:`Could not copy prompt.`,variant:`destructive`})}}return(0,$.jsx)(`div`,{className:K(`group px-4 py-4`,o&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:K(`flex flex-col gap-1 min-w-0 max-w-full`,o&&`items-end`),children:[(0,$.jsxs)(`div`,{className:K(`flex items-center gap-2`,o&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:K(m.compact,`font-medium text-foreground`),children:o?`You`:`Agent`}),o&&(0,$.jsx)(qt,{children:(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:g,"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)(Qe,{className:`h-3 w-3 text-green-500`}):(0,$.jsx)(fe,{className:`h-3 w-3`})})})}),(0,$.jsx)(G,{side:`left`,children:u?`Copied prompt`:`Copy prompt`})]}),f&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:i?h: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)(zt,{className:K(`h-3 w-3`,c&&`animate-spin`)})})})}),(0,$.jsx)(G,{side:`left`,children:a??`Restore checkpoint`})]})]})}),p&&(0,$.jsxs)(`span`,{className:K(m.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(n,{className:`h-2.5 w-2.5`}),p]}),e.model&&(0,$.jsxs)(`span`,{className:K(m.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`}),mr(e.model)]}),e.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:K(m.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(Oe,{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:K(m.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?v(e.metadata.estimatedCost):null]})]}),(0,$.jsx)(`div`,{className:K(`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=Yr(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:ai(t,!1).map((e,n)=>{if(e.type===`thinking-group`){let t=e;return(0,$.jsx)(jo,{text:t.text,label:t.label,isStreaming:!1},`tg-${n}`)}let r=e;if(r.type===`tool_use`)return gs(r,n,!1,us(t,r.id));if(r.type===`long_running_confirmation`){let e=r.prompt;return ps(e,n,fs(t,e.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return ms(e,n)}if(r.type===`web_fetch_permission`){let e=r.prompt;return hs(e,n)}return r.type===`tool-result`?(0,$.jsx)(Do,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:K(m.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:(0,$.jsx)(oa,{content:Jr(e.content),enableMermaid:!0})})})():s?(0,$.jsx)($.Fragment,{children:ai(s,!1).map((e,t)=>{if(e.type===`thinking-group`){let n=e;return(0,$.jsx)(jo,{text:n.text,label:n.label,isStreaming:!1},`tg-${t}`)}let n=e;if(n.type===`tool_use`&&n.name===`todo`||n.type===`tool-result`&&n.toolName===`todo`)return n.type===`tool-result`?(0,$.jsx)(Do,{inline:!0,sequence:r,block:n},t):null;if(n.type===`tool-result`&&n.toolName===`ask_user`)return null;if(n.type===`long_running_confirmation`){let e=n.prompt;return ps(e,t,fs(s,e.toolCallId))}return(0,$.jsx)(`div`,{children:n.type===`text`&&`text`in n?(0,$.jsx)(oa,{content:Jr(n.text),enableMermaid:!0}):n.type===`tool_use`?gs(n,void 0,!1,us(s,n.id)):n.type===`tool-result`?(0,$.jsx)(Do,{inline:!0,block:n}):null},t)})}):(0,$.jsx)(oa,{content:Jr(e.content),enableMermaid:!0,className:m.body})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(cs,{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:K(m.compact,`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-muted-foreground`),children:[(0,$.jsx)(ct,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}function vs(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(ys),f,p,h,g;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=ii(n),s=u?`pb-0`:`pb-4`;t[12]===s?g=t[13]:(g=K(`group px-4 pt-4`,s),t[12]=s,t[13]=g),f=`flex flex-col gap-1 min-w-0`;let c;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:K(m.compact,`font-medium text-foreground`),children:`Agent`}),t[14]=c):c=t[14];let _;t[15]===r?_=t[16]:(_=r&&(0,$.jsxs)(`span`,{className:K(m.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`}),mr(r)]}),t[15]=r,t[16]=_),t[17]===_?p=t[18]:(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,_]}),t[17]=_,t[18]=p),h=e.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-base`,children:ai(e,!0).map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(jo,{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)(Do,{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 ps(t,`stream-${n}`,fs(e,t.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return ms(e,`stream-${n}`,i)}if(r.type===`web_fetch_permission`){let e=r.prompt;return hs(e,`stream-${n}`,i)}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(oa,{content:Jr(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=r.id,n=us(e,t),i=ls(d[t]??{});return gs(r,void 0,!ds(e,t),n,i)})():r.type===`tool-result`?(0,$.jsx)(Do,{inline:!0,block:r}):null},`b-${n}`)})}):a||o?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(jo,{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]=h,t[11]=g}else f=t[8],p=t[9],h=t[10],g=t[11];let _;t[19]!==f||t[20]!==p||t[21]!==h?(_=(0,$.jsxs)(`div`,{className:f,children:[p,h]}),t[19]=f,t[20]=p,t[21]=h,t[22]=_):_=t[22];let v;return t[23]!==g||t[24]!==_?(v=(0,$.jsx)(`div`,{className:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25],v}function ys(e){return e.toolCallProgress}var bs=(0,Y.memo)(vs,(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}),xs=3e3;function Ss(e){let t=[...x],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function Cs(e){let t=(0,X.c)(3),[n,r]=(0,Y.useState)(Ce),i=(0,Y.useRef)(Ce),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(Ce),i.current=Ce;return}let t=setInterval(()=>{let e=i.current===`Processing...`?Ss():Ss(i.current);i.current=e,r(e)},xs);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Y.useEffect)(a,o),n}var ws=`w-7`,Ts=`-ml-9`;function Es(e){let t=(0,X.c)(11),{active:n,className:r}=e,i=n===void 0?!0:n,a=Cs(i),o;t[0]===r?o=t[1]:(o=K(`flex items-center gap-2`,Ts,r),t[0]=r,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(eo,{className:ws}),t[2]=s):s=t[2];let c=i?`animate-shimmer`:void 0,l;t[3]===c?l=t[4]:(l=K(m.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 Ds(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 u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:K(m.pageTitle,`tracking-tight text-balance`),children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 ${m.pageSubtitle}`,children:d})]})]}),t[2]=d,t[3]=f);let p;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)(l,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`${m.body} text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:m.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],p=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=p}else p=t[7];let h,g,_;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(R,{className:`h-5 w-5 text-muted-foreground`}),g=(0,$.jsx)(`span`,{className:`${m.body} text-foreground leading-snug font-medium`,children:`Connect a repo`}),_=(0,$.jsx)(`span`,{className:m.caption,children:`Clone an existing repository`}),t[11]=h,t[12]=g,t[13]=_):(h=t[11],g=t[12],_=t[13]);let v;t[14]===a?v=t[15]:(v=(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:[h,g,_]}),t[14]=a,t[15]=v);let y,b,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(tt,{className:`h-5 w-5 text-muted-foreground`}),b=(0,$.jsx)(`span`,{className:`${m.body} text-foreground leading-snug font-medium`,children:`New App`}),x=(0,$.jsx)(`span`,{className:m.caption,children:`Create a new project from template`}),t[16]=y,t[17]=b,t[18]=x):(y=t[16],b=t[17],x=t[18]);let S;t[19]===o?S=t[20]:(S=(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:[y,b,x]}),t[19]=o,t[20]=S);let C,w,T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(wn,{className:`h-5 w-5 text-muted-foreground`}),w=(0,$.jsx)(`span`,{className:`${m.body} text-foreground leading-snug font-medium`,children:`Open Folder`}),T=(0,$.jsx)(`span`,{className:m.caption,children:`Use an existing local folder`}),t[21]=C,t[22]=w,t[23]=T):(C=t[21],w=t[22],T=t[23]);let E;t[24]===s?E=t[25]:(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:s,children:[C,w,T]}),t[24]=s,t[25]=E);let D;t[26]!==S||t[27]!==E||t[28]!==p||t[29]!==v?(D=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[p,v,S,E]}),t[26]=S,t[27]=E,t[28]=p,t[29]=v,t[30]=D):D=t[30];let O;return t[31]!==D||t[32]!==f?(O=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,D]}),t[31]=D,t[32]=f,t[33]=O):O=t[33],O}function Os(){let e=Q(e=>e.selectedThreadId),{dispatch:t}=yi(e),{setActiveMainTab:n,setDevServerUrl:r,setDevServerRunning:i,setDevServerLoading:a}=va();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 rt(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 ks(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 As(e){let t=(0,X.c)(26),{project:n}=e,{setDevServerRunning:r}=va(),[i,a]=(0,Y.useState)(!1),{startServer:o}=Os(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Zt(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=ks(u),t[5]=u,t[6]=d);let f=d,p=!i&&n?.runCommand,h;t[7]!==n||t[8]!==o?(h=()=>{n&&o(n)},t[7]=n,t[8]=o,t[9]=h):h=t[9];let g=h,_;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(m.pageTitle,`tracking-tight text-foreground text-balance`),t[11]=v):v=t[11];let y=n?.name??`Project`,b;t[12]===y?b=t[13]:(b=(0,$.jsx)(`h1`,{className:v,children:y}),t[12]=y,t[13]=b);let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=K(m.pageSubtitle,`mt-2`),t[14]=x):x=t[14];let S;t[15]===f?S=t[16]:(S=(0,$.jsx)(`p`,{className:x,children:f}),t[15]=f,t[16]=S);let C;t[17]!==b||t[18]!==S?(C=(0,$.jsxs)(`div`,{className:`text-center`,children:[b,S]}),t[17]=b,t[18]=S,t[19]=C):C=t[19];let w;t[20]!==g||t[21]!==p?(w=p&&(0,$.jsx)(`button`,{type:`button`,onClick:g,className:K(m.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]=g,t[21]=p,t[22]=w):w=t[22];let T;return t[23]!==C||t[24]!==w?(T=(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:[_,C,w]})}),t[23]=C,t[24]=w,t[25]=T):T=t[25],T}var js=(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});js.displayName=`MessageList`;function Ms(e){let t=(0,X.c)(23),{context:n}=e;if(!n)return null;let{bottomInset:r,isStreaming:i,isCreatingProject:a,isProcessingThread:o,hasPendingMessage:s,hasActiveBlockingPrompt:c,selectedProjectId:l,streamingSegments:u,streamingModel:d,totalMessages:f,error:p,onClearError:h}=n,g=u.length>0||a||o&&(i||s),_=(i||s)&&!c,v;t[0]===r?v=t[1]:(v={paddingBottom:r},t[0]=r,t[1]=v);let y;t[2]!==g||t[3]!==a||t[4]!==o||t[5]!==i||t[6]!==l||t[7]!==_||t[8]!==d||t[9]!==u||t[10]!==f?(y=g&&(i||a||o)&&(0,$.jsx)(bs,{segments:u,model:d,projectId:l,isCreatingProject:a,isProcessingThread:o,totalMessages:f,showProcessingLine:_}),t[2]=g,t[3]=a,t[4]=o,t[5]=i,t[6]=l,t[7]=_,t[8]=d,t[9]=u,t[10]=f,t[11]=y):y=t[11];let b;t[12]!==g||t[13]!==_?(b=_&&(0,$.jsx)(`div`,{className:K(`px-4 pb-4`,g?`pt-0`:`pt-2`),children:(0,$.jsx)(Es,{active:_})}),t[12]=g,t[13]=_,t[14]=b):b=t[14];let x;t[15]!==p||t[16]!==h?(x=p&&(0,$.jsxs)(`div`,{className:`mx-4 my-2`,children:[(0,$.jsx)(Ar,{variant:`error`,className:`mb-0`,children:p}),(0,$.jsx)(`button`,{type:`button`,className:K(m.compact,`mt-1 text-destructive underline underline-offset-2 hover:text-destructive/80`),onClick:h,children:`Dismiss`})]}),t[15]=p,t[16]=h,t[17]=x):x=t[17];let S;return t[18]!==v||t[19]!==y||t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0`,style:v,children:[y,b,x]}),t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S):S=t[22],S}var Ns={List:js,Footer:Ms};function Ps(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 Fs(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 Is(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=Fs(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)}var Ls=(0,Y.forwardRef)(function(e,t){let n=(0,X.c)(71),{bottomInset:r,messages:i,isStreaming:a,streamingSegments:o,streamingModel:s,isCreatingProject:c,isProcessingThread:l,hasPendingMessage:u,selectedThreadId:d,selectedProjectId:f,projects:p,projectsLoading:m,messagesLoaded:h,onSelectThread:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b,error:x,onClearError:S,onAtBottomChange:C}=e,w=r===void 0?0:r,T=(0,Y.useRef)(null),E=(0,Y.useRef)(0),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!1),k;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>({scrollToBottom:()=>{T.current?.scrollTo({top:2**53-1,behavior:`smooth`})}}),n[0]=k):k=n[0],(0,Y.useImperativeHandle)(t,k);let A;n[1]===d?A=n[2]:(A=()=>{d&&T.current?.getState(e=>{$e(d,e.scrollTop)})},n[1]=d,n[2]=A);let j=A,M,N;n[3]===j?(M=n[4],N=n[5]):(M=()=>{let e=()=>{j()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),j()}},N=[j],n[3]=j,n[4]=M,n[5]=N),(0,Y.useEffect)(M,N);let P,F;n[6]===j?(P=n[7],F=n[8]):(P=()=>{let e=setInterval(()=>{j()},5e3);return()=>clearInterval(e)},F=[j],n[6]=j,n[7]=P,n[8]=F),(0,Y.useEffect)(P,F);let I,L;n[9]!==i.length||n[10]!==h||n[11]!==d?(I=()=>{if(!d||!h||O.current||(O.current=!0,i.length===0))return;let e=ot(d);e!==null&&e>0&&requestAnimationFrame(()=>{T.current?.scrollTo({top:e})})},L=[d,h,i.length],n[9]=i.length,n[10]=h,n[11]=d,n[12]=I,n[13]=L):(I=n[12],L=n[13]),(0,Y.useEffect)(I,L);let R;n[14]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{O.current=!1,E.current=0},n[14]=R):R=n[14];let z;n[15]===d?z=n[16]:(z=[d],n[15]=d,n[16]=z),(0,Y.useEffect)(R,z);let B;n[17]!==u||n[18]!==a||n[19]!==i.length?(B=()=>{if(!O.current)return;let e=i.length>E.current,t=D.current&&!a;(a||u||e||t)&&requestAnimationFrame(()=>{T.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),E.current=i.length,D.current=a},n[17]=u,n[18]=a,n[19]=i.length,n[20]=B):B=n[20];let V;n[21]!==u||n[22]!==a||n[23]!==i||n[24]!==o.length?(V=[a,u,i,o.length],n[21]=u,n[22]=a,n[23]=i,n[24]=o.length,n[25]=V):V=n[25],(0,Y.useEffect)(B,V);let H=i.length===0&&!a&&!c&&!d,ee=h&&i.length===0&&!a&&!c&&!l&&!u&&d,te;if(n[26]!==p||n[27]!==f){let e;n[29]===f?e=n[30]:(e=e=>e.projectId===f,n[29]=f,n[30]=e),te=p.find(e),n[26]=p,n[27]=f,n[28]=te}else te=n[28];let ne=te;if(H){let e=`transition-opacity duration-500 ease-in-out ${m?`opacity-0`:`opacity-100`}`,t;n[31]!==v||n[32]!==_||n[33]!==y||n[34]!==b||n[35]!==g||n[36]!==p?(t=(0,$.jsx)(Ds,{projects:p,onSelectProject:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b}),n[31]=v,n[32]=_,n[33]=y,n[34]=b,n[35]=g,n[36]=p,n[37]=t):t=n[37];let r;return n[38]!==e||n[39]!==t?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:t})}),n[38]=e,n[39]=t,n[40]=r):r=n[40],r}if(ee){let e;return n[41]===ne?e=n[42]:(e=(0,$.jsx)(As,{project:ne}),n[41]=ne,n[42]=e),e}let U;n[43]===o?U=n[44]:(U=Is(o),n[43]=o,n[44]=U);let re;n[45]!==w||n[46]!==x||n[47]!==u||n[48]!==c||n[49]!==l||n[50]!==a||n[51]!==i.length||n[52]!==S||n[53]!==f||n[54]!==s||n[55]!==o||n[56]!==U?(re={bottomInset:w,isStreaming:a,isCreatingProject:c,isProcessingThread:l,hasPendingMessage:u,hasActiveBlockingPrompt:U,selectedProjectId:f,streamingSegments:o,streamingModel:s,totalMessages:i.length,error:x,onClearError:S},n[45]=w,n[46]=x,n[47]=u,n[48]=c,n[49]=l,n[50]=a,n[51]=i.length,n[52]=S,n[53]=f,n[54]=s,n[55]=o,n[56]=U,n[57]=re):re=n[57];let ie=re,ae;n[58]===Symbol.for(`react.memo_cache_sentinel`)?(ae=K(`h-full overflow-hidden`),n[58]=ae):ae=n[58];let oe;n[59]===Symbol.for(`react.memo_cache_sentinel`)?(oe={height:`100%`},n[59]=oe):oe=n[59];let se;n[60]!==u||n[61]!==c||n[62]!==l||n[63]!==a||n[64]!==d?(se=(e,t)=>{let n=Ps({isUser:t.sender===`user`,hasCheckpointRef:!!t.checkpointRef,isStreaming:a,hasPendingMessage:u,isCreatingProject:c,isProcessingThread:l});return(0,$.jsx)(_s,{message:t,threadId:d,messageIndex:e,showCheckpointRestore:t.sender===`user`&&!!t.checkpointRef&&!a&&!u&&!c&&!l,checkpointRestoreTooltip:n})},n[60]=u,n[61]=c,n[62]=l,n[63]=a,n[64]=d,n[65]=se):se=n[65];let ce;return n[66]!==ie||n[67]!==i||n[68]!==C||n[69]!==se?(ce=(0,$.jsx)(`div`,{className:ae,children:(0,$.jsx)(or,{ref:T,style:oe,data:i,context:ie,itemContent:se,overscan:500,components:Ns,atBottomStateChange:C})}),n[66]=ie,n[67]=i,n[68]=C,n[69]=se,n[70]=ce):ce=n[70],ce});function Rs(e,t){return e?`linear-gradient(to right, transparent 0, transparent 40px, ${t} 40px)`:`linear-gradient(to right, ${t}, ${t})`}function zs(e){return Rs(e,`hsl(var(--background))`)}function Bs(e){let t=Rs(e,`hsl(var(--background))`);return e?`linear-gradient(to top, hsl(var(--background)) 0, hsl(var(--background)) calc(100% - 40px), transparent calc(100% - 40px), transparent 100%), ${t}`:`linear-gradient(to top, hsl(var(--background)) 0, transparent 100%), ${t}`}function Vs(e,t){return Rs(e,t?`hsl(var(--background) / 0.8)`:`hsl(var(--background))`)}function Hs({initialValue:e}={}){let t=_i(),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,w]=(0,Y.useState)(()=>(n?a[n]:void 0)??null),T=(0,Y.useRef)(C?.id??``),E=(0,Y.useRef)(C?.provider??``),D=(0,Y.useRef)(null),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)([]),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)([]),[H,ee]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)([]),[U,re]=(0,Y.useState)(!1),[ie,oe]=(0,Y.useState)(``),[ce,le]=(0,Y.useState)(0),[ue,fe]=(0,Y.useState)([]),[pe,me]=(0,Y.useState)([]),[he,ge]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(``),ye=(0,Y.useRef)(null),be=(0,Y.useRef)(null),xe=(0,Y.useRef)(null),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null),we=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{T.current=C?.id??``,E.current=C?.provider??``},[C?.id,C?.provider]);let Te=(0,Y.useCallback)((e,r)=>{w(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}`;D.current!==a&&(D.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),ae(i,{model:e.id,modelProvider:e.provider}).then(()=>{D.current===a&&(D.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{D.current===a&&(D.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 de(),t=Object.values(e).flat();if(t.length===0){S([]),w(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=T.current===i.id&&E.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:T.current,provider:E.current}}),c||Te(i,{persist:a})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n,r,i,a,Te]);let Ee=(0,Y.useRef)(Te);(0,Y.useEffect)(()=>{Ee.current=Te},[Te]),(0,Y.useEffect)(()=>{s!==0&&(async()=>{try{let e=await de(),t=Object.values(e).flat();if(t.length>0){S(t);let e=T.current,n=E.current;t.some(t=>t.id===e&&t.provider===n)||Ee.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[s]),(0,Y.useEffect)(()=>{!R||B.length>0||(async()=>{try{let e=await Re(),t=Object.values(e).flat();t.length>0&&(V(t),ee(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[R,B.length]);let[De,Oe]=(0,Y.useState)(n);(0,Y.useEffect)(()=>{if(n!==De){De&&v.current.trim()&&y.current[De]!==v.current&&t({type:Z.SetChatInputDraft,threadId:De,draft:v.current});let e=!1;return queueMicrotask(()=>{e||!b.current||(Oe(n),d(n?y.current[n]??``:``),ne([]),re(!1),fe([]),me([]),ge(!1),F(!1),z(!1),L(!1))}),()=>{e=!0}}},[n,De]),(0,Y.useEffect)(()=>{n&&se(n).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),fe(e),me(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n]);let ke=n?o[n]??``:``;return(0,Y.useEffect)(()=>{n&&d(ke)},[n,ke]),(0,Y.useLayoutEffect)(()=>{let e=be.current;if(!e)return;e.style.height=`auto`;let t=Math.max(e.scrollHeight,e.offsetHeight);e.style.height=`${Math.min(t,160)}px`},[u]),(0,Y.useEffect)(()=>{c&&n&&!l&&(be.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=>{xe.current&&!xe.current.contains(e.target)&&k(!1),Se.current&&!Se.current.contains(e.target)&&j(!1)};if(O||A)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[O,A]),{message:u,setMessage:d,historyIndex:f,setHistoryIndex:p,draftMessage:m,setDraftMessage:h,cursorPosition:g,setCursorPosition:_,availableModels:x,setAvailableModels:S,selectedModel:C,setSelectedModel:Te,selectedModelIdRef:T,showModelMenu:O,setShowModelMenu:k,showPlusMenu:A,setShowPlusMenu:j,attachments:M,setAttachments:N,planMode:P,setPlanMode:F,ralphMode:I,setRalphMode:L,imageMode:R,setImageMode:z,availableImageModels:B,setAvailableImageModels:V,selectedImageModel:H,setSelectedImageModel:ee,allFiles:te,setAllFiles:ne,showSuggestions:U,setShowSuggestions:re,suggestionQuery:ie,setSuggestionQuery:oe,selectedIndex:ce,setSelectedIndex:le,slashCommands:ue,setSlashCommands:fe,skills:pe,setSkills:me,showCommandSuggestions:he,setShowCommandSuggestions:ge,commandQuery:_e,setCommandQuery:ve,fileInputRef:ye,textareaRef:be,modelMenuRef:xe,plusMenuRef:Se,suggestionsRef:Ce,commandSuggestionsRef:we,handleNewChat:async()=>{if(n)try{let e=await ft(n);t({type:Z.ClearMessages}),console.log(`New conversation started:`,e);let r=await st(n);t({type:Z.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},selectedThreadId:n,dispatch:t}}var Us=e=>{Xt(e)};function Ws(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:z,setRalphMode:B,imageMode:V,setImageMode:H,selectedImageModel:te,hasConversationMessages:ne}=e,U;t[0]!==o||t[1]!==m||t[2]!==V||t[3]!==d||t[4]!==l||t[5]!==n||t[6]!==a||t[7]!==c||t[8]!==L||t[9]!==z||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?(U=()=>{if(!n.trim()&&o.length===0||!u)return;let e=V?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:V,ralphMode:z}}):c(n,e.id,o,e.provider,L,V,z);let t=n,h=i.find(e=>e.content===t);Us(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]=V,t[3]=d,t[4]=l,t[5]=n,t[6]=a,t[7]=c,t[8]=L,t[9]=z,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]=U):U=t[21];let re=U,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]!==H||t[33]!==r||t[34]!==R||t[35]!==B||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),B(!1),H(!1)):e.metadata.mode===`ralph`&&(B(!0),R(!1),H(!1))},t[29]=j,t[30]=y,t[31]=n,t[32]=H,t[33]=r,t[34]=R,t[35]=B,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,de,fe,pe;if(t[46]!==T||t[47]!==j||t[48]!==_||t[49]!==re||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){fe=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=de.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),O((D+1)%de.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),O((D-1+de.length)%de.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),de[D]&&ae(de[D]);return}if(e.key===`Escape`){S(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),re();return}let t=Be();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&&ee(u).then(e=>{E(e)}).catch(qs))}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],pe=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(Ks),...a.map(Gs)],t[88]=j,t[89]=ne,t[90]=P,t[91]=N,t[92]=i}else i=t[92];ue=i.slice(0,10),de=x?T.filter(e=>e.toLowerCase().includes(C.toLowerCase())).slice(0,10):[],t[46]=T,t[47]=j,t[48]=_,t[49]=re,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]=de,t[75]=fe,t[76]=pe}else ue=t[73],de=t[74],fe=t[75],pe=t[76];let me;return t[98]!==ue||t[99]!==de||t[100]!==fe||t[101]!==re||t[102]!==pe||t[103]!==se||t[104]!==ae||t[105]!==le?(me={handleSend:re,handleKeyDown:fe,handleTextareaInput:pe,insertFileReference:ae,insertCommand:se,insertSkill:le,allSuggestions:ue,fileSuggestions:de},t[98]=ue,t[99]=de,t[100]=fe,t[101]=re,t[102]=pe,t[103]=se,t[104]=ae,t[105]=le,t[106]=me):me=t[106],me}function Gs(e){return{type:`skill`,data:e}}function Ks(e){return{type:`command`,data:e}}function qs(e){return console.error(`Failed to fetch files:`,e)}var Js=768;function Ys(){let e=(0,X.c)(2),[t,n]=Y.useState(Xs),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Js-1}px)`),t=()=>{n(window.innerWidth<Js)};return e.addEventListener(`change`,t),n(window.innerWidth<Js),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),t}function Xs(){return typeof window>`u`?!1:window.innerWidth<Js}function Zs(e){let t=(0,X.c)(22),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let d;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);d=[...n.map($s),...s.map(Qs)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=d}else d=t[3];let f=d,p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=K(m.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),h=(0,$.jsx)(Me,{className:`h-3 w-3`}),t[8]=p,t[9]=h):(p=t[8],h=t[9]);let g=a&&` matching "${a}"`,_;t[10]===g?_=t[11]:(_=(0,$.jsxs)(`div`,{className:p,children:[h,`Commands & Skills`,g]}),t[10]=g,t[11]=_);let v;t[12]!==f||t[13]!==l||t[14]!==s||t[15]!==c||t[16]!==o?(v=f.length>0?f.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:K(`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:()=>s(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Me,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:m.compact,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:K(m.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:m.compact,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:K(`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:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ce,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:K(m.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:K(m.compact,`rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`),children:`project`})]}),(0,$.jsx)(`span`,{className:m.compact,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:K(m.compact,`px-3 py-4 text-center text-muted-foreground`),children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:m.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]=f,t[13]=l,t[14]=s,t[15]=c,t[16]=o,t[17]=v):v=t[17];let y;return t[18]!==u||t[19]!==_||t[20]!==v?(y=(0,$.jsxs)(`div`,{ref:u,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]=u,t[19]=_,t[20]=v,t[21]=y):y=t[21],y}function Qs(e){return{type:`skill`,data:e}}function $s(e){return{type:`command`,data:e}}function ec(e){return e.startsWith(`image/`)}function tc(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:K(m.compact,`group relative flex items-center gap-1 rounded-md bg-muted text-muted-foreground`),children:ec(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)(T,{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)(ct,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(T,{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 nc(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 rc(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=K(m.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),u=(0,$.jsx)(Pt,{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:K(m.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)(De,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(O,{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:K(m.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 ic(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:ac}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function ac(e){e.currentTarget.style.visibility=`hidden`}function oc(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=K(m.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)(ic,{providerSlug:n}),t[1]=n,t[2]=o);let s;t[3]!==i||t[4]!==r?(s=r?.url?(0,$.jsx)(hr,{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 sc(e){let t=e.pricing?.prompt;return t==null?null:Math.ceil(t*3)}function cc(e){return`$${sn(e)}`}function lc(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:`${cc(e.pricing.prompt??0)} input per million tokens`}),(0,$.jsx)(`div`,{children:`${cc(e.pricing.completion??0)} output per million tokens`}),(0,$.jsx)(`div`,{children:`Displayed value of ${t} is a relative price.`})]}):null}function uc(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=(sc(e)??2**53-1)-(sc(n)??2**53-1);if(t!==0)return t}return mr(e.id).localeCompare(mr(n.id))})}function dc(e){let t=(0,X.c)(37),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Y.useState(!1),[s,c]=Y.useState(`relative-price`),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Map,t[0]=l):l=t[0];let[u,d]=Y.useState(l),f=Y.useRef(null),p,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{Ee().then(function(e){d(new Map(e.map(pc)))})},h=[],t[1]=p,t[2]=h):(p=t[1],h=t[2]),Y.useEffect(p,h);let g,_;t[3]===a?(g=t[4],_=t[5]):(g=()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[a],t[3]=a,t[4]=g,t[5]=_),Y.useEffect(g,_);let v;t[6]===i?v=t[7]:(v=e=>{i(e),o(!1)},t[6]=i,t[7]=v);let y=v,b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{c(function(e){return e===`relative-price`?`alphabetical`:`relative-price`})},t[8]=b):b=t[8];let x=b,S;t[9]!==n||t[10]!==s?(S=uc(n,s),t[9]=n,t[10]=s,t[11]=S):S=t[11];let C=S,w=s===`relative-price`?dt:ht,T=s===`relative-price`?`Sort by relative price`:`Sort alphabetically`,E;t[12]===a?E=t[13]:(E=()=>o(!a),t[12]=a,t[13]=E);let D=r?.provider,O;t[14]===D?O=t[15]:(O=(0,$.jsx)(ic,{providerSlug:D}),t[14]=D,t[15]=O);let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=K(m.body,`font-normal`),t[16]=k):k=t[16];let A;t[17]===r?A=t[18]:(A=r?mr(r.id):`No model`,t[17]=r,t[18]=A);let j;t[19]===A?j=t[20]:(j=(0,$.jsx)(`span`,{className:k,children:A}),t[19]=A,t[20]=j);let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(yt,{className:`h-3 w-3`}),t[21]=M):M=t[21];let N;t[22]!==O||t[23]!==j||t[24]!==E?(N=(0,$.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:E,children:[O,j,M]}),t[22]=O,t[23]=j,t[24]=E,t[25]=N):N=t[25];let P;t[26]!==w||t[27]!==y||t[28]!==u||t[29]!==r?.id||t[30]!==a||t[31]!==T||t[32]!==C?(P=a&&(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)(qt,{children:[(0,$.jsx)(`div`,{className:`-mb-3 flex justify-end px-1 pb-1`,children:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":T,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:x,children:(0,$.jsx)(w,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(G,{side:`left`,align:`start`,sideOffset:8,children:T})]})}),Object.entries(C.reduce(fc,{})).map((e,t)=>{let[n,i]=e;return(0,$.jsxs)(`div`,{children:[t>0&&(0,$.jsx)(pr,{className:`my-1`}),(0,$.jsx)(oc,{providerSlug:n,providerData:u.get(n)}),i.map(e=>{let t=sc(e),n=t==null?null:lc(e,t);return(0,$.jsx)(`div`,{children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`button`,{type:`button`,className:K(m.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===r?.id&&`bg-accent font-medium`),onClick:()=>y(e),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:mr(e.id)}),t!=null&&n&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:t})}),(0,$.jsx)(G,{side:`left`,align:`end`,sideOffset:8,className:`max-w-64`,children:n})]})]})})},e.id)})]},n)})]})}),t[26]=w,t[27]=y,t[28]=u,t[29]=r?.id,t[30]=a,t[31]=T,t[32]=C,t[33]=P):P=t[33];let F;return t[34]!==N||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`relative`,ref:f,children:[N,P]}),t[34]=N,t[35]=P,t[36]=F):F=t[36],F}function fc(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}function pc(e){return[e.slug,e]}var mc=[{value:`build`,label:`Build`,icon:a},{value:`plan`,label:`Plan`,icon:b},{value:`image`,label:`Image`,icon:ie},{value:`ralph`,label:`Ralph`,icon:en}];function hc(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function gc({planMode:e,imageMode:t,ralphMode:n,setPlanMode:r,setImageMode:i,setRalphMode:a,projectId:o}){let s=_i(),c=Q(function(e){if(o)return e.projects.find(e=>e.projectId===o)}),[l,u]=Y.useState(!0),[d,f]=Y.useState(!1),p=hc(e,t,n),m=mc.find(e=>e.value===p);Y.useEffect(()=>{c&&u(c.allowAllCommands===!1)},[c]);async function g(){if(!o||d)return;let e=!l;u(e),f(!0);try{await h(o,{allowAllCommands:!e}),L(o);let t=await be();s({type:Z.SetProjects,projects:t.projects})}catch(t){u(!e),console.error(`Failed to update command confirmation setting:`,t)}finally{f(!1)}}function _(e){r(e===`plan`),i(e===`image`),a(e===`ralph`)}return{chatModes:mc,confirmCommands:l,currentConfig:m,currentMode:p,isUpdatingConfirmCommands:d,selectMode:_,toggleConfirmCommands:g}}function _c(e){let t=(0,X.c)(37),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s,projectId:c}=e,[l,u]=Y.useState(!1),d=Y.useRef(null),f;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s?(f={planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s,projectId:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=f):f=t[7];let{chatModes:p,confirmCommands:h,currentConfig:g,currentMode:_,isUpdatingConfirmCommands:v,selectMode:y,toggleConfirmCommands:b}=gc(f),x=g.icon,S,C;t[8]===l?(S=t[9],C=t[10]):(S=()=>{let e=function(e){d.current&&!d.current.contains(e.target)&&u(!1)};if(l)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},C=[l],t[8]=l,t[9]=S,t[10]=C),Y.useEffect(S,C);let w;t[11]===y?w=t[12]:(w=function(e){y(e),u(!1)},t[11]=y,t[12]=w);let T=w,E;t[13]===l?E=t[14]:(E=()=>u(!l),t[13]=l,t[14]=E);let D;t[15]===x?D=t[16]:(D=(0,$.jsx)(x,{className:`h-3.5 w-3.5`}),t[15]=x,t[16]=D);let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=K(m.body,`font-normal`),t[17]=O):O=t[17];let k;t[18]===g.label?k=t[19]:(k=(0,$.jsx)(`span`,{className:O,children:g.label}),t[18]=g.label,t[19]=k);let A;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(yt,{className:`h-3 w-3`}),t[20]=A):A=t[20];let j;t[21]!==E||t[22]!==D||t[23]!==k?(j=(0,$.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:E,children:[D,k,A]}),t[21]=E,t[22]=D,t[23]=k,t[24]=j):j=t[24];let M;t[25]!==p||t[26]!==h||t[27]!==_||t[28]!==T||t[29]!==v||t[30]!==l||t[31]!==c||t[32]!==b?(M=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:[c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:K(m.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent disabled:opacity-50`),onClick:()=>{b()},disabled:v,children:[`Confirm Commands`,h&&(0,$.jsx)(Qe,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),p.map(e=>{let t=e.icon,n=e.value===_;return(0,$.jsxs)(`button`,{type:`button`,className:K(m.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent`),onClick:()=>T(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(Qe,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]}),t[25]=p,t[26]=h,t[27]=_,t[28]=T,t[29]=v,t[30]=l,t[31]=c,t[32]=b,t[33]=M):M=t[33];let N;return t[34]!==j||t[35]!==M?(N=(0,$.jsxs)(`div`,{className:`relative hidden md:block`,ref:d,children:[j,M]}),t[34]=j,t[35]=M,t[36]=N):N=t[36],N}function vc(e){let t=(0,X.c)(32),{disabled:n,canAddTask:r,onFileAttach:i,onAddTask:a,showModes:o,planMode:s,imageMode:c,ralphMode:l,setPlanMode:u,setImageMode:d,setRalphMode:f,projectId:p}=e,m=n===void 0?!1:n,h=o===void 0?!1:o,g=s===void 0?!1:s,_=c===void 0?!1:c,v=l===void 0?!1:l,y=u??xc,b=d??bc,x=f??yc,S;t[0]!==_||t[1]!==g||t[2]!==p||t[3]!==v||t[4]!==y||t[5]!==b||t[6]!==x?(S={planMode:g,imageMode:_,ralphMode:v,setPlanMode:y,setImageMode:b,setRalphMode:x,projectId:p},t[0]=_,t[1]=g,t[2]=p,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=S):S=t[7];let C=gc(S),w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=function(e){e()},t[8]=w):w=t[8];let T=w,E,D;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Ze,{}),D=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[9]=E,t[10]=D):(E=t[9],D=t[10]);let O;t[11]===m?O=t[12]:(O=(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsxs)(J,{variant:`action`,size:`icon-sm`,disabled:m,children:[E,D]})}),t[11]=m,t[12]=O);let k;t[13]===i?k=t[14]:(k=()=>T(i),t[13]=i,t[14]=k);let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(ct,{className:`mr-2 h-3.5 w-3.5`}),t[15]=A):A=t[15];let j;t[16]===k?j=t[17]:(j=(0,$.jsxs)(Wo,{onClick:k,children:[A,`Attach File`]}),t[16]=k,t[17]=j);let M;t[18]!==r||t[19]!==a?(M=r&&(0,$.jsxs)(Wo,{onClick:()=>T(a),children:[(0,$.jsx)(Se,{className:`mr-2 h-3.5 w-3.5`}),`Add to Pending Tasks`]}),t[18]=r,t[19]=a,t[20]=M):M=t[20];let N;t[21]!==C||t[22]!==p||t[23]!==h?(N=h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jo,{}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Wo,{onClick:()=>{C.toggleConfirmCommands()},disabled:C.isUpdatingConfirmCommands,children:[`Confirm Commands`,C.confirmCommands&&(0,$.jsx)(Qe,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(Jo,{})]}),C.chatModes.map(e=>{let t=e.icon,n=e.value===C.currentMode;return(0,$.jsxs)(Wo,{onClick:()=>C.selectMode(e.value),className:K(n&&`bg-accent`),children:[(0,$.jsx)(t,{className:`mr-2 h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(Qe,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]}),t[21]=C,t[22]=p,t[23]=h,t[24]=N):N=t[24];let P;t[25]!==j||t[26]!==M||t[27]!==N?(P=(0,$.jsxs)(Uo,{align:`start`,side:`top`,className:`w-56`,children:[j,M,N]}),t[25]=j,t[26]=M,t[27]=N,t[28]=P):P=t[28];let F;return t[29]!==O||t[30]!==P?(F=(0,$.jsxs)(Ro,{children:[O,P]}),t[29]=O,t[30]=P,t[31]=F):F=t[31],F}function yc(){}function bc(){}function xc(){}var Sc=Mr(`useWebSpeech`);function Cc(e){switch(e){case`not-allowed`:return`Microphone access was denied. Please allow microphone access to use voice input.`;case`service-not-allowed`:return`Speech recognition is not allowed in this environment.`;case`audio-capture`:return`No microphone was found. Please connect a microphone to use voice input.`;case`network`:return`Speech recognition requires a network connection.`;case`no-speech`:case`aborted`:return null;default:return`Speech recognition error: ${e}`}}function wc(e){let t=``;for(let n=0;n<e.results.length;n+=1)t+=e.results[n][0]?.transcript??``;return t}function Tc(){let[e,t]=(0,Y.useState)(`idle`),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>()=>{l.current=!1,c.current?.abort(),c.current=null},[]);let u=(0,Y.useCallback)(()=>{let e=jr();if(!e){l.current=!1,t(`error`),r(!1),s(`Speech recognition is not supported in this environment.`);return}e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onresult=e=>{let t=wc(e).trim();t&&a(t)},e.onerror=e=>{let t=Cc(e.error);Sc.error(`Web Speech recognition error`,{error:e.error,message:e.message}),t&&s(t)},e.onend=()=>{if(c.current=null,!l.current){t(`ready`);return}Sc.info(`Web Speech recognition ended — restarting`),u()},c.current=e;try{e.start(),t(`recording`),Sc.info(`Web Speech recognition started`)}catch(e){c.current=null,l.current=!1;let n=e instanceof Error?e.message:`Unknown error`;Sc.error(`Failed to start Web Speech recognition`,{error:n}),t(`ready`),s(`Failed to start speech recognition: ${n}`)}},[]),d=(0,Y.useCallback)(async()=>{if(e===`ready`||e===`error`)return e;t(`checking-support`),s(null),Sc.info(`Checking Web Speech API support`,{userAgent:navigator.userAgent,platform:navigator.platform});let n=Pr();return r(n),n?(Sc.info(`Web Speech API available — ready`),t(`ready`),`ready`):(Sc.error(`Web Speech API not available`),t(`error`),s(`Speech recognition is not supported in this environment.`),`error`)},[e]);return{state:e,isSupported:n,transcript:i,error:o,downloadProgress:0,startListening:(0,Y.useCallback)(async()=>{l.current=!0,s(null),a(``),Sc.info(`Starting Web Speech recognition`),u()},[u]),stopListening:(0,Y.useCallback)(async()=>{l.current=!1,c.current?.stop(),c.current=null,t(`ready`),Sc.info(`Web Speech recognition stopped`)},[]),requestModelDownload:(0,Y.useCallback)(async()=>{},[]),ensureReady:d,resetTranscript:(0,Y.useCallback)(()=>{a(``),s(null)},[])}}var Ec=Mr(`useWhisperSpeech`),Dc=150;function Oc(e){let t=new URLSearchParams;return t.set(`model`,e),`/api/voice-model/download?${t.toString()}`}function kc(){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 jc(){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)(()=>Lt()),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(Lt())}function t(){h(Lt())}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=Oc(m);async function i(){t(`checking-support`),T(!1),p(0),d(null),Ec.separator(`VOICE SESSION START`),Ec.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform,model:m,url:n});try{let e=new Fr;g.current=e;let i=await e.checkWasmSupport();if(Ec.info(`WASM SIMD support check result`,{supported:i}),r(i),!i)return Ec.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`),`error`;let a=new Nr;_.current=a,Ec.info(`Checking IndexedDB model cache`,{url:n});try{let r=await a.loadModelByUrl(n);return Ec.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),Ec.info(`WASM model initialized from cache — ready`),t(`ready`),`ready`}catch(e){return Ec.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 Ec.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=Oc(m);t(`downloading-model`),p(0),d(null),Ec.info(`Model download requested`,{url:e,model:m});try{let n=await _.current.loadModelByUrl(e,e=>{p(e),e%10==0&&Ec.debug(`Model download progress`,{progress:e,model:m})});Ec.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),Ec.info(`WASM model initialized after download — ready`),T(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;Ec.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(``),Ec.separator(`RECORDING START`),Ec.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){Ec.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();Ec.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`),Ec.info(`Recording started`),b.current=Ir(n,{signal:i.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{Ec.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`)Ec.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`)Ec.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`;Ec.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){Ec.info(`stopListening called but no active recording`),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null),w.current&&t(`ready`);return}Ec.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){Ec.info(`Transcription cancelled by user`),t(`ready`);return}let i=(r.audioData.length/16e3).toFixed(2),a=Math.round(Ac()-n);Ec.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=kc(),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)},Dc))}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,Ec.debug(`Transcription segment received`,{index:_,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),p()}p(!0),Ec.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(Ec.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`)){Ec.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await g.current.restartModel(),Ec.info(`WASM reinitialized successfully`)}catch(e){Ec.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}}function Mc(){let e=(0,X.c)(22),t=jc(),n=Tc();if(!Ne()){let n;return e[0]!==t.downloadProgress||e[1]!==t.ensureReady||e[2]!==t.error||e[3]!==t.isWasmSupported||e[4]!==t.requestModelDownload||e[5]!==t.resetTranscript||e[6]!==t.startListening||e[7]!==t.state||e[8]!==t.stopListening||e[9]!==t.transcript?(n={state:t.state,isSupported:t.isWasmSupported,usesLocalModel:!0,transcript:t.transcript,error:t.error,downloadProgress:t.downloadProgress,startListening:t.startListening,stopListening:t.stopListening,requestModelDownload:t.requestModelDownload,ensureReady:t.ensureReady,resetTranscript:t.resetTranscript},e[0]=t.downloadProgress,e[1]=t.ensureReady,e[2]=t.error,e[3]=t.isWasmSupported,e[4]=t.requestModelDownload,e[5]=t.resetTranscript,e[6]=t.startListening,e[7]=t.state,e[8]=t.stopListening,e[9]=t.transcript,e[10]=n):n=e[10],n}let r;return e[11]!==n.downloadProgress||e[12]!==n.ensureReady||e[13]!==n.error||e[14]!==n.isSupported||e[15]!==n.requestModelDownload||e[16]!==n.resetTranscript||e[17]!==n.startListening||e[18]!==n.state||e[19]!==n.stopListening||e[20]!==n.transcript?(r={state:n.state,isSupported:n.isSupported,usesLocalModel:!1,transcript:n.transcript,error:n.error,downloadProgress:n.downloadProgress,startListening:n.startListening,stopListening:n.stopListening,requestModelDownload:n.requestModelDownload,ensureReady:n.ensureReady,resetTranscript:n.resetTranscript},e[11]=n.downloadProgress,e[12]=n.ensureReady,e[13]=n.error,e[14]=n.isSupported,e[15]=n.requestModelDownload,e[16]=n.resetTranscript,e[17]=n.startListening,e[18]=n.state,e[19]=n.stopListening,e[20]=n.transcript,e[21]=r):r=e[21],r}var Nc=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=K(`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)(Un,{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)(dr,{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});Nc.displayName=dr.displayName;var Pc=75;function Fc(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:s}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(c,{children:[(0,$.jsx)(Ct,{children:`Download Voice Model`}),(0,$.jsxs)(oe,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Pc,`MB. The model will be cached locally for future use.`]})]}),t[0]=l):l=t[0];let u;t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==r||t[5]!==o?(u=(0,$.jsxs)(y,{children:[l,a?(0,$.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,$.jsx)(Nc,{value:o,className:`w-full`}),(0,$.jsx)(`p`,{className:K(m.bodyMuted,`text-center`),children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):s?(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsx)(Ar,{variant:`error`,className:`mb-0`,children:s}),(0,$.jsxs)(wt,{children:[(0,$.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(J,{onClick:i,children:`Try Again`})]})]}):(0,$.jsxs)(wt,{children:[(0,$.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(J,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=s,t[3]=i,t[4]=r,t[5]=o,t[6]=u):u=t[6];let d;return t[7]!==r||t[8]!==n||t[9]!==u?(d=(0,$.jsx)(C,{open:n,onOpenChange:r,children:u}),t[7]=r,t[8]=n,t[9]=u,t[10]=d):d=t[10],d}function Ic(e){let t=(0,X.c)(68),{onTranscript:n,children:r}=e,{state:i,isSupported:a,usesLocalModel:o,transcript:s,error:c,downloadProgress:l,startListening:u,stopListening:d,requestModelDownload:f,ensureReady:p,resetTranscript:m}=Mc(),{toast:h}=Fi(),[g,_]=(0,Y.useState)(!1),v=(0,Y.useRef)(``),y=(0,Y.useRef)(null),b=i===`recording`,x=i===`transcribing`,S=b||x,C=i===`needs-model`,w=i===`downloading-model`||i===`initializing`,T=i===`checking-support`,E,D;t[0]!==g||t[1]!==c||t[2]!==h?(E=()=>{c&&c!==y.current&&!g&&h({title:`Voice Input Error`,description:c,variant:`destructive`}),y.current=c},D=[c,g,h],t[0]=g,t[1]=c,t[2]=h,t[3]=E,t[4]=D):(E=t[3],D=t[4]),(0,Y.useEffect)(E,D);let O,k;t[5]!==n||t[6]!==s?(O=()=>{if(s&&s!==v.current){let e=s.substring(v.current.length);v.current=s,n(e)}},k=[s,n],t[5]=n,t[6]=s,t[7]=O,t[8]=k):(O=t[7],k=t[8]),(0,Y.useEffect)(O,k);let A,j;t[9]===s?(A=t[10],j=t[11]):(A=()=>{s||(v.current=``)},j=[s],t[9]=s,t[10]=A,t[11]=j),(0,Y.useEffect)(A,j);let M;t[12]!==p||t[13]!==S||t[14]!==C||t[15]!==m||t[16]!==u||t[17]!==i||t[18]!==d?(M=async()=>{if(S){d();return}if(C){_(!0);return}if(i===`ready`){m(),u();return}if(i===`idle`){let e=await p();e===`needs-model`?_(!0):e===`ready`&&(m(),u())}},t[12]=p,t[13]=S,t[14]=C,t[15]=m,t[16]=u,t[17]=i,t[18]=d,t[19]=M):M=t[19];let N=M,P;t[20]===f?P=t[21]:(P=()=>{f()},t[20]=f,t[21]=P);let F=P,I,L;t[22]!==g||t[23]!==i?(L=()=>{i===`ready`&&g&&_(!1)},I=[i,g],t[22]=g,t[23]=i,t[24]=I,t[25]=L):(I=t[24],L=t[25]),(0,Y.useEffect)(L,I);let R;t[26]!==c||t[27]!==T||t[28]!==w||t[29]!==b||t[30]!==a||t[31]!==x||t[32]!==C?(R=()=>T?`Checking voice input support...`:a===!1?`Voice input not supported in this browser`:c||(w?`Downloading speech model...`:x?`Transcribing...`:b?`Stop listening`:C?`Click to download speech model`:`Start listening`),t[26]=c,t[27]=T,t[28]=w,t[29]=b,t[30]=a,t[31]=x,t[32]=C,t[33]=R):R=t[33];let z=R,B;t[34]!==w||t[35]!==b||t[36]!==x?(B=()=>w||x?(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin`}):b?(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)(qe,{className:`h-3 w-3`}),t[34]=w,t[35]=b,t[36]=x,t[37]=B):B=t[37];let V=B,H,ee;t[38]!==r||t[39]!==V||t[40]!==z||t[41]!==N||t[42]!==T||t[43]!==w||t[44]!==b||t[45]!==a||t[46]!==x||t[47]!==C?(H=z(),ee=r({onClick:N,disabled:T||w||x||a===!1,icon:V(),label:H,isRecording:b,isTranscribing:x,isDownloading:w,needsModel:C,isSupported:a!==!1}),t[38]=r,t[39]=V,t[40]=z,t[41]=N,t[42]=T,t[43]=w,t[44]=b,t[45]=a,t[46]=x,t[47]=C,t[48]=H,t[49]=ee):(H=t[48],ee=t[49]);let te=ee,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 U;t[51]===te?U=t[52]:(U=(0,$.jsx)(q,{asChild:!0,children:te}),t[51]=te,t[52]=U);let re;t[53]===H?re=t[54]:(re=(0,$.jsx)(G,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:H}),t[53]=H,t[54]=re);let ie;t[55]!==U||t[56]!==re?(ie=(0,$.jsxs)(W,{children:[U,re]}),t[55]=U,t[56]=re,t[57]=ie):ie=t[57];let ae;t[58]!==g||t[59]!==l||t[60]!==c||t[61]!==F||t[62]!==w||t[63]!==o?(ae=o?(0,$.jsx)(Fc,{open:g,onOpenChange:_,onConfirm:F,downloading:w,progress:l,error:c}):null,t[58]=g,t[59]=l,t[60]=c,t[61]=F,t[62]=w,t[63]=o,t[64]=ae):ae=t[64];let oe;return t[65]!==ie||t[66]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[ne,ie,ae]}),t[65]=ie,t[66]=ae,t[67]=oe):oe=t[67],oe}function Lc(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:K(m.compact,m.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:K(m.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)(T,{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)(Ar,{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 Rc(e){let t=(0,X.c)(27),{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=o||s||c,b,x;t[0]!==y||t[1]!==d?(b=()=>{d(y)},x=[y,d],t[0]=y,t[1]=d,t[2]=b,t[3]=x):(b=t[2],x=t[3]),(0,Y.useEffect)(b,x);let S=!f&&!y&&((p??!1)||!m&&r||!u&&h>0&&!g||u&&!g),C;t[4]!==m||t[5]!==f||t[6]!==y||t[7]!==v||t[8]!==n||t[9]!==_?(C=function(){if(f){_?.();return}if(y){n();return}if(m){v();return}n()},t[4]=m,t[5]=f,t[6]=y,t[7]=v,t[8]=n,t[9]=_,t[10]=C):C=t[10];let w=C,T=f?`Stop generation`:y?a:m?`Send message`:a,E=`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-['']`:``}`,D;t[11]!==m||t[12]!==i||t[13]!==f||t[14]!==y?(D=f?(0,$.jsx)(`span`,{className:`block h-3 w-3 shrink-0 rounded-[2px] bg-current`,"aria-hidden":`true`}):y||!m?i:(0,$.jsx)(Kt,{className:`h-3 w-3`}),t[11]=m,t[12]=i,t[13]=f,t[14]=y,t[15]=D):D=t[15];let O;t[16]===T?O=t[17]:(O=(0,$.jsx)(`span`,{className:`sr-only`,children:T}),t[16]=T,t[17]=O);let k;t[18]===l?k=t[19]:(k=!l&&(0,$.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`}),t[18]=l,t[19]=k);let A;return t[20]!==w||t[21]!==S||t[22]!==E||t[23]!==D||t[24]!==O||t[25]!==k?(A=(0,$.jsxs)(J,{size:`icon`,className:E,onClick:w,disabled:S,children:[D,O,k]}),t[20]=w,t[21]=S,t[22]=E,t[23]=D,t[24]=O,t[25]=k,t[26]=A):A=t[26],A}function zc(e){let t=(0,X.c)(168),{onSend:n,onStop:r,isStreaming:a,disabled:o,initialValue:s,queuedMessages:c,onRemoveQueuedMessage:l,isOverlay:d,userTasks:f,onMatchedUserTaskSend:p,onUserTaskCreated:h}=e,g=a===void 0?!1:a,_=d===void 0?!1:d,v;t[0]===f?v=t[1]:(v=f===void 0?[]:f,t[0]=f,t[1]=v);let y=v,b=Q(Jc),x;t[2]===s?x=t[3]:(x={initialValue:s},t[2]=s,t[3]=x);let{message:S,setMessage:C,historyIndex:w,setHistoryIndex:T,draftMessage:E,setDraftMessage:D,cursorPosition:O,setCursorPosition:k,availableModels:A,selectedModel:j,setSelectedModel:M,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:B,availableImageModels:V,selectedImageModel:H,setSelectedImageModel:ee,allFiles:te,setAllFiles:ne,showSuggestions:U,setShowSuggestions:re,suggestionQuery:ie,setSuggestionQuery:ae,selectedIndex:oe,setSelectedIndex:se,slashCommands:ce,skills:le,showCommandSuggestions:ue,setShowCommandSuggestions:de,commandQuery:fe,setCommandQuery:pe,fileInputRef:me,textareaRef:he,suggestionsRef:ge,commandSuggestionsRef:_e,selectedThreadId:ve,dispatch:ye}=Hs(x),be=Q(qc),xe=Q(Kc),Se;t[4]===be?Se=t[5]:(Se=be.some(Gc),t[4]=be,t[5]=Se);let Ce=Se,we=z?H:j,Te=z?V:A,Ee;t[6]===S?Ee=t[7]:(Ee=S.trim(),t[6]=S,t[7]=Ee);let De=Ee.length>0,Oe=De||N.length>0,[ke,Ae]=Y.useState(!1),je=Ys(),Me=ve??void 0,Ne;t[8]!==te||t[9]!==N||t[10]!==fe||t[11]!==O||t[12]!==ye||t[13]!==E||t[14]!==Ce||t[15]!==w||t[16]!==z||t[17]!==g||t[18]!==S||t[19]!==p||t[20]!==n||t[21]!==F||t[22]!==L||t[23]!==H||t[24]!==oe||t[25]!==j||t[26]!==ne||t[27]!==P||t[28]!==pe||t[29]!==k||t[30]!==D||t[31]!==T||t[32]!==B||t[33]!==C||t[34]!==I||t[35]!==R||t[36]!==se||t[37]!==de||t[38]!==re||t[39]!==ae||t[40]!==ue||t[41]!==U||t[42]!==le||t[43]!==ce||t[44]!==ie||t[45]!==Me||t[46]!==he||t[47]!==y?(Ne={message:S,setMessage:C,userTasks:y,onMatchedUserTaskSend:p,attachments:N,selectedModel:j,onSend:n,isStreaming:g,selectedThreadId:Me,isListening:!1,stopListening:Wc,resetTranscript:Uc,dispatch:ye,historyIndex:w,setHistoryIndex:T,draftMessage:E,setDraftMessage:D,cursorPosition:O,setCursorPosition:k,showSuggestions:U,setShowSuggestions:re,suggestionQuery:ie,setSuggestionQuery:ae,allFiles:te,setAllFiles:ne,selectedIndex:oe,setSelectedIndex:se,showCommandSuggestions:ue,setShowCommandSuggestions:de,commandQuery:fe,setCommandQuery:pe,slashCommands:ce,skills:le,textareaRef:he,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:B,selectedImageModel:H,hasConversationMessages:Ce},t[8]=te,t[9]=N,t[10]=fe,t[11]=O,t[12]=ye,t[13]=E,t[14]=Ce,t[15]=w,t[16]=z,t[17]=g,t[18]=S,t[19]=p,t[20]=n,t[21]=F,t[22]=L,t[23]=H,t[24]=oe,t[25]=j,t[26]=ne,t[27]=P,t[28]=pe,t[29]=k,t[30]=D,t[31]=T,t[32]=B,t[33]=C,t[34]=I,t[35]=R,t[36]=se,t[37]=de,t[38]=re,t[39]=ae,t[40]=ue,t[41]=U,t[42]=le,t[43]=ce,t[44]=ie,t[45]=Me,t[46]=he,t[47]=y,t[48]=Ne):Ne=t[48];let{handleSend:Pe,handleKeyDown:Fe,handleTextareaInput:Ie,insertFileReference:Le,insertCommand:Re,insertSkill:ze,fileSuggestions:Be}=Ws(Ne),Ve;t[49]===C?Ve=t[50]:(Ve=e=>{C(t=>(t.endsWith(` `),t+e))},t[49]=C,t[50]=Ve);let He=Ve,Ue;t[51]===P?Ue=t[52]:(Ue=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Hc);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];P(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[51]=P,t[52]=Ue);let We=Ue,Ge=_?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl max-md:px-2 px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl max-md:px-0 pb-2 md:px-4 md:pb-4 md:-mx-[6px]`,Ke=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${_?`border-border/50 shadow-lg backdrop-blur-sm`:`border-border shadow-2xl`}`,qe;t[53]!==_||t[54]!==b?(qe=Vs(b,_),t[53]=_,t[54]=b,t[55]=qe):qe=t[55];let Je;t[56]===qe?Je=t[57]:(Je={backgroundImage:qe},t[56]=qe,t[57]=Je);let Ye;t[58]!==l||t[59]!==c?(Ye=(0,$.jsx)(Lc,{queuedMessages:c,onRemoveQueuedMessage:l}),t[58]=l,t[59]=c,t[60]=Ye):Ye=t[60];let Xe=L?`Describe stories for Ralph to implement autonomously...`:F?`Describe what you want Tarsk to plan...`:z?`Describe the image you want to generate...`:ke?`Dictate your message...`:`Ask Tarsk anything, # for files, / for commands & skills`,Ze;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=K(m.body,`min-h-[4.5rem] w-full resize-none bg-transparent px-6 pt-4 pb-4 text-foreground placeholder:text-muted-foreground focus:outline-none`),t[61]=Ze):Ze=t[61];let Qe;t[62]!==o||t[63]!==Fe||t[64]!==We||t[65]!==Ie||t[66]!==S||t[67]!==Xe||t[68]!==he?(Qe=(0,$.jsx)(`textarea`,{ref:he,value:S,onChange:Ie,onKeyDown:Fe,onPaste:We,placeholder:Xe,rows:1,className:Ze,disabled:o}),t[62]=o,t[63]=Fe,t[64]=We,t[65]=Ie,t[66]=S,t[67]=Xe,t[68]=he,t[69]=Qe):Qe=t[69];let $e;t[70]!==fe||t[71]!==_e||t[72]!==Re||t[73]!==ze||t[74]!==oe||t[75]!==se||t[76]!==ue||t[77]!==le||t[78]!==ce?($e=(0,$.jsx)(Zs,{visible:ue,commands:ce,skills:le,query:fe,selectedIndex:oe,onSelectCommand:Re,onSelectSkill:ze,onMouseEnterSuggestion:se,containerRef:_e}),t[70]=fe,t[71]=_e,t[72]=Re,t[73]=ze,t[74]=oe,t[75]=se,t[76]=ue,t[77]=le,t[78]=ce,t[79]=$e):$e=t[79];let et;t[80]!==Be||t[81]!==Le||t[82]!==oe||t[83]!==se||t[84]!==U||t[85]!==ie||t[86]!==ge?(et=(0,$.jsx)(rc,{showSuggestions:U,fileSuggestions:Be,suggestionQuery:ie,selectedIndex:oe,onSelectFile:Le,onMouseEnterSuggestion:se,containerRef:ge}),t[80]=Be,t[81]=Le,t[82]=oe,t[83]=se,t[84]=U,t[85]=ie,t[86]=ge,t[87]=et):et=t[87];let tt;t[88]!==N||t[89]!==j?.id||t[90]!==j?.name||t[91]!==j?.supportsImages||t[92]!==P?(tt=N.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(tc,{attachments:N,onRemove:e=>P(t=>t.filter((t,n)=>n!==e))}),N.some(Vc)&&j?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:K(m.compact,`mb-2 flex items-center gap-1.5 text-amber-500`),children:[(0,$.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,j?.name||j?.id]})]})]}),t[88]=N,t[89]=j?.id,t[90]=j?.name,t[91]=j?.supportsImages,t[92]=P,t[93]=tt):tt=t[93];let nt;t[94]===me?nt=t[95]:(nt=()=>me.current?.click(),t[94]=me,t[95]=nt);let rt;t[96]!==ye||t[97]!==S||t[98]!==h||t[99]!==P||t[100]!==C||t[101]!==ve||t[102]!==he?(rt=()=>{let e=ve;if(!e)return;let t=S.trim();t&&i(e,t).then(t=>{h?.(t),C(``),P([]),ye({type:Z.ClearChatInputDraft,threadId:e}),he.current&&(he.current.style.height=`auto`)}).catch(Bc)},t[96]=ye,t[97]=S,t[98]=h,t[99]=P,t[100]=C,t[101]=ve,t[102]=he,t[103]=rt):rt=t[103];let W;t[104]!==o||t[105]!==De||t[106]!==z||t[107]!==je||t[108]!==F||t[109]!==L||t[110]!==xe||t[111]!==B||t[112]!==I||t[113]!==R||t[114]!==nt||t[115]!==rt?(W=(0,$.jsx)(vc,{disabled:o,canAddTask:De,showModes:je,planMode:F,imageMode:z,ralphMode:L,setPlanMode:I,setImageMode:B,setRalphMode:R,projectId:xe,onFileAttach:nt,onAddTask:rt}),t[104]=o,t[105]=De,t[106]=z,t[107]=je,t[108]=F,t[109]=L,t[110]=xe,t[111]=B,t[112]=I,t[113]=R,t[114]=nt,t[115]=rt,t[116]=W):W=t[116];let it=z?ee:M,at;t[117]!==Te||t[118]!==we||t[119]!==it?(at=(0,$.jsx)(dc,{availableModels:Te,selectedModel:we,onModelSelect:it}),t[117]=Te,t[118]=we,t[119]=it,t[120]=at):at=t[120];let ot;t[121]!==W||t[122]!==at?(ot=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[W,at]}),t[121]=W,t[122]=at,t[123]=ot):ot=t[123];let st;t[124]!==z||t[125]!==F||t[126]!==L||t[127]!==xe||t[128]!==B||t[129]!==I||t[130]!==R?(st=(0,$.jsx)(_c,{planMode:F,imageMode:z,ralphMode:L,setPlanMode:I,setImageMode:B,setRalphMode:R,projectId:xe}),t[124]=z,t[125]=F,t[126]=L,t[127]=xe,t[128]=B,t[129]=I,t[130]=R,t[131]=st):st=t[131];let ct;t[132]!==N.length||t[133]!==Oe||t[134]!==o||t[135]!==we||t[136]!==Pe||t[137]!==De||t[138]!==g||t[139]!==r?(ct=e=>{let{onClick:t,disabled:n,icon:i,label:a,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u}=e;return(0,$.jsx)(Rc,{onSpeechClick:t,speechDisabled:n,icon:i,label:a,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u,hasMessageText:De,setIsVoiceActive:Ae,isStreaming:g,disabled:o,canSubmitMessage:Oe,attachmentsLength:N.length,effectiveModel:we,onStop:r,onSend:Pe})},t[132]=N.length,t[133]=Oe,t[134]=o,t[135]=we,t[136]=Pe,t[137]=De,t[138]=g,t[139]=r,t[140]=ct):ct=t[140];let lt;t[141]!==He||t[142]!==ct?(lt=(0,$.jsx)(Ic,{onTranscript:He,children:ct}),t[141]=He,t[142]=ct,t[143]=lt):lt=t[143];let ut;t[144]!==st||t[145]!==lt?(ut=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[st,lt]}),t[144]=st,t[145]=lt,t[146]=ut):ut=t[146];let dt;t[147]!==ot||t[148]!==ut?(dt=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[ot,ut]}),t[147]=ot,t[148]=ut,t[149]=dt):dt=t[149];let G;t[150]!==Ke||t[151]!==Je||t[152]!==Ye||t[153]!==Qe||t[154]!==$e||t[155]!==et||t[156]!==tt||t[157]!==dt?(G=(0,$.jsxs)(`div`,{className:Ke,style:Je,children:[Ye,Qe,$e,et,tt,dt]}),t[150]=Ke,t[151]=Je,t[152]=Ye,t[153]=Qe,t[154]=$e,t[155]=et,t[156]=tt,t[157]=dt,t[158]=G):G=t[158];let ft;t[159]===P?ft=t[160]:(ft=e=>nc(e,e=>P(t=>[...t,...e])),t[159]=P,t[160]=ft);let pt;t[161]!==me||t[162]!==ft?(pt=(0,$.jsx)(`input`,{ref:me,type:`file`,multiple:!0,className:`hidden`,onChange:ft}),t[161]=me,t[162]=ft,t[163]=pt):pt=t[163];let mt;return t[164]!==Ge||t[165]!==G||t[166]!==pt?(mt=(0,$.jsxs)(`div`,{className:Ge,children:[G,pt]}),t[164]=Ge,t[165]=G,t[166]=pt,t[167]=mt):mt=t[167],mt}function Bc(e){console.error(`Failed to create user task:`,e)}function Vc(e){return e.mimeType.startsWith(`image/`)}function Hc(e){return e.type.startsWith(`image/`)}function Uc(){}function Wc(){}function Gc(e){return e.sender===`agent`}function Kc(e){return e.selectedProjectId}function qc(e){return e.messages}function Jc(e){return e.sidebarOpen}function Yc(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=K(m.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)(R,{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)(zo,{asChild:!0,children:(0,$.jsxs)(J,{variant:`outline`,size:`sm`,className:u,children:[d,f]})}),t[4]=f,t[5]=p);let h,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Ze,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),g=(0,$.jsx)(`span`,{children:`Create branch`}),t[6]=h,t[7]=g):(h=t[6],g=t[7]);let _;t[8]!==a||t[9]!==c?(_=(0,$.jsxs)(Wo,{onClick:c,disabled:a,children:[h,g]}),t[8]=a,t[9]=c,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Jo,{}),t[11]=v):v=t[11];let y;t[12]!==r||t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==s?(y=i?(0,$.jsxs)(`div`,{className:K(m.compact,`px-2 py-1.5 text-muted-foreground flex items-center gap-2`),children:[(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:K(m.compact,`px-2 py-1.5 text-muted-foreground`),children:`No branches found`}):r.map(e=>(0,$.jsxs)(Wo,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(R,{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:K(m.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]=y):y=t[17];let b;t[18]!==y||t[19]!==_?(b=(0,$.jsxs)(Uo,{align:`start`,children:[_,v,y]}),t[18]=y,t[19]=_,t[20]=b):b=t[20];let x;return t[21]!==l||t[22]!==b||t[23]!==p?(x=(0,$.jsxs)(Ro,{onOpenChange:l,children:[p,b]}),t[21]=l,t[22]=b,t[23]=p,t[24]=x):x=t[24],x}function Xc(e){let t=(0,X.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,l;t[0]!==i||t[1]!==o||t[2]!==s?(l=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(c,{children:[(0,$.jsx)(Ct,{children:`New Branch`}),(0,$.jsx)(oe,{children:`Enter a name for the new branch. It will be created from the default branch.`})]}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(g,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==o||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[f,(0,$.jsx)(Te,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:u,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=u,t[10]=o,t[11]=p,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=()=>r(!1),t[13]=r,t[14]=h);let _;t[15]!==o||t[16]!==h?(_=(0,$.jsx)(J,{variant:`outline`,onClick:h,disabled:o,children:`Cancel`}),t[15]=o,t[16]=h,t[17]=_):_=t[17];let v;t[18]!==i||t[19]!==o?(v=o||!i.trim(),t[18]=i,t[19]=o,t[20]=v):v=t[20];let b=o?`Creating...`:`Create Branch`,x;t[21]!==s||t[22]!==v||t[23]!==b?(x=(0,$.jsx)(J,{onClick:s,disabled:v,children:b}),t[21]=s,t[22]=v,t[23]=b,t[24]=x):x=t[24];let S;t[25]!==x||t[26]!==_?(S=(0,$.jsxs)(wt,{children:[_,x]}),t[25]=x,t[26]=_,t[27]=S):S=t[27];let w;t[28]!==S||t[29]!==m?(w=(0,$.jsxs)(y,{children:[d,m,S]}),t[28]=S,t[29]=m,t[30]=w):w=t[30];let T;return t[31]!==r||t[32]!==n||t[33]!==w?(T=(0,$.jsx)(C,{open:n,onOpenChange:r,children:w}),t[31]=r,t[32]=n,t[33]=w,t[34]=T):T=t[34],T}function Zc(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=Lr();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)(F,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(pt,{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)(J,{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 Qc=[{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 $c(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function el(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function tl(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=Qc.filter(e);d=`w-72 space-y-3`;let h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`h3`,{className:m.label,children:`Context`}),t[13]=h):h=t[13];let g;t[14]===r?g=t[15]:(g=r&&(0,$.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,$.jsx)(T,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[14]=r,t[15]=g),t[16]===g?f=t[17]:(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[h,g]}),t[16]=g,t[17]=f);let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=K(m.compact,`flex items-center justify-between text-muted-foreground`),t[18]=_):_=t[18];let v;t[19]===s?v=t[20]:(v=(0,$.jsxs)(`span`,{children:[s,`% Full`]}),t[19]=s,t[20]=v);let y;t[21]===a?y=t[22]:(y=$c(a),t[21]=a,t[22]=y);let b;t[23]===o?b=t[24]:(b=el(o),t[23]=o,t[24]=b);let x;t[25]!==y||t[26]!==b?(x=(0,$.jsxs)(`span`,{children:[`~`,y,` / `,b,` Tokens`]}),t[25]=y,t[26]=b,t[27]=x):x=t[27],t[28]!==v||t[29]!==x?(p=(0,$.jsxs)(`div`,{className:_,children:[v,x]}),t[28]=v,t[29]=x,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 S;t[31]!==i||t[32]!==o?(S=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]=S):S=t[33],l=n.map(S),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 h;t[34]!==c||t[35]!==l?(h=(0,$.jsx)(`div`,{className:c,children:l}),t[34]=c,t[35]=l,t[36]=h):h=t[36];let g;t[37]!==u||t[38]!==h?(g=(0,$.jsx)(`div`,{className:u,children:h}),t[37]=u,t[38]=h,t[39]=g):g=t[39];let _;t[40]===i?_=t[41]:(_=Qc.map(e=>(0,$.jsxs)(`div`,{className:K(m.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:$c(i[e.key])})]},e.key)),t[40]=i,t[41]=_);let v;t[42]===_?v=t[43]:(v=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:_}),t[42]=_,t[43]=v);let y;return t[44]!==v||t[45]!==d||t[46]!==f||t[47]!==p||t[48]!==g?(y=(0,$.jsxs)(`div`,{className:d,children:[f,p,g,v]}),t[44]=v,t[45]=d,t[46]=f,t[47]=p,t[48]=g,t[49]=y):y=t[49],y}function nl({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,h]=(0,Y.useState)(n?t:void 0);return(0,Y.useEffect)(()=>{if(n){o(n),h(t),u(null);return}t!==p&&(o(null),h(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 on(e,r);if(n)return;o(t),h(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)(oo,{open:d,onOpenChange:f,children:[(0,$.jsx)(so,{asChild:!0,children:i}),(0,$.jsxs)(co,{side:`top`,align:`end`,className:`w-auto p-4`,children:[s&&(0,$.jsxs)(`div`,{className:K(m.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(Ot,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading context...`})]}),l&&!s&&(0,$.jsxs)(`div`,{className:K(m.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(Ot,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:l})]}),!s&&!l&&a&&(0,$.jsx)(tl,{breakdown:a,onClose:()=>f(!1)})]})]})}function rl(e){return e.filter(e=>e.sender===`agent`).length}function il(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function al(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=il(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 ol(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=rl(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 Tt(n)).currentConversationId;if(s(e),!e){l(void 0);return}l(await on(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,h=typeof m==`number`&&m>25,g=String(d),_;t[9]!==m||t[10]!==h?(_=h?(0,$.jsx)(al,{percentage:m}):(0,$.jsx)(Ae,{className:`h-4 w-4`}),t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[12]=v):v=t[12];let y;t[13]===_?y=t[14]:(y=(0,$.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[_,v]}),t[13]=_,t[14]=y);let b;return t[15]!==c||t[16]!==o||t[17]!==g||t[18]!==y||t[19]!==n?(b=(0,$.jsx)(nl,{threadId:n,currentConversationId:o,initialBreakdown:c,refreshKey:g,children:y}),t[15]=c,t[16]=o,t[17]=g,t[18]=y,t[19]=n,t[20]=b):b=t[20],b}var sl=`[gitops-timing]`;function cl(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(`${sl} ${e} step=${n} ${r}ms`)}}function i(n,r,i){t.push({step:n,ms:r}),console.log(`${sl} ${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(`${sl} ${e} summary total=${i}ms slowest=${a.step}@${a.ms}ms breakdown=[${o}]${r?` ${r}`:``}`)}return{step:r,record:i,summary:a}}var ll=3e4,ul={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},dl=new Map,fl=new Map;function pl(e,t){let n=dl.get(e);if(n)for(let e of n)e(t)}function ml(e,t){let n=dl.get(e);return n||(n=new Set,dl.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&dl.delete(e)}}function hl(e){return`unified-git-status-${e}`}function gl(e){return s.getSync(hl(e))}function _l(e){let[t,n]=(0,Y.useState)(ul),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(void 0),o=(0,Y.useRef)(0),c=(0,Y.useCallback)(e=>{(0,Y.startTransition)(()=>{n(e)})},[]),l=(0,Y.useRef)(c);l.current=c;let u=(0,Y.useCallback)(async(t=!1)=>{if(!e)return;let n=++o.current,r=cl(`hook fetch thread=${e} force=${t}`),a=setTimeout(()=>{o.current===n&&i(!0)},100);try{let i=hl(e),a=performance.now(),l=gl(e);r.record(`local-cache-check`,Math.round(performance.now()-a),`result=${l?`hit`:`miss`}`),t&&(s.invalidate(i),r.record(`invalidate-local-cache`,0));let u=await r.step(`ttl-cache-get`,()=>s.get(i,()=>re(e,t,!1),ll));if(o.current!==n){r.summary(`stale-request`);return}await r.step(`update-state`,async()=>{c(u),pl(e,u)}),r.summary(`branch=${u.currentBranch} changes=${u.changedFilesCount} prExists=${u.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,c]),d=(0,Y.useRef)(u);return d.current=u,(0,Y.useEffect)(()=>{if(e)return ml(e,e=>{l.current(e)})},[e]),(0,Y.useEffect)(()=>{if(!e)return;let t=e;function n(){document.visibilityState===`visible`&&(s.invalidate(hl(t)),d.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(ul)});return}let t=a.current!==e,r=gl(e);t&&(console.log(`[gitops-timing] hook thread changed ${a.current??`none`} -> ${e}`),a.current=e,s.invalidate(hl(e))),(0,Y.startTransition)(()=>{n(r??ul)}),console.log(r?`[gitops-timing] hook load thread=${e} local cache=hit`:`[gitops-timing] hook load thread=${e} local cache=miss`);let c=e,u=!1;function f(){if(u)return;let e=fl.get(c);if(e){console.log(`[gitops-timing] hook initial fetch already in flight thread=${c}`),e.then(()=>{if(u)return;let e=gl(c);e&&l.current(e)});return}console.log(`[gitops-timing] hook starting initial fetch thread=${c}`);let t=d.current(!1).finally(()=>{console.log(`[gitops-timing] hook initial fetch settled thread=${c}`),fl.delete(c)});fl.set(c,t)}return f(),()=>{u=!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:u}}var vl=(0,Y.createContext)(void 0);function yl(e){let t=(0,X.c)(8),{threadId:n,fetchUnifiedStatus:r}=e,i=_i(),a=Q(Sl),o=Q(xl),s=Q(bl),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 bl(e){return e.selectedThreadId}function xl(e){return e.completedThreadIds}function Sl(e){return e.isStreaming}function Cl(e){let t=(0,X.c)(7),{threadId:n,children:r}=e,i=_l(n),a;t[0]!==n||t[1]!==i.fetchUnifiedStatus?(a=(0,$.jsx)(yl,{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)(vl.Provider,{value:i,children:[a,r]}),t[3]=r,t[4]=a,t[5]=i,t[6]=o):o=t[6],o}function wl(){let e=(0,Y.useContext)(vl);if(e===void 0)throw Error(`useGitStatus must be used within a GitStatusProvider`);return e}var Tl=`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 El(){return Tl[Math.floor(Math.random()*Tl.length)]??`branch`}function Dl(){let e=El(),t=El();for(;t===e;)t=El();return`${e}-${t}`}function Ol(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,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(`main`),g=wl();(0,Y.useEffect)(()=>{if(!s){u(``);return}u(Dl())},[s]),(0,Y.useEffect)(()=>{g.defaultBranch&&h(g.defaultBranch)},[g.defaultBranch]);async function _(){if(!(!e||r)){i(!0);try{n((await f(e)).branches)}catch{n([])}finally{i(!1)}}}async function v(t){if(!(!e||t===g.currentBranch)){o(!0);try{await E(e,t),await g.fetchUnifiedStatus(!0),Pi({title:`Switched to branch "${t}"`})}catch(e){Pi({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}function y(){c(!0)}async function b(){if(!(!e||!l.trim()||d)){p(!0);try{let t=await B(e,m,l);c(!1),await _(),await g.fetchUnifiedStatus(!0),Pi({title:`Branch created`,description:`Created branch "${t.branchName}" from ${m}`})}catch(e){Pi({title:`Failed to create branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{p(!1)}}}return{currentBranch:g.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:_,checkoutBranch:v,fetchUnifiedStatus:g.fetchUnifiedStatus,isCreateDialogOpen:s,setIsCreateDialogOpen:c,newBranchName:l,setNewBranchName:u,isCreatingBranch:d,createBranch:b,openCreateBranchDialog:y,defaultBranch:m}}function kl({threadId:e,messages:t=[]}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(null),o=Ol(e);return(0,Y.useEffect)(()=>{e&&Rt(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)(Yc,{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)(Zc,{collapsed:!1}),(0,$.jsx)(ol,{threadId:e,messages:t}),e&&(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||n)){r(!0);try{let t=await Rt(e);await navigator.clipboard.writeText(t)}finally{r(!1)}}},disabled:n,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(wn,{className:`h-4 w-4`})})}),(0,$.jsxs)(G,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),i&&(0,$.jsx)(`div`,{className:K(m.compact,`opacity-70`),children:i})]})]})]})]}),(0,$.jsx)(Xc,{open:o.isCreateDialogOpen,onOpenChange:o.setIsCreateDialogOpen,branchName:o.newBranchName,onBranchNameChange:o.setNewBranchName,isLoading:o.isCreatingBranch,onCreateBranch:()=>void o.createBranch()})]})}var Al=40,jl=4,Ml=10,Nl=2*Math.PI*Ml;function Pl(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(Il),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:m.compact,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(Fl),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:K(m.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 Fl(e){return(0,$.jsxs)(`div`,{className:K(m.caption,`flex items-start gap-2`),children:[e.status===`done`?(0,$.jsx)(It,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(n,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(at,{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 Il(e){return e.status===`done`}function Ll(e){let t=(0,X.c)(3),{completedCount:n,totalCount:r}=e,i=Nl*(1-(r>0?n/r:0)),a=Al/2,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:a,cy:a,r:Ml,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:jl}),t[0]=o):o=t[0];let s;return t[1]===i?s=t[2]:(s=(0,$.jsxs)(`svg`,{"aria-hidden":`true`,width:Al,height:Al,viewBox:`0 0 ${Al} ${Al}`,className:`size-10 shrink-0`,children:[o,(0,$.jsx)(`circle`,{cx:a,cy:a,r:Ml,fill:`none`,stroke:`currentColor`,strokeWidth:jl,strokeDasharray:Nl,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 Rl(e){let t=(0,X.c)(43),{layout:n}=e,r=n===void 0?`bar`:n,{todos:i}=(0,Y.useContext)(xo),[a,o]=(0,Y.useState)(!1),s;t[0]===i?s=t[1]:(s=i.filter(zl),t[0]=i,t[1]=s);let l=s.length,u=i.length-l,d=`${l} of ${i.length} complete`;if(u<=0)return null;if(r===`menu`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;t[3]!==l||t[4]!==i.length?(n=(0,$.jsx)(Ll,{completedCount:l,totalCount:i.length}),t[3]=l,t[4]=i.length,t[5]=n):n=t[5];let r;t[6]===d?r=t[7]:(r=(0,$.jsx)(`span`,{children:d}),t[6]=d,t[7]=r);let s;t[8]!==n||t[9]!==r?(s=(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:e,children:[n,r]}),t[8]=n,t[9]=r,t[10]=s):s=t[10];let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Agent Todos`})}),t[11]=u):u=t[11];let f;t[12]===i?f=t[13]:(f=(0,$.jsxs)(y,{className:`max-w-md`,children:[u,(0,$.jsx)(Pl,{todos:i})]}),t[12]=i,t[13]=f);let p;t[14]!==a||t[15]!==f?(p=(0,$.jsx)(C,{open:a,onOpenChange:o,children:f}),t[14]=a,t[15]=f,t[16]=p):p=t[16];let m;return t[17]!==s||t[18]!==p?(m=(0,$.jsxs)($.Fragment,{children:[s,p]}),t[17]=s,t[18]=p,t[19]=m):m=t[19],m}let f;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>o(!0),t[20]=f):f=t[20];let p;t[21]!==l||t[22]!==i.length?(p=(0,$.jsx)(Ll,{completedCount:l,totalCount:i.length}),t[21]=l,t[22]=i.length,t[23]=p):p=t[23];let m;t[24]===d?m=t[25]:(m=(0,$.jsx)(`span`,{className:`sr-only`,children:d}),t[24]=d,t[25]=m);let h;t[26]!==p||t[27]!==m?(h=(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon`,className:`ml-2 rounded-full [&_svg]:!size-10`,onClick:f,children:[p,m]})}),t[26]=p,t[27]=m,t[28]=h):h=t[28];let g;t[29]===d?g=t[30]:(g=(0,$.jsx)(G,{children:d}),t[29]=d,t[30]=g);let _;t[31]!==h||t[32]!==g?(_=(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[h,g]})}),t[31]=h,t[32]=g,t[33]=_):_=t[33];let v;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Agent Todos`})}),t[34]=v):v=t[34];let b;t[35]===i?b=t[36]:(b=(0,$.jsxs)(y,{className:`max-w-md`,children:[v,(0,$.jsx)(Pl,{todos:i})]}),t[35]=i,t[36]=b);let x;t[37]!==a||t[38]!==b?(x=(0,$.jsx)(C,{open:a,onOpenChange:o,children:b}),t[37]=a,t[38]=b,t[39]=x):x=t[39];let S;return t[40]!==x||t[41]!==_?(S=(0,$.jsxs)($.Fragment,{children:[_,x]}),t[40]=x,t[41]=_,t[42]=S):S=t[42],S}function zl(e){return e.status===`done`}function Bl(e){let t=(0,X.c)(30),{tasks:n,disabled:r,onSelectTask:i,onRemoveTask:a,layout:o}=e,s=r===void 0?!1:r,c=o===void 0?`bar`:o,[l,u]=(0,Y.useState)(!1),d=n.length,f=`${d} Pending ${d===1?`Task`:`Tasks`}`;if(d===0)return null;let p;t[0]===i?p=t[1]:(p=function(e){i(e),u(!1)},t[0]=i,t[1]=p);let h=p,g;t[2]!==a||t[3]!==d?(g=function(e){a(e),d===1&&u(!1)},t[2]=a,t[3]=d,t[4]=g):g=t[4];let _=g,v=c===`menu`?`ghost`:`outline`,y=c===`bar`&&`bg-background`,b=c===`menu`&&`w-full justify-start`,x;t[5]!==y||t[6]!==b?(x=K(`gap-2`,y,b),t[5]=y,t[6]=b,t[7]=x):x=t[7];let S;t[8]===f?S=t[9]:(S=(0,$.jsx)(`span`,{children:f}),t[8]=f,t[9]=S);let C;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(yt,{className:`h-4 w-4 shrink-0`}),t[10]=C):C=t[10];let w;t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==S?(w=(0,$.jsx)(so,{asChild:!0,children:(0,$.jsxs)(J,{variant:v,size:`sm`,className:x,disabled:s,children:[S,C]})}),t[11]=s,t[12]=v,t[13]=x,t[14]=S,t[15]=w):w=t[15];let E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`div`,{className:K(m.compact,m.label,`px-2 pb-1 pt-1 text-muted-foreground`),children:`Tasks`}),t[16]=E):E=t[16];let D;if(t[17]!==_||t[18]!==h||t[19]!==n){let e;t[21]!==_||t[22]!==h?(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:()=>h(e),children:[(0,$.jsx)(nn,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:K(m.body,`line-clamp-3 text-foreground`),children:e.content})]}),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>_(e.id),children:[(0,$.jsx)(T,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove task`})]})]},e.id),t[21]=_,t[22]=h,t[23]=e):e=t[23],D=n.map(e),t[17]=_,t[18]=h,t[19]=n,t[20]=D}else D=t[20];let O;t[24]===D?O=t[25]:(O=(0,$.jsx)(co,{align:`start`,className:`w-96 p-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[E,D]})}),t[24]=D,t[25]=O);let k;return t[26]!==l||t[27]!==w||t[28]!==O?(k=(0,$.jsxs)(oo,{open:l,onOpenChange:u,children:[w,O]}),t[26]=l,t[27]=w,t[28]=O,t[29]=k):k=t[29],k}var Vl=(0,Y.createContext)(void 0);function Hl(e){let t=(0,X.c)(24),{children:n}=e,r=_i(),i=Q(Kl),a=Q(Gl),o=Q(Wl),s=Q(Ul),{toast:c}=Fi(),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Y.useState)(l),f=s?.threadId===i,p=o||f,m,h;t[1]!==i||t[2]!==c?(m=()=>{if(!i){d([]);return}let e=!1;return(async function(){try{let t=await ue(i);e||d(t)}catch(t){e||(console.error(`Failed to load user tasks:`,t),c({title:`Could not load tasks`,description:`Failed to load UserTasks for this thread.`,variant:`destructive`}))}})(),()=>{e=!0}},h=[i,c],t[1]=i,t[2]=c,t[3]=m,t[4]=h):(m=t[3],h=t[4]),(0,Y.useEffect)(m,h);let g;t[5]!==r||t[6]!==i?(g=async function(){if(i)try{let e=await ft(i);r({type:Z.ClearMessages}),console.log(`New conversation started:`,e),setTimeout(()=>{(async()=>{try{let e=await st(i);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]=i,t[7]=g):g=t[7];let _=g,v;t[8]!==i||t[9]!==c?(v=async function(e){if(i)try{await ge(i,e),d(t=>t.filter(t=>t.id!==e))}catch(e){console.error(`Failed to delete user task:`,e),c({title:`Could not remove task`,description:`Failed to delete the selected task.`,variant:`destructive`})}},t[8]=i,t[9]=c,t[10]=v):v=t[10];let y=v,b;t[11]!==r||t[12]!==i?(b=function(e){i&&r({type:Z.SetChatInputDraft,threadId:i,draft:e.content})},t[11]=r,t[12]=i,t[13]=b):b=t[13];let x=b,S;t[14]!==p||t[15]!==_||t[16]!==y||t[17]!==x||t[18]!==a||t[19]!==u?(S={userTasks:u,setUserTasks:d,handleNewChat:_,handleSelectUserTask:x,handleRemoveUserTask:y,effectiveIsStreaming:p,isCreatingProject:a},t[14]=p,t[15]=_,t[16]=y,t[17]=x,t[18]=a,t[19]=u,t[20]=S):S=t[20];let C;return t[21]!==n||t[22]!==S?(C=(0,$.jsx)(Vl.Provider,{value:S,children:n}),t[21]=n,t[22]=S,t[23]=C):C=t[23],C}function Ul(e){return e.pendingChatMessage}function Wl(e){return e.isStreaming}function Gl(e){return e.isCreatingProject}function Kl(e){return e.selectedThreadId}function ql(){let e=(0,Y.useContext)(Vl);if(e===void 0)throw Error(`useChatInputToolbar must be used within a ChatInputToolbarProvider`);return e}function Jl({workspaceEntries:e,hasMultipleWorkspaces:t,runningScripts:n,onScriptClick:r}){return t?e.map(([e,t])=>(0,$.jsxs)(Bo,{children:[(0,$.jsx)(Vo,{children:e}),(0,$.jsx)(Ho,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Wo,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):e[0]?.[1].map(e=>(0,$.jsxs)(Wo,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))}function Yl({workspaceEntries:e,hasMultipleWorkspaces:t,runningScripts:n,onScriptClick:r}){return t?e.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs font-medium text-muted-foreground`,children:e}),t.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent`,onClick:()=>{r(e)},children:[n.has(e.name)?(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))]},e)):e[0]?.[1].map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent`,onClick:()=>{r(e)},children:[n.has(e.name)?(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))}function Xl({threadId:e,layout:t=`bar`}){let n=_i(),{setTerminalNotification:r}=va(),[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 Ye(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 t=>{if(o.has(t.name)){let r=c.current.get(t.name);r&&(r.abort(),c.current.delete(t.name));try{await Nt(e,t.name)}catch{}n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${t.friendlyName} stopped`}}),s(e=>{let n=new Set(e);return n.delete(t.name),n})}else{let i=new AbortController;c.current.set(t.name,i),s(e=>new Set([...e,t.name])),r(!0),n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${t.friendlyName}`}});try{let r=await Ft(e,t.name,t.command,{signal:i.signal});if(r){let t=r.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:r,value:o}=await t.read();if(r)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
46
|
+
`);a=s.pop()??``;for(let t of s)if(t.trim())try{let r=JSON.parse(t);typeof r==`string`?n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&n({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:t}})}}if(a.trim())try{let t=JSON.parse(a);typeof t==`string`?n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:t}}):t.type===`error`&&n({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:t.message}})}catch{n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{t.releaseLock()}}n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${t.friendlyName} done`}})}catch{}finally{c.current.delete(t.name),s(e=>{let n=new Set(e);return n.delete(t.name),n})}}};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;function p(e){l(e)}return t===`menu`?(0,$.jsxs)(oo,{children:[(0,$.jsx)(so,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(Qt,{className:`h-4 w-4 shrink-0`}),`Project Scripts`]})}),(0,$.jsx)(co,{align:`start`,className:`w-56 p-1`,children:(0,$.jsx)(Yl,{workspaceEntries:d,hasMultipleWorkspaces:f,runningScripts:o,onScriptClick:p})})]}):(0,$.jsxs)(Ro,{children:[(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsx)(J,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Qt,{})})})}),(0,$.jsx)(G,{children:`Project Scripts`})]})}),(0,$.jsx)(Uo,{align:`end`,className:`min-w-[180px]`,children:(0,$.jsx)(Jl,{workspaceEntries:d,hasMultipleWorkspaces:f,runningScripts:o,onScriptClick:p})})]})}var Zl=`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 Ql({open:e,onOpenChange:t,projectId:n,commands:r,onRefresh:i}){let[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)([]),[h,_]=(0,Y.useState)(0),[v,b]=(0,Y.useState)(!1),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),w=()=>{o({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),d(!1),p([])},E=e=>{o({...e}),d(!1),p([])},D=async()=>{try{b(!0);let e=await ln(n);p(e.scripts),_(0),d(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),Pi({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{b(!1)}},O=e=>{o(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),d(!1),p([]),x.current?.focus()},A=e=>{u&&(e.key===`ArrowDown`?(e.preventDefault(),_(e=>e<f.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),_(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),h<f.length&&O(f[h])):e.key===`Escape`&&(e.preventDefault(),d(!1),p([])))};(0,Y.useEffect)(()=>{let e=e=>{S.current&&!S.current.contains(e.target)&&(d(!1),p([]))};return u&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[u]);let j=async e=>{try{await bt(n,e),Pi({title:`Success`,description:`Command deleted`}),i()}catch{Pi({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(C,{open:e,onOpenChange:t,children:(0,$.jsxs)(y,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(c,{children:[(0,$.jsx)(Ct,{children:`Project Commands`}),(0,$.jsx)(oe,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:a?(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)(g,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(Te,{id:`name`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(g,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(bi,{ref:x,id:`commandLine`,value:a.commandLine,onChange:e=>o({...a,commandLine:e.target.value}),onKeyDown:A,placeholder:`e.g. npm test`,className:`font-mono text-base min-h-[100px] resize-none pr-10`}),(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void D(),disabled:v,children:(0,$.jsx)(tn,{className:`h-4 w-4`})})}),(0,$.jsx)(G,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),u&&(0,$.jsx)(`div`,{ref:S,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:K(m.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),children:[(0,$.jsx)(tn,{className:`h-3 w-3`}),`Available Scripts `,v&&`(loading...)`]}),f.length>0?(()=>{let e={};f.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:K(m.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:K(`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:()=>O(e),onMouseEnter:()=>_(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:K(m.caption,`font-mono`),children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:K(m.caption,`px-3 py-4 text-center`),children:v?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(g,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(Te,{id:`relativeFolder`,value:a.relativeFolder??``,onChange:e=>o({...a,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:m.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)(g,{children:`Icon`}),(0,$.jsx)(qt,{children:(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Zl.map(e=>{let t=ne[e]||rn;return(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:a.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>o({...a,icon:e}),children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),(0,$.jsx)(G,{children:e})]},e)})})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(null),children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(J,{size:`sm`,onClick:async()=>{if(!a?.name||!a?.commandLine){Pi({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{l(!0),await $t(n,a),Pi({title:`Success`,description:`Command saved`}),o(null),i()}catch{Pi({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{l(!1)}},disabled:s,children:[(0,$.jsx)(Qe,{className:`h-4 w-4 mr-2`}),` `,s?`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:[r.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),r.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:()=>E(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(ne[e.icon]||Et,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:m.label,children:e.name}),(0,$.jsx)(`span`,{className:K(m.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)(J,{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(),j(e.id)},children:(0,$.jsx)(k,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(J,{variant:`outline`,className:`w-full border-dashed`,onClick:w,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function $l(e){let t=(0,X.c)(36),{layout:n}=e,i=n===void 0?`bar`:n,a=Q(ru),o=Q(nu),s=Q(tu),c=Q(eu),{dispatch:l}=yi(o),[u,d]=(0,Y.useState)(!1),f,p,m,h,g;if(t[0]!==l||t[1]!==c||t[2]!==i||t[3]!==s||t[4]!==a||t[5]!==o||t[6]!==u){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[12]===a?e=t[13]:(e=e=>e.projectId===a,t[12]=a,t[13]=e),f=s.find(e)?.commands??[];let n;t[14]!==l||t[15]!==a||t[16]!==o?(n=e=>{!a||!o||l({type:Z.QueueTerminalCommand,threadId:o,command:e.commandLine,relativeFolder:e.relativeFolder})},t[14]=l,t[15]=a,t[16]=o,t[17]=n):n=t[17];let _=n,v;if(t[18]===l?v=t[19]:(v=async()=>{l({type:Z.ConfigUpdated})},t[18]=l,t[19]=v),p=v,!a){g=null;break bb0}if(i===`menu`){let e;t[20]!==_||t[21]!==c?(e=e=>(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:()=>_({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:c,children:[(0,$.jsx)(ne[e.icon]||Et,{className:`h-4 w-4 shrink-0`}),e.name]},e.id),t[20]=_,t[21]=c,t[22]=e):e=t[22];let n,i;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>d(!0),n=(0,$.jsx)(r,{className:`h-4 w-4 shrink-0`}),t[23]=n,t[24]=i):(n=t[23],i=t[24]);let o=f.length===0?`Project Commands`:`Manage commands`,s;t[25]===o?s=t[26]:(s=(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:i,children:[n,o]}),t[25]=o,t[26]=s),g=(0,$.jsxs)($.Fragment,{children:[f.map(e),s,(0,$.jsx)(Ql,{open:u,onOpenChange:d,projectId:a,commands:f,onRefresh:p})]});break bb0}m=`flex items-center gap-1`,h=f.length===0?(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:`action`,size:`icon-md`,onClick:()=>d(!0),children:(0,$.jsx)(r,{})})}),(0,$.jsx)(G,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(qt,{children:[f.map(e=>(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:`action`,size:`icon-md`,onClick:()=>_({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:c,children:(0,$.jsx)(ne[e.icon]||Et,{})})}),(0,$.jsx)(G,{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)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>d(!0),children:(0,$.jsx)(r,{})})}),(0,$.jsx)(G,{children:`Manage commands`})]})]})})}t[0]=l,t[1]=c,t[2]=i,t[3]=s,t[4]=a,t[5]=o,t[6]=u,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g}else f=t[7],p=t[8],m=t[9],h=t[10],g=t[11];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[27]!==f||t[28]!==p||t[29]!==a||t[30]!==u?(_=(0,$.jsx)(Ql,{open:u,onOpenChange:d,projectId:a,commands:f,onRefresh:p}),t[27]=f,t[28]=p,t[29]=a,t[30]=u,t[31]=_):_=t[31];let v;return t[32]!==m||t[33]!==h||t[34]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[32]=m,t[33]=h,t[34]=_,t[35]=v):v=t[35],v}function eu(e){return e.isRunningCommand}function tu(e){return e.projects}function nu(e){return e.selectedThreadId}function ru(e){return e.selectedProjectId}var iu=`VS Code`;function au(e){return e||me(iu)}var ou={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function su({projectId:e,threadId:n,openWith:r,layout:i=`bar`}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(()=>au(r)),[d,f]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{(async()=>{try{let e=await t();c(e);let n=au(r);e.includes(n)?u(n):e.length>0&&u(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),c([iu])}finally{f(!1)}})()},[]),(0,Y.useEffect)(()=>{if(r&&s.includes(r)){u(r);return}let e=me(iu);!r&&s.includes(e)&&u(e)},[r,s]);async function p(t){u(t),Bt(t),await we(e,t)}let m=async t=>{try{o(!0),await p(t),n?await Ve(n,t):await Ie(e,t),Pi({title:`Success`,description:`Opened project in ${t}`})}catch(e){console.error(`Failed to open project in ${t}:`,e);let n=`Failed to open project in ${t}`;if(e instanceof Error){let t=e;n=t.details?t.details:e.message}Pi({title:`Error`,description:n,variant:`destructive`})}finally{o(!1)}};async function h(e){try{await p(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),Pi({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}let g=async()=>{await m(l)};return d?(0,$.jsx)(J,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):i===`menu`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,disabled:a,onClick:()=>{g()},children:[(0,$.jsx)(`img`,{src:`/ide/${ou[l]||ou[iu]}.svg`,alt:l,className:`h-4 w-4 shrink-0`}),`Open in `,l]}),(0,$.jsxs)(oo,{children:[(0,$.jsx)(so,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(tn,{className:`h-4 w-4 shrink-0`}),`Change IDE`]})}),(0,$.jsx)(co,{align:`start`,className:`w-56 p-1`,children:s.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>{h(e)},disabled:a,children:[(0,$.jsx)(`img`,{src:`/ide/${ou[e]||ou[iu]}.svg`,alt:e,className:`h-4 w-4 shrink-0`}),e]},e))})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:a,onClick:g,children:(0,$.jsx)(`img`,{src:`/ide/${ou[l]||ou[iu]}.svg`,alt:l,className:`h-4 w-4`})})}),(0,$.jsx)(G,{children:`Open in ${l}`})]}),(0,$.jsxs)(Ro,{children:[(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsx)(J,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:a,children:(0,$.jsx)(tn,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Uo,{align:`end`,children:s.map(e=>(0,$.jsxs)(Wo,{onClick:()=>void h(e),disabled:a,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${ou[e]||ou[iu]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function cu({projectId:e,runCommand:t,large:n,layout:r=`bar`}){let{dispatch:i}=yi(Q(e=>e.selectedThreadId)),{setDevServerUrl:a,devServerRunning:o,setDevServerRunning:s,devServerLoading:c,setDevServerLoading:l}=va(),{startServer:u}=Os(),d=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{(async()=>{try{s((await Zt(e)).isRunning)}catch{s(!1)}})()},[e]);let f=()=>{u({projectId:e,runCommand:t||``})},p=async()=>{d.current=!0,l(!0);try{await Gt(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}}),Pi({title:`Error`,description:t,variant:`destructive`})}finally{l(!1)}},h=!!t,g=c?`Starting...`:o?`Stop dev server`:`Start dev server`;return n?(0,$.jsxs)(`button`,{onClick:o?p:f,disabled:c||!o&&!h,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)(hn,{className:`h-10 w-10 animate-spin`}):o?(0,$.jsx)(N,{className:`h-10 w-10 fill-current`}):(0,$.jsx)(Et,{className:`h-10 w-10 fill-current group-hover:text-foreground transition-colors`}),(0,$.jsx)(`span`,{className:K(m.body,`group-hover:text-foreground transition-colors`),children:g})]}):r===`menu`?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:K(`w-full justify-start gap-2`,o&&`text-orange-500`),onClick:o?p:f,disabled:c||!o&&!h,children:[c?(0,$.jsx)(hn,{className:`h-4 w-4 shrink-0 animate-spin`}):o?(0,$.jsx)(N,{className:`h-4 w-4 shrink-0 fill-current`}):(0,$.jsx)(Et,{className:`h-4 w-4 shrink-0`}),g]}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(qt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{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&&!h,children:[c?(0,$.jsx)(hn,{className:`h-4 w-4 animate-spin`}):o?(0,$.jsx)(N,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(Et,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:o?`Stop dev server`:`Start dev server`})]})}),(0,$.jsx)(G,{children:o?`Stop dev server`:h?`Start dev server: ${t}`:`Set run command in project settings`})]})})})}var lu=(0,Y.lazy)(()=>fr(()=>import(`./git-ops-button-D9m2nmhO.js`).then(e=>({default:e.GitOpsButton})),__vite__mapDeps([2,1,3,4,5])));function uu(e){return e===`menu`?`w-full justify-start gap-2`:`gap-2`}function du(e){let t=(0,X.c)(4),{threadId:n,projectId:r,messages:i,userTasks:a}=e,{hasChanges:o}=wl(),s=i.length>0,c=!!n&&(s||o||a.length>0||!!(n&&r)),l;return t[0]!==o||t[1]!==s||t[2]!==c?(l={isVisible:c,hasMessages:s,hasChanges:o},t[0]=o,t[1]=s,t[2]=c,t[3]=l):l=t[3],l}function fu(e){let t=(0,X.c)(60),{threadId:n,projectId:r,messages:i,userTasks:a,effectiveIsStreaming:o,isCreatingProject:s,onNewChat:c,onSelectUserTask:l,onRemoveUserTask:u,layout:d}=e,f=d===void 0?`bar`:d,{setActiveMainTab:p}=va(),m;t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a?(m={threadId:n,projectId:r,messages:i,userTasks:a},t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=m):m=t[4];let{hasMessages:h,hasChanges:g,isVisible:_}=du(m),{changedFilesCount:v}=wl(),y;t[5]===f?y=t[6]:(y=uu(f),t[5]=f,t[6]=y);let b=y,x=Q(pu),S;if(t[7]!==r||t[8]!==x){let e;t[10]===r?e=t[11]:(e=e=>e.projectId===r,t[10]=r,t[11]=e),S=x.find(e),t[7]=r,t[8]=x,t[9]=S}else S=t[9];let C=S,T=f===`menu`&&!!n&&!!r,E=h||g||a.length>0||!!(n&&r);if(!_)return null;let D=f===`bar`&&`absolute -top-12 left-0 z-10 ml-8 flex flex-wrap items-center gap-2`,O=f===`menu`&&`flex flex-col items-stretch gap-1 p-1 min-w-[220px]`,k;t[12]!==D||t[13]!==O?(k=K(D,O),t[12]=D,t[13]=O,t[14]=k):k=t[14];let A=f===`bar`?!0:void 0,j;t[15]!==h||t[16]!==f||t[17]!==c||t[18]!==b?(j=h&&(0,$.jsxs)(J,{variant:f===`menu`?`ghost`:`outline`,size:`sm`,className:b,onClick:c,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),t[15]=h,t[16]=f,t[17]=c,t[18]=b,t[19]=j):j=t[19];let M;t[20]!==v||t[21]!==g||t[22]!==f||t[23]!==p||t[24]!==b?(M=g&&(0,$.jsxs)(J,{variant:f===`menu`?`ghost`:`outline`,size:`sm`,className:b,onClick:()=>p(`review`),children:[(0,$.jsx)(w,{className:`h-4 w-4 shrink-0`}),v,` `,v===1?`File`:`Files`,` Changed`]}),t[20]=v,t[21]=g,t[22]=f,t[23]=p,t[24]=b,t[25]=M):M=t[25];let N;t[26]!==o||t[27]!==s||t[28]!==f||t[29]!==u||t[30]!==l||t[31]!==n||t[32]!==a?(N=a.length>0&&(0,$.jsx)(Bl,{tasks:a,disabled:o||!n&&!s,onSelectTask:l,onRemoveTask:u,layout:f}),t[26]=o,t[27]=s,t[28]=f,t[29]=u,t[30]=l,t[31]=n,t[32]=a,t[33]=N):N=t[33];let P;t[34]!==f||t[35]!==r||t[36]!==n?(P=n&&r&&(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(lu,{projectId:r,threadId:n,layout:f},n)}),t[34]=f,t[35]=r,t[36]=n,t[37]=P):P=t[37];let F;t[38]!==h||t[39]!==f?(F=h&&(0,$.jsx)(Rl,{layout:f}),t[38]=h,t[39]=f,t[40]=F):F=t[40];let I;t[41]!==E||t[42]!==T?(I=T&&E&&(0,$.jsx)(Jo,{className:`my-1`}),t[41]=E,t[42]=T,t[43]=I):I=t[43];let L;t[44]!==r||t[45]!==C?.openWith||t[46]!==C?.runCommand||t[47]!==T||t[48]!==n?(L=T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cu,{projectId:r,runCommand:C?.runCommand,layout:`menu`}),(0,$.jsx)(Xl,{threadId:n,layout:`menu`}),(0,$.jsx)($l,{layout:`menu`}),(0,$.jsx)(su,{projectId:r,threadId:n,openWith:C?.openWith,layout:`menu`})]}),t[44]=r,t[45]=C?.openWith,t[46]=C?.runCommand,t[47]=T,t[48]=n,t[49]=L):L=t[49];let R;return t[50]!==M||t[51]!==N||t[52]!==P||t[53]!==F||t[54]!==I||t[55]!==L||t[56]!==k||t[57]!==A||t[58]!==j?(R=(0,$.jsxs)(`div`,{className:k,"data-chat-toolbar":A,children:[j,M,N,P,F,I,L]}),t[50]=M,t[51]=N,t[52]=P,t[53]=F,t[54]=I,t[55]=L,t[56]=k,t[57]=A,t[58]=j,t[59]=R):R=t[59],R}function pu(e){return e.projects}function mu(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(fu,{...e}),t[0]=e,t[1]=n),n}function hu(){let e=(0,X.c)(20),t=Q(vu),n=Q(_u),r=Q(gu),{userTasks:i,handleNewChat:a,handleSelectUserTask:o,handleRemoveUserTask:s,effectiveIsStreaming:c,isCreatingProject:l}=ql(),u;e[0]!==r||e[1]!==n||e[2]!==t||e[3]!==i?(u={threadId:t,projectId:n,messages:r,userTasks:i},e[0]=r,e[1]=n,e[2]=t,e[3]=i,e[4]=u):u=e[4];let{isVisible:d}=du(u);if(!t||!d)return null;let f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(zo,{asChild:!0,children:(0,$.jsxs)(J,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 md:hidden electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(ye,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Chat actions`})]})}),e[5]=f):f=e[5];let p=n??``,m;e[6]===a?m=e[7]:(m=()=>{a()},e[6]=a,e[7]=m);let h;e[8]===s?h=e[9]:(h=e=>{s(e)},e[8]=s,e[9]=h);let g;return e[10]!==c||e[11]!==o||e[12]!==l||e[13]!==r||e[14]!==t||e[15]!==p||e[16]!==m||e[17]!==h||e[18]!==i?(g=(0,$.jsxs)(Ro,{children:[f,(0,$.jsx)(Uo,{align:`end`,className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(fu,{threadId:t,projectId:p,messages:r,userTasks:i,effectiveIsStreaming:c,isCreatingProject:l,onNewChat:m,onSelectUserTask:o,onRemoveUserTask:h,layout:`menu`})})]}),e[10]=c,e[11]=o,e[12]=l,e[13]=r,e[14]=t,e[15]=p,e[16]=m,e[17]=h,e[18]=i,e[19]=g):g=e[19],g}function gu(e){return e.messages}function _u(e){return e.selectedProjectId}function vu(e){return e.selectedThreadId}function yu(e){let t=(0,X.c)(3),{threadId:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(Cl,{threadId:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var bu=new Set,xu=new Map,Su=5e3;function Cu(e){bu.add(e);let t=xu.get(e);t&&clearTimeout(t),xu.set(e,setTimeout(()=>{bu.delete(e),xu.delete(e)},Su))}function wu(e){return bu.has(e)}function Tu(e){return e.filter(e=>!bu.has(e))}function Eu(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&&is(e.id,e.input.code,t)}catch{}}function Du(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`&&Ba(e.id,e.input.command)}catch{}}function Ou(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`&&Va(e.toolCallId)}catch{}}function ku(e,t,n){let r={type:`thinking`,content:ju,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:$r([],`thinking`,r.content??``),threadId:t})}var Au=/^\/compact(?:\s+(.*))?$/i,ju=`[Compact] Compaction in progress...`;function Mu(){let e=_i(),{toast:t}=Fi(),[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),p=Q(e=>e.queuedChatMessages),m=Q(e=>e.isStreaming),h=Q(e=>e.processingThreadIds),g=Q(e=>e.streamingModel),_=Q(e=>e.threadStreamingStates),v=Q(e=>e.pendingChatMessage);c.current=u;let y=(0,Y.useCallback)((t,n,r)=>{if(l.current.get(t)!==r){l.current.has(t)||(Cu(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;Cu(t);let i=oi(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 st(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]),b=(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)),ut(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:g||`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}),Cu(u)},[u,e,g]);(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 x=(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){y(t,i,u);return}u.cancel=he(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=ti(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=ni(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=ri(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??``;Eu(r,t),u.assistantThinking+=r,u.segments=$r(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=ei(u.segments,r),e({type:Z.SetStreamContent,content:r,threadId:t}),typeof r==`string`&&Eu(r,t)}else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=$r(u.segments,`content`,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:r,segments:u.segments,threadId:t})}}},()=>{y(t,i,u)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){y(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=$r(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=ei(u.segments,i),e({type:Z.SetStreamContent,content:i,threadId:t}),Eu(i,t)):(u.assistantMessage+=i,u.segments=$r(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&&(Du(i),Ou(i),u.assistantMessage+=i,u.segments=$r(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 et){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,y]);(0,Y.useEffect)(()=>{for(let e of h)l.current.has(e)||_[e]?.isStreaming||wu(e)||x(e,t=>Sn(e,t),`default`)},[x,h,_]);let S=(0,Y.useCallback)(async(n,i,a,o,c,l,p)=>{if(!u)return;let g=u;r(null),s(null);let _=n.trim().match(Au);if(_){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(h.includes(g)||m&&u===g){t({title:`Agent is busy`,description:`Wait for the agent to finish before compacting.`});return}let n=_[1]?.trim();ku(e,g,i);try{let r=await un(g,{model:i,provider:o,instructions:n});e({type:Z.SetMessages,messages:r.messages}),e({type:Z.ResetStream,threadId:g}),t({title:`Conversation compacted`,description:`${r.messagesBefore} messages → ${r.messagesAfter} summary`})}catch(n){e({type:Z.ResetStream,threadId:g}),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 ve(g,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:g});let S=n.trim().replace(/\n/g,` `).slice(0,100);if(d&&(ae(g,{title:S}).catch(e=>{console.error(`Failed to update thread title:`,e)}),e({type:Z.UpdateThreadTitle,projectId:d,threadId:g,title:S})),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:g}),e({type:Z.ResetStream,threadId:g});return}e({type:Z.SetStreaming,isStreaming:!0,threadId:g});try{let r=await Jt(n,i,t,g),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:g})}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:g})}finally{e({type:Z.ResetStream,threadId:g})}return}x(g,e=>cn(g,n,i,a,e,o,c,p,y),i)},[u,d,e,x,f,h,m,t]);(0,Y.useEffect)(()=>{let t=v;if(!t||m||t.threadId!==u)return;let n=setTimeout(()=>{e({type:Z.ClearPendingChatMessage}),S(t.message,t.model,[],t.provider)},100);return()=>clearTimeout(n)},[v,m,u,e,S]);let C=(0,Y.useMemo)(()=>u?p.filter(e=>e.threadId===u):[],[u,p]),w=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{if(m||!u||C.length===0||w.current)return;let[t]=C;w.current=!0,e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t.id});let n=setTimeout(()=>{S(t.message,t.model,t.attachments,t.provider,t.planMode,t.imageMode,t.ralphMode),w.current=!1},0);return()=>{clearTimeout(n),w.current=!1}},[e,S,m,C,u]),{error:n,setError:r,handleSend:S,handleStop:b,isStreaming:m,selectedThreadId:u,queuedMessagesForThread:C,handleRemoveQueuedMessage:(0,Y.useCallback)(t=>{let n=C.find(e=>e.id===t);e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t}),!(!n||m||f.length>0||!u)&&S(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[e,S,m,f.length,C,u]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function Nu(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Qn(),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)(Sr,{children:[(0,$.jsx)(vr,{children:`Balance empty`}),(0,$.jsx)(yr,{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)(wr,{children:[o,(0,$.jsx)(br,{children:(0,$.jsx)(J,{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)(xr,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Pu(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)(Fu,{messages:i}),t[2]=i,t[3]=a),a}function Fu(e){let t=(0,X.c)(44),{messages:n}=e,r=Q(Ru),i=Q(Lu),a=Q(Iu),{handleSend:o,handleStop:s,queuedMessagesForThread:c,handleRemoveQueuedMessage:l,showEmptyBalanceDialog:u,setShowEmptyBalanceDialog:d}=Mu(),{userTasks:f,setUserTasks:p,handleNewChat:m,handleSelectUserTask:h,handleRemoveUserTask:g,effectiveIsStreaming:_}=ql(),v=Ys()||Ne(),y;t[0]===d?y=t[1]:(y=()=>d(!1),t[0]=d,t[1]=y);let b;t[2]!==u||t[3]!==y?(b=(0,$.jsx)(Nu,{open:u,onClose:y}),t[2]=u,t[3]=y,t[4]=b):b=t[4];let x=v?`w-full min-w-0`:`w-[90vw] min-w-[400px]`,S;t[5]===x?S=t[6]:(S=K(`relative mx-auto max-w-3xl`,x),t[5]=x,t[6]=S);let C;t[7]!==_||t[8]!==m||t[9]!==g||t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==a||t[14]!==i||t[15]!==f?(C=i&&(a||n.length>0||f.length>0)&&(0,$.jsx)(`div`,{className:`max-md:hidden`,children:(0,$.jsx)(mu,{threadId:i,projectId:a??``,messages:n,userTasks:f,effectiveIsStreaming:_,isCreatingProject:r,onNewChat:()=>{m()},onSelectUserTask:h,onRemoveUserTask:e=>{g(e)}})}),t[7]=_,t[8]=m,t[9]=g,t[10]=h,t[11]=r,t[12]=n,t[13]=a,t[14]=i,t[15]=f,t[16]=C):C=t[16];let w=!i&&!r,T;t[17]===g?T=t[18]:(T=e=>{g(e.id)},t[17]=g,t[18]=T);let E;t[19]===p?E=t[20]:(E=e=>{p(t=>[...t,e])},t[19]=p,t[20]=E);let D;t[21]!==_||t[22]!==l||t[23]!==o||t[24]!==s||t[25]!==c||t[26]!==w||t[27]!==T||t[28]!==E||t[29]!==f?(D=(0,$.jsx)(zc,{onSend:o,onStop:s,isStreaming:_,disabled:w,initialValue:``,queuedMessages:c,onRemoveQueuedMessage:l,isOverlay:!1,userTasks:f,onMatchedUserTaskSend:T,onUserTaskCreated:E}),t[21]=_,t[22]=l,t[23]=o,t[24]=s,t[25]=c,t[26]=w,t[27]=T,t[28]=E,t[29]=f,t[30]=D):D=t[30];let O;t[31]!==C||t[32]!==D?(O=(0,$.jsxs)(`div`,{className:`relative`,children:[C,D]}),t[31]=C,t[32]=D,t[33]=O):O=t[33];let k=i??void 0,A;t[34]!==n||t[35]!==k?(A=(0,$.jsx)(`div`,{className:`max-md:hidden`,children:(0,$.jsx)(kl,{threadId:k,messages:n})}),t[34]=n,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==O||t[38]!==A||t[39]!==S?(j=(0,$.jsxs)(`div`,{className:S,children:[O,A]}),t[37]=O,t[38]=A,t[39]=S,t[40]=j):j=t[40];let M;return t[41]!==j||t[42]!==b?(M=(0,$.jsxs)($.Fragment,{children:[b,j]}),t[41]=j,t[42]=b,t[43]=M):M=t[43],M}function Iu(e){return e.selectedProjectId}function Lu(e){return e.selectedThreadId}function Ru(e){return e.isCreatingProject}var zu=768;function Bu(){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: ${zu-1}px)`),t=()=>{n(window.innerWidth<zu)};return e.addEventListener(`change`,t),n(window.innerWidth<zu),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),!!t}function Vu(){let e=(0,X.c)(7),t=_i(),n=Q(Uu),r=Q(Hu),i;e[0]!==t||e[1]!==n?(i=()=>{if(!n)return;let e=n,r=!1;return(async function(){try{let n=await st(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 Hu(e){return e.selectedProjectId}function Uu(e){return e.selectedThreadId}async function Wu(e){return U(`api/projects/${H(e)}/todos`)}async function Gu(e,t){return z(`api/projects/${H(e)}/todos`,{description:t})}async function Ku(e,t,n){return M(`api/projects/${H(e)}/todos/${H(t)}`,n)}async function qu(e,t){await St(`api/projects/${H(e)}/todos/${H(t)}`)}var Ju={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 Yu({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Y.useState)(!1),c=Ju[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 Ku(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:K(`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:K(m.label,`leading-tight`),children:e.title}),e.working&&(0,$.jsx)(hn,{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)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(J,{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)(G,{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)(W,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(J,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(P,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(G,{side:`right`,children:`Open thread`})]})]})]})}var Xu=`Please analyze this task and create a detailed implementation plan.
|
|
47
|
+
|
|
48
|
+
Task description:
|
|
49
|
+
{description}`,Zu="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Qu=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,$u=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
|
|
50
|
+
Directions:
|
|
51
|
+
Carefully read through the list of code changes creating a todo list of code to review.
|
|
52
|
+
Analyze the code structure, variable names, functions, and logic flow
|
|
53
|
+
Look for any syntax errors, bugs, or inefficiencies
|
|
54
|
+
Consider best practices for the specific programming language used
|
|
55
|
+
Provide clear and constructive feedback on areas that could be improved
|
|
56
|
+
If applicable, include examples of how to refactor problematic code
|
|
57
|
+
Offer praise for portions of the code that are well-written and follow best practices
|
|
58
|
+
|
|
59
|
+
Task description:
|
|
60
|
+
{description}`,ed={plan:Xu,test:Qu,review:$u},td={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function nd(e,t){let n=e?.[td[t]];return n&&n.trim()?n:ed[t]}function rd(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Zu.replace(/\{todoId\}/g,n)),i}var id=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],ad={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 od(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(`
|
|
61
|
+
`);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 sd(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function cd(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(`
|
|
62
|
+
`);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 ld(e){let t=await Wu(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];return await Promise.all(n.map(async t=>{try{await Tt(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ku(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n)}}})),r}function ud(e,t){return`project-todos:${e}:${t}`}function dd({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r,initialTodos:i}){let a=_i(),o=Q(e=>e.selectedThreadId),s=Q(e=>e.projectModelSelections),l=Q(e=>e.projects),[u,d]=(0,Y.useState)(i),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),[v,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(``),[O,k]=(0,Y.useState)(!1),[A,M]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!u.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Wu(e);d(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[u,e]),(0,Y.useEffect)(()=>{t&&g(``)},[t]);function N(e){g(e.description),p({todo:e})}function P(){p(null),g(``)}async function F(){if(h.trim()){b(!0);try{let t=await Gu(e,h);d(e=>[...e,t]),n(!1),g(``)}finally{b(!1)}}}async function I(){if(!(!h.trim()||!f)){b(!0);try{let t=await Ku(e,f.todo.id,{description:h});d(e=>e.map(e=>e.id===t.id?t:e)),P()}finally{b(!1)}}}async function L(){if(f){b(!0);try{await qu(e,f.todo.id),d(e=>e.filter(e=>e.id!==f.todo.id)),P()}finally{b(!1)}}}function R(e){d(t=>t.map(t=>t.id===e.id?e:t))}async function z(t){let n=o?s[o]:void 0,r=l.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===o),c=n?.id??i?.model,u=n?.provider??i?.modelProvider;if(!c||!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 _(e);if(!d)return;let f=null,p=await od(d,n=>{Ku(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{f=e,R(e)})});if(!p)return;f||R(await Ku(e,t.id,{status:`Plan`,working:!0,threadId:p}));let m=n??{id:c,provider:u,name:c,description:``};a({type:Z.SetProjectModel,threadId:p,model:m}),ae(p,{model:c,modelProvider:u});let h=await cn(p,rd(nd(r,`plan`),`plan`,t.id,t.description),c,[],void 0,u);h&&sd(h)}async function B(t){let n=await _(e);if(!n)return;let r=null,i=await od(n,n=>{Ku(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,R(e)})});if(!i)return;r||R(await Ku(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await Tt(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await U(`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:``}}),ae(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await cn(i,t.description,s,[],void 0,c);l&&sd(l)}async function V(t){try{let n=await _(e);if(!n){S(!1),T(null);return}let r=null;if(r=await od(n,e=>{r=e}),!r){S(!1),T(null);return}let i=await Tt(r),a=i.model,o=i.modelProvider;if(!a||!o)try{let t=(await U(`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){j(e,r),S(!1),T(null);return}let s=rd(nd(l.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),c=await cn(r,s,a,[],void 0,o);c&&D(await cd(c)),j(e,r)}catch(e){console.error(`Failed to generate test case:`,e),S(!1),T(null)}finally{k(!1)}}function H(e){T(e),D(``),k(!0),S(!0),V(e)}function ee(){S(!1),T(null),D(``)}async function te(){if(!w||!E.trim())return;let t=w,n=E;ee(),M(!0);try{let r=await _(e);if(!r)return;let i=null,o=await od(r,n=>{Ku(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,R(e)})});if(!o)return;i||R(await Ku(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await Tt(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await U(`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:``}}),ae(o,{model:c,modelProvider:l});let u=await cn(o,n,c,[],void 0,l);u&&sd(u)}finally{M(!1)}}async function ne(t){let n=await _(e);if(!n)return;let r=null,i=await od(n,n=>{Ku(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,R(e)})});if(!i)return;r||R(await Ku(e,t.id,{status:`Review`,working:!0,threadId:i}));let o=await Tt(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await U(`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:``}}),ae(i,{model:s,modelProvider:c});let u=await cn(i,rd(nd(l.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),s,[],void 0,c);u&&sd(u)}async function re(t,n){n===`Plan`?await z(t):n===`Build`?await B(t):n===`Test`?H(t):n===`Review`?await ne(t):R(await Ku(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:id.map(t=>{let i=u.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:K(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,ad[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:K(m.dropdownGroupHeading,`uppercase tracking-wide`),children:t}),(0,$.jsx)(`span`,{className:K(m.compact,`text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`),children:i.length})]}),(0,$.jsx)(Xe,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(J,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(Ze,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Yu,{todo:t,projectId:e,onUpdate:R,onEdit:N,onAction:re,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(C,{open:t,onOpenChange:n,children:(0,$.jsxs)(y,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(bi,{placeholder:`Describe what needs to be done...`,value:h,onChange:e=>g(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&F()}}),(0,$.jsx)(`p`,{className:K(m.caption,`mt-1.5`),children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(wt,{children:(0,$.jsx)(J,{onClick:()=>void F(),disabled:v||!h.trim(),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(C,{open:x,onOpenChange:e=>!e&&ee(),children:(0,$.jsxs)(y,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:O?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(hn,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:m.body,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bi,{value:E,onChange:e=>D(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0}),(0,$.jsx)(`p`,{className:K(m.caption,`mt-1.5`),children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(wt,{children:[(0,$.jsx)(J,{variant:`outline`,onClick:ee,disabled:O,children:`Cancel`}),(0,$.jsx)(J,{onClick:()=>void te(),disabled:O||!E.trim()||A,children:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(C,{open:f!==null,onOpenChange:e=>!e&&P(),children:(0,$.jsxs)(y,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(c,{children:(0,$.jsx)(Ct,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(bi,{placeholder:`Describe what needs to be done...`,value:h,onChange:e=>g(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&I()}})}),(0,$.jsxs)(wt,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(J,{variant:`destructive`,onClick:()=>void L(),disabled:v,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(J,{onClick:()=>void I(),disabled:v||!h.trim(),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}function fd(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=ud(r,n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;t[7]===r?o=t[8]:(o=()=>ld(r),t[7]=r,t[8]=o);let s=Cr(a,o),c;return t[9]!==s||t[10]!==r||t[11]!==i?(c=(0,$.jsx)(dd,{projectId:r,initialTodos:s,...i}),t[9]=s,t[10]=r,t[11]=i,t[12]=c):c=t[12],c}function pd(e){let t=(0,X.c)(11),[n,r]=(0,Y.useState)(0),i;t[0]!==n||t[1]!==e.projectId?(i=function(){Or(ud(e.projectId,n)),r(md)},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)(Er,{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)(fd,{...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)(Dr,{fallbackTitle:`Failed to load tasks`,onRetry:a,children:c}),t[8]=a,t[9]=c,t[10]=l):l=t[10],l}function md(e){return e+1}var hd=Pn,gd=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=K(`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)(jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});gd.displayName=jn.displayName;var _d=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=K(`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)(Ln,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});_d.displayName=Ln.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=K(`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)(Vn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vd.displayName=Vn.displayName;var yd=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Xu},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:$u},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Qu}];function bd({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 l(){s(!0);try{await h(n,{planPrompt:i.plan.trim()===Xu?null:i.plan.trim()||null,testPrompt:i.test.trim()===Qu?null:i.test.trim()||null,reviewPrompt:i.review.trim()===$u?null:i.review.trim()||null}),L(),Pi({title:`AI prompt settings saved`}),t(!1)}catch(e){Pi({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function u(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(C,{open:e,onOpenChange:t,children:(0,$.jsxs)(y,{className:`max-w-2xl`,children:[(0,$.jsxs)(c,{children:[(0,$.jsx)(Ct,{children:`AI Prompt Settings`}),(0,$.jsx)(oe,{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)(hd,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(gd,{className:`w-full`,children:yd.map(e=>(0,$.jsx)(_d,{value:e.value,className:`flex-1`,children:e.label},e.value))}),yd.map(e=>(0,$.jsxs)(vd,{value:e.value,children:[(0,$.jsx)(bi,{value:i[e.value]||e.defaultPrompt,onChange:t=>u(e.value,t.target.value),className:`min-h-[250px] font-mono resize-none`,placeholder:e.defaultPrompt,disabled:o}),(0,$.jsxs)(`p`,{className:K(m.bodyMuted,`mt-1.5`),children:[`Use `,(0,$.jsx)(`code`,{className:m.mono,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(wt,{children:(0,$.jsx)(J,{onClick:()=>void l(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function xd({projectId:e}){let t=_i(),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=Qn(),{setActiveMainTab:u}=va();async function d(a){if(n.find(t=>t.projectId===e)){l(`/`),u(`chat`);try{let{getProjects:n,invalidateProjectsCache:o}=await fr(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-I0_cSU2z.js`).then(e=>e.f);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 gt();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 gt();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)(pd,{projectId:e,addOpen:a,onAddOpenChange:o,onThreadSelect:d})}),(0,$.jsx)(J,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>c(!0),children:(0,$.jsx)(pe,{className:`h-4 w-4`})}),(0,$.jsx)(bd,{open:s,onOpenChange:c,projectId:e})]})}var Sd=4,Cd=`(max-width: 767px)`;function wd(e,t){let n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().top,i=t.querySelector(`[data-chat-toolbar]`);return i&&i.getBoundingClientRect().height>0&&(r=Math.min(r,i.getBoundingClientRect().top)),Math.max(0,Math.ceil(n-r))+(window.matchMedia(Cd).matches?Sd:0)}function Td(e,t,n){let r=(0,X.c)(5),[i,a]=(0,Y.useState)(0),o,s;return r[0]!==t||r[1]!==e||r[2]!==n?(o=()=>{if(!n){a(0);return}let r=e.current,i=t.current;if(!r||!i){a(0);return}let o=function(){let n=e.current,r=t.current;!n||!r||a(wd(n,r))};o();let s=new ResizeObserver(o);s.observe(r),s.observe(i);let c=i.querySelector(`[data-chat-toolbar]`);c&&s.observe(c);let l=new MutationObserver(o);l.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`]}),window.addEventListener(`resize`,o);let u=window.visualViewport;return u?.addEventListener(`resize`,o),u?.addEventListener(`scroll`,o),()=>{s.disconnect(),l.disconnect(),window.removeEventListener(`resize`,o),u?.removeEventListener(`resize`,o),u?.removeEventListener(`scroll`,o)}},s=[e,t,n],r[0]=t,r[1]=e,r[2]=n,r[3]=o,r[4]=s):(o=r[3],s=r[4]),(0,Y.useEffect)(o,s),i}var Ed;(function(e){e.Unimplemented=`UNIMPLEMENTED`,e.Unavailable=`UNAVAILABLE`})(Ed||={});var Dd=class extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}},Od=e=>e?.androidBridge?`android`:e?.webkit?.messageHandlers?.bridge?`ios`:`web`,kd=e=>{let t=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},i=()=>t===null?Od(e):t.name,a=()=>i()!==`web`,o=e=>!!(l.get(e)?.platforms.has(i())||s(e)),s=e=>n.PluginHeaders?.find(t=>t.name===e),c=t=>e.console.error(t),l=new Map;return n.convertFileSrc||=e=>e,n.getPlatform=i,n.handleError=c,n.isNativePlatform=a,n.isPluginAvailable=o,n.registerPlugin=(e,a={})=>{let o=l.get(e);if(o)return console.warn(`Capacitor plugin "${e}" already registered. Cannot register plugins twice.`),o.proxy;let c=i(),u=s(e),d,f=async()=>(!d&&c in a?d=d=typeof a[c]==`function`?await a[c]():a[c]:t!==null&&!d&&`web`in a&&(d=d=typeof a.web==`function`?await a.web():a.web),d),p=(t,r)=>{if(u){let i=u?.methods.find(e=>r===e.name);if(i)return i.rtype===`promise`?t=>n.nativePromise(e,r.toString(),t):(t,i)=>n.nativeCallback(e,r.toString(),t,i);if(t)return t[r]?.bind(t)}else if(t)return t[r]?.bind(t);else throw new Dd(`"${e}" plugin is not implemented on ${c}`,Ed.Unimplemented)},m=t=>{let n,r=(...r)=>{let i=f().then(i=>{let a=p(i,t);if(a){let e=a(...r);return n=e?.remove,e}else throw new Dd(`"${e}.${t}()" is not implemented on ${c}`,Ed.Unimplemented)});return t===`addListener`&&(i.remove=async()=>n()),i};return r.toString=()=>`${t.toString()}() { [capacitor code] }`,Object.defineProperty(r,"name",{value:t,writable:!1,configurable:!1}),r},h=m(`addListener`),g=m(`removeListener`),_=(e,t)=>{let n=h({eventName:e},t),r=async()=>{g({eventName:e,callbackId:await n},t)},i=new Promise(e=>n.then(()=>e({remove:r})));return i.remove=async()=>{console.warn(`Using addListener() without 'await' is deprecated.`),await r()},i},v=new Proxy({},{get(e,t){switch(t){case`$$typeof`:return;case`toJSON`:return()=>({});case`addListener`:return u?_:h;case`removeListener`:return g;default:return m(t)}}});return r[e]=v,l.set(e,{name:e,proxy:v,platforms:new Set([...Object.keys(a),...u?[c]:[]])}),v},n.Exception=Dd,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Ad=(e=>e.Capacitor=kd(e))(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}),jd=Ad.registerPlugin,Md=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let n=!1;this.listeners[e]||(this.listeners[e]=[],n=!0),this.listeners[e].push(t);let r=this.windowListeners[e];return r&&!r.registered&&this.addWindowListener(r),n&&this.sendRetainedArgumentsForEvent(e),Promise.resolve({remove:async()=>this.removeListener(e,t)})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,n){let r=this.listeners[e];if(!r){if(n){let n=this.retainedEventArguments[e];n||=[],n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(e=>e(t))}hasListeners(e){return!!this.listeners[e]?.length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:e=>{this.notifyListeners(t,e)}}}unimplemented(e=`not implemented`){return new Ad.Exception(e,Ed.Unimplemented)}unavailable(e=`not available`){return new Ad.Exception(e,Ed.Unavailable)}async removeListener(e,t){let n=this.listeners[e];if(!n)return;let r=n.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){let t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(t=>{this.notifyListeners(e,t)}))}},Nd=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Pd=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),Fd=class extends Md{async getCookies(){let e=document.cookie,t={};return e.split(`;`).forEach(e=>{if(e.length<=0)return;let[n,r]=e.replace(/=/,`CAP_COOKIE`).split(`CAP_COOKIE`);n=Pd(n).trim(),r=Pd(r).trim(),t[n]=r}),t}async setCookie(e){try{let t=Nd(e.key),n=Nd(e.value),r=e.expires?`; expires=${e.expires.replace(`expires=`,``)}`:``,i=(e.path||`/`).replace(`path=`,``),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:``;document.cookie=`${t}=${n||``}${r}; path=${i}; ${a};`}catch(e){return Promise.reject(e)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(e){return Promise.reject(e)}}async clearCookies(){try{let e=document.cookie.split(`;`)||[];for(let t of e)document.cookie=t.replace(/^ +/,``).replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}};jd(`CapacitorCookies`,{web:()=>new Fd});var Id=async e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e.indexOf(`,`)>=0?e.split(`,`)[1]:e)},r.onerror=e=>n(e),r.readAsDataURL(e)}),Ld=(e={})=>{let t=Object.keys(e);return Object.keys(e).map(e=>e.toLocaleLowerCase()).reduce((n,r,i)=>(n[r]=e[t[i]],n),{})},Rd=(e,t=!0)=>e?Object.entries(e).reduce((e,n)=>{let[r,i]=n,a,o;return Array.isArray(i)?(o=``,i.forEach(e=>{a=t?encodeURIComponent(e):e,o+=`${r}=${a}&`}),o.slice(0,-1)):(a=t?encodeURIComponent(i):i,o=`${r}=${a}`),`${e}&${o}`},``).substr(1):null,zd=(e,t={})=>{let n=Object.assign({method:e.method||`GET`,headers:e.headers},t),r=Ld(e.headers)[`content-type`]||``;if(typeof e.data==`string`)n.body=e.data;else if(r.includes(`application/x-www-form-urlencoded`)){let t=new URLSearchParams;for(let[n,r]of Object.entries(e.data||{}))t.set(n,r);n.body=t.toString()}else if(r.includes(`multipart/form-data`)||e.data instanceof FormData){let t=new FormData;if(e.data instanceof FormData)e.data.forEach((e,n)=>{t.append(n,e)});else for(let n of Object.keys(e.data))t.append(n,e.data[n]);n.body=t;let r=new Headers(n.headers);r.delete(`content-type`),n.headers=r}else (r.includes(`application/json`)||typeof e.data==`object`)&&(n.body=JSON.stringify(e.data));return n},Bd=class extends Md{async request(e){let t=zd(e,e.webFetchExtra),n=Rd(e.params,e.shouldEncodeUrlParams),r=n?`${e.url}?${n}`:e.url,i=await fetch(r,t),a=i.headers.get(`content-type`)||``,{responseType:o=`text`}=i.ok?e:{};a.includes(`application/json`)&&(o=`json`);let s,c;switch(o){case`arraybuffer`:case`blob`:c=await i.blob(),s=await Id(c);break;case`json`:s=await i.json();break;default:s=await i.text()}let l={};return i.headers.forEach((e,t)=>{l[t]=e}),{data:s,headers:l,status:i.status,url:i.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:`GET`}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:`POST`}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:`PUT`}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:`PATCH`}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:`DELETE`}))}};jd(`CapacitorHttp`,{web:()=>new Bd});var Vd;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(Vd||={});var Hd;(function(e){e.StatusBar=`StatusBar`,e.NavigationBar=`NavigationBar`})(Hd||={});var Ud=class extends Md{async setStyle(){this.unavailable(`not available for web`)}async setAnimation(){this.unavailable(`not available for web`)}async show(){this.unavailable(`not available for web`)}async hide(){this.unavailable(`not available for web`)}};jd(`SystemBars`,{web:()=>new Ud});var Wd;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(Wd||={});var Gd;(function(e){e.Body=`body`,e.Ionic=`ionic`,e.Native=`native`,e.None=`none`})(Gd||={});var Kd=jd(`Keyboard`);function qd(e){let t=window.visualViewport;if(!e||!t)return 0;let n=t.height+t.offsetTop,r=e.getBoundingClientRect().bottom;return Math.max(0,Math.round(r-n))}function Jd(e,t){return ke()?t:e>0?e:t}function Yd(e){let t=(0,X.c)(6),[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),o,s;t[0]===e?(o=t[1],s=t[2]):(o=()=>{let t=function(){r(qd(e.current))},n=function(){t(),requestAnimationFrame(t)};n();let i=window.visualViewport;i?.addEventListener(`resize`,n),i?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n);let o=[];return Ne()&&o.push(Kd.addListener(`keyboardWillShow`,e=>{a(e.keyboardHeight)}),Kd.addListener(`keyboardDidShow`,e=>{a(e.keyboardHeight)}),Kd.addListener(`keyboardWillHide`,()=>{a(0)}),Kd.addListener(`keyboardDidHide`,()=>{a(0)})),()=>{i?.removeEventListener(`resize`,n),i?.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n);for(let e of o)e.then(Xd)}},s=[e],t[0]=e,t[1]=o,t[2]=s),(0,Y.useEffect)(o,s);let c;return t[3]!==n||t[4]!==i?(c=Jd(n,i),t[3]=n,t[4]=i,t[5]=c):c=t[5],c}function Xd(e){e.remove()}var Zd=(0,Y.lazy)(()=>fr(()=>import(`./diff-view-B8vWYa_2.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),Qd=(0,Y.lazy)(()=>fr(()=>import(`./dialogs-config-I0_cSU2z.js`).then(e=>e.t),__vite__mapDeps([5,1])));function $d(e){let t=(0,X.c)(61),{onCreateThread:n}=e,r=_i(),i=Qn(),a=sr(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=Q(mf),d=Q(pf),f=Q(ff),p=Q(df),m=Q(uf),h=Q(lf),g=Q(cf),_=Q(sf),v=Q(of),y=Q(af),b=Q(rf),x=Q(nf),S=Q(tf),C;t[0]!==p||t[1]!==u?(C=u&&p.includes(u),t[0]=p,t[1]=u,t[2]=C):C=t[2];let w=!!C,T=b?.threadId===u,E;t[3]===r?E=t[4]:(E=()=>{r({type:Z.CloseSidebar})},t[3]=r,t[4]=E);let D=E,O;t[5]===D?O=t[6]:(O=()=>{D(),l(`clone`),s(!0)},t[5]=D,t[6]=O);let k=O,A;t[7]===D?A=t[8]:(A=()=>{D(),l(`webapp`),s(!0)},t[7]=D,t[8]=A);let j=A,M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=async(e,t)=>{try{await mn(e,t),s(!1),l(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[9]=M):M=t[9];let N=M,P;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(P=async(e,t,n)=>{try{await xe(e,t,n),s(!1),l(null)}catch(e){console.error(`Failed to create project:`,e)}},t[10]=P):P=t[10];let F=P,I;t[11]===D?I=t[12]:(I=async()=>{D();try{await Le(),s(!1),l(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[11]=D,t[12]=I);let L=I,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=async e=>{try{await vn(e),s(!1),l(null)}catch(e){console.error(`Failed to create folder:`,e)}},t[13]=R):R=t[13];let z=R,B=a.pathname===`/review`,V=a.pathname===`/todos`,H;t[14]===i?H=t[15]:(H=()=>{i(`/`)},t[14]=i,t[15]=H);let ee=H;Vu();let te;t[16]===x?te=t[17]:(te=zs(x),t[16]=x,t[17]=te);let ne=te,U;t[18]===x?U=t[19]:(U=Bs(x),t[18]=x,t[19]=U);let re=U,ie=(0,Y.useRef)(null),ae=(0,Y.useRef)(null),oe=(0,Y.useRef)(null),se=Bu(),[ce,le]=(0,Y.useState)(!0),ue=!B&&!V&&!!u,de=se&&ue&&!ce,fe=Td(ie,ae,ue),pe=Yd(ae),me;t[20]!==fe||t[21]!==D||t[22]!==r||t[23]!==k||t[24]!==ee||t[25]!==j||t[26]!==L||t[27]!==T||t[28]!==f||t[29]!==w||t[30]!==_||t[31]!==d||t[32]!==g||t[33]!==n||t[34]!==m||t[35]!==h||t[36]!==B||t[37]!==S||t[38]!==u||t[39]!==y||t[40]!==v||t[41]!==V?(me=V&&S?(0,$.jsx)(xd,{projectId:S}):B&&u?(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Er,{}),children:(0,$.jsx)(Zd,{threadId:u,onExit:ee})}):(0,$.jsx)(Ls,{ref:oe,bottomInset:fe,messages:d,isStreaming:_,streamingSegments:v,streamingModel:y,isCreatingProject:f,isProcessingThread:w,hasPendingMessage:T,selectedThreadId:u,selectedProjectId:S,projects:m,projectsLoading:h,messagesLoaded:g,onSelectThread:(e,t)=>{D(),r({type:Z.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:k,onNewApp:j,onOpenFolder:L,error:null,onClearError:ef,onAtBottomChange:le}),t[20]=fe,t[21]=D,t[22]=r,t[23]=k,t[24]=ee,t[25]=j,t[26]=L,t[27]=T,t[28]=f,t[29]=w,t[30]=_,t[31]=d,t[32]=g,t[33]=n,t[34]=m,t[35]=h,t[36]=B,t[37]=S,t[38]=u,t[39]=y,t[40]=v,t[41]=V,t[42]=me):me=t[42];let he;t[43]!==ne||t[44]!==re||t[45]!==pe||t[46]!==d||t[47]!==ue||t[48]!==de?(he=ue&&(0,$.jsxs)(`div`,{ref:ae,className:`absolute left-0 right-0 z-10 max-md:px-2`,style:{bottom:pe},children:[(0,$.jsx)(`div`,{className:`h-0 md:h-6`,style:{backgroundImage:re}}),(0,$.jsx)(`div`,{className:`h-0 md:h-8`,style:{backgroundImage:ne}}),de&&(0,$.jsx)(`div`,{className:`mb-1 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>oe.current?.scrollToBottom(),className:`flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background shadow-md transition-colors hover:bg-accent active:bg-accent`,"aria-label":`Scroll to bottom`,children:(0,$.jsx)(tn,{className:`h-4 w-4`})})}),(0,$.jsx)(`div`,{style:{backgroundImage:ne},children:(0,$.jsx)(Pu,{messages:d})})]}),t[43]=ne,t[44]=re,t[45]=pe,t[46]=d,t[47]=ue,t[48]=de,t[49]=he):he=t[49];let ge=c??void 0,_e;t[50]!==o||t[51]!==L||t[52]!==ge?(_e=(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Qd,{open:o,onOpenChange:s,initialMode:ge,onSubmitClone:N,onSubmitWebApp:F,onSubmitFolder:z,onOpenFolder:L})}),t[50]=o,t[51]=L,t[52]=ge,t[53]=_e):_e=t[53];let ve;t[54]!==me||t[55]!==he||t[56]!==_e?(ve=(0,$.jsxs)(`div`,{ref:ie,className:`relative flex h-full flex-col`,children:[me,he,_e]}),t[54]=me,t[55]=he,t[56]=_e,t[57]=ve):ve=t[57];let ye;return t[58]!==u||t[59]!==ve?(ye=(0,$.jsx)(So,{threadId:u,children:ve}),t[58]=u,t[59]=ve,t[60]=ye):ye=t[60],ye}function ef(){}function tf(e){return e.selectedProjectId}function nf(e){return e.sidebarOpen}function rf(e){return e.pendingChatMessage}function af(e){return e.streamingModel}function of(e){return e.streamingSegments}function sf(e){return e.isStreaming}function cf(e){return e.messagesLoaded}function lf(e){return e.projectsLoading}function uf(e){return e.projects}function df(e){return e.processingThreadIds}function ff(e){return e.isCreatingProject}function pf(e){return e.messages}function mf(e){return e.selectedThreadId}function hf(e){let t=(0,X.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=K(`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}function gf(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 _f(){let e=(0,X.c)(42),t=_i(),n=Q(xf),r=Q(bf),i=Q(yf),a=Q(vf),o;if(e[0]!==i||e[1]!==r){let t;e[3]===r?t=e[4]:(t=e=>e.projectId===r,e[3]=r,e[4]=t),o=i.find(t),e[0]=i,e[1]=r,e[2]=o}else o=e[2];let s=o,c=!a&&`max-md:pb-2 md:h-auto md:pb-3 md:h-[103px] md:pb-0`,l;e[5]===c?l=e[6]:(l=K(`pt-8 md:min-h-[103px]`,c),e[5]=c,e[6]=l);let u;e[7]===t?u=e[8]:(u=()=>t({type:Z.ToggleSidebar}),e[7]=t,e[8]=u);let d;e[9]===a?d=e[10]:(d=a?(0,$.jsx)(Mt,{className:`h-4 w-4`}):(0,$.jsx)(Ut,{className:`h-4 w-4`}),e[9]=a,e[10]=d);let f;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=f):f=e[11];let p;e[12]!==u||e[13]!==d?(p=(0,$.jsxs)(J,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,onClick:u,children:[d,f]}),e[12]=u,e[13]=d,e[14]=p):p=e[14];let h;e[15]!==i||e[16]!==r||e[17]!==n?(h=n&&(0,$.jsx)(`span`,{className:K(m.sectionTitle,`text-foreground truncate min-w-0`),children:lt(i,r)}),e[15]=i,e[16]=r,e[17]=n,e[18]=h):h=e[18];let g;e[19]!==p||e[20]!==h?(g=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[p,h]}),e[19]=p,e[20]=h,e[21]=g):g=e[21];let _;e[22]===n?_=e[23]:(_=n&&(0,$.jsx)(hu,{}),e[22]=n,e[23]=_);let v;e[24]!==s?.runCommand||e[25]!==r||e[26]!==n?(v=r&&(0,$.jsxs)(gf,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(cu,{projectId:r,runCommand:s?.runCommand}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xl,{threadId:n}),(0,$.jsx)($l,{})]})]}),e[24]=s?.runCommand,e[25]=r,e[26]=n,e[27]=v):v=e[27];let y;e[28]!==s?.openWith||e[29]!==r||e[30]!==n?(y=n&&r&&(0,$.jsx)(gf,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(su,{projectId:r,threadId:n,openWith:s?.openWith})}),e[28]=s?.openWith,e[29]=r,e[30]=n,e[31]=y):y=e[31];let b;e[32]!==v||e[33]!==y?(b=(0,$.jsxs)(`div`,{className:`hidden md:flex flex-wrap items-center justify-end gap-2`,children:[v,y]}),e[32]=v,e[33]=y,e[34]=b):b=e[34];let x;e[35]!==b||e[36]!==_?(x=(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[_,b]}),e[35]=b,e[36]=_,e[37]=x):x=e[37];let S;return e[38]!==x||e[39]!==l||e[40]!==g?(S=(0,$.jsxs)(hf,{className:l,children:[g,x]}),e[38]=x,e[39]=l,e[40]=g,e[41]=S):S=e[41],S}function vf(e){return e.sidebarOpen}function yf(e){return e.projects}function bf(e){return e.selectedProjectId}function xf(e){return e.selectedThreadId}function Sf(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)(vr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=K(m.body,`font-semibold text-foreground`),t[1]=s):s=t[1];let c;t[2]===r?c=t[3]:(c=(0,$.jsxs)(Sr,{children:[o,(0,$.jsxs)(yr,{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)(_r,{children:`Cancel`}),t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=(0,$.jsxs)(br,{children:[l,(0,$.jsx)(Tr,{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)(wr,{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)(xr,{open:n,onOpenChange:i,children:d}),t[10]=i,t[11]=n,t[12]=d,t[13]=f):f=t[13],f}function Cf(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)(vr,{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)(Sr,{children:[o,(0,$.jsxs)(yr,{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(wf),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)(_r,{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)(Tr,{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)(br,{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)(wr,{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)(xr,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function wf(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:m.label,children:r||`root`}),(0,$.jsx)(`div`,{className:m.bodyMuted,children:i})]})]})},t)}function Tf(){let[e,t]=(0,Y.useState)(!0),[n,r]=(0,Y.useState)(je),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=!0;return(async()=>{try{let n=await fetch(`${le()}/health`,{method:`GET`});e&&t(n.ok)}catch{e&&t(!1)}})(),()=>{e=!1}},[]);let c=(0,Y.useCallback)(async()=>{let e=Tn(n);if(e){a(null),s(!0);try{if(!await D(e)){a(e);return}d(n)}finally{s(!1)}}},[n]);return e?null:(0,$.jsx)(xr,{open:!0,children:(0,$.jsxs)(wr,{children:[(0,$.jsxs)(Sr,{children:[(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`mx-auto h-16 w-16 rounded-lg`}),(0,$.jsx)(vr,{children:`Connect to Tarsk`}),(0,$.jsx)(yr,{children:`Connect to the Tarsk server running on your local network by entering the IP Address or domain name below.`})]}),(0,$.jsx)(Te,{value:n,onChange:e=>{r(e.target.value),a(null)},onKeyDown:e=>{e.key===`Enter`&&!o&&c()},placeholder:`192.168.1.100`,autoComplete:`off`,spellCheck:!1,disabled:o}),i&&(0,$.jsxs)(Ar,{variant:`error`,className:`mb-0 flex items-start gap-3`,children:[(0,$.jsxs)(`p`,{className:`flex-1`,children:[`Unable to connect to `,i,`. Please check that you are on the same network and that the Tarsk server is running and accessible on the network.`]}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,"aria-label":`Dismiss error`,onClick:()=>a(null),children:(0,$.jsx)(T,{className:`h-4 w-4`})})]}),(0,$.jsx)(br,{children:(0,$.jsx)(J,{onClick:()=>void c(),disabled:!n.trim()||o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{className:`mr-2 h-4 w-4 animate-spin`}),`Connecting...`]}):`Connect`})}),(0,$.jsxs)(Ar,{variant:`hint`,className:`mb-0`,children:[(0,$.jsx)(`p`,{className:m.bodyMuted,children:`Start the Tarsk server on your local machine by running:`}),(0,$.jsx)(`code`,{className:K(m.mono,`mt-2 block rounded bg-background/60 px-2 py-1 text-foreground`),children:`npx tarsk --server`})]})]})})}var Ef=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=K(`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)(Rn,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},Df=tr,Of=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=K(`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)(xt,{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)(zn,{className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s},kf=kn,Af=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=K(`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)(Dn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Af.displayName=Dn.displayName;var jf=Wt(`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`}}),Mf=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=K(jf({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)(Bn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Mf.displayName=Bn.displayName;var Nf=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=K(`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`,m.body,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(ur,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Nf.displayName=ur.displayName;var Pf=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=K(`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)(T,{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)(Wn,{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});Pf.displayName=Wn.displayName;var Ff=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=K(m.dialogTitle,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});Ff.displayName=nr.displayName;var If=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=K(m.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)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});If.displayName=An.displayName;function Lf(){let e=(0,X.c)(5),{toasts:t}=Fi(),n;e[0]===t?n=e[1]:(n=t.map(Rf),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Af,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(kf,{children:[n,r]}),e[3]=n,e[4]=i),i}function Rf(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(Mf,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(Ff,{children:n}),r&&(0,$.jsx)(If,{children:r})]}),i,(0,$.jsx)(Pf,{})]},t)}function zf(){let e=(0,X.c)(4),{resolvedTheme:t,theme:n}=Lr(),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 Bf(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)(zf,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Rr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Vf(){let e=(0,X.c)(14),t=_i(),n=Q(Wf),r=Cr(`projects:bootstrap:${Q(Uf)}`,be),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(Hf);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 Hf(e){return e.isSelected}function Uf(e){return e.configUpdatedAt}function Wf(e){return e.selectedThreadId}function Gf(e){let t=_i(),n=Q(e=>e.projects),r=Q(e=>e.selectedProjectId),i=Q(e=>e.selectedThreadId),{toast:a}=Fi(),o=yi(`project-creation`).dispatch,[s,c]=(0,Y.useState)(null),l=(0,Y.useCallback)(async()=>{try{t({type:Z.SetProjectsLoading,projectsLoading:!0}),L(),kr(`projects:bootstrap:`);let e=await be();t({type:Z.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:Z.SetProjectsLoading,projectsLoading:!1})}},[t]),u=(0,Y.useCallback)((e,n)=>{(i!==n||r!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e}),Dt(e,n).catch(e=>{console.error(`Failed to select thread:`,e)})},[t,i,r]),d=(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 l();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,u=``,d=null,f=!1,p=null,m=null;for(;;){let{done:e,value:r}=await a.read();if(e)break;u+=s.decode(r,{stream:!0});let o=u.split(`
|
|
63
|
+
`);u=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){d=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&&c({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}),L();let h=await be();if(t({type:Z.SetProjects,projects:h.projects}),t({type:Z.SetProjectsLoading,projectsLoading:!1}),d){let n=h.projects.find(e=>e.projectId===d);if(n&&n.threads.length>0){let e=n.threads[0].threadId;t({type:Z.SelectThread,threadId:e,projectId:d,focusInput:!0})}e?.onProjectCreated?.(d)}}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,l,o,e?.onProjectCreated]),f=(0,Y.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await d({apiCall:()=>mn(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[d]),p=(0,Y.useCallback)(async(e,t,n)=>{await d({apiCall:()=>xe(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[d]),m=(0,Y.useCallback)(async e=>{await d({apiCall:()=>vn(e),initialMessage:`Creating folder "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create folder`,catchErrorPrefix:`Failed to create folder`})},[d]),h=(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 _(e,r);if(!o){await l();return}let s=o.getReader(),c=new TextDecoder,u=``,d=!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;u+=c.decode(r,{stream:!0});let o=u.split(`
|
|
64
|
+
`);u=o.pop()??``;for(let n of o){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`){if(!d&&n.threadId){d=!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`){d&&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)}}}d&&f&&t({type:Z.RemoveProcessingThread,threadId:f}),L(),await l(),f&&p&&t({type:Z.SelectThread,threadId:f,projectId:e,focusInput:!0})}catch(n){throw d&&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}},[l,t,n,a]),g=(0,Y.useCallback)(async(e,n)=>{t({type:Z.AddDeletingThread,threadId:n}),t({type:Z.ClearChatInputDraft,threadId:n});try{await j(e,n),i===n&&t({type:Z.SelectThread,threadId:``,projectId:``}),await l(),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})}},[l,i,t,a]),v=(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 te(e),r===e&&t({type:Z.SelectThread,threadId:``,projectId:``}),await l(),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})}},[l,r,n,t]),y=(0,Y.useCallback)(async e=>{let n=s;if(c(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 S(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 l()}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,l]);return{projects:n,selectedProjectId:r,selectedThreadId:i,refreshProjects:l,handleSelectThread:u,handleCreateProject:f,handleCreateWebApp:p,handleCreateFolder:m,handleOpenFolder:(0,Y.useCallback)(async()=>{await d({apiCall:Le,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[d]),handleCreateThread:h,handleDeleteThread:g,confirmDeleteProject:v,pendingSetupScriptConfirmation:s,resolveSetupScriptConfirmation:y}}function Kf(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(qf),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 qf(){return document.hasFocus()}var Jf=null;function Yf(){Jf??=new Audio(`/pop.wav`),Jf.currentTime=0,Jf.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Xf(){let e=_i(),t=gi(),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=Kf(),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=Tu(await gt()),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&&Yf(),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 Zf=(0,Y.lazy)(()=>fr(()=>import(`./terminal-panel-C5qj1ctH.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([12,1,5]))),Qf=(0,Y.lazy)(()=>fr(()=>import(`./diff-view-B8vWYa_2.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),$f=(0,Y.lazy)(()=>fr(()=>import(`./explorer-tab-view-BGWQPnkw.js`),__vite__mapDeps([13,1,3,4,7,5]))),ep=(0,Y.lazy)(()=>fr(()=>import(`./browser-tab-B3bYbBws.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([14,1,5]))),tp=(0,Y.lazy)(()=>fr(()=>import(`./dialogs-config-I0_cSU2z.js`).then(e=>e.t),__vite__mapDeps([5,1]))),np=(0,Y.lazy)(()=>fr(()=>import(`./onboarding-CgP4bJ5F.js`).then(e=>e.t),__vite__mapDeps([8,1,7,5]))),rp=(0,Y.lazy)(()=>fr(()=>import(`./settings-view-DLzrbu69.js`),__vite__mapDeps([15,1,3,4,7,5,8,16,17,10])));function ip(e){return e.startsWith(`/settings`)||e===`/review`}function ap(){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 op(){let e=_i(),t=Q(e=>e.selectedThreadId),n=Q(e=>e.selectedProjectId),r=Q(e=>e.sidebarOpen),i=Q(e=>e.deletingThreadIds),a=Q(e=>e.deletingProjectIds);(0,Y.useEffect)(()=>{window.__electrobunWebviewId&&new qr({})},[]);let o=Qn(),s=sr(),c=Ys(),l=c||Ne(),[u,d]=(0,Y.useState)(null),{projects:f,handleSelectThread:p,handleCreateProject:m,handleCreateWebApp:h,handleCreateFolder:g,handleOpenFolder:_,handleCreateThread:v,handleDeleteThread:y,confirmDeleteProject:b,refreshProjects:x,pendingSetupScriptConfirmation:S,resolveSetupScriptConfirmation:C}=Gf({onProjectCreated:d}),{processingThreadIds:w,completedThreadIds:T,clearCompleted:E}=Xf(),[D,O]=(0,Y.useState)(`chat`),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(!1),[L,R]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(0),[V,H]=(0,Y.useState)(null),[ee,te]=(0,Y.useState)(0),{terminalState:ne}=yi(t),U=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{ne.open&&t===U.current&&!ip(s.pathname)&&O(`terminal`),U.current=t},[ne.open,t,s.pathname]);let[re,ie]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),he=(0,Y.useRef)(null),ge=(0,Y.useRef)(null),_e=s.pathname.startsWith(`/settings`),ve=s.pathname===`/review`;(0,Y.useEffect)(()=>{c&&(ge.current?.querySelector(`[data-tab="${D}"]`))?.scrollIntoView({inline:`nearest`,block:`nearest`})},[D,c]);let ye=(0,Y.useRef)(D),be=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(_e){if(be.current===null){be.current=Date.now(),ye.current=D;return}ye.current!==D&&o(`/`)}else be.current=null;ye.current=D},[D,_e,o]);let xe=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=_e||ve;if(t&&xe.current===null)xe.current=r,r&&e({type:Z.ToggleSidebar});else if(!t&&xe.current!==null){let t=xe.current;xe.current=null,t&&!r&&e({type:Z.ToggleSidebar})}},[_e,ve]),(0,Y.useEffect)(()=>{(async()=>{try{(await jt()).updateAvailable&&fe(!0)}catch{}})()},[]);let Se=(0,Y.useCallback)(async()=>{me(!0);try{await Ht()}catch{me(!1)}},[]);(0,Y.useEffect)(()=>{se||(async()=>{try{(await At()).onboardingCompleted||oe(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ce(!0)}})()},[se]),(0,Y.useEffect)(()=>{ae||e({type:Z.ConfigUpdated})},[ae,e]);let Ce=(0,Y.useCallback)(e=>{let t=f.find(t=>t.projectId===e);t&&ue({id:t.projectId,name:nt(t)})},[f]),we=(0,Y.useCallback)(e=>{d(e),v(e,void 0)},[v]);(0,Y.useEffect)(()=>{u&&n===u&&t&&d(null)},[u,n,t]);let Te=(0,Y.useCallback)(async(n,r)=>{d(null),E(r),s.pathname!==`/`&&o(`/`),O(`chat`),t!==r&&te(e=>e+1),p(n,r),l&&e({type:Z.CloseSidebar})},[p,l,t,e,E,s.pathname,o]);(0,Y.useEffect)(()=>{r?he.current?.expand():he.current?.collapse()},[r]);let Ee={activeMainTab:D,setActiveMainTab:O,devServerUrl:k,setDevServerUrl:A,devServerRunning:j,setDevServerRunning:M,devServerLoading:N,setDevServerLoading:P,terminalNotification:F,setTerminalNotification:I,pendingExplorerPath:L,setPendingExplorerPath:R,explorerRefreshTick:z,triggerExplorerRefresh:()=>B(e=>e+1),explorerClearPath:V,setExplorerClearPath:H,browserResetTrigger:ee,triggerBrowserReset:()=>te(e=>e+1)};return(0,$.jsxs)(_a.Provider,{value:Ee,children:[(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Vf,{})}),(0,$.jsxs)(qt,{delayDuration:200,children:[(0,$.jsxs)(Ef,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Df,{ref:he,defaultSize:l?100:25,minSize:l?50:12,maxSize:l?100:32,collapsible:!0,collapsedSize:0,className:K(`border-r border-transparent`,l&&!r&&`hidden`),children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(zi,{projects:f,selectedThreadId:t,selectedProjectId:n,processingThreadIds:w,completedThreadIds:T,deletingThreadIds:i,deletingProjectIds:a,onSelectThread:Te,onCreateProject:()=>ie(!0),onCreateThread:we,onDeleteThread:y,onDeleteProject:Ce,onDeselect:()=>e({type:Z.ClearSelection}),collapsed:!r,updateAvailable:de,updatingApp:pe,onUpdateApp:Se,expandProjectId:u})})}),!l&&(0,$.jsx)(Of,{withHandle:!0,className:r?`ml-[-40px]`:``}),(0,$.jsx)(Df,{minSize:40,className:K(`overflow-hidden`,l&&r&&`hidden`),children:(0,$.jsx)(yu,{threadId:t??void 0,children:(0,$.jsx)(Hl,{children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!ve&&!_e&&(0,$.jsx)(_f,{}),!ve&&!_e&&t&&(0,$.jsx)(`div`,{ref:ge,className:`flex shrink-0 select-none overflow-x-auto overflow-y-hidden border-b border-border`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{"data-tab":t,onClick:()=>{O(t),t===`terminal`&&I(!1)},className:`relative shrink-0 px-4 py-2 text-base font-medium transition-colors ${D===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&F&&D!==`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${!ve&&!_e&&D!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(ir,{children:[(0,$.jsx)(Zn,{path:`/settings/providers/:providerSlug`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(ap,{}),children:(0,$.jsx)(rp,{})})}),(0,$.jsx)(Zn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(ap,{}),children:(0,$.jsx)(rp,{})})}),(0,$.jsx)(Zn,{path:`/settings/:tab?`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(ap,{}),children:(0,$.jsx)(rp,{})})}),(0,$.jsx)(Zn,{path:`*`,element:(0,$.jsx)($d,{onCreateThread:we})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${D===`terminal`&&!ve&&!_e?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Zf,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${D===`browser`&&!ve&&!_e?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(ep,{})})}),!ve&&!_e&&D!==`chat`&&D!==`terminal`&&D!==`browser`&&(D===`explorer`?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)($f,{})}):D===`review`&&t?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Qf,{threadId:t,onExit:()=>O(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})})})}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(tp,{open:re,onOpenChange:ie,onSubmitClone:m,onSubmitWebApp:h,onSubmitFolder:g,onOpenFolder:_})}),(0,$.jsx)(Sf,{open:le!==null,projectName:le?.name,onOpenChange:e=>!e&&ue(null),onConfirm:()=>{le&&(b(le.id),ue(null))}}),(0,$.jsx)(Cf,{open:S!==null,setupScripts:S?[S.command,...S.remainingScripts||[]]:[],onConfirm:C}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(np,{open:ae,onOpenChange:oe,onComplete:()=>{ce(!0),x()}})}),(0,$.jsx)(Tf,{})]}),(0,$.jsx)(Lf,{})]})]})}function sp(){let e=(0,X.c)(3),[t]=(0,Y.useState)(mi),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(op,{}),e[0]=n):n=e[0];let r;return e[1]===t?r=e[2]:(r=(0,$.jsx)(Bf,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(hi.Provider,{value:t,children:n})}),e[1]=t,e[2]=r),r}var cp=75,lp=125,up=100;function dp(){return window.matchMedia(`(max-width: 767px)`).matches}function fp(e){let t=bn(e,dp());document.documentElement.style.fontSize=`${t}%`}var pp=!1;function mp(){pp||(pp=!0,window.matchMedia(`(max-width: 767px)`).addEventListener(`change`,()=>{fp(Fe(up))}))}function hp(){let[e,t]=(0,Y.useState)(()=>Fe(up));(0,Y.useEffect)(()=>{mp(),fp(e)},[e]);function n(e){let n=Math.max(cp,Math.min(lp,Math.round(e)));t(n),Ge(n)}return{scale:e,updateScale:n,resetScale:(0,Y.useCallback)(()=>{n(up)},[]),min:cp,max:lp,default:up}}function gp(){mp(),fp(Fe(up))}var _p;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(_p||={});var vp;(function(e){e.None=`NONE`,e.Slide=`SLIDE`,e.Fade=`FADE`})(vp||={});var yp=jd(`StatusBar`),bp=`--app-viewport-height`;function xp(){let e=window.visualViewport,t=Math.round(A()===`ios`?window.innerHeight:e?.height??window.innerHeight);document.documentElement.style.setProperty(bp,`${t}px`)}function Sp(){xp(),requestAnimationFrame(xp)}function Cp(){document.documentElement.dataset.nativeShell=`true`,Sp(),window.addEventListener(`resize`,xp),window.addEventListener(`orientationchange`,Sp);let e=window.visualViewport;e?.addEventListener(`resize`,xp),e?.addEventListener(`scroll`,xp)}async function wp(){try{await yp.hide(),Sp()}catch{}}async function Tp(){try{let e=A()===`ios`?Gd.None:Gd.Body;await Kd.setResizeMode({mode:e})}catch{}}function Ep(){Ne()&&(Cp(),wp(),Tp(),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&(Sp(),wp())}))}gp(),Ep();var Dp=!1;window.addEventListener(`resize`,()=>{Dp||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,zr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Y.StrictMode,{children:(0,$.jsx)(er,{children:(0,$.jsx)(sp,{})})}));export{_i as A,va as C,Ci as D,Pi as E,yi as M,bi as O,Ta as S,Ri as T,Jo as _,hf as a,co as b,gd as c,cu as d,wl as f,Wo as g,Uo as h,Ef as i,Q as j,Z as k,_d as l,Ro as m,Of as n,hd as o,Ys as p,Df as r,vd as s,hp as t,Pu as u,zo as v,oa as w,so as x,oo as y};
|