tarsk 0.4.31 → 0.5.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/index.js +767 -288
  2. package/dist/public/assets/{account-view-Cdp8xegU.js → account-view-DjLjq8T6.js} +1 -1
  3. package/dist/public/assets/alert-dialog-BWqb8ENe.js +1 -0
  4. package/dist/public/assets/api-BbUzw5rb.js +1 -0
  5. package/dist/public/assets/{browser-tab-Ban23pgA.js → browser-tab-BVsBMyo3.js} +1 -1
  6. package/dist/public/assets/chat-input-container-Dh5eJPNP.js +22 -0
  7. package/dist/public/assets/commit-dialog-CfjW1f6P.js +1 -0
  8. package/dist/public/assets/{context-menu-D93N09Jw.js → context-menu-D_gX85jr.js} +1 -1
  9. package/dist/public/assets/conversation-history-view-CKiv8CxD.js +1 -0
  10. package/dist/public/assets/create-repo-dialog-ByvOv7em.js +1 -0
  11. package/dist/public/assets/{dialogs-config-VlhyoYms.js → dialogs-config-CV8HzCCA.js} +3 -3
  12. package/dist/public/assets/diff-view-CuEdnFtI.js +3 -0
  13. package/dist/public/assets/{explorer-tab-view-Bbboiq-d.js → explorer-tab-view-CiDUcvE2.js} +2 -2
  14. package/dist/public/assets/explorer-tree-cxPx2HiW.js +1 -0
  15. package/dist/public/assets/{explorer-view-CMcJFEtT.js → explorer-view-BCQNEBOZ.js} +1 -1
  16. package/dist/public/assets/git-history-dialog-DKey5IQa.js +1 -0
  17. package/dist/public/assets/history-view-DDpROJvQ.js +1 -0
  18. package/dist/public/assets/index-BZwvl9X4.js +29 -0
  19. package/dist/public/assets/index-CihB-pLh.css +1 -0
  20. package/dist/public/assets/{markdown-renderer-BPXg5AUu.js → markdown-renderer-B1teF28W.js} +4 -4
  21. package/dist/public/assets/mcp-server-card-CY-VLPhS.js +1 -0
  22. package/dist/public/assets/merged-pr-dialog-BfwdsytN.js +1 -0
  23. package/dist/public/assets/onboarding-BEy4bi0g.js +1 -0
  24. package/dist/public/assets/onboarding-dialog-GjczsXqi.js +1 -0
  25. package/dist/public/assets/{page-toolbar-CU9dGLvm.js → page-toolbar-rWocuukR.js} +1 -1
  26. package/dist/public/assets/{project-settings-view-BAs5RYWR.js → project-settings-view-wlaXVds9.js} +1 -1
  27. package/dist/public/assets/providers-list-view-BJsp9sta.js +1 -0
  28. package/dist/public/assets/pull-request-dialog-DDxX2W8n.js +1 -0
  29. package/dist/public/assets/pull-with-changes-dialog-BtXHWQ3k.js +1 -0
  30. package/dist/public/assets/push-before-pr-dialog-Cs54Vb76.js +1 -0
  31. package/dist/public/assets/{radio-group-CRwVSJCp.js → radio-group-D2kNbZM6.js} +1 -1
  32. package/dist/public/assets/react-vendor-DV_DP0Qd.js +22 -0
  33. package/dist/public/assets/resizable-jxPFsLog.js +1 -0
  34. package/dist/public/assets/run-stop-button-N1JNjOlD.js +2 -0
  35. package/dist/public/assets/settings-general-view-BKcgxF5z.js +1 -0
  36. package/dist/public/assets/{settings-instructions-view-DQRSZId7.js → settings-instructions-view-DbQ3c3f1.js} +1 -1
  37. package/dist/public/assets/settings-mcp-servers-view-D2_Brac1.js +5 -0
  38. package/dist/public/assets/{settings-models-skeleton-qdDMv5hS.js → settings-models-skeleton-BSV1GmZQ.js} +1 -1
  39. package/dist/public/assets/settings-models-view-BhFuBHAE.js +1 -0
  40. package/dist/public/assets/settings-rules-view-qL__Zcav.js +8 -0
  41. package/dist/public/assets/settings-skills-view-Ccj8tTR9.js +2 -0
  42. package/dist/public/assets/{settings-slash-commands-view-Cm5cy2My.js → settings-slash-commands-view-DyXAbQIp.js} +1 -1
  43. package/dist/public/assets/settings-subagents-view-LcaON0Dq.js +2 -0
  44. package/dist/public/assets/settings-view-cLrxaSw4.js +2 -0
  45. package/dist/public/assets/{side-panel-container-Cg99BH1l.js → side-panel-container-CCaF3ZtX.js} +2 -2
  46. package/dist/public/assets/{skeleton-B1fuNMHm.js → skeleton-DNfHG6mv.js} +1 -1
  47. package/dist/public/assets/standard-list-item-PWOXi212.js +1 -0
  48. package/dist/public/assets/store-9Wm6Zyve.js +4 -0
  49. package/dist/public/assets/{tab-context-BYpxvaoz.js → tab-context-BdML89mQ.js} +1 -1
  50. package/dist/public/assets/{tabs-ywSKq3qp.js → tabs-BVcV8raO.js} +1 -1
  51. package/dist/public/assets/{terminal-panel-C9XWZHaD.js → terminal-panel-BG8UFUSX.js} +2 -2
  52. package/dist/public/assets/{textarea-DuuNwegn.js → textarea-CU-XhvgE.js} +1 -1
  53. package/dist/public/assets/todos-view-DLC_0wx_.js +1 -0
  54. package/dist/public/assets/use-font-size-Bqn2rvp_.js +1 -0
  55. package/dist/public/assets/{use-toast-BF5WtiOJ.js → use-toast-CGSBJJb0.js} +1 -1
  56. package/dist/public/assets/{utils-CheqpoJ4.js → utils-Dt4Hs5eF.js} +1 -1
  57. package/dist/public/assets/{whisper-wasm-C_Ot631g.js → whisper-wasm-BCJQtWoU.js} +2 -2
  58. package/dist/public/busy.svg +3 -0
  59. package/dist/public/index.html +22 -22
  60. package/package.json +1 -1
  61. package/dist/public/assets/alert-dialog-DAJFcjdR.js +0 -1
  62. package/dist/public/assets/api-BYFUablr.js +0 -1
  63. package/dist/public/assets/chat-input-container-Bc7nCdKX.js +0 -21
  64. package/dist/public/assets/conversation-history-view-qm_qW0aD.js +0 -1
  65. package/dist/public/assets/diff-view-DUmzPmed.js +0 -3
  66. package/dist/public/assets/explorer-tree-CX03Vh31.js +0 -1
  67. package/dist/public/assets/history-view-Cub-F9g6.js +0 -1
  68. package/dist/public/assets/index-C-dv630o.css +0 -1
  69. package/dist/public/assets/index-DaJT5K7g.js +0 -29
  70. package/dist/public/assets/mcp-server-card-BCZmpcVY.js +0 -1
  71. package/dist/public/assets/onboarding-BPUo1aJX.js +0 -1
  72. package/dist/public/assets/onboarding-dialog-vqz8baom.js +0 -1
  73. package/dist/public/assets/providers-list-view-67A5O5vd.js +0 -1
  74. package/dist/public/assets/react-vendor-CtZx3FWA.js +0 -22
  75. package/dist/public/assets/resizable-AKojmHeo.js +0 -1
  76. package/dist/public/assets/run-stop-button-DYoC8i6e.js +0 -2
  77. package/dist/public/assets/settings-general-view-mu1Qq8cl.js +0 -1
  78. package/dist/public/assets/settings-mcp-servers-view-BqJMRVZJ.js +0 -5
  79. package/dist/public/assets/settings-models-view-DSrdZZfF.js +0 -1
  80. package/dist/public/assets/settings-rules-view-Dt_lfKVv.js +0 -8
  81. package/dist/public/assets/settings-skills-view-Djrk38ol.js +0 -2
  82. package/dist/public/assets/settings-subagents-view-CsGwbSvQ.js +0 -2
  83. package/dist/public/assets/settings-view-DuTfugUO.js +0 -2
  84. package/dist/public/assets/standard-list-item-0m99qNoa.js +0 -1
  85. package/dist/public/assets/store-DUqJt-K-.js +0 -4
  86. package/dist/public/assets/todos-view-CRzNrsfP.js +0 -1
  87. package/dist/public/assets/use-font-size-D2A0_bAi.js +0 -1
  88. /package/dist/public/assets/{dist-CAVGqbBm.js → dist-2eORHB3M.js} +0 -0
@@ -0,0 +1,29 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialogs-config-CV8HzCCA.js","assets/rolldown-runtime-B1FJdls4.js","assets/diff-view-CuEdnFtI.js","assets/monaco-BGyhgQtx.js","assets/monaco-Br_kD0ds.css","assets/chat-input-container-Dh5eJPNP.js","assets/history-view-DDpROJvQ.js","assets/onboarding-BEy4bi0g.js","assets/alert-dialog-BWqb8ENe.js","assets/react-vendor-DV_DP0Qd.js","assets/use-toast-CGSBJJb0.js","assets/store-9Wm6Zyve.js","assets/tab-context-BdML89mQ.js","assets/whisper-wasm-BCJQtWoU.js","assets/utils-Dt4Hs5eF.js","assets/page-toolbar-rWocuukR.js","assets/context-menu-D_gX85jr.js","assets/resizable-jxPFsLog.js","assets/standard-list-item-PWOXi212.js","assets/textarea-CU-XhvgE.js","assets/terminal-panel-BG8UFUSX.js","assets/explorer-tab-view-CiDUcvE2.js","assets/browser-tab-BVsBMyo3.js","assets/run-stop-button-N1JNjOlD.js","assets/onboarding-dialog-GjczsXqi.js","assets/settings-view-cLrxaSw4.js","assets/settings-models-skeleton-BSV1GmZQ.js","assets/skeleton-DNfHG6mv.js","assets/side-panel-container-CCaF3ZtX.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$n as n,Bn as r,Br as i,Ci as a,Cn as o,Dn as s,E as c,Ea as l,Et as u,Fn as d,Fr as f,Ft as p,Gr as m,H as h,Hn as g,Hr as _,Ht as v,It as y,J as b,Ji as x,Kn as S,Ln as C,Lr as w,Mn as T,Mt as E,N as D,Ni as O,Nr as k,O as A,Oa as j,On as M,P as N,Pn as P,Qn as F,R as I,Rr as L,Sa as R,Si as z,Sn as ee,St as te,Tt as B,Un as V,V as ne,Vn as re,W as ie,Wn as H,X as U,Xi as W,Yi as ae,Yn as oe,Zn as se,_ as ce,_a as G,_n as le,an as ue,ca as de,cn as fe,da as pe,ei as me,er as he,fa as ge,gi as _e,gn as ve,ha as ye,hn as be,ht as xe,ji as Se,k as Ce,la as we,li as Te,ln as Ee,ma as De,mi as Oe,na as ke,nr as Ae,oa as je,on as Me,pn as Ne,qi as Pe,qr as Fe,ra as Ie,rr as Le,ti as Re,tr as ze,ui as Be,un as Ve,va as He,vi as Ue,w as We,wi as Ge,xi as Ke,y as qe,yi as Je,zn as Ye,zr as Xe}from"./dialogs-config-CV8HzCCA.js";import{A as Ze,Ct as Qe,M as $e,N as et,O as tt,P as nt,St as rt,Tt as it,bt as at,j as ot,k as st,lt as ct,xt as lt,yt as ut}from"./react-vendor-DV_DP0Qd.js";import{Pt as dt}from"./monaco-BGyhgQtx.js";import{a as ft,c as pt,f as mt,h as ht,i as gt,m as _t,n as vt,o as yt,p as bt,r as xt,t as K}from"./store-9Wm6Zyve.js";import{t as St}from"./textarea-CU-XhvgE.js";import{c as q,l as Ct,s as J,u as Y}from"./history-view-DDpROJvQ.js";import{_ as wt,a as Tt,c as Et,d as Dt,f as Ot,g as kt,h as At,i as jt,l as Mt,m as Nt,n as Pt,o as Ft,p as It,r as Lt,s as Rt,t as zt,u as Bt,v as Vt,y as Ht}from"./chat-input-container-Dh5eJPNP.js";import{n as Ut,t as X}from"./use-toast-CGSBJJb0.js";import{t as Wt}from"./standard-list-item-PWOXi212.js";import{a as Gt,c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./alert-dialog-BWqb8ENe.js";import{t as $t}from"./side-panel-container-CCaF3ZtX.js";import{t as en}from"./markdown-renderer-B1teF28W.js";import{n as tn,t as nn}from"./tab-context-BdML89mQ.js";import{s as rn}from"./onboarding-BEy4bi0g.js";import{n as an,t as on}from"./run-stop-button-N1JNjOlD.js";import{n as sn,t as cn}from"./utils-Dt4Hs5eF.js";import{i as ln,n as un,r as dn,t as fn}from"./tabs-BVcV8raO.js";import{t as pn}from"./page-toolbar-rWocuukR.js";import{n as mn,r as hn,t as gn}from"./resizable-jxPFsLog.js";import{t as _n}from"./use-font-size-Bqn2rvp_.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 Z=e(j(),1),vn=it(),Q=l(),yn=1e10,bn=1e3;function xn(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 Sn(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=bn}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=yn?++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 xn([`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 xn([`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 xn([`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 xn([`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 Cn(e,t){let n=Sn({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 wn=window.__electrobunWebviewId,Tn=window.__electrobunRpcSocketPort,En=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:${Tn}/socket?webviewId=${wn}`);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 Cn(`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 Dn(e){let t=(0,Q.c)(47),{open:r,onOpenChange:i,feedbackName:a,onFeedbackNameChange:o,feedbackEmail:s,onFeedbackEmailChange:c,feedbackText:l,onFeedbackTextChange:u,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Le,{children:`Send Feedback`}),(0,$.jsx)(he,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(oe,{htmlFor:`feedback-name`,children:`Name`}),t[1]=h):h=t[1];let g;t[2]===o?g=t[3]:(g=e=>o(e.target.value),t[2]=o,t[3]=g);let _=f||d,v;t[4]!==a||t[5]!==g||t[6]!==_?(v=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(se,{id:`feedback-name`,value:a,onChange:g,placeholder:`Your name`,disabled:_})]}),t[4]=a,t[5]=g,t[6]=_,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(oe,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===c?b=t[10]:(b=e=>c(e.target.value),t[9]=c,t[10]=b);let x=f||d,S;t[11]!==s||t[12]!==b||t[13]!==x?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(se,{id:`feedback-email`,type:`email`,value:s,onChange:b,placeholder:`you@example.com`,disabled:x})]}),t[11]=s,t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(oe,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let w;t[16]===u?w=t[17]:(w=e=>u(e.target.value),t[16]=u,t[17]=w);let T;t[18]!==l||t[19]!==f||t[20]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(St,{id:`feedback-text`,value:l,onChange:w,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=l,t[19]=f,t[20]=w,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==v||t[24]!==S?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,T]}),t[22]=T,t[23]=v,t[24]=S,t[25]=E):E=t[25];let D;t[26]===i?D=t[27]:(D=()=>i(!1),t[26]=i,t[27]=D);let A;t[28]!==f||t[29]!==D?(A=(0,$.jsx)(k,{variant:`outline`,onClick:D,disabled:f,children:`Cancel`}),t[28]=f,t[29]=D,t[30]=A):A=t[30];let j;t[31]===f?j=t[32]:(j=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=f,t[32]=j);let M;t[33]!==p||t[34]!==f||t[35]!==j?(M=(0,$.jsx)(k,{onClick:p,disabled:f,children:j}),t[33]=p,t[34]=f,t[35]=j,t[36]=M):M=t[36];let N;t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(ze,{children:[A,M]}),t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==E||t[41]!==N?(P=(0,$.jsxs)(n,{className:`max-w-xl`,children:[m,E,N]}),t[40]=E,t[41]=N,t[42]=P):P=t[42];let I;return t[43]!==i||t[44]!==r||t[45]!==P?(I=(0,$.jsx)(F,{open:r,onOpenChange:i,children:P}),t[43]=i,t[44]=r,t[45]=P,t[46]=I):I=t[46],I}function On(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),te().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({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){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await H(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function kn(e){let t=(0,Q.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:m,collapsed:h,updateAvailable:g,updatingApp:_,onUpdateApp:v,expandProjectId:y}=e,b=Qe(),{showFeedback:x,feedbackName:C,setFeedbackName:T,feedbackEmail:E,setFeedbackEmail:D,feedbackText:A,setFeedbackText:j,loadingFeedbackUser:M,submittingFeedback:N,handleFeedbackDialogChange:P,handleSubmitFeedback:F}=On(),I;t[0]===n?I=t[1]:(I=n.map(An),t[0]=n,t[1]=I);let L=I,R;t[2]!==h||t[3]!==u?(R=!h&&(0,$.jsxs)(k,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Ue,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=h,t[3]=u,t[4]=R):R=t[4];let z;t[5]!==h||t[6]!==v||t[7]!==g||t[8]!==_?(z=g&&(0,$.jsxs)(k,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:v,disabled:_,children:[_?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(Ie,{className:`h-4 w-4`}),!h&&(0,$.jsx)(`span`,{className:`truncate`,children:_?`Updating...`:`Update to Latest`})]}),t[5]=h,t[6]=v,t[7]=g,t[8]=_,t[9]=z):z=t[9];let ee;t[10]===b?ee=t[11]:(ee=()=>void b(`/settings/general`),t[10]=b,t[11]=ee);let te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Te,{className:`h-4 w-4`}),t[12]=te):te=t[12];let B;t[13]===h?B=t[14]:(B=!h&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=h,t[14]=B);let V;t[15]!==ee||t[16]!==B?(V=(0,$.jsxs)(k,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:ee,children:[te,B]}),t[15]=ee,t[16]=B,t[17]=V):V=t[17];let ne;t[18]===P?ne=t[19]:(ne=()=>P(!0),t[18]=P,t[19]=ne);let re,ie;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(Se,{className:`h-4 w-4`}),re=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=re,t[21]=ie):(re=t[20],ie=t[21]);let H;t[22]===ne?H=t[23]:(H=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:ne,children:[ie,re]})}),t[22]=ne,t[23]=H);let U;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),t[24]=U):U=t[24];let W;t[25]===H?W=t[26]:(W=(0,$.jsx)(Ct,{children:(0,$.jsxs)(J,{children:[H,U]})}),t[25]=H,t[26]=W);let ae;t[27]!==W||t[28]!==V?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[V,W]}),t[27]=W,t[28]=V,t[29]=ae):ae=t[29];let oe;t[30]!==ae||t[31]!==z?(oe=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[z,ae]}),t[30]=ae,t[31]=z,t[32]=oe):oe=t[32];let se;t[33]===n.length?se=t[34]:(se=n.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No projects yet. Clone a repository to get started.`}),t[33]=n.length,t[34]=se);let ce;t[35]===y?ce=t[36]:(ce=y?[y]:void 0,t[35]=y,t[36]=ce);let G;t[37]!==o||t[38]!==c||t[39]!==s||t[40]!==b||t[41]!==d||t[42]!==p||t[43]!==f||t[44]!==l||t[45]!==a||t[46]!==n||t[47]!==i||t[48]!==r?(G=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(jn,{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 b(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(Mn,{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:`${w(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[37]=o,t[38]=c,t[39]=s,t[40]=b,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]=G):G=t[49];let le;t[50]!==L||t[51]!==ce||t[52]!==G?(le=(0,$.jsx)(Ht,{nodes:L,defaultOpen:!0,forceOpenIds:ce,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:G}),t[50]=L,t[51]=ce,t[52]=G,t[53]=le):le=t[53];let ue;t[54]!==se||t[55]!==le?(ue=(0,$.jsx)(S,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[se,le]})}),t[54]=se,t[55]=le,t[56]=ue):ue=t[56];let de;t[57]!==h||t[58]!==m||t[59]!==oe||t[60]!==R||t[61]!==ue?(de=(0,$.jsx)($t,{collapsed:h,onLogoClick:m,headerAction:R,footer:oe,children:ue}),t[57]=h,t[58]=m,t[59]=oe,t[60]=R,t[61]=ue,t[62]=de):de=t[62];let fe;t[63]===F?fe=t[64]:(fe=()=>void F(),t[63]=F,t[64]=fe);let pe;t[65]!==E||t[66]!==C||t[67]!==A||t[68]!==P||t[69]!==M||t[70]!==D||t[71]!==T||t[72]!==j||t[73]!==x||t[74]!==N||t[75]!==fe?(pe=(0,$.jsx)(Dn,{open:x,onOpenChange:P,feedbackName:C,onFeedbackNameChange:T,feedbackEmail:E,onFeedbackEmailChange:D,feedbackText:A,onFeedbackTextChange:j,loadingFeedbackUser:M,submittingFeedback:N,onSubmit:fe}),t[65]=E,t[66]=C,t[67]=A,t[68]=P,t[69]=M,t[70]=D,t[71]=T,t[72]=j,t[73]=x,t[74]=N,t[75]=fe,t[76]=pe):pe=t[76];let me;return t[77]!==de||t[78]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[de,pe]}),t[77]=de,t[78]=pe,t[79]=me):me=t[79],me}function An(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 jn(e){let t=(0,Q.c)(29),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:o,isSelected:s,onCreateThread:c,onDeleteProject:l,onProjectSettings:u}=e,d;t[0]===n?d=t[1]:(d=w(n),t[0]=n,t[1]=d);let p=d,m=o||s,h=r&&`rotate-90`,g;t[2]===h?g=t[3]:(g=f(`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)(ye,{className:g}),t[4]=g,t[5]=_);let v;t[6]===n.gitUrl?v=t[7]:(v=n.gitUrl?(0,$.jsx)(W,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(x,{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=f(`min-w-0 truncate transition-all block`,y),t[8]=y,t[9]=b);let S;t[10]!==p||t[11]!==b?(S=(0,$.jsx)(`span`,{className:b,children:p}),t[10]=p,t[11]=b,t[12]=S):S=t[12];let C;t[13]!==_||t[14]!==v||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,v,S]}),t[13]=_,t[14]=v,t[15]=S,t[16]=C):C=t[16];let T;t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==n.projectId||t[22]!==n.threads?(T=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(Ct,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(Te,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(q,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),c(n.projectId)},children:[(0,$.jsx)(Ue,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(me,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),t[17]=a,t[18]=c,t[19]=l,t[20]=u,t[21]=n.projectId,t[22]=n.threads,t[23]=T):T=t[23];let E;return t[24]!==i||t[25]!==C||t[26]!==T||t[27]!==m?(E=(0,$.jsxs)(Wt,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[C,T]}),t[24]=i,t[25]=C,t[26]=T,t[27]=m,t[28]=E):E=t[28],E}function Mn(e){let t=(0,Q.c)(50),{thread:n,projectId:r,selectedThreadId:i,isProcessing:a,isDeleting:o,isCompleted:s,projectTitlePrefix:c,onSelectThread:l,onDeleteThread:u}=e,[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),m=n.threadId===i,h,g;t[0]===a?(h=t[1],g=t[2]):(h=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},g=[a],t[0]=a,t[1]=h,t[2]=g),(0,Z.useEffect)(h,g);let _;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(_=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[3]=u,t[4]=r,t[5]=n.gitStatusDot,t[6]=n.threadId,t[7]=_):_=t[7];let v=_,y;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(y=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[8]=c,t[9]=n.threadId,t[10]=n.title,t[11]=y):y=t[11];let b=y,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Kt,{children:`Delete Thread`}),t[12]=x):x=t[12];let S;t[13]===b?S=t[14]:(S=(0,$.jsxs)(Gt,{children:[`Are you sure you want to delete "`,b,`" and all its files? This action cannot be undone.`]}),t[13]=b,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Xt,{children:`Cancel`}),t[15]=C):C=t[15];let w;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(w=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[C,(0,$.jsx)(Jt,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[16]=u,t[17]=r,t[18]=n.threadId,t[19]=w):w=t[19];let T;t[20]!==S||t[21]!==w?(T=(0,$.jsxs)(qt,{children:[x,S,w]}),t[20]=S,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==d||t[24]!==T?(E=(0,$.jsx)(Qt,{open:d,onOpenChange:f,children:T}),t[23]=d,t[24]=T,t[25]=E):E=t[25];let D,A;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(D=()=>l(r,n.threadId),A=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=D,t[30]=A):(D=t[29],A=t[30]);let j;t[31]===n.gitStatusDot?j=t[32]:(j=n.gitStatusDot?(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0`,viewBox:`0 0 12 12`,fill:`hsl(var(--brand))`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})}):(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-muted-foreground`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`})}),t[31]=n.gitStatusDot,t[32]=j);let M;t[33]===b?M=t[34]:(M=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:b})}),t[33]=b,t[34]=M);let N;t[35]!==v||t[36]!==s||t[37]!==o||t[38]!==a?(N=a||o?(0,$.jsx)(O,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(He,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):(0,$.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 group-hover:opacity-100 flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-opacity transition-colors`,onClick:v,children:[(0,$.jsx)(me,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[35]=v,t[36]=s,t[37]=o,t[38]=a,t[39]=N):N=t[39];let P;t[40]!==m||t[41]!==D||t[42]!==A||t[43]!==j||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(Wt,{ref:p,selected:m,onClick:D,onKeyDown:A,role:`button`,tabIndex:0,children:[j,M,N]}),t[40]=m,t[41]=D,t[42]=A,t[43]=j,t[44]=M,t[45]=N,t[46]=P):P=t[46];let F;return t[47]!==E||t[48]!==P?(F=(0,$.jsxs)($.Fragment,{children:[E,P]}),t[47]=E,t[48]=P,t[49]=F):F=t[49],F}function Nn(e){let t=e.toLowerCase();return t.includes(`bash`)||t.includes(`terminal`)||t.includes(`shell`)?`Ran`:t.includes(`read`)||t.includes(`file`)?`Read`:t===`ast_grep`?`Code Search`:t===`agent`?`Subagent`:t===`generate_image`?`Make Image`:e}function Pn(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 Fn(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function In(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 Ln(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Ln);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=In(r);t[n]=typeof e==`object`?Ln(e):r}else t[n]=Ln(r);return t}function Rn(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
3
+ `),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
4
+ `),t=t.replace(/\\"/g,`"`),t}function zn(e){if(e==null)return``;let t=typeof e==`object`&&e?Ln(e):e;return Rn(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function Bn(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:Pn(Fn(i),t),d=Pn(o?String(i.prompt):null,t),f=Pn(a&&typeof a.command==`string`?a.command:null,t),p=a&&typeof a.pattern==`string`?a.pattern:null,m=a&&typeof a.lang==`string`?a.lang:null,h=n===`code_search`,g=h&&a&&typeof a.query==`string`?a.query:null,_=h&&a&&typeof a.filePath==`string`?a.filePath:null,v=h&&a&&typeof a.fileGlob==`string`?a.fileGlob:null,y=Pn(a&&typeof a.path==`string`?a.path:null,t),b=a&&typeof a.offset==`number`?a.offset:null,x=a&&typeof a.limit==`number`?a.limit:null,S=n.toLowerCase(),C=S.includes(`read`)||S.includes(`write`)||S.includes(`edit`),w=S.includes(`edit`),T=C&&a&&typeof a.path==`string`?a.path:null,E=T?T.split(`/`).pop()??T:null,D=w&&a&&typeof a.oldText==`string`?a.oldText:null,O=w&&a&&typeof a.newText==`string`?a.newText:null,k=D!==null&&O!==null,A=n===`generate_image`&&a&&typeof a.prompt==`string`?a.prompt:null,j=n===`todo`&&a?a.status:void 0,M=n.charAt(0).toUpperCase()+n.slice(1),N=M;S===`bash`&&(M=`Ran`,N=`Running`),S===`code_search`&&(M=`Code Search`),S===`generate_image`&&(M=`Make Image`),S.includes(`read`)&&(b!==null||x!==null)&&(b!==null&&x!==null?M+=` (lines ${b} to ${b+x})`:b===null?M+=` (${x} lines)`:M+=` (from line ${b})`);let P=`default`;return S===`bash`||S.includes(`terminal`)||S.includes(`shell`)?P=`bash`:C?P=`file`:h||S===`find`||S.includes(`search`)||S.includes(`grep`)?P=`search`:S===`agent`||S.includes(`subagent`)||o?P=`agent`:S===`todo`?P=`todo`:S===`generate_image`&&(P=`imageGen`),{toolType:P,toolName:n,toolId:r,displayName:M,activeDisplayName:N,inputObj:a,toolInput:u,command:f,pattern:p,codeSearchQuery:g,codeSearchFilePath:_,codeSearchFileGlob:v,isFileTool:C,isEditTool:w,filePath:T,fileDisplayName:E,editOldText:D,editNewText:O,hasEditDiff:k,path:y,offset:b,limit:x,prompt:d,agentName:l,subagentType:c,lang:m,imageGenPrompt:A,todoStatus:j}}function Vn(e){let t=(0,Q.c)(11),{open:r,onOpenChange:i,title:a,content:o}=e,s;t[0]===a?s=t[1]:(s=(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:a})})}),t[0]=a,t[1]=s);let c;t[2]===o?c=t[3]:(c=(0,$.jsx)(`pre`,{className:`text-sm bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:o}),t[2]=o,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,$.jsxs)(n,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;return t[7]!==i||t[8]!==r||t[9]!==l?(u=(0,$.jsx)(F,{open:r,onOpenChange:i,children:l}),t[7]=i,t[8]=r,t[9]=l,t[10]=u):u=t[10],u}function Hn(e){let t=(0,Q.c)(9),{oldText:n,newText:r}=e,i,a,o;if(t[0]!==r||t[1]!==n){let e=n.split(`
5
+ `),s=r.split(`
6
+ `);i=`text-sm font-mono whitespace-pre-wrap overflow-auto`,a=e.map(Wn),o=s.map(Un),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[5]!==i||t[6]!==a||t[7]!==o?(s=(0,$.jsxs)(`pre`,{className:i,children:[a,o]}),t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Un(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 Wn(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 Gn(e){let t=(0,Q.c)(2),{name:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-sm px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono`,children:n}),t[0]=n,t[1]=r),r}function Kn(e){let t=(0,Q.c)(2),{type:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-sm px-2 py-0.5 rounded bg-muted text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}function qn(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`code`,{className:`text-sm font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n}),t[0]=n,t[1]=r),r}function Jn(e){let t=(0,Q.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=f(`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 Yn(e){let t=(0,Q.c)(11),{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=f(`inline-flex items-center gap-1`,o),t[0]=o,t[1]=c);let l=s?`text-muted-foreground`:void 0,u;t[2]===l?u=t[3]:(u=f(`text-sm`,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 p;return t[7]!==c||t[8]!==d||t[9]!==n?(p=(0,$.jsx)(`span`,{title:n,className:c,children:d}),t[7]=c,t[8]=d,t[9]=n,t[10]=p):p=t[10],p}function Xn(e){let t=(0,Q.c)(83),{data:n,inline:r,resultContent:i,isActive:a}=e,o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!!a),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(!!a),p=a?i??``:``,m,h;t[0]===a?(m=t[1],h=t[2]):(m=()=>{a&&!d.current?c(!0):!a&&d.current&&c(!1),d.current=!!a},h=[a],t[0]=a,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h);let g;t[3]!==a||t[4]!==s?(g=()=>{s&&a&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},t[3]=a,t[4]=s,t[5]=g):g=t[5];let _;if(t[6]!==a||t[7]!==s||t[8]!==p?(_=[s,a,p],t[6]=a,t[7]=s,t[8]=p,t[9]=_):_=t[9],(0,Z.useEffect)(g,_),r){if(a){let e;t[10]===s?e=t[11]:(e=()=>c(!s),t[10]=s,t[11]=e);let r;t[12]!==n.activeDisplayName||t[13]!==n.toolName?(r=(0,$.jsx)(Yn,{toolName:n.toolName,displayName:n.activeDisplayName,isActive:!1}),t[12]=n.activeDisplayName,t[13]=n.toolName,t[14]=r):r=t[14];let i;t[15]===n.command?i=t[16]:(i=n.command!==null&&(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground break-all`,children:n.command}),t[15]=n.command,t[16]=i);let a;t[17]===s?a=t[18]:(a=s?(0,$.jsx)(G,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(ye,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[17]=s,t[18]=a);let l;t[19]!==s||t[20]!==e||t[21]!==r||t[22]!==i||t[23]!==a?(l=(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]}),t[19]=s,t[20]=e,t[21]=r,t[22]=i,t[23]=a,t[24]=l):l=t[24];let u=s?`grid-rows-[1fr]`:`grid-rows-[0fr]`,d;t[25]===u?d=t[26]:(d=f(`grid transition-[grid-template-rows] duration-200 ease-in-out`,u),t[25]=u,t[26]=d);let m;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(m={maxHeight:`7.5em`},t[27]=m):m=t[27];let h;t[28]===p?h=t[29]:(h=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:o,className:`ml-5 text-sm text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`,style:m,children:p})}),t[28]=p,t[29]=h);let g;t[30]!==d||t[31]!==h?(g=(0,$.jsx)(`div`,{className:d,children:h}),t[30]=d,t[31]=h,t[32]=g):g=t[32];let _;return t[33]!==g||t[34]!==l?(_=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,g]}),t[33]=g,t[34]=l,t[35]=_):_=t[35],_}if(n.command!==null&&i){let e;t[36]!==n.displayName||t[37]!==n.toolName?(e=(0,$.jsx)(Yn,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[36]=n.displayName,t[37]=n.toolName,t[38]=e):e=t[38];let r;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>u(!0),t[39]=r):r=t[39];let a;t[40]===n.command?a=t[41]:(a=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:n.command})}),t[40]=n.command,t[41]=a);let o;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(q,{children:`View output`}),t[42]=o):o=t[42];let s;t[43]===a?s=t[44]:(s=(0,$.jsxs)(J,{children:[a,o]}),t[43]=a,t[44]=s);let c;t[45]!==e||t[46]!==s?(c=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,s]}),t[45]=e,t[46]=s,t[47]=c):c=t[47];let d;t[48]!==n.command||t[49]!==l||t[50]!==i?(d=(0,$.jsx)(Vn,{open:l,onOpenChange:u,title:n.command,content:i}),t[48]=n.command,t[49]=l,t[50]=i,t[51]=d):d=t[51];let f;return t[52]!==c||t[53]!==d?(f=(0,$.jsxs)($.Fragment,{children:[c,d]}),t[52]=c,t[53]=d,t[54]=f):f=t[54],f}let e;t[55]!==n.displayName||t[56]!==n.toolName?(e=(0,$.jsx)(Yn,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[55]=n.displayName,t[56]=n.toolName,t[57]=e):e=t[57];let r;t[58]===n.command?r=t[59]:(r=n.command!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n.command}),t[58]=n.command,t[59]=r);let d;return t[60]!==e||t[61]!==r?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[60]=e,t[61]=r,t[62]=d):d=t[62],d}let v;t[63]===s?v=t[64]:(v=()=>c(!s),t[63]=s,t[64]=v);let y=a?n.activeDisplayName:n.displayName,b;t[65]===y?b=t[66]:(b=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:y}),t[65]=y,t[66]=b);let x;t[67]===s?x=t[68]:(x=s?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[67]=s,t[68]=x);let S;t[69]!==n.toolName||t[70]!==v||t[71]!==b||t[72]!==x?(S=(0,$.jsxs)(`button`,{onClick:v,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[b,x]}),t[69]=n.toolName,t[70]=v,t[71]=b,t[72]=x,t[73]=S):S=t[73];let C;t[74]!==n.toolId||t[75]!==n.toolInput||t[76]!==a||t[77]!==s||t[78]!==p?(C=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-base text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),a?(0,$.jsx)(`div`,{ref:o,className:`text-sm text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`,style:{maxHeight:`7.5em`},children:p}):n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[74]=n.toolId,t[75]=n.toolInput,t[76]=a,t[77]=s,t[78]=p,t[79]=C):C=t[79];let w;return t[80]!==C||t[81]!==S?(w=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[S,C]}),t[80]=C,t[81]=S,t[82]=w):w=t[82],w}function Zn(e){let t=(0,Q.c)(41),{data:r,inline:i,rootPath:a,onOpenFile:o}=e,[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d;t[0]!==r.filePath||t[1]!==o||t[2]!==a?(d=function(){!r.filePath||!o||o(a&&r.filePath.startsWith(a)?r.filePath.slice(a.length+1):r.filePath)},t[0]=r.filePath,t[1]=o,t[2]=a,t[3]=d):d=t[3];let p=d;if(i){let e=!!(r.toolInput&&!r.command&&!r.path&&!r.pattern&&!r.fileDisplayName),i;t[4]!==r.displayName||t[5]!==r.toolId||t[6]!==r.toolInput||t[7]!==r.toolName||t[8]!==e?(i=e?(0,$.jsxs)(kt,{children:[(0,$.jsx)(Vt,{asChild:!0,children:(0,$.jsx)(`span`,{title:r.toolName,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)(Yn,{toolName:r.toolName,displayName:r.displayName,isActive:!1,muted:!1})})})}),(0,$.jsx)(wt,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,r.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:r.toolInput})]})})]}):(0,$.jsx)(Yn,{toolName:r.toolName,displayName:r.displayName,isActive:!1}),t[4]=r.displayName,t[5]=r.toolId,t[6]=r.toolInput,t[7]=r.toolName,t[8]=e,t[9]=i):i=t[9];let o;t[10]!==r.editNewText||t[11]!==r.editOldText||t[12]!==r.fileDisplayName||t[13]!==r.filePath||t[14]!==r.hasEditDiff||t[15]!==r.path||t[16]!==l||t[17]!==p||t[18]!==a?(o=r.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r.hasEditDiff?()=>u(!0):p,className:f(`text-sm font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:r.fileDisplayName})}),(0,$.jsx)(q,{children:r.hasEditDiff?`View diff`:r.filePath?Pn(r.filePath,a)??r.filePath:r.fileDisplayName})]}),r.hasEditDiff&&(0,$.jsx)(F,{open:l,onOpenChange:u,children:(0,$.jsxs)(n,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:Pn(r.filePath,a)??r.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(Hn,{oldText:r.editOldText,newText:r.editNewText})})]})})]}):r.path===null?null:(0,$.jsx)(`span`,{className:`text-sm font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:r.path,children:r.path}),t[10]=r.editNewText,t[11]=r.editOldText,t[12]=r.fileDisplayName,t[13]=r.filePath,t[14]=r.hasEditDiff,t[15]=r.path,t[16]=l,t[17]=p,t[18]=a,t[19]=o):o=t[19];let s;return t[20]!==i||t[21]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[i,o]}),t[20]=i,t[21]=o,t[22]=s):s=t[22],s}let m;t[23]===s?m=t[24]:(m=()=>c(!s),t[23]=s,t[24]=m);let h;t[25]===r.displayName?h=t[26]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),t[25]=r.displayName,t[26]=h);let g;t[27]===s?g=t[28]:(g=s?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[27]=s,t[28]=g);let _;t[29]!==r.toolName||t[30]!==m||t[31]!==h||t[32]!==g?(_=(0,$.jsxs)(`button`,{onClick:m,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:r.toolName,children:[h,g]}),t[29]=r.toolName,t[30]=m,t[31]=h,t[32]=g,t[33]=_):_=t[33];let v;t[34]!==r.toolId||t[35]!==r.toolInput||t[36]!==s?(v=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,r.toolId]}),r.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:r.toolInput}):null]}),t[34]=r.toolId,t[35]=r.toolInput,t[36]=s,t[37]=v):v=t[37];let y;return t[38]!==_||t[39]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[38]=_,t[39]=v,t[40]=y):y=t[40],y}function Qn(e){let t=(0,Q.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)(qn,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(qn,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(qn,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(qn,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(qn,{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 $n(e){let t=(0,Q.c)(62),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.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)(Yn,{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;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>l(!0),t[4]=r):r=t[4];let o;t[5]===d?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:d})}),t[5]=d,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(q,{children:`View results`}),t[7]=s):s=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(J,{children:[o,s]}),t[8]=o,t[9]=u);let f;t[10]!==e||t[11]!==u?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=f):f=t[12];let p;t[13]!==c||t[14]!==i||t[15]!==d?(p=(0,$.jsx)(Vn,{open:c,onOpenChange:l,title:d,content:i}),t[13]=c,t[14]=i,t[15]=d,t[16]=p):p=t[16];let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}let e;t[20]!==n.displayName||t[21]!==n.toolName||t[22]!==a?(e=(0,$.jsx)(Yn,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[20]=n.displayName,t[21]=n.toolName,t[22]=a,t[23]=e):e=t[23];let r;t[24]===n?r=t[25]:(r=(0,$.jsx)(Qn,{data:n}),t[24]=n,t[25]=r);let o;t[26]===n.lang?o=t[27]:(o=n.lang!==null&&(0,$.jsx)(`span`,{className:`text-sm px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:n.lang}),t[26]=n.lang,t[27]=o);let s;return t[28]!==e||t[29]!==r||t[30]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,o]}),t[28]=e,t[29]=r,t[30]=o,t[31]=s):s=t[31],s}let f;t[32]===o?f=t[33]:(f=()=>s(!o),t[32]=o,t[33]=f);let p;t[34]===a?p=t[35]:(p=a&&(0,$.jsx)(Jn,{size:`md`}),t[34]=a,t[35]=p);let m;t[36]===n.displayName?m=t[37]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[36]=n.displayName,t[37]=m);let h;t[38]!==n.codeSearchFileGlob||t[39]!==n.codeSearchFilePath||t[40]!==n.codeSearchQuery||t[41]!==n.pattern||t[42]!==u?(h=u&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(`code`,{className:`text-sm font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFileGlob})]}),t[38]=n.codeSearchFileGlob,t[39]=n.codeSearchFilePath,t[40]=n.codeSearchQuery,t[41]=n.pattern,t[42]=u,t[43]=h):h=t[43];let g;t[44]===o?g=t[45]:(g=o?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[44]=o,t[45]=g);let _;t[46]!==n.toolName||t[47]!==f||t[48]!==p||t[49]!==m||t[50]!==h||t[51]!==g?(_=(0,$.jsxs)(`button`,{onClick:f,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[p,m,h,g]}),t[46]=n.toolName,t[47]=f,t[48]=p,t[49]=m,t[50]=h,t[51]=g,t[52]=_):_=t[52];let v;t[53]!==n.toolId||t[54]!==n.toolInput||t[55]!==o||t[56]!==u||t[57]!==i?(v=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-64 mt-2`,children:i})]}),t[53]=n.toolId,t[54]=n.toolInput,t[55]=o,t[56]=u,t[57]=i,t[58]=v):v=t[58];let y;return t[59]!==_||t[60]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[59]=_,t[60]=v,t[61]=y):y=t[61],y}function er(e){let t=(0,Q.c)(54),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(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)(Yn,{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]!==n.toolName||t[5]!==e?(r=(0,$.jsx)(Vt,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:e})}),t[4]=n.toolName,t[5]=e,t[6]=r):r=t[6];let a;t[7]===n.toolId?a=t[8]:(a=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[7]=n.toolId,t[8]=a);let o;t[9]!==n.prompt||t[10]!==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[9]=n.prompt,t[10]=n.toolInput,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,$.jsx)(wt,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[a,o]})}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let c;t[15]!==r||t[16]!==s?(c=(0,$.jsxs)(kt,{children:[r,s]}),t[15]=r,t[16]=s,t[17]=c):c=t[17];let l;t[18]===n.agentName?l=t[19]:(l=n.agentName&&(0,$.jsx)(Gn,{name:n.agentName}),t[18]=n.agentName,t[19]=l);let u;t[20]===n.subagentType?u=t[21]:(u=n.subagentType&&(0,$.jsx)(Kn,{type:n.subagentType}),t[20]=n.subagentType,t[21]=u);let d;return t[22]!==c||t[23]!==l||t[24]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[c,l,u]}),t[22]=c,t[23]=l,t[24]=u,t[25]=d):d=t[25],d}let s;t[26]===a?s=t[27]:(s=()=>o(!a),t[26]=a,t[27]=s);let c;t[28]===i?c=t[29]:(c=i&&(0,$.jsx)(Jn,{size:`md`}),t[28]=i,t[29]=c);let l;t[30]===n.displayName?l=t[31]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[30]=n.displayName,t[31]=l);let u;t[32]===n.agentName?u=t[33]:(u=n.agentName&&(0,$.jsx)(Gn,{name:n.agentName}),t[32]=n.agentName,t[33]=u);let d;t[34]===n.subagentType?d=t[35]:(d=n.subagentType&&(0,$.jsx)(Kn,{type:n.subagentType}),t[34]=n.subagentType,t[35]=d);let f;t[36]===a?f=t[37]:(f=a?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[36]=a,t[37]=f);let p;t[38]!==n.toolName||t[39]!==s||t[40]!==c||t[41]!==l||t[42]!==u||t[43]!==d||t[44]!==f?(p=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u,d,f]}),t[38]=n.toolName,t[39]=s,t[40]=c,t[41]=l,t[42]=u,t[43]=d,t[44]=f,t[45]=p):p=t[45];let m;t[46]!==n.prompt||t[47]!==n.toolId||t[48]!==n.toolInput||t[49]!==a?(m=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`text-base bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[46]=n.prompt,t[47]=n.toolId,t[48]=n.toolInput,t[49]=a,t[50]=m):m=t[50];let h;return t[51]!==p||t[52]!==m?(h=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[p,m]}),t[51]=p,t[52]=m,t[53]=h):h=t[53],h}function tr(e){let t=(0,Q.c)(21),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.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]===i?c=t[3]:(c=i&&(0,$.jsx)(Jn,{size:`md`}),t[2]=i,t[3]=c);let l;t[4]===n.displayName?l=t[5]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[4]=n.displayName,t[5]=l);let u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[6]=a,t[7]=u);let d;t[8]!==n.toolName||t[9]!==s||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-base font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[8]=n.toolName,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.toolId||t[15]!==n.toolInput||t[16]!==a?(f=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[14]=n.toolId,t[15]=n.toolInput,t[16]=a,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function nr(e){let t=(0,Q.c)(30),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(Yn,{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,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.imageGenPrompt,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]===i?c=t[12]:(c=i&&(0,$.jsx)(Jn,{size:`md`}),t[11]=i,t[12]=c);let l;t[13]===n.displayName?l=t[14]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[13]=n.displayName,t[14]=l);let u;t[15]===a?u=t[16]:(u=a?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[15]=a,t[16]=u);let d;t[17]!==n.toolName||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-base font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[17]=n.toolName,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d):d=t[22];let f;t[23]!==n.toolId||t[24]!==n.toolInput||t[25]!==a?(f=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[23]=n.toolId,t[24]=n.toolInput,t[25]=a,t[26]=f):f=t[26];let p;return t[27]!==d||t[28]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[27]=d,t[28]=f,t[29]=p):p=t[29],p}function rr(e){let t=(0,Q.c)(35),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.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)(kt,{children:[(0,$.jsx)(Vt,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,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)(Yn,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(wt,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-base text-muted-foreground 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)(Yn,{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,$.jsx)(`span`,{className:`text-sm font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,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]===i?c=t[16]:(c=i&&(0,$.jsx)(Jn,{size:`md`}),t[15]=i,t[16]=c);let l;t[17]===n.displayName?l=t[18]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[17]=n.displayName,t[18]=l);let u;t[19]===a?u=t[20]:(u=a?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[19]=a,t[20]=u);let d;t[21]!==n.toolName||t[22]!==s||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[21]=n.toolName,t[22]=s,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.prompt||t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==a?(f=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[27]=n.prompt,t[28]=n.toolId,t[29]=n.toolInput,t[30]=a,t[31]=f):f=t[31];let p;return t[32]!==d||t[33]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[32]=d,t[33]=f,t[34]=p):p=t[34],p}function ir(e){let t=(0,Q.c)(41),{block:n,inline:r,resultContent:i,isActive:a}=e,{state:o}=ft(),{setPendingExplorerPath:s,setActiveMainTab:c}=tn(),l;if(t[0]!==o.projects||t[1]!==o.selectedProjectId||t[2]!==o.selectedThreadId){let e;t[4]===o.selectedProjectId?e=t[5]:(e=e=>e.projectId===o.selectedProjectId,t[4]=o.selectedProjectId,t[5]=e),l=o.projects.find(e)?.threads.find(e=>e.threadId===o.selectedThreadId),t[0]=o.projects,t[1]=o.selectedProjectId,t[2]=o.selectedThreadId,t[3]=l}else l=t[3];let u=l?.path,d=Bn(n,u),f=!!(a&&i===void 0),p;t[6]!==c||t[7]!==s?(p=function(e){s(e),c(`explorer`)},t[6]=c,t[7]=s,t[8]=p):p=t[8];let m=p;switch(d.toolType){case`bash`:{let e;return t[9]!==d||t[10]!==r||t[11]!==f||t[12]!==i?(e=(0,$.jsx)(Xn,{data:d,inline:r,resultContent:i,isActive:f}),t[9]=d,t[10]=r,t[11]=f,t[12]=i,t[13]=e):e=t[13],e}case`file`:{let e;return t[14]!==d||t[15]!==m||t[16]!==r||t[17]!==f||t[18]!==u?(e=(0,$.jsx)(Zn,{data:d,inline:r,rootPath:u,onOpenFile:m,isActive:f}),t[14]=d,t[15]=m,t[16]=r,t[17]=f,t[18]=u,t[19]=e):e=t[19],e}case`search`:{let e;return t[20]!==d||t[21]!==r||t[22]!==f||t[23]!==i?(e=(0,$.jsx)($n,{data:d,inline:r,resultContent:i,isActive:f}),t[20]=d,t[21]=r,t[22]=f,t[23]=i,t[24]=e):e=t[24],e}case`agent`:{let e;return t[25]!==d||t[26]!==r||t[27]!==f?(e=(0,$.jsx)(er,{data:d,inline:r,isActive:f}),t[25]=d,t[26]=r,t[27]=f,t[28]=e):e=t[28],e}case`todo`:{let e;return t[29]!==d||t[30]!==r||t[31]!==f?(e=(0,$.jsx)(tr,{data:d,inline:r,isActive:f}),t[29]=d,t[30]=r,t[31]=f,t[32]=e):e=t[32],e}case`imageGen`:{let e;return t[33]!==d||t[34]!==r||t[35]!==f?(e=(0,$.jsx)(nr,{data:d,inline:r,isActive:f}),t[33]=d,t[34]=r,t[35]=f,t[36]=e):e=t[36],e}default:{let e;return t[37]!==d||t[38]!==r||t[39]!==f?(e=(0,$.jsx)(rr,{data:d,inline:r,isActive:f}),t[37]=d,t[38]=r,t[39]=f,t[40]=e):e=t[40],e}}}function ar(e){let t=[];if(typeof e==`string`)t.push(e);else if(Array.isArray(e))for(let n of e)typeof n==`object`&&n&&`text`in n&&typeof n.text==`string`&&t.push(n.text);for(let e of t){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e.imageUrl||e.imageData)return{imageUrl:e.imageUrl,imageData:e.imageData,model:e.model}}catch{}}return null}function or(e){let t=(0,Q.c)(29),{imageUrl:n,imageData:r}=e,[i,a]=(0,Z.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 le(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:o,filename:e});X({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 I(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,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)(Ie,{className:`h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===c?m=t[9]:(m=(0,$.jsx)(Y,{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)(q,{children:`Save image`}),t[10]=h):h=t[10];let g;t[11]===m?g=t[12]:(g=(0,$.jsxs)(J,{children:[m,h]}),t[11]=m,t[12]=g);let _;t[13]===i?_=t[14]:(_=i?(0,$.jsx)(He,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(de,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=_);let v;t[15]!==u||t[16]!==_?(v=(0,$.jsx)(Y,{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)(q,{children:y}),t[18]=y,t[19]=b);let x;t[20]!==v||t[21]!==b?(x=(0,$.jsxs)(J,{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)(Ct,{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 sr(e){let t=(0,Q.c)(70),{block:r,inline:i,sequence:a}=e,o=a===void 0?0:a,[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),{state:d}=ft(),f=d.projects,p,m,h,g,_,v,y,b;if(t[0]!==r||t[1]!==i||t[2]!==o||t[3]!==d.projects||t[4]!==d.selectedProjectId||t[5]!==d.selectedThreadId){v=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[14]===d.selectedProjectId?e=t[15]:(e=e=>e.projectId===d.selectedProjectId,t[14]=d.selectedProjectId,t[15]=e);let n=f.find(e)?.threads.find(e=>e.threadId===d.selectedThreadId)?.path;b=r.toolName??`Unknown Tool`,y=r.toolCallId??`unknown`;let a=r,s=r.result??a.content,c;t[16]!==a||t[17]!==b?(c=b===`todo`?At(a):null,t[16]=a,t[17]=b,t[18]=c):c=t[18];let l=c;if(h=Pn(zn(s),n),!(h.length>0)&&l===null){v=null;break bb0}if(p=Nn(b),typeof s==`object`&&s){let e=s,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[19]===n?e=t[20]:(e=n.trim(),t[19]=n,t[20]=e),p=e}else if(b===`read`||b===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[21]===n?e=t[22]:(e=n.split(`/`).pop()??n,t[21]=n,t[22]=e),p=`Completed ${e}`}}}else if(s==null){let e;t[23]===b?e=t[24]:(e=Nn(b),t[23]=b,t[24]=e),p=`${e} (no result)`}if(p=Pn(p,n),l!==null){let e;t[25]!==o||t[26]!==l?(e=(0,$.jsx)(It,{todos:l,sequence:o}),t[25]=o,t[26]=l,t[27]=e):e=t[27],v=e;break bb0}if(b===`generate_image`){let e;t[28]===s?e=t[29]:(e=ar(s),t[28]=s,t[29]=e);let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[30]!==n.imageData||t[31]!==n.imageUrl?(e=(0,$.jsx)(or,{imageUrl:n.imageUrl,imageData:n.imageData}),t[30]=n.imageData,t[31]=n.imageUrl,t[32]=e):e=t[32],v=e;break bb0}}if(i){v=null;break bb0}let u;t[33]===b?u=t[34]:(u=b.toLowerCase().includes(`bash`),t[33]=b,t[34]=u),m=u,g=h?h.split(`
7
+ `):[],_=m?g.slice(0,3).join(`
8
+ `):h}t[0]=r,t[1]=i,t[2]=o,t[3]=d.projects,t[4]=d.selectedProjectId,t[5]=d.selectedThreadId,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_,t[11]=v,t[12]=y,t[13]=b}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10],v=t[11],y=t[12],b=t[13];if(v!==Symbol.for(`react.early_return_sentinel`))return v;let x=_,S=m&&g.length>3;if(m){let e;t[35]===p?e=t[36]:(e=(0,$.jsx)(`div`,{className:`px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:p})}),t[35]=p,t[36]=e);let r;t[37]!==S||t[38]!==x||t[39]!==h||t[40]!==g?(r=h&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-sm bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2${S?` cursor-pointer hover:bg-muted/80`:``}`,onClick:S?()=>u(!0):void 0,title:S?`Click to see full output`:void 0,children:[x,S&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
9
+ `,`...`]})]}),S&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`mt-1 text-sm text-brand hover:underline`,children:[`Show full output (`,g.length,` lines)`]})]}),t[37]=S,t[38]=x,t[39]=h,t[40]=g,t[41]=r):r=t[41];let i;t[42]!==e||t[43]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[e,r]}),t[42]=e,t[43]=r,t[44]=i):i=t[44];let a;t[45]!==l||t[46]!==S||t[47]!==h?(a=S&&(0,$.jsx)(F,{open:l,onOpenChange:u,children:(0,$.jsxs)(n,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-sm bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:h})]})}),t[45]=l,t[46]=S,t[47]=h,t[48]=a):a=t[48];let o;return t[49]!==i||t[50]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[49]=i,t[50]=a,t[51]=o):o=t[51],o}let C;t[52]===s?C=t[53]:(C=()=>c(!s),t[52]=s,t[53]=C);let w=`${b} result`,T;t[54]===p?T=t[55]:(T=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:p}),t[54]=p,t[55]=T);let E;t[56]===s?E=t[57]:(E=s?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[56]=s,t[57]=E);let D;t[58]!==C||t[59]!==w||t[60]!==T||t[61]!==E?(D=(0,$.jsxs)(`button`,{onClick:C,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:w,children:[T,E]}),t[58]=C,t[59]=w,t[60]=T,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==s||t[64]!==h||t[65]!==y?(O=s&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`Call ID: `,y]}),h&&(0,$.jsx)(`pre`,{className:`text-sm bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:h})]}),t[63]=s,t[64]=h,t[65]=y,t[66]=O):O=t[66];let k;return t[67]!==O||t[68]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[D,O]}),t[67]=O,t[68]=D,t[69]=k):k=t[69],k}function cr(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 lr(e,t,n){return e?t===`Validating`?`Validating...`:`Thinking...`:t===`Validated`?`Validated`:n<=0?`Thought complete.`:`Thought for ${cr(n)}.`}function ur(e){let t=(0,Q.c)(37),{text:n,isStreaming:r,label:i}=e,a=n===void 0?``:n,o=r===void 0?!1:r,s=(0,Z.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Date.now(),t[0]=c):c=t[0];let l=(0,Z.useRef)(c),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)(o),m=(0,Z.useRef)(o),h,g;t[1]===o?(h=t[2],g=t[3]):(h=()=>{o&&!m.current?(l.current=Date.now(),d(0),p(!0)):o?p(!0):m.current&&!o&&(d(Date.now()-l.current),p(!1)),m.current=o},g=[o],t[1]=o,t[2]=h,t[3]=g),(0,Z.useEffect)(h,g);let _;t[4]!==f||t[5]!==o?(_=()=>{f&&o&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},t[4]=f,t[5]=o,t[6]=_):_=t[6];let v;if(t[7]!==f||t[8]!==o||t[9]!==a?(v=[a,f,o],t[7]=f,t[8]=o,t[9]=a,t[10]=v):v=t[10],(0,Z.useEffect)(_,v),!a&&!o)return null;let y=!o&&i===`Validated`,b;t[11]!==u||t[12]!==o||t[13]!==i?(b=lr(o,i,u),t[11]=u,t[12]=o,t[13]=i,t[14]=b):b=t[14];let x=b,S;t[15]===f?S=t[16]:(S=()=>p(!f),t[15]=f,t[16]=S);let C;t[17]===y?C=t[18]:(C=y?(0,$.jsx)(ge,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):null,t[17]=y,t[18]=C);let w;t[19]===x?w=t[20]:(w=(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:x}),t[19]=x,t[20]=w);let T;t[21]!==f||t[22]!==C||t[23]!==w||t[24]!==S?(T=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:S,"aria-expanded":f,children:[C,w]}),t[21]=f,t[22]=C,t[23]=w,t[24]=S,t[25]=T):T=t[25];let E=f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,D;t[26]===E?D=t[27]:(D=[`grid transition-[grid-template-rows] duration-200 ease-in-out`,E],t[26]=E,t[27]=D);let O=D.join(` `),k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k={maxHeight:`7.5em`},t[28]=k):k=t[28];let A;t[29]===a?A=t[30]:(A=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:s,className:`ml-5 text-sm text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`,style:k,children:a})}),t[29]=a,t[30]=A);let j;t[31]!==O||t[32]!==A?(j=(0,$.jsx)(`div`,{className:O,children:A}),t[31]=O,t[32]=A,t[33]=j):j=t[33];let M;return t[34]!==T||t[35]!==j?(M=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[T,j]}),t[34]=T,t[35]=j,t[36]=M):M=t[36],M}function dr(e){let t=(0,Q.c)(52),{toolCall:n,className:r}=e,{state:i,dispatch:a}=ft(),[o,s]=(0,Z.useState)(!1),c=i.toolCallProgress[n.id],l;t[0]===n.name?l=t[1]:(l=n.name===`bash`?`Ran`:n.name.charAt(0).toUpperCase()+n.name.slice(1),t[0]=n.name,t[1]=l);let u=l;if(!i.isStreaming)return null;let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{s(pr)},t[2]=d):d=t[2];let p=d,m;t[3]!==a||t[4]!==i.streamingSegments||t[5]!==n.id||t[6]!==n.name?(m=()=>{a({type:K.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.`};a({type:K.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([e]),segments:i.streamingSegments})},t[3]=a,t[4]=i.streamingSegments,t[5]=n.id,t[6]=n.name,t[7]=m):m=t[7];let h=m,g=fr,_=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,v=!_&&typeof n.input?.description==`string`?n.input.description:null,y;t[8]===r?y=t[9]:(y=f(`overflow-hidden mb-2`,r),t[8]=r,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Jn,{}),t[10]=b):b=t[10];let x;t[11]===u?x=t[12]:(x=(0,$.jsx)(`span`,{className:`text-base text-muted-foreground`,children:u}),t[11]=u,t[12]=x);let S;t[13]!==x||t[14]!==n.name?(S=(0,$.jsxs)(`span`,{title:n.name,className:`inline-flex items-center gap-1`,children:[b,x]}),t[13]=x,t[14]=n.name,t[15]=S):S=t[15];let C;t[16]===_?C=t[17]:(C=_!==null&&(0,$.jsx)(`code`,{className:`text-base font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:_}),t[16]=_,t[17]=C);let w;t[18]===v?w=t[19]:(w=v!==null&&(0,$.jsx)(`span`,{className:`text-base text-muted-foreground`,children:v}),t[18]=v,t[19]=w);let T;t[20]!==_||t[21]!==v?(T=!_&&!v&&(0,$.jsx)(`span`,{className:`text-base text-muted-foreground`,children:`running`}),t[20]=_,t[21]=v,t[22]=T):T=t[22];let E=o?`Collapse`:`Expand`,D;t[23]===o?D=t[24]:(D=o?(0,$.jsx)(De,{className:`h-3 w-3`}):(0,$.jsx)(G,{className:`h-3 w-3`}),t[23]=o,t[24]=D);let O;t[25]!==E||t[26]!==D?(O=(0,$.jsx)(`button`,{onClick:p,className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:E,children:D}),t[25]=E,t[26]=D,t[27]=O):O=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Fe,{className:`h-3 w-3`}),t[28]=k):k=t[28];let A;t[29]===h?A=t[30]:(A=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:h,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:k})}),t[29]=h,t[30]=A);let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(q,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[31]=j):j=t[31];let M;t[32]===A?M=t[33]:(M=(0,$.jsxs)(J,{children:[A,j]}),t[32]=A,t[33]=M);let N;t[34]!==O||t[35]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[O,M]}),t[34]=O,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==T||t[38]!==N||t[39]!==S||t[40]!==C||t[41]!==w?(P=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[S,C,w,T,N]}),t[37]=T,t[38]=N,t[39]=S,t[40]=C,t[41]=w,t[42]=P):P=t[42];let F;t[43]!==o||t[44]!==n.id||t[45]!==n.input||t[46]!==c?(F=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Input:`}),(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 border border-slate-200 dark:border-slate-700`,children:g(n.input)})]}),c&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Progress:`}),(0,$.jsxs)(`div`,{className:`text-sm bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800`,children:[(0,$.jsx)(`div`,{className:`text-green-700 dark:text-green-300 font-mono`,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:`mt-1 text-green-600 dark:text-green-400 font-mono text-sm`,children:[`Building: `,c.partial.content[0].arguments.content.slice(-50),c.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(Jn,{}),`Executing`,c&&` with progress`,`...`]})]}),t[43]=o,t[44]=n.id,t[45]=n.input,t[46]=c,t[47]=F):F=t[47];let I;return t[48]!==P||t[49]!==F||t[50]!==y?(I=(0,$.jsxs)(`div`,{className:y,children:[P,F]}),t[48]=P,t[49]=F,t[50]=y,t[51]=I):I=t[51],I}function fr(e){return JSON.stringify(e,null,2)}function pr(e){return!e}function mr(e){let t=(0,Q.c)(51),{toolCallId:n,question:r,options:i,context:a,answeredText:o}=e,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!!o),[d,p]=(0,Z.useState)(o??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v;t[0]!==m||t[1]!==n?(v=async e=>{if(!(!e.trim()||m)){h(!0);try{await M(n,e.trim()),p(e.trim()),u(!0)}catch(e){console.error(`Failed to submit answer:`,e),h(!1),_(null)}}},t[0]=m,t[1]=n,t[2]=v):v=t[2];let y=v,b;t[3]!==y||t[4]!==m||t[5]!==l?(b=e=>{l||m||(_(e),y(e))},t[3]=y,t[4]=m,t[5]=l,t[6]=b):b=t[6];let x=b,S;t[7]!==s||t[8]!==y||t[9]!==m||t[10]!==l?(S=()=>{if(l||m)return;let e=s.trim();e&&y(e)},t[7]=s,t[8]=y,t[9]=m,t[10]=l,t[11]=S):S=t[11];let C=S,w;t[12]===C?w=t[13]:(w=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C())},t[12]=C,t[13]=w);let T=w;if(l){let e,n;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(He,{className:`h-4 w-4`}),n=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),t[14]=e,t[15]=n):(e=t[14],n=t[15]);let r;return t[16]===d?r=t[17]:(r=(0,$.jsx)(`div`,{className:`rounded-lg p-3 my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e,n,(0,$.jsx)(`span`,{children:d})]})}),t[16]=d,t[17]=r),r}let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(pe,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[18]=E):E=t[18];let D;t[19]===r?D=t[20]:(D=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(en,{content:r})}),t[19]=r,t[20]=D);let O;t[21]===a?O=t[22]:(O=a&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a}),t[21]=a,t[22]=O);let k;t[23]!==D||t[24]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[E,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[D,O]})]}),t[23]=D,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==x||t[27]!==m||t[28]!==i||t[29]!==g?(A=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=g===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(e),disabled:m,className:f(`rounded-md border px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-1.5`,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)(He,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[26]=x,t[27]=m,t[28]=i,t[29]=g,t[30]=A):A=t[30];let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>c(e.target.value),t[31]=j):j=t[31];let N=i?.length?`Or type a custom answer...`:`Type your answer...`,P;t[32]!==s||t[33]!==T||t[34]!==m||t[35]!==N?(P=(0,$.jsx)(`input`,{type:`text`,value:s,onChange:j,onKeyDown:T,placeholder:N,disabled:m,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),t[32]=s,t[33]=T,t[34]=m,t[35]=N,t[36]=P):P=t[36];let F;t[37]!==s||t[38]!==m?(F=m||!s.trim(),t[37]=s,t[38]=m,t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(R,{className:`h-3 w-3`}),t[40]=I):I=t[40];let L;t[41]!==C||t[42]!==F?(L=(0,$.jsx)(`button`,{type:`button`,onClick:C,disabled:F,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:I}),t[41]=C,t[42]=F,t[43]=L):L=t[43];let z;t[44]!==P||t[45]!==L?(z=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[P,L]}),t[44]=P,t[45]=L,t[46]=z):z=t[46];let ee;return t[47]!==z||t[48]!==k||t[49]!==A?(ee=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[k,A,z]}),t[47]=z,t[48]=k,t[49]=A,t[50]=ee):ee=t[50],ee}function hr(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=ft(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=Dt(n),t[0]=n,t[1]=s);let c=s,[l,u]=(0,Z.useState)(c?.status??`running`),d;t[2]===c?d=t[3]:(d=()=>{if(!c||c.status!==`success`)return null;let e=c.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},t[2]=c,t[3]=d);let[f,p]=(0,Z.useState)(d),[m,h]=(0,Z.useState)(c?.error??null),g,_;t[4]===n?(g=t[5],_=t[6]):(g=()=>Ot(n,()=>{let e=Dt(n);if(e)if(u(e.status),e.status===`success`){let t=e.result;p(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,Z.useEffect)(g,_);let v,y;t[7]!==i||t[8]!==o||t[9]!==n?(v=()=>{o&&Bt(n,i,o)},y=[n,i,o],t[7]=i,t[8]=o,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Z.useEffect)(v,y);let[b,x]=(0,Z.useState)(!1),S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>x(gr),t[12]=S):S=t[12];let C=S;if(l===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(je,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[13]=e):e=t[13];let n=r||`Executing Browser JS...`,i;return t[14]===n?i=t[15]:(i=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n})]})}),t[14]=n,t[15]=i),i}if(l===`success`){let e;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(je,{className:`h-4 w-4 shrink-0 text-brand`}),t[16]=e):e=t[16];let n=r||`Browser JS Executed Successfully`,a;t[17]===n?a=t[18]:(a=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n}),t[17]=n,t[18]=a);let o;t[19]===b?o=t[20]:(o=b?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[19]=b,t[20]=o);let s;t[21]!==a||t[22]!==o?(s=(0,$.jsxs)(`button`,{onClick:C,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,children:[e,a,o]}),t[21]=a,t[22]=o,t[23]=s):s=t[23];let c;t[24]!==i||t[25]!==b||t[26]!==f?(c=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i}),f!=null&&(0,$.jsx)(`pre`,{className:`text-sm text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:f})]}),t[24]=i,t[25]=b,t[26]=f,t[27]=c):c=t[27];let l;return t[28]!==s||t[29]!==c?(l=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[s,c]}),t[28]=s,t[29]=c,t[30]=l):l=t[30],l}let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(je,{className:`h-4 w-4 shrink-0 text-destructive`}),t[31]=w):w=t[31];let T=r||`Browser JS Execution Failed`,E;t[32]===T?E=t[33]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:T}),t[32]=T,t[33]=E);let D;t[34]===b?D=t[35]:(D=b?(0,$.jsx)(G,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0`}),t[34]=b,t[35]=D);let O;t[36]!==E||t[37]!==D?(O=(0,$.jsxs)(`button`,{onClick:C,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,children:[w,E,D]}),t[36]=E,t[37]=D,t[38]=O):O=t[38];let k;t[39]!==i||t[40]!==m||t[41]!==b?(k=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:m}),(0,$.jsx)(`pre`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=m,t[41]=b,t[42]=k):k=t[42];let A;return t[43]!==O||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[O,k]}),t[43]=O,t[44]=k,t[45]=A):A=t[45],A}function gr(e){return!e}function _r(e){let t=(0,Q.c)(29),{src:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await le(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});X({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 I(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)(Ie,{className:`h-3.5 w-3.5`}),t[7]=d):d=t[7];let f;t[8]===o?f=t[9]:(f=(0,$.jsx)(Y,{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)(q,{children:`Save image`}),t[10]=p):p=t[10];let m;t[11]===f?m=t[12]:(m=(0,$.jsxs)(J,{children:[f,p]}),t[11]=f,t[12]=m);let h;t[13]===r?h=t[14]:(h=r?(0,$.jsx)(He,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(de,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=h);let g;t[15]!==c||t[16]!==h?(g=(0,$.jsx)(Y,{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)(q,{children:_}),t[18]=_,t[19]=v);let y;t[20]!==g||t[21]!==v?(y=(0,$.jsxs)(J,{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)(Ct,{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 vr(e){let t=e.partial?.content?.[0]?.arguments;if(!(!t||typeof t!=`object`)&&`content`in t&&typeof t.content==`string`)return t.content}function yr(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 br(e,t){return e.some(e=>e.type===`tool-result`&&e.toolCallId===t)}function xr(e,t){return(0,$.jsx)(mr,{toolCallId:e.toolCallId??`long-running-confirmation`,question:e.question,options:e.options,context:e.context},t)}function Sr(e,t,n,r,i){if(e.name===`ask_user`)return(0,$.jsx)(mr,{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)(hr,{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)(dr,{toolCall:e},t):(0,$.jsx)(ir,{inline:!0,block:e,resultContent:a?i:r,isActive:a},t)}function Cr({message:e,threadId:t,messageIndex:n=0,showCheckpointRestore:r=!1}){let i=e.sender===`user`,a=i?null:_t(e.content),[o,s]=(0,Z.useState)(!1),c=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function l(){if(!(!e.checkpointRef||!t||o)){s(!0);try{let n=await Ne(t,e.checkpointRef);n.success?X({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):X({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){X({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{s(!1)}}}return(0,$.jsx)(`div`,{className:f(`group px-4 py-4`,i&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:f(`flex flex-col gap-1 min-w-0 max-w-full`,i&&`items-end`),children:[(0,$.jsxs)(`div`,{className:f(`flex items-center gap-2`,i&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:i?`You`:`Agent`}),i&&e.checkpointRef&&r&&(0,$.jsx)(Ct,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,disabled:o,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity hover:text-foreground hover:bg-muted disabled:opacity-50`,children:(0,$.jsx)(_e,{className:f(`h-3 w-3`,o&&`animate-spin`)})})}),(0,$.jsx)(q,{side:`left`,children:`Restore checkpoint`})]})}),c&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(we,{className:`h-2.5 w-2.5`}),c]}),e.model&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(je,{className:`h-2.5 w-2.5`}),rn(e.model)]}),e.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(Re,{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&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[e.metadata.tokenCount.toLocaleString(),` tokens`]})]}),(0,$.jsx)(`div`,{className:f(`flex flex-col gap-0.5 min-w-0 text-base`,i&&`rounded-xl px-4 py-3 bg-foreground text-background`),children:e.isThinking?(()=>{let t=ht(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:mt(t,!1).map((e,n)=>{if(e.type===`thinking-group`){let t=e;return(0,$.jsx)(ur,{text:t.text,label:t.label,isStreaming:!1},`tg-${n}`)}let r=e;return r.type===`tool_use`?Sr(r,n,!1,yr(t,r.id)):r.type===`long_running_confirmation`?xr(r.prompt,n):r.type===`tool-result`?(0,$.jsx)(sr,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:`text-base text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(en,{content:bt(e.content),enableMermaid:!0})})})():a?(()=>{let e=mt(a,!1),t=a.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[e.map((e,t)=>{if(e.type===`thinking-group`){let n=e;return(0,$.jsx)(ur,{text:n.text,label:n.label,isStreaming:!1},`tg-${t}`)}let r=e;return r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`?r.type===`tool-result`?(0,$.jsx)(sr,{inline:!0,sequence:n,block:r},t):null:r.type===`tool_use`&&r.name===`ask_user`||r.type===`tool-result`&&r.toolName===`ask_user`?null:r.type===`long_running_confirmation`?xr(r.prompt,t):(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(en,{content:bt(r.text),enableMermaid:!0}):r.type===`tool_use`?Sr(r,void 0,!1,yr(a,r.id)):r.type===`tool-result`?(0,$.jsx)(sr,{inline:!0,block:r}):null},t)}),t.map((e,t)=>(0,$.jsx)(mr,{toolCallId:e.id,question:typeof e.input?.question==`string`?e.input.question:``,options:e.input?.options,context:e.input?.context,answeredText:yr(a,e.id)},`ask-${t}`))]})})():(0,$.jsx)(en,{content:bt(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(_r,{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:`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(z,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}function wr(e){let t=(0,Q.c)(25),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a,totalMessages:o,showProcessingLine:s}=e,c=o===void 0?0:o,l=s===void 0?!1:s,{state:u}=ft(),d,p,m,h;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==l||t[5]!==u||t[6]!==c){let e=pt(n),o=l?`pb-0`:`pb-4`;t[11]===o?h=t[12]:(h=f(`group px-4 pt-4`,o),t[11]=o,t[12]=h),d=`flex flex-col gap-1 min-w-0`;let s;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[13]=s):s=t[13];let g;t[14]===r?g=t[15]:(g=r&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(je,{className:`h-2.5 w-2.5`}),rn(r)]}),t[14]=r,t[15]=g),t[16]===g?p=t[17]:(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,g]}),t[16]=g,t[17]=p),m=e.length>0?(()=>{let t=mt(e,!0),n=e.filter(Tr);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-base`,children:[t.map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(ur,{text:e.text,label:e.label,isStreaming:e.isCurrentlyStreaming},`tg-${n}`)}let r=t;return r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`?r.type===`tool-result`?(0,$.jsx)(sr,{inline:!0,sequence:c,block:r},`b-${n}`):null:r.type===`tool_use`&&r.name===`ask_user`?null:r.type===`long_running_confirmation`?xr(r.prompt,`stream-${n}`):(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(en,{content:bt(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=r.id,n=yr(e,t),i=vr(u.toolCallProgress[t]??{});return Sr(r,void 0,!br(e,t),n,i)})():r.type===`tool-result`?(0,$.jsx)(sr,{inline:!0,block:r}):null},`b-${n}`)}),n.map((t,n)=>(0,$.jsx)(mr,{toolCallId:t.id,question:typeof t.input?.question==`string`?t.input.question:``,options:t.input?.options,context:t.input?.context,answeredText:yr(e,t.id)},`ask-${n}`))]})})():i||a?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(ur,{isStreaming:!0})}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=l,t[5]=u,t[6]=c,t[7]=d,t[8]=p,t[9]=m,t[10]=h}else d=t[7],p=t[8],m=t[9],h=t[10];let g;t[18]!==d||t[19]!==p||t[20]!==m?(g=(0,$.jsxs)(`div`,{className:d,children:[p,m]}),t[18]=d,t[19]=p,t[20]=m,t[21]=g):g=t[21];let _;return t[22]!==h||t[23]!==g?(_=(0,$.jsx)(`div`,{className:h,children:g}),t[22]=h,t[23]=g,t[24]=_):_=t[24],_}function Tr(e){return e.type===`tool_use`&&e.name===`ask_user`}var Er=(0,Z.memo)(wr,(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(i.type===`long_running_confirmation`||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}),Dr=3e3;function Or(e){let t=[...Ce],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function kr(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(A),i=(0,Z.useRef)(A),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(A),i.current=A;return}let t=setInterval(()=>{let e=i.current===`Processing...`?Or():Or(i.current);i.current=e,r(e)},Dr);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}var Ar=`w-7`,jr=`-ml-9`;function Mr(e){let t=(0,Q.c)(11),{active:n,className:r}=e,i=n===void 0?!0:n,a=kr(i),o;t[0]===r?o=t[1]:(o=f(`flex items-center gap-2`,jr,r),t[0]=r,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Jn,{className:Ar}),t[2]=s):s=t[2];let c=i?`animate-shimmer`:`text-muted-foreground`,l;t[3]===c?l=t[4]:(l=f(`text-sm`,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 Nr(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=l):l=t[1];let u=n.length===0?`Start or connect your first project`:`Select a project to start coding`,d;t[2]===u?d=t[3]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[l,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:u})]})]}),t[2]=u,t[3]=d);let f;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(W,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[8]=i,t[9]=r,t[10]=e):e=t[10],f=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=f}else f=t[7];let p,m,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Pe,{className:`h-5 w-5 text-muted-foreground`}),m=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),h=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=p,t[12]=m,t[13]=h):(p=t[11],m=t[12],h=t[13]);let g;t[14]===a?g=t[15]:(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:a,children:[p,m,h]}),t[14]=a,t[15]=g);let _,v,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ke,{className:`h-5 w-5 text-muted-foreground`}),v=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),y=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=_,t[17]=v,t[18]=y):(_=t[16],v=t[17],y=t[18]);let b;t[19]===o?b=t[20]:(b=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[_,v,y]}),t[19]=o,t[20]=b);let x,S,C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ae,{className:`h-5 w-5 text-muted-foreground`}),S=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),C=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=x,t[22]=S,t[23]=C):(x=t[21],S=t[22],C=t[23]);let w;t[24]===s?w=t[25]:(w=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[x,S,C]}),t[24]=s,t[25]=w);let T;t[26]!==b||t[27]!==w||t[28]!==f||t[29]!==g?(T=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[f,g,b,w]}),t[26]=b,t[27]=w,t[28]=f,t[29]=g,t[30]=T):T=t[30];let E;return t[31]!==T||t[32]!==d?(E=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[d,T]}),t[31]=T,t[32]=d,t[33]=E):E=t[33],E}function Pr(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 Fr(e){let t=(0,Q.c)(24),{project:n}=e,{setDevServerRunning:r}=tn(),[i,a]=(0,Z.useState)(!1),{startServer:o}=an(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Me(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,Z.useEffect)(s,l),n?.name;let u=n?.name??`your project`,d;t[5]===u?d=t[6]:(d=Pr(u),t[5]=u,t[6]=d);let f=d,p=!i&&n?.runCommand,m;t[7]!==n||t[8]!==o?(m=()=>{n&&o(n)},t[7]=n,t[8]=o,t[9]=m):m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[10]=g):g=t[10];let _=n?.name??`Project`,v;t[11]===_?v=t[12]:(v=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:_}),t[11]=_,t[12]=v);let y;t[13]===f?y=t[14]:(y=(0,$.jsx)(`p`,{className:`mt-2 text-base text-muted-foreground`,children:f}),t[13]=f,t[14]=y);let b;t[15]!==y||t[16]!==v?(b=(0,$.jsxs)(`div`,{className:`text-center`,children:[v,y]}),t[15]=y,t[16]=v,t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==p?(x=p&&(0,$.jsx)(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Start App`}),t[18]=h,t[19]=p,t[20]=x):x=t[20];let S;return t[21]!==b||t[22]!==x?(S=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6 px-4`,children:[g,b,x]})}),t[21]=b,t[22]=x,t[23]=S):S=t[23],S}var Ir=(0,Z.forwardRef)((e,t)=>{let n=(0,Q.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});Ir.displayName=`MessageList`;function Lr(e){let t=(0,Q.c)(19),{context:n}=e;if(!n)return null;let{isStreaming:r,isCreatingProject:i,isProcessingThread:a,hasPendingMessage:o,hasActiveAskUserBlock:s,streamingSegments:c,streamingModel:l,totalMessages:u,error:d,onClearError:p}=n,m=c.length>0||i||a&&(r||o),h=(r||o)&&!s,g;t[0]!==m||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==h||t[5]!==l||t[6]!==c||t[7]!==u?(g=m&&(r||i||a)&&(0,$.jsx)(Er,{segments:c,model:l,isCreatingProject:i,isProcessingThread:a,totalMessages:u,showProcessingLine:h}),t[0]=m,t[1]=i,t[2]=a,t[3]=r,t[4]=h,t[5]=l,t[6]=c,t[7]=u,t[8]=g):g=t[8];let _;t[9]!==m||t[10]!==h?(_=h&&(0,$.jsx)(`div`,{className:f(`px-4 pb-4`,m?`pt-0`:`pt-2`),children:(0,$.jsx)(Mr,{active:h})}),t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;t[12]!==d||t[13]!==p?(v=d&&(0,$.jsxs)(`div`,{className:`mx-4 my-2 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:p,children:`Dismiss`})]}),t[12]=d,t[13]=p,t[14]=v):v=t[14];let y;return t[15]!==g||t[16]!==_||t[17]!==v?(y=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-48`,children:[g,_,v]}),t[15]=g,t[16]=_,t[17]=v,t[18]=y):y=t[18],y}var Rr={List:Ir,Footer:Lr};function zr(e){let t=e.some(e=>e.type!==`long_running_confirmation`&&e.chunks.some(e=>e.includes(`"type":"tool_use"`)&&e.includes(`"name":"ask_user"`))),n=e.some(e=>e.type!==`long_running_confirmation`&&e.chunks.some(e=>e.includes(`"type":"tool_result"`)&&e.includes(`"name":"ask_user"`)));return t&&!n}function Br(e){let t=(0,Q.c)(67),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:l,selectedThreadId:u,selectedProjectId:d,projects:p,projectsLoading:m,messagesLoaded:h,onSelectThread:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b,error:x,onClearError:S}=e,C=(0,Z.useRef)(null),w=(0,Z.useRef)(0),T=(0,Z.useRef)(!1),E=(0,Z.useRef)(!1),D;t[0]===u?D=t[1]:(D=()=>{u&&C.current?.getState(e=>{c(u,e.scrollTop)})},t[0]=u,t[1]=D);let O=D,k,A;t[2]===O?(k=t[3],A=t[4]):(k=()=>{let e=()=>{O()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),O()}},A=[O],t[2]=O,t[3]=k,t[4]=A),(0,Z.useEffect)(k,A);let j,M;t[5]===O?(j=t[6],M=t[7]):(j=()=>{let e=setInterval(()=>{O()},5e3);return()=>clearInterval(e)},M=[O],t[5]=O,t[6]=j,t[7]=M),(0,Z.useEffect)(j,M);let N,P;t[8]!==n.length||t[9]!==h||t[10]!==u?(N=()=>{if(!u||!h||E.current||(E.current=!0,n.length===0))return;let e=qe(u);e!==null&&e>0&&requestAnimationFrame(()=>{C.current?.scrollTo({top:e})})},P=[u,h,n.length],t[8]=n.length,t[9]=h,t[10]=u,t[11]=N,t[12]=P):(N=t[11],P=t[12]),(0,Z.useEffect)(N,P);let F;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{E.current=!1,w.current=0},t[13]=F):F=t[13];let I;t[14]===u?I=t[15]:(I=[u],t[14]=u,t[15]=I),(0,Z.useEffect)(F,I);let L;t[16]!==l||t[17]!==r||t[18]!==n.length?(L=()=>{if(!E.current)return;let e=n.length>w.current,t=T.current&&!r;(r||l||e||t)&&requestAnimationFrame(()=>{C.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),w.current=n.length,T.current=r},t[16]=l,t[17]=r,t[18]=n.length,t[19]=L):L=t[19];let R;t[20]!==l||t[21]!==r||t[22]!==n||t[23]!==i.length?(R=[r,l,n,i.length],t[20]=l,t[21]=r,t[22]=n,t[23]=i.length,t[24]=R):R=t[24],(0,Z.useEffect)(L,R);let z=n.length===0&&!r&&!o&&!u,ee=h&&n.length===0&&!r&&!o&&!s&&!l&&u,te;if(t[25]!==p||t[26]!==d){let e;t[28]===d?e=t[29]:(e=e=>e.projectId===d,t[28]=d,t[29]=e),te=p.find(e),t[25]=p,t[26]=d,t[27]=te}else te=t[27];let B=te;if(z){let e=`transition-opacity duration-500 ease-in-out ${m?`opacity-0`:`opacity-100`}`,n;t[30]!==v||t[31]!==_||t[32]!==y||t[33]!==b||t[34]!==g||t[35]!==p?(n=(0,$.jsx)(Nr,{projects:p,onSelectProject:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b}),t[30]=v,t[31]=_,t[32]=y,t[33]=b,t[34]=g,t[35]=p,t[36]=n):n=t[36];let r;return t[37]!==e||t[38]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[37]=e,t[38]=n,t[39]=r):r=t[39],r}if(ee){let e;return t[40]===B?e=t[41]:(e=(0,$.jsx)(Fr,{project:B}),t[40]=B,t[41]=e),e}let V;t[42]===i?V=t[43]:(V=zr(i),t[42]=i,t[43]=V);let ne;t[44]!==x||t[45]!==l||t[46]!==o||t[47]!==s||t[48]!==r||t[49]!==n.length||t[50]!==S||t[51]!==a||t[52]!==i||t[53]!==V?(ne={isStreaming:r,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:l,hasActiveAskUserBlock:V,streamingSegments:i,streamingModel:a,totalMessages:n.length,error:x,onClearError:S},t[44]=x,t[45]=l,t[46]=o,t[47]=s,t[48]=r,t[49]=n.length,t[50]=S,t[51]=a,t[52]=i,t[53]=V,t[54]=ne):ne=t[54];let re=ne,ie;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(ie=f(`h-full overflow-hidden`),t[55]=ie):ie=t[55];let H;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(H={height:`100%`},t[56]=H):H=t[56];let U;t[57]!==l||t[58]!==o||t[59]!==s||t[60]!==r||t[61]!==u?(U=(e,t)=>(0,$.jsx)(Cr,{message:t,threadId:u,messageIndex:e,showCheckpointRestore:t.sender===`user`&&!!t.checkpointRef&&!r&&!l&&!o&&!s}),t[57]=l,t[58]=o,t[59]=s,t[60]=r,t[61]=u,t[62]=U):U=t[62];let W;return t[63]!==re||t[64]!==n||t[65]!==U?(W=(0,$.jsx)(`div`,{className:ie,children:(0,$.jsx)(ct,{ref:C,style:H,data:n,context:re,itemContent:U,overscan:500,components:Rr})}),t[63]=re,t[64]=n,t[65]=U,t[66]=W):W=t[66],W}async function Vr(e){return re(`api/projects/${r(e)}/todos`)}async function Hr(e,t){return H(`api/projects/${r(e)}/todos`,{description:t})}async function Ur(e,t,n){return V(`api/projects/${r(e)}/todos/${r(t)}`,n)}async function Wr(e,t){await Ye(`api/projects/${r(e)}/todos/${r(t)}`)}var Gr={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 Kr({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Gr[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 Ur(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:f(`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:`text-sm font-medium leading-tight`,children:e.title}),e.working&&(0,$.jsx)(O,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(k,{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)(q,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(k,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(ke,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var qr=`Please analyze this task and create a detailed implementation plan.
10
+
11
+ Task description:
12
+ {description}`,Jr="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Yr=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Xr=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
13
+ Directions:
14
+ Carefully read through the list of code changes creating a todo list of code to review.
15
+ Analyze the code structure, variable names, functions, and logic flow
16
+ Look for any syntax errors, bugs, or inefficiencies
17
+ Consider best practices for the specific programming language used
18
+ Provide clear and constructive feedback on areas that could be improved
19
+ If applicable, include examples of how to refactor problematic code
20
+ Offer praise for portions of the code that are well-written and follow best practices
21
+
22
+ Task description:
23
+ {description}`,Zr={plan:qr,test:Yr,review:Xr},Qr={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function $r(e,t){let n=e?.[Qr[t]];return n&&n.trim()?n:Zr[t]}function ei(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Jr.replace(/\{todoId\}/g,n)),i}var ti=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],ni={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 ri(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(`
24
+ `);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 ii(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function ai(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(`
25
+ `);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}function oi({projectId:e,addOpen:r,onAddOpenChange:i,onThreadSelect:a}){let{state:s,dispatch:c}=ft(),[l,u]=(0,Z.useState)([]),[d,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),[x,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),I=(0,Z.useCallback)(async()=>{try{let t=await Vr(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await v(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ur(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),u(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{p(!1)}},[e]);(0,Z.useEffect)(()=>{I()},[I]),(0,Z.useEffect)(()=>{if(!l.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Vr(e);u(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[l,e]),(0,Z.useEffect)(()=>{r&&_(``)},[r]);function L(e){_(e.description),h({todo:e})}function R(){h(null),_(``)}async function z(){if(g.trim()){b(!0);try{let t=await Hr(e,g);u(e=>[...e,t]),i(!1),_(``)}finally{b(!1)}}}async function ee(){if(!(!g.trim()||!m)){b(!0);try{let t=await Ur(e,m.todo.id,{description:g});u(e=>e.map(e=>e.id===t.id?t:e)),R()}finally{b(!1)}}}async function te(){if(m){b(!0);try{await Wr(e,m.todo.id),u(e=>e.filter(e=>e.id!==m.todo.id)),R()}finally{b(!1)}}}function B(e){u(t=>t.map(t=>t.id===e.id?e:t))}async function V(t){let n=s.selectedThreadId?s.projectModelSelections[s.selectedThreadId]:void 0,r=s.projects.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===s.selectedThreadId),a=n?.id??i?.model,l=n?.provider??i?.modelProvider;if(!a||!l)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 u=await ie(e);if(!u)return;let d=null,f=await ri(u,n=>{Ur(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{d=e,B(e)})});if(!f)return;d||B(await Ur(e,t.id,{status:`Plan`,working:!0,threadId:f}));let p=n??{id:a,provider:l,name:a,description:``};c({type:K.SetProjectModel,threadId:f,model:p}),C(f,{model:a,modelProvider:l});let m=await o(f,ei($r(r,`plan`),`plan`,t.id,t.description),a,[],void 0,l);m&&ii(m)}async function ne(t){let n=await ie(e);if(!n)return;let r=null,i=await ri(n,n=>{Ur(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,B(e)})});if(!i)return;r||B(await Ur(e,t.id,{status:`Build`,working:!0,threadId:i}));let a=await v(i),s=a.model,l=a.modelProvider;if(!s||!l)try{let t=(await re(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);c({type:K.SetProjectModel,threadId:i,model:{id:s,provider:l,name:s,description:``}}),C(i,{model:s,modelProvider:l}),console.log(`Sending chat message with provider:`,i,t.description,l);let u=await o(i,t.description,s,[],void 0,l);u&&ii(u)}async function H(n){try{let r=await ie(e);if(!r){w(!1),E(null);return}let i=null;if(i=await ri(r,e=>{i=e}),!i){w(!1),E(null);return}let a=await v(i),c=a.model,l=a.modelProvider;if(!c||!l)try{let t=(await re(`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){t(e,i),w(!1),E(null);return}let u=ei($r(s.projects.find(t=>t.projectId===e),`test`),`test`,n.id,n.description),d=await o(i,u,c,[],void 0,l);d&&A(await ai(d)),t(e,i)}catch(e){console.error(`Failed to generate test case:`,e),w(!1),E(null)}finally{M(!1)}}function U(e){E(e),A(``),M(!0),w(!0),H(e)}function W(){w(!1),E(null),A(``)}async function ae(){if(!T||!D.trim())return;let t=T,n=D;W(),P(!0);try{let r=await ie(e);if(!r)return;let i=null,a=await ri(r,n=>{Ur(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,B(e)})});if(!a)return;i||B(await Ur(e,t.id,{status:`Test`,working:!0,threadId:a}));let s=await v(a),l=s.model,u=s.modelProvider;if(!l||!u)try{let t=(await re(`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&&(l=t.model,u=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!l||!u)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);c({type:K.SetProjectModel,threadId:a,model:{id:l,provider:u,name:l,description:``}}),C(a,{model:l,modelProvider:u});let d=await o(a,n,l,[],void 0,u);d&&ii(d)}finally{P(!1)}}async function oe(t){let n=await ie(e);if(!n)return;let r=null,i=await ri(n,n=>{Ur(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,B(e)})});if(!i)return;r||B(await Ur(e,t.id,{status:`Review`,working:!0,threadId:i}));let a=await v(i),l=a.model,u=a.modelProvider;if(!l||!u)try{let t=(await re(`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&&(l=t.model,u=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!l||!u)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);c({type:K.SetProjectModel,threadId:i,model:{id:l,provider:u,name:l,description:``}}),C(i,{model:l,modelProvider:u});let d=await o(i,ei($r(s.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),l,[],void 0,u);d&&ii(d)}async function se(t,n){n===`Plan`?await V(t):n===`Build`?await ne(t):n===`Test`?U(t):n===`Review`?await oe(t):B(await Ur(e,t.id,{status:n,working:n!==`Done`}))}return d?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(O,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):(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:ti.map(t=>{let n=l.filter(e=>e.status===t),r=t===`Ready`;return(0,$.jsxs)(`div`,{className:f(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,ni[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-muted-foreground uppercase tracking-wide`,children:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:n.length})]}),(0,$.jsx)(S,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r&&(0,$.jsxs)(k,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>i(!0),children:[(0,$.jsx)(Ue,{className:`h-3 w-3 mr-1`}),`Add Task`]}),n.map(t=>(0,$.jsx)(Kr,{todo:t,projectId:e,onUpdate:B,onEdit:L,onAction:se,onThreadSelect:a},t.id))]})})]},t)})}),(0,$.jsx)(F,{open:r,onOpenChange:i,children:(0,$.jsxs)(n,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(St,{placeholder:`Describe what needs to be done...`,value:g,onChange:e=>_(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&z()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(ze,{children:(0,$.jsx)(k,{onClick:()=>void z(),disabled:y||!g.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(F,{open:x,onOpenChange:e=>!e&&W(),children:(0,$.jsxs)(n,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:j?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(St,{value:D,onChange:e=>A(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(k,{variant:`outline`,onClick:W,disabled:j,children:`Cancel`}),(0,$.jsx)(k,{onClick:()=>void ae(),disabled:j||!D.trim()||N,children:N?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(F,{open:m!==null,onOpenChange:e=>!e&&R(),children:(0,$.jsxs)(n,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(Ae,{children:(0,$.jsx)(Le,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(St,{placeholder:`Describe what needs to be done...`,value:g,onChange:e=>_(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&ee()}})}),(0,$.jsxs)(ze,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(k,{variant:`destructive`,onClick:()=>void te(),disabled:y,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(k,{onClick:()=>void ee(),disabled:y||!g.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var si=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:qr},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Xr},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Yr}];function ci({open:e,onOpenChange:t,projectId:r}){let{state:i}=ft(),[a,o]=(0,Z.useState)({plan:``,review:``,test:``}),[s,c]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e)return;let t=i.projects.find(e=>e.projectId===r);o({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,r,i.projects]);async function l(){c(!0);try{await T(r,{planPrompt:a.plan.trim()===qr?null:a.plan.trim()||null,testPrompt:a.test.trim()===Yr?null:a.test.trim()||null,reviewPrompt:a.review.trim()===Xr?null:a.review.trim()||null}),ue(),X({title:`AI prompt settings saved`}),t(!1)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{c(!1)}}function u(e,t){o(n=>({...n,[e]:t}))}return(0,$.jsx)(F,{open:e,onOpenChange:t,children:(0,$.jsxs)(n,{className:`max-w-2xl`,children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Le,{children:`AI Prompt Settings`}),(0,$.jsx)(he,{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)(fn,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(dn,{className:`w-full`,children:si.map(e=>(0,$.jsx)(ln,{value:e.value,className:`flex-1`,children:e.label},e.value))}),si.map(e=>(0,$.jsxs)(un,{value:e.value,children:[(0,$.jsx)(St,{value:a[e.value]||e.defaultPrompt,onChange:t=>u(e.value,t.target.value),className:`min-h-[250px] font-mono text-sm resize-none`,placeholder:e.defaultPrompt,disabled:s}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:[`Use `,(0,$.jsx)(`code`,{className:`text-xs`,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(ze,{children:(0,$.jsx)(k,{onClick:()=>void l(),disabled:s,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function li({projectId:e}){let{state:t,dispatch:n}=ft(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=Qe(),{setActiveMainTab:l}=tn();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await dt(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-CV8HzCCA.js`).then(e=>e.M);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([0,1]));a();let o=await r();n({type:K.SetProjects,projects:o.projects});let s=o.projects.find(t=>t.projectId===e);if(s&&s.threads.find(e=>e.threadId===i)){(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:K.SelectThread,threadId:i,projectId:e});try{let e=await E();n({type:K.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after thread selection:`,e)}}}catch(r){console.error(`Failed to refresh projects for thread selection:`,r),(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:K.SelectThread,threadId:i,projectId:e});try{let e=await E();n({type:K.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)(oi,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(k,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(Te,{className:`h-4 w-4`})}),(0,$.jsx)(ci,{open:o,onOpenChange:s,projectId:e})]})}var ui=(0,Z.lazy)(()=>dt(()=>import(`./diff-view-CuEdnFtI.js`),__vite__mapDeps([2,1,3,4,5,6,0,7,8,9,10,11,12,13,14,15,16,17,18,19]))),di=(0,Z.lazy)(()=>dt(()=>import(`./dialogs-config-CV8HzCCA.js`).then(e=>e.t),__vite__mapDeps([0,1]))),fi=40,pi=`linear-gradient(to right, transparent 0, transparent ${fi}px, hsl(var(--background)) ${fi}px)`,mi=`linear-gradient(to top, hsl(var(--background)) 0, hsl(var(--background)) calc(100% - ${fi}px), transparent calc(100% - ${fi}px), transparent 100%), linear-gradient(to right, transparent 0, transparent ${fi}px, hsl(var(--background)) ${fi}px)`;function hi(e){let t=(0,Q.c)(54),{onCreateThread:n}=e,{state:r,dispatch:i}=ft(),a=Qe(),o=rt(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),{selectedThreadId:d,messages:f,isCreatingProject:p,processingThreadIds:m,projects:g,projectsLoading:_,messagesLoaded:v,isStreaming:y,streamingSegments:b,streamingModel:x,pendingChatMessage:S}=r,C;t[0]!==m||t[1]!==d?(C=d&&m.includes(d),t[0]=m,t[1]=d,t[2]=C):C=t[2];let w=!!C,T=S?.threadId===d,E;t[3]!==i||t[4]!==r.sidebarOpen?(E=()=>{r.sidebarOpen&&i({type:K.ToggleSidebar})},t[3]=i,t[4]=r.sidebarOpen,t[5]=E):E=t[5];let D=E,O;t[6]===D?O=t[7]:(O=()=>{D(),u(`clone`),c(!0)},t[6]=D,t[7]=O);let k=O,A;t[8]===D?A=t[9]:(A=()=>{D(),u(`webapp`),c(!0)},t[8]=D,t[9]=A);let j=A,M;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=async(e,t)=>{try{await ne(e,t),c(!1),u(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=M):M=t[10];let N=M,P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=async(e,t,n)=>{try{await h(e,t,n),c(!1),u(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=P):P=t[11];let F=P,I;t[12]===D?I=t[13]:(I=async()=>{D();try{await fe(),c(!1),u(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=D,t[13]=I);let L=I,R=o.pathname===`/review`,z=o.pathname===`/todos`,ee;t[14]===a?ee=t[15]:(ee=()=>{a(`/`)},t[14]=a,t[15]=ee);let te=ee,{selectedProjectId:B}=r,V;t[16]!==D||t[17]!==i||t[18]!==k||t[19]!==te||t[20]!==j||t[21]!==L||t[22]!==T||t[23]!==p||t[24]!==w||t[25]!==y||t[26]!==f||t[27]!==v||t[28]!==n||t[29]!==g||t[30]!==_||t[31]!==R||t[32]!==B||t[33]!==d||t[34]!==x||t[35]!==b||t[36]!==z?(V=z&&B?(0,$.jsx)(li,{projectId:B}):R&&d?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(ui,{threadId:d,onExit:te})}):(0,$.jsx)(Br,{messages:f,isStreaming:y,streamingSegments:b,streamingModel:x,isCreatingProject:p,isProcessingThread:w,hasPendingMessage:T,selectedThreadId:d,selectedProjectId:B,projects:g,projectsLoading:_,messagesLoaded:v,onSelectThread:(e,t)=>{D(),i({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:k,onNewApp:j,onOpenFolder:L,error:null,onClearError:gi}),t[16]=D,t[17]=i,t[18]=k,t[19]=te,t[20]=j,t[21]=L,t[22]=T,t[23]=p,t[24]=w,t[25]=y,t[26]=f,t[27]=v,t[28]=n,t[29]=g,t[30]=_,t[31]=R,t[32]=B,t[33]=d,t[34]=x,t[35]=b,t[36]=z,t[37]=V):V=t[37];let re;t[38]!==f||t[39]!==R||t[40]!==d||t[41]!==z?(re=!R&&!z&&d&&(0,$.jsxs)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pr-4`,children:[(0,$.jsx)(`div`,{className:`h-6`,style:{backgroundImage:mi}}),(0,$.jsx)(`div`,{className:`h-8`,style:{backgroundImage:pi}}),(0,$.jsx)(`div`,{style:{backgroundImage:pi},children:(0,$.jsx)(zt,{messages:f})})]}),t[38]=f,t[39]=R,t[40]=d,t[41]=z,t[42]=re):re=t[42];let ie=l??void 0,H;t[43]!==s||t[44]!==L||t[45]!==ie?(H=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(di,{open:s,onOpenChange:c,initialMode:ie,onSubmitClone:N,onSubmitWebApp:F,onOpenFolder:L})}),t[43]=s,t[44]=L,t[45]=ie,t[46]=H):H=t[46];let U;t[47]!==re||t[48]!==H||t[49]!==V?(U=(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[V,re,H]}),t[47]=re,t[48]=H,t[49]=V,t[50]=U):U=t[50];let W;return t[51]!==d||t[52]!==U?(W=(0,$.jsx)(Nt,{threadId:d,children:U}),t[51]=d,t[52]=U,t[53]=W):W=t[53],W}function gi(){}var _i=`VS Code`;function vi(e){return e||ce(_i)}var yi={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function bi({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(()=>vi(n)),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await xe();o(e);let t=vi(n);e.includes(t)?c(t):e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([_i])}finally{u(!1)}})()},[]),(0,Z.useEffect)(()=>{if(n&&a.includes(n)){c(n);return}let e=ce(_i);!n&&a.includes(e)&&c(e)},[n,a]);async function d(t){c(t),We(t),await P(e,t)}let f=async n=>{try{i(!0),await d(n),t?await Ve(t,n):await Ee(e,n),X({title:`Success`,description:`Opened project in ${n}`})}catch(e){console.error(`Failed to open project in ${n}:`,e);let t=`Failed to open project in ${n}`;if(e instanceof Error){let n=e;t=n.details?n.details:e.message}X({title:`Error`,description:t,variant:`destructive`})}finally{i(!1)}};async function p(e){try{await d(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),X({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}return l?(0,$.jsx)(k,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(k,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await f(s)},title:`Open in ${s}`,children:(0,$.jsx)(`img`,{src:`/ide/${yi[s]||yi[_i]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(Lt,{children:[(0,$.jsx)(Mt,{asChild:!0,children:(0,$.jsx)(k,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(G,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(jt,{align:`end`,children:a.map(e=>(0,$.jsxs)(Tt,{onClick:()=>void p(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${yi[e]||yi[_i]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}var xi=`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 Si({open:e,onOpenChange:t,projectId:r,commands:i,onRefresh:a}){let[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(0),[y,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),w=()=>{s({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),g([])},T=e=>{s({...e}),p(!1),g([])},E=async()=>{try{x(!0);let e=await u(r);g(e.scripts),v(0),p(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),X({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{x(!1)}},D=e=>{s(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),g([]),S.current?.focus()},O=e=>{d&&(e.key===`ArrowDown`?(e.preventDefault(),v(e=>e<h.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),v(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),_<h.length&&D(h[_])):e.key===`Escape`&&(e.preventDefault(),p(!1),g([])))};(0,Z.useEffect)(()=>{let e=e=>{C.current&&!C.current.contains(e.target)&&(p(!1),g([]))};return d&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[d]);let A=async e=>{try{await b(r,e),X({title:`Success`,description:`Command deleted`}),a()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(F,{open:e,onOpenChange:t,children:(0,$.jsxs)(n,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Le,{children:`Project Commands`}),(0,$.jsx)(he,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:o?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(oe,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(se,{id:`name`,value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(oe,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(St,{ref:S,id:`commandLine`,value:o.commandLine,onChange:e=>s({...o,commandLine:e.target.value}),onKeyDown:O,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(Ct,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(k,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void E(),disabled:y,children:(0,$.jsx)(G,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),d&&(0,$.jsx)(`div`,{ref:C,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:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[(0,$.jsx)(G,{className:`h-3 w-3`}),`Available Scripts `,y&&`(loading...)`]}),h.length>0?(()=>{let e={};h.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:`px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 bg-muted/30`,children:t}),r.map(e=>{let t=n===_;return n++,(0,$.jsxs)(`button`,{type:`button`,className:f(`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:()=>D(e),onMouseEnter:()=>v(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:y?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(oe,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(se,{id:`relativeFolder`,value:o.relativeFolder??``,onChange:e=>s({...o,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,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)(oe,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:xi.map(e=>{let t=m[e]||pe;return(0,$.jsx)(k,{variant:o.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>s({...o,icon:e}),title:e,children:(0,$.jsx)(t,{className:`h-4 w-4`})},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:()=>s(null),children:[(0,$.jsx)(Fe,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(k,{size:`sm`,onClick:async()=>{if(!o?.name||!o?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{l(!0),await ve(r,o),X({title:`Success`,description:`Command saved`}),s(null),a()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{l(!1)}},disabled:c,children:[(0,$.jsx)(He,{className:`h-4 w-4 mr-2`}),` `,c?`Saving...`:`Save Command`]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2`,children:[i.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>T(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(m[e.icon]||Je,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground 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)(k,{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(),A(e.id)},children:(0,$.jsx)(me,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(k,{variant:`outline`,className:`w-full border-dashed`,onClick:w,children:[(0,$.jsx)(Ue,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Ci(){let e=(0,Q.c)(27),{state:t}=ft(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=yt(r),[o,s]=(0,Z.useState)(!1),c,l,u,d,f;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){f=Symbol.for(`react.early_return_sentinel`);bb0:{let o;e[10]===n?o=e[11]:(o=e=>e.projectId===n,e[10]=n,e[11]=o),c=i.find(o)?.commands??[];let p;e[12]!==a||e[13]!==n||e[14]!==r?(p=e=>{!n||!r||a({type:K.QueueTerminalCommand,threadId:r,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=a,e[13]=n,e[14]=r,e[15]=p):p=e[15];let h=p,g;if(e[16]===a?g=e[17]:(g=async()=>{a({type:K.ConfigUpdated})},e[16]=a,e[17]=g),l=g,!n){f=null;break bb0}u=`flex items-center gap-1`,d=c.length===0?(0,$.jsx)(Ct,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(k,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(Be,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ct,{children:[c.map(e=>{let n=m[e.icon]||Je;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(k,{variant:`action`,size:`icon-md`,onClick:()=>h({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(n,{})})}),(0,$.jsx)(q,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(k,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(Be,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})]})})}e[0]=a,e[1]=i,e[2]=n,e[3]=r,e[4]=t.isRunningCommand,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f}else c=e[5],l=e[6],u=e[7],d=e[8],f=e[9];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;e[18]!==c||e[19]!==l||e[20]!==n||e[21]!==o?(p=(0,$.jsx)(Si,{open:o,onOpenChange:s,projectId:n,commands:c,onRefresh:l}),e[18]=c,e[19]=l,e[20]=n,e[21]=o,e[22]=p):p=e[22];let h;return e[23]!==u||e[24]!==d||e[25]!==p?(h=(0,$.jsxs)(`div`,{className:u,children:[d,p]}),e[23]=u,e[24]=d,e[25]=p,e[26]=h):h=e[26],h}function wi(e){let t=(0,Q.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 Ti({threadId:e}){let{dispatch:t}=ft(),{setTerminalNotification:n}=tn(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(new Set),c=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>((async()=>{try{let t=await p(e);if(t.length===0){i(null);return}i(t),o(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{i(null)}})(),()=>{for(let e of c.current.values())e.abort();c.current.clear()}),[e]);let l=async r=>{if(a.has(r.name)){let n=c.current.get(r.name);n&&(n.abort(),c.current.delete(r.name));try{await s(e,r.name)}catch{}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${r.friendlyName} stopped`}}),o(e=>{let t=new Set(e);return t.delete(r.name),t})}else{let i=new AbortController;c.current.set(r.name,i),o(e=>new Set([...e,r.name])),n(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${r.friendlyName}`}});try{let n=await be(e,r.name,r.command,{signal:i.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
26
+ `);a=s.pop()??``;for(let n of s)if(n.trim())try{let r=JSON.parse(n);typeof r==`string`?t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&t({type:K.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}})}}if(a.trim())try{let n=JSON.parse(a);typeof n==`string`?t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}}):n.type===`error`&&t({type:K.AppendTerminalLine,threadId:e,line:{type:`error`,content:n.message}})}catch{t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{r.releaseLock()}}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${r.friendlyName} done`}})}catch{}finally{c.current.delete(r.name),o(e=>{let t=new Set(e);return t.delete(r.name),t})}}};if(!r)return null;let u=r.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),d=Object.entries(u).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),f=d.length>1;return(0,$.jsxs)(Lt,{children:[(0,$.jsx)(Ct,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(Mt,{asChild:!0,children:(0,$.jsx)(k,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Oe,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(jt,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Et,{children:e}),(0,$.jsx)(Rt,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Tt,{onClick:()=>{l(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):d[0]?.[1].map(e=>(0,$.jsxs)(Tt,{onClick:()=>{l(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}function Ei(){let e=(0,Q.c)(40),{state:t,dispatch:n}=ft(),{selectedThreadId:r,selectedProjectId:i,projects:o,sidebarOpen:s}=t,c;if(e[0]!==o||e[1]!==i){let t;e[3]===i?t=e[4]:(t=e=>e.projectId===i,e[3]=i,e[4]=t),c=o.find(t),e[0]=o,e[1]=i,e[2]=c}else c=e[2];let l=c,u=!s,d=u&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2`,p;e[5]===d?p=e[6]:(p=f(d),e[5]=d,e[6]=p);let m;e[7]===n?m=e[8]:(m=()=>n({type:K.ToggleSidebar}),e[7]=n,e[8]=m);let h;e[9]===s?h=e[10]:(h=s?(0,$.jsx)(Ge,{className:`h-4 w-4`}):(0,$.jsx)(a,{className:`h-4 w-4`}),e[9]=s,e[10]=h);let g;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=g):g=e[11];let _;e[12]!==m||e[13]!==h?(_=(0,$.jsxs)(k,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,onClick:m,children:[h,g]}),e[12]=m,e[13]=h,e[14]=_):_=e[14];let v;e[15]!==o||e[16]!==i||e[17]!==r?(v=r&&(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-2xl font-bold text-foreground`,children:L(o,i)}),(0,$.jsx)(`span`,{className:`text-base text-muted-foreground`,children:Xe(o,r)})]}),e[15]=o,e[16]=i,e[17]=r,e[18]=v):v=e[18];let y;e[19]!==_||e[20]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,v]}),e[19]=_,e[20]=v,e[21]=y):y=e[21];let b=u?`ml-0`:`ml-auto`,x;e[22]===b?x=e[23]:(x=f(`flex flex-wrap items-center justify-end gap-2`,b,`md:ml-auto`),e[22]=b,e[23]=x);let S;e[24]!==l?.runCommand||e[25]!==i||e[26]!==r?(S=i&&(0,$.jsxs)(wi,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(on,{projectId:i,runCommand:l?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ti,{threadId:r}),(0,$.jsx)(Ci,{})]})]}),e[24]=l?.runCommand,e[25]=i,e[26]=r,e[27]=S):S=e[27];let C;e[28]!==l?.openWith||e[29]!==i||e[30]!==r?(C=r&&i&&(0,$.jsx)(wi,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(bi,{projectId:i,threadId:r,openWith:l?.openWith})}),e[28]=l?.openWith,e[29]=i,e[30]=r,e[31]=C):C=e[31];let w;e[32]!==x||e[33]!==S||e[34]!==C?(w=(0,$.jsxs)(`div`,{className:x,children:[S,C]}),e[32]=x,e[33]=S,e[34]=C,e[35]=w):w=e[35];let T;return e[36]!==w||e[37]!==p||e[38]!==y?(T=(0,$.jsxs)(pn,{className:p,children:[y,w]}),e[36]=w,e[37]=p,e[38]=y,e[39]=T):T=e[39],T}function Di(e){let t=(0,Q.c)(13),{open:n,projectName:r,onOpenChange:i,onConfirm:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Kt,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(Zt,{children:[o,(0,$.jsxs)(Gt,{children:[`Are you sure you want to delete`,` `,(0,$.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[`"`,r,`"`]}),`? This will remove the project and all its data. This action cannot be undone.`]})]}),t[1]=r,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Xt,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(Yt,{children:[c,(0,$.jsx)(Jt,{onClick:a,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[4]=a,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,$.jsxs)(qt,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==i||t[10]!==n||t[11]!==u?(d=(0,$.jsx)(Qt,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function Oi(e){let t=(0,Q.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)(Kt,{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)(Zt,{children:[o,(0,$.jsxs)(Gt,{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(ki),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)(Xt,{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)(Jt,{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)(Yt,{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)(qt,{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)(Qt,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function ki(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:`font-medium text-sm`,children:r||`root`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i})]})]})},t)}function Ai(){let e=(0,Q.c)(6),[t,n]=(0,Z.useState)(!0),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=!0;return(async()=>{try{let t=await fetch(`${g()}/health`,{method:`GET`});e&&n(t.ok)}catch{e&&n(!1)}})(),()=>{e=!1}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a=ji;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=g(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(Zt,{children:[(0,$.jsx)(Kt,{children:`Service unavailable`}),(0,$.jsx)(Gt,{children:`Service is not currently up. Please ensure the backend is running at the address below, then retry.`})]}),l=(0,$.jsx)(`div`,{className:`rounded-md bg-muted px-3 py-2 text-xs font-mono text-muted-foreground`,children:s}),e[3]=c,e[4]=l):(c=e[3],l=e[4]);let u;return e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Qt,{open:!0,children:(0,$.jsxs)(qt,{children:[c,l,(0,$.jsx)(Yt,{children:(0,$.jsx)(k,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function ji(){window.location.assign(window.location.href)}var Mi=ot,Ni=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(`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)(nt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ni.displayName=nt.displayName;var Pi=i(`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`}}),Fi=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(Pi({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)($e,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Fi.displayName=$e.displayName;var Ii=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm 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`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(tt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ii.displayName=tt.displayName;var Li=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(`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)(Fe,{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)(st,{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});Li.displayName=st.displayName;var Ri=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(`text-sm font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(et,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ri.displayName=et.displayName;var zi=Z.forwardRef((e,t)=>{let n=(0,Q.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=f(`text-sm opacity-90`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Ze,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});zi.displayName=Ze.displayName;function Bi(){let e=(0,Q.c)(5),{toasts:t}=Ut(),n;e[0]===t?n=e[1]:(n=t.map(Vi),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Ni,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(Mi,{children:[n,r]}),e[3]=n,e[4]=i),i}function Vi(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(Fi,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(Ri,{children:n}),r&&(0,$.jsx)(zi,{children:r})]}),i,(0,$.jsx)(Li,{})]},t)}function Hi(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=sn(),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,Z.useEffect)(r,i),null}function Ui(e){let t=(0,Q.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)(Hi,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(cn,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Wi(e){let{state:n,dispatch:r}=ft(),{toast:i}=Ut(),a=yt(`project-creation`).dispatch,[o,s]=(0,Z.useState)(null),c=(0,Z.useCallback)(async()=>{try{r({type:K.SetProjectsLoading,projectsLoading:!0});let e=await y();r({type:K.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{r({type:K.SetProjectsLoading,projectsLoading:!1})}},[r]),l=(0,Z.useCallback)(async(e,t)=>{try{await ee(e,t)}catch(e){console.error(`Failed to select thread:`,e)}(n.selectedThreadId!==t||n.selectedProjectId!==e)&&r({type:K.SelectThread,threadId:t,projectId:e})},[r,n.selectedThreadId,n.selectedProjectId]),u=(0,Z.useCallback)(async t=>{r({type:K.SetCreatingProject,isCreating:!0});try{let n=await t.apiCall();if(!n){r({type:K.SetCreatingProject,isCreating:!1}),await c();return}let i=t.useTerminalDispatch?a:r;i({type:K.ClearTerminalOutput}),i({type:K.SetTerminalOpen,open:!0}),i({type:K.AppendTerminalLine,line:{type:`system`,content:t.initialMessage}});let o=n.getReader(),l=new TextDecoder,u=``,d=null,f=!1,p=null,m=null;for(;;){let{done:e,value:n}=await o.read();if(e)break;u+=l.decode(n,{stream:!0});let a=u.split(`
27
+ `);u=a.pop()??``;for(let e of a){let n=e.trim();if(n)try{let e=JSON.parse(n);if(e.type===`progress`)!f&&e.threadId&&e.projectId&&(f=!0,p=e.projectId,m=e.threadId,r({type:K.AddCreatingProject,projectId:e.projectId,threadId:e.threadId,projectName:t.optimisticProjectName,gitUrl:t.gitUrl??``}),r({type:K.AddProcessingThread,threadId:e.threadId})),r({type:K.AppendTerminalLine,...t.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`output`,content:e.message}});else if(e.type===`complete`){if(e.project){d=e.project.id;let n=t.includeThreadPath&&e.project.threads?.length>0?`${e.project.path}/${e.project.threads[0]}`:e.project.path;i({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${n}`}}),r({type:K.SetTerminalOpen,open:!1}),t.handleSetupScript&&e.suggestedSetupScript&&s({projectId:e.project.id,command:e.suggestedSetupScript,remainingScripts:e.project.pendingSetupScripts??[]})}}else e.type===`error`&&(f&&p&&(r({type:K.RemoveCreatingProject,projectId:p}),m&&r({type:K.RemoveProcessingThread,threadId:m})),r({type:K.AppendTerminalLine,...t.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`error`,content:`Error: ${e.message}`}}))}catch(e){console.error(`Failed to parse ${t.logTag} event`,e)}}}r({type:K.SetCreatingProject,isCreating:!1}),f&&m&&r({type:K.RemoveProcessingThread,threadId:m}),ue();let h=await y();if(r({type:K.SetProjects,projects:h.projects}),r({type:K.SetProjectsLoading,projectsLoading:!1}),d){let t=h.projects.find(e=>e.projectId===d);if(t&&t.threads.length>0){let e=t.threads[0].threadId;r({type:K.SelectThread,threadId:e,projectId:d,focusInput:!0})}e?.onProjectCreated?.(d)}}catch(e){console.error(`Failed to ${t.logTag}:`,e),r({type:K.SetCreatingProject,isCreating:!1}),(t.useTerminalDispatch?a:r)({type:K.AppendTerminalLine,line:{type:`error`,content:`${t.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[r,c,a,e?.onProjectCreated]),f=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await u({apiCall:()=>ne(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[u]),p=(0,Z.useCallback)(async(e,t,n)=>{await u({apiCall:()=>h(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[u]),m=(0,Z.useCallback)(async(e,t)=>{try{let a=t??(()=>{let t=n.projects.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 ie(e,t);if(!o){await c();return}let s=o.getReader(),l=new TextDecoder,u=``,d=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${a}"...`}];try{for(;;){let{done:t,value:n}=await s.read();if(t)break;u+=l.decode(n,{stream:!0});let o=u.split(`
28
+ `);u=o.pop()??``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);if(t.type===`progress`){if(!d&&t.threadId){d=!0,f=t.threadId,r({type:K.AddCreatingThread,projectId:e,threadId:t.threadId,title:a}),r({type:K.AddProcessingThread,threadId:t.threadId}),r({type:K.ClearTerminalOutput,threadId:f});for(let e of m)r({type:K.AppendTerminalLine,threadId:f,line:e});m.length=0}let n={type:`output`,content:t.message};f?r({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n)}else if(t.type===`error`){d&&f&&(r({type:K.RemoveCreatingThread,projectId:e,threadId:f}),r({type:K.RemoveProcessingThread,threadId:f}));let n={type:`error`,content:`Error: ${t.message}`};f?r({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n),console.error(`Thread creation error:`,t.message),i({title:`Thread Creation Failed`,description:t.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}d&&f&&r({type:K.RemoveProcessingThread,threadId:f}),ue(),await c(),f&&p&&r({type:K.SelectThread,threadId:f,projectId:e,focusInput:!0})}catch(t){throw d&&f&&(r({type:K.RemoveCreatingThread,projectId:e,threadId:f}),r({type:K.RemoveProcessingThread,threadId:f})),i({title:`Thread Creation Failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`}),t}}catch(e){console.error(`Failed to create thread:`,e);let t=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw r({type:K.AppendTerminalLine,line:{type:`error`,content:t}}),i({variant:`destructive`,title:`Thread Creation Failed`,description:t}),e}},[c,r,n.projects,i]),g=(0,Z.useCallback)(async(e,i)=>{r({type:K.AddDeletingThread,threadId:i}),r({type:K.ClearChatInputDraft,threadId:i});try{await t(e,i),ue(),await c(),n.selectedThreadId===i&&r({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{r({type:K.RemoveDeletingThread,threadId:i})}},[c,n.selectedThreadId,r]),_=(0,Z.useCallback)(async e=>{r({type:K.AddDeletingProject,projectId:e});let t=n.projects.find(t=>t.projectId===e)?.threads.map(e=>e.threadId)??[];for(let e of t)r({type:K.AddDeletingThread,threadId:e}),r({type:K.ClearChatInputDraft,threadId:e});try{await U(e),await c(),n.selectedProjectId===e&&r({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{r({type:K.RemoveDeletingProject,projectId:e});for(let e of t)r({type:K.RemoveDeletingThread,threadId:e})}},[c,n.selectedProjectId,n.projects,r]),v=(0,Z.useCallback)(async e=>{let t=o;if(s(null),!t||!e)return;let{projectId:n,command:i,remainingScripts:a}=t,l=[i,...a||[]];try{r({type:K.SetCreatingProject,isCreating:!0}),r({type:K.SetTerminalOpen,open:!0}),r({type:K.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${l.length} package${l.length===1?``:`s`}...`}});for(let e=0;e<l.length;e++){let t=l[e],i=t.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;r({type:K.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${l.length} in ${a}...`}}),r({type:K.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${t}`}});let o=await d(n,t,!0);if(o){let e=o.getReader(),t=new TextDecoder,n=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;n+=t.decode(a,{stream:!0});let o=n.split(`
29
+ `);n=o.pop()??``;for(let e of o)if(e.trim())try{let t=JSON.parse(e);typeof t==`string`?r({type:K.AppendTerminalLine,line:{type:`output`,content:t}}):t.type===`error`&&r({type:K.AppendTerminalLine,line:{type:`error`,content:t.message}})}catch{r({type:K.AppendTerminalLine,line:{type:`output`,content:e}})}}if(n.trim())try{let e=JSON.parse(n);typeof e==`string`?r({type:K.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&r({type:K.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{r({type:K.AppendTerminalLine,line:{type:`output`,content:n}})}}e<l.length-1&&(r({type:K.AppendTerminalLine,line:{type:`system`,content:``}}),r({type:K.AppendTerminalLine,line:{type:`system`,content:`---`}}),r({type:K.AppendTerminalLine,line:{type:`system`,content:``}}))}r({type:K.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),r({type:K.SetCreatingProject,isCreating:!1}),await c()}catch(e){r({type:K.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),r({type:K.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[o,r,c]);(0,Z.useEffect)(()=>{let e=!0;async function t(){try{r({type:K.SetProjectsLoading,projectsLoading:!0});let t=await y();if(!e)return;if(r({type:K.SetProjects,projects:t.projects}),!n.selectedThreadId)for(let e of t.projects){let t=e.threads.find(e=>e.isSelected);if(t){r({type:K.SelectThread,threadId:t.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{e&&r({type:K.SetProjectsLoading,projectsLoading:!1})}}return t(),()=>{e=!1}},[r,n.selectedThreadId,n.configUpdatedAt]);let b=(0,Z.useCallback)(async()=>{await u({apiCall:fe,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[u]);return{projects:n.projects,selectedProjectId:n.selectedProjectId,selectedThreadId:n.selectedThreadId,refreshProjects:c,handleSelectThread:l,handleCreateProject:f,handleCreateWebApp:p,handleOpenFolder:b,handleCreateThread:m,handleDeleteThread:g,confirmDeleteProject:_,pendingSetupScriptConfirmation:o,resolveSetupScriptConfirmation:v}}function Gi(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(Ki),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,Z.useEffect)(r,i),t}function Ki(){return document.hasFocus()}var qi=null;function Ji(){qi??=new Audio(`/pop.wav`),qi.currentTime=0,qi.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Yi(){let{state:e,dispatch:t}=ft(),n=Gi(),r=(0,Z.useRef)(null),i=(0,Z.useRef)(!1),a=(0,Z.useRef)([]),o=(0,Z.useRef)(e),s=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{o.current=e},[e]),(0,Z.useEffect)(()=>{s.current=n},[n]);let c=(0,Z.useCallback)(async()=>{try{let e=Pt(await E()),n=a.current.filter(t=>!e.includes(t));for(let e of n)e!==o.current.selectedThreadId&&t({type:K.MarkThreadCompleted,threadId:e});return n.length>0&&!s.current&&Ji(),a.current=e,t({type:K.SetProcessingThreads,threadIds:e}),e}catch(e){return console.error(`Failed to fetch processing threads:`,e),[]}},[t]);(0,Z.useEffect)(()=>{let e=()=>{if(r.current||i.current)return;i.current=!0;let e=async()=>{let t=await c(),n=Object.values(o.current.threadStreamingStates).some(e=>e.isStreaming);t.length>0||n||o.current.isCreatingProject?r.current=setTimeout(e,1e3):(r.current=null,i.current=!1)};e()},t=()=>{r.current&&=(clearTimeout(r.current),null),i.current=!1};return e(),()=>{t()}},[e.processingThreadIds.length,Object.values(e.threadStreamingStates).some(e=>e.isStreaming),e.isCreatingProject,c]);let l=(0,Z.useCallback)(e=>{t({type:K.ClearThreadCompleted,threadId:e})},[t]);return{processingThreadIds:e.processingThreadIds,completedThreadIds:e.completedThreadIds,isThreadProcessing:t=>e.processingThreadIds.includes(t),isThreadCompleted:t=>e.completedThreadIds.includes(t),clearCompleted:l}}var Xi=768;function Zi(){let e=(0,Q.c)(2),[t,n]=Z.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Xi-1}px)`),t=()=>{n(window.innerWidth<Xi)};return e.addEventListener(`change`,t),n(window.innerWidth<Xi),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Qi=(0,Z.lazy)(()=>dt(()=>import(`./terminal-panel-BG8UFUSX.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([20,1,0,11,12]))),$i=(0,Z.lazy)(()=>dt(()=>import(`./todos-view-DLC_0wx_.js`).then(e=>({default:e.TodosView})),[])),ea=(0,Z.lazy)(()=>dt(()=>import(`./diff-view-CuEdnFtI.js`),__vite__mapDeps([2,1,3,4,5,6,0,7,8,9,10,11,12,13,14,15,16,17,18,19]))),ta=(0,Z.lazy)(()=>dt(()=>import(`./explorer-tab-view-CiDUcvE2.js`),__vite__mapDeps([21,1,3,4,0,17,9,6,11,12]))),na=(0,Z.lazy)(()=>dt(()=>import(`./browser-tab-BVsBMyo3.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([22,1,0,23,6,10,11,12]))),ra=(0,Z.lazy)(()=>dt(()=>import(`./dialogs-config-CV8HzCCA.js`).then(e=>e.t),__vite__mapDeps([0,1]))),ia=(0,Z.lazy)(()=>dt(()=>import(`./onboarding-dialog-GjczsXqi.js`),__vite__mapDeps([24,7,1,6,0]))),aa=(0,Z.lazy)(()=>dt(()=>import(`./settings-view-cLrxaSw4.js`),__vite__mapDeps([25,1,3,4,0,26,27,28,17,9,6,18,11])));function oa(e){return e.startsWith(`/settings`)||e===`/review`||e===`/todos`}function sa(){let e=(0,Q.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 ca(){let{state:e,dispatch:t}=ft();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new En({})},[]);let n=Qe(),r=rt(),i=Zi(),[a,o]=(0,Z.useState)(null),{projects:s,handleSelectThread:c,handleCreateProject:l,handleCreateWebApp:u,handleOpenFolder:d,handleCreateThread:f,handleDeleteThread:p,confirmDeleteProject:m,refreshProjects:h,pendingSetupScriptConfirmation:g,resolveSetupScriptConfirmation:_}=Wi({onProjectCreated:o}),{processingThreadIds:v,completedThreadIds:y,clearCompleted:b}=Yi(),[x,S]=(0,Z.useState)(`chat`),[C,T]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(0),[R,z]=(0,Z.useState)(null),[ee,te]=(0,Z.useState)(0),{terminalState:V}=yt(e.selectedThreadId),ne=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{V.open&&e.selectedThreadId===ne.current&&!oa(r.pathname)&&S(`terminal`),ne.current=e.selectedThreadId},[V.open,e.selectedThreadId,r.pathname]);let[re,ie]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(!1),[W,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(null),[ce,G]=(0,Z.useState)(!1),[le,ue]=(0,Z.useState)(!1),de=(0,Z.useRef)(null),fe=r.pathname.startsWith(`/settings`),pe=r.pathname===`/review`,me=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&x===`tasks`&&S(`chat`)},[r.pathname]);let he=(0,Z.useRef)(x),ge=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(fe){if(ge.current===null){ge.current=Date.now(),he.current=x;return}he.current!==x&&n(`/`)}else ge.current=null;he.current=x},[x,fe,n]);let _e=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=fe||pe||me;if(n&&_e.current===null)_e.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&_e.current!==null){let n=_e.current;_e.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[fe,pe,me]),(0,Z.useEffect)(()=>{(async()=>{try{(await N()).updateAvailable&&G(!0)}catch{}})()},[]);let ve=(0,Z.useCallback)(async()=>{ue(!0);try{await D()}catch{ue(!1)}},[]);(0,Z.useEffect)(()=>{W||(async()=>{try{(await B()).onboardingCompleted||U(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ae(!0)}})()},[W]),(0,Z.useEffect)(()=>{H||t({type:K.ConfigUpdated})},[H,t]);let ye=(0,Z.useCallback)(e=>{let t=s.find(t=>t.projectId===e);t&&se({id:t.projectId,name:w(t)})},[s]),be=(0,Z.useCallback)(e=>{o(e),f(e,void 0)},[f]);(0,Z.useEffect)(()=>{a&&e.selectedProjectId===a&&e.selectedThreadId&&o(null)},[a,e.selectedProjectId,e.selectedThreadId]);let xe=(0,Z.useCallback)(async(a,s)=>{o(null),b(s),r.pathname!==`/`&&n(`/`),S(`chat`),e.selectedThreadId!==s&&te(e=>e+1),await c(a,s),i&&e.sidebarOpen&&t({type:K.ToggleSidebar})},[c,i,e.sidebarOpen,e.selectedThreadId,t,b,r.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?de.current?.expand():de.current?.collapse()},[e.sidebarOpen]);let Se={activeMainTab:x,setActiveMainTab:S,devServerUrl:C,setDevServerUrl:T,devServerRunning:E,setDevServerRunning:O,devServerLoading:k,setDevServerLoading:A,terminalNotification:j,setTerminalNotification:M,pendingExplorerPath:P,setPendingExplorerPath:F,explorerRefreshTick:I,triggerExplorerRefresh:()=>L(e=>e+1),explorerClearPath:R,setExplorerClearPath:z,browserResetTrigger:ee,triggerBrowserReset:()=>te(e=>e+1)};return(0,$.jsx)(nn.Provider,{value:Se,children:(0,$.jsxs)(Ct,{delayDuration:200,children:[(0,$.jsxs)(hn,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(mn,{ref:de,defaultSize:i?100:25,minSize:i?50:12,maxSize:i?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(kn,{projects:s,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:v,completedThreadIds:y,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:xe,onCreateProject:()=>ie(!0),onCreateThread:be,onDeleteThread:p,onDeleteProject:ye,onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ce,updatingApp:le,onUpdateApp:ve,expandProjectId:a})})}),!i&&(0,$.jsx)(gn,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(mn,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!pe&&!fe&&!me&&(0,$.jsx)(Ei,{}),!pe&&!fe&&!me&&e.selectedThreadId&&(0,$.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{onClick:()=>{S(t),t===`terminal`&&M(!1)},className:`relative px-4 py-2 text-base font-medium transition-colors ${x===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&j&&x!==`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${!pe&&!fe&&!me&&x!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(lt,{children:[(0,$.jsx)(at,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(sa,{}),children:(0,$.jsx)(aa,{})})}),(0,$.jsx)(at,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(sa,{}),children:(0,$.jsx)(aa,{})})}),(0,$.jsx)(at,{path:`*`,element:(0,$.jsx)(hi,{onCreateThread:be})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${x===`terminal`&&!pe&&!fe&&!me?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Qi,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${x===`browser`&&!pe&&!fe&&!me?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(na,{})})}),!pe&&!fe&&!me&&x!==`chat`&&x!==`terminal`&&x!==`browser`&&(x===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ta,{})}):x===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)($i,{projectId:e.selectedProjectId})}):x===`review`&&e.selectedThreadId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ea,{threadId:e.selectedThreadId,onExit:()=>S(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ra,{open:re,onOpenChange:ie,onSubmitClone:l,onSubmitWebApp:u,onOpenFolder:d})}),(0,$.jsx)(Di,{open:oe!==null,projectName:oe?.name,onOpenChange:e=>!e&&se(null),onConfirm:()=>{oe&&(m(oe.id),se(null))}}),(0,$.jsx)(Oi,{open:g!==null,setupScripts:g?[g.command,...g.remainingScripts||[]]:[],onConfirm:_}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ia,{open:H,onOpenChange:U,onComplete:()=>{ae(!0),h()}})}),(0,$.jsx)(Ai,{})]}),(0,$.jsx)(Bi,{})]})})}function la(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(xt,gt),r;e[0]===t?r=e[1]:(r={state:t,dispatch:n},e[0]=t,e[1]=r);let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(ca,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Ui,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(vt.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}_n();var ua=!1;window.addEventListener(`resize`,()=>{ua||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,vn.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(ut,{children:(0,$.jsx)(la,{})})}));export{li as t};