tarsk 0.4.20 → 0.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -13
- package/dist/public/assets/{browser-tab-Cz-q-Pvk.js → browser-tab-BUOT-D_w.js} +1 -1
- package/dist/public/assets/chat-input-container-2a99CMGs.js +1 -0
- package/dist/public/assets/{diff-view-VbYca6ii.js → diff-view-DXIv51Tn.js} +1 -1
- package/dist/public/assets/{explorer-tab-view-uSxyCL34.js → explorer-tab-view-tyn_6pBh.js} +2 -2
- package/dist/public/assets/{explorer-view-B0uaxiLf.js → explorer-view-Bw3-gTSX.js} +1 -1
- package/dist/public/assets/index-BPF49zet.css +1 -0
- package/dist/public/assets/{index-BE8v6oQ0.js → index-DAw9BEzt.js} +5 -5
- package/dist/public/assets/{run-stop-button-Z7jiLiq7.js → run-stop-button-iZHomql0.js} +1 -1
- package/dist/public/assets/store-CAPnOXso.js +2 -0
- package/dist/public/assets/{terminal-panel-D6GPXaCe.js → terminal-panel-r8cb3-tk.js} +1 -1
- package/dist/public/assets/todos-view-MAb840dD.js +1 -0
- package/dist/public/index.html +5 -5
- package/package.json +1 -1
- package/dist/public/assets/chat-input-container-0T-khQfd.js +0 -1
- package/dist/public/assets/index-DVUFB7SX.css +0 -1
- package/dist/public/assets/store-CLOSXq_q.js +0 -2
- package/dist/public/assets/todos-view-yPftPooW.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-view-D1kGyryt.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-DmDjliuA.js","assets/use-toast-C9B1H3P9.js","assets/project-settings-view-BJYR_l3u.js","assets/react-vendor-CaS5zjF7.js","assets/history-view-BOjZoBCb.js","assets/monaco-c-HyCuEi.js","assets/textarea-BjfyGfGR.js","assets/dist-CIGnaqp2.js","assets/diff-view-
|
|
2
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,$r as n,$t as r,A as i,Ai as a,Ar as o,At as s,B as c,Bi as l,Bn as u,Cn as d,Cr as f,Di as p,Dn as m,Dr as h,Dt as g,E as _,Ei as v,En as y,Et as b,F as x,Fr as S,Ft as C,Gi as w,Gr as T,Gt as E,Hi as D,Hn as O,Hr as k,Ht as A,I as j,Ii as M,In as N,Ir as P,It as F,J as I,Ji as L,Jn as R,Jr as z,Jt as ee,Ki as te,Kn as ne,Kr as re,Kt as ie,L as ae,Li as oe,Lr as se,Lt as ce,M as le,Mn as B,Mr as ue,Mt as de,N as fe,Nn as V,Nr as pe,Nt as me,O as he,Or as ge,Ot as _e,P as ve,Pi as ye,Pn as H,Pr as be,Pt as xe,Qi as U,Qr as Se,R as Ce,Rn as W,Rt as we,S as Te,Sn as Ee,Ti as De,Tn as Oe,Ui as ke,Un as Ae,Ur as je,Ut as Me,Vn as Ne,Vt as Pe,Wi as Fe,Wn as G,Wt as Ie,X as Le,Xi as Re,Yi as ze,Yr as Be,Zr as Ve,Zt as He,_ as Ue,_n as We,_t as Ge,aa as Ke,ai as qe,an as Je,bn as Ye,bt as Xe,ca as Ze,ci as Qe,ct as $e,dn as et,dt as tt,ea as nt,ei as rt,en as it,et as at,f as ot,fi as st,ft as ct,g as lt,gi as ut,gt as dt,h as ft,hi as pt,hn as mt,ht,ii as gt,in as _t,it as vt,j as yt,jr as bt,jt as xt,k as St,ki as Ct,kn as wt,kr as Tt,la as Et,lt as Dt,mi as Ot,mt as kt,na as At,ni as jt,nn as Mt,o as Nt,oi as Pt,on as Ft,ot as It,p as Lt,pi as Rt,pt as zt,qi as Bt,qn as Vt,qr as Ht,qt as Ut,ra as Wt,ri as Gt,sa as Kt,st as qt,ta as Jt,ti as Yt,tn as Xt,un as Zt,ut as Qt,v as $t,vn as en,vt as tn,wi as nn,wn as rn,wt as an,x as on,xi as sn,xn as cn,xt as ln,yi as un,z as dn,zn as fn,zr as pn,zt as mn}from"./dialogs-config-DmDjliuA.js";import{$ as hn,A as gn,C as _n,G as vn,H as yn,I as bn,K as xn,L as Sn,M as Cn,N as wn,O as Tn,P as En,Q as Dn,R as On,S as kn,U as An,V as jn,W as Mn,b as Nn,et as Pn,ft as Fn,gt as In,ht as Ln,j as Rn,k as zn,mt as Bn,nt as Vn,pt as Hn,q as Un,tt as Wn,v as Gn,vt as Kn,w as qn,x as Jn,y as Yn,yt as Xn,z as Zn}from"./react-vendor-CaS5zjF7.js";import{a as Qn,c as $n,d as er,f as tr,i as nr,n as rr,o as ir,p as ar,r as or,t as K}from"./store-CLOSXq_q.js";import{t as sr}from"./textarea-BjfyGfGR.js";import{c as q,l as cr,s as J,u as Y}from"./history-view-BOjZoBCb.js";import{a as lr,i as ur,n as dr,r as fr,t as pr}from"./chat-input-container-0T-khQfd.js";import{n as mr,t as X}from"./use-toast-C9B1H3P9.js";import{t as hr}from"./standard-list-item-CpBjveM0.js";import{a as gr,c as _r,i as vr,n as yr,o as br,r as xr,s as Sr,t as Cr}from"./alert-dialog-Bk7neo_n.js";import{n as wr,t as Tr}from"./utils-BG_JNnOl.js";import{t as Er}from"./side-panel-container-BqWSTCOr.js";import{n as Dr,t as Or}from"./tab-context-Bmd79Rk0.js";import{n as kr,r as Ar}from"./onboarding-BgEjTEKs.js";import{n as jr,t as Mr}from"./run-stop-button-Z7jiLiq7.js";import{i as Nr,n as Pr,r as Fr,t as Ir}from"./tabs-DEmnnGvq.js";import{t as Lr}from"./page-toolbar-CvreDTwj.js";import{n as Rr,r as zr,t as Br}from"./resizable-DJ5w1ZWX.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(Et(),1),Vr=Xn(),Q=Kt(),Hr=1e10,Ur=1e3;function Wr(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 Gr(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=Ur}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Hr?++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 Wr([`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 Wr([`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 Wr([`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 Wr([`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 Kr(e,t){let n=Gr({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 qr=window.__electrobunWebviewId,Jr=window.__electrobunRpcSocketPort,Yr=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:${Jr}/socket?webviewId=${qr}`);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 Kr(`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))}})}})}},$=f();function Xr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:l,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Send Feedback`}),(0,$.jsx)(u,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(B,{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)(V,{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)(B,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===s?b=t[10]:(b=e=>s(e.target.value),t[9]=s,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)(V,{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)(B,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let w;t[16]===l?w=t[17]:(w=e=>l(e.target.value),t[16]=l,t[17]=w);let T;t[18]!==c||t[19]!==f||t[20]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(sr,{id:`feedback-text`,value:c,onChange:w,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=c,t[19]=f,t[20]=w,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==v||t[24]!==S?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,T]}),t[22]=T,t[23]=v,t[24]=S,t[25]=E):E=t[25];let D;t[26]===r?D=t[27]:(D=()=>r(!1),t[26]=r,t[27]=D);let k;t[28]!==f||t[29]!==D?(k=(0,$.jsx)(H,{variant:`outline`,onClick:D,disabled:f,children:`Cancel`}),t[28]=f,t[29]=D,t[30]=k):k=t[30];let A;t[31]===f?A=t[32]:(A=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{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)(H,{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)(Ne,{children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==E||t[41]!==M?(N=(0,$.jsxs)(fn,{className:`max-w-xl`,children:[m,E,M]}),t[40]=E,t[41]=M,t[42]=N):N=t[42];let P;return t[43]!==r||t[44]!==n||t[45]!==N?(P=(0,$.jsx)(W,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function Zr(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),qt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await m(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Qr(e){let t=(0,Q.c)(8),{theme:n,setTheme:r}=wr(),i;t[0]!==r||t[1]!==n?(i=()=>r(n===`dark`?`light`:`dark`),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a,o,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(pn,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),o=(0,$.jsx)(Pt,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),s=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=a,t[4]=o,t[5]=s):(a=t[3],o=t[4],s=t[5]);let c;return t[6]===i?c=t[7]:(c=(0,$.jsxs)(H,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:i,children:[a,o,s]}),t[6]=i,t[7]=c),c}function $r({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(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),[g,_]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||g||!e)return;async function n(){d(!0),p(null);try{let n=(await b(e)).currentConversationId??t,[r,a]=await Promise.allSettled([s(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?vt(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(a?.status===`fulfilled`&&a.value){if(o(a.value),a.value.model?.model){let e=a.value.model.model,t=a.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Qt(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(a?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,a.reason),a.reason;_(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,g,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,$.jsx)($.Fragment,{children:n});let v=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&&g&&_(!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)(nt,{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)(nt,{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)(nt,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[v(r.totalTokens),` tokens`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(be,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),a&&(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)(ge,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=v(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(a.footprint?.totalTokens??a.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),a.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[a.model.model,c?.context_length&&(0,$.jsxs)(`span`,{className:`ml-1`,children:[v(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: `,v(r.totalInputTokens)]}),(0,$.jsxs)(`span`,{children:[`Out: `,v(r.totalOutputTokens)]}),(0,$.jsxs)(`span`,{children:[`Avg: `,v(r.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,$.jsx)($.Fragment,{children:n})}function ei(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 b(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)(H,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,$.jsx)(be,{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)($r,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}var ti=(0,Z.lazy)(()=>Kn(()=>import(`./account-view-D1kGyryt.js`),__vite__mapDeps([0,1,2,3]))),ni=(0,Z.lazy)(()=>Kn(()=>import(`./project-settings-view-BJYR_l3u.js`),__vite__mapDeps([4,1,5,6,2,7,8,3])));function ri(e){let t=(0,Q.c)(101),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onNavigateToSettings:m,onDeselect:h,collapsed:g,updateAvailable:_,updatingApp:v,onUpdateApp:y,onRefreshProjects:b}=e,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),{showFeedback:T,feedbackName:E,setFeedbackName:D,feedbackEmail:O,setFeedbackEmail:k,feedbackText:A,setFeedbackText:j,loadingFeedbackUser:M,submittingFeedback:N,handleFeedbackDialogChange:P,handleSubmitFeedback:F}=Zr(),I;t[0]===n?I=t[1]:(I=n.map(ii),t[0]=n,t[1]=I);let L=I,R;t[2]!==g||t[3]!==u?(R=!g&&(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Se,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=u,t[4]=R):R=t[4];let z;t[5]!==g||t[6]!==y||t[7]!==_||t[8]!==v?(z=_&&(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:y,disabled:v,children:[v?(0,$.jsx)(pt,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(oe,{className:`h-4 w-4`}),!g&&(0,$.jsx)(`span`,{className:`truncate`,children:v?`Updating...`:`Update to Latest`})]}),t[5]=g,t[6]=y,t[7]=_,t[8]=v,t[9]=z):z=t[9];let ee;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(nt,{className:`h-4 w-4`}),t[10]=ee):ee=t[10];let te;t[11]===g?te=t[12]:(te=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),t[11]=g,t[12]=te);let re;t[13]!==m||t[14]!==te?(re=(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:m,children:[ee,te]})}),t[13]=m,t[14]=te,t[15]=re):re=t[15];let ie,ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>S(!0),ae=(0,$.jsx)(bt,{className:`h-4 w-4`}),t[16]=ie,t[17]=ae):(ie=t[16],ae=t[17]);let se;t[18]===g?se=t[19]:(se=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),t[18]=g,t[19]=se);let ce;t[20]===se?ce=t[21]:(ce=(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:ie,children:[ae,se]}),t[20]=se,t[21]=ce);let le;t[22]===P?le=t[23]:(le=()=>P(!0),t[22]=P,t[23]=le);let B,ue;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(st,{className:`h-4 w-4`}),ue=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[24]=B,t[25]=ue):(B=t[24],ue=t[25]);let de;t[26]===le?de=t[27]:(de=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:le,children:[B,ue]})}),t[26]=le,t[27]=de);let fe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),t[28]=fe):fe=t[28];let V;t[29]===de?V=t[30]:(V=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[de,fe]})}),t[29]=de,t[30]=V);let pe=r??void 0,me;t[31]===pe?me=t[32]:(me=(0,$.jsx)(ei,{threadId:pe}),t[31]=pe,t[32]=me);let he;t[33]===g?he=t[34]:(he=(0,$.jsx)(Qr,{collapsed:g}),t[33]=g,t[34]=he);let ge;t[35]!==ce||t[36]!==V||t[37]!==me||t[38]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,V,me,he]}),t[35]=ce,t[36]=V,t[37]=me,t[38]=he,t[39]=ge):ge=t[39];let _e;t[40]!==ge||t[41]!==z||t[42]!==re?(_e=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[z,re,ge]}),t[40]=ge,t[41]=z,t[42]=re,t[43]=_e):_e=t[43];let ve;t[44]===n.length?ve=t[45]:(ve=n.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No projects yet. Clone a repository to get started.`}),t[44]=n.length,t[45]=ve);let ye;t[46]!==o||t[47]!==c||t[48]!==s||t[49]!==d||t[50]!==p||t[51]!==f||t[52]!==l||t[53]!==a||t[54]!==n||t[55]!==i||t[56]!==r?(ye=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(ai,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:w,hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(oi,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${ne(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[46]=o,t[47]=c,t[48]=s,t[49]=d,t[50]=p,t[51]=f,t[52]=l,t[53]=a,t[54]=n,t[55]=i,t[56]=r,t[57]=ye):ye=t[57];let be;t[58]!==L||t[59]!==ye?(be=(0,$.jsx)(lr,{nodes:L,defaultOpen:!0,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ye}),t[58]=L,t[59]=ye,t[60]=be):be=t[60];let xe;t[61]!==ve||t[62]!==be?(xe=(0,$.jsx)(wt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ve,be]})}),t[61]=ve,t[62]=be,t[63]=xe):xe=t[63];let U;t[64]!==g||t[65]!==h||t[66]!==R||t[67]!==_e||t[68]!==xe?(U=(0,$.jsx)(Er,{collapsed:g,onLogoClick:h,headerAction:R,footer:_e,children:xe}),t[64]=g,t[65]=h,t[66]=R,t[67]=_e,t[68]=xe,t[69]=U):U=t[69];let Ce=C!==null,we;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>!e&&w(null),t[70]=we):we=t[70];let Te;t[71]===b?Te=t[72]:(Te=()=>{b?.(),w(null)},t[71]=b,t[72]=Te);let Ee;t[73]!==C||t[74]!==Te?(Ee=(0,$.jsx)(fn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ni,{projectId:C,onProjectUpdated:Te})})}),t[73]=C,t[74]=Te,t[75]=Ee):Ee=t[75];let De;t[76]!==Ce||t[77]!==Ee?(De=(0,$.jsx)(W,{open:Ce,onOpenChange:we,children:Ee}),t[76]=Ce,t[77]=Ee,t[78]=De):De=t[78];let Oe;t[79]===F?Oe=t[80]:(Oe=()=>void F(),t[79]=F,t[80]=Oe);let ke;t[81]!==O||t[82]!==E||t[83]!==A||t[84]!==P||t[85]!==M||t[86]!==k||t[87]!==D||t[88]!==j||t[89]!==T||t[90]!==N||t[91]!==Oe?(ke=(0,$.jsx)(Xr,{open:T,onOpenChange:P,feedbackName:E,onFeedbackNameChange:D,feedbackEmail:O,onFeedbackEmailChange:k,feedbackText:A,onFeedbackTextChange:j,loadingFeedbackUser:M,submittingFeedback:N,onSubmit:Oe}),t[81]=O,t[82]=E,t[83]=A,t[84]=P,t[85]=M,t[86]=k,t[87]=D,t[88]=j,t[89]=T,t[90]=N,t[91]=Oe,t[92]=ke):ke=t[92];let Ae;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(fn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ti,{})})}),t[93]=Ae):Ae=t[93];let je;t[94]===x?je=t[95]:(je=(0,$.jsx)(W,{open:x,onOpenChange:S,children:Ae}),t[94]=x,t[95]=je);let Me;return t[96]!==U||t[97]!==De||t[98]!==ke||t[99]!==je?(Me=(0,$.jsxs)($.Fragment,{children:[U,De,ke,je]}),t[96]=U,t[97]=De,t[98]=ke,t[99]=je,t[100]=Me):Me=t[100],Me}function ii(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 ai(e){let t=(0,Q.c)(26),{project:n,isOpen:r,onToggle:i,isDeletingProject:o,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,f;t[0]===n?f=t[1]:(f=ne(n),t[0]=n,t[1]=f);let p=f,m=s||c,h=r&&`rotate-90`,g;t[2]===h?g=t[3]:(g=G(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,h),t[2]=h,t[3]=g);let _;t[4]===g?_=t[5]:(_=(0,$.jsx)(Re,{className:g}),t[4]=g,t[5]=_);let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=v):v=t[6];let y=(s||c)&&`font-bold text-foreground`,b;t[7]===y?b=t[8]:(b=G(`min-w-0 truncate transition-all block`,y),t[7]=y,t[8]=b);let x;t[9]!==p||t[10]!==b?(x=(0,$.jsx)(`span`,{className:b,children:p}),t[9]=p,t[10]=b,t[11]=x):x=t[11];let C;t[12]!==_||t[13]!==x?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,v,x]}),t[12]=_,t[13]=x,t[14]=C):C=t[14];let w;t[15]!==o||t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==n?(w=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:o?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(cr,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(n.projectId)},children:[(0,$.jsx)(T,{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)(H,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(Se,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(S,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),t[15]=o,t[16]=l,t[17]=u,t[18]=d,t[19]=n,t[20]=w):w=t[20];let E;return t[21]!==i||t[22]!==C||t[23]!==w||t[24]!==m?(E=(0,$.jsxs)(hr,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[C,w]}),t[21]=i,t[22]=C,t[23]=w,t[24]=m,t[25]=E):E=t[25],E}function oi(e){let n=(0,Q.c)(47),{thread:r,projectId:i,selectedThreadId:a,isProcessing:o,isDeleting:s,isCompleted:c,projectTitlePrefix:l,onSelectThread:u,onDeleteThread:d}=e,[f,p]=(0,Z.useState)(!1),m;n[0]!==d||n[1]!==i||n[2]!==r.gitStatusDot||n[3]!==r.threadId?(m=e=>{e.stopPropagation(),r.gitStatusDot?p(!0):d(i,r.threadId)},n[0]=d,n[1]=i,n[2]=r.gitStatusDot,n[3]=r.threadId,n[4]=m):m=n[4];let h=m,g;n[5]!==l||n[6]!==r.threadId||n[7]!==r.title?(g=r.title?.startsWith(l)?r.title.slice(l.length):r.title??r.threadId,n[5]=l,n[6]=r.threadId,n[7]=r.title,n[8]=g):g=n[8];let _=g,v;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(_r,{children:`Delete Thread`}),n[9]=v):v=n[9];let y;n[10]===_?y=n[11]:(y=(0,$.jsxs)(gr,{children:[`Are you sure you want to delete "`,_,`" and all its files? This action cannot be undone.`]}),n[10]=_,n[11]=y);let b;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(xr,{children:`Cancel`}),n[12]=b):b=n[12];let x;n[13]!==d||n[14]!==i||n[15]!==r.threadId?(x=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[b,(0,$.jsx)(yr,{onClick:()=>{p(!1),d(i,r.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),n[13]=d,n[14]=i,n[15]=r.threadId,n[16]=x):x=n[16];let C;n[17]!==y||n[18]!==x?(C=(0,$.jsxs)(vr,{children:[v,y,x]}),n[17]=y,n[18]=x,n[19]=C):C=n[19];let w;n[20]!==f||n[21]!==C?(w=(0,$.jsx)(Cr,{open:f,onOpenChange:p,children:C}),n[20]=f,n[21]=C,n[22]=w):w=n[22];let T=r.threadId===a,E,D;n[23]!==u||n[24]!==i||n[25]!==r.threadId?(E=()=>u(i,r.threadId),D=e=>{(e.key===`Enter`||e.key===` `)&&u(i,r.threadId)},n[23]=u,n[24]=i,n[25]=r.threadId,n[26]=E,n[27]=D):(E=n[26],D=n[27]);let O;n[28]===r.gitStatusDot?O=n[29]:(O=r.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`})}),n[28]=r.gitStatusDot,n[29]=O);let k;n[30]===_?k=n[31]:(k=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:_})}),n[30]=_,n[31]=k);let A;n[32]!==h||n[33]!==c||n[34]!==s||n[35]!==o?(A=o||s?(0,$.jsx)(pt,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):c?(0,$.jsx)(t,{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)(H,{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:h,children:[(0,$.jsx)(S,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),n[32]=h,n[33]=c,n[34]=s,n[35]=o,n[36]=A):A=n[36];let j;n[37]!==E||n[38]!==D||n[39]!==O||n[40]!==k||n[41]!==A||n[42]!==T?(j=(0,$.jsxs)(hr,{selected:T,onClick:E,onKeyDown:D,role:`button`,tabIndex:0,children:[O,k,A]}),n[37]=E,n[38]=D,n[39]=O,n[40]=k,n[41]=A,n[42]=T,n[43]=j):j=n[43];let M;return n[44]!==j||n[45]!==w?(M=(0,$.jsxs)($.Fragment,{children:[w,j]}),n[44]=j,n[45]=w,n[46]=M):M=n[46],M}var si=e(Ze(),1),ci=.1,li=10,ui=1.25,di=.001;function fi(){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=pi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*ui)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/ui)),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*di;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 pi(e){return Math.min(Math.max(e,ci),li)}function mi(){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 hi(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 gi(e){let t=(0,Q.c)(69),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:s,zoomIn:c,zoomOut:l,reset:u,onMouseDown:d,onMouseMove:f,onMouseUp:p}=fi(),m,h;t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[3]=g):g=t[3],(0,Z.useEffect)(_i,g);let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:`mermaid diagram`}),t[4]=_):_=t[4];let v,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Qe,{className:`h-3.5 w-3.5`}),y=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=v,t[6]=y):(v=t[5],y=t[6]);let b;t[7]===l?b=t[8]:(b=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[v,y]})}),t[7]=l,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(q,{children:`Zoom out`}),t[9]=x):x=t[9];let S;t[10]===b?S=t[11]:(S=(0,$.jsxs)(J,{children:[b,x]}),t[10]=b,t[11]=S);let C;t[12]===i?C=t[13]:(C=Math.round(i*100),t[12]=i,t[13]=C);let w;t[14]!==u||t[15]!==C?(w=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:u,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:[C,`%`]})}),t[14]=u,t[15]=C,t[16]=w):w=t[16];let T;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Reset zoom`}),t[17]=T):T=t[17];let E;t[18]===w?E=t[19]:(E=(0,$.jsxs)(J,{children:[w,T]}),t[18]=w,t[19]=E);let D,O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Se,{className:`h-3.5 w-3.5`}),O=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[20]=D,t[21]=O):(D=t[20],O=t[21]);let k;t[22]===c?k=t[23]:(k=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[D,O]})}),t[22]=c,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(q,{children:`Zoom in`}),t[24]=A):A=t[24];let j;t[25]===k?j=t[26]:(j=(0,$.jsxs)(J,{children:[k,A]}),t[25]=k,t[26]=j);let M,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`}),N=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[27]=M,t[28]=N):(M=t[27],N=t[28]);let P;t[29]===u?P=t[30]:(P=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[M,N]})}),t[29]=u,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(q,{children:`Reset view`}),t[31]=F):F=t[31];let I;t[32]===P?I=t[33]:(I=(0,$.jsxs)(J,{children:[P,F]}),t[32]=P,t[33]=I);let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[34]=L):L=t[34];let R,z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Tt,{className:`h-3.5 w-3.5`}),z=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[35]=R,t[36]=z):(R=t[35],z=t[36]);let ee;t[37]===r?ee=t[38]:(ee=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[R,z]})}),t[37]=r,t[38]=ee);let te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(q,{children:`Close (Esc)`}),t[39]=te):te=t[39];let ne;t[40]===ee?ne=t[41]:(ne=(0,$.jsxs)(J,{children:[ee,te]}),t[40]=ee,t[41]=ne);let re;t[42]!==E||t[43]!==j||t[44]!==I||t[45]!==ne||t[46]!==S?(re=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[_,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S,E,j,I,L,ne]})]}),t[42]=E,t[43]=j,t[44]=I,t[45]=ne,t[46]=S,t[47]=re):re=t[47];let ie=o?`cursor-grabbing`:`cursor-grab`,ae;t[48]===ie?ae=t[49]:(ae=G(`flex-1 overflow-hidden select-none`,ie),t[48]=ie,t[49]=ae);let oe=`translate(${a.x}px, ${a.y}px) scale(${i})`,se=o?`none`:`transform 0.1s ease-out`,ce;t[50]!==oe||t[51]!==se?(ce={transform:oe,transformOrigin:`center center`,transition:se},t[50]=oe,t[51]=se,t[52]=ce):ce=t[52];let le;t[53]===n?le=t[54]:(le={__html:n},t[53]=n,t[54]=le);let B;t[55]!==ce||t[56]!==le?(B=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:ce,dangerouslySetInnerHTML:le}),t[55]=ce,t[56]=le,t[57]=B):B=t[57];let ue;t[58]!==s||t[59]!==d||t[60]!==f||t[61]!==p||t[62]!==ae||t[63]!==B?(ue=(0,$.jsx)(`div`,{ref:s,className:ae,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:B}),t[58]=s,t[59]=d,t[60]=f,t[61]=p,t[62]=ae,t[63]=B,t[64]=ue):ue=t[64];let de;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(de=(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`}),t[65]=de):de=t[65];let fe;return t[66]!==re||t[67]!==ue?(fe=(0,si.createPortal)((0,$.jsx)(cr,{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:[re,ue,de]})}),document.body),t[66]=re,t[67]=ue,t[68]=fe):fe=t[68],fe}function _i(){return document.body.style.overflow=`hidden`,vi}function vi(){document.body.style.overflow=``}function yi(e){let n=(0,Q.c)(51),{content:r,className:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{svgOutput:l,renderError:u}=hi(r,mi()),d;n[0]===r?d=n[1]:(d=async function(){await navigator.clipboard.writeText(r),o(!0),setTimeout(()=>o(!1),2e3)},n[0]=r,n[1]=d);let f=d,p=u?`mermaid (render error)`:`mermaid diagram`,m;n[2]===p?m=n[3]:(m=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:p}),n[2]=p,n[3]=m);let h;n[4]!==u||n[5]!==l?(h=l&&!u&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`action`,size:`icon-xs`,onClick:()=>c(!0),children:[(0,$.jsx)(Rt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(q,{children:`View fullscreen`})]}),n[4]=u,n[5]=l,n[6]=h):h=n[6];let g;n[7]===a?g=n[8]:(g=a?(0,$.jsx)(t,{}):(0,$.jsx)(D,{}),n[7]=a,n[8]=g);let _;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),n[9]=_):_=n[9];let v;n[10]!==f||n[11]!==g?(v=(0,$.jsxs)(H,{variant:`action`,size:`icon-xs`,onClick:f,children:[g,_]}),n[10]=f,n[11]=g,n[12]=v):v=n[12];let y;n[13]!==h||n[14]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h,v]}),n[13]=h,n[14]=v,n[15]=y):y=n[15];let b;n[16]!==m||n[17]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[m,y]}),n[16]=m,n[17]=y,n[18]=b):b=n[18];let x=b;if(u){let e;n[19]===i?e=n[20]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[19]=i,n[20]=e);let t;n[21]===r?t=n[22]:(t=(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})}),n[21]=r,n[22]=t);let a;return n[23]!==x||n[24]!==e||n[25]!==t?(a=(0,$.jsxs)(`div`,{className:e,children:[x,t]}),n[23]=x,n[24]=e,n[25]=t,n[26]=a):a=n[26],a}if(!l){let e;n[27]===i?e=n[28]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[27]=i,n[28]=e);let t;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:`Rendering diagram…`}),n[29]=t):t=n[29];let r;return n[30]!==x||n[31]!==e?(r=(0,$.jsxs)(`div`,{className:e,children:[x,t]}),n[30]=x,n[31]=e,n[32]=r):r=n[32],r}let S;n[33]===i?S=n[34]:(S=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[33]=i,n[34]=S);let C;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>c(!0),n[35]=C):C=n[35];let w;n[36]===l?w=n[37]:(w=(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:C,dangerouslySetInnerHTML:{__html:l}})}),n[36]=l,n[37]=w);let T;n[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Click to view fullscreen`}),n[38]=T):T=n[38];let E;n[39]===w?E=n[40]:(E=(0,$.jsxs)(J,{children:[w,T]}),n[39]=w,n[40]=E);let O;n[41]!==x||n[42]!==S||n[43]!==E?(O=(0,$.jsxs)(`div`,{className:S,children:[x,E]}),n[41]=x,n[42]=S,n[43]=E,n[44]=O):O=n[44];let k;n[45]!==s||n[46]!==l?(k=s&&(0,$.jsx)(gi,{svgOutput:l,onClose:()=>c(!1)}),n[45]=s,n[46]=l,n[47]=k):k=n[47];let A;return n[48]!==O||n[49]!==k?(A=(0,$.jsxs)(cr,{children:[O,k]}),n[48]=O,n[49]=k,n[50]=A):A=n[50],A}var bi=`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(`.`),xi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 Si(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-view-D1kGyryt.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-DmDjliuA.js","assets/use-toast-C9B1H3P9.js","assets/project-settings-view-BJYR_l3u.js","assets/react-vendor-CaS5zjF7.js","assets/history-view-BOjZoBCb.js","assets/monaco-c-HyCuEi.js","assets/textarea-BjfyGfGR.js","assets/dist-CIGnaqp2.js","assets/diff-view-DXIv51Tn.js","assets/chat-input-container-2a99CMGs.js","assets/onboarding-BgEjTEKs.js","assets/alert-dialog-Bk7neo_n.js","assets/store-CAPnOXso.js","assets/page-toolbar-CvreDTwj.js","assets/context-menu-DHHElhQ1.js","assets/resizable-DJ5w1ZWX.js","assets/standard-list-item-CpBjveM0.js","assets/utils-BG_JNnOl.js","assets/terminal-panel-r8cb3-tk.js","assets/tab-context-Bmd79Rk0.js","assets/explorer-tab-view-tyn_6pBh.js","assets/browser-tab-BUOT-D_w.js","assets/run-stop-button-iZHomql0.js","assets/onboarding-dialog-EiVl-ynw.js","assets/conversation-history-view-HVFzgO9e.js","assets/settings-view-C38jeeqJ.js","assets/side-panel-container-BqWSTCOr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,$r as n,$t as r,A as i,Ai as a,Ar as o,At as s,B as c,Bi as l,Bn as u,Cn as d,Cr as f,Di as p,Dn as m,Dr as h,Dt as g,E as _,Ei as v,En as y,Et as b,F as x,Fr as S,Ft as C,Gi as w,Gr as T,Gt as E,Hi as D,Hn as O,Hr as k,Ht as A,I as j,Ii as M,In as N,Ir as P,It as F,J as I,Ji as L,Jn as R,Jr as z,Jt as ee,Ki as te,Kn as ne,Kr as re,Kt as ie,L as ae,Li as oe,Lr as se,Lt as ce,M as le,Mn as B,Mr as ue,Mt as de,N as fe,Nn as V,Nr as pe,Nt as me,O as he,Or as ge,Ot as _e,P as ve,Pi as ye,Pn as H,Pr as be,Pt as xe,Qi as U,Qr as Se,R as Ce,Rn as W,Rt as we,S as Te,Sn as Ee,Ti as De,Tn as Oe,Ui as ke,Un as Ae,Ur as je,Ut as Me,Vn as Ne,Vt as Pe,Wi as Fe,Wn as G,Wt as Ie,X as Le,Xi as Re,Yi as ze,Yr as Be,Zr as Ve,Zt as He,_ as Ue,_n as We,_t as Ge,aa as Ke,ai as qe,an as Je,bn as Ye,bt as Xe,ca as Ze,ci as Qe,ct as $e,dn as et,dt as tt,ea as nt,ei as rt,en as it,et as at,f as ot,fi as st,ft as ct,g as lt,gi as ut,gt as dt,h as ft,hi as pt,hn as mt,ht,ii as gt,in as _t,it as vt,j as yt,jr as bt,jt as xt,k as St,ki as Ct,kn as wt,kr as Tt,la as Et,lt as Dt,mi as Ot,mt as kt,na as At,ni as jt,nn as Mt,o as Nt,oi as Pt,on as Ft,ot as It,p as Lt,pi as Rt,pt as zt,qi as Bt,qn as Vt,qr as Ht,qt as Ut,ra as Wt,ri as Gt,sa as Kt,st as qt,ta as Jt,ti as Yt,tn as Xt,un as Zt,ut as Qt,v as $t,vn as en,vt as tn,wi as nn,wn as rn,wt as an,x as on,xi as sn,xn as cn,xt as ln,yi as un,z as dn,zn as fn,zr as pn,zt as mn}from"./dialogs-config-DmDjliuA.js";import{$ as hn,A as gn,C as _n,G as vn,H as yn,I as bn,K as xn,L as Sn,M as Cn,N as wn,O as Tn,P as En,Q as Dn,R as On,S as kn,U as An,V as jn,W as Mn,b as Nn,et as Pn,ft as Fn,gt as In,ht as Ln,j as Rn,k as zn,mt as Bn,nt as Vn,pt as Hn,q as Un,tt as Wn,v as Gn,vt as Kn,w as qn,x as Jn,y as Yn,yt as Xn,z as Zn}from"./react-vendor-CaS5zjF7.js";import{a as Qn,c as $n,d as er,f as tr,i as nr,n as rr,o as ir,p as ar,r as or,t as K}from"./store-CAPnOXso.js";import{t as sr}from"./textarea-BjfyGfGR.js";import{c as q,l as cr,s as J,u as Y}from"./history-view-BOjZoBCb.js";import{a as lr,i as ur,n as dr,r as fr,t as pr}from"./chat-input-container-2a99CMGs.js";import{n as mr,t as X}from"./use-toast-C9B1H3P9.js";import{t as hr}from"./standard-list-item-CpBjveM0.js";import{a as gr,c as _r,i as vr,n as yr,o as br,r as xr,s as Sr,t as Cr}from"./alert-dialog-Bk7neo_n.js";import{n as wr,t as Tr}from"./utils-BG_JNnOl.js";import{t as Er}from"./side-panel-container-BqWSTCOr.js";import{n as Dr,t as Or}from"./tab-context-Bmd79Rk0.js";import{n as kr,r as Ar}from"./onboarding-BgEjTEKs.js";import{n as jr,t as Mr}from"./run-stop-button-iZHomql0.js";import{i as Nr,n as Pr,r as Fr,t as Ir}from"./tabs-DEmnnGvq.js";import{t as Lr}from"./page-toolbar-CvreDTwj.js";import{n as Rr,r as zr,t as Br}from"./resizable-DJ5w1ZWX.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(Et(),1),Vr=Xn(),Q=Kt(),Hr=1e10,Ur=1e3;function Wr(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 Gr(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=Ur}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Hr?++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 Wr([`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 Wr([`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 Wr([`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 Wr([`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 Kr(e,t){let n=Gr({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 qr=window.__electrobunWebviewId,Jr=window.__electrobunRpcSocketPort,Yr=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:${Jr}/socket?webviewId=${qr}`);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 Kr(`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))}})}})}},$=f();function Xr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:l,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Send Feedback`}),(0,$.jsx)(u,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(B,{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)(V,{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)(B,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===s?b=t[10]:(b=e=>s(e.target.value),t[9]=s,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)(V,{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)(B,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let w;t[16]===l?w=t[17]:(w=e=>l(e.target.value),t[16]=l,t[17]=w);let T;t[18]!==c||t[19]!==f||t[20]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(sr,{id:`feedback-text`,value:c,onChange:w,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=c,t[19]=f,t[20]=w,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==v||t[24]!==S?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,T]}),t[22]=T,t[23]=v,t[24]=S,t[25]=E):E=t[25];let D;t[26]===r?D=t[27]:(D=()=>r(!1),t[26]=r,t[27]=D);let k;t[28]!==f||t[29]!==D?(k=(0,$.jsx)(H,{variant:`outline`,onClick:D,disabled:f,children:`Cancel`}),t[28]=f,t[29]=D,t[30]=k):k=t[30];let A;t[31]===f?A=t[32]:(A=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{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)(H,{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)(Ne,{children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==E||t[41]!==M?(N=(0,$.jsxs)(fn,{className:`max-w-xl`,children:[m,E,M]}),t[40]=E,t[41]=M,t[42]=N):N=t[42];let P;return t[43]!==r||t[44]!==n||t[45]!==N?(P=(0,$.jsx)(W,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function Zr(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),qt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await m(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Qr(e){let t=(0,Q.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=wr();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)(pn,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(Pt,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,$.jsxs)(H,{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 $r({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(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),[g,_]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||g||!e)return;async function n(){d(!0),p(null);try{let n=(await b(e)).currentConversationId??t,[r,a]=await Promise.allSettled([s(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?vt(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(a?.status===`fulfilled`&&a.value){if(o(a.value),a.value.model?.model){let e=a.value.model.model,t=a.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Qt(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(a?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,a.reason),a.reason;_(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,g,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,$.jsx)($.Fragment,{children:n});let v=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&&g&&_(!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)(nt,{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)(nt,{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)(nt,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[v(r.totalTokens),` tokens`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(be,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),a&&(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)(ge,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=v(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(a.footprint?.totalTokens??a.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),a.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[a.model.model,c?.context_length&&(0,$.jsxs)(`span`,{className:`ml-1`,children:[v(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: `,v(r.totalInputTokens)]}),(0,$.jsxs)(`span`,{children:[`Out: `,v(r.totalOutputTokens)]}),(0,$.jsxs)(`span`,{children:[`Avg: `,v(r.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,$.jsx)($.Fragment,{children:n})}function ei(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 b(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)(H,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,$.jsx)(be,{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)($r,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}var ti=(0,Z.lazy)(()=>Kn(()=>import(`./account-view-D1kGyryt.js`),__vite__mapDeps([0,1,2,3]))),ni=(0,Z.lazy)(()=>Kn(()=>import(`./project-settings-view-BJYR_l3u.js`),__vite__mapDeps([4,1,5,6,2,7,8,3])));function ri(e){let t=(0,Q.c)(101),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onNavigateToSettings:m,onDeselect:h,collapsed:g,updateAvailable:_,updatingApp:v,onUpdateApp:y,onRefreshProjects:b}=e,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),{showFeedback:T,feedbackName:E,setFeedbackName:D,feedbackEmail:O,setFeedbackEmail:k,feedbackText:A,setFeedbackText:j,loadingFeedbackUser:M,submittingFeedback:N,handleFeedbackDialogChange:P,handleSubmitFeedback:F}=Zr(),I;t[0]===n?I=t[1]:(I=n.map(ii),t[0]=n,t[1]=I);let L=I,R;t[2]!==g||t[3]!==u?(R=!g&&(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Se,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=u,t[4]=R):R=t[4];let z;t[5]!==g||t[6]!==y||t[7]!==_||t[8]!==v?(z=_&&(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:y,disabled:v,children:[v?(0,$.jsx)(pt,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(oe,{className:`h-4 w-4`}),!g&&(0,$.jsx)(`span`,{className:`truncate`,children:v?`Updating...`:`Update to Latest`})]}),t[5]=g,t[6]=y,t[7]=_,t[8]=v,t[9]=z):z=t[9];let ee;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(nt,{className:`h-4 w-4`}),t[10]=ee):ee=t[10];let te;t[11]===g?te=t[12]:(te=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),t[11]=g,t[12]=te);let re;t[13]!==m||t[14]!==te?(re=(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:m,children:[ee,te]})}),t[13]=m,t[14]=te,t[15]=re):re=t[15];let ie,ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>S(!0),ae=(0,$.jsx)(bt,{className:`h-4 w-4`}),t[16]=ie,t[17]=ae):(ie=t[16],ae=t[17]);let se;t[18]===g?se=t[19]:(se=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),t[18]=g,t[19]=se);let ce;t[20]===se?ce=t[21]:(ce=(0,$.jsxs)(H,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:ie,children:[ae,se]}),t[20]=se,t[21]=ce);let le;t[22]===P?le=t[23]:(le=()=>P(!0),t[22]=P,t[23]=le);let B,ue;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(st,{className:`h-4 w-4`}),ue=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[24]=B,t[25]=ue):(B=t[24],ue=t[25]);let de;t[26]===le?de=t[27]:(de=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:le,children:[B,ue]})}),t[26]=le,t[27]=de);let fe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),t[28]=fe):fe=t[28];let V;t[29]===de?V=t[30]:(V=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[de,fe]})}),t[29]=de,t[30]=V);let pe=r??void 0,me;t[31]===pe?me=t[32]:(me=(0,$.jsx)(ei,{threadId:pe}),t[31]=pe,t[32]=me);let he;t[33]===g?he=t[34]:(he=(0,$.jsx)(Qr,{collapsed:g}),t[33]=g,t[34]=he);let ge;t[35]!==ce||t[36]!==V||t[37]!==me||t[38]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,V,me,he]}),t[35]=ce,t[36]=V,t[37]=me,t[38]=he,t[39]=ge):ge=t[39];let _e;t[40]!==ge||t[41]!==z||t[42]!==re?(_e=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[z,re,ge]}),t[40]=ge,t[41]=z,t[42]=re,t[43]=_e):_e=t[43];let ve;t[44]===n.length?ve=t[45]:(ve=n.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No projects yet. Clone a repository to get started.`}),t[44]=n.length,t[45]=ve);let ye;t[46]!==o||t[47]!==c||t[48]!==s||t[49]!==d||t[50]!==p||t[51]!==f||t[52]!==l||t[53]!==a||t[54]!==n||t[55]!==i||t[56]!==r?(ye=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(ai,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:w,hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(oi,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${ne(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[46]=o,t[47]=c,t[48]=s,t[49]=d,t[50]=p,t[51]=f,t[52]=l,t[53]=a,t[54]=n,t[55]=i,t[56]=r,t[57]=ye):ye=t[57];let be;t[58]!==L||t[59]!==ye?(be=(0,$.jsx)(lr,{nodes:L,defaultOpen:!0,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ye}),t[58]=L,t[59]=ye,t[60]=be):be=t[60];let xe;t[61]!==ve||t[62]!==be?(xe=(0,$.jsx)(wt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ve,be]})}),t[61]=ve,t[62]=be,t[63]=xe):xe=t[63];let U;t[64]!==g||t[65]!==h||t[66]!==R||t[67]!==_e||t[68]!==xe?(U=(0,$.jsx)(Er,{collapsed:g,onLogoClick:h,headerAction:R,footer:_e,children:xe}),t[64]=g,t[65]=h,t[66]=R,t[67]=_e,t[68]=xe,t[69]=U):U=t[69];let Ce=C!==null,we;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>!e&&w(null),t[70]=we):we=t[70];let Te;t[71]===b?Te=t[72]:(Te=()=>{b?.(),w(null)},t[71]=b,t[72]=Te);let Ee;t[73]!==C||t[74]!==Te?(Ee=(0,$.jsx)(fn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ni,{projectId:C,onProjectUpdated:Te})})}),t[73]=C,t[74]=Te,t[75]=Ee):Ee=t[75];let De;t[76]!==Ce||t[77]!==Ee?(De=(0,$.jsx)(W,{open:Ce,onOpenChange:we,children:Ee}),t[76]=Ce,t[77]=Ee,t[78]=De):De=t[78];let Oe;t[79]===F?Oe=t[80]:(Oe=()=>void F(),t[79]=F,t[80]=Oe);let ke;t[81]!==O||t[82]!==E||t[83]!==A||t[84]!==P||t[85]!==M||t[86]!==k||t[87]!==D||t[88]!==j||t[89]!==T||t[90]!==N||t[91]!==Oe?(ke=(0,$.jsx)(Xr,{open:T,onOpenChange:P,feedbackName:E,onFeedbackNameChange:D,feedbackEmail:O,onFeedbackEmailChange:k,feedbackText:A,onFeedbackTextChange:j,loadingFeedbackUser:M,submittingFeedback:N,onSubmit:Oe}),t[81]=O,t[82]=E,t[83]=A,t[84]=P,t[85]=M,t[86]=k,t[87]=D,t[88]=j,t[89]=T,t[90]=N,t[91]=Oe,t[92]=ke):ke=t[92];let Ae;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(fn,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ti,{})})}),t[93]=Ae):Ae=t[93];let je;t[94]===x?je=t[95]:(je=(0,$.jsx)(W,{open:x,onOpenChange:S,children:Ae}),t[94]=x,t[95]=je);let Me;return t[96]!==U||t[97]!==De||t[98]!==ke||t[99]!==je?(Me=(0,$.jsxs)($.Fragment,{children:[U,De,ke,je]}),t[96]=U,t[97]=De,t[98]=ke,t[99]=je,t[100]=Me):Me=t[100],Me}function ii(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 ai(e){let t=(0,Q.c)(26),{project:n,isOpen:r,onToggle:i,isDeletingProject:o,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,f;t[0]===n?f=t[1]:(f=ne(n),t[0]=n,t[1]=f);let p=f,m=s||c,h=r&&`rotate-90`,g;t[2]===h?g=t[3]:(g=G(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,h),t[2]=h,t[3]=g);let _;t[4]===g?_=t[5]:(_=(0,$.jsx)(Re,{className:g}),t[4]=g,t[5]=_);let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=v):v=t[6];let y=(s||c)&&`font-bold text-foreground`,b;t[7]===y?b=t[8]:(b=G(`min-w-0 truncate transition-all block`,y),t[7]=y,t[8]=b);let x;t[9]!==p||t[10]!==b?(x=(0,$.jsx)(`span`,{className:b,children:p}),t[9]=p,t[10]=b,t[11]=x):x=t[11];let C;t[12]!==_||t[13]!==x?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,v,x]}),t[12]=_,t[13]=x,t[14]=C):C=t[14];let w;t[15]!==o||t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==n?(w=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:o?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(cr,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(n.projectId)},children:[(0,$.jsx)(T,{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)(H,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(Se,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(S,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),t[15]=o,t[16]=l,t[17]=u,t[18]=d,t[19]=n,t[20]=w):w=t[20];let E;return t[21]!==i||t[22]!==C||t[23]!==w||t[24]!==m?(E=(0,$.jsxs)(hr,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[C,w]}),t[21]=i,t[22]=C,t[23]=w,t[24]=m,t[25]=E):E=t[25],E}function oi(e){let n=(0,Q.c)(47),{thread:r,projectId:i,selectedThreadId:a,isProcessing:o,isDeleting:s,isCompleted:c,projectTitlePrefix:l,onSelectThread:u,onDeleteThread:d}=e,[f,p]=(0,Z.useState)(!1),m;n[0]!==d||n[1]!==i||n[2]!==r.gitStatusDot||n[3]!==r.threadId?(m=e=>{e.stopPropagation(),r.gitStatusDot?p(!0):d(i,r.threadId)},n[0]=d,n[1]=i,n[2]=r.gitStatusDot,n[3]=r.threadId,n[4]=m):m=n[4];let h=m,g;n[5]!==l||n[6]!==r.threadId||n[7]!==r.title?(g=r.title?.startsWith(l)?r.title.slice(l.length):r.title??r.threadId,n[5]=l,n[6]=r.threadId,n[7]=r.title,n[8]=g):g=n[8];let _=g,v;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(_r,{children:`Delete Thread`}),n[9]=v):v=n[9];let y;n[10]===_?y=n[11]:(y=(0,$.jsxs)(gr,{children:[`Are you sure you want to delete "`,_,`" and all its files? This action cannot be undone.`]}),n[10]=_,n[11]=y);let b;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(xr,{children:`Cancel`}),n[12]=b):b=n[12];let x;n[13]!==d||n[14]!==i||n[15]!==r.threadId?(x=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[b,(0,$.jsx)(yr,{onClick:()=>{p(!1),d(i,r.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),n[13]=d,n[14]=i,n[15]=r.threadId,n[16]=x):x=n[16];let C;n[17]!==y||n[18]!==x?(C=(0,$.jsxs)(vr,{children:[v,y,x]}),n[17]=y,n[18]=x,n[19]=C):C=n[19];let w;n[20]!==f||n[21]!==C?(w=(0,$.jsx)(Cr,{open:f,onOpenChange:p,children:C}),n[20]=f,n[21]=C,n[22]=w):w=n[22];let T=r.threadId===a,E,D;n[23]!==u||n[24]!==i||n[25]!==r.threadId?(E=()=>u(i,r.threadId),D=e=>{(e.key===`Enter`||e.key===` `)&&u(i,r.threadId)},n[23]=u,n[24]=i,n[25]=r.threadId,n[26]=E,n[27]=D):(E=n[26],D=n[27]);let O;n[28]===r.gitStatusDot?O=n[29]:(O=r.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`})}),n[28]=r.gitStatusDot,n[29]=O);let k;n[30]===_?k=n[31]:(k=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:_})}),n[30]=_,n[31]=k);let A;n[32]!==h||n[33]!==c||n[34]!==s||n[35]!==o?(A=o||s?(0,$.jsx)(pt,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):c?(0,$.jsx)(t,{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)(H,{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:h,children:[(0,$.jsx)(S,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),n[32]=h,n[33]=c,n[34]=s,n[35]=o,n[36]=A):A=n[36];let j;n[37]!==E||n[38]!==D||n[39]!==O||n[40]!==k||n[41]!==A||n[42]!==T?(j=(0,$.jsxs)(hr,{selected:T,onClick:E,onKeyDown:D,role:`button`,tabIndex:0,children:[O,k,A]}),n[37]=E,n[38]=D,n[39]=O,n[40]=k,n[41]=A,n[42]=T,n[43]=j):j=n[43];let M;return n[44]!==j||n[45]!==w?(M=(0,$.jsxs)($.Fragment,{children:[w,j]}),n[44]=j,n[45]=w,n[46]=M):M=n[46],M}var si=e(Ze(),1),ci=.1,li=10,ui=1.25,di=.001;function fi(){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=pi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*ui)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/ui)),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*di;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 pi(e){return Math.min(Math.max(e,ci),li)}function mi(){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 hi(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 gi(e){let t=(0,Q.c)(69),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:s,zoomIn:c,zoomOut:l,reset:u,onMouseDown:d,onMouseMove:f,onMouseUp:p}=fi(),m,h;t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[3]=g):g=t[3],(0,Z.useEffect)(_i,g);let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:`mermaid diagram`}),t[4]=_):_=t[4];let v,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Qe,{className:`h-3.5 w-3.5`}),y=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=v,t[6]=y):(v=t[5],y=t[6]);let b;t[7]===l?b=t[8]:(b=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[v,y]})}),t[7]=l,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(q,{children:`Zoom out`}),t[9]=x):x=t[9];let S;t[10]===b?S=t[11]:(S=(0,$.jsxs)(J,{children:[b,x]}),t[10]=b,t[11]=S);let C;t[12]===i?C=t[13]:(C=Math.round(i*100),t[12]=i,t[13]=C);let w;t[14]!==u||t[15]!==C?(w=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:u,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:[C,`%`]})}),t[14]=u,t[15]=C,t[16]=w):w=t[16];let T;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Reset zoom`}),t[17]=T):T=t[17];let E;t[18]===w?E=t[19]:(E=(0,$.jsxs)(J,{children:[w,T]}),t[18]=w,t[19]=E);let D,O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Se,{className:`h-3.5 w-3.5`}),O=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[20]=D,t[21]=O):(D=t[20],O=t[21]);let k;t[22]===c?k=t[23]:(k=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[D,O]})}),t[22]=c,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(q,{children:`Zoom in`}),t[24]=A):A=t[24];let j;t[25]===k?j=t[26]:(j=(0,$.jsxs)(J,{children:[k,A]}),t[25]=k,t[26]=j);let M,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`}),N=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[27]=M,t[28]=N):(M=t[27],N=t[28]);let P;t[29]===u?P=t[30]:(P=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[M,N]})}),t[29]=u,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(q,{children:`Reset view`}),t[31]=F):F=t[31];let I;t[32]===P?I=t[33]:(I=(0,$.jsxs)(J,{children:[P,F]}),t[32]=P,t[33]=I);let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[34]=L):L=t[34];let R,z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Tt,{className:`h-3.5 w-3.5`}),z=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[35]=R,t[36]=z):(R=t[35],z=t[36]);let ee;t[37]===r?ee=t[38]:(ee=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[R,z]})}),t[37]=r,t[38]=ee);let te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(q,{children:`Close (Esc)`}),t[39]=te):te=t[39];let ne;t[40]===ee?ne=t[41]:(ne=(0,$.jsxs)(J,{children:[ee,te]}),t[40]=ee,t[41]=ne);let re;t[42]!==E||t[43]!==j||t[44]!==I||t[45]!==ne||t[46]!==S?(re=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[_,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S,E,j,I,L,ne]})]}),t[42]=E,t[43]=j,t[44]=I,t[45]=ne,t[46]=S,t[47]=re):re=t[47];let ie=o?`cursor-grabbing`:`cursor-grab`,ae;t[48]===ie?ae=t[49]:(ae=G(`flex-1 overflow-hidden select-none`,ie),t[48]=ie,t[49]=ae);let oe=`translate(${a.x}px, ${a.y}px) scale(${i})`,se=o?`none`:`transform 0.1s ease-out`,ce;t[50]!==oe||t[51]!==se?(ce={transform:oe,transformOrigin:`center center`,transition:se},t[50]=oe,t[51]=se,t[52]=ce):ce=t[52];let le;t[53]===n?le=t[54]:(le={__html:n},t[53]=n,t[54]=le);let B;t[55]!==ce||t[56]!==le?(B=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:ce,dangerouslySetInnerHTML:le}),t[55]=ce,t[56]=le,t[57]=B):B=t[57];let ue;t[58]!==s||t[59]!==d||t[60]!==f||t[61]!==p||t[62]!==ae||t[63]!==B?(ue=(0,$.jsx)(`div`,{ref:s,className:ae,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:B}),t[58]=s,t[59]=d,t[60]=f,t[61]=p,t[62]=ae,t[63]=B,t[64]=ue):ue=t[64];let de;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(de=(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`}),t[65]=de):de=t[65];let fe;return t[66]!==re||t[67]!==ue?(fe=(0,si.createPortal)((0,$.jsx)(cr,{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:[re,ue,de]})}),document.body),t[66]=re,t[67]=ue,t[68]=fe):fe=t[68],fe}function _i(){return document.body.style.overflow=`hidden`,vi}function vi(){document.body.style.overflow=``}function yi(e){let n=(0,Q.c)(51),{content:r,className:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{svgOutput:l,renderError:u}=hi(r,mi()),d;n[0]===r?d=n[1]:(d=async function(){await navigator.clipboard.writeText(r),o(!0),setTimeout(()=>o(!1),2e3)},n[0]=r,n[1]=d);let f=d,p=u?`mermaid (render error)`:`mermaid diagram`,m;n[2]===p?m=n[3]:(m=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:p}),n[2]=p,n[3]=m);let h;n[4]!==u||n[5]!==l?(h=l&&!u&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`action`,size:`icon-xs`,onClick:()=>c(!0),children:[(0,$.jsx)(Rt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(q,{children:`View fullscreen`})]}),n[4]=u,n[5]=l,n[6]=h):h=n[6];let g;n[7]===a?g=n[8]:(g=a?(0,$.jsx)(t,{}):(0,$.jsx)(D,{}),n[7]=a,n[8]=g);let _;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),n[9]=_):_=n[9];let v;n[10]!==f||n[11]!==g?(v=(0,$.jsxs)(H,{variant:`action`,size:`icon-xs`,onClick:f,children:[g,_]}),n[10]=f,n[11]=g,n[12]=v):v=n[12];let y;n[13]!==h||n[14]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h,v]}),n[13]=h,n[14]=v,n[15]=y):y=n[15];let b;n[16]!==m||n[17]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[m,y]}),n[16]=m,n[17]=y,n[18]=b):b=n[18];let x=b;if(u){let e;n[19]===i?e=n[20]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[19]=i,n[20]=e);let t;n[21]===r?t=n[22]:(t=(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})}),n[21]=r,n[22]=t);let a;return n[23]!==x||n[24]!==e||n[25]!==t?(a=(0,$.jsxs)(`div`,{className:e,children:[x,t]}),n[23]=x,n[24]=e,n[25]=t,n[26]=a):a=n[26],a}if(!l){let e;n[27]===i?e=n[28]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[27]=i,n[28]=e);let t;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:`Rendering diagram…`}),n[29]=t):t=n[29];let r;return n[30]!==x||n[31]!==e?(r=(0,$.jsxs)(`div`,{className:e,children:[x,t]}),n[30]=x,n[31]=e,n[32]=r):r=n[32],r}let S;n[33]===i?S=n[34]:(S=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,i),n[33]=i,n[34]=S);let C;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>c(!0),n[35]=C):C=n[35];let w;n[36]===l?w=n[37]:(w=(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:C,dangerouslySetInnerHTML:{__html:l}})}),n[36]=l,n[37]=w);let T;n[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Click to view fullscreen`}),n[38]=T):T=n[38];let E;n[39]===w?E=n[40]:(E=(0,$.jsxs)(J,{children:[w,T]}),n[39]=w,n[40]=E);let O;n[41]!==x||n[42]!==S||n[43]!==E?(O=(0,$.jsxs)(`div`,{className:S,children:[x,E]}),n[41]=x,n[42]=S,n[43]=E,n[44]=O):O=n[44];let k;n[45]!==s||n[46]!==l?(k=s&&(0,$.jsx)(gi,{svgOutput:l,onClose:()=>c(!1)}),n[45]=s,n[46]=l,n[47]=k):k=n[47];let A;return n[48]!==O||n[49]!==k?(A=(0,$.jsxs)(cr,{children:[O,k]}),n[48]=O,n[49]=k,n[50]=A):A=n[50],A}var bi=`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(`.`),xi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 Si(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
|
|
3
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(bi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of xi)t.test(e)&&r++;return r>=2}function Ci(e){if(!Si(e))return null;let t=/```mermaid\s*\n([\s\S]*?)\n```/.exec(e);if(t)return t[1].trim();let n=e.split(`
|
|
4
4
|
`).map(e=>e.trim()).filter(e=>e.length>0)[0].toLowerCase();return bi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var wi=(0,Z.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:Ti(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)(Ei,{block:e,start:i[t]},t))})});function Ti(e,t=!1){let n=e.split(`
|
|
5
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`||Si(o.join(`
|
|
@@ -14,7 +14,7 @@ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,$r as n,$t as
|
|
|
14
14
|
`);i=`text-xs font-mono whitespace-pre-wrap overflow-auto`,a=e.map(qi),o=s.map(Ki),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 Ki(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 qi(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 Ji(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 Yi(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 Xi(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 Zi(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)(Wi,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 Qi=Pn,$i=Wn,ea=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)(hn,{children:(0,$.jsx)(Dn,{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});ea.displayName=Dn.displayName;function ta(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)(Qi,{children:[(0,$.jsx)($i,{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)(ea,{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?Li(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(W,{open:c,onOpenChange:l,children:(0,$.jsxs)(fn,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:Li(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)(Gi,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 na(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)(Xi,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Xi,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Xi,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Xi,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Xi,{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 ra(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)(Wi,{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)(na,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 ia(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)($i,{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)(ea,{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)(Qi,{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)(Ji,{name:n.agentName}),t[21]=n.agentName,t[22]=d);let f;t[23]===n.subagentType?f=t[24]:(f=n.subagentType&&(0,$.jsx)(Yi,{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)(Ji,{name:n.agentName}),t[35]=n.agentName,t[36]=u);let d;t[37]===n.subagentType?d=t[38]:(d=n.subagentType&&(0,$.jsx)(Yi,{type:n.subagentType}),t[37]=n.subagentType,t[38]=d);let f;t[39]===i?f=t[40]:(f=i?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 aa(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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 oa(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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 sa(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)(Qi,{children:[(0,$.jsx)($i,{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)(ea,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 ca(e){let t=(0,Q.c)(34),{block:n,inline:r,resultContent:i}=e,{state:a}=Qn(),{setPendingExplorerPath:o,setActiveMainTab:s}=Dr(),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=Ui(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)(Zi,{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)(ta,{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)(ra,{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)(ia,{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)(aa,{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)(oa,{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)(sa,{data:u,inline:r}),t[31]=u,t[32]=r,t[33]=e):e=t[33],e}}}var la=(0,Z.createContext)({todos:[],setTodos:()=>{}});function ua(e){let t=(0,Q.c)(7),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{a(e)},t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c={todos:i,setTodos:s},t[2]=i,t[3]=c);let l;return t[4]!==n||t[5]!==c?(l=(0,$.jsx)(la.Provider,{value:c,children:n}),t[4]=n,t[5]=c,t[6]=l):l=t[6],l}function da(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function fa(e){let t=(0,Q.c)(17),{todos:n}=e,{todos:r,setTodos:i}=(0,Z.useContext)(la),a,o;t[0]!==n||t[1]!==i?(a=()=>{i(n)},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,Z.useEffect)(a,o);let s=r.length>0?r:n,c;t[4]===s?c=t[5]:(c=s.filter(ma),t[4]=s,t[5]=c);let l=c.length,u;t[6]===s.length?u=t[7]:(u=s.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[6]=s.length,t[7]=u);let d;t[8]===s?d=t[9]:(d=s.map(pa),t[8]=s,t[9]=d);let f;t[10]!==l||t[11]!==s.length?(f=s.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[l,`/`,s.length,` completed`]}),t[10]=l,t[11]=s.length,t[12]=f):f=t[12];let p;return t[13]!==u||t[14]!==d||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[u,d,f]}),t[13]=u,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function pa(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,$.jsx)(Bt,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(Fe,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(w,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function ma(e){return e.status===`done`}function ha(e){let t=(0,Q.c)(4),{todos:n}=e,{setTodos:r}=(0,Z.useContext)(la),i,a;return t[0]!==r||t[1]!==n?(i=()=>{r(n)},a=[n,r],t[0]=r,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Z.useEffect)(i,a),null}function ga(e){let t=(0,Q.c)(21),{todos:n}=e,[r,i]=(0,Z.useState)(!0);if(n.length===0)return null;let a;t[0]===n?a=t[1]:(a=n.filter(_a),t[0]=n,t[1]=a);let o=a.length,s=o===n.length,c=n.length-o,l=s?`${n.length} Tasks Completed`:`${c} Tasks To Do`,u;t[2]===r?u=t[3]:(u=()=>i(!r),t[2]=r,t[3]=u);let d;t[4]===s?d=t[5]:(d=s?(0,$.jsx)(Bt,{className:`h-4 w-4 shrink-0 text-brand`}):(0,$.jsx)(ut,{className:`h-4 w-4 shrink-0`}),t[4]=s,t[5]=d);let f;t[6]===l?f=t[7]:(f=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:l}),t[6]=l,t[7]=f);let p;t[8]===r?p=t[9]:(p=r?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[8]=r,t[9]=p);let m;t[10]!==u||t[11]!==d||t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`button`,{onClick:u,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:`Todo list`,children:[d,f,p]}),t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==r||t[16]!==n?(h=r&&(0,$.jsx)(`div`,{className:`px-3 py-3 bg-background border-t border-border`,children:(0,$.jsx)(fa,{todos:n})}),t[15]=r,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==m||t[19]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[m,h]}),t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function _a(e){return e.status===`done`}function va(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 ya(e){let n=(0,Q.c)(29),{imageUrl:r,imageData:i}=e,[a,o]=(0,Z.useState)(!1),s=i?`data:image/png;base64,${i}`:r??``,c;n[0]===s?c=n[1]:(c=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await Xt(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:s,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},n[0]=s,n[1]=c);let l=c,u;n[2]===s?u=n[3]:(u=async()=>{await _(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:s}),o(!0),setTimeout(()=>o(!1),2e3)},n[2]=s,n[3]=u);let d=u,f;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={maxHeight:`512px`},n[4]=f):f=n[4];let p;n[5]===s?p=n[6]:(p=(0,$.jsx)(`img`,{src:s,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:f}),n[5]=s,n[6]=p);let m;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(oe,{className:`h-3.5 w-3.5`}),n[7]=m):m=n[7];let h;n[8]===l?h=n[9]:(h=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:m})}),n[8]=l,n[9]=h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{children:`Save image`}),n[10]=g):g=n[10];let v;n[11]===h?v=n[12]:(v=(0,$.jsxs)(J,{children:[h,g]}),n[11]=h,n[12]=v);let y;n[13]===a?y=n[14]:(y=a?(0,$.jsx)(t,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),n[13]=a,n[14]=y);let b;n[15]!==d||n[16]!==y?(b=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:d,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:y})}),n[15]=d,n[16]=y,n[17]=b):b=n[17];let x=a?`Copied!`:`Copy to clipboard`,S;n[18]===x?S=n[19]:(S=(0,$.jsx)(q,{children:x}),n[18]=x,n[19]=S);let C;n[20]!==b||n[21]!==S?(C=(0,$.jsxs)(J,{children:[b,S]}),n[20]=b,n[21]=S,n[22]=C):C=n[22];let w;n[23]!==C||n[24]!==v?(w=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(cr,{children:[v,C]})}),n[23]=C,n[24]=v,n[25]=w):w=n[25];let T;return n[26]!==w||n[27]!==p?(T=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[p,w]}),n[26]=w,n[27]=p,n[28]=T):T=n[28],T}function ba(e){let t=(0,Q.c)(70),{block:n,inline:r}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),{state:c}=Qn(),l=c.projects,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==c.projects||t[3]!==c.selectedProjectId||t[4]!==c.selectedThreadId){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[13]===c.selectedProjectId?e=t[14]:(e=e=>e.projectId===c.selectedProjectId,t[13]=c.selectedProjectId,t[14]=e);let i=l.find(e)?.threads.find(e=>e.threadId===c.selectedThreadId)?.path;_=n.toolName??`Unknown Tool`,g=n.toolCallId??`unknown`;let a=n,o=n.result??a.content,s;t[15]!==a||t[16]!==_?(s=_===`todo`?da(a):null,t[15]=a,t[16]=_,t[17]=s):s=t[17];let v=s;if(f=Li(Hi(o),i),!(f.length>0)&&v===null){h=null;break bb0}if(u=Ii(_),typeof o==`object`&&o){let e=o,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[18]===n?e=t[19]:(e=n.trim(),t[18]=n,t[19]=e),u=e}else if(_===`read`||_===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[20]===n?e=t[21]:(e=n.split(`/`).pop()??n,t[20]=n,t[21]=e),u=`Completed ${e}`}}}else if(o==null){let e;t[22]===_?e=t[23]:(e=Ii(_),t[22]=_,t[23]=e),u=`${e} (no result)`}if(u=Li(u,i),v!==null){let e;t[24]===v?e=t[25]:(e=(0,$.jsx)(ha,{todos:v}),t[24]=v,t[25]=e),h=e;break bb0}if(_===`generate_image`){let e;t[26]===o?e=t[27]:(e=va(o),t[26]=o,t[27]=e);let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[28]!==n.imageData||t[29]!==n.imageUrl?(e=(0,$.jsx)(ya,{imageUrl:n.imageUrl,imageData:n.imageData}),t[28]=n.imageData,t[29]=n.imageUrl,t[30]=e):e=t[30],h=e;break bb0}}if(r){h=null;break bb0}let y;t[31]===_?y=t[32]:(y=_.toLowerCase().includes(`bash`),t[31]=_,t[32]=y),d=y,p=f?f.split(`
|
|
15
15
|
`):[],m=d?p.slice(0,3).join(`
|
|
16
16
|
`):f}t[0]=n,t[1]=r,t[2]=c.projects,t[3]=c.selectedProjectId,t[4]=c.selectedThreadId,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let v=m,y=d&&p.length>3;if(d){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bt,{className:`h-4 w-4 shrink-0`}),t[33]=e):e=t[33];let n;t[34]===u?n=t[35]:(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:u})]}),t[34]=u,t[35]=n);let r;t[36]!==y||t[37]!==v||t[38]!==f||t[39]!==p?(r=f&&(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${y?` cursor-pointer hover:bg-muted/80`:``}`,onClick:y?()=>s(!0):void 0,title:y?`Click to see full output`:void 0,children:[v,y&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
17
|
-
`,`...`]})]}),y&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,p.length,` lines)`]})]}),t[36]=y,t[37]=v,t[38]=f,t[39]=p,t[40]=r):r=t[40];let i;t[41]!==n||t[42]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[41]=n,t[42]=r,t[43]=i):i=t[43];let a;t[44]!==o||t[45]!==y||t[46]!==f?(a=y&&(0,$.jsx)(W,{open:o,onOpenChange:s,children:(0,$.jsxs)(fn,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{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:f})]})}),t[44]=o,t[45]=y,t[46]=f,t[47]=a):a=t[47];let c;return t[48]!==i||t[49]!==a?(c=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[48]=i,t[49]=a,t[50]=c):c=t[50],c}let b;t[51]===i?b=t[52]:(b=()=>a(!i),t[51]=i,t[52]=b);let x=`${_} result`,S;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Bt,{className:`h-4 w-4 shrink-0`}),t[53]=S):S=t[53];let C;t[54]===u?C=t[55]:(C=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:u}),t[54]=u,t[55]=C);let w;t[56]===i?w=t[57]:(w=i?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[56]=i,t[57]=w);let T;t[58]!==b||t[59]!==x||t[60]!==C||t[61]!==w?(T=(0,$.jsxs)(`button`,{onClick:b,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:x,children:[S,C,w]}),t[58]=b,t[59]=x,t[60]=C,t[61]=w,t[62]=T):T=t[62];let E;t[63]!==i||t[64]!==f||t[65]!==g?(E=i&&(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: `,g]}),f&&(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:f})]}),t[63]=i,t[64]=f,t[65]=g,t[66]=E):E=t[66];let D;return t[67]!==E||t[68]!==T?(D=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[T,E]}),t[67]=E,t[68]=T,t[69]=D):D=t[69],D}function xa(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)(nt,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 Sa({toolCall:e,className:t}){let{state:n,dispatch:r}=Qn(),[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)(pt,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children: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)(ze,{className:`h-3.5 w-3.5`}):(0,$.jsx)(U,{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)(Tt,{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)(pt,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function Ca(e){let n=(0,Q.c)(51),{toolCallId:r,question:i,options:a,context:o,answeredText:s}=e,[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!!s),[f,p]=(0,Z.useState)(s??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v;n[0]!==m||n[1]!==r?(v=async e=>{if(!(!e.trim()||m)){h(!0);try{await et(r,e.trim()),p(e.trim()),d(!0)}catch(e){console.error(`Failed to submit answer:`,e),h(!1),_(null)}}},n[0]=m,n[1]=r,n[2]=v):v=n[2];let y=v,b;n[3]!==y||n[4]!==m||n[5]!==u?(b=e=>{u||m||(_(e),y(e))},n[3]=y,n[4]=m,n[5]=u,n[6]=b):b=n[6];let x=b,S;n[7]!==c||n[8]!==y||n[9]!==m||n[10]!==u?(S=()=>{if(u||m)return;let e=c.trim();e&&y(e)},n[7]=c,n[8]=y,n[9]=m,n[10]=u,n[11]=S):S=n[11];let C=S,w;n[12]===C?w=n[13]:(w=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C())},n[12]=C,n[13]=w);let T=w;if(u){let e,r;n[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(t,{className:`h-4 w-4`}),r=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),n[14]=e,n[15]=r):(e=n[14],r=n[15]);let i;return n[16]===f?i=n[17]:(i=(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,r,(0,$.jsx)(`span`,{children:f})]})}),n[16]=f,n[17]=i),i}let E;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(te,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),n[18]=E):E=n[18];let D;n[19]===i?D=n[20]:(D=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(wi,{content:i})}),n[19]=i,n[20]=D);let O;n[21]===o?O=n[22]:(O=o&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o}),n[21]=o,n[22]=O);let k;n[23]!==D||n[24]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[E,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[D,O]})]}),n[23]=D,n[24]=O,n[25]=k):k=n[25];let A;n[26]!==x||n[27]!==m||n[28]!==a||n[29]!==g?(A=a&&a.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:a.map(e=>{let n=g===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(e),disabled:m,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`,n?`border-foreground/20 bg-accent text-accent-foreground`:`border-foreground/20 bg-background text-foreground hover:bg-accent hover:text-accent-foreground`),children:[n&&(0,$.jsx)(t,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),n[26]=x,n[27]=m,n[28]=a,n[29]=g,n[30]=A):A=n[30];let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>l(e.target.value),n[31]=j):j=n[31];let M=a?.length?`Or type a custom answer...`:`Type your answer...`,N;n[32]!==c||n[33]!==T||n[34]!==m||n[35]!==M?(N=(0,$.jsx)(`input`,{type:`text`,value:c,onChange:j,onKeyDown:T,placeholder:M,disabled:m,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),n[32]=c,n[33]=T,n[34]=m,n[35]=M,n[36]=N):N=n[36];let P;n[37]!==c||n[38]!==m?(P=m||!c.trim(),n[37]=c,n[38]=m,n[39]=P):P=n[39];let F;n[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Wt,{className:`h-3 w-3`}),n[40]=F):F=n[40];let I;n[41]!==C||n[42]!==P?(I=(0,$.jsx)(`button`,{type:`button`,onClick:C,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}),n[41]=C,n[42]=P,n[43]=I):I=n[43];let L;n[44]!==N||n[45]!==I?(L=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[N,I]}),n[44]=N,n[45]=I,n[46]=L):L=n[46];let R;return n[47]!==L||n[48]!==k||n[49]!==A?(R=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[k,A,L]}),n[47]=L,n[48]=k,n[49]=A,n[50]=R):R=n[50],R}function wa(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=Qn(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=fr(n),t[0]=n,t[1]=s);let c=s,[u,d]=(0,Z.useState)(c?.status??`running`),f;t[2]===c?f=t[3]:(f=()=>{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]=f);let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(c?.error??null),_,v;t[4]===n?(_=t[5],v=t[6]):(_=()=>ur(n,()=>{let e=fr(n);if(e)if(d(e.status),e.status===`success`){let t=e.result;m(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&g(e.error??null)}),v=[n],t[4]=n,t[5]=_,t[6]=v),(0,Z.useEffect)(_,v);let y,b;t[7]!==i||t[8]!==o||t[9]!==n?(y=()=>{o&&dr(n,i,o)},b=[n,i,o],t[7]=i,t[8]=o,t[9]=n,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,Z.useEffect)(y,b);let[x,S]=(0,Z.useState)(!1),C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>S(Ta),t[12]=C):C=t[12];let w=C;if(u===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(l,{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(u===`success`){let e;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(l,{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]===x?o=t[20]:(o=x?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[19]=x,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]!==x||t[26]!==p?(c=x&&(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}),p!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:p})]}),t[24]=i,t[25]=x,t[26]=p,t[27]=c):c=t[27];let u;return t[28]!==s||t[29]!==c?(u=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[s,c]}),t[28]=s,t[29]=c,t[30]=u):u=t[30],u}let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(l,{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]===x?O=t[35]:(O=x?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[34]=x,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]!==h||t[41]!==x?(A=x&&(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:h}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=h,t[41]=x,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 Ta(e){return!e}function Ea(e){let t=[];for(let n of e){if(n.type!==`tool-result`||n.toolName!==`todo`)continue;let e=[n.result,n.content];for(let n of e){let e=[];if(typeof n==`string`)e.push(n);else if(Array.isArray(n))for(let t of n)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&e.push(t.text);for(let n of e)try{let e=JSON.parse(n.trim());e&&Array.isArray(e.todos)&&(t=e.todos)}catch{}}}return t}function Da(e){let n=(0,Q.c)(29),{src:r}=e,[i,a]=(0,Z.useState)(!1),o;n[0]===r?o=n[1]:(o=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await Xt(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:r,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},n[0]=r,n[1]=o);let s=o,c;n[2]===r?c=n[3]:(c=async()=>{await _(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:r}),a(!0),setTimeout(()=>a(!1),2e3)},n[2]=r,n[3]=c);let l=c,u;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={maxHeight:`512px`},n[4]=u):u=n[4];let d;n[5]===r?d=n[6]:(d=(0,$.jsx)(`img`,{src:r,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:u}),n[5]=r,n[6]=d);let f;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(oe,{className:`h-3.5 w-3.5`}),n[7]=f):f=n[7];let p;n[8]===s?p=n[9]:(p=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:f})}),n[8]=s,n[9]=p);let m;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{children:`Save image`}),n[10]=m):m=n[10];let h;n[11]===p?h=n[12]:(h=(0,$.jsxs)(J,{children:[p,m]}),n[11]=p,n[12]=h);let g;n[13]===i?g=n[14]:(g=i?(0,$.jsx)(t,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),n[13]=i,n[14]=g);let v;n[15]!==l||n[16]!==g?(v=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:g})}),n[15]=l,n[16]=g,n[17]=v):v=n[17];let y=i?`Copied!`:`Copy to clipboard`,b;n[18]===y?b=n[19]:(b=(0,$.jsx)(q,{children:y}),n[18]=y,n[19]=b);let x;n[20]!==v||n[21]!==b?(x=(0,$.jsxs)(J,{children:[v,b]}),n[20]=v,n[21]=b,n[22]=x):x=n[22];let S;n[23]!==x||n[24]!==h?(S=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(cr,{children:[h,x]})}),n[23]=x,n[24]=h,n[25]=S):S=n[25];let C;return n[26]!==S||n[27]!==d?(C=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[d,S]}),n[26]=S,n[27]=d,n[28]=C):C=n[28],C}function Oa(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 ka(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(Ca,{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)(wa,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Sa,{toolCall:e}),(0,$.jsx)(ca,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(ca,{inline:!0,block:e,resultContent:r},t)}function Aa({message:e,threadId:t}){let n=e.sender===`user`,r=n?null:tr(e.content),[i,a]=(0,Z.useState)(!1),o=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function s(){if(!(!e.checkpointRef||!t||i)){a(!0);try{let n=await He(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{a(!1)}}}return(0,$.jsxs)(`div`,{className:G(`group flex gap-3 px-4 py-4`,n?`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`,n?`bg-foreground`:`bg-muted`),children:n?(0,$.jsx)(bt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-muted-foreground`})}),n&&e.checkpointRef&&(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,disabled:i,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)(Ve,{className:G(`h-3 w-3`,i&&`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`,n&&`items-end`),children:[(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2`,n&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:n?`You`:`Agent`}),o&&(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)(Fe,{className:`h-2.5 w-2.5`}),o]}),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)(l,{className:`h-2.5 w-2.5`}),Ar(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)(P,{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`,n?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=ar(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?ka(e,n,!1,Oa(t,e.id)):e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(xa,{text:er(e.text),label:e.label},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(wi,{content:er(e.content),enableMermaid:!0})})})():r?(()=>{let e=Ea(r),t=r.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[r.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,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)(xa,{text:er(e.text),label:e.label}):e.type===`text`&&`text`in e?(0,$.jsx)(wi,{content:er(e.text),enableMermaid:!0}):e.type===`tool_use`?ka(e,void 0,!1,Oa(r,e.id)):e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:e}):null},t)),e.length>0&&(0,$.jsx)(ga,{todos:e}),t.map((e,t)=>(0,$.jsx)(Ca,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:Oa(r,e.id)},`ask-${t}`))]})})():(0,$.jsx)(wi,{content:er(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Da,{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)(Yt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function ja(e){let t=(0,Q.c)(23),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a}=e,o,s,c,u,d;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n){let e=$n(n),f=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;u=`group flex gap-3 px-4 py-4`,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 self-end items-center justify-center rounded-full bg-brand animate-radial-pulse-brand`,children:(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-white`})}),t[9]=d):d=t[9],o=`flex flex-1 flex-col gap-1 min-w-0`;let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=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)(l,{className:`h-2.5 w-2.5`}),Ar(r)]}),t[11]=r,t[12]=m),t[13]===m?s=t[14]:(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[13]=m,t[14]=s),c=e.length>0?(()=>{let t=Ea(e),n=e.filter(Ma);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)(ba,{inline:!0,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)(xa,{text:er(t.text),label:t.label,isStreaming:!0,hasContentAfter:f(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(wi,{content:er(t.text),enableMermaid:!0}):t.type===`tool_use`?ka(t,void 0,!0,Oa(e,t.id)):t.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:t}):null},`b-${n}`)),t.length>0&&(0,$.jsx)(ga,{todos:t}),n.map((t,n)=>(0,$.jsx)(Ca,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:Oa(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)(xa,{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]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d}else o=t[4],s=t[5],c=t[6],u=t[7],d=t[8];let f;t[15]!==o||t[16]!==s||t[17]!==c?(f=(0,$.jsxs)(`div`,{className:o,children:[s,c]}),t[15]=o,t[16]=s,t[17]=c,t[18]=f):f=t[18];let p;return t[19]!==u||t[20]!==d||t[21]!==f?(p=(0,$.jsxs)(`div`,{className:u,children:[d,f]}),t[19]=u,t[20]=d,t[21]=f,t[22]=p):p=t[22],p}function Ma(e){return e.type===`tool_use`&&e.name===`ask_user`}var Na=(0,Z.memo)(ja,(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 Pa(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:o,onNewApp:s,onOpenFolder:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[l,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:d})]})]}),t[2]=d,t[3]=f);let m;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)(a,{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],m=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=m}else m=t[7];let h,g,_;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(p,{className:`h-5 w-5 text-muted-foreground`}),g=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),_=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=h,t[12]=g,t[13]=_):(h=t[11],g=t[12],_=t[13]);let v;t[14]===o?v=t[15]:(v=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[h,g,_]}),t[14]=o,t[15]=v);let y,b,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(rt,{className:`h-5 w-5 text-muted-foreground`}),b=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),x=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=y,t[17]=b,t[18]=x):(y=t[16],b=t[17],x=t[18]);let S;t[19]===s?S=t[20]:(S=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[y,b,x]}),t[19]=s,t[20]=S);let C,w,T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Ct,{className:`h-5 w-5 text-muted-foreground`}),w=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),T=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=C,t[22]=w,t[23]=T):(C=t[21],w=t[22],T=t[23]);let E;t[24]===c?E=t[25]:(E=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:c,children:[C,w,T]}),t[24]=c,t[25]=E);let D;t[26]!==S||t[27]!==E||t[28]!==m||t[29]!==v?(D=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[m,v,S,E]}),t[26]=S,t[27]=E,t[28]=m,t[29]=v,t[30]=D):D=t[30];let O;return t[31]!==D||t[32]!==f?(O=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,D]}),t[31]=D,t[32]=f,t[33]=O):O=t[33],O}function Fa(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=Dr(),[i,a]=(0,Z.useState)(!1),{startServer:o}=jr(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Ie(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 Ia=(0,Z.createContext)(null),La=(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});La.displayName=`MessageList`;function Ra(){let e=(0,Q.c)(12),t=(0,Z.useContext)(Ia);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,error:s,onClearError:c}=t,l;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==o||e[4]!==a?(l=(n||r||i)&&(0,$.jsx)(Na,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i}),e[0]=r,e[1]=i,e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5];let u;e[6]!==s||e[7]!==c?(u=s&&(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:s}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:c,children:`Dismiss`})]}),e[6]=s,e[7]=c,e[8]=u):u=e[8];let d;return e[9]!==l||e[10]!==u?(d=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-4`,children:[l,u]}),e[9]=l,e[10]=u,e[11]=d):d=e[11],d}var za={List:La,Footer:Ra};function Ba(e){let t=(0,Q.c)(43),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,selectedThreadId:c,selectedProjectId:l,projects:u,projectsLoading:d,onSelectThread:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g,error:_,onClearError:v}=e,y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{b.current?.scrollTo({top:b.current.scrollHeight})},t[0]=x):x=t[0];let S;t[1]!==n||t[2]!==i?(S=[n,i],t[1]=n,t[2]=i,t[3]=S):S=t[3],(0,Z.useEffect)(x,S);let C=n.length===0&&!r&&!o&&!c,w=n.length===0&&!r&&!o&&c,T;if(t[4]!==u||t[5]!==l){let e;t[7]===l?e=t[8]:(e=e=>e.projectId===l,t[7]=l,t[8]=e),T=u.find(e),t[4]=u,t[5]=l,t[6]=T}else T=t[6];let E=T;if(C){let e=`transition-opacity duration-500 ease-in-out ${d?`opacity-0`:`opacity-100`}`,n;t[9]!==m||t[10]!==p||t[11]!==h||t[12]!==g||t[13]!==f||t[14]!==u?(n=(0,$.jsx)(Pa,{projects:u,onSelectProject:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g}),t[9]=m,t[10]=p,t[11]=h,t[12]=g,t[13]=f,t[14]=u,t[15]=n):n=t[15];let r;return t[16]!==e||t[17]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[16]=e,t[17]=n,t[18]=r):r=t[18],r}if(w){let e;return t[19]===E?e=t[20]:(e=(0,$.jsx)(Fa,{project:E}),t[19]=E,t[20]=e),e}let D;t[21]!==_||t[22]!==o||t[23]!==s||t[24]!==r||t[25]!==v||t[26]!==a||t[27]!==i?(D={isStreaming:r,isCreatingProject:o,isProcessingThread:s,streamingSegments:i,streamingModel:a,error:_,onClearError:v},t[21]=_,t[22]=o,t[23]=s,t[24]=r,t[25]=v,t[26]=a,t[27]=i,t[28]=D):D=t[28];let O=D,k;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(k=G(`flex-1 overflow-hidden`),t[29]=k):k=t[29];let A,j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{e instanceof HTMLElement&&(b.current=e)},j={height:`100%`},t[30]=A,t[31]=j):(A=t[30],j=t[31]);let M;t[32]===c?M=t[33]:(M=(e,t)=>(0,$.jsx)(Aa,{message:t,threadId:c}),t[32]=c,t[33]=M);let N;t[34]!==n||t[35]!==M?(N=(0,$.jsx)(Vn,{ref:y,scrollerRef:A,style:j,data:n,itemContent:M,overscan:500,components:za}),t[34]=n,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==O||t[38]!==N?(P=(0,$.jsx)(Ia.Provider,{value:O,children:N}),t[37]=O,t[38]=N,t[39]=P):P=t[39];let F;return t[40]!==c||t[41]!==P?(F=(0,$.jsx)(`div`,{className:k,children:(0,$.jsx)(ua,{children:P},c)}),t[40]=c,t[41]=P,t[42]=F):F=t[42],F}async function Va(e){return rn(`api/projects/${d(e)}/todos`)}async function Ha(e,t){return m(`api/projects/${d(e)}/todos`,{description:t})}async function Ua(e,t,n){return y(`api/projects/${d(e)}/todos/${d(t)}`,n)}async function Wa(e,t){await Ee(`api/projects/${d(e)}/todos/${d(t)}`)}var Ga={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 Ka({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Ga[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 Ua(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)(pt,{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)(H,{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)(H,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(M,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var qa=`Please analyze this task and create a detailed implementation plan.
|
|
17
|
+
`,`...`]})]}),y&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,p.length,` lines)`]})]}),t[36]=y,t[37]=v,t[38]=f,t[39]=p,t[40]=r):r=t[40];let i;t[41]!==n||t[42]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[41]=n,t[42]=r,t[43]=i):i=t[43];let a;t[44]!==o||t[45]!==y||t[46]!==f?(a=y&&(0,$.jsx)(W,{open:o,onOpenChange:s,children:(0,$.jsxs)(fn,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{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:f})]})}),t[44]=o,t[45]=y,t[46]=f,t[47]=a):a=t[47];let c;return t[48]!==i||t[49]!==a?(c=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[48]=i,t[49]=a,t[50]=c):c=t[50],c}let b;t[51]===i?b=t[52]:(b=()=>a(!i),t[51]=i,t[52]=b);let x=`${_} result`,S;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Bt,{className:`h-4 w-4 shrink-0`}),t[53]=S):S=t[53];let C;t[54]===u?C=t[55]:(C=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:u}),t[54]=u,t[55]=C);let w;t[56]===i?w=t[57]:(w=i?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[56]=i,t[57]=w);let T;t[58]!==b||t[59]!==x||t[60]!==C||t[61]!==w?(T=(0,$.jsxs)(`button`,{onClick:b,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:x,children:[S,C,w]}),t[58]=b,t[59]=x,t[60]=C,t[61]=w,t[62]=T):T=t[62];let E;t[63]!==i||t[64]!==f||t[65]!==g?(E=i&&(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: `,g]}),f&&(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:f})]}),t[63]=i,t[64]=f,t[65]=g,t[66]=E):E=t[66];let D;return t[67]!==E||t[68]!==T?(D=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[T,E]}),t[67]=E,t[68]=T,t[69]=D):D=t[69],D}function xa(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)(nt,{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)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{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 Sa({toolCall:e,className:t}){let{state:n,dispatch:r}=Qn(),[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)(pt,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),(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)(ze,{className:`h-3.5 w-3.5`}):(0,$.jsx)(U,{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)(Tt,{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)(pt,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function Ca(e){let n=(0,Q.c)(51),{toolCallId:r,question:i,options:a,context:o,answeredText:s}=e,[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!!s),[f,p]=(0,Z.useState)(s??``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v;n[0]!==m||n[1]!==r?(v=async e=>{if(!(!e.trim()||m)){h(!0);try{await et(r,e.trim()),p(e.trim()),d(!0)}catch(e){console.error(`Failed to submit answer:`,e),h(!1),_(null)}}},n[0]=m,n[1]=r,n[2]=v):v=n[2];let y=v,b;n[3]!==y||n[4]!==m||n[5]!==u?(b=e=>{u||m||(_(e),y(e))},n[3]=y,n[4]=m,n[5]=u,n[6]=b):b=n[6];let x=b,S;n[7]!==c||n[8]!==y||n[9]!==m||n[10]!==u?(S=()=>{if(u||m)return;let e=c.trim();e&&y(e)},n[7]=c,n[8]=y,n[9]=m,n[10]=u,n[11]=S):S=n[11];let C=S,w;n[12]===C?w=n[13]:(w=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C())},n[12]=C,n[13]=w);let T=w;if(u){let e,r;n[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(t,{className:`h-4 w-4`}),r=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),n[14]=e,n[15]=r):(e=n[14],r=n[15]);let i;return n[16]===f?i=n[17]:(i=(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,r,(0,$.jsx)(`span`,{children:f})]})}),n[16]=f,n[17]=i),i}let E;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(te,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),n[18]=E):E=n[18];let D;n[19]===i?D=n[20]:(D=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(wi,{content:i})}),n[19]=i,n[20]=D);let O;n[21]===o?O=n[22]:(O=o&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o}),n[21]=o,n[22]=O);let k;n[23]!==D||n[24]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[E,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[D,O]})]}),n[23]=D,n[24]=O,n[25]=k):k=n[25];let A;n[26]!==x||n[27]!==m||n[28]!==a||n[29]!==g?(A=a&&a.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:a.map(e=>{let n=g===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>x(e),disabled:m,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`,n?`border-foreground/20 bg-accent text-accent-foreground`:`border-foreground/20 bg-background text-foreground hover:bg-accent hover:text-accent-foreground`),children:[n&&(0,$.jsx)(t,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),n[26]=x,n[27]=m,n[28]=a,n[29]=g,n[30]=A):A=n[30];let j;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>l(e.target.value),n[31]=j):j=n[31];let M=a?.length?`Or type a custom answer...`:`Type your answer...`,N;n[32]!==c||n[33]!==T||n[34]!==m||n[35]!==M?(N=(0,$.jsx)(`input`,{type:`text`,value:c,onChange:j,onKeyDown:T,placeholder:M,disabled:m,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),n[32]=c,n[33]=T,n[34]=m,n[35]=M,n[36]=N):N=n[36];let P;n[37]!==c||n[38]!==m?(P=m||!c.trim(),n[37]=c,n[38]=m,n[39]=P):P=n[39];let F;n[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Wt,{className:`h-3 w-3`}),n[40]=F):F=n[40];let I;n[41]!==C||n[42]!==P?(I=(0,$.jsx)(`button`,{type:`button`,onClick:C,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}),n[41]=C,n[42]=P,n[43]=I):I=n[43];let L;n[44]!==N||n[45]!==I?(L=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[N,I]}),n[44]=N,n[45]=I,n[46]=L):L=n[46];let R;return n[47]!==L||n[48]!==k||n[49]!==A?(R=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[k,A,L]}),n[47]=L,n[48]=k,n[49]=A,n[50]=R):R=n[50],R}function wa(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=Qn(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=fr(n),t[0]=n,t[1]=s);let c=s,[u,d]=(0,Z.useState)(c?.status??`running`),f;t[2]===c?f=t[3]:(f=()=>{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]=f);let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(c?.error??null),_,v;t[4]===n?(_=t[5],v=t[6]):(_=()=>ur(n,()=>{let e=fr(n);if(e)if(d(e.status),e.status===`success`){let t=e.result;m(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&g(e.error??null)}),v=[n],t[4]=n,t[5]=_,t[6]=v),(0,Z.useEffect)(_,v);let y,b;t[7]!==i||t[8]!==o||t[9]!==n?(y=()=>{o&&dr(n,i,o)},b=[n,i,o],t[7]=i,t[8]=o,t[9]=n,t[10]=y,t[11]=b):(y=t[10],b=t[11]),(0,Z.useEffect)(y,b);let[x,S]=(0,Z.useState)(!1),C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>S(Ta),t[12]=C):C=t[12];let w=C;if(u===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(l,{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(u===`success`){let e;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(l,{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]===x?o=t[20]:(o=x?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[19]=x,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]!==x||t[26]!==p?(c=x&&(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}),p!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:p})]}),t[24]=i,t[25]=x,t[26]=p,t[27]=c):c=t[27];let u;return t[28]!==s||t[29]!==c?(u=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[s,c]}),t[28]=s,t[29]=c,t[30]=u):u=t[30],u}let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(l,{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]===x?O=t[35]:(O=x?(0,$.jsx)(U,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0`}),t[34]=x,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]!==h||t[41]!==x?(A=x&&(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:h}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=h,t[41]=x,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 Ta(e){return!e}function Ea(e){let t=[];for(let n of e){if(n.type!==`tool-result`||n.toolName!==`todo`)continue;let e=[n.result,n.content];for(let n of e){let e=[];if(typeof n==`string`)e.push(n);else if(Array.isArray(n))for(let t of n)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&e.push(t.text);for(let n of e)try{let e=JSON.parse(n.trim());e&&Array.isArray(e.todos)&&(t=e.todos)}catch{}}}return t}function Da(e){let n=(0,Q.c)(29),{src:r}=e,[i,a]=(0,Z.useState)(!1),o;n[0]===r?o=n[1]:(o=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await Xt(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:r,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},n[0]=r,n[1]=o);let s=o,c;n[2]===r?c=n[3]:(c=async()=>{await _(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:r}),a(!0),setTimeout(()=>a(!1),2e3)},n[2]=r,n[3]=c);let l=c,u;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={maxHeight:`512px`},n[4]=u):u=n[4];let d;n[5]===r?d=n[6]:(d=(0,$.jsx)(`img`,{src:r,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:u}),n[5]=r,n[6]=d);let f;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(oe,{className:`h-3.5 w-3.5`}),n[7]=f):f=n[7];let p;n[8]===s?p=n[9]:(p=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:f})}),n[8]=s,n[9]=p);let m;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{children:`Save image`}),n[10]=m):m=n[10];let h;n[11]===p?h=n[12]:(h=(0,$.jsxs)(J,{children:[p,m]}),n[11]=p,n[12]=h);let g;n[13]===i?g=n[14]:(g=i?(0,$.jsx)(t,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),n[13]=i,n[14]=g);let v;n[15]!==l||n[16]!==g?(v=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:g})}),n[15]=l,n[16]=g,n[17]=v):v=n[17];let y=i?`Copied!`:`Copy to clipboard`,b;n[18]===y?b=n[19]:(b=(0,$.jsx)(q,{children:y}),n[18]=y,n[19]=b);let x;n[20]!==v||n[21]!==b?(x=(0,$.jsxs)(J,{children:[v,b]}),n[20]=v,n[21]=b,n[22]=x):x=n[22];let S;n[23]!==x||n[24]!==h?(S=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(cr,{children:[h,x]})}),n[23]=x,n[24]=h,n[25]=S):S=n[25];let C;return n[26]!==S||n[27]!==d?(C=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[d,S]}),n[26]=S,n[27]=d,n[28]=C):C=n[28],C}function Oa(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 ka(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(Ca,{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)(wa,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Sa,{toolCall:e}),(0,$.jsx)(ca,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(ca,{inline:!0,block:e,resultContent:r},t)}function Aa({message:e,threadId:t}){let n=e.sender===`user`,r=n?null:tr(e.content),[i,a]=(0,Z.useState)(!1),o=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function s(){if(!(!e.checkpointRef||!t||i)){a(!0);try{let n=await He(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{a(!1)}}}return(0,$.jsxs)(`div`,{className:G(`group flex gap-3 px-4 py-4`,n?`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`,n?`bg-foreground`:`bg-muted`),children:n?(0,$.jsx)(bt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-muted-foreground`})}),n&&e.checkpointRef&&(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,disabled:i,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)(Ve,{className:G(`h-3 w-3`,i&&`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`,n&&`items-end`),children:[(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2`,n&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:n?`You`:`Agent`}),o&&(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)(Fe,{className:`h-2.5 w-2.5`}),o]}),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)(l,{className:`h-2.5 w-2.5`}),Ar(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)(P,{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`,n?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=ar(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?ka(e,n,!1,Oa(t,e.id)):e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(xa,{text:er(e.text),label:e.label},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(wi,{content:er(e.content),enableMermaid:!0})})})():r?(()=>{let e=Ea(r),t=r.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[r.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,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)(xa,{text:er(e.text),label:e.label}):e.type===`text`&&`text`in e?(0,$.jsx)(wi,{content:er(e.text),enableMermaid:!0}):e.type===`tool_use`?ka(e,void 0,!1,Oa(r,e.id)):e.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:e}):null},t)),e.length>0&&(0,$.jsx)(ga,{todos:e}),t.map((e,t)=>(0,$.jsx)(Ca,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:Oa(r,e.id)},`ask-${t}`))]})})():(0,$.jsx)(wi,{content:er(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Da,{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)(Yt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function ja(e){let t=(0,Q.c)(23),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a}=e,o,s,c,u,d;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n){let e=$n(n),f=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;u=`group flex gap-3 px-4 py-4`,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 self-end items-center justify-center rounded-full bg-brand animate-radial-pulse-brand`,children:(0,$.jsx)(Jt,{className:`h-3.5 w-3.5 text-white`})}),t[9]=d):d=t[9],o=`flex flex-1 flex-col gap-1 min-w-0`;let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=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)(l,{className:`h-2.5 w-2.5`}),Ar(r)]}),t[11]=r,t[12]=m),t[13]===m?s=t[14]:(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[13]=m,t[14]=s),c=e.length>0?(()=>{let t=Ea(e),n=e.filter(Ma);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)(ba,{inline:!0,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)(xa,{text:er(t.text),label:t.label,isStreaming:!0,hasContentAfter:f(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(wi,{content:er(t.text),enableMermaid:!0}):t.type===`tool_use`?ka(t,void 0,!0,Oa(e,t.id)):t.type===`tool-result`?(0,$.jsx)(ba,{inline:!0,block:t}):null},`b-${n}`)),t.length>0&&(0,$.jsx)(ga,{todos:t}),n.map((t,n)=>(0,$.jsx)(Ca,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:Oa(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)(xa,{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]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d}else o=t[4],s=t[5],c=t[6],u=t[7],d=t[8];let f;t[15]!==o||t[16]!==s||t[17]!==c?(f=(0,$.jsxs)(`div`,{className:o,children:[s,c]}),t[15]=o,t[16]=s,t[17]=c,t[18]=f):f=t[18];let p;return t[19]!==u||t[20]!==d||t[21]!==f?(p=(0,$.jsxs)(`div`,{className:u,children:[d,f]}),t[19]=u,t[20]=d,t[21]=f,t[22]=p):p=t[22],p}function Ma(e){return e.type===`tool_use`&&e.name===`ask_user`}var Na=(0,Z.memo)(ja,(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 Pa(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:o,onNewApp:s,onOpenFolder:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[l,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:d})]})]}),t[2]=d,t[3]=f);let m;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)(a,{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],m=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=m}else m=t[7];let h,g,_;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(p,{className:`h-5 w-5 text-muted-foreground`}),g=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),_=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=h,t[12]=g,t[13]=_):(h=t[11],g=t[12],_=t[13]);let v;t[14]===o?v=t[15]:(v=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[h,g,_]}),t[14]=o,t[15]=v);let y,b,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(rt,{className:`h-5 w-5 text-muted-foreground`}),b=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),x=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=y,t[17]=b,t[18]=x):(y=t[16],b=t[17],x=t[18]);let S;t[19]===s?S=t[20]:(S=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[y,b,x]}),t[19]=s,t[20]=S);let C,w,T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Ct,{className:`h-5 w-5 text-muted-foreground`}),w=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),T=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=C,t[22]=w,t[23]=T):(C=t[21],w=t[22],T=t[23]);let E;t[24]===c?E=t[25]:(E=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:c,children:[C,w,T]}),t[24]=c,t[25]=E);let D;t[26]!==S||t[27]!==E||t[28]!==m||t[29]!==v?(D=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[m,v,S,E]}),t[26]=S,t[27]=E,t[28]=m,t[29]=v,t[30]=D):D=t[30];let O;return t[31]!==D||t[32]!==f?(O=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,D]}),t[31]=D,t[32]=f,t[33]=O):O=t[33],O}function Fa(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=Dr(),[i,a]=(0,Z.useState)(!1),{startServer:o}=jr(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Ie(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 Ia=(0,Z.createContext)(null),La=(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});La.displayName=`MessageList`;function Ra(){let e=(0,Q.c)(12),t=(0,Z.useContext)(Ia);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,error:s,onClearError:c}=t,l;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==o||e[4]!==a?(l=(n||r||i)&&(0,$.jsx)(Na,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i}),e[0]=r,e[1]=i,e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5];let u;e[6]!==s||e[7]!==c?(u=s&&(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:s}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:c,children:`Dismiss`})]}),e[6]=s,e[7]=c,e[8]=u):u=e[8];let d;return e[9]!==l||e[10]!==u?(d=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-4`,children:[l,u]}),e[9]=l,e[10]=u,e[11]=d):d=e[11],d}var za={List:La,Footer:Ra};function Ba(e){let t=(0,Q.c)(45),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,selectedThreadId:c,selectedProjectId:l,projects:u,projectsLoading:d,onSelectThread:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g,error:_,onClearError:v}=e,y=(0,Z.useRef)(null),b=(0,Z.useRef)(0),x=(0,Z.useRef)(!1),S;t[0]!==r||t[1]!==n.length?(S=()=>{let e=n.length>b.current,t=x.current&&!r;(r||e||t)&&requestAnimationFrame(()=>{y.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),b.current=n.length,x.current=r},t[0]=r,t[1]=n.length,t[2]=S):S=t[2];let C;t[3]!==r||t[4]!==n||t[5]!==i.length?(C=[r,n,i.length],t[3]=r,t[4]=n,t[5]=i.length,t[6]=C):C=t[6],(0,Z.useEffect)(S,C);let w=n.length===0&&!r&&!o&&!c,T=n.length===0&&!r&&!o&&c,E;if(t[7]!==u||t[8]!==l){let e;t[10]===l?e=t[11]:(e=e=>e.projectId===l,t[10]=l,t[11]=e),E=u.find(e),t[7]=u,t[8]=l,t[9]=E}else E=t[9];let D=E;if(w){let e=`transition-opacity duration-500 ease-in-out ${d?`opacity-0`:`opacity-100`}`,n;t[12]!==m||t[13]!==p||t[14]!==h||t[15]!==g||t[16]!==f||t[17]!==u?(n=(0,$.jsx)(Pa,{projects:u,onSelectProject:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g}),t[12]=m,t[13]=p,t[14]=h,t[15]=g,t[16]=f,t[17]=u,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(T){let e;return t[22]===D?e=t[23]:(e=(0,$.jsx)(Fa,{project:D}),t[22]=D,t[23]=e),e}let O;t[24]!==_||t[25]!==o||t[26]!==s||t[27]!==r||t[28]!==v||t[29]!==a||t[30]!==i?(O={isStreaming:r,isCreatingProject:o,isProcessingThread:s,streamingSegments:i,streamingModel:a,error:_,onClearError:v},t[24]=_,t[25]=o,t[26]=s,t[27]=r,t[28]=v,t[29]=a,t[30]=i,t[31]=O):O=t[31];let k=O,A;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(A=G(`flex-1 overflow-hidden`),t[32]=A):A=t[32];let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j={height:`100%`},t[33]=j):j=t[33];let M;t[34]===c?M=t[35]:(M=(e,t)=>(0,$.jsx)(Aa,{message:t,threadId:c}),t[34]=c,t[35]=M);let N;t[36]!==n||t[37]!==M?(N=(0,$.jsx)(Vn,{ref:y,style:j,data:n,itemContent:M,overscan:500,components:za}),t[36]=n,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==k||t[40]!==N?(P=(0,$.jsx)(Ia.Provider,{value:k,children:N}),t[39]=k,t[40]=N,t[41]=P):P=t[41];let F;return t[42]!==c||t[43]!==P?(F=(0,$.jsx)(`div`,{className:A,children:(0,$.jsx)(ua,{children:P},c)}),t[42]=c,t[43]=P,t[44]=F):F=t[44],F}async function Va(e){return rn(`api/projects/${d(e)}/todos`)}async function Ha(e,t){return m(`api/projects/${d(e)}/todos`,{description:t})}async function Ua(e,t,n){return y(`api/projects/${d(e)}/todos/${d(t)}`,n)}async function Wa(e,t){await Ee(`api/projects/${d(e)}/todos/${d(t)}`)}var Ga={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 Ka({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Ga[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 Ua(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)(pt,{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)(H,{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)(H,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(M,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var qa=`Please analyze this task and create a detailed implementation plan.
|
|
18
18
|
|
|
19
19
|
Task description:
|
|
20
20
|
{description}`,Ja="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ya=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Xa=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
|
|
@@ -30,7 +30,7 @@ Offer praise for portions of the code that are well-written and follow best prac
|
|
|
30
30
|
Task description:
|
|
31
31
|
{description}`,Za={plan:qa,test:Ya,review:Xa},Qa={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function $a(e,t){let n=e?.[Qa[t]];return n&&n.trim()?n:Za[t]}function eo(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Ja.replace(/\{todoId\}/g,n)),i}var to=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],no={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 ro(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
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 io(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function ao(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 oo({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:i,dispatch:a}=Qn(),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),D=(0,Z.useCallback)(async()=>{try{let t=await Va(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await b(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ua(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),s(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{l(!1)}},[e]);(0,Z.useEffect)(()=>{D()},[D]),(0,Z.useEffect)(()=>{if(!o.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Va(e);s(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[o,e]),(0,Z.useEffect)(()=>{t&&p(``)},[t]);function k(e){p(e.description),d({todo:e})}function A(){d(null),p(``)}async function j(){if(f.trim()){h(!0);try{let t=await Ha(e,f);s(e=>[...e,t]),n(!1),p(``)}finally{h(!1)}}}async function M(){if(!(!f.trim()||!u)){h(!0);try{let t=await Ua(e,u.todo.id,{description:f});s(e=>e.map(e=>e.id===t.id?t:e)),A()}finally{h(!1)}}}async function N(){if(u){h(!0);try{await Wa(e,u.todo.id),s(e=>e.filter(e=>e.id!==u.todo.id)),A()}finally{h(!1)}}}function P(e){s(t=>t.map(t=>t.id===e.id?e:t))}async function F(t){let n=i.selectedThreadId?i.projectModelSelections[i.selectedThreadId]:void 0,r=i.projects.find(t=>t.projectId===e),o=r?.threads.find(e=>e.threadId===i.selectedThreadId),s=n?.id??o?.model,c=n?.provider??o?.modelProvider;if(!s||!c)throw console.error(`No model or provider found for project`,e,o),Error(`No model configuration found. Please configure a model and provider for this project first.`);let l=await le(e);if(!l)return;let u=null,d=await ro(l,n=>{Ua(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,P(e)})});if(!d)return;u||P(await Ua(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};a({type:K.SetProjectModel,threadId:d,model:f}),Ye(d,{model:s,modelProvider:c});let p=await Ft(d,eo($a(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&io(p)}async function I(t){let n=await le(e);if(!n)return;let r=null,i=await ro(n,n=>{Ua(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!i)return;r||P(await Ua(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await b(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await rn(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,c=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!c)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:K.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),Ye(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await Ft(i,t.description,s,[],void 0,c);l&&io(l)}async function L(t){try{let n=await le(e);if(!n){_(!1),y(null);return}let r=null;if(r=await ro(n,e=>{r=e}),!r){_(!1),y(null);return}let a=await b(r),o=a.model,s=a.modelProvider;if(!o||!s)try{let t=(await rn(`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){dn(e,r),_(!1),y(null);return}let c=eo($a(i.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await Ft(r,c,o,[],void 0,s);l&&S(await ao(l)),dn(e,r)}catch(e){console.error(`Failed to generate test case:`,e),_(!1),y(null)}finally{w(!1)}}function R(e){y(e),S(``),w(!0),_(!0),L(e)}function z(){_(!1),y(null),S(``)}async function ee(){if(!v||!x.trim())return;let t=v,n=x;z(),E(!0);try{let r=await le(e);if(!r)return;let i=null,o=await ro(r,n=>{Ua(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,P(e)})});if(!o)return;i||P(await Ua(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await b(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await rn(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),Ye(o,{model:c,modelProvider:l});let u=await Ft(o,n,c,[],void 0,l);u&&io(u)}finally{E(!1)}}async function te(t){let n=await le(e);if(!n)return;let r=null,o=await ro(n,n=>{Ua(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!o)return;r||P(await Ua(e,t.id,{status:`Review`,working:!0,threadId:o}));let s=await b(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await rn(`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.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),Ye(o,{model:c,modelProvider:l});let u=await Ft(o,eo($a(i.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&io(u)}async function ne(t,n){n===`Plan`?await F(t):n===`Build`?await I(t):n===`Test`?R(t):n===`Review`?await te(t):P(await Ua(e,t.id,{status:n,working:n!==`Done`}))}return c?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(pt,{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:to.map(t=>{let i=o.filter(e=>e.status===t),a=t===`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`,no[t]),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:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:i.length})]}),(0,$.jsx)(wt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(Se,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Ka,{todo:t,projectId:e,onUpdate:P,onEdit:k,onAction:ne,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(W,{open:t,onOpenChange:n,children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(sr,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&j()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{onClick:()=>void j(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(W,{open:g,onOpenChange:e=>!e&&z(),children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:C?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(pt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sr,{value:x,onChange:e=>S(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)(Ne,{children:[(0,$.jsx)(H,{variant:`outline`,onClick:z,disabled:C,children:`Cancel`}),(0,$.jsx)(H,{onClick:()=>void ee(),disabled:C||!x.trim()||T,children:T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(W,{open:u!==null,onOpenChange:e=>!e&&A(),children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(sr,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}})}),(0,$.jsxs)(Ne,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(H,{variant:`destructive`,onClick:()=>void N(),disabled:m,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(H,{onClick:()=>void M(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var so=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:qa},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Xa},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ya}];function co({open:e,onOpenChange:t,projectId:n}){let{state:r}=Qn(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,s]=(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 c(){s(!0);try{await mt(n,{planPrompt:i.plan.trim()===qa?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ya?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Xa?null:i.review.trim()||null}),Me(),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{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(W,{open:e,onOpenChange:t,children:(0,$.jsxs)(fn,{className:`max-w-2xl`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`AI Prompt Settings`}),(0,$.jsx)(u,{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)(Ir,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Fr,{className:`w-full`,children:so.map(e=>(0,$.jsx)(Nr,{value:e.value,className:`flex-1`,children:e.label},e.value))}),so.map(e=>(0,$.jsxs)(Pr,{value:e.value,children:[(0,$.jsx)(sr,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(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)(Ne,{children:(0,$.jsx)(H,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function lo({projectId:e}){let{state:t,dispatch:n}=Qn(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=In(),{setActiveMainTab:l}=Dr();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-DmDjliuA.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 tn();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 tn();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)(oo,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(T,{className:`h-4 w-4`})}),(0,$.jsx)(co,{open:o,onOpenChange:s,projectId:e})]})}var uo=(0,Z.lazy)(()=>Kn(()=>import(`./diff-view-VbYca6ii.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,8,19]))),fo=(0,Z.lazy)(()=>Kn(()=>import(`./dialogs-config-DmDjliuA.js`).then(e=>e.t),__vite__mapDeps([2,1])));function po(e){let t=(0,Q.c)(48),{onCreateThread:n}=e,{state:r,dispatch:a}=Qn(),o=In(),s=Ln(),[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}=r,x;t[0]!==h||t[1]!==f?(x=f&&h.includes(f),t[0]=h,t[1]=f,t[2]=x):x=t[2];let S=!!x,C;t[3]!==a||t[4]!==r.sidebarOpen?(C=()=>{r.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=r.sidebarOpen,t[5]=C):C=t[5];let w=C,T;t[6]===w?T=t[7]:(T=()=>{w(),d(`clone`),l(!0)},t[6]=w,t[7]=T);let E=T,D;t[8]===w?D=t[9]:(D=()=>{w(),d(`webapp`),l(!0)},t[8]=w,t[9]=D);let O=D,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=async(e,t)=>{try{await St(e,t),l(!1),d(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=k):k=t[10];let A=k,j;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=async(e,t,n)=>{try{await i(e,t,n),l(!1),d(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=j):j=t[11];let M=j,N;t[12]===w?N=t[13]:(N=async()=>{w();try{await ie(),l(!1),d(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=w,t[13]=N);let P=N,F=s.pathname===`/review`,I=s.pathname===`/todos`,L;t[14]===o?L=t[15]:(L=()=>{o(`/`)},t[14]=o,t[15]=L);let R=L,{selectedProjectId:z}=r,ee;t[16]!==w||t[17]!==a||t[18]!==E||t[19]!==R||t[20]!==O||t[21]!==P||t[22]!==m||t[23]!==S||t[24]!==v||t[25]!==p||t[26]!==n||t[27]!==g||t[28]!==_||t[29]!==F||t[30]!==z||t[31]!==f||t[32]!==b||t[33]!==y||t[34]!==I?(ee=I&&z?(0,$.jsx)(lo,{projectId:z}):F&&f?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(uo,{threadId:f,onExit:R})}):(0,$.jsx)(Ba,{messages:p,isStreaming:v,streamingSegments:y,streamingModel:b,isCreatingProject:m,isProcessingThread:S,selectedThreadId:f,selectedProjectId:z,projects:g,projectsLoading:_,onSelectThread:(e,t)=>{w(),a({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:E,onNewApp:O,onOpenFolder:P,error:null,onClearError:mo}),t[16]=w,t[17]=a,t[18]=E,t[19]=R,t[20]=O,t[21]=P,t[22]=m,t[23]=S,t[24]=v,t[25]=p,t[26]=n,t[27]=g,t[28]=_,t[29]=F,t[30]=z,t[31]=f,t[32]=b,t[33]=y,t[34]=I,t[35]=ee):ee=t[35];let te;t[36]!==F||t[37]!==f||t[38]!==I?(te=!F&&!I&&f&&(0,$.jsx)(pr,{}),t[36]=F,t[37]=f,t[38]=I,t[39]=te):te=t[39];let ne=u??void 0,re;t[40]!==c||t[41]!==P||t[42]!==ne?(re=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(fo,{open:c,onOpenChange:l,initialMode:ne,onSubmitClone:A,onSubmitWebApp:M,onOpenFolder:P})}),t[40]=c,t[41]=P,t[42]=ne,t[43]=re):re=t[43];let ae;return t[44]!==te||t[45]!==re||t[46]!==ee?(ae=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[ee,te,re]}),t[44]=te,t[45]=re,t[46]=ee,t[47]=ae):ae=t[47],ae}function mo(){}var ho=yn,go=Un,_o=Mn,vo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=G(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Re,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,$.jsxs)(xn,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});vo.displayName=xn.displayName;var yo=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(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(vn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});yo.displayName=vn.displayName;var bo=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,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=G(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(Zn,{children:(0,$.jsx)(En,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});bo.displayName=En.displayName;var xo=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,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=G(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(bn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});xo.displayName=bn.displayName;var So=Z.forwardRef((e,n)=>{let r=(0,Q.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:o,children:a,checked:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c;r[5]===o?c=r[6]:(c=G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[5]=o,r[6]=c);let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Sn,{children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),r[7]=l):l=r[7];let u;return r[8]!==i||r[9]!==a||r[10]!==s||r[11]!==n||r[12]!==c?(u=(0,$.jsxs)(wn,{ref:n,className:c,checked:i,...s,children:[l,a]}),r[8]=i,r[9]=a,r[10]=s,r[11]=n,r[12]=c,r[13]=u):u=r[13],u});So.displayName=wn.displayName;var Co=Z.forwardRef((e,t)=>{let n=(0,Q.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Sn,{children:(0,$.jsx)(w,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(jn,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});Co.displayName=jn.displayName;var wo=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,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=G(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(On,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});wo.displayName=On.displayName;var To=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(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});To.displayName=An.displayName;var Eo=e=>{let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};Eo.displayName=`DropdownMenuShortcut`;var Do=`VS Code`,Oo={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function ko({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(n??Do),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await at();o(e),!s&&e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([Do])}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 We(e,n),t?await ee(t,n):await Ut(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)(H,{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)(H,{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/${Oo[s]||Oo[Do]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(ho,{children:[(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(U,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(bo,{align:`end`,children:a.map(e=>(0,$.jsxs)(xo,{onClick:()=>d(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Oo[e]||Oo[Do]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Ao(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 jo(e,t){return t?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(v,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(M,{className:`h-3.5 w-3.5`}):(0,$.jsx)(De,{className:`h-3.5 w-3.5`})}function Mo(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 No(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 Po(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)(102),{branchStatus:n,currentBranch:r,remoteUrl:i,hasRemoteBranch:a,hasUnpushedCommits:o,canCreateRepo:s,repoUrl:c,isRefreshing:l,isBrandState:u,gitUser:d,availableBranches:f,isLoadingBranches:m,onBranchSubMenuOpen:h,onCheckoutBranch:g,isDirectCommitMode:_,isLoading:v,isLoadingHistory:y,onFetch:b,onPull:x,onPush:S,onOpenHistory:C,onNewBranch:w,onCreatePR:T,onCreateRepo:E,onViewInGitHub:D}=e,O=`h-8 w-8 rounded-l-none px-1 border-transparent${u?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,k;t[0]===l?k=t[1]:(k=l?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),t[0]=l,t[1]=k);let A;t[2]!==v||t[3]!==O||t[4]!==k?(A=(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`outline`,size:`sm`,className:O,disabled:v,children:k})}),t[2]=v,t[3]=O,t[4]=k,t[5]=A):A=t[5];let j;t[6]===h?j=t[7]:(j=async e=>{e&&await h()},t[6]=h,t[7]=j);let N;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(p,{className:`h-3 w-3 shrink-0`}),t[8]=N):N=t[8];let P=r||`Unknown`,F;t[9]===P?F=t[10]:(F=(0,$.jsxs)(vo,{className:`gap-2 text-xs`,children:[N,(0,$.jsx)(`span`,{className:`font-medium`,children:P})]}),t[9]=P,t[10]=F);let I;t[11]!==f||t[12]!==r||t[13]!==v||t[14]!==m||t[15]!==g?(I=m?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin`}),`Loading branches…`]}):f.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):f.map(e=>(0,$.jsxs)(xo,{disabled:e===r||v,onClick:()=>void g(e),children:[(0,$.jsx)(p,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===r?`font-semibold text-foreground`:``,children:e}),e===r&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[11]=f,t[12]=r,t[13]=v,t[14]=m,t[15]=g,t[16]=I):I=t[16];let L;t[17]===I?L=t[18]:(L=(0,$.jsx)(yo,{children:I}),t[17]=I,t[18]=L);let R;t[19]!==j||t[20]!==F||t[21]!==L?(R=(0,$.jsxs)(_o,{onOpenChange:j,children:[F,L]}),t[19]=j,t[20]=F,t[21]=L,t[22]=R):R=t[22];let z;t[23]!==n||t[24]!==i?(z=n===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,i?`origin`:`remote`]}),t[23]=n,t[24]=i,t[25]=z):z=t[25];let ee;t[26]===d?ee=t[27]:(ee=d&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,d]}),t[26]=d,t[27]=ee);let te;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(To,{}),t[28]=te):te=t[28];let ne;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(oe,{className:`h-3.5 w-3.5 mr-2`}),t[29]=ne):ne=t[29];let re;t[30]!==v||t[31]!==b?(re=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:b,disabled:v,children:[ne,`Fetch`]})}),t[30]=v,t[31]=b,t[32]=re):re=t[32];let ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),t[33]=ie):ie=t[33];let ae;t[34]===re?ae=t[35]:(ae=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[re,ie]})}),t[34]=re,t[35]=ae);let se;t[36]!==a||t[37]!==v||t[38]!==x?(se=()=>{a&&!v&&x()},t[36]=a,t[37]=v,t[38]=x,t[39]=se):se=t[39];let ce=!a||v?`opacity-50 cursor-not-allowed`:``,le;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Ke,{className:`h-3.5 w-3.5 mr-2`}),t[40]=le):le=t[40];let B;t[41]!==se||t[42]!==ce?(B=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:se,className:ce,children:[le,`Pull`]})}),t[41]=se,t[42]=ce,t[43]=B):B=t[43];let de=a?`Pull latest changes from remote`:`No remote branch to pull from`,fe;t[44]===de?fe=t[45]:(fe=(0,$.jsx)(q,{side:`right`,children:de}),t[44]=de,t[45]=fe);let V;t[46]!==B||t[47]!==fe?(V=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[B,fe]})}),t[46]=B,t[47]=fe,t[48]=V):V=t[48];let pe;t[49]!==a||t[50]!==v||t[51]!==S?(pe=!a&&(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:S,disabled:v,children:[(0,$.jsx)(ue,{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[49]=a,t[50]=v,t[51]=S,t[52]=pe):pe=t[52];let me;t[53]!==o||t[54]!==v||t[55]!==S?(me=()=>{o&&!v&&S()},t[53]=o,t[54]=v,t[55]=S,t[56]=me):me=t[56];let he=!o||v?`opacity-50 cursor-not-allowed`:``,ge;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(ue,{className:`h-3.5 w-3.5 mr-2`}),t[57]=ge):ge=t[57];let _e;t[58]!==me||t[59]!==he?(_e=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:me,className:he,children:[ge,`Push Commits`]})}),t[58]=me,t[59]=he,t[60]=_e):_e=t[60];let ve=o?v?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,ye;t[61]===ve?ye=t[62]:(ye=(0,$.jsx)(q,{side:`right`,children:ve}),t[61]=ve,t[62]=ye);let be;t[63]!==_e||t[64]!==ye?(be=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[_e,ye]})}),t[63]=_e,t[64]=ye,t[65]=be):be=t[65];let xe=v||y,Se;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(sn,{className:`h-3.5 w-3.5 mr-2`}),t[66]=Se):Se=t[66];let Ce;t[67]!==C||t[68]!==xe?(Ce=(0,$.jsxs)(xo,{onClick:C,disabled:xe,children:[Se,`History`]}),t[67]=C,t[68]=xe,t[69]=Ce):Ce=t[69];let W;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(p,{className:`h-3.5 w-3.5 mr-2`}),t[70]=W):W=t[70];let we;t[71]!==v||t[72]!==w?(we=(0,$.jsxs)(xo,{onClick:w,disabled:v,children:[W,`New Branch`]}),t[71]=v,t[72]=w,t[73]=we):we=t[73];let Te;t[74]!==_||t[75]!==v||t[76]!==T?(Te=!_&&(0,$.jsxs)(xo,{onClick:T,disabled:v,children:[(0,$.jsx)(De,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[74]=_,t[75]=v,t[76]=T,t[77]=Te):Te=t[77];let Ee;t[78]!==s||t[79]!==v||t[80]!==E?(Ee=s&&(0,$.jsxs)(xo,{onClick:E,disabled:v,children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[78]=s,t[79]=v,t[80]=E,t[81]=Ee):Ee=t[81];let Oe;t[82]!==v||t[83]!==D||t[84]!==c?(Oe=c&&(0,$.jsxs)(xo,{onClick:D,disabled:v,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[82]=v,t[83]=D,t[84]=c,t[85]=Oe):Oe=t[85];let ke;t[86]!==R||t[87]!==z||t[88]!==ee||t[89]!==ae||t[90]!==V||t[91]!==pe||t[92]!==be||t[93]!==Ce||t[94]!==we||t[95]!==Te||t[96]!==Ee||t[97]!==Oe?(ke=(0,$.jsxs)(bo,{align:`end`,children:[R,z,ee,te,ae,V,pe,be,Ce,we,Te,Ee,Oe]}),t[86]=R,t[87]=z,t[88]=ee,t[89]=ae,t[90]=V,t[91]=pe,t[92]=be,t[93]=Ce,t[94]=we,t[95]=Te,t[96]=Ee,t[97]=Oe,t[98]=ke):ke=t[98];let Ae;return t[99]!==A||t[100]!==ke?(Ae=(0,$.jsxs)(ho,{children:[A,ke]}),t[99]=A,t[100]=ke,t[101]=Ae):Ae=t[101],Ae}function Io(){return{autoGenerateCommitMessage:ot(),autoGeneratePRInfo:Lt(),privateRepositoryDefault:ft()}}function Lo(e){e.autoGenerateCommitMessage!==void 0&<(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&Ue(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&$t(e.privateRepositoryDefault)}function Ro(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function zo(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:s,isGeneratingMessage:c,isLoading:l,onGenerateMessage:d,onCommit:f,currentBranch:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ae,{children:`Commit Changes`}),t[0]=m):m=t[0];let h;t[1]===p?h=t[2]:(h=(0,$.jsxs)(O,{children:[m,(0,$.jsxs)(u,{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)(B,{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)(sr,{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=c||l,b;t[9]===c?b=t[10]:(b=c?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[9]=c,t[10]=b);let x;t[11]!==d||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{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=c?`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 w;t[17]!==C||t[18]!==x?(w=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[x,C]})}),t[17]=C,t[18]=x,t[19]=w):w=t[19];let T;t[20]!==w||t[21]!==v?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,w]})]}),t[20]=w,t[21]=v,t[22]=T):T=t[22];let E;t[23]===s?E=t[24]:(E=e=>s(e===!0),t[23]=s,t[24]=E);let D;t[25]!==o||t[26]!==E?(D=(0,$.jsx)(kr,{id:`auto-generate`,checked:o,onCheckedChange:E}),t[25]=o,t[26]=E,t[27]=D):D=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(B,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=k):k=t[28];let A;t[29]===D?A=t[30]:(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,k]}),t[29]=D,t[30]=A);let j;t[31]!==T||t[32]!==A?(j=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[T,A]}),t[31]=T,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]!==l||t[37]!==M?(N=(0,$.jsx)(H,{variant:`outline`,onClick:M,disabled:l,children:`Cancel`}),t[36]=l,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==i||t[40]!==l?(P=l||!i.trim(),t[39]=i,t[40]=l,t[41]=P):P=t[41];let F=l?`Committing...`:`Commit`,I;t[42]!==f||t[43]!==P||t[44]!==F?(I=(0,$.jsx)(H,{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)(Ne,{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)(fn,{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)(W,{open:n,onOpenChange:r,children:R}),t[53]=r,t[54]=n,t[55]=R,t[56]=z):z=t[56],z}function Bo(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:s,isGeneratingPRInfo:c,isLoading:l,onGeneratePRInfo:d,onCreatePR:f,currentBranch:p,autoGeneratePRInfo:m,onAutoGeneratePRInfoChange:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ae,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===p?_=t[2]:(_=(0,$.jsxs)(O,{children:[g,(0,$.jsxs)(u,{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)(B,{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)(V,{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)(B,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=S):S=t[10];let C;t[11]===s?C=t[12]:(C=e=>s(e.target.value),t[11]=s,t[12]=C);let w;t[13]!==o||t[14]!==C?(w=(0,$.jsx)(sr,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:C,rows:4,className:`pr-10`}),t[13]=o,t[14]=C,t[15]=w):w=t[15];let T=c||l,E;t[16]===c?E=t[17]:(E=c?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[16]=c,t[17]=E);let D;t[18]!==d||t[19]!==T||t[20]!==E?(D=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:T,children:E})}),t[18]=d,t[19]=T,t[20]=E,t[21]=D):D=t[21];let k=c?`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]!==D||t[25]!==A?(j=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[D,A]})}),t[24]=D,t[25]=A,t[26]=j):j=t[26];let M;t[27]!==j||t[28]!==w?(M=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsxs)(`div`,{className:`relative`,children:[w,j]})]}),t[27]=j,t[28]=w,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)(kr,{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)(B,{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]!==l||t[45]!==R?(z=(0,$.jsx)(H,{variant:`outline`,onClick:R,disabled:l,children:`Cancel`}),t[44]=l,t[45]=R,t[46]=z):z=t[46];let ee=l?`Creating...`:`Create PR`,te;t[47]!==l||t[48]!==f||t[49]!==ee?(te=(0,$.jsx)(H,{onClick:f,disabled:l,children:ee}),t[47]=l,t[48]=f,t[49]=ee,t[50]=te):te=t[50];let ne;t[51]!==z||t[52]!==te?(ne=(0,$.jsxs)(Ne,{children:[z,te]}),t[51]=z,t[52]=te,t[53]=ne):ne=t[53];let re;t[54]!==_||t[55]!==L||t[56]!==ne?(re=(0,$.jsxs)(fn,{children:[_,L,ne]}),t[54]=_,t[55]=L,t[56]=ne,t[57]=re):re=t[57];let ie;return t[58]!==r||t[59]!==n||t[60]!==re?(ie=(0,$.jsx)(W,{open:n,onOpenChange:r,children:re}),t[58]=r,t[59]=n,t[60]=re,t[61]=ie):ie=t[61],ie}function Vo(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:s,isPrivateRepo:c,onPrivateRepoChange:l,isLoading:d,onCreateRepo:f}=e,p;t[0]!==r||t[1]!==s||t[2]!==a?(p=e=>{e||(a(``),s(``)),r(e)},t[0]=r,t[1]=s,t[2]=a,t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Create GitHub Repository`}),(0,$.jsx)(u,{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)(B,{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)(V,{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)(B,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===s?y=t[13]:(y=e=>s(e.target.value),t[12]=s,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(sr,{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]===l?x=t[18]:(x=e=>l(e===!0),t[17]=l,t[18]=x);let S;t[19]!==c||t[20]!==x?(S=(0,$.jsx)(kr,{id:`repo-private`,checked:c,onCheckedChange:x}),t[19]=c,t[20]=x,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(B,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=C):C=t[22];let w;t[23]===S?w=t[24]:(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[23]=S,t[24]=w);let T;t[25]!==w||t[26]!==_||t[27]!==b?(T=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,w]}),t[25]=w,t[26]=_,t[27]=b,t[28]=T):T=t[28];let E;t[29]===r?E=t[30]:(E=()=>r(!1),t[29]=r,t[30]=E);let D;t[31]!==d||t[32]!==E?(D=(0,$.jsx)(H,{variant:`outline`,onClick:E,disabled:d,children:`Cancel`}),t[31]=d,t[32]=E,t[33]=D):D=t[33];let k=d?`Creating...`:`Create & Push`,A;t[34]!==d||t[35]!==f||t[36]!==k?(A=(0,$.jsx)(H,{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]!==D||t[39]!==A?(j=(0,$.jsxs)(Ne,{children:[D,A]}),t[38]=D,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==T||t[42]!==j?(M=(0,$.jsxs)(fn,{children:[m,T,j]}),t[41]=T,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==p||t[46]!==M?(N=(0,$.jsx)(W,{open:n,onOpenChange:p,children:M}),t[44]=n,t[45]=p,t[46]=M,t[47]=N):N=t[47],N}function Ho(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:s,currentBranch:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ae,{children:`Commit History`}),t[0]=l):l=t[0];let d;t[1]===c?d=t[2]:(d=(0,$.jsxs)(O,{children:[l,(0,$.jsxs)(u,{children:[`Recent commits on branch `,c]})]}),t[1]=c,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(Uo):(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)(pt,{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]!==s||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:h}),t[15]=s,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==d||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(fn,{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)(W,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function Uo(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 Wo(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Push Branch First`}),(0,$.jsx)(u,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==o?(c=(0,$.jsx)(H,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=c):c=t[3];let l=i?`Pushing...`:`Push & Create PR`,d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,$.jsx)(H,{onClick:a,disabled:i,children:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]!==c||t[9]!==d?(f=(0,$.jsxs)(fn,{children:[s,(0,$.jsxs)(Ne,{children:[c,d]})]}),t[8]=c,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(W,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function Go(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:s}=e,c=s===void 0?!1:s,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(O,{children:[(0,$.jsxs)(Ae,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pe,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(u,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=l):l=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)(v,{className:`h-4 w-4 mr-2`}),t[2]=f):f=t[2];let p;t[3]!==c||t[4]!==i?(p=(0,$.jsxs)(H,{onClick:i,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[f,`Commit changes first, then pull`]}),t[3]=c,t[4]=i,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(gt,{className:`h-4 w-4 mr-2`}),t[6]=m):m=t[6];let h;t[7]!==c||t[8]!==a?(h=(0,$.jsxs)(H,{onClick:a,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[m,`Stash changes → Pull → Restore changes`]}),t[7]=c,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 y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(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]=y):y=t[14];let b;t[15]===g?b=t[16]:(b=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,g,y]})}),t[15]=g,t[16]=b);let x;t[17]!==c||t[18]!==o?(x=(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=x):x=t[19];let S;t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(fn,{className:`sm:max-w-[425px]`,children:[l,b,x]}),t[20]=b,t[21]=x,t[22]=S):S=t[22];let C;return t[23]!==r||t[24]!==n||t[25]!==S?(C=(0,$.jsx)(W,{open:n,onOpenChange:r,children:S}),t[23]=r,t[24]=n,t[25]=S,t[26]=C):C=t[26],C}function Ko(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:s}=e,c=o===void 0?!1:o,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ae,{children:`Pull Request Merged`}),t[0]=l):l=t[0];let d=s?` from ${s}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(O,{children:[l,(0,$.jsxs)(u,{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]!==c||t[4]!==a?(p=(0,$.jsx)(H,{variant:`ghost`,onClick:a,disabled:c,children:`Just Open`}),t[3]=c,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==c||t[7]!==i?(m=(0,$.jsx)(H,{onClick:i,disabled:c,children:`New Branch`}),t[6]=c,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(Ne,{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)(fn,{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)(W,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function qo(e){let t=(0,Q.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,c;t[0]!==i||t[1]!==o||t[2]!==s?(c=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=c,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`New Branch`}),(0,$.jsx)(u,{children:`Enter a name for the new branch.`})]}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(B,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==l||t[10]!==o||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[f,(0,$.jsx)(V,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:l,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=l,t[10]=o,t[11]=p,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=()=>r(!1),t[13]=r,t[14]=h);let g;t[15]!==o||t[16]!==h?(g=(0,$.jsx)(H,{variant:`outline`,onClick:h,disabled:o,children:`Cancel`}),t[15]=o,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i||t[19]!==o?(_=o||!i.trim(),t[18]=i,t[19]=o,t[20]=_):_=t[20];let v=o?`Creating...`:`Create Branch`,y;t[21]!==s||t[22]!==_||t[23]!==v?(y=(0,$.jsx)(H,{onClick:s,disabled:_,children:v}),t[21]=s,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(Ne,{children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==m?(x=(0,$.jsxs)(fn,{children:[d,m,b]}),t[28]=b,t[29]=m,t[30]=x):x=t[30];let S;return t[31]!==r||t[32]!==n||t[33]!==x?(S=(0,$.jsx)(W,{open:n,onOpenChange:r,children:x}),t[31]=r,t[32]=n,t[33]=x,t[34]=S):S=t[34],S}var Jo=3e4;function Yo(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(void 0),[D,O]=(0,Z.useState)(void 0),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),N=(0,Z.useRef)(!0),P=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),w(e.prExists),E(e.prUrl),O(e.prState),A(e.commitsAheadOfDefault??!1)},[]),F=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>M(!0),100);try{let n=`unified-git-status-${e}`;t&&cn.invalidate(n),P(await cn.get(n,()=>xt(e,t),Jo))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),M(!1)}},[e,P]);return(0,Z.useEffect)(()=>{e&&(async()=>{if(N.current){let t=`unified-git-status-${e}`,n=cn.getSync(t);n&&P(n),N.current=!1}await F()})()},[e,F,P]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:T,prState:D,commitsAheadOfDefault:k,isRefreshing:j,fetchUnifiedStatus:F}}function Xo(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function Zo(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}:Xo(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 I(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 Le(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 Qo({projectId:e,threadId:t}){let{state:n,dispatch:r}=Qn(),[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,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=(0,Z.useRef)(!1),w=(0,Z.useRef)(!1),[T,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)([]),[P,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[z,ee]=(0,Z.useState)(``),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(``),[ae,oe]=(0,Z.useState)(!1),[se,le]=(0,Z.useState)(!1),[B,ue]=(0,Z.useState)(!1),[fe,V]=(0,Z.useState)(!1),[pe,ge]=(0,Z.useState)(``),[_e,ve]=(0,Z.useState)([]),[ye,be]=(0,Z.useState)(!1),U=Yo(t),Se=Zo(t,e,n.projectModelSelections);async function Ce(){Me();let e=await ln();r({type:K.SetProjects,projects:e.projects})}let[W,Te]=(0,Z.useState)(()=>Io()),Ee=n.projects.find(t=>t.projectId===e),De=Ee?.commitMethod===Nt.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&&Ee?.name&&!z&&ee(Ee.name)},[L,Ee?.name,z]),(0,Z.useEffect)(()=>{Lo(W)},[W]),(0,Z.useEffect)(()=>{let e=!0;return $e().then(t=>{e&&ie(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){w.current=!1;return}if(c&&W.autoGenerateCommitMessage&&!f.trim()&&t&&!w.current){w.current=!0;async function e(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}e()}},[c,W.autoGenerateCommitMessage,t,Se,f]),(0,Z.useEffect)(()=>{if(!u){S.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:u,autoGeneratePRInfo:W.autoGeneratePRInfo,prTitleEmpty:!m.trim(),prDescriptionEmpty:!g.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:S.current}),u&&W.autoGeneratePRInfo&&!m.trim()&&!g.trim()&&t&&!S.current){console.log(`[pr-auto-gen] Starting auto-generation...`),S.current=!0;async function e(){let e=await Se.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,W.autoGeneratePRInfo,t,Se,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`),ue(!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 Oe(){if(f.trim()&&Ro(t))try{a(!0),await me(t,f),p(``),l(!1),await U.fetchUnifiedStatus(!0),Ce(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${U.currentBranch}'.`}),se&&(le(!1),await G())}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 ke(){if(U.status===`Behind`&&!U.hasChanges&&!U.hasUnpushedCommits){await Be();return}if(U.hasChanges){l(!0);return}if(U.prExists&&U.prState===`OPEN`&&!U.hasChanges&&!U.hasUnpushedCommits){U.prUrl&&await E(U.prUrl);return}if(U.commitsAheadOfDefault&&!U.prExists&&!U.hasChanges){d(!0);return}if(U.hasUnpushedCommits&&U.prExists){await Ne();return}}async function Ae(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}async function je(){if(Ro(t))try{a(!0),await F(t),await U.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function Ne(){if(Ro(t))try{a(!0),await mn(t),await U.fetchUnifiedStatus(!0),Ce(),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 Fe(){if(Ro(t)){if(U.hasChanges){oe(!0);return}await G()}}async function G(){try{a(!0),await we(t),await U.fetchUnifiedStatus(!0),Ce(),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 Ie(){oe(!1),le(!0),l(!0)}async function Le(){oe(!1),await G()}async function Re(){if(t)try{a(!0);let e=await xe(t,U.defaultBranch??void 0);Me();let n=await ln();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),ue(!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 ze(){if(!(!t||!pe.trim()))try{a(!0);let e=await xe(t,U.defaultBranch??void 0,pe.trim());Me();let n=await ln();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Switched to branch "${e.branchName}"`}),ge(``),V(!1),await U.fetchUnifiedStatus(!0),setTimeout(()=>void U.fetchUnifiedStatus(!0),1500)}catch(e){X({title:`Failed to create branch`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}finally{a(!1)}}async function Be(){if(!Ro(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 Pe(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await U.fetchUnifiedStatus(!0),Ce(),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 Ve(){if(Ro(t))try{a(!0),s(!0);let e=await C(t,m,g);e.prUrl&&await E(e.prUrl),h(``),_(``),d(!1),await U.fetchUnifiedStatus(),Ce()}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),We({title:m,description:g})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),s(!1)}}async function He(){if(Ro(t))try{a(!0);let e=await he(t,z,te,W.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{E(e.repoUrl)},3e3),ee(``),ne(``),R(!1),await U.fetchUnifiedStatus(),Ce()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Ue(){let e=await Se.generatePRInfoWithAI();e&&(h(e.title),_(e.description))}async function We(e){let n=e??b;if(!(!t||!n))try{a(!0),s(!0);try{await mn(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 Pe(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await mn(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 C(t,n.title,n.description);e.prUrl&&await E(e.prUrl),h(``),_(``),x(null),y(!1),await U.fetchUnifiedStatus(),Ce()}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 Ge(){if(Ro(t))try{j(!0);let e=await It(t,100);k(e),N(e.slice(0,10)),D(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{j(!1)}}function Ke(){P||(I(!0),setTimeout(()=>{let e=M.length+10;N(O.slice(0,e)),I(!1)},300))}function qe(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&M.length<O.length&&!P&&Ke()}let Je=Po(U);async function Ye(){if(!ye){be(!0);try{ve((await ce(t)).branches)}catch{ve([])}finally{be(!1)}}}async function Xe(e){if(e!==U.currentBranch){a(!0);try{await de(t,e),await U.fetchUnifiedStatus(!0),X({title:`Switched to branch "${e}"`})}catch(e){X({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{a(!1)}}}function Ze(){ge(``),V(!0)}function Qe(){U.repoUrl&&E(U.repoUrl)}function et(){y(!1),x(null)}function tt(){ue(!1),U.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${Je?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:No(U,i),onClick:ke,children:[jo(U,o),Ao(U,o)]})}),(0,$.jsx)(q,{children:Mo(U)})]})}),(0,$.jsx)(Fo,{branchStatus:U.status,currentBranch:U.currentBranch,remoteUrl:U.remoteUrl,hasRemoteBranch:U.hasRemoteBranch,hasUnpushedCommits:U.hasUnpushedCommits,canCreateRepo:U.canCreateRepo,repoUrl:U.repoUrl,isRefreshing:U.isRefreshing,isBrandState:Je,gitUser:re,availableBranches:_e,isLoadingBranches:ye,onBranchSubMenuOpen:Ye,onCheckoutBranch:Xe,isDirectCommitMode:De,isLoading:i,isLoadingHistory:A,onFetch:()=>void je(),onPull:()=>void Fe(),onPush:()=>void Ne(),onOpenHistory:()=>void Ge(),onNewBranch:Ze,onCreatePR:()=>d(!0),onCreateRepo:()=>R(!0),onViewInGitHub:Qe})]}),(0,$.jsx)(zo,{open:c,onOpenChange:l,commitMessage:f,onCommitMessageChange:p,autoGenerateCommitMessage:W.autoGenerateCommitMessage,onAutoGenerateChange:e=>Te(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:Se.isGeneratingMessage,isLoading:i,onGenerateMessage:Ae,onCommit:Oe,currentBranch:U.currentBranch}),(0,$.jsx)(Bo,{open:u,onOpenChange:d,prTitle:m,onPrTitleChange:h,prDescription:g,onPrDescriptionChange:_,isGeneratingPRInfo:Se.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Ue,onCreatePR:Ve,currentBranch:U.currentBranch,autoGeneratePRInfo:W.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>Te(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(Wo,{open:v,onOpenChange:y,isLoading:i,onPushAndCreatePR:We,onCancel:et}),(0,$.jsx)(Vo,{open:L,onOpenChange:R,repoName:z,onRepoNameChange:ee,repoDescription:te,onRepoDescriptionChange:ne,isPrivateRepo:W.privateRepositoryDefault,onPrivateRepoChange:e=>Te(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:He}),(0,$.jsx)(Ho,{open:T,onOpenChange:D,commits:O,displayedCommits:M,isLoadingMore:P,onScroll:qe,currentBranch:U.currentBranch}),(0,$.jsx)(Go,{open:ae,onOpenChange:oe,onCommitFirst:Ie,onStashAndPull:Le,onCancel:()=>oe(!1),isLoading:i}),(0,$.jsx)(Ko,{open:B,onOpenChange:ue,onNewBranch:Re,onJustOpen:tt,isLoading:i,defaultBranch:U.defaultBranch??void 0}),(0,$.jsx)(qo,{open:fe,onOpenChange:V,branchName:pe,onBranchNameChange:ge,isLoading:i,onCreateBranch:ze})]})}var $o=`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 es({open:e,onOpenChange:r,projectId:i,commands:a,onRefresh:o}){let[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(0),[y,b]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),g([])},E=e=>{c({...e}),p(!1),g([])},D=async()=>{try{b(!0);let e=await ct(i);g(e.scripts),v(0),p(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),X({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{b(!1)}},k=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),g([]),C.current?.focus()},A=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),v(e=>e<m.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),v(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),_<m.length&&k(m[_])):e.key===`Escape`&&(e.preventDefault(),p(!1),g([])))};(0,Z.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&(p(!1),g([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let j=async e=>{try{await x(i,e),X({title:`Success`,description:`Command deleted`}),o()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(W,{open:e,onOpenChange:r,children:(0,$.jsxs)(fn,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Project Commands`}),(0,$.jsx)(u,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:s?(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)(B,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(V,{id:`name`,value:s.name,onChange:e=>c({...s,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(B,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(sr,{ref:C,id:`commandLine`,value:s.commandLine,onChange:e=>c({...s,commandLine:e.target.value}),onKeyDown:A,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{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:y,children:(0,$.jsx)(U,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(0,$.jsx)(`div`,{ref:w,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)(U,{className:`h-3 w-3`}),`Available Scripts `,y&&`(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===_;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:()=>k(e),onMouseEnter:()=>v(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:y?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(B,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(V,{id:`relativeFolder`,value:s.relativeFolder??``,onChange:e=>c({...s,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)(B,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:$o.map(e=>{let t=h[e]||te;return(0,$.jsx)(H,{variant:s.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...s,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)(H,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(Tt,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(H,{size:`sm`,onClick:async()=>{if(!s?.name||!s?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{d(!0),await it(i,s),X({title:`Success`,description:`Command saved`}),c(null),o()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{d(!1)}},disabled:l,children:[(0,$.jsx)(t,{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:[a.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),a.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)(h[e.icon]||n,{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)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),j(e.id)},children:(0,$.jsx)(S,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(H,{variant:`outline`,className:`w-full border-dashed`,onClick:T,children:[(0,$.jsx)(Se,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function ts(){let e=(0,Q.c)(27),{state:t}=Qn(),{selectedProjectId:r,selectedThreadId:i,projects:a}=t,{dispatch:o}=ir(i),[s,c]=(0,Z.useState)(!1),l,u,d,f,p;if(e[0]!==o||e[1]!==a||e[2]!==r||e[3]!==i||e[4]!==t.isRunningCommand){p=Symbol.for(`react.early_return_sentinel`);bb0:{let s;e[10]===r?s=e[11]:(s=e=>e.projectId===r,e[10]=r,e[11]=s),l=a.find(s)?.commands??[];let m;e[12]!==o||e[13]!==r||e[14]!==i?(m=e=>{!r||!i||o({type:K.QueueTerminalCommand,threadId:i,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=o,e[13]=r,e[14]=i,e[15]=m):m=e[15];let g=m,_;if(e[16]===o?_=e[17]:(_=async()=>{o({type:K.ConfigUpdated})},e[16]=o,e[17]=_),u=_,!r){p=null;break bb0}d=`flex items-center gap-1`,f=l.length===0?(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,onClick:()=>c(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(cr,{children:[l.map(e=>{let r=h[e.icon]||n;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(r,{})})}),(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)(H,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>c(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})]})})}e[0]=o,e[1]=a,e[2]=r,e[3]=i,e[4]=t.isRunningCommand,e[5]=l,e[6]=u,e[7]=d,e[8]=f,e[9]=p}else l=e[5],u=e[6],d=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;e[18]!==l||e[19]!==u||e[20]!==r||e[21]!==s?(m=(0,$.jsx)(es,{open:s,onOpenChange:c,projectId:r,commands:l,onRefresh:u}),e[18]=l,e[19]=u,e[20]=r,e[21]=s,e[22]=m):m=e[22];let g;return e[23]!==d||e[24]!==f||e[25]!==m?(g=(0,$.jsxs)(`div`,{className:d,children:[f,m]}),e[23]=d,e[24]=f,e[25]=m,e[26]=g):g=e[26],g}function ns(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 rs({threadId:e}){let{dispatch:t}=Qn(),{setTerminalNotification:n}=Dr(),[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 Xe(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 Zt(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])),n(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${i.friendlyName}`}});try{let n=await r(e,i.name,i.command,{signal:a.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
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 oo({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:i,dispatch:a}=Qn(),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),D=(0,Z.useCallback)(async()=>{try{let t=await Va(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await b(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ua(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),s(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{l(!1)}},[e]);(0,Z.useEffect)(()=>{D()},[D]),(0,Z.useEffect)(()=>{if(!o.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Va(e);s(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[o,e]),(0,Z.useEffect)(()=>{t&&p(``)},[t]);function k(e){p(e.description),d({todo:e})}function A(){d(null),p(``)}async function j(){if(f.trim()){h(!0);try{let t=await Ha(e,f);s(e=>[...e,t]),n(!1),p(``)}finally{h(!1)}}}async function M(){if(!(!f.trim()||!u)){h(!0);try{let t=await Ua(e,u.todo.id,{description:f});s(e=>e.map(e=>e.id===t.id?t:e)),A()}finally{h(!1)}}}async function N(){if(u){h(!0);try{await Wa(e,u.todo.id),s(e=>e.filter(e=>e.id!==u.todo.id)),A()}finally{h(!1)}}}function P(e){s(t=>t.map(t=>t.id===e.id?e:t))}async function F(t){let n=i.selectedThreadId?i.projectModelSelections[i.selectedThreadId]:void 0,r=i.projects.find(t=>t.projectId===e),o=r?.threads.find(e=>e.threadId===i.selectedThreadId),s=n?.id??o?.model,c=n?.provider??o?.modelProvider;if(!s||!c)throw console.error(`No model or provider found for project`,e,o),Error(`No model configuration found. Please configure a model and provider for this project first.`);let l=await le(e);if(!l)return;let u=null,d=await ro(l,n=>{Ua(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,P(e)})});if(!d)return;u||P(await Ua(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};a({type:K.SetProjectModel,threadId:d,model:f}),Ye(d,{model:s,modelProvider:c});let p=await Ft(d,eo($a(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&io(p)}async function I(t){let n=await le(e);if(!n)return;let r=null,i=await ro(n,n=>{Ua(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!i)return;r||P(await Ua(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await b(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await rn(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,c=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!c)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:K.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),Ye(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await Ft(i,t.description,s,[],void 0,c);l&&io(l)}async function L(t){try{let n=await le(e);if(!n){_(!1),y(null);return}let r=null;if(r=await ro(n,e=>{r=e}),!r){_(!1),y(null);return}let a=await b(r),o=a.model,s=a.modelProvider;if(!o||!s)try{let t=(await rn(`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){dn(e,r),_(!1),y(null);return}let c=eo($a(i.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await Ft(r,c,o,[],void 0,s);l&&S(await ao(l)),dn(e,r)}catch(e){console.error(`Failed to generate test case:`,e),_(!1),y(null)}finally{w(!1)}}function R(e){y(e),S(``),w(!0),_(!0),L(e)}function z(){_(!1),y(null),S(``)}async function ee(){if(!v||!x.trim())return;let t=v,n=x;z(),E(!0);try{let r=await le(e);if(!r)return;let i=null,o=await ro(r,n=>{Ua(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,P(e)})});if(!o)return;i||P(await Ua(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await b(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await rn(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),Ye(o,{model:c,modelProvider:l});let u=await Ft(o,n,c,[],void 0,l);u&&io(u)}finally{E(!1)}}async function te(t){let n=await le(e);if(!n)return;let r=null,o=await ro(n,n=>{Ua(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!o)return;r||P(await Ua(e,t.id,{status:`Review`,working:!0,threadId:o}));let s=await b(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await rn(`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.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),Ye(o,{model:c,modelProvider:l});let u=await Ft(o,eo($a(i.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&io(u)}async function ne(t,n){n===`Plan`?await F(t):n===`Build`?await I(t):n===`Test`?R(t):n===`Review`?await te(t):P(await Ua(e,t.id,{status:n,working:n!==`Done`}))}return c?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(pt,{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:to.map(t=>{let i=o.filter(e=>e.status===t),a=t===`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`,no[t]),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:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:i.length})]}),(0,$.jsx)(wt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(Se,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Ka,{todo:t,projectId:e,onUpdate:P,onEdit:k,onAction:ne,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(W,{open:t,onOpenChange:n,children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(sr,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&j()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{onClick:()=>void j(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(W,{open:g,onOpenChange:e=>!e&&z(),children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:C?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(pt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sr,{value:x,onChange:e=>S(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)(Ne,{children:[(0,$.jsx)(H,{variant:`outline`,onClick:z,disabled:C,children:`Cancel`}),(0,$.jsx)(H,{onClick:()=>void ee(),disabled:C||!x.trim()||T,children:T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(W,{open:u!==null,onOpenChange:e=>!e&&A(),children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(O,{children:(0,$.jsx)(Ae,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(sr,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}})}),(0,$.jsxs)(Ne,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(H,{variant:`destructive`,onClick:()=>void N(),disabled:m,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(H,{onClick:()=>void M(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var so=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:qa},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Xa},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ya}];function co({open:e,onOpenChange:t,projectId:n}){let{state:r}=Qn(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,s]=(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 c(){s(!0);try{await mt(n,{planPrompt:i.plan.trim()===qa?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ya?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Xa?null:i.review.trim()||null}),Me(),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{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(W,{open:e,onOpenChange:t,children:(0,$.jsxs)(fn,{className:`max-w-2xl`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`AI Prompt Settings`}),(0,$.jsx)(u,{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)(Ir,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Fr,{className:`w-full`,children:so.map(e=>(0,$.jsx)(Nr,{value:e.value,className:`flex-1`,children:e.label},e.value))}),so.map(e=>(0,$.jsxs)(Pr,{value:e.value,children:[(0,$.jsx)(sr,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(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)(Ne,{children:(0,$.jsx)(H,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function lo({projectId:e}){let{state:t,dispatch:n}=Qn(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=In(),{setActiveMainTab:l}=Dr();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-DmDjliuA.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 tn();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 tn();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)(oo,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(H,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(T,{className:`h-4 w-4`})}),(0,$.jsx)(co,{open:o,onOpenChange:s,projectId:e})]})}var uo=(0,Z.lazy)(()=>Kn(()=>import(`./diff-view-DXIv51Tn.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,8,19]))),fo=(0,Z.lazy)(()=>Kn(()=>import(`./dialogs-config-DmDjliuA.js`).then(e=>e.t),__vite__mapDeps([2,1])));function po(e){let t=(0,Q.c)(49),{onCreateThread:n}=e,{state:r,dispatch:a}=Qn(),o=In(),s=Ln(),[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}=r,x;t[0]!==h||t[1]!==f?(x=f&&h.includes(f),t[0]=h,t[1]=f,t[2]=x):x=t[2];let S=!!x,C;t[3]!==a||t[4]!==r.sidebarOpen?(C=()=>{r.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=r.sidebarOpen,t[5]=C):C=t[5];let w=C,T;t[6]===w?T=t[7]:(T=()=>{w(),d(`clone`),l(!0)},t[6]=w,t[7]=T);let E=T,D;t[8]===w?D=t[9]:(D=()=>{w(),d(`webapp`),l(!0)},t[8]=w,t[9]=D);let O=D,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=async(e,t)=>{try{await St(e,t),l(!1),d(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=k):k=t[10];let A=k,j;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=async(e,t,n)=>{try{await i(e,t,n),l(!1),d(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=j):j=t[11];let M=j,N;t[12]===w?N=t[13]:(N=async()=>{w();try{await ie(),l(!1),d(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=w,t[13]=N);let P=N,F=s.pathname===`/review`,I=s.pathname===`/todos`,L;t[14]===o?L=t[15]:(L=()=>{o(`/`)},t[14]=o,t[15]=L);let R=L,{selectedProjectId:z}=r,ee;t[16]!==w||t[17]!==a||t[18]!==E||t[19]!==R||t[20]!==O||t[21]!==P||t[22]!==m||t[23]!==S||t[24]!==v||t[25]!==p||t[26]!==n||t[27]!==g||t[28]!==_||t[29]!==F||t[30]!==z||t[31]!==f||t[32]!==b||t[33]!==y||t[34]!==I?(ee=I&&z?(0,$.jsx)(lo,{projectId:z}):F&&f?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(uo,{threadId:f,onExit:R})}):(0,$.jsx)(Ba,{messages:p,isStreaming:v,streamingSegments:y,streamingModel:b,isCreatingProject:m,isProcessingThread:S,selectedThreadId:f,selectedProjectId:z,projects:g,projectsLoading:_,onSelectThread:(e,t)=>{w(),a({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:E,onNewApp:O,onOpenFolder:P,error:null,onClearError:mo}),t[16]=w,t[17]=a,t[18]=E,t[19]=R,t[20]=O,t[21]=P,t[22]=m,t[23]=S,t[24]=v,t[25]=p,t[26]=n,t[27]=g,t[28]=_,t[29]=F,t[30]=z,t[31]=f,t[32]=b,t[33]=y,t[34]=I,t[35]=ee):ee=t[35];let te;t[36]!==p||t[37]!==F||t[38]!==f||t[39]!==I?(te=!F&&!I&&f&&(0,$.jsx)(pr,{messages:p}),t[36]=p,t[37]=F,t[38]=f,t[39]=I,t[40]=te):te=t[40];let ne=u??void 0,re;t[41]!==c||t[42]!==P||t[43]!==ne?(re=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(fo,{open:c,onOpenChange:l,initialMode:ne,onSubmitClone:A,onSubmitWebApp:M,onOpenFolder:P})}),t[41]=c,t[42]=P,t[43]=ne,t[44]=re):re=t[44];let ae;return t[45]!==te||t[46]!==re||t[47]!==ee?(ae=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[ee,te,re]}),t[45]=te,t[46]=re,t[47]=ee,t[48]=ae):ae=t[48],ae}function mo(){}var ho=yn,go=Un,_o=Mn,vo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=G(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Re,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,$.jsxs)(xn,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});vo.displayName=xn.displayName;var yo=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(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(vn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});yo.displayName=vn.displayName;var bo=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,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=G(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(Zn,{children:(0,$.jsx)(En,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});bo.displayName=En.displayName;var xo=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,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=G(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(bn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});xo.displayName=bn.displayName;var So=Z.forwardRef((e,n)=>{let r=(0,Q.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:o,children:a,checked:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c;r[5]===o?c=r[6]:(c=G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[5]=o,r[6]=c);let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Sn,{children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),r[7]=l):l=r[7];let u;return r[8]!==i||r[9]!==a||r[10]!==s||r[11]!==n||r[12]!==c?(u=(0,$.jsxs)(wn,{ref:n,className:c,checked:i,...s,children:[l,a]}),r[8]=i,r[9]=a,r[10]=s,r[11]=n,r[12]=c,r[13]=u):u=r[13],u});So.displayName=wn.displayName;var Co=Z.forwardRef((e,t)=>{let n=(0,Q.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=G(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Sn,{children:(0,$.jsx)(w,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(jn,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});Co.displayName=jn.displayName;var wo=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,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=G(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(On,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});wo.displayName=On.displayName;var To=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(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});To.displayName=An.displayName;var Eo=e=>{let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};Eo.displayName=`DropdownMenuShortcut`;var Do=`VS Code`,Oo={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function ko({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(n??Do),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await at();o(e),!s&&e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([Do])}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 We(e,n),t?await ee(t,n):await Ut(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)(H,{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)(H,{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/${Oo[s]||Oo[Do]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(ho,{children:[(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(U,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(bo,{align:`end`,children:a.map(e=>(0,$.jsxs)(xo,{onClick:()=>d(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Oo[e]||Oo[Do]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Ao(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 jo(e,t){return t?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(v,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(M,{className:`h-3.5 w-3.5`}):(0,$.jsx)(De,{className:`h-3.5 w-3.5`})}function Mo(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 No(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 Po(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)(102),{branchStatus:n,currentBranch:r,remoteUrl:i,hasRemoteBranch:a,hasUnpushedCommits:o,canCreateRepo:s,repoUrl:c,isRefreshing:l,isBrandState:u,gitUser:d,availableBranches:f,isLoadingBranches:m,onBranchSubMenuOpen:h,onCheckoutBranch:g,isDirectCommitMode:_,isLoading:v,isLoadingHistory:y,onFetch:b,onPull:x,onPush:S,onOpenHistory:C,onNewBranch:w,onCreatePR:T,onCreateRepo:E,onViewInGitHub:D}=e,O=`h-8 w-8 rounded-l-none px-1 border-transparent${u?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,k;t[0]===l?k=t[1]:(k=l?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),t[0]=l,t[1]=k);let A;t[2]!==v||t[3]!==O||t[4]!==k?(A=(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`outline`,size:`sm`,className:O,disabled:v,children:k})}),t[2]=v,t[3]=O,t[4]=k,t[5]=A):A=t[5];let j;t[6]===h?j=t[7]:(j=async e=>{e&&await h()},t[6]=h,t[7]=j);let N;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(p,{className:`h-3 w-3 shrink-0`}),t[8]=N):N=t[8];let P=r||`Unknown`,F;t[9]===P?F=t[10]:(F=(0,$.jsxs)(vo,{className:`gap-2 text-xs`,children:[N,(0,$.jsx)(`span`,{className:`font-medium`,children:P})]}),t[9]=P,t[10]=F);let I;t[11]!==f||t[12]!==r||t[13]!==v||t[14]!==m||t[15]!==g?(I=m?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin`}),`Loading branches…`]}):f.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):f.map(e=>(0,$.jsxs)(xo,{disabled:e===r||v,onClick:()=>void g(e),children:[(0,$.jsx)(p,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===r?`font-semibold text-foreground`:``,children:e}),e===r&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[11]=f,t[12]=r,t[13]=v,t[14]=m,t[15]=g,t[16]=I):I=t[16];let L;t[17]===I?L=t[18]:(L=(0,$.jsx)(yo,{children:I}),t[17]=I,t[18]=L);let R;t[19]!==j||t[20]!==F||t[21]!==L?(R=(0,$.jsxs)(_o,{onOpenChange:j,children:[F,L]}),t[19]=j,t[20]=F,t[21]=L,t[22]=R):R=t[22];let z;t[23]!==n||t[24]!==i?(z=n===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,i?`origin`:`remote`]}),t[23]=n,t[24]=i,t[25]=z):z=t[25];let ee;t[26]===d?ee=t[27]:(ee=d&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,d]}),t[26]=d,t[27]=ee);let te;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(To,{}),t[28]=te):te=t[28];let ne;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(oe,{className:`h-3.5 w-3.5 mr-2`}),t[29]=ne):ne=t[29];let re;t[30]!==v||t[31]!==b?(re=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:b,disabled:v,children:[ne,`Fetch`]})}),t[30]=v,t[31]=b,t[32]=re):re=t[32];let ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),t[33]=ie):ie=t[33];let ae;t[34]===re?ae=t[35]:(ae=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[re,ie]})}),t[34]=re,t[35]=ae);let se;t[36]!==a||t[37]!==v||t[38]!==x?(se=()=>{a&&!v&&x()},t[36]=a,t[37]=v,t[38]=x,t[39]=se):se=t[39];let ce=!a||v?`opacity-50 cursor-not-allowed`:``,le;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Ke,{className:`h-3.5 w-3.5 mr-2`}),t[40]=le):le=t[40];let B;t[41]!==se||t[42]!==ce?(B=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:se,className:ce,children:[le,`Pull`]})}),t[41]=se,t[42]=ce,t[43]=B):B=t[43];let de=a?`Pull latest changes from remote`:`No remote branch to pull from`,fe;t[44]===de?fe=t[45]:(fe=(0,$.jsx)(q,{side:`right`,children:de}),t[44]=de,t[45]=fe);let V;t[46]!==B||t[47]!==fe?(V=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[B,fe]})}),t[46]=B,t[47]=fe,t[48]=V):V=t[48];let pe;t[49]!==a||t[50]!==v||t[51]!==S?(pe=!a&&(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:S,disabled:v,children:[(0,$.jsx)(ue,{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[49]=a,t[50]=v,t[51]=S,t[52]=pe):pe=t[52];let me;t[53]!==o||t[54]!==v||t[55]!==S?(me=()=>{o&&!v&&S()},t[53]=o,t[54]=v,t[55]=S,t[56]=me):me=t[56];let he=!o||v?`opacity-50 cursor-not-allowed`:``,ge;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(ue,{className:`h-3.5 w-3.5 mr-2`}),t[57]=ge):ge=t[57];let _e;t[58]!==me||t[59]!==he?(_e=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(xo,{onClick:me,className:he,children:[ge,`Push Commits`]})}),t[58]=me,t[59]=he,t[60]=_e):_e=t[60];let ve=o?v?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,ye;t[61]===ve?ye=t[62]:(ye=(0,$.jsx)(q,{side:`right`,children:ve}),t[61]=ve,t[62]=ye);let be;t[63]!==_e||t[64]!==ye?(be=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[_e,ye]})}),t[63]=_e,t[64]=ye,t[65]=be):be=t[65];let xe=v||y,Se;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(sn,{className:`h-3.5 w-3.5 mr-2`}),t[66]=Se):Se=t[66];let Ce;t[67]!==C||t[68]!==xe?(Ce=(0,$.jsxs)(xo,{onClick:C,disabled:xe,children:[Se,`History`]}),t[67]=C,t[68]=xe,t[69]=Ce):Ce=t[69];let W;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(p,{className:`h-3.5 w-3.5 mr-2`}),t[70]=W):W=t[70];let we;t[71]!==v||t[72]!==w?(we=(0,$.jsxs)(xo,{onClick:w,disabled:v,children:[W,`New Branch`]}),t[71]=v,t[72]=w,t[73]=we):we=t[73];let Te;t[74]!==_||t[75]!==v||t[76]!==T?(Te=!_&&(0,$.jsxs)(xo,{onClick:T,disabled:v,children:[(0,$.jsx)(De,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[74]=_,t[75]=v,t[76]=T,t[77]=Te):Te=t[77];let Ee;t[78]!==s||t[79]!==v||t[80]!==E?(Ee=s&&(0,$.jsxs)(xo,{onClick:E,disabled:v,children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[78]=s,t[79]=v,t[80]=E,t[81]=Ee):Ee=t[81];let Oe;t[82]!==v||t[83]!==D||t[84]!==c?(Oe=c&&(0,$.jsxs)(xo,{onClick:D,disabled:v,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[82]=v,t[83]=D,t[84]=c,t[85]=Oe):Oe=t[85];let ke;t[86]!==R||t[87]!==z||t[88]!==ee||t[89]!==ae||t[90]!==V||t[91]!==pe||t[92]!==be||t[93]!==Ce||t[94]!==we||t[95]!==Te||t[96]!==Ee||t[97]!==Oe?(ke=(0,$.jsxs)(bo,{align:`end`,children:[R,z,ee,te,ae,V,pe,be,Ce,we,Te,Ee,Oe]}),t[86]=R,t[87]=z,t[88]=ee,t[89]=ae,t[90]=V,t[91]=pe,t[92]=be,t[93]=Ce,t[94]=we,t[95]=Te,t[96]=Ee,t[97]=Oe,t[98]=ke):ke=t[98];let Ae;return t[99]!==A||t[100]!==ke?(Ae=(0,$.jsxs)(ho,{children:[A,ke]}),t[99]=A,t[100]=ke,t[101]=Ae):Ae=t[101],Ae}function Io(){return{autoGenerateCommitMessage:ot(),autoGeneratePRInfo:Lt(),privateRepositoryDefault:ft()}}function Lo(e){e.autoGenerateCommitMessage!==void 0&<(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&Ue(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&$t(e.privateRepositoryDefault)}function Ro(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function zo(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:s,isGeneratingMessage:c,isLoading:l,onGenerateMessage:d,onCommit:f,currentBranch:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ae,{children:`Commit Changes`}),t[0]=m):m=t[0];let h;t[1]===p?h=t[2]:(h=(0,$.jsxs)(O,{children:[m,(0,$.jsxs)(u,{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)(B,{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)(sr,{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=c||l,b;t[9]===c?b=t[10]:(b=c?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[9]=c,t[10]=b);let x;t[11]!==d||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{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=c?`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 w;t[17]!==C||t[18]!==x?(w=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[x,C]})}),t[17]=C,t[18]=x,t[19]=w):w=t[19];let T;t[20]!==w||t[21]!==v?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,w]})]}),t[20]=w,t[21]=v,t[22]=T):T=t[22];let E;t[23]===s?E=t[24]:(E=e=>s(e===!0),t[23]=s,t[24]=E);let D;t[25]!==o||t[26]!==E?(D=(0,$.jsx)(kr,{id:`auto-generate`,checked:o,onCheckedChange:E}),t[25]=o,t[26]=E,t[27]=D):D=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(B,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=k):k=t[28];let A;t[29]===D?A=t[30]:(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,k]}),t[29]=D,t[30]=A);let j;t[31]!==T||t[32]!==A?(j=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[T,A]}),t[31]=T,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]!==l||t[37]!==M?(N=(0,$.jsx)(H,{variant:`outline`,onClick:M,disabled:l,children:`Cancel`}),t[36]=l,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==i||t[40]!==l?(P=l||!i.trim(),t[39]=i,t[40]=l,t[41]=P):P=t[41];let F=l?`Committing...`:`Commit`,I;t[42]!==f||t[43]!==P||t[44]!==F?(I=(0,$.jsx)(H,{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)(Ne,{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)(fn,{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)(W,{open:n,onOpenChange:r,children:R}),t[53]=r,t[54]=n,t[55]=R,t[56]=z):z=t[56],z}function Bo(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:s,isGeneratingPRInfo:c,isLoading:l,onGeneratePRInfo:d,onCreatePR:f,currentBranch:p,autoGeneratePRInfo:m,onAutoGeneratePRInfoChange:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ae,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===p?_=t[2]:(_=(0,$.jsxs)(O,{children:[g,(0,$.jsxs)(u,{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)(B,{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)(V,{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)(B,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=S):S=t[10];let C;t[11]===s?C=t[12]:(C=e=>s(e.target.value),t[11]=s,t[12]=C);let w;t[13]!==o||t[14]!==C?(w=(0,$.jsx)(sr,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:C,rows:4,className:`pr-10`}),t[13]=o,t[14]=C,t[15]=w):w=t[15];let T=c||l,E;t[16]===c?E=t[17]:(E=c?(0,$.jsx)(pt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[16]=c,t[17]=E);let D;t[18]!==d||t[19]!==T||t[20]!==E?(D=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:T,children:E})}),t[18]=d,t[19]=T,t[20]=E,t[21]=D):D=t[21];let k=c?`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]!==D||t[25]!==A?(j=(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[D,A]})}),t[24]=D,t[25]=A,t[26]=j):j=t[26];let M;t[27]!==j||t[28]!==w?(M=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsxs)(`div`,{className:`relative`,children:[w,j]})]}),t[27]=j,t[28]=w,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)(kr,{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)(B,{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]!==l||t[45]!==R?(z=(0,$.jsx)(H,{variant:`outline`,onClick:R,disabled:l,children:`Cancel`}),t[44]=l,t[45]=R,t[46]=z):z=t[46];let ee=l?`Creating...`:`Create PR`,te;t[47]!==l||t[48]!==f||t[49]!==ee?(te=(0,$.jsx)(H,{onClick:f,disabled:l,children:ee}),t[47]=l,t[48]=f,t[49]=ee,t[50]=te):te=t[50];let ne;t[51]!==z||t[52]!==te?(ne=(0,$.jsxs)(Ne,{children:[z,te]}),t[51]=z,t[52]=te,t[53]=ne):ne=t[53];let re;t[54]!==_||t[55]!==L||t[56]!==ne?(re=(0,$.jsxs)(fn,{children:[_,L,ne]}),t[54]=_,t[55]=L,t[56]=ne,t[57]=re):re=t[57];let ie;return t[58]!==r||t[59]!==n||t[60]!==re?(ie=(0,$.jsx)(W,{open:n,onOpenChange:r,children:re}),t[58]=r,t[59]=n,t[60]=re,t[61]=ie):ie=t[61],ie}function Vo(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:s,isPrivateRepo:c,onPrivateRepoChange:l,isLoading:d,onCreateRepo:f}=e,p;t[0]!==r||t[1]!==s||t[2]!==a?(p=e=>{e||(a(``),s(``)),r(e)},t[0]=r,t[1]=s,t[2]=a,t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Create GitHub Repository`}),(0,$.jsx)(u,{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)(B,{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)(V,{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)(B,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===s?y=t[13]:(y=e=>s(e.target.value),t[12]=s,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(sr,{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]===l?x=t[18]:(x=e=>l(e===!0),t[17]=l,t[18]=x);let S;t[19]!==c||t[20]!==x?(S=(0,$.jsx)(kr,{id:`repo-private`,checked:c,onCheckedChange:x}),t[19]=c,t[20]=x,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(B,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=C):C=t[22];let w;t[23]===S?w=t[24]:(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[23]=S,t[24]=w);let T;t[25]!==w||t[26]!==_||t[27]!==b?(T=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,w]}),t[25]=w,t[26]=_,t[27]=b,t[28]=T):T=t[28];let E;t[29]===r?E=t[30]:(E=()=>r(!1),t[29]=r,t[30]=E);let D;t[31]!==d||t[32]!==E?(D=(0,$.jsx)(H,{variant:`outline`,onClick:E,disabled:d,children:`Cancel`}),t[31]=d,t[32]=E,t[33]=D):D=t[33];let k=d?`Creating...`:`Create & Push`,A;t[34]!==d||t[35]!==f||t[36]!==k?(A=(0,$.jsx)(H,{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]!==D||t[39]!==A?(j=(0,$.jsxs)(Ne,{children:[D,A]}),t[38]=D,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==T||t[42]!==j?(M=(0,$.jsxs)(fn,{children:[m,T,j]}),t[41]=T,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==p||t[46]!==M?(N=(0,$.jsx)(W,{open:n,onOpenChange:p,children:M}),t[44]=n,t[45]=p,t[46]=M,t[47]=N):N=t[47],N}function Ho(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:s,currentBranch:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ae,{children:`Commit History`}),t[0]=l):l=t[0];let d;t[1]===c?d=t[2]:(d=(0,$.jsxs)(O,{children:[l,(0,$.jsxs)(u,{children:[`Recent commits on branch `,c]})]}),t[1]=c,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(Uo):(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)(pt,{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]!==s||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:h}),t[15]=s,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==d||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(fn,{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)(W,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function Uo(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 Wo(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Push Branch First`}),(0,$.jsx)(u,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==o?(c=(0,$.jsx)(H,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=c):c=t[3];let l=i?`Pushing...`:`Push & Create PR`,d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,$.jsx)(H,{onClick:a,disabled:i,children:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]!==c||t[9]!==d?(f=(0,$.jsxs)(fn,{children:[s,(0,$.jsxs)(Ne,{children:[c,d]})]}),t[8]=c,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(W,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function Go(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:s}=e,c=s===void 0?!1:s,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(O,{children:[(0,$.jsxs)(Ae,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pe,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(u,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=l):l=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)(v,{className:`h-4 w-4 mr-2`}),t[2]=f):f=t[2];let p;t[3]!==c||t[4]!==i?(p=(0,$.jsxs)(H,{onClick:i,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[f,`Commit changes first, then pull`]}),t[3]=c,t[4]=i,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(gt,{className:`h-4 w-4 mr-2`}),t[6]=m):m=t[6];let h;t[7]!==c||t[8]!==a?(h=(0,$.jsxs)(H,{onClick:a,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[m,`Stash changes → Pull → Restore changes`]}),t[7]=c,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 y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(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]=y):y=t[14];let b;t[15]===g?b=t[16]:(b=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,g,y]})}),t[15]=g,t[16]=b);let x;t[17]!==c||t[18]!==o?(x=(0,$.jsx)(Ne,{children:(0,$.jsx)(H,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=x):x=t[19];let S;t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(fn,{className:`sm:max-w-[425px]`,children:[l,b,x]}),t[20]=b,t[21]=x,t[22]=S):S=t[22];let C;return t[23]!==r||t[24]!==n||t[25]!==S?(C=(0,$.jsx)(W,{open:n,onOpenChange:r,children:S}),t[23]=r,t[24]=n,t[25]=S,t[26]=C):C=t[26],C}function Ko(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:s}=e,c=o===void 0?!1:o,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ae,{children:`Pull Request Merged`}),t[0]=l):l=t[0];let d=s?` from ${s}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(O,{children:[l,(0,$.jsxs)(u,{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]!==c||t[4]!==a?(p=(0,$.jsx)(H,{variant:`ghost`,onClick:a,disabled:c,children:`Just Open`}),t[3]=c,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==c||t[7]!==i?(m=(0,$.jsx)(H,{onClick:i,disabled:c,children:`New Branch`}),t[6]=c,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(Ne,{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)(fn,{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)(W,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function qo(e){let t=(0,Q.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,c;t[0]!==i||t[1]!==o||t[2]!==s?(c=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=c,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`New Branch`}),(0,$.jsx)(u,{children:`Enter a name for the new branch.`})]}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(B,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==l||t[10]!==o||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[f,(0,$.jsx)(V,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:l,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=l,t[10]=o,t[11]=p,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=()=>r(!1),t[13]=r,t[14]=h);let g;t[15]!==o||t[16]!==h?(g=(0,$.jsx)(H,{variant:`outline`,onClick:h,disabled:o,children:`Cancel`}),t[15]=o,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i||t[19]!==o?(_=o||!i.trim(),t[18]=i,t[19]=o,t[20]=_):_=t[20];let v=o?`Creating...`:`Create Branch`,y;t[21]!==s||t[22]!==_||t[23]!==v?(y=(0,$.jsx)(H,{onClick:s,disabled:_,children:v}),t[21]=s,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(Ne,{children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==m?(x=(0,$.jsxs)(fn,{children:[d,m,b]}),t[28]=b,t[29]=m,t[30]=x):x=t[30];let S;return t[31]!==r||t[32]!==n||t[33]!==x?(S=(0,$.jsx)(W,{open:n,onOpenChange:r,children:x}),t[31]=r,t[32]=n,t[33]=x,t[34]=S):S=t[34],S}var Jo=3e4;function Yo(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(void 0),[D,O]=(0,Z.useState)(void 0),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),N=(0,Z.useRef)(!0),P=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),w(e.prExists),E(e.prUrl),O(e.prState),A(e.commitsAheadOfDefault??!1)},[]),F=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>M(!0),100);try{let n=`unified-git-status-${e}`;t&&cn.invalidate(n),P(await cn.get(n,()=>xt(e,t),Jo))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),M(!1)}},[e,P]);return(0,Z.useEffect)(()=>{e&&(async()=>{if(N.current){let t=`unified-git-status-${e}`,n=cn.getSync(t);n&&P(n),N.current=!1}await F()})()},[e,F,P]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:T,prState:D,commitsAheadOfDefault:k,isRefreshing:j,fetchUnifiedStatus:F}}function Xo(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function Zo(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}:Xo(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 I(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 Le(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 Qo({projectId:e,threadId:t}){let{state:n,dispatch:r}=Qn(),[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,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=(0,Z.useRef)(!1),w=(0,Z.useRef)(!1),[T,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)([]),[P,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[z,ee]=(0,Z.useState)(``),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(``),[ae,oe]=(0,Z.useState)(!1),[se,le]=(0,Z.useState)(!1),[B,ue]=(0,Z.useState)(!1),[fe,V]=(0,Z.useState)(!1),[pe,ge]=(0,Z.useState)(``),[_e,ve]=(0,Z.useState)([]),[ye,be]=(0,Z.useState)(!1),U=Yo(t),Se=Zo(t,e,n.projectModelSelections);async function Ce(){Me();let e=await ln();r({type:K.SetProjects,projects:e.projects})}let[W,Te]=(0,Z.useState)(()=>Io()),Ee=n.projects.find(t=>t.projectId===e),De=Ee?.commitMethod===Nt.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&&Ee?.name&&!z&&ee(Ee.name)},[L,Ee?.name,z]),(0,Z.useEffect)(()=>{Lo(W)},[W]),(0,Z.useEffect)(()=>{let e=!0;return $e().then(t=>{e&&ie(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){w.current=!1;return}if(c&&W.autoGenerateCommitMessage&&!f.trim()&&t&&!w.current){w.current=!0;async function e(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}e()}},[c,W.autoGenerateCommitMessage,t,Se,f]),(0,Z.useEffect)(()=>{if(!u){S.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:u,autoGeneratePRInfo:W.autoGeneratePRInfo,prTitleEmpty:!m.trim(),prDescriptionEmpty:!g.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:S.current}),u&&W.autoGeneratePRInfo&&!m.trim()&&!g.trim()&&t&&!S.current){console.log(`[pr-auto-gen] Starting auto-generation...`),S.current=!0;async function e(){let e=await Se.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,W.autoGeneratePRInfo,t,Se,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`),ue(!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 Oe(){if(f.trim()&&Ro(t))try{a(!0),await me(t,f),p(``),l(!1),await U.fetchUnifiedStatus(!0),Ce(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${U.currentBranch}'.`}),se&&(le(!1),await G())}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 ke(){if(U.status===`Behind`&&!U.hasChanges&&!U.hasUnpushedCommits){await Be();return}if(U.hasChanges){l(!0);return}if(U.prExists&&U.prState===`OPEN`&&!U.hasChanges&&!U.hasUnpushedCommits){U.prUrl&&await E(U.prUrl);return}if(U.commitsAheadOfDefault&&!U.prExists&&!U.hasChanges){d(!0);return}if(U.hasUnpushedCommits&&U.prExists){await Ne();return}}async function Ae(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}async function je(){if(Ro(t))try{a(!0),await F(t),await U.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function Ne(){if(Ro(t))try{a(!0),await mn(t),await U.fetchUnifiedStatus(!0),Ce(),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 Fe(){if(Ro(t)){if(U.hasChanges){oe(!0);return}await G()}}async function G(){try{a(!0),await we(t),await U.fetchUnifiedStatus(!0),Ce(),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 Ie(){oe(!1),le(!0),l(!0)}async function Le(){oe(!1),await G()}async function Re(){if(t)try{a(!0);let e=await xe(t,U.defaultBranch??void 0);Me();let n=await ln();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),ue(!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 ze(){if(!(!t||!pe.trim()))try{a(!0);let e=await xe(t,U.defaultBranch??void 0,pe.trim());Me();let n=await ln();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Switched to branch "${e.branchName}"`}),ge(``),V(!1),await U.fetchUnifiedStatus(!0),setTimeout(()=>void U.fetchUnifiedStatus(!0),1500)}catch(e){X({title:`Failed to create branch`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}finally{a(!1)}}async function Be(){if(!Ro(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 Pe(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await U.fetchUnifiedStatus(!0),Ce(),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 Ve(){if(Ro(t))try{a(!0),s(!0);let e=await C(t,m,g);e.prUrl&&await E(e.prUrl),h(``),_(``),d(!1),await U.fetchUnifiedStatus(),Ce()}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),We({title:m,description:g})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),s(!1)}}async function He(){if(Ro(t))try{a(!0);let e=await he(t,z,te,W.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{E(e.repoUrl)},3e3),ee(``),ne(``),R(!1),await U.fetchUnifiedStatus(),Ce()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Ue(){let e=await Se.generatePRInfoWithAI();e&&(h(e.title),_(e.description))}async function We(e){let n=e??b;if(!(!t||!n))try{a(!0),s(!0);try{await mn(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 Pe(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await mn(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 C(t,n.title,n.description);e.prUrl&&await E(e.prUrl),h(``),_(``),x(null),y(!1),await U.fetchUnifiedStatus(),Ce()}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 Ge(){if(Ro(t))try{j(!0);let e=await It(t,100);k(e),N(e.slice(0,10)),D(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{j(!1)}}function Ke(){P||(I(!0),setTimeout(()=>{let e=M.length+10;N(O.slice(0,e)),I(!1)},300))}function qe(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&M.length<O.length&&!P&&Ke()}let Je=Po(U);async function Ye(){if(!ye){be(!0);try{ve((await ce(t)).branches)}catch{ve([])}finally{be(!1)}}}async function Xe(e){if(e!==U.currentBranch){a(!0);try{await de(t,e),await U.fetchUnifiedStatus(!0),X({title:`Switched to branch "${e}"`})}catch(e){X({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{a(!1)}}}function Ze(){ge(``),V(!0)}function Qe(){U.repoUrl&&E(U.repoUrl)}function et(){y(!1),x(null)}function tt(){ue(!1),U.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${Je?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:No(U,i),onClick:ke,children:[jo(U,o),Ao(U,o)]})}),(0,$.jsx)(q,{children:Mo(U)})]})}),(0,$.jsx)(Fo,{branchStatus:U.status,currentBranch:U.currentBranch,remoteUrl:U.remoteUrl,hasRemoteBranch:U.hasRemoteBranch,hasUnpushedCommits:U.hasUnpushedCommits,canCreateRepo:U.canCreateRepo,repoUrl:U.repoUrl,isRefreshing:U.isRefreshing,isBrandState:Je,gitUser:re,availableBranches:_e,isLoadingBranches:ye,onBranchSubMenuOpen:Ye,onCheckoutBranch:Xe,isDirectCommitMode:De,isLoading:i,isLoadingHistory:A,onFetch:()=>void je(),onPull:()=>void Fe(),onPush:()=>void Ne(),onOpenHistory:()=>void Ge(),onNewBranch:Ze,onCreatePR:()=>d(!0),onCreateRepo:()=>R(!0),onViewInGitHub:Qe})]}),(0,$.jsx)(zo,{open:c,onOpenChange:l,commitMessage:f,onCommitMessageChange:p,autoGenerateCommitMessage:W.autoGenerateCommitMessage,onAutoGenerateChange:e=>Te(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:Se.isGeneratingMessage,isLoading:i,onGenerateMessage:Ae,onCommit:Oe,currentBranch:U.currentBranch}),(0,$.jsx)(Bo,{open:u,onOpenChange:d,prTitle:m,onPrTitleChange:h,prDescription:g,onPrDescriptionChange:_,isGeneratingPRInfo:Se.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Ue,onCreatePR:Ve,currentBranch:U.currentBranch,autoGeneratePRInfo:W.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>Te(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(Wo,{open:v,onOpenChange:y,isLoading:i,onPushAndCreatePR:We,onCancel:et}),(0,$.jsx)(Vo,{open:L,onOpenChange:R,repoName:z,onRepoNameChange:ee,repoDescription:te,onRepoDescriptionChange:ne,isPrivateRepo:W.privateRepositoryDefault,onPrivateRepoChange:e=>Te(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:He}),(0,$.jsx)(Ho,{open:T,onOpenChange:D,commits:O,displayedCommits:M,isLoadingMore:P,onScroll:qe,currentBranch:U.currentBranch}),(0,$.jsx)(Go,{open:ae,onOpenChange:oe,onCommitFirst:Ie,onStashAndPull:Le,onCancel:()=>oe(!1),isLoading:i}),(0,$.jsx)(Ko,{open:B,onOpenChange:ue,onNewBranch:Re,onJustOpen:tt,isLoading:i,defaultBranch:U.defaultBranch??void 0}),(0,$.jsx)(qo,{open:fe,onOpenChange:V,branchName:pe,onBranchNameChange:ge,isLoading:i,onCreateBranch:ze})]})}var $o=`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 es({open:e,onOpenChange:r,projectId:i,commands:a,onRefresh:o}){let[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(0),[y,b]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),g([])},E=e=>{c({...e}),p(!1),g([])},D=async()=>{try{b(!0);let e=await ct(i);g(e.scripts),v(0),p(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),X({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{b(!1)}},k=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),g([]),C.current?.focus()},A=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),v(e=>e<m.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),v(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),_<m.length&&k(m[_])):e.key===`Escape`&&(e.preventDefault(),p(!1),g([])))};(0,Z.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&(p(!1),g([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let j=async e=>{try{await x(i,e),X({title:`Success`,description:`Command deleted`}),o()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(W,{open:e,onOpenChange:r,children:(0,$.jsxs)(fn,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Project Commands`}),(0,$.jsx)(u,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:s?(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)(B,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(V,{id:`name`,value:s.name,onChange:e=>c({...s,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(B,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(sr,{ref:C,id:`commandLine`,value:s.commandLine,onChange:e=>c({...s,commandLine:e.target.value}),onKeyDown:A,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{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:y,children:(0,$.jsx)(U,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(0,$.jsx)(`div`,{ref:w,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)(U,{className:`h-3 w-3`}),`Available Scripts `,y&&`(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===_;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:()=>k(e),onMouseEnter:()=>v(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:y?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(B,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(V,{id:`relativeFolder`,value:s.relativeFolder??``,onChange:e=>c({...s,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)(B,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:$o.map(e=>{let t=h[e]||te;return(0,$.jsx)(H,{variant:s.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...s,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)(H,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(Tt,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(H,{size:`sm`,onClick:async()=>{if(!s?.name||!s?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{d(!0),await it(i,s),X({title:`Success`,description:`Command saved`}),c(null),o()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{d(!1)}},disabled:l,children:[(0,$.jsx)(t,{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:[a.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),a.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)(h[e.icon]||n,{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)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),j(e.id)},children:(0,$.jsx)(S,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(H,{variant:`outline`,className:`w-full border-dashed`,onClick:T,children:[(0,$.jsx)(Se,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function ts(){let e=(0,Q.c)(27),{state:t}=Qn(),{selectedProjectId:r,selectedThreadId:i,projects:a}=t,{dispatch:o}=ir(i),[s,c]=(0,Z.useState)(!1),l,u,d,f,p;if(e[0]!==o||e[1]!==a||e[2]!==r||e[3]!==i||e[4]!==t.isRunningCommand){p=Symbol.for(`react.early_return_sentinel`);bb0:{let s;e[10]===r?s=e[11]:(s=e=>e.projectId===r,e[10]=r,e[11]=s),l=a.find(s)?.commands??[];let m;e[12]!==o||e[13]!==r||e[14]!==i?(m=e=>{!r||!i||o({type:K.QueueTerminalCommand,threadId:i,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=o,e[13]=r,e[14]=i,e[15]=m):m=e[15];let g=m,_;if(e[16]===o?_=e[17]:(_=async()=>{o({type:K.ConfigUpdated})},e[16]=o,e[17]=_),u=_,!r){p=null;break bb0}d=`flex items-center gap-1`,f=l.length===0?(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,onClick:()=>c(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(cr,{children:[l.map(e=>{let r=h[e.icon]||n;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(r,{})})}),(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)(H,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>c(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})]})})}e[0]=o,e[1]=a,e[2]=r,e[3]=i,e[4]=t.isRunningCommand,e[5]=l,e[6]=u,e[7]=d,e[8]=f,e[9]=p}else l=e[5],u=e[6],d=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;e[18]!==l||e[19]!==u||e[20]!==r||e[21]!==s?(m=(0,$.jsx)(es,{open:s,onOpenChange:c,projectId:r,commands:l,onRefresh:u}),e[18]=l,e[19]=u,e[20]=r,e[21]=s,e[22]=m):m=e[22];let g;return e[23]!==d||e[24]!==f||e[25]!==m?(g=(0,$.jsxs)(`div`,{className:d,children:[f,m]}),e[23]=d,e[24]=f,e[25]=m,e[26]=g):g=e[26],g}function ns(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 rs({threadId:e}){let{dispatch:t}=Qn(),{setTerminalNotification:n}=Dr(),[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 Xe(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 Zt(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])),n(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${i.friendlyName}`}});try{let n=await r(e,i.name,i.command,{signal:a.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
34
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{r.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)(ho,{children:[(0,$.jsx)(cr,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Be,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(bo,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(_o,{children:[(0,$.jsx)(vo,{children:e}),(0,$.jsx)(yo,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(xo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(pt,{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)(xo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(pt,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}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(`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)(Cn,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});is.displayName=Cn.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(`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)(gn,{className:`flex items-center justify-center`,children:(0,$.jsx)(w,{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)(Rn,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});as.displayName=Rn.displayName;function os({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)(B,{htmlFor:`skillName`,children:`Skill Name`}),(0,$.jsx)(V,{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)(B,{htmlFor:`skillDescription`,children:`Description`}),(0,$.jsx)(sr,{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)(B,{children:`Scope`}),(0,$.jsxs)(is,{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)(as,{value:`local`,id:`scope-local`}),(0,$.jsx)(B,{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)(as,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(B,{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)(H,{onClick:async()=>{if(!(!d||!i.trim()||!e)){l(!0);try{let n=await ve(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)(pt,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(Re,{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 ss=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)(zn,{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)(Tn,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});ss.displayName=Tn.displayName;function cs({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)(B,{htmlFor:`ruleName`,children:`Rule Name`}),(0,$.jsx)(V,{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)(B,{htmlFor:`ruleDescription`,children:`Description`}),(0,$.jsx)(sr,{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)(B,{htmlFor:`alwaysApply`,children:`Always Apply`}),(0,$.jsx)(ss,{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)(B,{children:`Scope`}),(0,$.jsxs)(is,{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)(as,{value:`local`,id:`scope-local`}),(0,$.jsx)(B,{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)(as,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(B,{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)(H,{onClick:async()=>{if(!(!p||!e)){d(!0);try{let n=`---
|
|
35
35
|
description: ${i.trim()}
|
|
36
36
|
alwaysApply: ${o}
|
|
@@ -47,4 +47,4 @@ Place your rule instructions here as markdown.
|
|
|
47
47
|
`)),x(e=>new Set(e).add(n)),l(),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?pe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,l,pe]),ve=(0,Z.useCallback)(async e=>{if(!t||S.has(e.name))return;let n=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await A(t,e.gitHubRepo,e.gitHubFolder,n);let r=`${n}/${e.name}.md`;C(t=>new Map(t).set(e.name,r))}else{let n=await yt(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);C(t=>new Map(t).set(e.name,n.filePath))}l(),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?pe(e.name,e.gitHubRepo,e.gitHubFolder,n):await n()},[t,S,l,pe]);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)(pt,{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)(pt,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(gs,{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)(W,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(O,{children:[(0,$.jsxs)(Ae,{children:[`Install `,v?.name]}),(0,$.jsxs)(u,{children:[`Install `,(0,$.jsx)(`strong`,{children:v?.name}),` from`,` `,(0,$.jsx)(`strong`,{children:v?.gitHubRepo}),` (`,v?.gitHubFolder,`)?`]})]}),(0,$.jsxs)(Ne,{className:`flex-row gap-2 sm:justify-between`,children:[(0,$.jsx)(H,{variant:`outline`,onClick:()=>{v&&E(`${v.gitHubRepo.replace(/\.git$/,``)}/tree/HEAD/${v.gitHubFolder}`)},children:`More Information`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(H,{variant:`outline`,onClick:()=>y(null),children:`No`}),(0,$.jsx)(H,{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)(Ir,{value:f,onValueChange:F,children:(0,$.jsxs)(Fr,{className:`w-full`,children:[(0,$.jsx)(Nr,{value:`mcp`,className:`flex-1`,children:`MCP`}),(0,$.jsx)(Nr,{value:`skills`,className:`flex-1`,children:`Skills`}),(0,$.jsx)(Nr,{value:`agents`,className:`flex-1`,children:`Agents`}),(0,$.jsx)(Nr,{value:`rules`,className:`flex-1`,children:`Rules`}),(0,$.jsx)(Nr,{value:`commands`,className:`flex-1`,children:`Commands`})]})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(V,{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)(pt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):L.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:L.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)(pt,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(gs,{name:e.name,description:e.description,installed:n,onClick:()=>void re(e),onOpen:n?ae:void 0,onUninstall:n?()=>void ie(e):void 0})]},e.id)})})}),f===`skills`&&(0,$.jsx)(ye,{items:R,onInstall:e=>void me(e),isInstalled:e=>b.has(`.agents/skills/${e.id}/SKILL.md`),noThreadWarning:!0,onOpen:oe,onUninstall:e=>void B(e)}),f===`agents`&&(0,$.jsx)(ye,{items:ee,onInstall:e=>void he(e),isInstalled:e=>b.has(`.agents/agents/${e.id}/AGENT.md`),noThreadWarning:!0,onOpen:se,onUninstall:e=>void ue(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:ce,onUninstall:e=>void de(e)}),f===`commands`&&(0,$.jsx)(ye,{items:ne,onInstall:e=>void ve(e),isInstalled:e=>S.has(e.name),noThreadWarning:!0,onOpen:le,onUninstall:e=>void fe(e)})]})]})]})}function ys(){let e=In(),{state:t}=Qn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,a=i.find(e=>e.projectId===n),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o!==`instructions`||!r||(f(!0),g(r,`AGENTS.md`).then(e=>l(e.content)).catch(()=>l(``)).finally(()=>f(!1)))},[o,r]);let h=async()=>{if(r){m(!0);try{await _t(r,`AGENTS.md`,c),X({title:`Instructions saved`}),s(null)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{m(!1)}}};return n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cr,{children:(0,$.jsxs)(ho,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(go,{asChild:!0,children:(0,$.jsx)(H,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(nt,{})})})}),(0,$.jsx)(q,{children:`AI`})]}),(0,$.jsxs)(bo,{align:`end`,children:[(0,$.jsx)(xo,{onSelect:()=>s(`mcp`),children:`Add MCP Server`}),(0,$.jsx)(xo,{onSelect:()=>s(`skill`),children:`Add Skill`}),(0,$.jsx)(xo,{onSelect:()=>s(`rule`),children:`Add Rule`}),(0,$.jsx)(xo,{onSelect:()=>s(`slash-command`),children:`Add Slash Command`}),(0,$.jsx)(xo,{onSelect:()=>s(`subagent`),children:`Add Subagent`}),(0,$.jsx)(To,{}),(0,$.jsx)(xo,{onSelect:()=>s(`instructions`),disabled:!r,children:`Instructions`}),(0,$.jsx)(xo,{onSelect:()=>void e(`/settings?tab=providers`),children:`Model Providers`}),(0,$.jsx)(To,{}),(0,$.jsx)(xo,{onSelect:()=>s(`marketplace`),children:`Marketplace`})]})]})}),(0,$.jsx)(W,{open:o===`mcp`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(hs,{projectPath:a?.projectPath,onBack:()=>s(null)})})})}),(0,$.jsx)(W,{open:o===`marketplace`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-3xl h-[80vh] overflow-y-auto p-0`,children:(0,$.jsx)(vs,{projectPath:a?.projectPath,threadId:r,onClose:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`skill`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(os,{threadId:r,onSkillCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`rule`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(cs,{threadId:r,onRuleCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`slash-command`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(us,{projectId:n,threadId:r,onCommandCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`subagent`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(fn,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(ls,{threadId:r,onAgentCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`instructions`,onOpenChange:e=>!e&&s(null),children:(0,$.jsxs)(fn,{className:`max-w-2xl`,children:[(0,$.jsxs)(O,{children:[(0,$.jsx)(Ae,{children:`Instructions`}),(0,$.jsx)(u,{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)(pt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsx)(sr,{value:c,onChange:e=>l(e.target.value),className:`min-h-[300px] font-mono text-sm resize-none`,placeholder:`Add instructions for your agent in AGENTS.md...`,disabled:p}),(0,$.jsxs)(Ne,{children:[(0,$.jsx)(H,{variant:`outline`,onClick:()=>s(null),children:`Cancel`}),(0,$.jsx)(H,{onClick:()=>void h(),disabled:d||p,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})]})]})})]}):null}function bs(){let e=(0,Q.c)(44),{state:t,dispatch:n}=Qn(),{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)(Gt,{className:`h-4 w-4`}):(0,$.jsx)(jt,{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)(H,{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:Vt(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:R(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)(ns,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Mr,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rs,{threadId:r}),(0,$.jsx)(ts,{}),(0,$.jsx)(ys,{})]})]}),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)(ns,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Qo,{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)(ns,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(ko,{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)(Lr,{className:d,children:[_,C]}),e[40]=C,e[41]=d,e[42]=_,e[43]=w):w=e[43],w}function xs(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)(_r,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(Sr,{children:[o,(0,$.jsxs)(gr,{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)(xr,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(br,{children:[c,(0,$.jsx)(yr,{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)(vr,{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)(Cr,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function Ss(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)(_r,{children:`Install dependencies?`}),t[2]=o):o=t[2];let s=r.length===1?``:`s`,c;t[3]!==r.length||t[4]!==s?(c=(0,$.jsxs)(Sr,{children:[o,(0,$.jsxs)(gr,{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(Cs),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)(xr,{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)(yr,{onClick:f,children:[`Install All (`,r.length,`)`]}),t[14]=r.length,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==d||t[18]!==p?(m=(0,$.jsxs)(br,{children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==m||t[21]!==c||t[22]!==u?(h=(0,$.jsxs)(vr,{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)(Cr,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function Cs(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 ws(){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(`${Oe()}/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=Ts;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Oe(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(Sr,{children:[(0,$.jsx)(_r,{children:`Service unavailable`}),(0,$.jsx)(gr,{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)(Cr,{open:!0,children:(0,$.jsxs)(vr,{children:[c,l,(0,$.jsx)(br,{children:(0,$.jsx)(H,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function Ts(){window.location.assign(window.location.href)}var Es=Jn,Ds=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)(qn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ds.displayName=qn.displayName;var Os=N(`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`}}),ks=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(Os({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)(kn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});ks.displayName=kn.displayName;var As=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)(Gn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});As.displayName=Gn.displayName;var js=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)(Tt,{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)(Yn,{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});js.displayName=Yn.displayName;var Ms=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)(_n,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ms.displayName=_n.displayName;var Ns=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)(Nn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ns.displayName=Nn.displayName;function Ps(){let e=(0,Q.c)(5),{toasts:t}=mr(),n;e[0]===t?n=e[1]:(n=t.map(Fs),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Ds,{}),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 Fs(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(ks,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(Ms,{children:n}),r&&(0,$.jsx)(Ns,{children:r})]}),i,(0,$.jsx)(js,{})]},t)}function Is(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=wr(),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 Ls(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)(Is,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Tr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Rs(){let{state:e,dispatch:t}=Qn(),{toast:n}=mr(),r=ir(`project-creation`).dispatch,[a,o]=(0,Z.useState)(null),s=(0,Z.useCallback)(async()=>{try{t({type:K.SetProjectsLoading,projectsLoading:!0});let e=await ln();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 Je(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 i=e.useTerminalDispatch?r:t;i({type:K.ClearTerminalOutput}),i({type:K.SetTerminalOpen,open:!0}),i({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:r}=await a.read();if(n)break;l+=c.decode(r,{stream:!0});let s=l.split(`
|
|
48
48
|
`);l=s.pop()??``;for(let n of s){let r=n.trim();if(r)try{let n=JSON.parse(r);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 r=e.includeThreadPath&&n.project.threads?.length>0?`${n.project.path}/${n.project.threads[0]}`:n.project.path;i({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),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}),Me();let m=await ln();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?r:t)({type:K.AppendTerminalLine,line:{type:`error`,content:`${e.catchErrorPrefix}: ${n instanceof Error?n.message:`Unknown error`}`}})}},[t,s,r]),u=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await l({apiCall:()=>St(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:()=>i(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 le(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
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}),Me(),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 dn(n,r),Me(),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 ae(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 en(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 ln();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:ie,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 zs(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(Bs),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 Bs(){return document.hasFocus()}var Vs=null;function Hs(){Vs??=new Audio(`/pop.wav`),Vs.currentTime=0,Vs.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Us(){let{state:e,dispatch:t}=Qn(),n=zs(),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 tn(),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&&Hs(),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 Ws=768;function Gs(){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: ${Ws-1}px)`),t=()=>{n(window.innerWidth<Ws)};return e.addEventListener(`change`,t),n(window.innerWidth<Ws),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Ks=(0,Z.lazy)(()=>Kn(()=>import(`./terminal-panel-D6GPXaCe.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([20,1,2,14,21]))),qs=(0,Z.lazy)(()=>Kn(()=>import(`./todos-view-yPftPooW.js`).then(e=>({default:e.TodosView})),[])),Js=(0,Z.lazy)(()=>Kn(()=>import(`./diff-view-VbYca6ii.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,8,19]))),Ys=(0,Z.lazy)(()=>Kn(()=>import(`./explorer-tab-view-uSxyCL34.js`),__vite__mapDeps([22,1,5,6,2,7,17,14,21]))),Xs=(0,Z.lazy)(()=>Kn(()=>import(`./browser-tab-Cz-q-Pvk.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,2,24,6,3,14,21]))),Zs=(0,Z.lazy)(()=>Kn(()=>import(`./dialogs-config-DmDjliuA.js`).then(e=>e.t),__vite__mapDeps([2,1]))),Qs=(0,Z.lazy)(()=>Kn(()=>import(`./onboarding-dialog-EiVl-ynw.js`),__vite__mapDeps([25,12,1,6,2]))),$s=(0,Z.lazy)(()=>Kn(()=>import(`./conversation-history-view-HVFzgO9e.js`),__vite__mapDeps([26,6,1,2]))),ec=(0,Z.lazy)(()=>Kn(()=>import(`./settings-view-C38jeeqJ.js`),__vite__mapDeps([27,1,5,6,2,7,28,17])));function tc(){let{state:e,dispatch:t}=Qn();(0,Z.useEffect)(()=>{new Yr({})},[]);let n=In(),r=Ln(),i=Gs(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=Rs(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=Us(),[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}=ir(e.selectedThreadId),R=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===R.current&&b(`terminal`),R.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[z,ee]=(0,Z.useState)(!1),[te,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(!1),[B,ue]=(0,Z.useState)(!1),de=(0,Z.useRef)(null),fe=r.pathname.startsWith(`/settings`),V=r.pathname===`/review`,pe=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&y===`tasks`&&b(`chat`)},[r.pathname]);let me=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=fe||V||pe;if(n&&me.current===null)me.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&me.current!==null){let n=me.current;me.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[fe,V,pe]),(0,Z.useEffect)(()=>{(async()=>{try{(await Te()).updateAvailable&&le(!0)}catch{}})()},[]);let he=(0,Z.useCallback)(async()=>{ue(!0);try{await on()}catch{ue(!1)}},[]);(0,Z.useEffect)(()=>{ie||(async()=>{try{(await tt()).onboardingCompleted||re(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ae(!0)}})()},[ie]),(0,Z.useEffect)(()=>{te||t({type:K.ConfigUpdated})},[te,t]);let ge=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&se({id:t.projectId,name:ne(t)})},[a]),_e=(0,Z.useCallback)(e=>{u(e,void 0)},[u]),ve=(0,Z.useCallback)(async(a,s)=>{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?de.current?.expand():de.current?.collapse()},[e.sidebarOpen]);let ye={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)(Or.Provider,{value:ye,children:(0,$.jsxs)(cr,{delayDuration:200,children:[(0,$.jsxs)(zr,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Rr,{ref:de,defaultSize:i?100:25,minSize:i?50:12,maxSize:i?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(ri,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:ve,onCreateProject:()=>ee(!0),onCreateThread:_e,onDeleteThread:d,onDeleteProject:ge,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:K.ClearSelection}),updateAvailable:ce,updatingApp:B,onUpdateApp:he,onRefreshProjects:p})})}),!i&&(0,$.jsx)(Br,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Rr,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!V&&!fe&&!pe&&(0,$.jsx)(bs,{}),!V&&!fe&&!pe&&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${!V&&!fe&&!pe&&y!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(Bn,{children:[(0,$.jsx)(Hn,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`*`,element:(0,$.jsx)(po,{onCreateThread:_e})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!V&&!fe&&!pe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ks,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!V&&!fe&&!pe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xs,{})})}),!V&&!fe&&!pe&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ys,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(qs,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)($s,{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)(Js,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{open:z,onOpenChange:ee,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(xs,{open:oe!==null,projectName:oe?.name,onOpenChange:e=>!e&&se(null),onConfirm:()=>{oe&&(f(oe.id),se(null))}}),(0,$.jsx)(Ss,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Qs,{open:te,onOpenChange:re,onComplete:()=>{ae(!0),p()}})}),(0,$.jsx)(ws,{})]}),(0,$.jsx)(Ps,{})]})})}function nc(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(or,nr),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)(tc,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Ls,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(rr.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var rc=!1;window.addEventListener(`resize`,()=>{rc||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Vr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Fn,{children:(0,$.jsx)(nc,{})})}));export{lo as t};
|
|
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 ln();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:ie,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 zs(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(Bs),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 Bs(){return document.hasFocus()}var Vs=null;function Hs(){Vs??=new Audio(`/pop.wav`),Vs.currentTime=0,Vs.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Us(){let{state:e,dispatch:t}=Qn(),n=zs(),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 tn(),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&&Hs(),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 Ws=768;function Gs(){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: ${Ws-1}px)`),t=()=>{n(window.innerWidth<Ws)};return e.addEventListener(`change`,t),n(window.innerWidth<Ws),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Ks=(0,Z.lazy)(()=>Kn(()=>import(`./terminal-panel-r8cb3-tk.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([20,1,2,14,21]))),qs=(0,Z.lazy)(()=>Kn(()=>import(`./todos-view-MAb840dD.js`).then(e=>({default:e.TodosView})),[])),Js=(0,Z.lazy)(()=>Kn(()=>import(`./diff-view-DXIv51Tn.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,8,19]))),Ys=(0,Z.lazy)(()=>Kn(()=>import(`./explorer-tab-view-tyn_6pBh.js`),__vite__mapDeps([22,1,5,6,2,7,17,14,21]))),Xs=(0,Z.lazy)(()=>Kn(()=>import(`./browser-tab-BUOT-D_w.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,2,24,6,3,14,21]))),Zs=(0,Z.lazy)(()=>Kn(()=>import(`./dialogs-config-DmDjliuA.js`).then(e=>e.t),__vite__mapDeps([2,1]))),Qs=(0,Z.lazy)(()=>Kn(()=>import(`./onboarding-dialog-EiVl-ynw.js`),__vite__mapDeps([25,12,1,6,2]))),$s=(0,Z.lazy)(()=>Kn(()=>import(`./conversation-history-view-HVFzgO9e.js`),__vite__mapDeps([26,6,1,2]))),ec=(0,Z.lazy)(()=>Kn(()=>import(`./settings-view-C38jeeqJ.js`),__vite__mapDeps([27,1,5,6,2,7,28,17])));function tc(){let{state:e,dispatch:t}=Qn();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new Yr({})},[]);let n=In(),r=Ln(),i=Gs(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=Rs(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=Us(),[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}=ir(e.selectedThreadId),R=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===R.current&&b(`terminal`),R.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[z,ee]=(0,Z.useState)(!1),[te,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(!1),[B,ue]=(0,Z.useState)(!1),de=(0,Z.useRef)(null),fe=r.pathname.startsWith(`/settings`),V=r.pathname===`/review`,pe=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&y===`tasks`&&b(`chat`)},[r.pathname]);let me=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=fe||V||pe;if(n&&me.current===null)me.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&me.current!==null){let n=me.current;me.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[fe,V,pe]),(0,Z.useEffect)(()=>{(async()=>{try{(await Te()).updateAvailable&&le(!0)}catch{}})()},[]);let he=(0,Z.useCallback)(async()=>{ue(!0);try{await on()}catch{ue(!1)}},[]);(0,Z.useEffect)(()=>{ie||(async()=>{try{(await tt()).onboardingCompleted||re(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ae(!0)}})()},[ie]),(0,Z.useEffect)(()=>{te||t({type:K.ConfigUpdated})},[te,t]);let ge=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&se({id:t.projectId,name:ne(t)})},[a]),_e=(0,Z.useCallback)(e=>{u(e,void 0)},[u]),ve=(0,Z.useCallback)(async(a,s)=>{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?de.current?.expand():de.current?.collapse()},[e.sidebarOpen]);let ye={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)(Or.Provider,{value:ye,children:(0,$.jsxs)(cr,{delayDuration:200,children:[(0,$.jsxs)(zr,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Rr,{ref:de,defaultSize:i?100:25,minSize:i?50:12,maxSize:i?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(ri,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:ve,onCreateProject:()=>ee(!0),onCreateThread:_e,onDeleteThread:d,onDeleteProject:ge,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ce,updatingApp:B,onUpdateApp:he,onRefreshProjects:p})})}),!i&&(0,$.jsx)(Br,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Rr,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!V&&!fe&&!pe&&(0,$.jsx)(bs,{}),!V&&!fe&&!pe&&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${!V&&!fe&&!pe&&y!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(Bn,{children:[(0,$.jsx)(Hn,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ec,{})})}),(0,$.jsx)(Hn,{path:`*`,element:(0,$.jsx)(po,{onCreateThread:_e})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!V&&!fe&&!pe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ks,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!V&&!fe&&!pe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xs,{})})}),!V&&!fe&&!pe&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ys,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(qs,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)($s,{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)(Js,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{open:z,onOpenChange:ee,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(xs,{open:oe!==null,projectName:oe?.name,onOpenChange:e=>!e&&se(null),onConfirm:()=>{oe&&(f(oe.id),se(null))}}),(0,$.jsx)(Ss,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Qs,{open:te,onOpenChange:re,onComplete:()=>{ae(!0),p()}})}),(0,$.jsx)(ws,{})]}),(0,$.jsx)(Ps,{})]})})}function nc(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(or,nr),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)(tc,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Ls,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(rr.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var rc=!1;window.addEventListener(`resize`,()=>{rc||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Vr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Fn,{children:(0,$.jsx)(nc,{})})}));export{lo as t};
|