tarsk 0.4.23 → 0.4.25

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 (29) hide show
  1. package/dist/public/assets/{alert-dialog-2Kcr7vcf.js → alert-dialog-JOYww-on.js} +1 -1
  2. package/dist/public/assets/{browser-tab-CgLMsYM8.js → browser-tab-xojjEFYj.js} +1 -1
  3. package/dist/public/assets/chat-input-container-fUw0AY1R.js +1 -0
  4. package/dist/public/assets/{context-menu-sx0fb5uQ.js → context-menu-5lS4H_pS.js} +1 -1
  5. package/dist/public/assets/{diff-view-v-bVp3Zf.js → diff-view-DWNDi8zT.js} +1 -1
  6. package/dist/public/assets/{explorer-tab-view-CsPSJADk.js → explorer-tab-view-BtTXy75I.js} +2 -2
  7. package/dist/public/assets/{explorer-tree-DXXm8_b9.js → explorer-tree-DdPiBm7Y.js} +1 -1
  8. package/dist/public/assets/{explorer-view-8g0_dmv4.js → explorer-view-06kjYKL2.js} +1 -1
  9. package/dist/public/assets/index-CoryOY5D.css +1 -0
  10. package/dist/public/assets/index-DJNTxm7E.js +50 -0
  11. package/dist/public/assets/{project-settings-view-CVYvsVWo.js → project-settings-view-DF-F7P8K.js} +1 -1
  12. package/dist/public/assets/{provider-details-view-Cp_INkPg.js → provider-details-view-CbGbbmaI.js} +1 -1
  13. package/dist/public/assets/{react-vendor-4OUTOTE0.js → react-vendor-BX34Jw0L.js} +1 -1
  14. package/dist/public/assets/{resizable-D62plzWh.js → resizable-asBmgm9X.js} +1 -1
  15. package/dist/public/assets/{run-stop-button-ClYpPnNG.js → run-stop-button-MczHUMXL.js} +1 -1
  16. package/dist/public/assets/{settings-view-BWQrM94z.js → settings-view-CtiXQd-N.js} +2 -2
  17. package/dist/public/assets/{side-panel-container-Bkpb7_cb.js → side-panel-container-5txNmqNe.js} +1 -1
  18. package/dist/public/assets/store-xK3nfJ3V.js +2 -0
  19. package/dist/public/assets/tabs-B7OXJglU.js +1 -0
  20. package/dist/public/assets/{terminal-panel-4EVJwsCQ.js → terminal-panel-D3OZDoCd.js} +1 -1
  21. package/dist/public/assets/todos-view-CzW8DtQ9.js +1 -0
  22. package/dist/public/index.html +11 -11
  23. package/package.json +1 -1
  24. package/dist/public/assets/chat-input-container-VXGAcgnU.js +0 -1
  25. package/dist/public/assets/index-BPF49zet.css +0 -1
  26. package/dist/public/assets/index-DsX2aOD3.js +0 -50
  27. package/dist/public/assets/store-CJdxpohI.js +0 -2
  28. package/dist/public/assets/tabs-DI_KCGYt.js +0 -1
  29. package/dist/public/assets/todos-view-D3JYa8fa.js +0 -1
@@ -0,0 +1,50 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-view-D5WVMsrD.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-3Hr2GRdt.js","assets/use-toast-C3jyoS6i.js","assets/project-settings-view-DF-F7P8K.js","assets/react-vendor-BX34Jw0L.js","assets/history-view-Cyhu-ped.js","assets/monaco-c-HyCuEi.js","assets/textarea-Dg4M60Yx.js","assets/dist-CIGnaqp2.js","assets/diff-view-DWNDi8zT.js","assets/chat-input-container-fUw0AY1R.js","assets/onboarding-DzgFi5ix.js","assets/alert-dialog-JOYww-on.js","assets/store-xK3nfJ3V.js","assets/tab-context-D2auNMAI.js","assets/page-toolbar-De9hbhUD.js","assets/context-menu-5lS4H_pS.js","assets/resizable-asBmgm9X.js","assets/standard-list-item-DUKJ8HEG.js","assets/utils-4yrqj6yI.js","assets/terminal-panel-D3OZDoCd.js","assets/explorer-tab-view-BtTXy75I.js","assets/browser-tab-xojjEFYj.js","assets/run-stop-button-MczHUMXL.js","assets/onboarding-dialog-lFFrB1GZ.js","assets/conversation-history-view-IVxKEbP_.js","assets/settings-view-CtiXQd-N.js","assets/side-panel-container-5txNmqNe.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$r as t,$t as n,A as r,Ar as i,At as a,B as o,Bn as s,Cn as c,Cr as l,Dn as u,Dr as d,Dt as f,E as p,Ei as m,En as h,Et as g,F as _,Fr as v,Ft as y,Gi as b,Gr as x,Gt as S,Hi as C,Hn as w,Hr as T,Ht as E,I as D,Ii as O,In as k,Ir as A,It as j,J as M,Ji as N,Jn as P,Jr as F,Jt as I,Ki as L,Kn as R,Kr as z,Kt as ee,L as te,Lr as B,M as V,Mi as ne,Mn as H,Mr as re,N as ie,Nn as ae,Nr as oe,Nt as se,O as ce,Oi as le,Or as U,Ot as ue,P as de,Pn as W,Pr as fe,Pt as pe,Qi as me,R as he,Ri as ge,Rn as _e,Rt as ve,S as ye,Si as be,Sn as xe,Ti as Se,Tn as Ce,Un as we,Ur as Te,Ut as Ee,Vn as De,Vt as Oe,Wi as ke,Wn as G,Wt as Ae,X as je,Xi as Me,Yi as Ne,Yr as Pe,Zi as Fe,Zr as Ie,Zt as Le,_ as Re,_n as ze,_t as Be,aa as Ve,ai as He,an as Ue,bi as We,bn as Ge,bt as Ke,ct as qe,da as Je,dn as Ye,dt as Xe,ea as Ze,ei as Qe,en as $e,et,f as tt,ft as nt,g as rt,gi as it,gt as at,h as ot,hi as st,hn as ct,ht as lt,ia as ut,ii as dt,in as ft,it as pt,j as mt,ji as ht,jr as gt,k as _t,ki as vt,kn as yt,kr as bt,la as xt,li as St,lt as Ct,mi as wt,mt as Tt,na as Et,ni as Dt,nn as Ot,o as kt,oi as At,on as jt,ot as Mt,p as Nt,pi as Pt,pt as Ft,qi as It,qn as Lt,qr as Rt,qt as zt,ra as Bt,ri as Vt,sa as Ht,si as Ut,st as Wt,ta as Gt,ti as Kt,tn as qt,ua as Jt,un as Yt,ut as Xt,v as Zt,vn as Qt,vt as $t,wn as en,wt as tn,x as nn,xt as rn,z as an,zi as on,zn as sn,zr as cn,zt as ln}from"./dialogs-config-3Hr2GRdt.js";import{$ as un,A as dn,C as fn,M as pn,O as mn,Q as hn,S as gn,b as _n,et as vn,ft as yn,gt as bn,ht as xn,j as Sn,k as Cn,mt as wn,nt as Tn,pt as En,tt as Dn,v as On,vt as kn,w as An,x as jn,y as Mn,yt as Nn}from"./react-vendor-BX34Jw0L.js";import{a as Pn,c as Fn,d as In,f as Ln,i as Rn,n as zn,o as Bn,p as Vn,r as Hn,t as K}from"./store-xK3nfJ3V.js";import{t as Un}from"./textarea-Dg4M60Yx.js";import{c as q,l as Wn,s as J,u as Y}from"./history-view-Cyhu-ped.js";import{_ as Gn,a as Kn,c as qn,d as Jn,f as Yn,g as Xn,h as Zn,i as Qn,l as $n,m as er,n as tr,o as nr,p as rr,r as ir,s as ar,t as or,u as sr}from"./chat-input-container-fUw0AY1R.js";import{n as cr,t as X}from"./use-toast-C3jyoS6i.js";import{t as lr}from"./standard-list-item-DUKJ8HEG.js";import{a as ur,c as dr,i as fr,n as pr,o as mr,r as hr,s as gr,t as _r}from"./alert-dialog-JOYww-on.js";import{n as vr,t as yr}from"./utils-4yrqj6yI.js";import{t as br}from"./side-panel-container-5txNmqNe.js";import{n as xr,t as Sr}from"./tab-context-D2auNMAI.js";import{n as Cr,r as wr}from"./onboarding-DzgFi5ix.js";import{n as Tr,t as Er}from"./run-stop-button-MczHUMXL.js";import{i as Dr,n as Or,r as kr,t as Ar}from"./tabs-B7OXJglU.js";import{t as jr}from"./page-toolbar-De9hbhUD.js";import{n as Mr,r as Nr,t as Pr}from"./resizable-asBmgm9X.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(Je(),1),Fr=Nn(),Q=xt(),Ir=1e10,Lr=1e3;function Rr(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 zr(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=Lr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Ir?++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 Rr([`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 Rr([`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 Rr([`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 Rr([`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 Br(e,t){let n=zr({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 Vr=window.__electrobunWebviewId,Hr=window.__electrobunRpcSocketPort,Ur=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:${Hr}/socket?webviewId=${Vr}`);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 Br(`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))}})}})}},$=l();function Wr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,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)(w,{children:[(0,$.jsx)(we,{children:`Send Feedback`}),(0,$.jsx)(s,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(H,{htmlFor:`feedback-name`,children:`Name`}),t[1]=h):h=t[1];let g;t[2]===a?g=t[3]:(g=e=>a(e.target.value),t[2]=a,t[3]=g);let _=f||d,v;t[4]!==i||t[5]!==g||t[6]!==_?(v=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(ae,{id:`feedback-name`,value:i,onChange:g,placeholder:`Your name`,disabled:_})]}),t[4]=i,t[5]=g,t[6]=_,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(H,{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]!==o||t[12]!==b||t[13]!==x?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(ae,{id:`feedback-email`,type:`email`,value:o,onChange:b,placeholder:`you@example.com`,disabled:x})]}),t[11]=o,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)(H,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let T;t[16]===u?T=t[17]:(T=e=>u(e.target.value),t[16]=u,t[17]=T);let E;t[18]!==l||t[19]!==f||t[20]!==T?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(Un,{id:`feedback-text`,value:l,onChange:T,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=l,t[19]=f,t[20]=T,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==v||t[24]!==S?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,E]}),t[22]=E,t[23]=v,t[24]=S,t[25]=D):D=t[25];let O;t[26]===r?O=t[27]:(O=()=>r(!1),t[26]=r,t[27]=O);let k;t[28]!==f||t[29]!==O?(k=(0,$.jsx)(W,{variant:`outline`,onClick:O,disabled:f,children:`Cancel`}),t[28]=f,t[29]=O,t[30]=k):k=t[30];let A;t[31]===f?A=t[32]:(A=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=f,t[32]=A);let j;t[33]!==p||t[34]!==f||t[35]!==A?(j=(0,$.jsx)(W,{onClick:p,disabled:f,children:A}),t[33]=p,t[34]=f,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(De,{children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==D||t[41]!==M?(N=(0,$.jsxs)(sn,{className:`max-w-xl`,children:[m,D,M]}),t[40]=D,t[41]=M,t[42]=N):N=t[42];let P;return t[43]!==r||t[44]!==n||t[45]!==N?(P=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function Gr(){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),[d,f]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),Wt().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:d,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}f(!0);try{await u(`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{f(!1)}}}}function Kr(e){let t=(0,Q.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=vr();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(cn,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(Ut,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,$.jsxs)(W,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function qr({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||_||!e)return;async function n(){d(!0),p(null);try{let n=(await g(e)).currentConversationId??t,[r,o]=await Promise.allSettled([a(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?pt(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)i(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(o?.status===`fulfilled`&&o.value){if(s(o.value),o.value.model?.model){let e=o.value.model.model,t=o.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Xt(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(o?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,o.reason),o.reason;v(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,_,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,$.jsx)($.Fragment,{children:n});let y=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,$.jsxs)(J,{open:m,onOpenChange:e=>{h(e),!e&&_&&v(!1)},children:[(0,$.jsx)(Y,{asChild:!0,children:n}),(0,$.jsx)(q,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[u&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading usage...`})]}),f&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Et,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`No usage information for this thread`})]}),!u&&!f&&r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Et,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[y(r.totalTokens),` tokens`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(fe,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),o&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=y(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(o.footprint?.totalTokens??o.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),o.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[o.model.model,c?.context_length&&(0,$.jsxs)(`span`,{className:`ml-1`,children:[y(typeof c.context_length==`number`?c.context_length:0),` `,`context)`]})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[`In: `,y(r.totalInputTokens)]}),(0,$.jsxs)(`span`,{children:[`Out: `,y(r.totalOutputTokens)]}),(0,$.jsxs)(`span`,{children:[`Avg: `,y(r.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,$.jsx)($.Fragment,{children:n})}function Jr(e){let t=(0,Q.c)(7),{threadId:n}=e,[r,i]=(0,Z.useState)(),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{(async function(){if(n)try{i((await g(n)).currentConversationId)}catch(e){console.error(`Failed to fetch thread data:`,e)}})()},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),!n||n===``)return null;let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(W,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,$.jsx)(fe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]}),t[3]=s):s=t[3];let c;return t[4]!==r||t[5]!==n?(c=(0,$.jsx)(qr,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}var Yr=(0,Z.lazy)(()=>kn(()=>import(`./account-view-D5WVMsrD.js`),__vite__mapDeps([0,1,2,3]))),Xr=(0,Z.lazy)(()=>kn(()=>import(`./project-settings-view-DF-F7P8K.js`),__vite__mapDeps([4,1,5,6,2,7,8,3])));function Zr(e){let n=(0,Q.c)(104),{projects:r,selectedThreadId:i,selectedProjectId:a,processingThreadIds:o,completedThreadIds:s,deletingThreadIds:c,deletingProjectIds:l,onSelectThread:u,onCreateProject:d,onCreateThread:f,onDeleteThread:p,onDeleteProject:m,onNavigateToSettings:h,onDeselect:g,collapsed:_,updateAvailable:v,updatingApp:y,onUpdateApp:b,onRefreshProjects:x,expandProjectId:S}=e,[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),{showFeedback:D,feedbackName:O,setFeedbackName:k,feedbackEmail:A,setFeedbackEmail:j,feedbackText:M,setFeedbackText:N,loadingFeedbackUser:P,submittingFeedback:F,handleFeedbackDialogChange:I,handleSubmitFeedback:L}=Gr(),z;n[0]===r?z=n[1]:(z=r.map(Qr),n[0]=r,n[1]=z);let ee=z,te;n[2]!==_||n[3]!==d?(te=!_&&(0,$.jsxs)(W,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:d,children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),n[2]=_,n[3]=d,n[4]=te):te=n[4];let B;n[5]!==_||n[6]!==b||n[7]!==v||n[8]!==y?(B=v&&(0,$.jsxs)(W,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:b,disabled:y,children:[y?(0,$.jsx)(it,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(on,{className:`h-4 w-4`}),!_&&(0,$.jsx)(`span`,{className:`truncate`,children:y?`Updating...`:`Update to Latest`})]}),n[5]=_,n[6]=b,n[7]=v,n[8]=y,n[9]=B):B=n[9];let V;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Et,{className:`h-4 w-4`}),n[10]=V):V=n[10];let ne;n[11]===_?ne=n[12]:(ne=!_&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),n[11]=_,n[12]=ne);let H;n[13]!==h||n[14]!==ne?(H=(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,$.jsxs)(W,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:h,children:[V,ne]})}),n[13]=h,n[14]=ne,n[15]=H):H=n[15];let re,ie;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>w(!0),ie=(0,$.jsx)(gt,{className:`h-4 w-4`}),n[16]=re,n[17]=ie):(re=n[16],ie=n[17]);let ae;n[18]===_?ae=n[19]:(ae=!_&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),n[18]=_,n[19]=ae);let oe;n[20]===ae?oe=n[21]:(oe=(0,$.jsxs)(W,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:re,children:[ie,ae]}),n[20]=ae,n[21]=oe);let se;n[22]===I?se=n[23]:(se=()=>I(!0),n[22]=I,n[23]=se);let ce,le;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Pt,{className:`h-4 w-4`}),le=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),n[24]=ce,n[25]=le):(ce=n[24],le=n[25]);let U;n[26]===se?U=n[27]:(U=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:se,children:[ce,le]})}),n[26]=se,n[27]=U);let ue;n[28]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),n[28]=ue):ue=n[28];let de;n[29]===U?de=n[30]:(de=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[U,ue]})}),n[29]=U,n[30]=de);let fe=i??void 0,pe;n[31]===fe?pe=n[32]:(pe=(0,$.jsx)(Jr,{threadId:fe}),n[31]=fe,n[32]=pe);let me;n[33]===_?me=n[34]:(me=(0,$.jsx)(Kr,{collapsed:_}),n[33]=_,n[34]=me);let he;n[35]!==oe||n[36]!==de||n[37]!==pe||n[38]!==me?(he=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[oe,de,pe,me]}),n[35]=oe,n[36]=de,n[37]=pe,n[38]=me,n[39]=he):he=n[39];let ge;n[40]!==he||n[41]!==B||n[42]!==H?(ge=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[B,H,he]}),n[40]=he,n[41]=B,n[42]=H,n[43]=ge):ge=n[43];let ve;n[44]===r.length?ve=n[45]:(ve=r.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.`}),n[44]=r.length,n[45]=ve);let ye;n[46]===S?ye=n[47]:(ye=S?[S]:void 0,n[46]=S,n[47]=ye);let be;n[48]!==s||n[49]!==l||n[50]!==c||n[51]!==f||n[52]!==m||n[53]!==p||n[54]!==u||n[55]!==o||n[56]!==r||n[57]!==a||n[58]!==i?(be=(e,t)=>{let{isOpen:n,toggle:d}=t;return e.kind===`project`?(0,$.jsx)($r,{project:e.project,isOpen:n,onToggle:d,isDeletingProject:l.includes(e.project.projectId),isSelected:a?e.project.projectId===a:!1,onCreateThread:f,onDeleteProject:m,onProjectSettings:E,hasSelectedThread:e.project.threads.some(e=>e.threadId===i)}):(0,$.jsx)(ei,{thread:e.thread,projectId:e.projectId,selectedThreadId:i,isProcessing:o.includes(e.thread.threadId),isDeleting:c.includes(e.thread.threadId),isCompleted:s.includes(e.thread.threadId),projectTitlePrefix:`${R(r.find(t=>t.projectId===e.projectId))} - `,onSelectThread:u,onDeleteThread:p})},n[48]=s,n[49]=l,n[50]=c,n[51]=f,n[52]=m,n[53]=p,n[54]=u,n[55]=o,n[56]=r,n[57]=a,n[58]=i,n[59]=be):be=n[59];let xe;n[60]!==ee||n[61]!==ye||n[62]!==be?(xe=(0,$.jsx)(Gn,{nodes:ee,defaultOpen:!0,forceOpenIds:ye,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:be}),n[60]=ee,n[61]=ye,n[62]=be,n[63]=xe):xe=n[63];let Se;n[64]!==ve||n[65]!==xe?(Se=(0,$.jsx)(yt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ve,xe]})}),n[64]=ve,n[65]=xe,n[66]=Se):Se=n[66];let Ce;n[67]!==_||n[68]!==g||n[69]!==te||n[70]!==ge||n[71]!==Se?(Ce=(0,$.jsx)(br,{collapsed:_,onLogoClick:g,headerAction:te,footer:ge,children:Se}),n[67]=_,n[68]=g,n[69]=te,n[70]=ge,n[71]=Se,n[72]=Ce):Ce=n[72];let we=T!==null,Te;n[73]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>!e&&E(null),n[73]=Te):Te=n[73];let Ee;n[74]===x?Ee=n[75]:(Ee=()=>{x?.(),E(null)},n[74]=x,n[75]=Ee);let De;n[76]!==T||n[77]!==Ee?(De=(0,$.jsx)(sn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xr,{projectId:T,onProjectUpdated:Ee})})}),n[76]=T,n[77]=Ee,n[78]=De):De=n[78];let Oe;n[79]!==we||n[80]!==De?(Oe=(0,$.jsx)(_e,{open:we,onOpenChange:Te,children:De}),n[79]=we,n[80]=De,n[81]=Oe):Oe=n[81];let ke;n[82]===L?ke=n[83]:(ke=()=>void L(),n[82]=L,n[83]=ke);let G;n[84]!==A||n[85]!==O||n[86]!==M||n[87]!==I||n[88]!==P||n[89]!==j||n[90]!==k||n[91]!==N||n[92]!==D||n[93]!==F||n[94]!==ke?(G=(0,$.jsx)(Wr,{open:D,onOpenChange:I,feedbackName:O,onFeedbackNameChange:k,feedbackEmail:A,onFeedbackEmailChange:j,feedbackText:M,onFeedbackTextChange:N,loadingFeedbackUser:P,submittingFeedback:F,onSubmit:ke}),n[84]=A,n[85]=O,n[86]=M,n[87]=I,n[88]=P,n[89]=j,n[90]=k,n[91]=N,n[92]=D,n[93]=F,n[94]=ke,n[95]=G):G=n[95];let Ae;n[96]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(sn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Yr,{})})}),n[96]=Ae):Ae=n[96];let je;n[97]===C?je=n[98]:(je=(0,$.jsx)(_e,{open:C,onOpenChange:w,children:Ae}),n[97]=C,n[98]=je);let Me;return n[99]!==Ce||n[100]!==Oe||n[101]!==G||n[102]!==je?(Me=(0,$.jsxs)($.Fragment,{children:[Ce,Oe,G,je]}),n[99]=Ce,n[100]=Oe,n[101]=G,n[102]=je,n[103]=Me):Me=n[103],Me}function Qr(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 $r(e){let n=(0,Q.c)(26),{project:r,isOpen:i,onToggle:a,isDeletingProject:o,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,f;n[0]===r?f=n[1]:(f=R(r),n[0]=r,n[1]=f);let p=f,m=s||c,h=i&&`rotate-90`,g;n[2]===h?g=n[3]:(g=G(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,h),n[2]=h,n[3]=g);let _;n[4]===g?_=n[5]:(_=(0,$.jsx)(me,{className:g}),n[4]=g,n[5]=_);let y;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),n[6]=y):y=n[6];let b=(s||c)&&`font-bold text-foreground`,S;n[7]===b?S=n[8]:(S=G(`min-w-0 truncate transition-all block`,b),n[7]=b,n[8]=S);let C;n[9]!==p||n[10]!==S?(C=(0,$.jsx)(`span`,{className:S,children:p}),n[9]=p,n[10]=S,n[11]=C):C=n[11];let w;n[12]!==_||n[13]!==C?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,y,C]}),n[12]=_,n[13]=C,n[14]=w):w=n[14];let T;n[15]!==o||n[16]!==l||n[17]!==u||n[18]!==d||n[19]!==r?(T=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:o?(0,$.jsx)(it,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(Wn,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(r.projectId)},children:[(0,$.jsx)(x,{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)(W,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(r.projectId)},children:[(0,$.jsx)(t,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),r.threads.length===0&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),u(r.projectId)},children:[(0,$.jsx)(v,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),n[15]=o,n[16]=l,n[17]=u,n[18]=d,n[19]=r,n[20]=T):T=n[20];let E;return n[21]!==a||n[22]!==w||n[23]!==T||n[24]!==m?(E=(0,$.jsxs)(lr,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:a,children:[w,T]}),n[21]=a,n[22]=w,n[23]=T,n[24]=m,n[25]=E):E=n[25],E}function ei(e){let t=(0,Q.c)(47),{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;t[0]!==u||t[1]!==r||t[2]!==n.gitStatusDot||t[3]!==n.threadId?(p=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[0]=u,t[1]=r,t[2]=n.gitStatusDot,t[3]=n.threadId,t[4]=p):p=t[4];let m=p,h;t[5]!==c||t[6]!==n.threadId||t[7]!==n.title?(h=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[5]=c,t[6]=n.threadId,t[7]=n.title,t[8]=h):h=t[8];let g=h,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(dr,{children:`Delete Thread`}),t[9]=_):_=t[9];let y;t[10]===g?y=t[11]:(y=(0,$.jsxs)(ur,{children:[`Are you sure you want to delete "`,g,`" and all its files? This action cannot be undone.`]}),t[10]=g,t[11]=y);let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(hr,{children:`Cancel`}),t[12]=b):b=t[12];let x;t[13]!==u||t[14]!==r||t[15]!==n.threadId?(x=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[b,(0,$.jsx)(pr,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[13]=u,t[14]=r,t[15]=n.threadId,t[16]=x):x=t[16];let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(fr,{children:[_,y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==d||t[21]!==S?(C=(0,$.jsx)(_r,{open:d,onOpenChange:f,children:S}),t[20]=d,t[21]=S,t[22]=C):C=t[22];let w=n.threadId===i,T,E;t[23]!==l||t[24]!==r||t[25]!==n.threadId?(T=()=>l(r,n.threadId),E=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[23]=l,t[24]=r,t[25]=n.threadId,t[26]=T,t[27]=E):(T=t[26],E=t[27]);let D;t[28]===n.gitStatusDot?D=t[29]:(D=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[28]=n.gitStatusDot,t[29]=D);let O;t[30]===g?O=t[31]:(O=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:g})}),t[30]=g,t[31]=O);let k;t[32]!==m||t[33]!==s||t[34]!==o||t[35]!==a?(k=a||o?(0,$.jsx)(it,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(Gt,{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)(W,{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:m,children:[(0,$.jsx)(v,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[32]=m,t[33]=s,t[34]=o,t[35]=a,t[36]=k):k=t[36];let A;t[37]!==T||t[38]!==E||t[39]!==D||t[40]!==O||t[41]!==k||t[42]!==w?(A=(0,$.jsxs)(lr,{selected:w,onClick:T,onKeyDown:E,role:`button`,tabIndex:0,children:[D,O,k]}),t[37]=T,t[38]=E,t[39]=D,t[40]=O,t[41]=k,t[42]=w,t[43]=A):A=t[43];let j;return t[44]!==A||t[45]!==C?(j=(0,$.jsxs)($.Fragment,{children:[C,A]}),t[44]=A,t[45]=C,t[46]=j):j=t[46],j}var ti=18,ni=4,ri=(ti+ni/2+2)*2,ii=2*Math.PI*ti;function ai(e){let t=(0,Q.c)(8),{eventCount:n}=e,r=ii*(1-(n===void 0?0:n)%360/360),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={width:ri,height:ri},t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={position:`absolute`,inset:0},o=(0,$.jsx)(`circle`,{cx:ri/2,cy:ri/2,r:ti,fill:`none`,stroke:`hsl(var(--brand) / 0.2)`,strokeWidth:ni}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===r?s=t[4]:(s=(0,$.jsxs)(`svg`,{className:`animate-spin-slow animate-radial-pulse-brand rounded-full`,width:ri,height:ri,style:a,children:[o,(0,$.jsx)(`circle`,{cx:ri/2,cy:ri/2,r:ti,fill:`none`,stroke:`hsl(var(--brand))`,strokeWidth:ni,strokeDasharray:ii,strokeDashoffset:r,strokeLinecap:`round`})]}),t[3]=r,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`absolute flex items-center justify-center rounded-full bg-brand`,style:{inset:ni+2},children:(0,$.jsx)(Bt,{className:`h-3.5 w-3.5 text-white`})}),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsxs)(`div`,{className:`relative shrink-0 self-end`,style:i,children:[s,c]}),t[6]=s,t[7]=l),l}var oi=e(Jt(),1),si=.1,ci=10,li=1.25,ui=.001;function di(){let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={x:0,y:0},e[0]=r):r=e[0];let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=fi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*li)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/li)),e[2]=f):f=e[2];let p=f,m;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{n(1),a({x:0,y:0})},e[3]=m):m=e[3];let h=m,g;e[4]===i?g=e[5]:(g=e=>{e.preventDefault(),s(!0),c.current={x:e.clientX,y:e.clientY,ox:i.x,oy:i.y}},e[4]=i,e[5]=g);let _=g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{c.current&&a({x:c.current.ox+(e.clientX-c.current.x),y:c.current.oy+(e.clientY-c.current.y)})},e[6]=v):v=e[6];let y=v,b;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{s(!1),c.current=null},e[7]=b):b=e[7];let x=b,S=(0,Z.useRef)(null),C,w;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=S.current;if(!e)return;let t=function(e){e.preventDefault();let t=-e.deltaY*ui;n(e=>l(e*(1+t)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},w=[],e[8]=C,e[9]=w):(C=e[8],w=e[9]),(0,Z.useEffect)(C,w);let T;return e[10]!==o||e[11]!==i||e[12]!==_||e[13]!==t?(T={scale:t,offset:i,isDragging:o,containerRef:S,zoomIn:d,zoomOut:p,reset:h,onMouseDown:_,onMouseMove:y,onMouseUp:x},e[10]=o,e[11]=i,e[12]=_,e[13]=t,e[14]=T):T=e[14],T}function fi(e){return Math.min(Math.max(e,si),ci)}function pi(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(!1),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){n(document.documentElement.classList.contains(`dark`))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function mi(e,t){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let n=!1;async function i(){try{let{renderMermaidSVG:i}=await kn(async()=>{let{renderMermaidSVG:e}=await import(`./dist-CIGnaqp2.js`);return{renderMermaidSVG:e}},__vite__mapDeps([9,1])),o=i(e,{bg:t?`#18181B`:`#FFFFFF`,fg:t?`#FAFAFA`:`#27272A`,transparent:!1,padding:32});n||(r(o),a(!1))}catch(e){console.error(`Mermaid render error:`,e),n||a(!0)}}return i(),()=>{n=!0}},[e,t]),{svgOutput:n,renderError:i}}function hi(e){let n=(0,Q.c)(69),{svgOutput:r,onClose:i}=e,{scale:a,offset:o,isDragging:s,containerRef:c,zoomIn:l,zoomOut:u,reset:d,onMouseDown:f,onMouseMove:p,onMouseUp:m}=di(),h,g;n[0]===i?(h=n[1],g=n[2]):(h=()=>{let e=function(e){e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[i],n[0]=i,n[1]=h,n[2]=g),(0,Z.useEffect)(h,g);let _;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],n[3]=_):_=n[3],(0,Z.useEffect)(gi,_);let v;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:`mermaid diagram`}),n[4]=v):v=n[4];let y,b;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(St,{className:`h-3.5 w-3.5`}),b=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),n[5]=y,n[6]=b):(y=n[5],b=n[6]);let x;n[7]===u?x=n[8]:(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[y,b]})}),n[7]=u,n[8]=x);let S;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(q,{children:`Zoom out`}),n[9]=S):S=n[9];let C;n[10]===x?C=n[11]:(C=(0,$.jsxs)(J,{children:[x,S]}),n[10]=x,n[11]=C);let w;n[12]===a?w=n[13]:(w=Math.round(a*100),n[12]=a,n[13]=w);let T;n[14]!==d||n[15]!==w?(T=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:`min-w-[3rem] px-2 py-1 text-xs font-mono text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`,children:[w,`%`]})}),n[14]=d,n[15]=w,n[16]=T):T=n[16];let E;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(q,{children:`Reset zoom`}),n[17]=E):E=n[17];let D;n[18]===T?D=n[19]:(D=(0,$.jsxs)(J,{children:[T,E]}),n[18]=T,n[19]=D);let O,k;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),k=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),n[20]=O,n[21]=k):(O=n[20],k=n[21]);let A;n[22]===l?A=n[23]:(A=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[O,k]})}),n[22]=l,n[23]=A);let j;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(q,{children:`Zoom in`}),n[24]=j):j=n[24];let M;n[25]===A?M=n[26]:(M=(0,$.jsxs)(J,{children:[A,j]}),n[25]=A,n[26]=M);let N,P;n[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Ie,{className:`h-3.5 w-3.5`}),P=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),n[27]=N,n[28]=P):(N=n[27],P=n[28]);let F;n[29]===d?F=n[30]:(F=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-xs`,onClick:d,children:[N,P]})}),n[29]=d,n[30]=F);let I;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(q,{children:`Reset view`}),n[31]=I):I=n[31];let L;n[32]===F?L=n[33]:(L=(0,$.jsxs)(J,{children:[F,I]}),n[32]=F,n[33]=L);let R;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),n[34]=R):R=n[34];let z,ee;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(bt,{className:`h-3.5 w-3.5`}),ee=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),n[35]=z,n[36]=ee):(z=n[35],ee=n[36]);let te;n[37]===i?te=n[38]:(te=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`ghost`,size:`icon-xs`,onClick:i,children:[z,ee]})}),n[37]=i,n[38]=te);let B;n[39]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(q,{children:`Close (Esc)`}),n[39]=B):B=n[39];let V;n[40]===te?V=n[41]:(V=(0,$.jsxs)(J,{children:[te,B]}),n[40]=te,n[41]=V);let ne;n[42]!==D||n[43]!==M||n[44]!==L||n[45]!==V||n[46]!==C?(ne=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[v,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[C,D,M,L,R,V]})]}),n[42]=D,n[43]=M,n[44]=L,n[45]=V,n[46]=C,n[47]=ne):ne=n[47];let H=s?`cursor-grabbing`:`cursor-grab`,re;n[48]===H?re=n[49]:(re=G(`flex-1 overflow-hidden select-none`,H),n[48]=H,n[49]=re);let ie=`translate(${o.x}px, ${o.y}px) scale(${a})`,ae=s?`none`:`transform 0.1s ease-out`,oe;n[50]!==ie||n[51]!==ae?(oe={transform:ie,transformOrigin:`center center`,transition:ae},n[50]=ie,n[51]=ae,n[52]=oe):oe=n[52];let se;n[53]===r?se=n[54]:(se={__html:r},n[53]=r,n[54]=se);let ce;n[55]!==oe||n[56]!==se?(ce=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:oe,dangerouslySetInnerHTML:se}),n[55]=oe,n[56]=se,n[57]=ce):ce=n[57];let le;n[58]!==c||n[59]!==f||n[60]!==p||n[61]!==m||n[62]!==re||n[63]!==ce?(le=(0,$.jsx)(`div`,{ref:c,className:re,onMouseDown:f,onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:ce}),n[58]=c,n[59]=f,n[60]=p,n[61]=m,n[62]=re,n[63]=ce,n[64]=le):le=n[64];let U;n[65]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(`div`,{className:`shrink-0 px-4 py-2 text-center text-xs text-muted-foreground/60 bg-background/60 border-t border-border`,children:`Scroll to zoom · Drag to pan · Esc to close`}),n[65]=U):U=n[65];let ue;return n[66]!==ne||n[67]!==le?(ue=(0,oi.createPortal)((0,$.jsx)(Wn,{children:(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Diagram fullscreen view`,children:[ne,le,U]})}),document.body),n[66]=ne,n[67]=le,n[68]=ue):ue=n[68],ue}function gi(){return document.body.style.overflow=`hidden`,_i}function _i(){document.body.style.overflow=``}function vi(e){let t=(0,Q.c)(51),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),{svgOutput:c,renderError:l}=mi(n,pi()),u;t[0]===n?u=t[1]:(u=async function(){await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=n,t[1]=u);let d=u,f=l?`mermaid (render error)`:`mermaid diagram`,p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==c?(m=c&&!l&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`action`,size:`icon-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(wt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(q,{children:`View fullscreen`})]}),t[4]=l,t[5]=c,t[6]=m):m=t[6];let h;t[7]===i?h=t[8]:(h=i?(0,$.jsx)(Gt,{}):(0,$.jsx)(ke,{}),t[7]=i,t[8]=h);let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[9]=g):g=t[9];let _;t[10]!==d||t[11]!==h?(_=(0,$.jsxs)(W,{variant:`action`,size:`icon-xs`,onClick:d,children:[h,g]}),t[10]=d,t[11]=h,t[12]=_):_=t[12];let v;t[13]!==m||t[14]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m,_]}),t[13]=m,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==p||t[17]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[p,v]}),t[16]=p,t[17]=v,t[18]=y):y=t[18];let b=y;if(l){let e;t[19]===r?e=t[20]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[19]=r,t[20]=e);let i;t[21]===n?i=t[22]:(i=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:`text-xs font-mono text-foreground leading-relaxed`,children:n})}),t[21]=n,t[22]=i);let a;return t[23]!==b||t[24]!==e||t[25]!==i?(a=(0,$.jsxs)(`div`,{className:e,children:[b,i]}),t[23]=b,t[24]=e,t[25]=i,t[26]=a):a=t[26],a}if(!c){let e;t[27]===r?e=t[28]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[27]=r,t[28]=e);let n;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:`Rendering diagram…`}),t[29]=n):n=t[29];let i;return t[30]!==b||t[31]!==e?(i=(0,$.jsxs)(`div`,{className:e,children:[b,n]}),t[30]=b,t[31]=e,t[32]=i):i=t[32],i}let x;t[33]===r?x=t[34]:(x=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[33]=r,t[34]=x);let S;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>s(!0),t[35]=S):S=t[35];let C;t[36]===c?C=t[37]:(C=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`block w-full text-left cursor-zoom-in p-4 max-w-full overflow-hidden [&_svg]:max-w-full [&_svg]:h-auto hover:bg-muted/70 transition-colors`,onClick:S,dangerouslySetInnerHTML:{__html:c}})}),t[36]=c,t[37]=C);let w;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(q,{children:`Click to view fullscreen`}),t[38]=w):w=t[38];let T;t[39]===C?T=t[40]:(T=(0,$.jsxs)(J,{children:[C,w]}),t[39]=C,t[40]=T);let E;t[41]!==b||t[42]!==x||t[43]!==T?(E=(0,$.jsxs)(`div`,{className:x,children:[b,T]}),t[41]=b,t[42]=x,t[43]=T,t[44]=E):E=t[44];let D;t[45]!==o||t[46]!==c?(D=o&&(0,$.jsx)(hi,{svgOutput:c,onClose:()=>s(!1)}),t[45]=o,t[46]=c,t[47]=D):D=t[47];let O;return t[48]!==E||t[49]!==D?(O=(0,$.jsxs)(Wn,{children:[E,D]}),t[48]=E,t[49]=D,t[50]=O):O=t[50],O}var yi=`graph.flowchart.sequenceDiagram.classDiagram.stateDiagram.erDiagram.journey.gantt.pie.quadrantChart.requirementDiagram.gitgraph.mindmap.timeline.zenuml.sankey.block.architecture.c4.packet.circuit.flowchart LR.flowchart TD.flowchart BT.flowchart RL.graph LR.graph TD.graph BT.graph RL`.split(`.`),bi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\w+\[\w+\]/,/\w+\(\w+\)/,/\w+\{\w+\}/,/\w+>\w+\]/,/\w+\(\w+\)/,/\w+\[\(\w+\)\]/,/participant\s+\w+/,/actor\s+\w+/,/Note over \w+/,/loop\s+/,/alt\s+/,/opt\s+/,/class\s+\w+/,/interface\s+\w+/,/enum\s+\w+/,/\[\*\]/,/\[\*\]/,/title\s+/,/direction\s+/,/subgraph\s+/];function xi(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
3
+ `).map(e=>e.trim()).filter(e=>e.length>0);if(t.length===0)return!1;if(/```mermaid\s*\n([\s\S]*?)\n```/.test(e))return!0;let n=t[0].toLowerCase();if(yi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of bi)t.test(e)&&r++;return r>=2}function Si(e){if(!xi(e))return null;let t=/```mermaid\s*\n([\s\S]*?)\n```/.exec(e);if(t)return t[1].trim();let n=e.split(`
4
+ `).map(e=>e.trim()).filter(e=>e.length>0)[0].toLowerCase();return yi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var Ci=(0,Z.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:wi(e,n),[e,n]);if(r.length===0)return null;let i=(0,Z.useMemo)(()=>{let e=0;return r.map(t=>{if(t.type===`list`&&t.ordered){let n=e+1;return e+=t.items.length,n}else if(t.type===`list`&&!t.ordered)return 1;else return e=0,1})},[r]);return(0,$.jsx)(`div`,{className:G(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(Ti,{block:e,start:i[t]},t))})});function wi(e,t=!1){let n=e.split(`
5
+ `),r=[],i=0;for(;i<n.length;){let e=n[i];if(e.trimStart().startsWith("```")){let a=e.trimStart().slice(3).trim(),o=[];for(i++;i<n.length&&!n[i].trimStart().startsWith("```");)o.push(n[i]),i++;t&&(a===`mermaid`||xi(o.join(`
6
+ `)))?r.push({type:`mermaid`,code:o.join(`
7
+ `)}):r.push({type:`code`,language:a,code:o.join(`
8
+ `)}),i++;continue}let a=e.match(/^(#{1,6})(\s.*)?$/);if(a){r.push({type:`heading`,level:a[1].length,text:a[2]?a[2].trim():``}),i++;continue}if(/^(---|\*\*\*|___)/.test(e.trim())){r.push({type:`hr`}),i++;continue}if(e.includes(`|`)&&i+1<n.length&&n[i+1].match(/^\|?\s*[-:]+/)){let t=e.split(`|`).map(e=>e.trim()).filter(Boolean);i+=2;let a=[];for(;i<n.length&&n[i].includes(`|`);)a.push(n[i].split(`|`).map(e=>e.trim()).filter(Boolean)),i++;r.push({type:`table`,headers:t,rows:a});continue}if(e.startsWith(`> `)){let e=[];for(;i<n.length&&n[i].startsWith(`> `);)e.push(n[i].slice(2)),i++;r.push({type:`blockquote`,text:e.join(`
9
+ `)});continue}if(/^\s*[-*+]\s/.test(e)){let e=[];for(;i<n.length&&/^\s*[-*+]\s/.test(n[i]);)e.push(n[i].replace(/^\s*[-*+]\s/,``)),i++;r.push({type:`list`,ordered:!1,items:e});continue}if(/^\s*\d+\.\s/.test(e)){let e=[];for(;i<n.length&&/^\s*\d+\.\s/.test(n[i]);)e.push(n[i].replace(/^\s*\d+\.\s/,``)),i++;r.push({type:`list`,ordered:!0,items:e});continue}if(e.trim()===``){i++;continue}let o=[];for(;i<n.length&&n[i].trim()!==``&&!n[i].startsWith(`#`)&&!n[i].startsWith("```")&&!n[i].startsWith(`> `)&&!/^\s*[-*+]\s/.test(n[i])&&!/^\s*\d+\.\s/.test(n[i]);)o.push(n[i]),i++;if(o.length>0){let e=o.join(`
10
+ `);if(t&&xi(e)){let t=Si(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var Ti=(0,Z.memo)(function(e){let t=(0,Q.c)(42),{block:n,start:r}=e,i=r===void 0?1:r;switch(n.type){case`heading`:{let e=`h${n.level}`,r,i;t[0]!==e||t[1]!==n.level?(r=e,i=G({1:`text-xl font-bold`,2:`text-lg font-semibold`,3:`text-base font-semibold`,4:`text-sm font-semibold`,5:`text-sm font-medium`,6:`text-xs font-medium`}[n.level]),t[0]=e,t[1]=n.level,t[2]=r,t[3]=i):(r=t[2],i=t[3]);let a;t[4]===n.text?a=t[5]:(a=(0,$.jsx)(Ei,{text:n.text}),t[4]=n.text,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(r,{className:i,children:a}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}case`code`:{let e;return t[10]!==n.code||t[11]!==n.language?(e=(0,$.jsx)(Oi,{language:n.language,code:n.code}),t[10]=n.code,t[11]=n.language,t[12]=e):e=t[12],e}case`blockquote`:{let e;return t[13]===n.text?e=t[14]:(e=(0,$.jsx)(`blockquote`,{className:`border-l-2 border-border pl-4 text-muted-foreground italic`,children:(0,$.jsx)(Ei,{text:n.text})}),t[13]=n.text,t[14]=e),e}case`list`:{if(n.ordered){let e;if(t[15]!==n.items||t[16]!==i){let r;t[18]===i?r=t[19]:(r=(e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 select-none tabular-nums`,children:[i+t,`.`]}),(0,$.jsx)(`span`,{children:(0,$.jsx)(Ei,{text:e})})]},t),t[18]=i,t[19]=r),e=n.items.map(r),t[15]=n.items,t[16]=i,t[17]=e}else e=t[17];let r;return t[20]===e?r=t[21]:(r=(0,$.jsx)(`ol`,{className:`space-y-1 text-sm`,children:e}),t[20]=e,t[21]=r),r}let e;t[22]===n.items?e=t[23]:(e=n.items.map(ki),t[22]=n.items,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,$.jsx)(`ul`,{className:`space-y-1 pl-5 text-sm list-outside overflow-visible list-disc`,children:e}),t[24]=e,t[25]=r),r}case`paragraph`:{let e;return t[26]===n.text?e=t[27]:(e=(0,$.jsx)(`p`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words`,children:(0,$.jsx)(Ei,{text:n.text})}),t[26]=n.text,t[27]=e),e}case`hr`:{let e;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`hr`,{className:`border-border`}),t[28]=e):e=t[28],e}case`table`:{let e;t[29]===n.headers?e=t[30]:(e=n.headers.map(Ai),t[29]=n.headers,t[30]=e);let r;t[31]===e?r=t[32]:(r=(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-b border-border bg-muted/50`,children:e})}),t[31]=e,t[32]=r);let i;t[33]===n.rows?i=t[34]:(i=n.rows.map(Mi),t[33]=n.rows,t[34]=i);let a;t[35]===i?a=t[36]:(a=(0,$.jsx)(`tbody`,{children:i}),t[35]=i,t[36]=a);let o;return t[37]!==r||t[38]!==a?(o=(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border max-w-full`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[r,a]})}),t[37]=r,t[38]=a,t[39]=o):o=t[39],o}case`mermaid`:{let e;return t[40]===n.code?e=t[41]:(e=(0,$.jsx)(vi,{content:n.code}),t[40]=n.code,t[41]=e),e}default:return null}}),Ei=(0,Z.memo)(function(e){let t=(0,Q.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=Di(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(Ni),t[2]=i,t[3]=a);let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)($.Fragment,{children:a}),t[4]=a,t[5]=o),o});function Di(e){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(__[^_]+__)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)]+\))/g,r=0,i;for(;(i=n.exec(e))!==null;){i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)});let n=i[0];if(n.startsWith("`"))t.push({type:`code`,text:n.slice(1,-1)});else if(n.startsWith(`**`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`__`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`~~`))t.push({type:`strikethrough`,text:n.slice(2,-2)});else if(n.startsWith(`*`)||n.startsWith(`_`))t.push({type:`italic`,text:n.slice(1,-1)});else if(n.startsWith(`[`)){let e=n.match(/\[([^\]]+)\]\(([^)]+)\)/);e&&t.push({type:`link`,text:e[1],href:e[2]})}r=i.index+n.length}return r<e.length&&t.push({type:`text`,text:e.slice(r)}),t.length>0?t:[{type:`text`,text:e}]}function Oi(e){let t=(0,Q.c)(18),{language:n,code:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===r?o=t[1]:(o=async()=>{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=r,t[1]=o);let s=o,c=n||`text`,l;t[2]===c?l=t[3]:(l=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:c}),t[2]=c,t[3]=l);let u;t[4]===i?u=t[5]:(u=i?(0,$.jsx)(Gt,{}):(0,$.jsx)(ke,{}),t[4]=i,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[6]=d):d=t[6];let f;t[7]!==s||t[8]!==u?(f=(0,$.jsxs)(W,{variant:`action`,size:`icon-xs`,onClick:s,children:[u,d]}),t[7]=s,t[8]=u,t[9]=f):f=t[9];let p;t[10]!==l||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[l,f]}),t[10]=l,t[11]=f,t[12]=p):p=t[12];let m;t[13]===r?m=t[14]:(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:`text-xs font-mono text-foreground leading-relaxed`,children:r})}),t[13]=r,t[14]=m);let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function ki(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Ei,{text:e})},t)}function Ai(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(Ei,{text:e})},t)}function ji(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(Ei,{text:e})},t)}function Mi(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ji)},t)}function Ni(e,t){switch(e.type){case`bold`:return(0,$.jsx)(`strong`,{className:`font-semibold`,children:e.text},t);case`italic`:return(0,$.jsx)(`em`,{children:e.text},t);case`strikethrough`:return(0,$.jsx)(`del`,{className:`text-muted-foreground`,children:e.text},t);case`code`:return(0,$.jsx)(`code`,{className:`rounded bg-muted/20 px-1.5 py-0.5 text-xs font-mono`,children:e.text},t);case`link`:return(0,$.jsx)(`a`,{href:e.href,className:`text-primary underline underline-offset-2 hover:text-primary/80`,target:`_blank`,rel:`noopener noreferrer`,children:e.text},t);default:return(0,$.jsx)(`span`,{children:e.text},t)}}function Pi(e){let n=e.toLowerCase();return n.includes(`read`)||n.includes(`file`)?ut:n.includes(`create`)?t:n.includes(`replace`)||n.includes(`edit`)?T:n.includes(`delete`)?Me:n.includes(`terminal`)||n.includes(`bash`)||n.includes(`shell`)?B:n.includes(`run`)?U:n.includes(`git`)||n.includes(`branch`)?vt:n.includes(`search`)||n.includes(`grep`)||n.includes(`find`)?F:n.includes(`code`)||n.includes(`debug`)?b:n.includes(`test`)?Ne:n.includes(`agent`)||n.includes(`subagent`)?At:n.includes(`copy`)?ke:n.includes(`dir`)||n.includes(`list`)||n.includes(`ls`)?st:n.includes(`view`)||n.includes(`show`)?O:n.includes(`config`)||n.includes(`setting`)?x:n.includes(`image`)||n.includes(`generate_image`)?We:n.includes(`chat`)||n.includes(`message`)||n.includes(`ask`)?Pt:i}function Fi(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 Ii(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 Li(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Ri(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 zi(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(zi);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Ri(r);t[n]=typeof e==`object`?zi(e):r}else t[n]=zi(r);return t}function Bi(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
11
+ `),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
12
+ `),t=t.replace(/\\"/g,`"`),t}function Vi(e){if(e==null)return``;let t=typeof e==`object`&&e?zi(e):e;return Bi(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function Hi(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:Ii(Li(i),t),d=Ii(o?String(i.prompt):null,t),f=Ii(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=Ii(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=Pi(n),P=(n===`todo`?j===`done`?Ne:j===`working`?N:It:null)??M,F=n.charAt(0).toUpperCase()+n.slice(1);S===`bash`&&(F=`Ran`),S===`code_search`&&(F=`Code Search`),S===`generate_image`&&(F=`Make Image`),S.includes(`read`)&&(b!==null||x!==null)&&(b!==null&&x!==null?F+=` (lines ${b} to ${b+x})`:b===null?F+=` (${x} lines)`:F+=` (from line ${b})`);let I=`default`;return S===`bash`||S.includes(`terminal`)||S.includes(`shell`)?I=`bash`:C?I=`file`:h||S===`find`||S.includes(`search`)||S.includes(`grep`)?I=`search`:S===`agent`||S.includes(`subagent`)||o?I=`agent`:S===`todo`?I=`todo`:S===`generate_image`&&(I=`imageGen`),{toolType:I,toolName:n,toolId:r,displayName:F,icon:P,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 Ui(e){let t=(0,Q.c)(11),{open:n,onOpenChange:r,title:i,content:a}=e,o;t[0]===i?o=t[1]:(o=(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:i})})}),t[0]=i,t[1]=o);let s;t[2]===a?s=t[3]:(s=(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:a}),t[2]=a,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsxs)(sn,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==r||t[8]!==n||t[9]!==c?(l=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:c}),t[7]=r,t[8]=n,t[9]=c,t[10]=l):l=t[10],l}function Wi(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(`
13
+ `),s=r.split(`
14
+ `);i=`text-xs font-mono whitespace-pre-wrap overflow-auto`,a=e.map(Ki),o=s.map(Gi),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 Gi(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 Ki(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 qi(e){let t=(0,Q.c)(2),{name:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono`,children:n}),t[0]=n,t[1]=r),r}function Ji(e){let t=(0,Q.c)(2),{type:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}function Yi(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`code`,{className:`text-xs 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 Xi(e){let t=(0,Q.c)(55),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1);if(r){if(n.command!==null&&i){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===n.command?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:n.command})}),t[5]=n.command,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View output`}),t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=u);let d;t[10]!==e||t[11]!==r||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,u]}),t[10]=e,t[11]=r,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.command||t[15]!==s||t[16]!==i?(f=(0,$.jsx)(Ui,{open:s,onOpenChange:c,title:n.command,content:i}),t[14]=n.command,t[15]=s,t[16]=i,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)($.Fragment,{children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let l;t[29]===n.command?l=t[30]:(l=n.command!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n.command}),t[29]=n.command,t[30]=l);let u;return t[31]!==o||t[32]!==l?(u=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,l]}),t[31]=o,t[32]=l,t[33]=u):u=t[33],u}let l;t[34]===a?l=t[35]:(l=()=>o(!a),t[34]=a,t[35]=l);let u=n.toolName,d;t[36]===n.icon?d=t[37]:(d=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[36]=n.icon,t[37]=d);let f;t[38]===n.displayName?f=t[39]:(f=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=f);let p;t[40]===a?p=t[41]:(p=a?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[40]=a,t[41]=p);let m;t[42]!==n.toolName||t[43]!==l||t[44]!==d||t[45]!==f||t[46]!==p?(m=(0,$.jsxs)(`button`,{onClick:l,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:u,children:[d,f,p]}),t[42]=n.toolName,t[43]=l,t[44]=d,t[45]=f,t[46]=p,t[47]=m):m=t[47];let h;t[48]!==n.toolId||t[49]!==n.toolInput||t[50]!==a?(h=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-xs 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[48]=n.toolId,t[49]=n.toolInput,t[50]=a,t[51]=h):h=t[51];let g;return t[52]!==m||t[53]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[52]=m,t[53]=h,t[54]=g):g=t[54],g}var Zi=vn,Qi=Dn,$i=Z.forwardRef((e,t)=>{let n=(0,Q.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,align:a,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a===void 0?`center`:a,c=o===void 0?4:o,l;n[5]===r?l=n[6]:(l=G(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=l);let u;return n[7]!==s||n[8]!==i||n[9]!==t||n[10]!==c||n[11]!==l?(u=(0,$.jsx)(un,{children:(0,$.jsx)(hn,{ref:t,align:s,sideOffset:c,className:l,...i})}),n[7]=s,n[8]=i,n[9]=t,n[10]=c,n[11]=l,n[12]=u):u=n[12],u});$i.displayName=hn.displayName;function ea(e){let t=(0,Q.c)(45),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(u=function(){!n.filePath||!a||a(i&&n.filePath.startsWith(i)?n.filePath.slice(i.length+1):n.filePath)},t[0]=n.filePath,t[1]=a,t[2]=i,t[3]=u):u=t[3];let d=u;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.icon||t[6]!==n.toolId||t[7]!==n.toolInput||t[8]!==n.toolName||t[9]!==e?(r=e?(0,$.jsxs)(Zi,{children:[(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsxs)(`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,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)($i,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput})]})})]}):(0,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[4]=n.displayName,t[5]=n.icon,t[6]=n.toolId,t[7]=n.toolInput,t[8]=n.toolName,t[9]=e,t[10]=r):r=t[10];let a;t[11]!==n.editNewText||t[12]!==n.editOldText||t[13]!==n.fileDisplayName||t[14]!==n.filePath||t[15]!==n.hasEditDiff||t[16]!==n.path||t[17]!==c||t[18]!==d||t[19]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:G(`text-xs font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:n.fileDisplayName})}),(0,$.jsx)(q,{children:n.hasEditDiff?`View diff`:n.filePath?Ii(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(_e,{open:c,onOpenChange:l,children:(0,$.jsxs)(sn,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:Ii(n.filePath,i)??n.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(Wi,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,children:n.path}),t[11]=n.editNewText,t[12]=n.editOldText,t[13]=n.fileDisplayName,t[14]=n.filePath,t[15]=n.hasEditDiff,t[16]=n.path,t[17]=c,t[18]=d,t[19]=i,t[20]=a):a=t[20];let o;return t[21]!==r||t[22]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[21]=r,t[22]=a,t[23]=o):o=t[23],o}let f;t[24]===o?f=t[25]:(f=()=>s(!o),t[24]=o,t[25]=f);let p=n.toolName,m;t[26]===n.icon?m=t[27]:(m=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[26]=n.icon,t[27]=m);let h;t[28]===n.displayName?h=t[29]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[28]=n.displayName,t[29]=h);let g;t[30]===o?g=t[31]:(g=o?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[30]=o,t[31]=g);let _;t[32]!==n.toolName||t[33]!==f||t[34]!==m||t[35]!==h||t[36]!==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:p,children:[m,h,g]}),t[32]=n.toolName,t[33]=f,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37];let v;t[38]!==n.toolId||t[39]!==n.toolInput||t[40]!==o?(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-xs 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[38]=n.toolId,t[39]=n.toolInput,t[40]=o,t[41]=v):v=t[41];let y;return t[42]!==_||t[43]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[42]=_,t[43]=v,t[44]=y):y=t[44],y}function ta(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)(Yi,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Yi,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Yi,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Yi,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Yi,{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 na(e){let t=(0,Q.c)(67),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=n.toolName===`code_search`,u=n.codeSearchQuery??n.pattern??n.codeSearchFilePath??n.codeSearchFileGlob??`search`;if(r){if(i&&(l||n.toolName===`find`||n.pattern!==null)){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===u?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:u})}),t[5]=u,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View results`}),t[7]=l):l=t[7];let d;t[8]===o?d=t[9]:(d=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=d);let f;t[10]!==e||t[11]!==r||t[12]!==d?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,d]}),t[10]=e,t[11]=r,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==s||t[15]!==i||t[16]!==u?(p=(0,$.jsx)(Ui,{open:s,onOpenChange:c,title:u,content:i}),t[14]=s,t[15]=i,t[16]=u,t[17]=p):p=t[17];let m;return t[18]!==f||t[19]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),t[18]=f,t[19]=p,t[20]=m):m=t[20],m}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let d;t[29]===n?d=t[30]:(d=(0,$.jsx)(ta,{data:n}),t[29]=n,t[30]=d);let f;t[31]===n.lang?f=t[32]:(f=n.lang!==null&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:n.lang}),t[31]=n.lang,t[32]=f);let p;return t[33]!==o||t[34]!==d||t[35]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,d,f]}),t[33]=o,t[34]=d,t[35]=f,t[36]=p):p=t[36],p}let d;t[37]===a?d=t[38]:(d=()=>o(!a),t[37]=a,t[38]=d);let f=n.toolName,p;t[39]===n.icon?p=t[40]:(p=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[39]=n.icon,t[40]=p);let m;t[41]===n.displayName?m=t[42]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[41]=n.displayName,t[42]=m);let h;t[43]!==n.codeSearchFileGlob||t[44]!==n.codeSearchFilePath||t[45]!==n.codeSearchQuery||t[46]!==n.pattern||t[47]!==l?(h=l&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:`text-xs 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-xs 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-xs 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-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFileGlob})]}),t[43]=n.codeSearchFileGlob,t[44]=n.codeSearchFilePath,t[45]=n.codeSearchQuery,t[46]=n.pattern,t[47]=l,t[48]=h):h=t[48];let g;t[49]===a?g=t[50]:(g=a?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[49]=a,t[50]=g);let _;t[51]!==n.toolName||t[52]!==d||t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(_=(0,$.jsxs)(`button`,{onClick:d,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:f,children:[p,m,h,g]}),t[51]=n.toolName,t[52]=d,t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=_):_=t[57];let v;t[58]!==n.toolId||t[59]!==n.toolInput||t[60]!==a||t[61]!==l||t[62]!==i?(v=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-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,l&&i&&(0,$.jsx)(`pre`,{className:`text-xs 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[58]=n.toolId,t[59]=n.toolInput,t[60]=a,t[61]=l,t[62]=i,t[63]=v):v=t[63];let y;return t[64]!==_||t[65]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[64]=_,t[65]=v,t[66]=y):y=t[66],y}function ra(e){let t=(0,Q.c)(57),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==r||t[5]!==i?(a=(0,$.jsxs)(`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:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o;t[7]!==n.toolName||t[8]!==a?(o=(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:e,className:`inline-flex`,children:a})}),t[7]=n.toolName,t[8]=a,t[9]=o):o=t[9];let s;t[10]===n.toolId?s=t[11]:(s=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[10]=n.toolId,t[11]=s);let c;t[12]!==n.prompt||t[13]!==n.toolInput?(c=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[12]=n.prompt,t[13]=n.toolInput,t[14]=c):c=t[14];let l;t[15]!==s||t[16]!==c?(l=(0,$.jsx)($i,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[s,c]})}),t[15]=s,t[16]=c,t[17]=l):l=t[17];let u;t[18]!==o||t[19]!==l?(u=(0,$.jsxs)(Zi,{children:[o,l]}),t[18]=o,t[19]=l,t[20]=u):u=t[20];let d;t[21]===n.agentName?d=t[22]:(d=n.agentName&&(0,$.jsx)(qi,{name:n.agentName}),t[21]=n.agentName,t[22]=d);let f;t[23]===n.subagentType?f=t[24]:(f=n.subagentType&&(0,$.jsx)(Ji,{type:n.subagentType}),t[23]=n.subagentType,t[24]=f);let p;return t[25]!==d||t[26]!==f||t[27]!==u?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[u,d,f]}),t[25]=d,t[26]=f,t[27]=u,t[28]=p):p=t[28],p}let o;t[29]===i?o=t[30]:(o=()=>a(!i),t[29]=i,t[30]=o);let s=n.toolName,c;t[31]===n.icon?c=t[32]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[31]=n.icon,t[32]=c);let l;t[33]===n.displayName?l=t[34]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[33]=n.displayName,t[34]=l);let u;t[35]===n.agentName?u=t[36]:(u=n.agentName&&(0,$.jsx)(qi,{name:n.agentName}),t[35]=n.agentName,t[36]=u);let d;t[37]===n.subagentType?d=t[38]:(d=n.subagentType&&(0,$.jsx)(Ji,{type:n.subagentType}),t[37]=n.subagentType,t[38]=d);let f;t[39]===i?f=t[40]:(f=i?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[39]=i,t[40]=f);let p;t[41]!==n.toolName||t[42]!==o||t[43]!==c||t[44]!==l||t[45]!==u||t[46]!==d||t[47]!==f?(p=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u,d,f]}),t[41]=n.toolName,t[42]=o,t[43]=c,t[44]=l,t[45]=u,t[46]=d,t[47]=f,t[48]=p):p=t[48];let m;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==i?(m=i&&(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-xs 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-xs 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[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=i,t[53]=m):m=t[53];let h;return t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[p,m]}),t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function ia(e){let t=(0,Q.c)(21),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r)return null;let o;t[0]===i?o=t[1]:(o=()=>a(!i),t[0]=i,t[1]=o);let s=n.toolName,c;t[2]===n.icon?c=t[3]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[2]=n.icon,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]===i?u=t[7]:(u=i?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[6]=i,t[7]=u);let d;t[8]!==n.toolName||t[9]!==o||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[8]=n.toolName,t[9]=o,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]!==i?(f=i&&(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-xs 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]=i,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 aa(e){let t=(0,Q.c)(34),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==n.toolName||t[5]!==r||t[6]!==i?(a=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,i]}),t[4]=n.toolName,t[5]=r,t[6]=i,t[7]=a):a=t[7];let o;t[8]===n.imageGenPrompt?o=t[9]:(o=n.imageGenPrompt!==null&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.imageGenPrompt,children:n.imageGenPrompt}),t[8]=n.imageGenPrompt,t[9]=o);let s;return t[10]!==a||t[11]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[a,o]}),t[10]=a,t[11]=o,t[12]=s):s=t[12],s}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,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]===i?u=t[20]:(u=i?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.toolId||t[28]!==n.toolInput||t[29]!==i?(f=i&&(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-xs 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.toolId,t[28]=n.toolInput,t[29]=i,t[30]=f):f=t[30];let p;return t[31]!==d||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function oa(e){let t=(0,Q.c)(35),{data:n,inline:r}=e,[i,a]=(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.icon||t[2]!==n.prompt||t[3]!==n.toolId||t[4]!==n.toolInput||t[5]!==n.toolName||t[6]!==e?(r=e?(0,$.jsxs)(Zi,{children:[(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsxs)(`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,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)($i,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs 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,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[0]=n.displayName,t[1]=n.icon,t[2]=n.prompt,t[3]=n.toolId,t[4]=n.toolInput,t[5]=n.toolName,t[6]=e,t[7]=r):r=t[7];let i;t[8]===n.path?i=t[9]:(i=n.path!==null&&(0,$.jsx)(`span`,{className:`text-xs 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]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,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]===i?u=t[20]:(u=i?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,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]!==i?(f=i&&(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-xs 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-xs 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]=i,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 sa(e){let t=(0,Q.c)(34),{block:n,inline:r,resultContent:i}=e,{state:a}=Pn(),{setPendingExplorerPath:o,setActiveMainTab:s}=xr(),c;if(t[0]!==a.projects||t[1]!==a.selectedProjectId||t[2]!==a.selectedThreadId){let e;t[4]===a.selectedProjectId?e=t[5]:(e=e=>e.projectId===a.selectedProjectId,t[4]=a.selectedProjectId,t[5]=e),c=a.projects.find(e)?.threads.find(e=>e.threadId===a.selectedThreadId),t[0]=a.projects,t[1]=a.selectedProjectId,t[2]=a.selectedThreadId,t[3]=c}else c=t[3];let l=c?.path,u=Hi(n,l),d;t[6]!==s||t[7]!==o?(d=function(e){o(e),s(`explorer`)},t[6]=s,t[7]=o,t[8]=d):d=t[8];let f=d;switch(u.toolType){case`bash`:{let e;return t[9]!==u||t[10]!==r||t[11]!==i?(e=(0,$.jsx)(Xi,{data:u,inline:r,resultContent:i}),t[9]=u,t[10]=r,t[11]=i,t[12]=e):e=t[12],e}case`file`:{let e;return t[13]!==u||t[14]!==f||t[15]!==r||t[16]!==l?(e=(0,$.jsx)(ea,{data:u,inline:r,rootPath:l,onOpenFile:f}),t[13]=u,t[14]=f,t[15]=r,t[16]=l,t[17]=e):e=t[17],e}case`search`:{let e;return t[18]!==u||t[19]!==r||t[20]!==i?(e=(0,$.jsx)(na,{data:u,inline:r,resultContent:i}),t[18]=u,t[19]=r,t[20]=i,t[21]=e):e=t[21],e}case`agent`:{let e;return t[22]!==u||t[23]!==r?(e=(0,$.jsx)(ra,{data:u,inline:r}),t[22]=u,t[23]=r,t[24]=e):e=t[24],e}case`todo`:{let e;return t[25]!==u||t[26]!==r?(e=(0,$.jsx)(ia,{data:u,inline:r}),t[25]=u,t[26]=r,t[27]=e):e=t[27],e}case`imageGen`:{let e;return t[28]!==u||t[29]!==r?(e=(0,$.jsx)(aa,{data:u,inline:r}),t[28]=u,t[29]=r,t[30]=e):e=t[30],e}default:{let e;return t[31]!==u||t[32]!==r?(e=(0,$.jsx)(oa,{data:u,inline:r}),t[31]=u,t[32]=r,t[33]=e):e=t[33],e}}}function ca(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 la(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 qt(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 p(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 m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(on,{className:`h-3.5 w-3.5`}),t[7]=m):m=t[7];let h;t[8]===c?h=t[9]:(h=(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:m})}),t[8]=c,t[9]=h);let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{children:`Save image`}),t[10]=g):g=t[10];let _;t[11]===h?_=t[12]:(_=(0,$.jsxs)(J,{children:[h,g]}),t[11]=h,t[12]=_);let v;t[13]===i?v=t[14]:(v=i?(0,$.jsx)(Gt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(ke,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=v);let y;t[15]!==u||t[16]!==v?(y=(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:v})}),t[15]=u,t[16]=v,t[17]=y):y=t[17];let b=i?`Copied!`:`Copy to clipboard`,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(q,{children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(J,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==_?(C=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(Wn,{children:[_,S]})}),t[23]=S,t[24]=_,t[25]=C):C=t[25];let w;return t[26]!==C||t[27]!==f?(w=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[f,C]}),t[26]=C,t[27]=f,t[28]=w):w=t[28],w}function ua(e){let t=(0,Q.c)(72),{block:n,inline:r,sequence:i}=e,a=i===void 0?0:i,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),{state:u}=Pn(),d=u.projects,f,p,m,h,g,_,v,y;if(t[0]!==n||t[1]!==r||t[2]!==a||t[3]!==u.projects||t[4]!==u.selectedProjectId||t[5]!==u.selectedThreadId){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[14]===u.selectedProjectId?e=t[15]:(e=e=>e.projectId===u.selectedProjectId,t[14]=u.selectedProjectId,t[15]=e);let i=d.find(e)?.threads.find(e=>e.threadId===u.selectedThreadId)?.path;y=n.toolName??`Unknown Tool`,v=n.toolCallId??`unknown`;let o=n,s=n.result??o.content,c;t[16]!==o||t[17]!==y?(c=y===`todo`?Xn(o):null,t[16]=o,t[17]=y,t[18]=c):c=t[18];let l=c;if(m=Ii(Vi(s),i),!(m.length>0)&&l===null){_=null;break bb0}if(f=Fi(y),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),f=e}else if(y===`read`||y===`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),f=`Completed ${e}`}}}else if(s==null){let e;t[23]===y?e=t[24]:(e=Fi(y),t[23]=y,t[24]=e),f=`${e} (no result)`}if(f=Ii(f,i),l!==null){let e;t[25]!==a||t[26]!==l?(e=(0,$.jsx)(er,{todos:l,sequence:a}),t[25]=a,t[26]=l,t[27]=e):e=t[27],_=e;break bb0}if(y===`generate_image`){let e;t[28]===s?e=t[29]:(e=ca(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)(la,{imageUrl:n.imageUrl,imageData:n.imageData}),t[30]=n.imageData,t[31]=n.imageUrl,t[32]=e):e=t[32],_=e;break bb0}}if(r){_=null;break bb0}let b;t[33]===y?b=t[34]:(b=y.toLowerCase().includes(`bash`),t[33]=y,t[34]=b),p=b,h=m?m.split(`
15
+ `):[],g=p?h.slice(0,3).join(`
16
+ `):m}t[0]=n,t[1]=r,t[2]=a,t[3]=u.projects,t[4]=u.selectedProjectId,t[5]=u.selectedThreadId,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y}else f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let b=g,x=p&&h.length>3;if(p){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ne,{className:`h-4 w-4 shrink-0`}),t[35]=e):e=t[35];let n;t[36]===f?n=t[37]:(n=(0,$.jsxs)(`div`,{className:`px-3 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:f})]}),t[36]=f,t[37]=n);let r;t[38]!==x||t[39]!==b||t[40]!==m||t[41]!==h?(r=m&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2${x?` cursor-pointer hover:bg-muted/80`:``}`,onClick:x?()=>l(!0):void 0,title:x?`Click to see full output`:void 0,children:[b,x&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
17
+ `,`...`]})]}),x&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,h.length,` lines)`]})]}),t[38]=x,t[39]=b,t[40]=m,t[41]=h,t[42]=r):r=t[42];let i;t[43]!==n||t[44]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[43]=n,t[44]=r,t[45]=i):i=t[45];let a;t[46]!==c||t[47]!==x||t[48]!==m?(a=x&&(0,$.jsx)(_e,{open:c,onOpenChange:l,children:(0,$.jsxs)(sn,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:m})]})}),t[46]=c,t[47]=x,t[48]=m,t[49]=a):a=t[49];let o;return t[50]!==i||t[51]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[50]=i,t[51]=a,t[52]=o):o=t[52],o}let S;t[53]===o?S=t[54]:(S=()=>s(!o),t[53]=o,t[54]=S);let C=`${y} result`,T;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ne,{className:`h-4 w-4 shrink-0`}),t[55]=T):T=t[55];let E;t[56]===f?E=t[57]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f}),t[56]=f,t[57]=E);let D;t[58]===o?D=t[59]:(D=o?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[58]=o,t[59]=D);let O;t[60]!==S||t[61]!==C||t[62]!==E||t[63]!==D?(O=(0,$.jsxs)(`button`,{onClick:S,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:C,children:[T,E,D]}),t[60]=S,t[61]=C,t[62]=E,t[63]=D,t[64]=O):O=t[64];let k;t[65]!==o||t[66]!==m||t[67]!==v?(k=o&&(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: `,v]}),m&&(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:m})]}),t[65]=o,t[66]=m,t[67]=v,t[68]=k):k=t[68];let A;return t[69]!==O||t[70]!==k?(A=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[O,k]}),t[69]=O,t[70]=k,t[71]=A):A=t[71],A}function da(e){let t=(0,Q.c)(22),{text:n,label:r,isStreaming:i,hasContentAfter:a}=e,o=i===void 0?!1:i,s=a===void 0?!1:a,[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(o),d=(0,Z.useRef)(s),f,p;if(t[0]!==s||t[1]!==o?(f=()=>{(u.current&&!o||!d.current&&s)&&(0,Z.startTransition)(()=>{l(!1)}),u.current=o,d.current=s},p=[o,s,l],t[0]=s,t[1]=o,t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p),!n?.trim())return null;let m=c??o,h;t[4]===m?h=t[5]:(h=()=>l(!m),t[4]=m,t[5]=h);let g=r??`Thinking`,_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Et,{className:`h-4 w-4 shrink-0 text-brand`}),t[6]=_):_=t[6];let v=r??`Thinking`,y;t[7]===v?y=t[8]:(y=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:v}),t[7]=v,t[8]=y);let b;t[9]===m?b=t[10]:(b=m?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[9]=m,t[10]=b);let x;t[11]!==b||t[12]!==h||t[13]!==g||t[14]!==y?(x=(0,$.jsxs)(`button`,{onClick:h,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:g,children:[_,y,b]}),t[11]=b,t[12]=h,t[13]=g,t[14]=y,t[15]=x):x=t[15];let S;t[16]!==m||t[17]!==n?(S=m&&(0,$.jsx)(`div`,{className:`py-2 border-t border-border`,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:n})}),t[16]=m,t[17]=n,t[18]=S):S=t[18];let C;return t[19]!==x||t[20]!==S?(C=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[x,S]}),t[19]=x,t[20]=S,t[21]=C):C=t[21],C}function fa({toolCall:e,className:t}){let{state:n,dispatch:r}=Pn(),[i,a]=(0,Z.useState)(!1),o=n.toolCallProgress[e.id];return(0,Z.useMemo)(()=>{if(!n.isStreaming)return{isActive:!1,isCompleted:!0};let t=!1,r=!1;for(let i of n.streamingSegments)if(i.type===`thinking`){for(let n of i.chunks)if(n.includes(e.id))try{let i=JSON.parse(n);if(Array.isArray(i))for(let n of i)n.type===`tool_use`&&n.id===e.id&&(t=!0),n.type===`tool-result`&&n.toolCallId===e.id&&(r=!0,t=!1)}catch{}}return t&&!n.isStreaming&&(r=!0,t=!1),{isActive:t,isCompleted:r}},[n.isStreaming,n.streamingSegments,e.id]).isActive?(0,$.jsxs)(`div`,{className:G(`overflow-hidden mb-2`,t),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1`,children:[(0,$.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name===`bash`?`Run`:e.name.charAt(0).toUpperCase()+e.name.slice(1)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.name===`bash`&&typeof e.input?.command==`string`?`run "${e.input.command}"`:typeof e.input?.description==`string`?e.input.description:`running`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>{a(e=>!e)},className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:i?`Collapse`:`Expand`,children:i?(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ze,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:()=>{r({type:K.StopStream});let t={type:`tool-result`,toolCallId:e.id,toolName:e.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.`};r({type:K.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([t]),segments:n.streamingSegments})},className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:(0,$.jsx)(bt,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`})]})]})]}),i&&(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: `,e.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-xs 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:(e=>JSON.stringify(e,null,2))(e.input)})]}),o&&(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-xs 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:o.delta}),o.partial?.content?.[0]?.arguments&&typeof o.partial.content[0].arguments==`object`&&`content`in o.partial.content[0].arguments&&typeof o.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:`mt-1 text-green-600 dark:text-green-400 font-mono text-xs`,children:[`Building: `,o.partial.content[0].arguments.content.slice(-50),o.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(it,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function pa(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,f]=(0,Z.useState)(o??``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_;t[0]!==p||t[1]!==n?(_=async e=>{if(!(!e.trim()||p)){m(!0);try{await Ye(n,e.trim()),f(e.trim()),u(!0)}catch(e){console.error(`Failed to submit answer:`,e),m(!1),g(null)}}},t[0]=p,t[1]=n,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==p||t[5]!==l?(y=e=>{l||p||(g(e),v(e))},t[3]=v,t[4]=p,t[5]=l,t[6]=y):y=t[6];let b=y,x;t[7]!==s||t[8]!==v||t[9]!==p||t[10]!==l?(x=()=>{if(l||p)return;let e=s.trim();e&&v(e)},t[7]=s,t[8]=v,t[9]=p,t[10]=l,t[11]=x):x=t[11];let S=x,C;t[12]===S?C=t[13]:(C=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},t[12]=S,t[13]=C);let w=C;if(l){let e,n;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gt,{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 T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(N,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[18]=T):T=t[18];let E;t[19]===r?E=t[20]:(E=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(Ci,{content:r})}),t[19]=r,t[20]=E);let D;t[21]===a?D=t[22]:(D=a&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:a}),t[21]=a,t[22]=D);let O;t[23]!==E||t[24]!==D?(O=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[T,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[E,D]})]}),t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==b||t[27]!==p||t[28]!==i||t[29]!==h?(k=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=h===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e),disabled:p,className:G(`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)(Gt,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[26]=b,t[27]=p,t[28]=i,t[29]=h,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>c(e.target.value),t[31]=A):A=t[31];let j=i?.length?`Or type a custom answer...`:`Type your answer...`,M;t[32]!==s||t[33]!==w||t[34]!==p||t[35]!==j?(M=(0,$.jsx)(`input`,{type:`text`,value:s,onChange:A,onKeyDown:w,placeholder:j,disabled:p,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]=w,t[34]=p,t[35]=j,t[36]=M):M=t[36];let P;t[37]!==s||t[38]!==p?(P=p||!s.trim(),t[37]=s,t[38]=p,t[39]=P):P=t[39];let F;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Ve,{className:`h-3 w-3`}),t[40]=F):F=t[40];let I;t[41]!==S||t[42]!==P?(I=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:P,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:F}),t[41]=S,t[42]=P,t[43]=I):I=t[43];let L;t[44]!==M||t[45]!==I?(L=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[M,I]}),t[44]=M,t[45]=I,t[46]=L):L=t[46];let R;return t[47]!==L||t[48]!==O||t[49]!==k?(R=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[O,k,L]}),t[47]=L,t[48]=O,t[49]=k,t[50]=R):R=t[50],R}function ma(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=Pn(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=Yn(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=()=>rr(n,()=>{let e=Yn(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&&Jn(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(ha),t[12]=S):S=t[12];let w=S;if(l===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(C,{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)(C,{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)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{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:w,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-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i}),f!=null&&(0,$.jsx)(`pre`,{className:`text-xs 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 T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 text-destructive`}),t[31]=T):T=t[31];let E=r||`Browser JS Execution Failed`,D;t[32]===E?D=t[33]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),t[32]=E,t[33]=D);let O;t[34]===b?O=t[35]:(O=b?(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}),t[34]=b,t[35]=O);let k;t[36]!==D||t[37]!==O?(k=(0,$.jsxs)(`button`,{onClick:w,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:[T,D,O]}),t[36]=D,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==i||t[40]!==m||t[41]!==b?(A=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:m}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=m,t[41]=b,t[42]=A):A=t[42];let j;return t[43]!==k||t[44]!==A?(j=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),t[43]=k,t[44]=A,t[45]=j):j=t[45],j}function ha(e){return!e}function ga(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 qt(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 p(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)(on,{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 m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{children:`Save image`}),t[10]=m):m=t[10];let h;t[11]===f?h=t[12]:(h=(0,$.jsxs)(J,{children:[f,m]}),t[11]=f,t[12]=h);let g;t[13]===r?g=t[14]:(g=r?(0,$.jsx)(Gt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(ke,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=g);let _;t[15]!==c||t[16]!==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:g})}),t[15]=c,t[16]=g,t[17]=_):_=t[17];let v=r?`Copied!`:`Copy to clipboard`,y;t[18]===v?y=t[19]:(y=(0,$.jsx)(q,{children:v}),t[18]=v,t[19]=y);let b;t[20]!==_||t[21]!==y?(b=(0,$.jsxs)(J,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(Wn,{children:[h,b]})}),t[23]=b,t[24]=h,t[25]=x):x=t[25];let S;return t[26]!==x||t[27]!==u?(S=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[u,x]}),t[26]=x,t[27]=u,t[28]=S):S=t[28],S}function _a(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 va(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(pa,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:r},t):e.name===`run_js`||e.name===`run_web_worker`?(0,$.jsx)(ma,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(fa,{toolCall:e}),(0,$.jsx)(sa,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(sa,{inline:!0,block:e,resultContent:r},t)}function ya({message:e,threadId:t,messageIndex:n=0}){let r=e.sender===`user`,i=r?null:Ln(e.content),[a,o]=(0,Z.useState)(!1),s=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function c(){if(!(!e.checkpointRef||!t||a)){o(!0);try{let n=await Le(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{o(!1)}}}return(0,$.jsxs)(`div`,{className:G(`group flex gap-3 px-4 py-4`,r?`flex-row-reverse`:`flex-row`),children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 shrink-0`,children:[(0,$.jsx)(`div`,{className:G(`flex h-7 w-7 items-center justify-center rounded-full`,r?`bg-foreground`:`bg-muted`),children:r?(0,$.jsx)(gt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Bt,{className:`h-3.5 w-3.5 text-muted-foreground`})}),r&&e.checkpointRef&&(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,disabled:a,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)(Ie,{className:G(`h-3 w-3`,a&&`animate-spin`)})})}),(0,$.jsx)(q,{side:`left`,children:`Restore checkpoint`})]})})]}),(0,$.jsxs)(`div`,{className:G(`flex flex-1 flex-col gap-1 min-w-0`,r&&`items-end`),children:[(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2`,r&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:r?`You`:`Agent`}),s&&(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)(L,{className:`h-2.5 w-2.5`}),s]}),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)(C,{className:`h-2.5 w-2.5`}),wr(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)(A,{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:G(`rounded-xl px-4 py-3 flex flex-col gap-0.5 min-w-0`,r?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=Vn(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?va(e,n,!1,_a(t,e.id)):e.type===`tool-result`?(0,$.jsx)(ua,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(da,{text:In(e.text),label:e.label},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Ci,{content:In(e.content),enableMermaid:!0})})})():i?(()=>{let e=i.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[i.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(ua,{inline:!0,sequence:n,block:e},t):null:e.type===`tool_use`&&e.name===`ask_user`||e.type===`tool-result`&&e.toolName===`ask_user`?null:(0,$.jsx)(`div`,{children:e.type===`reasoning`&&`text`in e?(0,$.jsx)(da,{text:In(e.text),label:e.label}):e.type===`text`&&`text`in e?(0,$.jsx)(Ci,{content:In(e.text),enableMermaid:!0}):e.type===`tool_use`?va(e,void 0,!1,_a(i,e.id)):e.type===`tool-result`?(0,$.jsx)(ua,{inline:!0,block:e}):null},t)),e.map((e,t)=>(0,$.jsx)(pa,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:_a(i,e.id)},`ask-${t}`))]})})():(0,$.jsx)(Ci,{content:In(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(ga,{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)(Dt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function ba(e){let t=(0,Q.c)(26),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a,totalMessages:o,eventCount:s}=e,c=o===void 0?0:o,l=s===void 0?0:s,u,d,f,p,m;if(t[0]!==l||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==n||t[5]!==c){let e=Fn(n),o=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;p=`group flex gap-3 px-4 py-4`,t[11]===l?m=t[12]:(m=(0,$.jsx)(ai,{eventCount:l}),t[11]=l,t[12]=m),u=`flex flex-1 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 h;t[14]===r?h=t[15]:(h=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)(C,{className:`h-2.5 w-2.5`}),wr(r)]}),t[14]=r,t[15]=h),t[16]===h?d=t[17]:(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,h]}),t[16]=h,t[17]=d),f=e.length>0?(()=>{let t=e.filter(xa);return(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted px-4 py-3 text-foreground flex flex-col gap-0.5 min-w-0`,children:[e.map((t,n)=>t.type===`tool_use`&&t.name===`todo`||t.type===`tool-result`&&t.toolName===`todo`?t.type===`tool-result`?(0,$.jsx)(ua,{inline:!0,sequence:c,block:t},`b-${n}`):null:t.type===`tool_use`&&t.name===`ask_user`?null:(0,$.jsx)(`div`,{children:t.type===`reasoning`&&`text`in t?(0,$.jsx)(da,{text:In(t.text),label:t.label,isStreaming:!0,hasContentAfter:o(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(Ci,{content:In(t.text),enableMermaid:!0}):t.type===`tool_use`?va(t,void 0,!0,_a(e,t.id)):t.type===`tool-result`?(0,$.jsx)(ua,{inline:!0,block:t}):null},`b-${n}`)),t.map((t,n)=>(0,$.jsx)(pa,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:_a(e,t.id)},`ask-${n}`))]})})():i||a?(0,$.jsx)(`div`,{className:`rounded-xl bg-muted px-4 py-3 min-w-0 text-foreground`,children:(0,$.jsx)(da,{text:`Setting up workspace and running install commands...`,label:`Installing`,isStreaming:!0,hasContentAfter:!1})}):(0,$.jsx)(`div`,{className:`rounded-xl bg-muted px-4 py-3 min-w-0`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:300ms]`})]})}),t[0]=l,t[1]=i,t[2]=a,t[3]=r,t[4]=n,t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m}else u=t[6],d=t[7],f=t[8],p=t[9],m=t[10];let h;t[18]!==u||t[19]!==d||t[20]!==f?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f]}),t[18]=u,t[19]=d,t[20]=f,t[21]=h):h=t[21];let g;return t[22]!==p||t[23]!==m||t[24]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g):g=t[25],g}function xa(e){return e.type===`tool_use`&&e.name===`ask_user`}var Sa=(0,Z.memo)(ba,(e,t)=>{if(e.model!==t.model||e.segments.length!==t.segments.length)return!1;for(let n=0;n<e.segments.length;n++){if(e.segments[n].type!==t.segments[n].type||e.segments[n].chunks.length!==t.segments[n].chunks.length)return!1;for(let r=0;r<e.segments[n].chunks.length;r++)if(e.segments[n].chunks[r]!==t.segments[n].chunks[r])return!1}return!0});function Ca(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)(ne,{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)(vt,{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)(Kt,{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)(ht,{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 wa(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=xr(),[i,a]=(0,Z.useState)(!1),{startServer:o}=Tr(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Ae(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);let u=!i&&n?.runCommand,d;t[5]!==n||t[6]!==o?(d=()=>{n&&o(n)},t[5]=n,t[6]=o,t[7]=d):d=t[7];let f=d,p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[8]=p):p=t[8];let m=n?.name??`Project`,h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:m}),t[9]=m,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`p`,{className:`mt-2 text-base text-muted-foreground`,children:`What would you like to build today?`}),t[11]=g):g=t[11];let _;t[12]===h?_=t[13]:(_=(0,$.jsxs)(`div`,{className:`text-center`,children:[h,g]}),t[12]=h,t[13]=_);let v;t[14]!==f||t[15]!==u?(v=u&&(0,$.jsx)(`button`,{type:`button`,onClick:f,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[14]=f,t[15]=u,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==_?(y=(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:[p,_,v]})}),t[17]=v,t[18]=_,t[19]=y):y=t[19],y}var Ta=(0,Z.createContext)(null),Ea=(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});Ea.displayName=`MessageList`;function Da(){let e=(0,Q.c)(14),t=(0,Z.useContext)(Ta);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,streamingEventCount:s,totalMessages:c,error:l,onClearError:u}=t,d;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==s||e[4]!==o||e[5]!==a||e[6]!==c?(d=(n||r||i)&&(0,$.jsx)(Sa,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i,totalMessages:c,eventCount:s}),e[0]=r,e[1]=i,e[2]=n,e[3]=s,e[4]=o,e[5]=a,e[6]=c,e[7]=d):d=e[7];let f;e[8]!==l||e[9]!==u?(f=l&&(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:l}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:u,children:`Dismiss`})]}),e[8]=l,e[9]=u,e[10]=f):f=e[10];let p;return e[11]!==d||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-4`,children:[d,f]}),e[11]=d,e[12]=f,e[13]=p):p=e[13],p}var Oa={List:Ea,Footer:Da};function ka(e){let t=(0,Q.c)(44),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,streamingEventCount:o,isCreatingProject:s,isProcessingThread:c,selectedThreadId:l,selectedProjectId:u,projects:d,projectsLoading:f,onSelectThread:p,onCreateThread:m,onConnectRepo:h,onNewApp:g,onOpenFolder:_,error:v,onClearError:y}=e,b=(0,Z.useRef)(null),x=(0,Z.useRef)(0),S=(0,Z.useRef)(!1),C;t[0]!==r||t[1]!==n.length?(C=()=>{let e=n.length>x.current,t=S.current&&!r;(r||e||t)&&requestAnimationFrame(()=>{b.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),x.current=n.length,S.current=r},t[0]=r,t[1]=n.length,t[2]=C):C=t[2];let w;t[3]!==r||t[4]!==n||t[5]!==i.length?(w=[r,n,i.length],t[3]=r,t[4]=n,t[5]=i.length,t[6]=w):w=t[6],(0,Z.useEffect)(C,w);let T=n.length===0&&!r&&!s&&!l,E=n.length===0&&!r&&!s&&l,D;if(t[7]!==d||t[8]!==u){let e;t[10]===u?e=t[11]:(e=e=>e.projectId===u,t[10]=u,t[11]=e),D=d.find(e),t[7]=d,t[8]=u,t[9]=D}else D=t[9];let O=D;if(T){let e=`transition-opacity duration-500 ease-in-out ${f?`opacity-0`:`opacity-100`}`,n;t[12]!==h||t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==p||t[17]!==d?(n=(0,$.jsx)(Ca,{projects:d,onSelectProject:p,onCreateThread:m,onConnectRepo:h,onNewApp:g,onOpenFolder:_}),t[12]=h,t[13]=m,t[14]=g,t[15]=_,t[16]=p,t[17]=d,t[18]=n):n=t[18];let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}if(E){let e;return t[22]===O?e=t[23]:(e=(0,$.jsx)(wa,{project:O}),t[22]=O,t[23]=e),e}let k;t[24]!==v||t[25]!==s||t[26]!==c||t[27]!==r||t[28]!==n.length||t[29]!==y||t[30]!==o||t[31]!==a||t[32]!==i?(k={isStreaming:r,isCreatingProject:s,isProcessingThread:c,streamingSegments:i,streamingModel:a,streamingEventCount:o,totalMessages:n.length,error:v,onClearError:y},t[24]=v,t[25]=s,t[26]=c,t[27]=r,t[28]=n.length,t[29]=y,t[30]=o,t[31]=a,t[32]=i,t[33]=k):k=t[33];let A=k,j;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(j=G(`flex-1 overflow-hidden`),t[34]=j):j=t[34];let M;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(M={height:`100%`},t[35]=M):M=t[35];let N;t[36]===l?N=t[37]:(N=(e,t)=>(0,$.jsx)(ya,{message:t,threadId:l,messageIndex:e}),t[36]=l,t[37]=N);let P;t[38]!==n||t[39]!==N?(P=(0,$.jsx)(Tn,{ref:b,style:M,data:n,itemContent:N,overscan:500,components:Oa}),t[38]=n,t[39]=N,t[40]=P):P=t[40];let F;return t[41]!==A||t[42]!==P?(F=(0,$.jsx)(`div`,{className:j,children:(0,$.jsx)(Ta.Provider,{value:A,children:P})}),t[41]=A,t[42]=P,t[43]=F):F=t[43],F}async function Aa(e){return en(`api/projects/${c(e)}/todos`)}async function ja(e,t){return u(`api/projects/${c(e)}/todos`,{description:t})}async function Ma(e,t,n){return h(`api/projects/${c(e)}/todos/${c(t)}`,n)}async function Na(e,t){await xe(`api/projects/${c(e)}/todos/${c(t)}`)}var Pa={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 Fa({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Pa[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 Ma(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:G(`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)(it,{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)(W,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,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)(W,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(ge,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var Ia=`Please analyze this task and create a detailed implementation plan.
18
+
19
+ Task description:
20
+ {description}`,La="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ra=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,za=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
21
+ Directions:
22
+ Carefully read through the list of code changes creating a todo list of code to review.
23
+ Analyze the code structure, variable names, functions, and logic flow
24
+ Look for any syntax errors, bugs, or inefficiencies
25
+ Consider best practices for the specific programming language used
26
+ Provide clear and constructive feedback on areas that could be improved
27
+ If applicable, include examples of how to refactor problematic code
28
+ Offer praise for portions of the code that are well-written and follow best practices
29
+
30
+ Task description:
31
+ {description}`,Ba={plan:Ia,test:Ra,review:za},Va={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Ha(e,t){let n=e?.[Va[t]];return n&&n.trim()?n:Ba[t]}function Ua(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=La.replace(/\{todoId\}/g,n)),i}var Wa=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],Ga={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 Ka(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(`
32
+ `);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 qa(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function Ja(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(`
33
+ `);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 Ya({projectId:e,addOpen:n,onAddOpenChange:r,onThreadSelect:i}){let{state:a,dispatch:o}=Pn(),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)(!0),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),k=(0,Z.useCallback)(async()=>{try{let t=await Aa(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await g(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ma(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),c(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{u(!1)}},[e]);(0,Z.useEffect)(()=>{k()},[k]),(0,Z.useEffect)(()=>{if(!s.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Aa(e);c(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[s,e]),(0,Z.useEffect)(()=>{n&&m(``)},[n]);function A(e){m(e.description),f({todo:e})}function j(){f(null),m(``)}async function M(){if(p.trim()){_(!0);try{let t=await ja(e,p);c(e=>[...e,t]),r(!1),m(``)}finally{_(!1)}}}async function N(){if(!(!p.trim()||!d)){_(!0);try{let t=await Ma(e,d.todo.id,{description:p});c(e=>e.map(e=>e.id===t.id?t:e)),j()}finally{_(!1)}}}async function P(){if(d){_(!0);try{await Na(e,d.todo.id),c(e=>e.filter(e=>e.id!==d.todo.id)),j()}finally{_(!1)}}}function F(e){c(t=>t.map(t=>t.id===e.id?e:t))}async function I(t){let n=a.selectedThreadId?a.projectModelSelections[a.selectedThreadId]:void 0,r=a.projects.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===a.selectedThreadId),s=n?.id??i?.model,c=n?.provider??i?.modelProvider;if(!s||!c)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 l=await V(e);if(!l)return;let u=null,d=await Ka(l,n=>{Ma(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,F(e)})});if(!d)return;u||F(await Ma(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};o({type:K.SetProjectModel,threadId:d,model:f}),Ge(d,{model:s,modelProvider:c});let p=await jt(d,Ua(Ha(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&qa(p)}async function L(t){let n=await V(e);if(!n)return;let r=null,i=await Ka(n,n=>{Ma(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Ma(e,t.id,{status:`Build`,working:!0,threadId:i}));let a=await g(i),s=a.model,c=a.modelProvider;if(!s||!c)try{let t=(await en(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,c=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!c)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);o({type:K.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),Ge(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await jt(i,t.description,s,[],void 0,c);l&&qa(l)}async function R(t){try{let n=await V(e);if(!n){y(!1),x(null);return}let r=null;if(r=await Ka(n,e=>{r=e}),!r){y(!1),x(null);return}let i=await g(r),o=i.model,s=i.modelProvider;if(!o||!s)try{let t=(await en(`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&&(o=t.model,s=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!o||!s){an(e,r),y(!1),x(null);return}let c=Ua(Ha(a.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await jt(r,c,o,[],void 0,s);l&&C(await Ja(l)),an(e,r)}catch(e){console.error(`Failed to generate test case:`,e),y(!1),x(null)}finally{E(!1)}}function z(e){x(e),C(``),E(!0),y(!0),R(e)}function ee(){y(!1),x(null),C(``)}async function te(){if(!b||!S.trim())return;let t=b,n=S;ee(),O(!0);try{let r=await V(e);if(!r)return;let i=null,a=await Ka(r,n=>{Ma(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,F(e)})});if(!a)return;i||F(await Ma(e,t.id,{status:`Test`,working:!0,threadId:a}));let s=await g(a),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await en(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);o({type:K.SetProjectModel,threadId:a,model:{id:c,provider:l,name:c,description:``}}),Ge(a,{model:c,modelProvider:l});let u=await jt(a,n,c,[],void 0,l);u&&qa(u)}finally{O(!1)}}async function B(t){let n=await V(e);if(!n)return;let r=null,i=await Ka(n,n=>{Ma(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Ma(e,t.id,{status:`Review`,working:!0,threadId:i}));let s=await g(i),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await en(`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&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);o({type:K.SetProjectModel,threadId:i,model:{id:c,provider:l,name:c,description:``}}),Ge(i,{model:c,modelProvider:l});let u=await jt(i,Ua(Ha(a.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&qa(u)}async function ne(t,n){n===`Plan`?await I(t):n===`Build`?await L(t):n===`Test`?z(t):n===`Review`?await B(t):F(await Ma(e,t.id,{status:n,working:n!==`Done`}))}return l?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(it,{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:Wa.map(n=>{let a=s.filter(e=>e.status===n),o=n===`Ready`;return(0,$.jsxs)(`div`,{className:G(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,Ga[n]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:n}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:a.length})]}),(0,$.jsx)(yt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[o&&(0,$.jsxs)(W,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>r(!0),children:[(0,$.jsx)(t,{className:`h-3 w-3 mr-1`}),`Add Task`]}),a.map(t=>(0,$.jsx)(Fa,{todo:t,projectId:e,onUpdate:F,onEdit:A,onAction:ne,onThreadSelect:i},t.id))]})})]},n)})}),(0,$.jsx)(_e,{open:n,onOpenChange:r,children:(0,$.jsxs)(sn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(Un,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(De,{children:(0,$.jsx)(W,{onClick:()=>void M(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(_e,{open:v,onOpenChange:e=>!e&&ee(),children:(0,$.jsxs)(sn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:T?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(it,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Un,{value:S,onChange:e=>C(e.target.value),rows:12,className:`resize-none text-sm`,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)(De,{children:[(0,$.jsx)(W,{variant:`outline`,onClick:ee,disabled:T,children:`Cancel`}),(0,$.jsx)(W,{onClick:()=>void te(),disabled:T||!S.trim()||D,children:D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(_e,{open:d!==null,onOpenChange:e=>!e&&j(),children:(0,$.jsxs)(sn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(we,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(Un,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&N()}})}),(0,$.jsxs)(De,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(W,{variant:`destructive`,onClick:()=>void P(),disabled:h,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(W,{onClick:()=>void N(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var Xa=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Ia},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:za},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ra}];function Za({open:e,onOpenChange:t,projectId:n}){let{state:r}=Pn(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,c]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e)return;let t=r.projects.find(e=>e.projectId===n);a({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,n,r.projects]);async function l(){c(!0);try{await ct(n,{planPrompt:i.plan.trim()===Ia?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ra?null:i.test.trim()||null,reviewPrompt:i.review.trim()===za?null:i.review.trim()||null}),Ee(),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){a(n=>({...n,[e]:t}))}return(0,$.jsx)(_e,{open:e,onOpenChange:t,children:(0,$.jsxs)(sn,{className:`max-w-2xl`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(we,{children:`AI Prompt Settings`}),(0,$.jsx)(s,{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)(Ar,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(kr,{className:`w-full`,children:Xa.map(e=>(0,$.jsx)(Dr,{value:e.value,className:`flex-1`,children:e.label},e.value))}),Xa.map(e=>(0,$.jsxs)(Or,{value:e.value,children:[(0,$.jsx)(Un,{value:i[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:o}),(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)(De,{children:(0,$.jsx)(W,{onClick:()=>void l(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function Qa({projectId:e}){let{state:t,dispatch:n}=Pn(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=bn(),{setActiveMainTab:l}=xr();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await kn(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.b);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([2,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 $t();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 $t();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)(Ya,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(W,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(x,{className:`h-4 w-4`})}),(0,$.jsx)(Za,{open:o,onOpenChange:s,projectId:e})]})}var $a=(0,Z.lazy)(()=>kn(()=>import(`./diff-view-DWNDi8zT.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,3,14,15,16,17,18,19,8,20]))),eo=(0,Z.lazy)(()=>kn(()=>import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.t),__vite__mapDeps([2,1])));function to(e){let t=(0,Q.c)(53),{onCreateThread:n}=e,{state:i,dispatch:a}=Pn(),o=bn(),s=xn(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),{selectedThreadId:f,messages:p,isCreatingProject:m,processingThreadIds:h,projects:g,projectsLoading:_,isStreaming:v,streamingSegments:y,streamingModel:b,streamingEventCount:x}=i,S;t[0]!==h||t[1]!==f?(S=f&&h.includes(f),t[0]=h,t[1]=f,t[2]=S):S=t[2];let C=!!S,w;t[3]!==a||t[4]!==i.sidebarOpen?(w=()=>{i.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=i.sidebarOpen,t[5]=w):w=t[5];let T=w,E;t[6]===T?E=t[7]:(E=()=>{T(),d(`clone`),l(!0)},t[6]=T,t[7]=E);let D=E,O;t[8]===T?O=t[9]:(O=()=>{T(),d(`webapp`),l(!0)},t[8]=T,t[9]=O);let k=O,A;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=async(e,t)=>{try{await _t(e,t),l(!1),d(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=A):A=t[10];let j=A,M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=async(e,t,n)=>{try{await r(e,t,n),l(!1),d(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=M):M=t[11];let N=M,P;t[12]===T?P=t[13]:(P=async()=>{T();try{await ee(),l(!1),d(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=T,t[13]=P);let F=P,I=s.pathname===`/review`,L=s.pathname===`/todos`,R;t[14]===o?R=t[15]:(R=()=>{o(`/`)},t[14]=o,t[15]=R);let z=R,{selectedProjectId:te}=i,B;t[16]!==T||t[17]!==a||t[18]!==D||t[19]!==z||t[20]!==k||t[21]!==F||t[22]!==m||t[23]!==C||t[24]!==v||t[25]!==p||t[26]!==n||t[27]!==g||t[28]!==_||t[29]!==I||t[30]!==te||t[31]!==f||t[32]!==x||t[33]!==b||t[34]!==y||t[35]!==L?(B=L&&te?(0,$.jsx)(Qa,{projectId:te}):I&&f?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)($a,{threadId:f,onExit:z})}):(0,$.jsx)(ka,{messages:p,isStreaming:v,streamingSegments:y,streamingModel:b,streamingEventCount:x,isCreatingProject:m,isProcessingThread:C,selectedThreadId:f,selectedProjectId:te,projects:g,projectsLoading:_,onSelectThread:(e,t)=>{T(),a({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:D,onNewApp:k,onOpenFolder:F,error:null,onClearError:no}),t[16]=T,t[17]=a,t[18]=D,t[19]=z,t[20]=k,t[21]=F,t[22]=m,t[23]=C,t[24]=v,t[25]=p,t[26]=n,t[27]=g,t[28]=_,t[29]=I,t[30]=te,t[31]=f,t[32]=x,t[33]=b,t[34]=y,t[35]=L,t[36]=B):B=t[36];let V;t[37]!==p||t[38]!==I||t[39]!==f||t[40]!==L?(V=!I&&!L&&f&&(0,$.jsx)(or,{messages:p}),t[37]=p,t[38]=I,t[39]=f,t[40]=L,t[41]=V):V=t[41];let ne=u??void 0,H;t[42]!==c||t[43]!==F||t[44]!==ne?(H=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(eo,{open:c,onOpenChange:l,initialMode:ne,onSubmitClone:j,onSubmitWebApp:N,onOpenFolder:F})}),t[42]=c,t[43]=F,t[44]=ne,t[45]=H):H=t[45];let re;t[46]!==V||t[47]!==H||t[48]!==B?(re=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[B,V,H]}),t[46]=V,t[47]=H,t[48]=B,t[49]=re):re=t[49];let ie;return t[50]!==f||t[51]!==re?(ie=(0,$.jsx)(Zn,{threadId:f,children:re}),t[50]=f,t[51]=re,t[52]=ie):ie=t[52],ie}function no(){}var ro=`VS Code`,io={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function ao({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(n??ro),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await et();o(e),!s&&e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([ro])}finally{u(!1)}})()},[]),(0,Z.useEffect)(()=>{n&&a.includes(n)&&c(n)},[n,a,c]);let d=async n=>{try{i(!0),c(n),await ze(e,n),t?await I(t,n):await zt(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)}};return l?(0,$.jsx)(W,{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)(W,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await d(s)},title:`Open in ${s}`,children:(0,$.jsx)(`img`,{src:`/ide/${io[s]||io[ro]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(ir,{children:[(0,$.jsx)(sr,{asChild:!0,children:(0,$.jsx)(W,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(Ze,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,children:a.map(e=>(0,$.jsxs)(Kn,{onClick:()=>d(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${io[e]||io[ro]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function oo(e,t){return t?`Creating PR...`:e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Sync`:e.hasChanges?`Commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`Open PR`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create PR`:e.hasUnpushedCommits&&e.prExists?`Update PR`:`Commit`}function so(e,t){return t?(0,$.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(le,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(ge,{className:`h-3.5 w-3.5`}):(0,$.jsx)(m,{className:`h-3.5 w-3.5`})}function co(e){return e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Your branch "${e.currentBranch}" is behind "${e.defaultBranch??`main`}". This will rebase and sync with the latest changes`:e.hasChanges?e.changedFilesCount>0?`Commit ${e.changedFilesCount} changed file${e.changedFilesCount===1?``:`s`}`:`No changes to commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`View pull request in GitHub`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create pull request for committed changes`:e.hasUnpushedCommits&&e.prExists?`Update pull request with unpushed commits`:`No actions available`}function lo(e,t){return t?!0:e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?!1:!e.hasChanges&&!e.hasUnpushedCommits}function uo(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function fo(e){let t=(0,Q.c)(79),{branchStatus:n,remoteUrl:r,hasRemoteBranch:i,hasUnpushedCommits:a,canCreateRepo:o,repoUrl:s,isRefreshing:c,isBrandState:l,gitUser:u,isDirectCommitMode:d,isLoading:f,isLoadingHistory:p,onFetch:h,onPull:g,onPush:_,onOpenHistory:v,onCreatePR:y,onCreateRepo:b,onViewInGitHub:x}=e,S=`h-8 w-8 rounded-l-none px-1 border-transparent${l?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,C;t[0]===c?C=t[1]:(C=c?(0,$.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ze,{className:`h-3.5 w-3.5`}),t[0]=c,t[1]=C);let w;t[2]!==f||t[3]!==S||t[4]!==C?(w=(0,$.jsx)(sr,{asChild:!0,children:(0,$.jsx)(W,{variant:`outline`,size:`sm`,className:S,disabled:f,children:C})}),t[2]=f,t[3]=S,t[4]=C,t[5]=w):w=t[5];let T;t[6]!==n||t[7]!==r?(T=n===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,r?`origin`:`remote`]}),t[6]=n,t[7]=r,t[8]=T):T=t[8];let E;t[9]===u?E=t[10]:(E=u&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,u]}),t[9]=u,t[10]=E);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(nr,{}),t[11]=D):D=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(on,{className:`h-3.5 w-3.5 mr-2`}),t[12]=O):O=t[12];let k;t[13]!==f||t[14]!==h?(k=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(Kn,{onClick:h,disabled:f,children:[O,`Fetch`]})}),t[13]=f,t[14]=h,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),t[16]=A):A=t[16];let j;t[17]===k?j=t[18]:(j=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[k,A]})}),t[17]=k,t[18]=j);let M;t[19]!==i||t[20]!==f||t[21]!==g?(M=()=>{i&&!f&&g()},t[19]=i,t[20]=f,t[21]=g,t[22]=M):M=t[22];let N=!i||f?`opacity-50 cursor-not-allowed`:``,P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 mr-2`}),t[23]=P):P=t[23];let F;t[24]!==M||t[25]!==N?(F=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(Kn,{onClick:M,className:N,children:[P,`Pull`]})}),t[24]=M,t[25]=N,t[26]=F):F=t[26];let I=i?`Pull latest changes from remote`:`No remote branch to pull from`,L;t[27]===I?L=t[28]:(L=(0,$.jsx)(q,{side:`right`,children:I}),t[27]=I,t[28]=L);let R;t[29]!==F||t[30]!==L?(R=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[F,L]})}),t[29]=F,t[30]=L,t[31]=R):R=t[31];let z;t[32]!==i||t[33]!==f||t[34]!==_?(z=!i&&(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(Kn,{onClick:_,disabled:f,children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-2`}),`Push Branch to Remote`]})}),(0,$.jsx)(q,{side:`right`,children:`Create remote branch and push local commits`})]})}),t[32]=i,t[33]=f,t[34]=_,t[35]=z):z=t[35];let ee;t[36]!==a||t[37]!==f||t[38]!==_?(ee=()=>{a&&!f&&_()},t[36]=a,t[37]=f,t[38]=_,t[39]=ee):ee=t[39];let te=!a||f?`opacity-50 cursor-not-allowed`:``,B;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-2`}),t[40]=B):B=t[40];let V;t[41]!==ee||t[42]!==te?(V=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(Kn,{onClick:ee,className:te,children:[B,`Push Commits`]})}),t[41]=ee,t[42]=te,t[43]=V):V=t[43];let ne=a?f?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,H;t[44]===ne?H=t[45]:(H=(0,$.jsx)(q,{side:`right`,children:ne}),t[44]=ne,t[45]=H);let ie;t[46]!==V||t[47]!==H?(ie=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[V,H]})}),t[46]=V,t[47]=H,t[48]=ie):ie=t[48];let ae=f||p,oe;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(be,{className:`h-3.5 w-3.5 mr-2`}),t[49]=oe):oe=t[49];let se;t[50]!==v||t[51]!==ae?(se=(0,$.jsxs)(Kn,{onClick:v,disabled:ae,children:[oe,`History`]}),t[50]=v,t[51]=ae,t[52]=se):se=t[52];let ce;t[53]!==d||t[54]!==f||t[55]!==y?(ce=!d&&(0,$.jsxs)(Kn,{onClick:y,disabled:f,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[53]=d,t[54]=f,t[55]=y,t[56]=ce):ce=t[56];let le;t[57]!==o||t[58]!==f||t[59]!==b?(le=o&&(0,$.jsxs)(Kn,{onClick:b,disabled:f,children:[(0,$.jsx)(Se,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[57]=o,t[58]=f,t[59]=b,t[60]=le):le=t[60];let U;t[61]!==f||t[62]!==x||t[63]!==s?(U=s&&(0,$.jsxs)(Kn,{onClick:x,disabled:f,children:[(0,$.jsx)(ge,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[61]=f,t[62]=x,t[63]=s,t[64]=U):U=t[64];let ue;t[65]!==j||t[66]!==R||t[67]!==z||t[68]!==ie||t[69]!==se||t[70]!==ce||t[71]!==le||t[72]!==U||t[73]!==T||t[74]!==E?(ue=(0,$.jsxs)(Qn,{align:`end`,children:[T,E,D,j,R,z,ie,se,ce,le,U]}),t[65]=j,t[66]=R,t[67]=z,t[68]=ie,t[69]=se,t[70]=ce,t[71]=le,t[72]=U,t[73]=T,t[74]=E,t[75]=ue):ue=t[75];let de;return t[76]!==w||t[77]!==ue?(de=(0,$.jsxs)(ir,{children:[w,ue]}),t[76]=w,t[77]=ue,t[78]=de):de=t[78],de}function po(){return{autoGenerateCommitMessage:tt(),autoGeneratePRInfo:Nt(),privateRepositoryDefault:ot()}}function mo(e){e.autoGenerateCommitMessage!==void 0&&rt(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&Re(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&Zt(e.privateRepositoryDefault)}function ho(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function go(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:c,isGeneratingMessage:l,isLoading:u,onGenerateMessage:d,onCommit:f,currentBranch:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(we,{children:`Commit Changes`}),t[0]=m):m=t[0];let h;t[1]===p?h=t[2]:(h=(0,$.jsxs)(w,{children:[m,(0,$.jsxs)(s,{children:[`Enter a commit message for your changes on branch `,p]})]}),t[1]=p,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(H,{htmlFor:`commit-message`,children:`Commit Message`}),t[3]=g):g=t[3];let _;t[4]===a?_=t[5]:(_=e=>a(e.target.value),t[4]=a,t[5]=_);let v;t[6]!==i||t[7]!==_?(v=(0,$.jsx)(Un,{id:`commit-message`,placeholder:`Enter commit message...`,value:i,onChange:_,rows:4,className:`pr-10`}),t[6]=i,t[7]=_,t[8]=v):v=t[8];let y=l||u,b;t[9]===l?b=t[10]:(b=l?(0,$.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Te,{className:`h-3.5 w-3.5`}),t[9]=l,t[10]=b);let x;t[11]!==d||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:y,children:b})}),t[11]=d,t[12]=y,t[13]=b,t[14]=x):x=t[14];let S=l?`Generating commit message...`:`Generate commit message with AI`,C;t[15]===S?C=t[16]:(C=(0,$.jsx)(q,{children:S}),t[15]=S,t[16]=C);let T;t[17]!==C||t[18]!==x?(T=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[x,C]})}),t[17]=C,t[18]=x,t[19]=T):T=t[19];let E;t[20]!==T||t[21]!==v?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,T]})]}),t[20]=T,t[21]=v,t[22]=E):E=t[22];let D;t[23]===c?D=t[24]:(D=e=>c(e===!0),t[23]=c,t[24]=D);let O;t[25]!==o||t[26]!==D?(O=(0,$.jsx)(Cr,{id:`auto-generate`,checked:o,onCheckedChange:D}),t[25]=o,t[26]=D,t[27]=O):O=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(H,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=k):k=t[28];let A;t[29]===O?A=t[30]:(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,k]}),t[29]=O,t[30]=A);let j;t[31]!==E||t[32]!==A?(j=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[E,A]}),t[31]=E,t[32]=A,t[33]=j):j=t[33];let M;t[34]===r?M=t[35]:(M=()=>r(!1),t[34]=r,t[35]=M);let N;t[36]!==u||t[37]!==M?(N=(0,$.jsx)(W,{variant:`outline`,onClick:M,disabled:u,children:`Cancel`}),t[36]=u,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==i||t[40]!==u?(P=u||!i.trim(),t[39]=i,t[40]=u,t[41]=P):P=t[41];let F=u?`Committing...`:`Commit`,I;t[42]!==f||t[43]!==P||t[44]!==F?(I=(0,$.jsx)(W,{onClick:f,disabled:P,children:F}),t[42]=f,t[43]=P,t[44]=F,t[45]=I):I=t[45];let L;t[46]!==N||t[47]!==I?(L=(0,$.jsxs)(De,{children:[N,I]}),t[46]=N,t[47]=I,t[48]=L):L=t[48];let R;t[49]!==j||t[50]!==h||t[51]!==L?(R=(0,$.jsxs)(sn,{children:[h,j,L]}),t[49]=j,t[50]=h,t[51]=L,t[52]=R):R=t[52];let z;return t[53]!==r||t[54]!==n||t[55]!==R?(z=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:R}),t[53]=r,t[54]=n,t[55]=R,t[56]=z):z=t[56],z}function _o(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:c,isGeneratingPRInfo:l,isLoading:u,onGeneratePRInfo:d,onCreatePR:f,currentBranch:p,autoGeneratePRInfo:m,onAutoGeneratePRInfoChange:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(we,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===p?_=t[2]:(_=(0,$.jsxs)(w,{children:[g,(0,$.jsxs)(s,{children:[`Create a pull request for branch `,p]})]}),t[1]=p,t[2]=_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(H,{htmlFor:`pr-title`,children:`Title (optional)`}),t[3]=v):v=t[3];let y=p||`Enter PR title...`,b;t[4]===a?b=t[5]:(b=e=>a(e.target.value),t[4]=a,t[5]=b);let x;t[6]!==i||t[7]!==y||t[8]!==b?(x=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(ae,{id:`pr-title`,placeholder:y,value:i,onChange:b})]}),t[6]=i,t[7]=y,t[8]=b,t[9]=x):x=t[9];let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(H,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=S):S=t[10];let C;t[11]===c?C=t[12]:(C=e=>c(e.target.value),t[11]=c,t[12]=C);let T;t[13]!==o||t[14]!==C?(T=(0,$.jsx)(Un,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:C,rows:4,className:`pr-10`}),t[13]=o,t[14]=C,t[15]=T):T=t[15];let E=l||u,D;t[16]===l?D=t[17]:(D=l?(0,$.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Te,{className:`h-3.5 w-3.5`}),t[16]=l,t[17]=D);let O;t[18]!==d||t[19]!==E||t[20]!==D?(O=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:E,children:D})}),t[18]=d,t[19]=E,t[20]=D,t[21]=O):O=t[21];let k=l?`Generating PR description...`:`Generate PR title and description with AI`,A;t[22]===k?A=t[23]:(A=(0,$.jsx)(q,{children:k}),t[22]=k,t[23]=A);let j;t[24]!==O||t[25]!==A?(j=(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[O,A]})}),t[24]=O,t[25]=A,t[26]=j):j=t[26];let M;t[27]!==j||t[28]!==T?(M=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsxs)(`div`,{className:`relative`,children:[T,j]})]}),t[27]=j,t[28]=T,t[29]=M):M=t[29];let N;t[30]===h?N=t[31]:(N=e=>h(e===!0),t[30]=h,t[31]=N);let P;t[32]!==m||t[33]!==N?(P=(0,$.jsx)(Cr,{id:`auto-generate-pr`,checked:m,onCheckedChange:N}),t[32]=m,t[33]=N,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(H,{htmlFor:`auto-generate-pr`,className:`text-sm font-normal`,children:`Auto generate PR title and description`}),t[35]=F):F=t[35];let I;t[36]===P?I=t[37]:(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,F]}),t[36]=P,t[37]=I);let L;t[38]!==M||t[39]!==I||t[40]!==x?(L=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[x,M,I]}),t[38]=M,t[39]=I,t[40]=x,t[41]=L):L=t[41];let R;t[42]===r?R=t[43]:(R=()=>r(!1),t[42]=r,t[43]=R);let z;t[44]!==u||t[45]!==R?(z=(0,$.jsx)(W,{variant:`outline`,onClick:R,disabled:u,children:`Cancel`}),t[44]=u,t[45]=R,t[46]=z):z=t[46];let ee=u?`Creating...`:`Create PR`,te;t[47]!==u||t[48]!==f||t[49]!==ee?(te=(0,$.jsx)(W,{onClick:f,disabled:u,children:ee}),t[47]=u,t[48]=f,t[49]=ee,t[50]=te):te=t[50];let B;t[51]!==z||t[52]!==te?(B=(0,$.jsxs)(De,{children:[z,te]}),t[51]=z,t[52]=te,t[53]=B):B=t[53];let V;t[54]!==_||t[55]!==L||t[56]!==B?(V=(0,$.jsxs)(sn,{children:[_,L,B]}),t[54]=_,t[55]=L,t[56]=B,t[57]=V):V=t[57];let ne;return t[58]!==r||t[59]!==n||t[60]!==V?(ne=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:V}),t[58]=r,t[59]=n,t[60]=V,t[61]=ne):ne=t[61],ne}function vo(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:c,isPrivateRepo:l,onPrivateRepoChange:u,isLoading:d,onCreateRepo:f}=e,p;t[0]!==r||t[1]!==c||t[2]!==a?(p=e=>{e||(a(``),c(``)),r(e)},t[0]=r,t[1]=c,t[2]=a,t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(w,{children:[(0,$.jsx)(we,{children:`Create GitHub Repository`}),(0,$.jsx)(s,{children:`Create a new GitHub repository and push your local repository`})]}),t[4]=m):m=t[4];let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(H,{htmlFor:`repo-name`,children:`Repository Name (optional)`}),t[5]=h):h=t[5];let g;t[6]===a?g=t[7]:(g=e=>a(e.target.value),t[6]=a,t[7]=g);let _;t[8]!==i||t[9]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(ae,{id:`repo-name`,placeholder:`Leave empty to use current folder name`,value:i,onChange:g})]}),t[8]=i,t[9]=g,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(H,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===c?y=t[13]:(y=e=>c(e.target.value),t[12]=c,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(Un,{id:`repo-description`,placeholder:`Enter repository description...`,value:o,onChange:y,rows:3})]}),t[14]=o,t[15]=y,t[16]=b):b=t[16];let x;t[17]===u?x=t[18]:(x=e=>u(e===!0),t[17]=u,t[18]=x);let S;t[19]!==l||t[20]!==x?(S=(0,$.jsx)(Cr,{id:`repo-private`,checked:l,onCheckedChange:x}),t[19]=l,t[20]=x,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(H,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=C):C=t[22];let T;t[23]===S?T=t[24]:(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[23]=S,t[24]=T);let E;t[25]!==T||t[26]!==_||t[27]!==b?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,T]}),t[25]=T,t[26]=_,t[27]=b,t[28]=E):E=t[28];let D;t[29]===r?D=t[30]:(D=()=>r(!1),t[29]=r,t[30]=D);let O;t[31]!==d||t[32]!==D?(O=(0,$.jsx)(W,{variant:`outline`,onClick:D,disabled:d,children:`Cancel`}),t[31]=d,t[32]=D,t[33]=O):O=t[33];let k=d?`Creating...`:`Create & Push`,A;t[34]!==d||t[35]!==f||t[36]!==k?(A=(0,$.jsx)(W,{onClick:f,disabled:d,children:k}),t[34]=d,t[35]=f,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==O||t[39]!==A?(j=(0,$.jsxs)(De,{children:[O,A]}),t[38]=O,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==E||t[42]!==j?(M=(0,$.jsxs)(sn,{children:[m,E,j]}),t[41]=E,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==p||t[46]!==M?(N=(0,$.jsx)(_e,{open:n,onOpenChange:p,children:M}),t[44]=n,t[45]=p,t[46]=M,t[47]=N):N=t[47],N}function yo(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:c,currentBranch:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(we,{children:`Commit History`}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,$.jsxs)(w,{children:[u,(0,$.jsxs)(s,{children:[`Recent commits on branch `,l]})]}),t[1]=l,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(bo):(0,$.jsx)(`p`,{className:`text-sm text-slate-500 text-center py-8`,children:`No commits found`}),t[3]=a,t[4]=f);let p;t[5]===o?p=t[6]:(p=o&&(0,$.jsx)(`div`,{className:`p-3 text-center`,children:(0,$.jsx)(it,{className:`h-4 w-4 animate-spin inline`})}),t[5]=o,t[6]=p);let m;t[7]!==i.length||t[8]!==a.length||t[9]!==o?(m=a.length<i.length&&!o&&(0,$.jsx)(`div`,{className:`p-3 text-center text-xs text-slate-500`,children:`Scroll to load more`}),t[7]=i.length,t[8]=a.length,t[9]=o,t[10]=m):m=t[10];let h;t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`divide-y`,children:[f,p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==c||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:c,children:h}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(De,{children:(0,$.jsx)(W,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==d||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(sn,{className:`max-w-2xl max-h-[80vh] flex flex-col`,children:[d,g,_]}),t[20]=d,t[21]=g,t[22]=_,t[23]=v):v=t[23];let y;return t[24]!==r||t[25]!==n||t[26]!==v?(y=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function bo(e){return(0,$.jsxs)(`div`,{className:`p-3 hover:bg-slate-50 dark:hover:bg-slate-900 transition-colors`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium break-words`,children:e.message}),(0,$.jsxs)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400 mt-1`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:e.hash.substring(0,7)}),` •`,` `,e.author,` • `,new Date(e.date).toLocaleDateString()]})]},e.hash)}function xo(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(w,{children:[(0,$.jsx)(we,{children:`Push Branch First`}),(0,$.jsx)(s,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=c):c=t[0];let l;t[1]!==i||t[2]!==o?(l=(0,$.jsx)(W,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=l):l=t[3];let u=i?`Pushing...`:`Push & Create PR`,d;t[4]!==i||t[5]!==a||t[6]!==u?(d=(0,$.jsx)(W,{onClick:a,disabled:i,children:u}),t[4]=i,t[5]=a,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==l||t[9]!==d?(f=(0,$.jsxs)(sn,{children:[c,(0,$.jsxs)(De,{children:[l,d]})]}),t[8]=l,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function So(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:c}=e,l=c===void 0?!1:c,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(w,{children:[(0,$.jsxs)(we,{className:`flex items-center gap-2`,children:[(0,$.jsx)(oe,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(s,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Choose how you want to proceed:`}),t[1]=d):d=t[1];let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(le,{className:`h-4 w-4 mr-2`}),t[2]=f):f=t[2];let p;t[3]!==l||t[4]!==i?(p=(0,$.jsxs)(W,{onClick:i,disabled:l,className:`w-full justify-start`,variant:`outline`,children:[f,`Commit changes first, then pull`]}),t[3]=l,t[4]=i,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(He,{className:`h-4 w-4 mr-2`}),t[6]=m):m=t[6];let h;t[7]!==l||t[8]!==a?(h=(0,$.jsxs)(W,{onClick:a,disabled:l,className:`w-full justify-start`,variant:`outline`,children:[m,`Stash changes → Pull → Restore changes`]}),t[7]=l,t[8]=a,t[9]=h):h=t[9];let g;t[10]!==p||t[11]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[p,h]}),t[10]=p,t[11]=h,t[12]=g):g=t[12];let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`strong`,{children:`Commit first:`}),t[13]=_):_=t[13];let v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-4`,children:[_,` Safe option, preserves changes in your commit history`,(0,$.jsx)(`br`,{}),(0,$.jsx)(`strong`,{children:`Stash and pull:`}),` Temporary option, changes will be restored after pulling`]}),t[14]=v):v=t[14];let y;t[15]===g?y=t[16]:(y=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,g,v]})}),t[15]=g,t[16]=y);let b;t[17]!==l||t[18]!==o?(b=(0,$.jsx)(De,{children:(0,$.jsx)(W,{variant:`ghost`,onClick:o,disabled:l,children:`Cancel`})}),t[17]=l,t[18]=o,t[19]=b):b=t[19];let x;t[20]!==y||t[21]!==b?(x=(0,$.jsxs)(sn,{className:`sm:max-w-[425px]`,children:[u,y,b]}),t[20]=y,t[21]=b,t[22]=x):x=t[22];let S;return t[23]!==r||t[24]!==n||t[25]!==x?(S=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:x}),t[23]=r,t[24]=n,t[25]=x,t[26]=S):S=t[26],S}function Co(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:c}=e,l=o===void 0?!1:o,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(we,{children:`Pull Request Merged`}),t[0]=u):u=t[0];let d=c?` from ${c}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(w,{children:[u,(0,$.jsxs)(s,{children:[`As the pull request has been merged a new branch will be created`,d,`.`]})]}),t[1]=d,t[2]=f);let p;t[3]!==l||t[4]!==a?(p=(0,$.jsx)(W,{variant:`ghost`,onClick:a,disabled:l,children:`Just Open`}),t[3]=l,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==l||t[7]!==i?(m=(0,$.jsx)(W,{onClick:i,disabled:l,children:`New Branch`}),t[6]=l,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(De,{children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==f||t[13]!==h?(g=(0,$.jsxs)(sn,{children:[f,h]}),t[12]=f,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==r||t[16]!==n||t[17]!==g?(_=(0,$.jsx)(_e,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function wo(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function To(e,t,n){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=()=>{let t=e?n[e]:void 0;return t?.id?t.provider?{provider:t.provider,model:t.id}:wo(t.id):{provider:void 0,model:void 0}};return{isGeneratingMessage:r,isGeneratingPRInfo:a,generateCommitMessageWithAI:async()=>{if(!e)return null;try{i(!0);let{provider:t,model:n}=s();return await M(e,n,t)}catch(e){return console.error(`Failed to generate commit message:`,e),X({title:`Error`,description:e instanceof Error?e.message:`Failed to generate commit message`,variant:`destructive`}),null}finally{i(!1)}},generatePRInfoWithAI:async()=>{if(!e)return null;try{o(!0);let{provider:t,model:n}=s(),r=await je(e,n,t);return X({title:`Success`,description:`PR title and description generated`}),r}catch(e){return console.error(`Failed to generate PR info:`,e),X({title:`Error`,description:e instanceof Error?e.message:`Failed to generate PR info`,variant:`destructive`}),null}finally{o(!1)}}}}function Eo({projectId:e,threadId:t}){let{state:n,dispatch:r}=Pn(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),[v,b]=(0,Z.useState)(!1),[x,C]=(0,Z.useState)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)([]),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[z,ee]=(0,Z.useState)(``),[te,B]=(0,Z.useState)(``),[V,ne]=(0,Z.useState)(``),[H,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[oe,le]=(0,Z.useState)(!1),U=tr(t),ue=To(t,e,n.projectModelSelections);async function de(){Ee();let e=await rn();r({type:K.SetProjects,projects:e.projects})}let[fe,me]=(0,Z.useState)(()=>po()),he=n.projects.find(t=>t.projectId===e),ge=he?.commitMethod===kt.Direct;(0,Z.useEffect)(()=>{function e(){document.visibilityState===`visible`&&U.fetchUnifiedStatus(!0)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[U.fetchUnifiedStatus]),(0,Z.useEffect)(()=>{L&&he?.name&&!z&&ee(he.name)},[L,he?.name,z]),(0,Z.useEffect)(()=>{mo(fe)},[fe]),(0,Z.useEffect)(()=>{let e=!0;return qe().then(t=>{e&&ne(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){T.current=!1;return}if(c&&fe.autoGenerateCommitMessage&&!f.trim()&&t&&!T.current){T.current=!0;async function e(){let e=await ue.generateCommitMessageWithAI();e&&p(e)}e()}},[c,fe.autoGenerateCommitMessage,t,ue,f]),(0,Z.useEffect)(()=>{if(!u){w.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:u,autoGeneratePRInfo:fe.autoGeneratePRInfo,prTitleEmpty:!m.trim(),prDescriptionEmpty:!g.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:w.current}),u&&fe.autoGeneratePRInfo&&!m.trim()&&!g.trim()&&t&&!w.current){console.log(`[pr-auto-gen] Starting auto-generation...`),w.current=!0;async function e(){let e=await ue.generatePRInfoWithAI();e&&(console.log(`[pr-auto-gen] Setting PR info:`,e.title.substring(0,50)),h(e.title),_(e.description))}e()}else console.log(`[pr-auto-gen] Skipping auto-generation - conditions not met`)},[u,fe.autoGeneratePRInfo,t,ue,m,g]),(0,Z.useEffect)(()=>{console.log(`Unified status changed:`,{prExists:U.prExists,prState:U.prState,threadId:t}),U.prExists&&U.prState===`MERGED`&&(console.log(`Merged PR detected, opening dialog`),le(!0))},[U.prExists,U.prState,t]),(0,Z.useEffect)(()=>{!n.isStreaming&&n.completedThreadIds.includes(n.selectedThreadId??``)&&(U.fetchUnifiedStatus(!0),r({type:K.ClearThreadCompleted,threadId:n.selectedThreadId??``}))},[n.isStreaming,n.completedThreadIds,n.selectedThreadId,U,r]);async function _e(){if(f.trim()&&ho(t))try{a(!0),await se(t,f),p(``),l(!1),await U.fetchUnifiedStatus(!0),de(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${U.currentBranch}'.`}),ie&&(ae(!1),await we())}catch(e){console.error(`Failed to commit:`,e),X({title:`Commit failed`,description:e instanceof Error?e.message:`Failed to commit changes`,variant:`destructive`})}finally{a(!1)}}async function ye(){if(U.status===`Behind`&&!U.hasChanges&&!U.hasUnpushedCommits){await G();return}if(U.hasChanges){l(!0);return}if(U.prExists&&U.prState===`OPEN`&&!U.hasChanges&&!U.hasUnpushedCommits){U.prUrl&&await S(U.prUrl);return}if(U.commitsAheadOfDefault&&!U.prExists&&!U.hasChanges){d(!0);return}if(U.hasUnpushedCommits&&U.prExists){await Se();return}}async function be(){let e=await ue.generateCommitMessageWithAI();e&&p(e)}async function xe(){if(ho(t))try{a(!0),await j(t),await U.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function Se(){if(ho(t))try{a(!0),await ln(t),await U.fetchUnifiedStatus(!0),de(),U.hasRemoteBranch?X({title:`Branch pushed successfully`,description:`Your branch '${U.currentBranch}' has been pushed to the remote.`}):X({title:`Push completed`,description:`Changes have been pushed successfully.`})}catch(e){console.error(`Failed to push:`,e),X({title:`Push failed`,description:e instanceof Error?e.message:`Failed to push to remote`,variant:`destructive`})}finally{a(!1)}}async function Ce(){if(ho(t)){if(U.hasChanges){re(!0);return}await we()}}async function we(){try{a(!0),await ve(t),await U.fetchUnifiedStatus(!0),de(),X({title:`Pull successful`,description:`Latest changes have been pulled from remote.`})}catch(e){console.error(`Failed to pull:`,e),X({title:`Pull failed`,description:e instanceof Error?e.message:`Failed to pull from remote`,variant:`destructive`})}finally{a(!1)}}function Te(){re(!1),ae(!0),l(!0)}async function De(){re(!1),await we()}async function ke(){if(t)try{a(!0);let e=await pe(t,U.defaultBranch??void 0);Ee();let n=await rn();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),le(!1),await U.fetchUnifiedStatus(!0),setTimeout(()=>void U.fetchUnifiedStatus(!0),1500)}catch(e){console.error(`Failed to create new branch:`,e),X({title:`Failed to create new branch`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}finally{a(!1)}}async function G(){if(!ho(t)){console.log(`[sync] Thread operation validation failed`);return}try{console.log(`[sync] Starting branch sync for thread: ${t}`),console.log(`[sync] Current branch: ${U.currentBranch}, Default branch: ${U.defaultBranch}`),a(!0),console.log(`[sync] Calling gitSyncBranch API...`);let e=await Oe(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await U.fetchUnifiedStatus(!0),de(),console.log(`[sync] ✓ Git status refreshed`),X({title:`Branch synced successfully`,description:`Your branch '${U.currentBranch}' has been synced with the latest changes`}),console.log(`[sync] ✓ Sync operation completed successfully`)}catch(e){console.error(`[sync] ✗ Failed to sync branch:`,e),X({title:`Sync failed`,description:e instanceof Error?e.message:`Failed to sync with default branch`,variant:`destructive`})}finally{a(!1)}}async function Ae(){if(ho(t))try{a(!0),s(!0);let e=await y(t,m,g);e.prUrl&&await S(e.prUrl),h(``),_(``),d(!1),await U.fetchUnifiedStatus(),de()}catch(e){console.error(`Failed to create PR:`,e);let t=e instanceof Error?e.message:`Failed to create PR`;t.includes(`push the current branch`)||t.includes(`--head flag`)?(d(!1),Ne({title:m,description:g})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),s(!1)}}async function je(){if(ho(t))try{a(!0);let e=await ce(t,z,te,fe.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{S(e.repoUrl)},3e3),ee(``),B(``),R(!1),await U.fetchUnifiedStatus(),de()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Me(){let e=await ue.generatePRInfoWithAI();e&&(h(e.title),_(e.description))}async function Ne(e){let n=e??x;if(!(!t||!n))try{a(!0),s(!0);try{await ln(t)}catch(e){let n=e?.message??``;if(n.includes(`non-fast-forward`)||n.includes(`Updates were rejected because the tip of your current branch is behind`)){console.log(`[push-and-pr] Non-fast-forward error detected, pulling first...`),X({title:`Syncing branch before push`,description:`Your branch is behind remote. Pulling latest changes first...`});try{await Oe(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await ln(t),console.log(`[push-and-pr] ✓ Push succeeded after pull`)}catch(t){throw console.error(`[push-and-pr] Pull failed:`,t),e}}else throw e}let e=await y(t,n.title,n.description);e.prUrl&&await S(e.prUrl),h(``),_(``),C(null),b(!1),await U.fetchUnifiedStatus(),de()}catch(e){console.error(`Failed to push and create PR:`,e),X({title:`Push & Create PR Failed`,description:e instanceof Error?e.message:`Failed to push and create PR`,variant:`destructive`})}finally{a(!1),s(!1)}}async function Pe(){if(ho(t))try{M(!0);let e=await Mt(t,100);k(e),P(e.slice(0,10)),D(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{M(!1)}}function Fe(){F||(I(!0),setTimeout(()=>{let e=N.length+10;P(O.slice(0,e)),I(!1)},300))}function Ie(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&N.length<O.length&&!F&&Fe()}let Le=uo(U);function Re(){U.repoUrl&&S(U.repoUrl)}function ze(){b(!1),C(null)}function Be(){le(!1),U.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(W,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${Le?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:lo(U,i),onClick:ye,children:[so(U,o),oo(U,o)]})}),(0,$.jsx)(q,{children:co(U)})]})}),(0,$.jsx)(fo,{branchStatus:U.status,remoteUrl:U.remoteUrl,hasRemoteBranch:U.hasRemoteBranch,hasUnpushedCommits:U.hasUnpushedCommits,canCreateRepo:U.canCreateRepo,repoUrl:U.repoUrl,isRefreshing:U.isRefreshing,isBrandState:Le,gitUser:V,isDirectCommitMode:ge,isLoading:i,isLoadingHistory:A,onFetch:()=>void xe(),onPull:()=>void Ce(),onPush:()=>void Se(),onOpenHistory:()=>void Pe(),onCreatePR:()=>d(!0),onCreateRepo:()=>R(!0),onViewInGitHub:Re})]}),(0,$.jsx)(go,{open:c,onOpenChange:l,commitMessage:f,onCommitMessageChange:p,autoGenerateCommitMessage:fe.autoGenerateCommitMessage,onAutoGenerateChange:e=>me(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:ue.isGeneratingMessage,isLoading:i,onGenerateMessage:be,onCommit:_e,currentBranch:U.currentBranch}),(0,$.jsx)(_o,{open:u,onOpenChange:d,prTitle:m,onPrTitleChange:h,prDescription:g,onPrDescriptionChange:_,isGeneratingPRInfo:ue.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Me,onCreatePR:Ae,currentBranch:U.currentBranch,autoGeneratePRInfo:fe.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>me(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(xo,{open:v,onOpenChange:b,isLoading:i,onPushAndCreatePR:Ne,onCancel:ze}),(0,$.jsx)(vo,{open:L,onOpenChange:R,repoName:z,onRepoNameChange:ee,repoDescription:te,onRepoDescriptionChange:B,isPrivateRepo:fe.privateRepositoryDefault,onPrivateRepoChange:e=>me(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:je}),(0,$.jsx)(yo,{open:E,onOpenChange:D,commits:O,displayedCommits:N,isLoadingMore:F,onScroll:Ie,currentBranch:U.currentBranch}),(0,$.jsx)(So,{open:H,onOpenChange:re,onCommitFirst:Te,onStashAndPull:De,onCancel:()=>re(!1),isLoading:i}),(0,$.jsx)(Co,{open:oe,onOpenChange:le,onNewBranch:ke,onJustOpen:Be,isLoading:i,defaultBranch:U.defaultBranch??void 0})]})}var Do=`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 Oo({open:e,onOpenChange:n,projectId:r,commands:i,onRefresh:a}){let[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)([]),[g,y]=(0,Z.useState)(0),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),T=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),h([])},E=e=>{c({...e}),p(!1),h([])},D=async()=>{try{x(!0);let e=await nt(r);h(e.scripts),y(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)}},O=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),h([]),S.current?.focus()},k=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),y(e=>e<m.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),y(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),g<m.length&&O(m[g])):e.key===`Escape`&&(e.preventDefault(),p(!1),h([])))};(0,Z.useEffect)(()=>{let e=e=>{C.current&&!C.current.contains(e.target)&&(p(!1),h([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let A=async e=>{try{await _(r,e),X({title:`Success`,description:`Command deleted`}),a()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(_e,{open:e,onOpenChange:n,children:(0,$.jsxs)(sn,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(we,{children:`Project Commands`}),(0,$.jsx)(s,{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)(H,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(ae,{id:`name`,value:o.name,onChange:e=>c({...o,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(H,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Un,{ref:S,id:`commandLine`,value:o.commandLine,onChange:e=>c({...o,commandLine:e.target.value}),onKeyDown:k,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void D(),disabled:b,children:(0,$.jsx)(Ze,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(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)(Ze,{className:`h-3 w-3`}),`Available Scripts `,b&&`(loading...)`]}),m.length>0?(()=>{let e={};m.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===g;return n++,(0,$.jsxs)(`button`,{type:`button`,className:G(`flex w-full flex-col gap-1 rounded-lg mx-1 px-3 py-2 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>O(e),onMouseEnter:()=>y(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:b?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(H,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(ae,{id:`relativeFolder`,value:o.relativeFolder??``,onChange:e=>c({...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)(H,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Do.map(e=>{let t=d[e]||N;return(0,$.jsx)(W,{variant:o.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...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)(W,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(bt,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(W,{size:`sm`,onClick:async()=>{if(!o?.name||!o?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{u(!0),await $e(r,o),X({title:`Success`,description:`Command saved`}),c(null),a()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{u(!1)}},disabled:l,children:[(0,$.jsx)(Gt,{className:`h-4 w-4 mr-2`}),` `,l?`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:()=>E(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(d[e.icon]||Qe,{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)(W,{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)(v,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(W,{variant:`outline`,className:`w-full border-dashed`,onClick:T,children:[(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function ko(){let e=(0,Q.c)(27),{state:t}=Pn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=Bn(r),[o,s]=(0,Z.useState)(!1),c,l,u,f,p;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){p=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 m;e[12]!==a||e[13]!==n||e[14]!==r?(m=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]=m):m=e[15];let h=m,g;if(e[16]===a?g=e[17]:(g=async()=>{a({type:K.ConfigUpdated})},e[16]=a,e[17]=g),l=g,!n){p=null;break bb0}u=`flex items-center gap-1`,f=c.length===0?(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(z,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Wn,{children:[c.map(e=>{let n=d[e.icon]||Qe;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{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)(W,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(z,{})})}),(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]=f,e[9]=p}else c=e[5],l=e[6],u=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;e[18]!==c||e[19]!==l||e[20]!==n||e[21]!==o?(m=(0,$.jsx)(Oo,{open:o,onOpenChange:s,projectId:n,commands:c,onRefresh:l}),e[18]=c,e[19]=l,e[20]=n,e[21]=o,e[22]=m):m=e[22];let h;return e[23]!==u||e[24]!==f||e[25]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[f,m]}),e[23]=u,e[24]=f,e[25]=m,e[26]=h):h=e[26],h}function Ao(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 jo({threadId:e}){let{dispatch:t}=Pn(),{setTerminalNotification:r}=xr(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(new Set),c=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>((async()=>{try{let t=await Ke(e);if(t.length===0){a(null);return}a(t),s(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{a(null)}})(),()=>{for(let e of c.current.values())e.abort();c.current.clear()}),[e]);let l=async i=>{if(o.has(i.name)){let n=c.current.get(i.name);n&&(n.abort(),c.current.delete(i.name));try{await Yt(e,i.name)}catch{}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${i.friendlyName} stopped`}}),s(e=>{let t=new Set(e);return t.delete(i.name),t})}else{let a=new AbortController;c.current.set(i.name,a),s(e=>new Set([...e,i.name])),r(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${i.friendlyName}`}});try{let r=await n(e,i.name,i.command,{signal:a.signal});if(r){let n=r.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:r,value:o}=await n.read();if(r)break;a+=i.decode(o,{stream:!0});let s=a.split(`
34
+ `);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{n.releaseLock()}}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${i.friendlyName} done`}})}catch{}finally{c.current.delete(i.name),s(e=>{let t=new Set(e);return t.delete(i.name),t})}}};if(!i)return null;let u=i.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),d=Object.entries(u).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),f=d.length>1;return(0,$.jsxs)(ir,{children:[(0,$.jsx)(Wn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(sr,{asChild:!0,children:(0,$.jsx)(W,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Pe,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(Qn,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(ar,{children:[(0,$.jsx)($n,{children:e}),(0,$.jsx)(qn,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Kn,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(it,{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)(Kn,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(it,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}var Mo=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=G(`grid gap-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(pn,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Mo.displayName=pn.displayName;var No=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=G(`aspect-square h-4 w-4 rounded-full border border-brand text-brand ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(dn,{className:`flex items-center justify-center`,children:(0,$.jsx)(It,{className:`h-2.5 w-2.5 fill-current text-current`})}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(Sn,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});No.displayName=Sn.displayName;function Po({threadId:e,onSkillCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(`local`),[c,l]=(0,Z.useState)(!1),u=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),d=u.length>0&&u.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Skill`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new agent skill. The skill will be saved as a SKILL.md file in the .agents/skills folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`skillName`,children:`Skill Name`}),(0,$.jsx)(ae,{id:`skillName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Review`,disabled:c}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:u||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`skillDescription`,children:`Description`}),(0,$.jsx)(Un,{id:`skillDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe when Tarsk should apply this skill`,className:`resize-none min-h-[120px]`,disabled:c})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(Mo,{value:o,onValueChange:e=>s(e),className:`flex gap-4`,disabled:c,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o===`local`?`This skill will only be available for this project.`:`This skill will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(W,{onClick:async()=>{if(!(!d||!i.trim()||!e)){l(!0);try{let n=await de(e,u,i.trim());X({title:`Skill created`,description:`Skill '${u}' was created successfully.`}),r(``),a(``),s(`local`),t?.(n.path,`SKILL.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{l(!1)}}},disabled:!d||!i.trim()||c,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(me,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add a skill.`})]})})}var Fo=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=G(`peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Cn,{className:G(`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`)}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(mn,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});Fo.displayName=mn.displayName;function Io({threadId:e,onRuleCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`local`),[u,d]=(0,Z.useState)(!1),f=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),p=f.length>0&&f.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Rule`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new agent rule. The rule will be saved as a .md file in the .agents/rules folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`ruleName`,children:`Rule Name`}),(0,$.jsx)(ae,{id:`ruleName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Style Guide`,disabled:u}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`File name: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[f||`...`,`.md`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`ruleDescription`,children:`Description`}),(0,$.jsx)(Un,{id:`ruleDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe when Tarsk should apply this rule...`,className:`resize-none min-h-[120px]`,disabled:u})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(H,{htmlFor:`alwaysApply`,children:`Always Apply`}),(0,$.jsx)(Fo,{id:`alwaysApply`,checked:o,onCheckedChange:s,disabled:u})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`This rule will be automatically added to context for all conversations.`:`Only the rule description will be added to context, allowing the agent to read the rule file when needed.`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(Mo,{value:c,onValueChange:e=>l(e),className:`flex gap-4`,disabled:u,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c===`local`?`This rule will only be available for this project.`:`This rule will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(W,{onClick:async()=>{if(!(!p||!e)){d(!0);try{let n=`---
35
+ description: ${i.trim()}
36
+ alwaysApply: ${o}
37
+ ---
38
+
39
+ Place your rule instructions here as markdown.
40
+ `;await ft(e,`.agents/rules/${f}.md`,n),X({title:`Rule created`,description:`Rule '${f}' was created successfully.`}),r(``),a(``),s(!1),l(`local`),t?.(f)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create rule`,variant:`destructive`})}finally{d(!1)}}},disabled:!p||!i.trim()||u,children:u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(me,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add a rule.`})]})})}function Lo({threadId:e,onAgentCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(`local`),[u,d]=(0,Z.useState)(!1),f=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),p=f.length>0&&f.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Agent`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new subagent. The agent will be saved as an AGENT.md file in the .agents/agents folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`agentName`,children:`Agent Name`}),(0,$.jsx)(ae,{id:`agentName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Security Reviewer`,disabled:u}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:f||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`agentDescription`,children:`Description`}),(0,$.jsx)(Un,{id:`agentDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe what this agent does and when it should be invoked`,className:`resize-none min-h-[120px]`,disabled:u})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`agentTools`,children:`Allowed Tools (optional)`}),(0,$.jsx)(ae,{id:`agentTools`,value:o,onChange:e=>s(e.target.value),placeholder:`e.g. read grep glob`,disabled:u}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Space-separated list of tools this agent can use. Leave empty to allow all coding tools.`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(Mo,{value:c,onValueChange:e=>l(e),className:`flex gap-4`,disabled:u,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c===`local`?`This agent will only be available for this project.`:`This agent will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(W,{onClick:async()=>{if(!(!p||!i.trim()||!e)){d(!0);try{let n=await ie(e,f,i.trim(),o.trim()||void 0);X({title:`Agent created`,description:`Agent '${f}' was created successfully.`}),r(``),a(``),s(``),l(`local`),t?.(n.path,`AGENT.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create agent`,variant:`destructive`})}finally{d(!1)}}},disabled:!p||!i.trim()||u,children:u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(me,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add an agent.`})]})})}function Ro({projectId:e,threadId:t,onCommandCreated:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`default`),[d,f]=(0,Z.useState)(`local`),[p,m]=(0,Z.useState)(!1),h=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),g=h.length>0&&h.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Slash Command`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new slash command. The command will be saved as a .md file in the ~/.agents/commands folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`commandName`,children:`Command Name`}),(0,$.jsx)(ae,{id:`commandName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. review`,disabled:p}),r&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Command: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[`/`,h||`...`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`commandDescription`,children:`Description`}),(0,$.jsx)(ae,{id:`commandDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Brief description shown in autocomplete`,disabled:p})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`argumentHint`,children:`Argument Hint (optional)`}),(0,$.jsx)(ae,{id:`argumentHint`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. <focus-area> or <branch-name>`,disabled:p}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Shows after the command name to guide users what to type`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Mode`}),(0,$.jsxs)(Mo,{value:l,onValueChange:e=>u(e),className:`flex gap-4`,disabled:p,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`default`,id:`mode-default`}),(0,$.jsx)(H,{htmlFor:`mode-default`,className:`font-normal cursor-pointer`,children:`Default`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`plan`,id:`mode-plan`}),(0,$.jsx)(H,{htmlFor:`mode-plan`,className:`font-normal cursor-pointer`,children:`Plan`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l===`default`?`Standard chat mode`:`Activates plan mode when this command is used`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(Mo,{value:d,onValueChange:e=>f(e),className:`flex gap-4`,disabled:p,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(No,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d===`local`?`This command will only be available for this project.`:`This command will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(W,{onClick:async()=>{if(!(!g||!e)){m(!0);try{await mt(h,``,{description:a.trim()||void 0,argumentHint:s.trim()||void 0,mode:l===`plan`?`plan`:void 0},d===`global`?`global`:`project`,t??void 0),X({title:`Command created`,description:`Command '/${h}' was created successfully.`}),i(``),o(``),c(``),u(`default`),f(`local`),n?.(h)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create command`,variant:`destructive`})}finally{m(!1)}}},disabled:!g||p,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(me,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Project Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a project to add a slash command.`})]})})}function zo(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),a=(0,Z.useCallback)(async()=>{if(e){i(!0);try{let t=await Ct(e);n(Object.entries(t.servers??{}).map(([e,t])=>({name:e,config:t})))}catch{n([])}finally{i(!1)}}},[e]);return(0,Z.useEffect)(()=>{a()},[a]),{installedServers:t,loadingConfig:r,loadInstalledServers:a}}function Bo(){let e=(0,Q.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),i,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{Tt().then(r).catch(()=>r([]))},a=[],e[1]=i,e[2]=a):(i=e[1],a=e[2]),(0,Z.useEffect)(i,a);let o;return e[3]===n?o=e[4]:(o={popularServers:n},e[3]=n,e[4]=o),o}async function Vo(e,t,n){await Ot(e,t,n)}async function Ho(e,t){await D(e,t)}function Uo({projectPath:e,serverName:n,onBack:r}){let{installedServers:i}=zo(e),a=!!n,[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(a),[S,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{if(a&&n){let e=i.find(e=>e.name===n);if(e){s(e.name),l(e.config.command);let t=e.config.args.join(`
41
+ `);d(t);let n=Object.entries(e.config.env??{}).map(([e,t])=>({key:e,value:t}));p(n),C(e.name),T(e.config.command),D(t),k(n),x(!1)}}else x(!1)},[i,n,a]);let A=(0,Z.useCallback)(()=>{p(e=>[...e,{key:``,value:``}])},[]),j=(0,Z.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),M=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),N=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]),P=()=>{let e=u.split(`
42
+ `).map(e=>e.trim()).filter(Boolean),t={};for(let{key:e,value:n}of f)e.trim()&&(t[e.trim()]=n);return{command:c.trim(),args:e,...Object.keys(t).length>0?{env:t}:{}}},F=async()=>{y(null);let t=o.trim(),n=c.trim();if(!t){y(`Server name is required`);return}if(!n){y(`Command is required`);return}h(!0);try{if(!e)throw Error(`No project path`);await Vo(e,S||t,P()),X({title:`Success`,description:a?`MCP server configuration saved`:`MCP server added`}),r()}catch(e){y(e instanceof Error?e.message:`Failed to save server`)}finally{h(!1)}},I=async()=>{if(e){_(!0);try{await Ho(e,S),X({title:`Success`,description:`MCP server removed`}),r()}catch(e){y(e instanceof Error?e.message:`Failed to delete server`)}finally{_(!1)}}},L=a?c!==w||u!==E||JSON.stringify(f)!==JSON.stringify(O):o.trim()!==``||c.trim()!==``||u.trim()!==``||f.length>0;return b?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading server configuration...`})}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:a?o:`Add MCP Server`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:a?`Edit MCP Server configuration.`:`Configure a new MCP Server.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`server-name`,children:`Server name`}),(0,$.jsx)(ae,{id:`server-name`,placeholder:`e.g. filesystem`,value:o,onChange:e=>s(e.target.value),disabled:a}),a&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Server name cannot be changed`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`server-command`,children:`Command`}),(0,$.jsx)(ae,{id:`server-command`,placeholder:`e.g. npx`,value:c,onChange:e=>l(e.target.value),className:`text-sm`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(H,{htmlFor:`server-args`,children:[`Arguments `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(one per line)`})]}),(0,$.jsx)(Un,{id:`server-args`,placeholder:`-y
43
+ @modelcontextprotocol/server-filesystem
44
+ /path/to/dir`,value:u,onChange:e=>d(e.target.value),className:`font-mono text-xs min-h-[80px] resize-none`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(H,{children:`Environment variables`}),(0,$.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:A,className:`h-6 px-2 text-xs`,children:[(0,$.jsx)(t,{className:`h-3 w-3 mr-1`}),`Add variable`]})]}),f.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground py-1`,children:`No environment variables configured`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ae,{placeholder:`KEY`,value:e.key,onChange:e=>M(t,e.target.value),className:`font-mono text-xs w-[35%]`}),(0,$.jsx)(ae,{placeholder:`value`,value:e.value,onChange:e=>N(t,e.target.value),className:`font-mono text-xs flex-1`}),(0,$.jsx)(W,{variant:`ghost`,size:`icon`,onClick:()=>j(t),className:`h-9 w-9 flex-shrink-0`,children:(0,$.jsx)(bt,{className:`h-3.5 w-3.5`})})]},t))})]}),v&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:v}),(0,$.jsxs)(`div`,{className:`border-t pt-4 flex items-center justify-between`,children:[a&&(0,$.jsx)(W,{variant:`destructive`,onClick:I,disabled:g||m,children:g?`Removing...`:`Remove`}),!a&&(0,$.jsx)(`div`,{}),(0,$.jsx)(W,{onClick:F,disabled:m||g||!L,children:m?a?`Saving...`:`Adding...`:a?`Save`:`Add`})]})]})]})}function Wo(e){let t=(0,Q.c)(23),{name:n,description:r,installed:i,onClick:a,onOpen:o,onUninstall:s}=e,c=`flex flex-col gap-2 p-2.5 rounded-lg border border-border bg-card text-left transition-colors w-full ${i?``:`hover:bg-accent/50 cursor-pointer`}`,l=i?void 0:a,u=i?void 0:`button`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`flex-shrink-0 h-6 w-6 rounded-md bg-muted flex items-center justify-center`,children:(0,$.jsx)(Rt,{className:`h-3 w-3 text-muted-foreground`})}),t[0]=d):d=t[0];let f;t[1]===n?f=t[2]:(f=(0,$.jsx)(`span`,{className:`font-medium text-sm truncate`,children:n}),t[1]=n,t[2]=f);let p;t[3]===i?p=t[4]:(p=i&&(0,$.jsx)(Wn,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`span`,{className:`flex-shrink-0 h-4 w-4 rounded-full bg-green-500/15 flex items-center justify-center`,children:(0,$.jsx)(Gt,{className:`h-2.5 w-2.5 text-green-600 dark:text-green-400`})})}),(0,$.jsx)(q,{children:`Installed`})]})}),t[3]=i,t[4]=p);let m;t[5]!==f||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,f,p]}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==i||t[9]!==o||t[10]!==s?(h=i&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[o&&(0,$.jsx)(Wn,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),o()},children:(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{children:`Open in Explorer`})]})}),s&&(0,$.jsx)(Wn,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),s()},className:`text-destructive hover:text-destructive`,children:(0,$.jsx)(v,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{children:`Remove`})]})})]}),t[8]=i,t[9]=o,t[10]=s,t[11]=h):h=t[11];let g;t[12]!==m||t[13]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[m,h]}),t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]===r?_=t[16]:(_=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3`,children:r}),t[15]=r,t[16]=_);let y;return t[17]!==c||t[18]!==_||t[19]!==l||t[20]!==u||t[21]!==g?(y=(0,$.jsxs)(`div`,{className:c,onClick:l,role:u,children:[g,_]}),t[17]=c,t[18]=_,t[19]=l,t[20]=u,t[21]=g,t[22]=y):y=t[22],y}function Go(e){let t=[];for(let n of e)n.type===`file`&&t.push(n.path),n.children&&t.push(...Go(n.children));return t}function Ko({projectPath:e,threadId:t,onClose:n}){let{installedServers:r,loadInstalledServers:i}=zo(e),{popularServers:a}=Bo(),{setActiveMainTab:c,setPendingExplorerPath:l,triggerExplorerRefresh:u,setExplorerClearPath:d}=xr(),[f,p]=(0,Z.useState)(`mcp`),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(new Set),[C,T]=(0,Z.useState)(new Map),[D,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)([]),[N,P]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{at().then(O).catch(()=>O([])),Ft().then(A).catch(()=>A([])),lt().then(M).catch(()=>M([])),Be().then(P).catch(()=>P([]))},[]),(0,Z.useEffect)(()=>{t&&(ue(t).then(e=>x(new Set(Go(e)))).catch(()=>{}),tn(t).then(e=>T(new Map(e.map(e=>[e.name,e.filePath])))).catch(()=>{}))},[t]);let I=(0,Z.useCallback)(e=>{p(e),h(``)},[]),L=(0,Z.useCallback)(e=>{let t=m.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)):e},[m]),R=(0,Z.useMemo)(()=>L(a),[a,L]),z=(0,Z.useMemo)(()=>L(D),[D,L]),ee=(0,Z.useMemo)(()=>L(k),[k,L]),te=(0,Z.useMemo)(()=>L(j),[j,L]),B=(0,Z.useMemo)(()=>L(N),[N,L]),V=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);if(!r.some(e=>e.name===n||e.name===t.id)){_(t.id);try{await Vo(e,n,{command:t.command,args:t.args,...Object.keys(t.env??{}).length>0?{env:t.env}:{}}),await i(),u(),X({title:`MCP server installed`,description:t.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install server`,variant:`destructive`})}finally{_(null)}}},[e,r,i,u]),ne=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);try{await Ho(e,n),await i(),u(),X({title:`MCP server removed`,description:t.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove server`,variant:`destructive`})}},[e,i,u]),H=(0,Z.useCallback)(()=>{l(`.agents/mcp.json`),c(`explorer`),n()},[l,c,n]),re=(0,Z.useCallback)(e=>{l(`.agents/skills/${e.id}/SKILL.md`),c(`explorer`),n()},[l,c,n]),ie=(0,Z.useCallback)(e=>{l(`.agents/agents/${e.id}/AGENT.md`),c(`explorer`),n()},[l,c,n]),oe=(0,Z.useCallback)(e=>{l(`.agents/rules/${e.name}.md`),c(`explorer`),n()},[l,c,n]),se=(0,Z.useCallback)(e=>{let t=C.get(e.name);t&&(l(t),c(`explorer`),n())},[C,l,c,n]),ce=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/skills/${e.id}/SKILL.md`;try{await o(t,`.agents/skills/${e.id}`),x(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/skills/${e.id}`),u(),X({title:`Skill removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove skill`,variant:`destructive`})}},[t,u,d]),le=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/agents/${e.id}/AGENT.md`;try{await o(t,`.agents/agents/${e.id}`),x(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/agents/${e.id}`),u(),X({title:`Agent removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove agent`,variant:`destructive`})}},[t,u,d]),U=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/rules/${e.name}.md`;try{await o(t,n),x(e=>{let t=new Set(e);return t.delete(n),t}),d(n),u(),X({title:`Rule removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove rule`,variant:`destructive`})}},[t,u,d]),de=(0,Z.useCallback)(async e=>{let t=C.get(e.name);if(t)try{await he(t),T(t=>{let n=new Map(t);return n.delete(e.name),n}),d(t),u(),X({title:`Command removed`,description:`/${e.name}`})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove command`,variant:`destructive`})}},[C,u,d]),fe=(0,Z.useCallback)((e,t,n,r)=>{y({name:e,gitHubRepo:t,gitHubFolder:n,onConfirm:r})},[]),pe=(0,Z.useCallback)(async e=>{let n=`.agents/skills/${e.id}/SKILL.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await E(t,e.gitHubRepo,e.gitHubFolder,`.agents/skills/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.allowedTools&&r.push(`allowed-tools: ${e.allowedTools}`),e.license&&r.push(`license: ${e.license}`),r.push(`---`,``,e.instructions),await ft(t,n,r.join(`
45
+ `))}x(e=>new Set(e).add(n)),u(),X({title:`Skill installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install skill`,variant:`destructive`})}finally{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),me=(0,Z.useCallback)(async e=>{let n=`.agents/agents/${e.id}/AGENT.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await E(t,e.gitHubRepo,e.gitHubFolder,`.agents/agents/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.tools&&r.push(`tools: ${e.tools}`),r.push(`---`,``,e.systemPrompt),await ft(t,n,r.join(`
46
+ `))}x(e=>new Set(e).add(n)),u(),X({title:`Agent installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install agent`,variant:`destructive`})}finally{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),ge=(0,Z.useCallback)(async e=>{let n=`.agents/rules/${e.name}.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{e.gitHubRepo&&e.gitHubFolder?await E(t,e.gitHubRepo,e.gitHubFolder,`.agents/rules`):await ft(t,n,[`---`,`description: ${e.description}`,`alwaysApply: ${e.alwaysApply??!1}`,`---`,``,e.content].join(`
47
+ `)),x(e=>new Set(e).add(n)),u(),X({title:`Rule installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install rule`,variant:`destructive`})}finally{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),ve=(0,Z.useCallback)(async e=>{if(!t||C.has(e.name))return;let n=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await E(t,e.gitHubRepo,e.gitHubFolder,n);let r=`${n}/${e.name}.md`;T(t=>new Map(t).set(e.name,r))}else{let n=await mt(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);T(t=>new Map(t).set(e.name,n.filePath))}u(),X({title:`Command installed`,description:`/${e.name}`})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install command`,variant:`destructive`})}finally{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,n):await n()},[t,C,u,fe]);function ye({items:e,onInstall:n,isInstalled:r,noThreadWarning:i,onOpen:a,onUninstall:o}){return e.length===0&&m.trim()?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:[`No results for "`,m,`"`]}):e.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,$.jsx)(it,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsxs)($.Fragment,{children:[i&&!t&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground bg-muted rounded-md px-3 py-2`,children:`Open a thread to install items into your project.`}),(0,$.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(min(220px, 100%), 1fr))`},children:e.map(e=>{let t=r(e);return(0,$.jsxs)(`div`,{className:`relative`,children:[g===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(it,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(Wo,{name:e.name,description:e.description,installed:t,onClick:()=>n(e),onOpen:t&&a?()=>a(e):void 0,onUninstall:t&&o?()=>o(e):void 0})]},e.id)})})]})}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_e,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,$.jsxs)(sn,{children:[(0,$.jsxs)(w,{children:[(0,$.jsxs)(we,{children:[`Install `,v?.name]}),(0,$.jsxs)(s,{children:[`Install `,(0,$.jsx)(`strong`,{children:v?.name}),` from`,` `,(0,$.jsx)(`strong`,{children:v?.gitHubRepo}),` (`,v?.gitHubFolder,`)?`]})]}),(0,$.jsxs)(De,{className:`flex-row gap-2 sm:justify-between`,children:[(0,$.jsx)(W,{variant:`outline`,onClick:()=>{v&&S(`${v.gitHubRepo.replace(/\.git$/,``)}/tree/HEAD/${v.gitHubFolder}`)},children:`More Information`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(W,{variant:`outline`,onClick:()=>y(null),children:`No`}),(0,$.jsx)(W,{onClick:()=>{let e=v;y(null),e&&e.onConfirm()},children:`Yes`})]})]})]})}),(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`p-6 pb-0 space-y-4 flex-shrink-0`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Marketplace`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:{mcp:`Browse and install popular MCP servers`,skills:`Reusable instruction sets that guide agent behavior`,agents:`Specialized sub-agents for focused tasks`,rules:`Coding standards and project-wide guidelines`,commands:`Slash commands for quick prompts`}[f]})]}),(0,$.jsx)(Ar,{value:f,onValueChange:I,children:(0,$.jsxs)(kr,{className:`w-full`,children:[(0,$.jsx)(Dr,{value:`mcp`,className:`flex-1`,children:`MCP`}),(0,$.jsx)(Dr,{value:`skills`,className:`flex-1`,children:`Skills`}),(0,$.jsx)(Dr,{value:`agents`,className:`flex-1`,children:`Agents`}),(0,$.jsx)(Dr,{value:`rules`,className:`flex-1`,children:`Rules`}),(0,$.jsx)(Dr,{value:`commands`,className:`flex-1`,children:`Commands`})]})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(F,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(ae,{placeholder:`Search ${f===`mcp`?`servers`:f}...`,value:m,onChange:e=>h(e.target.value),className:`pl-8`})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 pt-4 space-y-3`,children:[f===`mcp`&&(0,$.jsx)($.Fragment,{children:a.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,$.jsx)(it,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):R.length===0?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:[`No results for "`,m,`"`]}):(0,$.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(min(220px, 100%), 1fr))`},children:R.map(e=>{let t=e.name.toLowerCase().replace(/\s+/g,`-`),n=r.some(n=>n.name===t||n.name===e.id);return(0,$.jsxs)(`div`,{className:`relative`,children:[g===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(it,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(Wo,{name:e.name,description:e.description,installed:n,onClick:()=>void V(e),onOpen:n?H:void 0,onUninstall:n?()=>void ne(e):void 0})]},e.id)})})}),f===`skills`&&(0,$.jsx)(ye,{items:z,onInstall:e=>void pe(e),isInstalled:e=>b.has(`.agents/skills/${e.id}/SKILL.md`),noThreadWarning:!0,onOpen:re,onUninstall:e=>void ce(e)}),f===`agents`&&(0,$.jsx)(ye,{items:ee,onInstall:e=>void me(e),isInstalled:e=>b.has(`.agents/agents/${e.id}/AGENT.md`),noThreadWarning:!0,onOpen:ie,onUninstall:e=>void le(e)}),f===`rules`&&(0,$.jsx)(ye,{items:te,onInstall:e=>void ge(e),isInstalled:e=>b.has(`.agents/rules/${e.name}.md`),noThreadWarning:!0,onOpen:oe,onUninstall:e=>void U(e)}),f===`commands`&&(0,$.jsx)(ye,{items:B,onInstall:e=>void ve(e),isInstalled:e=>C.has(e.name),noThreadWarning:!0,onOpen:se,onUninstall:e=>void de(e)})]})]})]})}function qo(){let e=bn(),{state:t}=Pn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,a=i.find(e=>e.projectId===n),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o!==`instructions`||!r||(p(!0),f(r,`AGENTS.md`).then(e=>u(e.content)).catch(()=>u(``)).finally(()=>p(!1)))},[o,r]);let g=async()=>{if(r){h(!0);try{await ft(r,`AGENTS.md`,l),X({title:`Instructions saved`}),c(null)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{h(!1)}}};return n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Wn,{children:(0,$.jsxs)(ir,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(sr,{asChild:!0,children:(0,$.jsx)(W,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Et,{})})})}),(0,$.jsx)(q,{children:`AI`})]}),(0,$.jsxs)(Qn,{align:`end`,children:[(0,$.jsx)(Kn,{onSelect:()=>c(`mcp`),children:`Add MCP Server`}),(0,$.jsx)(Kn,{onSelect:()=>c(`skill`),children:`Add Skill`}),(0,$.jsx)(Kn,{onSelect:()=>c(`rule`),children:`Add Rule`}),(0,$.jsx)(Kn,{onSelect:()=>c(`slash-command`),children:`Add Slash Command`}),(0,$.jsx)(Kn,{onSelect:()=>c(`subagent`),children:`Add Subagent`}),(0,$.jsx)(nr,{}),(0,$.jsx)(Kn,{onSelect:()=>c(`instructions`),disabled:!r,children:`Instructions`}),(0,$.jsx)(Kn,{onSelect:()=>void e(`/settings?tab=providers`),children:`Model Providers`}),(0,$.jsx)(nr,{}),(0,$.jsx)(Kn,{onSelect:()=>c(`marketplace`),children:`Marketplace`})]})]})}),(0,$.jsx)(_e,{open:o===`mcp`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(Uo,{projectPath:a?.projectPath,onBack:()=>c(null)})})})}),(0,$.jsx)(_e,{open:o===`marketplace`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-3xl h-[80vh] overflow-y-auto p-0`,children:(0,$.jsx)(Ko,{projectPath:a?.projectPath,threadId:r,onClose:()=>c(null)})})}),(0,$.jsx)(_e,{open:o===`skill`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Po,{threadId:r,onSkillCreated:()=>c(null)})})}),(0,$.jsx)(_e,{open:o===`rule`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Io,{threadId:r,onRuleCreated:()=>c(null)})})}),(0,$.jsx)(_e,{open:o===`slash-command`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Ro,{projectId:n,threadId:r,onCommandCreated:()=>c(null)})})}),(0,$.jsx)(_e,{open:o===`subagent`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(sn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Lo,{threadId:r,onAgentCreated:()=>c(null)})})}),(0,$.jsx)(_e,{open:o===`instructions`,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(sn,{className:`max-w-2xl`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(we,{children:`Instructions`}),(0,$.jsx)(s,{children:`Add context like coding guidelines and expectations that are relevant for all conversations (this is stored in the agents.md file)`})]}),d?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(it,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsx)(Un,{value:l,onChange:e=>u(e.target.value),className:`min-h-[300px] font-mono text-sm resize-none`,placeholder:`Add instructions for your agent in AGENTS.md...`,disabled:m}),(0,$.jsxs)(De,{children:[(0,$.jsx)(W,{variant:`outline`,onClick:()=>c(null),children:`Cancel`}),(0,$.jsx)(W,{onClick:()=>void g(),disabled:d||m,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(it,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})]})]})})]}):null}function Jo(){let e=(0,Q.c)(44),{state:t,dispatch:n}=Pn(),{selectedThreadId:r,selectedProjectId:i,projects:a,sidebarOpen:o}=t,s;if(e[0]!==a||e[1]!==i){let t;e[3]===i?t=e[4]:(t=e=>e.projectId===i,e[3]=i,e[4]=t),s=a.find(t),e[0]=a,e[1]=i,e[2]=s}else s=e[2];let c=s,l=!o,u=l&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2`,d;e[5]===u?d=e[6]:(d=G(u),e[5]=u,e[6]=d);let f;e[7]===n?f=e[8]:(f=()=>n({type:K.ToggleSidebar}),e[7]=n,e[8]=f);let p;e[9]===o?p=e[10]:(p=o?(0,$.jsx)(dt,{className:`h-4 w-4`}):(0,$.jsx)(Vt,{className:`h-4 w-4`}),e[9]=o,e[10]=p);let m;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=m):m=e[11];let h;e[12]!==f||e[13]!==p?(h=(0,$.jsxs)(W,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,onClick:f,children:[p,m]}),e[12]=f,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==a||e[16]!==i||e[17]!==r?(g=r&&(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Lt(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P(a,r)})]}),e[15]=a,e[16]=i,e[17]=r,e[18]=g):g=e[18];let _;e[19]!==h||e[20]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),e[19]=h,e[20]=g,e[21]=_):_=e[21];let v=l?`ml-0`:`ml-auto`,y;e[22]===v?y=e[23]:(y=G(`flex flex-wrap items-center justify-end gap-2`,v,`md:ml-auto`),e[22]=v,e[23]=y);let b;e[24]!==c?.runCommand||e[25]!==i||e[26]!==r?(b=i&&(0,$.jsxs)(Ao,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Er,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jo,{threadId:r}),(0,$.jsx)(ko,{}),(0,$.jsx)(qo,{})]})]}),e[24]=c?.runCommand,e[25]=i,e[26]=r,e[27]=b):b=e[27];let x;e[28]!==i||e[29]!==r?(x=r&&i&&(0,$.jsx)(Ao,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Eo,{projectId:i,threadId:r})}),e[28]=i,e[29]=r,e[30]=x):x=e[30];let S;e[31]!==c?.openWith||e[32]!==i||e[33]!==r?(S=r&&i&&(0,$.jsx)(Ao,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(ao,{projectId:i,threadId:r,openWith:c?.openWith})}),e[31]=c?.openWith,e[32]=i,e[33]=r,e[34]=S):S=e[34];let C;e[35]!==y||e[36]!==b||e[37]!==x||e[38]!==S?(C=(0,$.jsxs)(`div`,{className:y,children:[b,x,S]}),e[35]=y,e[36]=b,e[37]=x,e[38]=S,e[39]=C):C=e[39];let w;return e[40]!==C||e[41]!==d||e[42]!==_?(w=(0,$.jsxs)(jr,{className:d,children:[_,C]}),e[40]=C,e[41]=d,e[42]=_,e[43]=w):w=e[43],w}function Yo(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)(dr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(gr,{children:[o,(0,$.jsxs)(ur,{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)(hr,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(mr,{children:[c,(0,$.jsx)(pr,{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)(fr,{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)(_r,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function Xo(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)(dr,{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)(gr,{children:[o,(0,$.jsxs)(ur,{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(Zo),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)(hr,{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)(pr,{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)(mr,{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)(fr,{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)(_r,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function Zo(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 Qo(){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(`${Ce()}/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=$o;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Ce(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(gr,{children:[(0,$.jsx)(dr,{children:`Service unavailable`}),(0,$.jsx)(ur,{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)(_r,{open:!0,children:(0,$.jsxs)(fr,{children:[c,l,(0,$.jsx)(mr,{children:(0,$.jsx)(W,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function $o(){window.location.assign(window.location.href)}var es=jn,ts=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=G(`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)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ts.displayName=An.displayName;var ns=k(`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`}}),rs=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=G(ns({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)(gn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});rs.displayName=gn.displayName;var is=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=G(`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)(On,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});is.displayName=On.displayName;var as=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=G(`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)(bt,{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)(Mn,{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});as.displayName=Mn.displayName;var os=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=G(`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)(fn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});os.displayName=fn.displayName;var ss=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=G(`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)(_n,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ss.displayName=_n.displayName;function cs(){let e=(0,Q.c)(5),{toasts:t}=cr(),n;e[0]===t?n=e[1]:(n=t.map(ls),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ts,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(es,{children:[n,r]}),e[3]=n,e[4]=i),i}function ls(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(rs,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(os,{children:n}),r&&(0,$.jsx)(ss,{children:r})]}),i,(0,$.jsx)(as,{})]},t)}function us(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=vr(),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 ds(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)(us,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(yr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function fs(){let{state:e,dispatch:t}=Pn(),{toast:n}=cr(),i=Bn(`project-creation`).dispatch,[a,o]=(0,Z.useState)(null),s=(0,Z.useCallback)(async()=>{try{t({type:K.SetProjectsLoading,projectsLoading:!0});let e=await rn();t({type:K.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:K.SetProjectsLoading,projectsLoading:!1})}},[t]),c=(0,Z.useCallback)(async(n,r)=>{try{await Ue(n,r)}catch(e){console.error(`Failed to select thread:`,e)}(e.selectedThreadId!==r||e.selectedProjectId!==n)&&t({type:K.SelectThread,threadId:r,projectId:n})},[t,e.selectedThreadId,e.selectedProjectId]),l=(0,Z.useCallback)(async e=>{t({type:K.SetCreatingProject,isCreating:!0});try{let n=await e.apiCall();if(!n){t({type:K.SetCreatingProject,isCreating:!1}),await s();return}let r=e.useTerminalDispatch?i:t;r({type:K.ClearTerminalOutput}),r({type:K.SetTerminalOpen,open:!0}),r({type:K.AppendTerminalLine,line:{type:`system`,content:e.initialMessage}});let a=n.getReader(),c=new TextDecoder,l=``,u=null,d=!1,f=null,p=null;for(;;){let{done:n,value:i}=await a.read();if(n)break;l+=c.decode(i,{stream:!0});let s=l.split(`
48
+ `);l=s.pop()??``;for(let n of s){let i=n.trim();if(i)try{let n=JSON.parse(i);if(n.type===`progress`)!d&&n.threadId&&n.projectId&&(d=!0,f=n.projectId,p=n.threadId,t({type:K.AddCreatingProject,projectId:n.projectId,threadId:n.threadId,projectName:e.optimisticProjectName,gitUrl:e.gitUrl??``}),t({type:K.AddProcessingThread,threadId:n.threadId})),t({type:K.AppendTerminalLine,...e.useTerminalDispatch?{threadId:p??`project-creation`}:{},line:{type:`output`,content:n.message}});else if(n.type===`complete`){if(n.project){u=n.project.id;let i=e.includeThreadPath&&n.project.threads?.length>0?`${n.project.path}/${n.project.threads[0]}`:n.project.path;r({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${i}`}}),t({type:K.SetTerminalOpen,open:!1}),e.handleSetupScript&&n.suggestedSetupScript&&o({projectId:n.project.id,command:n.suggestedSetupScript,remainingScripts:n.project.pendingSetupScripts??[]})}}else n.type===`error`&&(d&&f&&(t({type:K.RemoveCreatingProject,projectId:f}),p&&t({type:K.RemoveProcessingThread,threadId:p})),t({type:K.AppendTerminalLine,...e.useTerminalDispatch?{threadId:p??`project-creation`}:{},line:{type:`error`,content:`Error: ${n.message}`}}))}catch(t){console.error(`Failed to parse ${e.logTag} event`,t)}}}t({type:K.SetCreatingProject,isCreating:!1}),d&&p&&t({type:K.RemoveProcessingThread,threadId:p}),Ee();let m=await rn();if(t({type:K.SetProjects,projects:m.projects}),t({type:K.SetProjectsLoading,projectsLoading:!1}),u){let e=m.projects.find(e=>e.projectId===u);if(e&&e.threads.length>0){let n=e.threads[0].threadId;t({type:K.SelectThread,threadId:n,projectId:u,focusInput:!0})}}}catch(n){console.error(`Failed to ${e.logTag}:`,n),t({type:K.SetCreatingProject,isCreating:!1}),(e.useTerminalDispatch?i:t)({type:K.AppendTerminalLine,line:{type:`error`,content:`${e.catchErrorPrefix}: ${n instanceof Error?n.message:`Unknown error`}`}})}},[t,s,i]),u=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await l({apiCall:()=>_t(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[l]),d=(0,Z.useCallback)(async(e,t,n)=>{await l({apiCall:()=>r(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[l]),f=(0,Z.useCallback)(async(r,i)=>{try{let a=i??(()=>{let t=e.projects.find(e=>e.projectId===r)?.threads.map(e=>e.title)??[],n=/^thread-(\d+)$/i,i=0;for(let e of t){let t=e.match(n);t&&(i=Math.max(i,parseInt(t[1],10)))}return`thread-${i+1}`})(),o=await V(r,i);if(!o){await s();return}let c=o.getReader(),l=new TextDecoder,u=``,d=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${a}"...`}];try{for(;;){let{done:e,value:i}=await c.read();if(e)break;u+=l.decode(i,{stream:!0});let o=u.split(`
49
+ `);u=o.pop()??``;for(let e of o){let i=e.trim();if(i)try{let e=JSON.parse(i);if(e.type===`progress`){if(!d&&e.threadId){d=!0,f=e.threadId,t({type:K.AddCreatingThread,projectId:r,threadId:e.threadId,title:a}),t({type:K.AddProcessingThread,threadId:e.threadId}),t({type:K.ClearTerminalOutput,threadId:f});for(let e of m)t({type:K.AppendTerminalLine,threadId:f,line:e});m.length=0}let n={type:`output`,content:e.message};f?t({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n)}else if(e.type===`error`){d&&f&&(t({type:K.RemoveCreatingThread,projectId:r,threadId:f}),t({type:K.RemoveProcessingThread,threadId:f}));let i={type:`error`,content:`Error: ${e.message}`};f?t({type:K.AppendTerminalLine,threadId:f,line:i}):m.push(i),console.error(`Thread creation error:`,e.message),n({title:`Thread Creation Failed`,description:e.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}d&&f&&t({type:K.RemoveProcessingThread,threadId:f}),Ee(),await s(),f&&p&&t({type:K.SelectThread,threadId:f,projectId:r,focusInput:!0})}catch(e){throw d&&f&&(t({type:K.RemoveCreatingThread,projectId:r,threadId:f}),t({type:K.RemoveProcessingThread,threadId:f})),n({title:`Thread Creation Failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}),e}}catch(e){console.error(`Failed to create thread:`,e);let r=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw t({type:K.AppendTerminalLine,line:{type:`error`,content:r}}),n({variant:`destructive`,title:`Thread Creation Failed`,description:r}),e}},[s,t,e.projects,n]),p=(0,Z.useCallback)(async(n,r)=>{t({type:K.AddDeletingThread,threadId:r});try{await an(n,r),Ee(),await s(),e.selectedThreadId===r&&t({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{t({type:K.RemoveDeletingThread,threadId:r})}},[s,e.selectedThreadId,t]),m=(0,Z.useCallback)(async n=>{t({type:K.AddDeletingProject,projectId:n});let r=e.projects.find(e=>e.projectId===n)?.threads.map(e=>e.threadId)??[];for(let e of r)t({type:K.AddDeletingThread,threadId:e});try{await te(n),await s(),e.selectedProjectId===n&&t({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{t({type:K.RemoveDeletingProject,projectId:n});for(let e of r)t({type:K.RemoveDeletingThread,threadId:e})}},[s,e.selectedProjectId,e.projects,t]),h=(0,Z.useCallback)(async e=>{let n=a;if(o(null),!n||!e)return;let{projectId:r,command:i,remainingScripts:c}=n,l=[i,...c||[]];try{t({type:K.SetCreatingProject,isCreating:!0}),t({type:K.SetTerminalOpen,open:!0}),t({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 n=l[e],i=n.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;t({type:K.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${l.length} in ${a}...`}}),t({type:K.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${n}`}});let o=await Qt(r,n,!0);if(o){let e=o.getReader(),n=new TextDecoder,r=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;r+=n.decode(a,{stream:!0});let o=r.split(`
50
+ `);r=o.pop()??``;for(let e of o)if(e.trim())try{let n=JSON.parse(e);typeof n==`string`?t({type:K.AppendTerminalLine,line:{type:`output`,content:n}}):n.type===`error`&&t({type:K.AppendTerminalLine,line:{type:`error`,content:n.message}})}catch{t({type:K.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?t({type:K.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&t({type:K.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{t({type:K.AppendTerminalLine,line:{type:`output`,content:r}})}}e<l.length-1&&(t({type:K.AppendTerminalLine,line:{type:`system`,content:``}}),t({type:K.AppendTerminalLine,line:{type:`system`,content:`---`}}),t({type:K.AppendTerminalLine,line:{type:`system`,content:``}}))}t({type:K.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),t({type:K.SetCreatingProject,isCreating:!1}),await s()}catch(e){t({type:K.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),t({type:K.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[a,t,s]);(0,Z.useEffect)(()=>{let n=!0;async function r(){try{t({type:K.SetProjectsLoading,projectsLoading:!0});let r=await rn();if(!n)return;if(t({type:K.SetProjects,projects:r.projects}),!e.selectedThreadId)for(let e of r.projects){let n=e.threads.find(e=>e.isSelected);if(n){t({type:K.SelectThread,threadId:n.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{n&&t({type:K.SetProjectsLoading,projectsLoading:!1})}}return r(),()=>{n=!1}},[t,e.selectedThreadId,e.configUpdatedAt]);let g=(0,Z.useCallback)(async()=>{await l({apiCall:ee,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[l]);return{projects:e.projects,selectedProjectId:e.selectedProjectId,selectedThreadId:e.selectedThreadId,refreshProjects:s,handleSelectThread:c,handleCreateProject:u,handleCreateWebApp:d,handleOpenFolder:g,handleCreateThread:f,handleDeleteThread:p,confirmDeleteProject:m,pendingSetupScriptConfirmation:a,resolveSetupScriptConfirmation:h}}function ps(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(ms),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 ms(){return document.hasFocus()}var hs=null;function gs(){hs??=new Audio(`/pop.wav`),hs.currentTime=0,hs.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function _s(){let{state:e,dispatch:t}=Pn(),n=ps(),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=await $t(),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&&gs(),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()=>{(await c()).length>0||o.current.isStreaming||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.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 vs=768;function ys(){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: ${vs-1}px)`),t=()=>{n(window.innerWidth<vs)};return e.addEventListener(`change`,t),n(window.innerWidth<vs),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var bs=(0,Z.lazy)(()=>kn(()=>import(`./terminal-panel-D3OZDoCd.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([21,1,2,14,15]))),xs=(0,Z.lazy)(()=>kn(()=>import(`./todos-view-CzW8DtQ9.js`).then(e=>({default:e.TodosView})),[])),Ss=(0,Z.lazy)(()=>kn(()=>import(`./diff-view-DWNDi8zT.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,3,14,15,16,17,18,19,8,20]))),Cs=(0,Z.lazy)(()=>kn(()=>import(`./explorer-tab-view-BtTXy75I.js`),__vite__mapDeps([22,1,5,6,2,7,18,14,15]))),ws=(0,Z.lazy)(()=>kn(()=>import(`./browser-tab-xojjEFYj.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,2,24,6,3,14,15]))),Ts=(0,Z.lazy)(()=>kn(()=>import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.t),__vite__mapDeps([2,1]))),Es=(0,Z.lazy)(()=>kn(()=>import(`./onboarding-dialog-lFFrB1GZ.js`),__vite__mapDeps([25,12,1,6,2]))),Ds=(0,Z.lazy)(()=>kn(()=>import(`./conversation-history-view-IVxKEbP_.js`),__vite__mapDeps([26,6,1,2]))),Os=(0,Z.lazy)(()=>kn(()=>import(`./settings-view-CtiXQd-N.js`),__vite__mapDeps([27,1,5,6,2,7,28,18])));function ks(){let{state:e,dispatch:t}=Pn();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new Ur({})},[]);let n=bn(),r=xn(),i=ys(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=fs(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=_s(),[y,b]=(0,Z.useState)(`chat`),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(0),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(0),{terminalState:L}=Bn(e.selectedThreadId),z=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===z.current&&b(`terminal`),z.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[ee,te]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(!1),[ne,H]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)(!1),le=(0,Z.useRef)(null),U=r.pathname.startsWith(`/settings`),ue=r.pathname===`/review`,de=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&y===`tasks`&&b(`chat`)},[r.pathname]);let W=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=U||ue||de;if(n&&W.current===null)W.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&W.current!==null){let n=W.current;W.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[U,ue,de]),(0,Z.useEffect)(()=>{(async()=>{try{(await ye()).updateAvailable&&oe(!0)}catch{}})()},[]);let fe=(0,Z.useCallback)(async()=>{ce(!0);try{await nn()}catch{ce(!1)}},[]);(0,Z.useEffect)(()=>{ne||(async()=>{try{(await Xe()).onboardingCompleted||V(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{H(!0)}})()},[ne]),(0,Z.useEffect)(()=>{B||t({type:K.ConfigUpdated})},[B,t]);let pe=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&ie({id:t.projectId,name:R(t)})},[a]),me=(0,Z.useCallback)(e=>{ge(e),u(e,void 0)},[u]),[he,ge]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{he&&e.selectedProjectId===he&&e.selectedThreadId&&ge(null)},[he,e.selectedProjectId,e.selectedThreadId]);let _e=(0,Z.useCallback)(async(a,s)=>{ge(null),v(s),r.pathname!==`/`&&n(`/`),b(`chat`),e.selectedThreadId!==s&&I(e=>e+1),await o(a,s),i&&e.sidebarOpen&&t({type:K.ToggleSidebar})},[o,i,e.sidebarOpen,e.selectedThreadId,t,v,r.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?le.current?.expand():le.current?.collapse()},[e.sidebarOpen]);let ve={activeMainTab:y,setActiveMainTab:b,devServerUrl:x,setDevServerUrl:S,devServerRunning:C,setDevServerRunning:w,devServerLoading:T,setDevServerLoading:E,terminalNotification:D,setTerminalNotification:O,pendingExplorerPath:k,setPendingExplorerPath:A,explorerRefreshTick:j,triggerExplorerRefresh:()=>M(e=>e+1),explorerClearPath:N,setExplorerClearPath:P,browserResetTrigger:F,triggerBrowserReset:()=>I(e=>e+1)};return(0,$.jsx)(Sr.Provider,{value:ve,children:(0,$.jsxs)(Wn,{delayDuration:200,children:[(0,$.jsxs)(Nr,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Mr,{ref:le,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)(Zr,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:_e,onCreateProject:()=>te(!0),onCreateThread:me,onDeleteThread:d,onDeleteProject:pe,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ae,updatingApp:se,onUpdateApp:fe,onRefreshProjects:p,expandProjectId:he})})}),!i&&(0,$.jsx)(Pr,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Mr,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!ue&&!U&&!de&&(0,$.jsx)(Jo,{}),!ue&&!U&&!de&&e.selectedThreadId&&(0,$.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`,`History`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{onClick:()=>{b(t),t===`terminal`&&O(!1)},className:`relative px-4 py-2 text-sm font-medium transition-colors ${y===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&D&&y!==`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${!ue&&!U&&!de&&y!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(wn,{children:[(0,$.jsx)(En,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Os,{})})}),(0,$.jsx)(En,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Os,{})})}),(0,$.jsx)(En,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Os,{})})}),(0,$.jsx)(En,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Os,{})})}),(0,$.jsx)(En,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Os,{})})}),(0,$.jsx)(En,{path:`*`,element:(0,$.jsx)(to,{onCreateThread:me})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!ue&&!U&&!de?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(bs,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!ue&&!U&&!de?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ws,{})})}),!ue&&!U&&!de&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Cs,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(xs,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ds,{isOpen:!0,onClose:()=>b(`chat`),initialFilter:e.selectedProjectId?{type:`project`,id:e.selectedProjectId}:void 0,projects:a,inline:!0})}):y===`review`&&e.selectedThreadId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ss,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ts,{open:ee,onOpenChange:te,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(Yo,{open:re!==null,projectName:re?.name,onOpenChange:e=>!e&&ie(null),onConfirm:()=>{re&&(f(re.id),ie(null))}}),(0,$.jsx)(Xo,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Es,{open:B,onOpenChange:V,onComplete:()=>{H(!0),p()}})}),(0,$.jsx)(Qo,{})]}),(0,$.jsx)(cs,{})]})})}function As(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(Hn,Rn),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)(ks,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(ds,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(zn.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var js=!1;window.addEventListener(`resize`,()=>{js||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Fr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(yn,{children:(0,$.jsx)(As,{})})}));export{Qa as t};