tarsk 0.4.23 → 0.4.24
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/public/assets/{alert-dialog-2Kcr7vcf.js → alert-dialog-JOYww-on.js} +1 -1
- package/dist/public/assets/{browser-tab-CgLMsYM8.js → browser-tab-xojjEFYj.js} +1 -1
- package/dist/public/assets/chat-input-container-fUw0AY1R.js +1 -0
- package/dist/public/assets/{context-menu-sx0fb5uQ.js → context-menu-5lS4H_pS.js} +1 -1
- package/dist/public/assets/{diff-view-v-bVp3Zf.js → diff-view-DWNDi8zT.js} +1 -1
- package/dist/public/assets/{explorer-tab-view-CsPSJADk.js → explorer-tab-view-BtTXy75I.js} +2 -2
- package/dist/public/assets/{explorer-tree-DXXm8_b9.js → explorer-tree-DdPiBm7Y.js} +1 -1
- package/dist/public/assets/{explorer-view-8g0_dmv4.js → explorer-view-06kjYKL2.js} +1 -1
- package/dist/public/assets/index-CoryOY5D.css +1 -0
- package/dist/public/assets/index-DJNTxm7E.js +50 -0
- package/dist/public/assets/{project-settings-view-CVYvsVWo.js → project-settings-view-DF-F7P8K.js} +1 -1
- package/dist/public/assets/{provider-details-view-Cp_INkPg.js → provider-details-view-CbGbbmaI.js} +1 -1
- package/dist/public/assets/{react-vendor-4OUTOTE0.js → react-vendor-BX34Jw0L.js} +1 -1
- package/dist/public/assets/{resizable-D62plzWh.js → resizable-asBmgm9X.js} +1 -1
- package/dist/public/assets/{run-stop-button-ClYpPnNG.js → run-stop-button-MczHUMXL.js} +1 -1
- package/dist/public/assets/{settings-view-BWQrM94z.js → settings-view-CtiXQd-N.js} +2 -2
- package/dist/public/assets/{side-panel-container-Bkpb7_cb.js → side-panel-container-5txNmqNe.js} +1 -1
- package/dist/public/assets/store-xK3nfJ3V.js +2 -0
- package/dist/public/assets/tabs-B7OXJglU.js +1 -0
- package/dist/public/assets/{terminal-panel-4EVJwsCQ.js → terminal-panel-D3OZDoCd.js} +1 -1
- package/dist/public/assets/todos-view-CzW8DtQ9.js +1 -0
- package/dist/public/index.html +11 -11
- package/package.json +1 -1
- package/dist/public/assets/chat-input-container-VXGAcgnU.js +0 -1
- package/dist/public/assets/index-BPF49zet.css +0 -1
- package/dist/public/assets/index-DsX2aOD3.js +0 -50
- package/dist/public/assets/store-CJdxpohI.js +0 -2
- package/dist/public/assets/tabs-DI_KCGYt.js +0 -1
- package/dist/public/assets/todos-view-D3JYa8fa.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Fn as n,Wn as r,da as i,la as a}from"./dialogs-config-3Hr2GRdt.js";import{at as o,ct as s,it as c,lt as l,ot as u,rt as d,st as f,ut as p}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Fn as n,Wn as r,da as i,la as a}from"./dialogs-config-3Hr2GRdt.js";import{at as o,ct as s,it as c,lt as l,ot as u,rt as d,st as f,ut as p}from"./react-vendor-BX34Jw0L.js";var m=a(),h=e(i(),1),g=t(),_=l,v=s,y=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(f,{className:o,...a,ref:t}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});y.displayName=f.displayName;var b=h.forwardRef((e,t)=>{let n=(0,m.c)(10),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let s;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(y,{}),n[3]=s):s=n[3];let c;n[4]===i?c=n[5]:(c=r(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),n[4]=i,n[5]=c);let l;return n[6]!==a||n[7]!==t||n[8]!==c?(l=(0,g.jsxs)(v,{children:[s,(0,g.jsx)(o,{ref:t,className:c,...a})]}),n[6]=a,n[7]=t,n[8]=c,n[9]=l):l=n[9],l});b.displayName=o.displayName;var x=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-lg font-semibold`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(p,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});C.displayName=p.displayName;var w=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-sm text-muted-foreground`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(u,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});w.displayName=u.displayName;var T=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==t||i[7]!==s?(c=(0,g.jsx)(d,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=c):c=i[8],c});T.displayName=d.displayName;var E=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=s);let l;return i[5]!==o||i[6]!==t||i[7]!==s?(l=(0,g.jsx)(c,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=l):l=i[8],l});E.displayName=c.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Gt as n,Ri as r,Rr as i,Wr as a,Xr as o,ci as s,da as c,la as l}from"./dialogs-config-3Hr2GRdt.js";import{a as u}from"./store-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Gt as n,Ri as r,Rr as i,Wr as a,Xr as o,ci as s,da as c,la as l}from"./dialogs-config-3Hr2GRdt.js";import{a as u}from"./store-xK3nfJ3V.js";import{n as d}from"./tab-context-D2auNMAI.js";import{t as f}from"./run-stop-button-MczHUMXL.js";var p=l(),m=e(c(),1),h=t();function g(){let e=(0,p.c)(41),{devServerUrl:t,browserResetTrigger:c}=d(),{state:l}=u(),{selectedProjectId:g,projects:_}=l,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===c?O=e[7]:(O=[c],e[6]=c,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===t?(k=e[9],A=e[10]):(k=()=>{t&&(x(t),C(t))},A=[t],e[8]=t,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(o,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(s,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(i,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(a,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void n(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(r,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$r as n,Ci as r,Cr as i,D as a,Di as o,Fi as s,Hn as c,Jr as l,Ki as u,Lr as d,Lt as f,Mt as p,Nr as m,Or as h,Pi as g,Pn as _,Q as v,Qi as y,Qr as b,Rn as x,Tn as S,Tt as C,Un as w,Vr as T,Wn as E,Y as D,Yi as O,Yt as k,Zi as A,_i as j,aa as M,bn as N,cn as P,d as F,da as I,di as L,fi as R,fn as z,gi as ee,ji as te,jt as ne,ki as re,kr as ie,kt as ae,la as B,m as oe,ni as V,nt as H,on as U,pn as W,qi as G,ta as K,tt as q,vi as se,w as J,xi as ce,xn as le,y as ue,zn as de}from"./dialogs-config-3Hr2GRdt.js";import{B as fe,G as pe,H as me,J as he,K as ge,L as _e,R as ve,U as ye,V as be,X as xe,Y as Se,Z as Ce,gt as we,q as Te}from"./react-vendor-BX34Jw0L.js";import{a as Ee,l as Y,s as De,t as X,u as Oe}from"./store-xK3nfJ3V.js";import{c as ke,s as Ae,u as je}from"./history-view-Cyhu-ped.js";import{t as Me}from"./use-toast-C3jyoS6i.js";import{a as Ne,c as Pe,i as Fe,o as Ie,s as Le,t as Re}from"./alert-dialog-JOYww-on.js";import{n as ze}from"./tab-context-D2auNMAI.js";import{r as Be}from"./onboarding-DzgFi5ix.js";var Z=B(),Q=e(I(),1),$=i();function Ve(e){let t=(0,Z.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(Ve,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function He(e){let t=(0,Z.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(i);i!==h&&(g(i),m({}));let _;t[1]===o?_=t[2]:(_=o?new Set(o):void 0,t[1]=o,t[2]=_);let v=_,y;t[3]===u?y=t[4]:(y=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=y);let b=y,x;t[5]===l?x=t[6]:(x=E(`min-w-0`,l),t[5]=l,t[6]=x);let S;if(t[7]!==c||t[8]!==u||t[9]!==v||t[10]!==b||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==v||t[19]!==b||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,$.jsx)(Ve,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:b,forceOpenIds:v},e.id),t[16]=c,t[17]=u,t[18]=v,t[19]=b,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],S=n.map(e),t[7]=c,t[8]=u,t[9]=v,t[10]=b,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=S}else S=t[15];let C;return t[24]!==x||t[25]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[24]=x,t[25]=S,t[26]=C):C=t[26],C}var Ue=(0,Q.createContext)({todos:[],setTodos:()=>{}});function We(e){let t=(0,Z.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Q.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,$.jsx)(Ue.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function Ge(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 Ke(e){let t=(0,Z.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Q.useContext)(Ue),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Q.useEffect)(a,o),null}var qe=new Map,Je=new Map;function Ye(e){return qe.get(e)}function Xe(e,t){let n=Je.get(e);return n||(n=new Set,Je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Je.delete(e)}}function Ze(e){let t=Je.get(e);if(t)for(let e of t)e()}function Qe(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function $e(e,t,n){if(qe.has(e))return;qe.set(e,{status:`running`}),Ze(e);let r=S();(async()=>{try{let i=Qe(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;qe.set(e,{status:`success`,result:s}),Ze(e),await z(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);qe.set(e,{status:`error`,error:n}),Ze(e);try{await z(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}var et=()=>{if(typeof window>`u`)return null;let e=window.SpeechRecognition||window.webkitSpeechRecognition;return e?new e:null};function tt(){let e=(0,Z.c)(14),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(``),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{try{let e=et();e?(e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{n(!0),o(null),u.current=``},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n][0].transcript;e.results[n].isFinal?i(e=>e+r+` `):t+=r}u.current=t},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),o(e.error||`An error occurred during speech recognition`)},e.onend=()=>{n(!1)},l.current=e,c(!0)):(c(!1),o(`Speech Recognition API is not supported in your browser`))}catch(e){console.error(`Failed to initialize speech recognition:`,e),c(!1),o(`Failed to initialize speech recognition`)}return()=>{l.current&&l.current.abort()}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Q.useEffect)(d,f);let p;e[2]===t?p=e[3]:(p=()=>{l.current&&!t&&l.current.start()},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=()=>{l.current&&t&&l.current.stop()},e[4]=t,e[5]=h);let g=h,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{i(``),u.current=``},e[6]=_):_=e[6];let v=_,y;return e[7]!==a||e[8]!==t||e[9]!==s||e[10]!==m||e[11]!==g||e[12]!==r?(y={isListening:t,transcript:r,error:a,startListening:m,stopListening:g,resetTranscript:v,isSupported:s},e[7]=a,e[8]=t,e[9]=s,e[10]=m,e[11]=g,e[12]=r,e[13]=y):y=e[13],y}function nt({initialValue:e}={}){let{state:n,dispatch:r}=Ee(),[i,a]=(0,Q.useState)(e??``),[o,s]=(0,Q.useState)(-1),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(0),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(()=>(n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0)??null),g=(0,Q.useRef)(m?.id??``),_=(0,Q.useRef)(m?.provider??``),y=(0,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)([]),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)([]),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)([]),[ee,te]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(``),[ie,ae]=(0,Q.useState)(0),[B,oe]=(0,Q.useState)([]),[V,H]=(0,Q.useState)([]),[U,W]=(0,Q.useState)(!1),[G,K]=(0,Q.useState)(``),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{g.current=m?.id??``,_.current=m?.provider??``},[m?.id,m?.provider]);let pe=(0,Q.useCallback)((e,t)=>{h(e);let i=n.selectedThreadId;if(!i||(r({type:X.SetProjectModel,threadId:i,model:e}),t?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;y.current!==a&&(y.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),N(i,{model:e.id,modelProvider:e.provider}).then(()=>{y.current===a&&(y.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{y.current===a&&(y.current=null),console.error(`Failed to save model to thread:`,e)}))},[n.selectedThreadId,r]);(0,Q.useEffect)(()=>{(async()=>{let e=n.selectedProjectId?n.projects.find(e=>e.projectId===n.selectedProjectId)?.threads.find(e=>e.threadId===n.selectedThreadId):void 0,r=n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0,i=e?.model??r?.id??null,a=e?.modelProvider??r?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n.selectedThreadId,projectId:n.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:r?{id:r.id,provider:r.provider}:void 0,savedModelId:i,savedModelProvider:a});try{let e=await t(),n=Object.values(e).flat();if(n.length===0){p([]),h(null);return}p(n);let r=i&&a?n.find(e=>e.id===i&&e.provider===a)??null:null,o=n[0],s=r??o,c=!r&&!!(i||a),l=g.current===s.id&&_.current===s.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:r?{id:r.id}:null,fallbackModel:{id:o.id},modelToSelect:{id:s.id},shouldPersistFallback:c,hasSameSelection:l,currentSelected:{id:g.current,provider:_.current}}),l||pe(s,{persist:c})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n.selectedThreadId,n.selectedProjectId,n.projects,pe]);let me=(0,Q.useRef)(pe);(0,Q.useEffect)(()=>{me.current=pe},[pe]),(0,Q.useEffect)(()=>{n.configUpdatedAt!==0&&(async()=>{try{let e=await t(),n=Object.values(e).flat();if(n.length>0){p(n);let e=g.current,t=_.current;n.some(n=>n.id===e&&n.provider===t)||me.current(n[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[n.configUpdatedAt]),(0,Q.useEffect)(()=>{!j||P.length>0||(async()=>{try{let e=await v(),t=Object.values(e).flat();t.length>0&&(F(t),L(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[j,P.length]);let[he,ge]=(0,Q.useState)(n.selectedThreadId);return(0,Q.useEffect)(()=>{n.selectedThreadId!==he&&setTimeout(()=>{ge(n.selectedThreadId),z([]),te(!1),oe([]),H([]),W(!1),O(!1),M(!1),A(!1)},0)},[n.selectedThreadId,he]),(0,Q.useEffect)(()=>{n.selectedThreadId&&C(n.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),oe(e),H(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n.selectedThreadId]),(0,Q.useEffect)(()=>{n.focusChatInput&&n.selectedThreadId&&!n.isStreaming&&(ce.current?.focus(),r({type:X.ClearFocusChatInput}))},[n.focusChatInput,n.selectedThreadId,n.isStreaming,r]),(0,Q.useEffect)(()=>{let e=e=>{le.current&&!le.current.contains(e.target)&&x(!1),ue.current&&!ue.current.contains(e.target)&&w(!1)};if(b||S)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[b,S]),{message:i,setMessage:a,historyIndex:o,setHistoryIndex:s,draftMessage:c,setDraftMessage:l,cursorPosition:u,setCursorPosition:d,availableModels:f,setAvailableModels:p,selectedModel:m,setSelectedModel:pe,selectedModelIdRef:g,showModelMenu:b,setShowModelMenu:x,showPlusMenu:S,setShowPlusMenu:w,attachments:T,setAttachments:E,planMode:D,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:P,setAvailableImageModels:F,selectedImageModel:I,setSelectedImageModel:L,allFiles:R,setAllFiles:z,showSuggestions:ee,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:re,selectedIndex:ie,setSelectedIndex:ae,slashCommands:B,setSlashCommands:oe,skills:V,setSkills:H,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,fileInputRef:se,textareaRef:ce,modelMenuRef:le,plusMenuRef:ue,suggestionsRef:de,commandSuggestionsRef:fe,handleNewChat:async()=>{if(n.selectedThreadId)try{let e=await J(n.selectedThreadId);r({type:X.ClearMessages}),console.log(`New conversation started:`,e);let t=await q(n.selectedThreadId);r({type:X.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:n,dispatch:r}}var rt=e=>{F(e)};function it(e){let t=(0,Z.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:y,setShowSuggestions:b,suggestionQuery:x,setSuggestionQuery:S,allFiles:C,setAllFiles:w,selectedIndex:T,setSelectedIndex:E,showCommandSuggestions:D,setShowCommandSuggestions:O,commandQuery:k,setCommandQuery:A,slashCommands:j,skills:M,textareaRef:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,selectedImageModel:te}=e,ne;t[0]!==i||t[1]!==f||t[2]!==z||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==F||t[8]!==L||t[9]!==d||t[10]!==te||t[11]!==a||t[12]!==c||t[13]!==P||t[14]!==g||t[15]!==m||t[16]!==r||t[17]!==u||t[18]!==N?(ne=()=>{if(!n.trim()&&i.length===0||!c)return;let e=z?te:a;e&&(l&&(u(),d()),s?f({type:X.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:F,imageMode:z,ralphMode:L}}):o(n,e.id,i,e.provider,F,z,L),rt(n),r(``),P([]),m(-1),g(``),N.current&&(N.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=z,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=F,t[8]=L,t[9]=d,t[10]=te,t[11]=a,t[12]=c,t[13]=P,t[14]=g,t[15]=m,t[16]=r,t[17]=u,t[18]=N,t[19]=ne):ne=t[19];let re=ne,ie;t[20]!==_||t[21]!==n||t[22]!==r||t[23]!==b||t[24]!==x||t[25]!==N?(ie=e=>{let t=n.substring(0,_-x.length-1);r(`${t}${e} ${n.substring(_)}`),b(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.length+1;N.current.setSelectionRange(n,n)}},0)},t[20]=_,t[21]=n,t[22]=r,t[23]=b,t[24]=x,t[25]=N,t[26]=ie):ie=t[26];let B=ie,V;t[27]!==k||t[28]!==_||t[29]!==n||t[30]!==ee||t[31]!==r||t[32]!==I||t[33]!==R||t[34]!==O||t[35]!==N?(V=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_);r(`${t}${e.content}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.content.length;N.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(I(!0),R(!1),ee(!1)):e.metadata.mode===`ralph`&&(R(!0),I(!1),ee(!1))},t[27]=k,t[28]=_,t[29]=n,t[30]=ee,t[31]=r,t[32]=I,t[33]=R,t[34]=O,t[35]=N,t[36]=V):V=t[36];let H=V,U;t[37]!==k||t[38]!==_||t[39]!==n||t[40]!==r||t[41]!==O||t[42]!==N?(U=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let e=t.length+a.length;N.current.setSelectionRange(e,e)}},0)},t[37]=k,t[38]=_,t[39]=n,t[40]=r,t[41]=O,t[42]=N,t[43]=U):U=t[43];let W=U,G,K,q,se;if(t[44]!==C||t[45]!==k||t[46]!==h||t[47]!==re||t[48]!==p||t[49]!==H||t[50]!==B||t[51]!==W||t[52]!==n||t[53]!==T||t[54]!==c||t[55]!==w||t[56]!==A||t[57]!==v||t[58]!==g||t[59]!==m||t[60]!==r||t[61]!==E||t[62]!==O||t[63]!==b||t[64]!==S||t[65]!==D||t[66]!==y||t[67]!==M||t[68]!==j||t[69]!==x){q=e=>{if(D){if(e.key===`ArrowDown`){e.preventDefault(),E((T+1)%G.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E((T-1+G.length)%G.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=G[T];t&&(t.type===`command`?H(t.data):W(t.data));return}if(e.key===`Escape`){O(!1);return}}if(y){let t=K.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),E((T+1)%K.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),E((T-1+K.length)%K.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),K[T]&&B(K[T]);return}if(e.key===`Escape`){b(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),re();return}let t=oe();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[74]!==C||t[75]!==c||t[76]!==w||t[77]!==A||t[78]!==v||t[79]!==r||t[80]!==E||t[81]!==O||t[82]!==b||t[83]!==S?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?O(!1):(A(e),O(!0),b(!1),E(0))}else O(!1)}else{O(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?b(!1):(S(t),b(!0),E(0),C.length===0&&c&&ae(c).then(e=>{w(e)}).catch(st))}else b(!1)}else b(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=C,t[75]=c,t[76]=w,t[77]=A,t[78]=v,t[79]=r,t[80]=E,t[81]=O,t[82]=b,t[83]=S,t[84]=e):e=t[84],se=e;let i;if(t[85]!==k||t[86]!==M||t[87]!==j){let e;t[89]===k?e=t[90]:(e=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[89]=k,t[90]=e);let n=j.filter(e),r;t[91]===k?r=t[92]:(r=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[91]=k,t[92]=r);let a=M.filter(r);i=[...n.map(ot),...a.map(at)],t[85]=k,t[86]=M,t[87]=j,t[88]=i}else i=t[88];G=i.slice(0,10),K=y?C.filter(e=>e.toLowerCase().includes(x.toLowerCase())).slice(0,10):[],t[44]=C,t[45]=k,t[46]=h,t[47]=re,t[48]=p,t[49]=H,t[50]=B,t[51]=W,t[52]=n,t[53]=T,t[54]=c,t[55]=w,t[56]=A,t[57]=v,t[58]=g,t[59]=m,t[60]=r,t[61]=E,t[62]=O,t[63]=b,t[64]=S,t[65]=D,t[66]=y,t[67]=M,t[68]=j,t[69]=x,t[70]=G,t[71]=K,t[72]=q,t[73]=se}else G=t[70],K=t[71],q=t[72],se=t[73];let J;return t[93]!==G||t[94]!==K||t[95]!==q||t[96]!==re||t[97]!==se||t[98]!==H||t[99]!==B||t[100]!==W?(J={handleSend:re,handleKeyDown:q,handleTextareaInput:se,insertFileReference:B,insertCommand:H,insertSkill:W,allSuggestions:G,fileSuggestions:K},t[93]=G,t[94]=K,t[95]=q,t[96]=re,t[97]=se,t[98]=H,t[99]=B,t[100]=W,t[101]=J):J=t[101],J}function at(e){return{type:`skill`,data:e}}function ot(e){return{type:`command`,data:e}}function st(e){return console.error(`Failed to fetch files:`,e)}function ct(e){let t=(0,Z.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let f;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);f=[...n.map(ut),...s.map(lt)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=f}else f=t[3];let p=f,m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(d,{className:`h-3 w-3`}),t[8]=m):m=t[8];let g=a&&` matching "${a}"`,_;t[9]===g?_=t[10]:(_=(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:[m,`Commands & Skills`,g]}),t[9]=g,t[10]=_);let v;t[11]!==p||t[12]!==l||t[13]!==s||t[14]!==c||t[15]!==o?(v=p.length>0?p.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(h,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=p,t[12]=l,t[13]=s,t[14]=c,t[15]=o,t[16]=v):v=t[16];let y;return t[17]!==u||t[18]!==_||t[19]!==v?(y=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[_,v]}),t[17]=u,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function lt(e){return{type:`skill`,data:e}}function ut(e){return{type:`command`,data:e}}function dt(e){return e.startsWith(`image/`)}function ft(e){let t=(0,Z.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:dt(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(ie,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(V,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(ie,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function pt(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function mt(e){let t=(0,Z.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:c,containerRef:u}=e;if(!n||r.length===0)return null;let d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(l,{className:`h-3 w-3`}),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=(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:[d,`Files matching "`,i,`"`]}),t[1]=i,t[2]=f);let p;if(t[3]!==r||t[4]!==c||t[5]!==o||t[6]!==a){let e;t[8]!==c||t[9]!==o||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>c(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(s,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=c,t[9]=o,t[10]=a,t[11]=e):e=t[11],p=r.map(e),t[3]=r,t[4]=c,t[5]=o,t[6]=a,t[7]=p}else p=t[7];let m;return t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[f,p]}),t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function ht(e){let t=(0,Z.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0`,onError:gt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function gt(e){e.currentTarget.style.visibility=`hidden`}function _t(e){let t=(0,Z.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Q.useState(!1),s=Q.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Q.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,$.jsx)(ht,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?Be(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(A,{className:`h-3 w-3`}),t[13]=v):v=t[13];let y;t[14]!==f||t[15]!==m||t[16]!==g?(y=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,v]}),t[14]=f,t[15]=m,t[16]=g,t[17]=y):y=t[17];let b;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(b=a&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(vt,{})).map(e=>{let[t,n]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,$.jsx)(ht,{provider:t}),t]}),n.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:Be(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x}function vt(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var yt=[{value:`build`,label:`Build`,icon:r},{value:`plan`,label:`Plan`,icon:se},{value:`image`,label:`Image`,icon:ce},{value:`ralph`,label:`Ralph`,icon:b}];function bt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function xt(e){let t=(0,Z.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Q.useState(!1),u=Q.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=bt(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=yt.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,v;t[6]===c?(g=t[7],v=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},v=[c],t[6]=c,t[7]=g,t[8]=v),Q.useEffect(g,v);let y;t[9]!==o||t[10]!==a||t[11]!==s?(y=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=y):y=t[12];let b=y,x;t[13]===c?x=t[14]:(x=()=>l(!c),t[13]=c,t[14]=x);let S;t[15]===h?S=t[16]:(S=(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=S);let C;t[17]===m.label?C=t[18]:(C=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=C);let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(A,{className:`h-3 w-3`}),t[19]=w):w=t[19];let T;t[20]!==x||t[21]!==S||t[22]!==C?(T=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:x,children:[S,C,w]}),t[20]=x,t[21]=S,t[22]=C,t[23]=T):T=t[23];let E;t[24]!==f||t[25]!==c||t[26]!==b?(E=c&&(0,$.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:yt.map(e=>{let t=e.icon,n=e.value===f;return(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>b(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(K,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=b,t[27]=E):E=t[27];let D;return t[28]!==T||t[29]!==E?(D=(0,$.jsxs)(`div`,{className:`relative`,ref:u,children:[T,E]}),t[28]=T,t[29]=E,t[30]=D):D=t[30],D}function St(e){let t=(0,Z.c)(17),{onFileAttach:r}=e,[i,a]=Q.useState(!1),o=Q.useRef(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};if(i)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},c=[i],t[0]=i,t[1]=s,t[2]=c),Q.useEffect(s,c);let l;t[3]===r?l=t[4]:(l=function(){r(),a(!1)},t[3]=r,t[4]=l);let u=l,d;t[5]===i?d=t[6]:(d=()=>a(!i),t[5]=i,t[6]=d);let f,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(n,{}),p=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=f,t[8]=p):(f=t[7],p=t[8]);let m;t[9]===d?m=t[10]:(m=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,onClick:d,children:[f,p]}),t[9]=d,t[10]=m);let h;t[11]!==u||t[12]!==i?(h=i&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:u,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=u,t[12]=i,t[13]=h):h=t[13];let g;return t[14]!==m||t[15]!==h?(g=(0,$.jsxs)(`div`,{className:`relative`,ref:o,children:[m,h]}),t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function Ct(e){let t=(0,Z.c)(14),{onToggleSpeech:n}=e,{isListening:r,isSupported:i}=tt();if(!i)return null;let a=r?`bg-red-500/20 text-red-500 hover:bg-red-500/30`:`text-muted-foreground hover:text-background`,o;t[0]===r?o=t[1]:(o=r?(0,$.jsx)(R,{}):(0,$.jsx)(L,{}),t[0]=r,t[1]=o);let s=r?`Stop listening`:`Start listening`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:s}),t[2]=s,t[3]=c);let l;t[4]!==n||t[5]!==a||t[6]!==o||t[7]!==c?(l=(0,$.jsx)(je,{asChild:!0,children:(0,$.jsxs)(_,{variant:`ghost`,size:`icon-sm`,className:a,onClick:n,children:[o,c]})}),t[4]=n,t[5]=a,t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=r?`Stop listening`:`Start listening`,d;t[9]===u?d=t[10]:(d=(0,$.jsx)(ke,{side:`top`,className:`bg-popover text-popover-foreground`,children:u}),t[9]=u,t[10]=d);let f;return t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Ae,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13],f}function wt(e){let t=(0,Z.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(ie,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function Tt(e){let t=(0,Z.c)(146),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,{isListening:f,transcript:p,startListening:h,stopListening:g,resetTranscript:v}=tt(),y;t[0]===o?y=t[1]:(y={initialValue:o},t[0]=o,t[1]=y);let{message:b,setMessage:x,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,availableModels:k,selectedModel:A,setSelectedModel:j,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,availableImageModels:te,selectedImageModel:ne,setSelectedImageModel:re,allFiles:ie,setAllFiles:ae,showSuggestions:B,setShowSuggestions:oe,suggestionQuery:V,setSuggestionQuery:H,selectedIndex:U,setSelectedIndex:W,slashCommands:G,skills:K,showCommandSuggestions:q,setShowCommandSuggestions:se,commandQuery:J,setCommandQuery:ce,fileInputRef:le,textareaRef:ue,suggestionsRef:de,commandSuggestionsRef:fe,state:pe,dispatch:me}=nt(y),he=z?ne:A,ge=z?te:k,_e=pe.selectedThreadId??void 0,ve;t[2]!==ie||t[3]!==N||t[4]!==J||t[5]!==D||t[6]!==me||t[7]!==w||t[8]!==S||t[9]!==z||t[10]!==f||t[11]!==u||t[12]!==b||t[13]!==n||t[14]!==F||t[15]!==L||t[16]!==v||t[17]!==ne||t[18]!==U||t[19]!==A||t[20]!==ae||t[21]!==P||t[22]!==ce||t[23]!==O||t[24]!==E||t[25]!==C||t[26]!==ee||t[27]!==x||t[28]!==I||t[29]!==R||t[30]!==W||t[31]!==se||t[32]!==oe||t[33]!==H||t[34]!==q||t[35]!==B||t[36]!==K||t[37]!==G||t[38]!==g||t[39]!==V||t[40]!==_e||t[41]!==ue?(ve={message:b,setMessage:x,attachments:N,selectedModel:A,onSend:n,isStreaming:u,selectedThreadId:_e,isListening:f,stopListening:g,resetTranscript:v,dispatch:me,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,showSuggestions:B,setShowSuggestions:oe,suggestionQuery:V,setSuggestionQuery:H,allFiles:ie,setAllFiles:ae,selectedIndex:U,setSelectedIndex:W,showCommandSuggestions:q,setShowCommandSuggestions:se,commandQuery:J,setCommandQuery:ce,slashCommands:G,skills:K,textareaRef:ue,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,selectedImageModel:ne},t[2]=ie,t[3]=N,t[4]=J,t[5]=D,t[6]=me,t[7]=w,t[8]=S,t[9]=z,t[10]=f,t[11]=u,t[12]=b,t[13]=n,t[14]=F,t[15]=L,t[16]=v,t[17]=ne,t[18]=U,t[19]=A,t[20]=ae,t[21]=P,t[22]=ce,t[23]=O,t[24]=E,t[25]=C,t[26]=ee,t[27]=x,t[28]=I,t[29]=R,t[30]=W,t[31]=se,t[32]=oe,t[33]=H,t[34]=q,t[35]=B,t[36]=K,t[37]=G,t[38]=g,t[39]=V,t[40]=_e,t[41]=ue,t[42]=ve):ve=t[42];let{handleSend:ye,handleKeyDown:be,handleTextareaInput:xe,insertFileReference:Se,insertCommand:Ce,insertSkill:we,fileSuggestions:Te}=it(ve),Ee=Q.useRef(``),Y,De;t[43]!==x||t[44]!==p?(Y=()=>{if(p&&p!==Ee.current){let e=p.substring(Ee.current.length);x(t=>(t.endsWith(` `),t+e)),Ee.current=p}},De=[p,x],t[43]=x,t[44]=p,t[45]=Y,t[46]=De):(Y=t[45],De=t[46]),Q.useEffect(Y,De);let X;t[47]===P?X=t[48]:(X=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Dt);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];P(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[47]=P,t[48]=X);let Oe=X,ke;t[49]!==f||t[50]!==v||t[51]!==h||t[52]!==g?(ke=()=>{f?(g(),v()):(v(),h())},t[49]=f,t[50]=v,t[51]=h,t[52]=g,t[53]=ke):ke=t[53];let Ae=ke,je=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Me=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,Ne;t[54]!==c||t[55]!==s?(Ne=(0,$.jsx)(wt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[54]=c,t[55]=s,t[56]=Ne):Ne=t[56];let Pe=L?`Describe stories for Ralph to implement autonomously...`:F?`Describe what you want Tarsk to plan...`:z?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,Fe;t[57]!==a||t[58]!==be||t[59]!==Oe||t[60]!==xe||t[61]!==b||t[62]!==Pe||t[63]!==ue?(Fe=(0,$.jsx)(`textarea`,{ref:ue,value:b,onChange:xe,onKeyDown:be,onPaste:Oe,placeholder:Pe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[57]=a,t[58]=be,t[59]=Oe,t[60]=xe,t[61]=b,t[62]=Pe,t[63]=ue,t[64]=Fe):Fe=t[64];let Ie;t[65]!==J||t[66]!==fe||t[67]!==Ce||t[68]!==we||t[69]!==U||t[70]!==W||t[71]!==q||t[72]!==K||t[73]!==G?(Ie=(0,$.jsx)(ct,{visible:q,commands:G,skills:K,query:J,selectedIndex:U,onSelectCommand:Ce,onSelectSkill:we,onMouseEnterSuggestion:W,containerRef:fe}),t[65]=J,t[66]=fe,t[67]=Ce,t[68]=we,t[69]=U,t[70]=W,t[71]=q,t[72]=K,t[73]=G,t[74]=Ie):Ie=t[74];let Le;t[75]!==Te||t[76]!==Se||t[77]!==U||t[78]!==W||t[79]!==B||t[80]!==V||t[81]!==de?(Le=(0,$.jsx)(mt,{showSuggestions:B,fileSuggestions:Te,suggestionQuery:V,selectedIndex:U,onSelectFile:Se,onMouseEnterSuggestion:W,containerRef:de}),t[75]=Te,t[76]=Se,t[77]=U,t[78]=W,t[79]=B,t[80]=V,t[81]=de,t[82]=Le):Le=t[82];let Re;t[83]!==N||t[84]!==A?.id||t[85]!==A?.name||t[86]!==A?.supportsImages||t[87]!==P?(Re=N.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(ft,{attachments:N,onRemove:e=>P(t=>t.filter((t,n)=>n!==e))}),N.some(Et)&&A?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,$.jsx)(m,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,A?.name||A?.id]})]})]}),t[83]=N,t[84]=A?.id,t[85]=A?.name,t[86]=A?.supportsImages,t[87]=P,t[88]=Re):Re=t[88];let ze;t[89]===le?ze=t[90]:(ze=(0,$.jsx)(St,{onFileAttach:()=>le.current?.click()}),t[89]=le,t[90]=ze);let Be;t[91]===Ae?Be=t[92]:(Be=(0,$.jsx)(Ct,{onToggleSpeech:Ae}),t[91]=Ae,t[92]=Be);let Ve=z?re:j,He;t[93]!==ge||t[94]!==he||t[95]!==Ve?(He=(0,$.jsx)(_t,{availableModels:ge,selectedModel:he,onModelSelect:Ve}),t[93]=ge,t[94]=he,t[95]=Ve,t[96]=He):He=t[96];let Ue;t[97]!==ze||t[98]!==Be||t[99]!==He?(Ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ze,Be,He]}),t[97]=ze,t[98]=Be,t[99]=He,t[100]=Ue):Ue=t[100];let We;t[101]!==z||t[102]!==F||t[103]!==L||t[104]!==ee||t[105]!==I||t[106]!==R?(We=(0,$.jsx)(xt,{planMode:F,imageMode:z,ralphMode:L,setPlanMode:I,setImageMode:ee,setRalphMode:R}),t[101]=z,t[102]=F,t[103]=L,t[104]=ee,t[105]=I,t[106]=R,t[107]=We):We=t[107];let Ge=u?r:ye,Ke;t[108]!==N.length||t[109]!==a||t[110]!==he||t[111]!==u||t[112]!==b?(Ke=!u&&((a??!1)||!b.trim()&&N.length===0||!he),t[108]=N.length,t[109]=a,t[110]=he,t[111]=u,t[112]=b,t[113]=Ke):Ke=t[113];let qe;t[114]===u?qe=t[115]:(qe=u?(0,$.jsx)(T,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(M,{className:`h-3 w-3`}),t[114]=u,t[115]=qe);let Je=u?`Stop generation`:`Send message`,Ye;t[116]===Je?Ye=t[117]:(Ye=(0,$.jsx)(`span`,{className:`sr-only`,children:Je}),t[116]=Je,t[117]=Ye);let Xe;t[118]!==Ge||t[119]!==Ke||t[120]!==qe||t[121]!==Ye?(Xe=(0,$.jsxs)(_,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:Ge,disabled:Ke,children:[qe,Ye]}),t[118]=Ge,t[119]=Ke,t[120]=qe,t[121]=Ye,t[122]=Xe):Xe=t[122];let Ze;t[123]!==We||t[124]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[We,Xe]}),t[123]=We,t[124]=Xe,t[125]=Ze):Ze=t[125];let Qe;t[126]!==Ue||t[127]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Ue,Ze]}),t[126]=Ue,t[127]=Ze,t[128]=Qe):Qe=t[128];let $e;t[129]!==Me||t[130]!==Ne||t[131]!==Fe||t[132]!==Ie||t[133]!==Le||t[134]!==Re||t[135]!==Qe?($e=(0,$.jsxs)(`div`,{className:Me,children:[Ne,Fe,Ie,Le,Re,Qe]}),t[129]=Me,t[130]=Ne,t[131]=Fe,t[132]=Ie,t[133]=Le,t[134]=Re,t[135]=Qe,t[136]=$e):$e=t[136];let et;t[137]===P?et=t[138]:(et=e=>pt(e,e=>P(t=>[...t,...e])),t[137]=P,t[138]=et);let rt;t[139]!==le||t[140]!==et?(rt=(0,$.jsx)(`input`,{ref:le,type:`file`,multiple:!0,className:`hidden`,onChange:et}),t[139]=le,t[140]=et,t[141]=rt):rt=t[141];let at;return t[142]!==je||t[143]!==$e||t[144]!==rt?(at=(0,$.jsxs)(`div`,{className:je,children:[$e,rt]}),t[142]=je,t[143]=$e,t[144]=rt,t[145]=at):at=t[145],at}function Et(e){return e.mimeType.startsWith(`image/`)}function Dt(e){return e.type.startsWith(`image/`)}var Ot=ge,kt=Ce,At=he,jt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(y,{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)(xe,{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});jt.displayName=xe.displayName;var Mt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(Se,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Mt.displayName=Se.displayName;var Nt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(ye,{children:(0,$.jsx)(ve,{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});Nt.displayName=ve.displayName;var Pt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(fe,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Pt.displayName=fe.displayName;var Ft=Q.forwardRef((e,t)=>{let n=(0,Z.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=E(`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`,a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(be,{children:(0,$.jsx)(K,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(_e,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});Ft.displayName=_e.displayName;var It=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(be,{children:(0,$.jsx)(G,{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)(pe,{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});It.displayName=pe.displayName;var Lt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`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)(me,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Lt.displayName=me.displayName;var Rt=Q.forwardRef((e,t)=>{let n=(0,Z.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=E(`-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)(Te,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Rt.displayName=Te.displayName;var zt=e=>{let t=(0,Z.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=E(`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};zt.displayName=`DropdownMenuShortcut`;function Bt(e){let t=(0,Z.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s}=e,c;t[0]===o?c=t[1]:(c=e=>{e&&o()},t[0]=o,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=l):l=t[2];let u=n||`Unknown`,d;t[3]===u?d=t[4]:(d=(0,$.jsx)(kt,{asChild:!0,children:(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[l,u]})}),t[3]=u,t[4]=d);let f;t[5]!==r||t[6]!==n||t[7]!==a||t[8]!==i||t[9]!==s?(f=i?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(ee,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,$.jsxs)(Pt,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=r,t[6]=n,t[7]=a,t[8]=i,t[9]=s,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,$.jsx)(Nt,{align:`start`,children:f}),t[11]=f,t[12]=p);let m;return t[13]!==c||t[14]!==d||t[15]!==p?(m=(0,$.jsxs)(Ot,{onOpenChange:c,children:[d,p]}),t[13]=c,t[14]=d,t[15]=p,t[16]=m):m=t[16],m}var Vt=3e4;function Ht(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(void 0),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(`Up to date`),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(void 0),[D,O]=(0,Q.useState)(void 0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=(0,Q.useRef)(!0),P=(0,Q.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,Q.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>M(!0),100);try{let n=`unified-git-status-${e}`;t&&le.invalidate(n),P(await le.get(n,()=>ne(e,t),Vt))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),M(!1)}},[e,P]);return(0,Q.useEffect)(()=>{e&&(async()=>{if(N.current){let t=`unified-git-status-${e}`,n=le.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 Ut(e){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=Ht(e);async function c(){if(!(!e||r)){i(!0);try{n((await f(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await p(e,t),await s.fetchUnifiedStatus(!0),Me({title:`Switched to branch "${t}"`})}catch(e){Me({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}return{currentBranch:s.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:c,checkoutBranch:l,fetchUnifiedStatus:s.fetchUnifiedStatus}}function Wt({threadId:e}){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(null),a=Ut(e);return(0,Q.useEffect)(()=>{e&&H(e).then(i).catch(()=>{})},[e]),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,$.jsx)(Bt,{currentBranch:a.currentBranch,availableBranches:a.availableBranches,isLoadingBranches:a.isLoadingBranches,isCheckingOut:a.isCheckingOut,onLoadBranches:a.loadBranches,onCheckoutBranch:a.checkoutBranch}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:e&&(0,$.jsxs)(Ae,{children:[(0,$.jsx)(je,{asChild:!0,children:(0,$.jsx)(_,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background`,onClick:async()=>{if(!(!e||t)){n(!0);try{let t=await H(e);await navigator.clipboard.writeText(t)}finally{n(!1)}}},disabled:t,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(te,{className:`h-3.5 w-3.5 mr-1`})})}),(0,$.jsxs)(ke,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),r&&(0,$.jsx)(`div`,{className:`opacity-70 text-xs`,children:r})]})]})})]})}function Gt(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&$e(e.id,e.input.code,t)}catch{}}function Kt(){let{state:e,dispatch:t}=Ee(),[n,r]=(0,Q.useState)(null),[i,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(``),c=(0,Q.useRef)(``),l=(0,Q.useRef)([]),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(()=>{}),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),{selectedThreadId:x,selectedProjectId:S,messages:C,queuedChatMessages:w,isStreaming:T,streamingModel:E,processingThreadIds:O}=e,A=!!(x&&O.includes(x)),j=(0,Q.useCallback)(n=>{if(d.current=null,f.current=null,g.current){g.current=!1;return}let r=l.current,i=De(r)||`...`;if(v.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${v.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:X.AddMessage,message:r}),t({type:X.ResetStream}),x&&t({type:X.RemoveProcessingThread,threadId:x}),v.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};s.current=``,c.current=``,l.current=[],v.current=null,t({type:X.AddMessage,message:a}),t({type:X.ResetStream}),x&&(t({type:X.MarkThreadCompleted,threadId:x}),t({type:X.RemoveProcessingThread,threadId:x}))},[e.streamingModel,t,x]);(0,Q.useEffect)(()=>{p.current=j},[j]);let M=(0,Q.useCallback)(()=>{x&&h(x),g.current=!0,x&&P(x),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],v.current=null;let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:X.AddMessage,message:n}),t({type:X.ResetStream}),x&&(t({type:X.MarkThreadCompleted,threadId:x}),t({type:X.RemoveProcessingThread,threadId:x}))},[x,t,e.streamingModel]);(0,Q.useEffect)(()=>{_.current&&!T&&d.current&&(d.current.abort(),d.current=null,f.current&&=(f.current(),null),p.current(E||`default`)),_.current=T},[T,E]),(0,Q.useEffect)(()=>{if(y.current&&=(clearTimeout(y.current),null),T){let e=12e4,t=n=>{y.current&&=(clearTimeout(y.current),null),y.current=setTimeout(()=>{let n=Date.now(),r=b?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),p.current(E||`default`)},n)},n=e;if(b?.current!=null){let t=Date.now()-b.current;n=t>=e?0:e-t}t(n)}return()=>{y.current&&=(clearTimeout(y.current),null)}},[T,E]),(0,Q.useEffect)(()=>()=>{d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,t({type:X.ResetStream})},[x,t]),(0,Q.useEffect)(()=>{if(!x)return;let e=!1;async function n(){try{let n=await q(x);e||t({type:X.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:X.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[x,S,t]),(0,Q.useEffect)(()=>{if(!x||!A||T)return;let e=new AbortController;return d.current=e,t({type:X.ResetStream}),t({type:X.SetStreaming,isStreaming:!0}),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,W(x,e.signal).then(n=>{if(!n||e.signal.aborted){p.current(`default`);return}f.current=k(n,e=>{if(t({type:X.IncrementStreamEventCount}),e.type===`error`){let t=e.content||`Unknown error occurred`;v.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:X.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:X.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){let n=e.content??``;Gt(n,x),c.current+=n;let r=Y(l.current,`thinking`,n);l.current=r,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:n,segments:r})}else if(e.type===`result`)u.current=!0,s.current=e.content??``,l.current=Oe(l.current,e.content??``),t({type:X.SetStreamContent,content:e.content??``});else{if(u.current)return;s.current+=e.content??``;let n=Y(l.current,`content`,e.content??``);l.current=n,t({type:X.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{p.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(`default`);return}v.current=e,r(e)},e=>{if(t({type:X.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=Y(l.current,`thinking`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=Oe(l.current,r),t({type:X.SetStreamContent,content:r});else{s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:X.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:X.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:X.ResetStream})}),()=>{e.abort(),f.current&&=(f.current(),null)}},[x,A]);let F=(0,Q.useCallback)(async(n,i,m,g,_,y,b)=>{if(!x)return;r(null),h(null),d.current&&d.current.abort(),f.current&&f.current();let C=`msg-${Date.now()}`,w;try{let e=await a(x,C);e.success&&e.stashed&&e.checkpointRef&&(w=e.checkpointRef)}catch{}let T={messageId:C,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:m.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:w};t({type:X.AddMessage,message:T});let E=n.trim().replace(/\n/g,` `).slice(0,100);if(S&&x&&(N(x,{title:E}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:X.UpdateThreadTitle,projectId:S,threadId:x,title:E})),y){let e=g??void 0;if(!e&&typeof i==`string`){let t=i.split(/[:/]/)[0]?.trim();t&&(e=t)}if(!e){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:X.AddMessage,message:e}),t({type:X.ResetStream});return}t({type:X.SetStreaming,isStreaming:!0});try{let r=await D(n,i,e,x),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};t({type:X.AddMessage,message:a})}catch(e){let n=e instanceof Error?e.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:X.AddMessage,message:r})}finally{t({type:X.ResetStream})}return}t({type:X.ResetStream}),t({type:X.SetStreaming,isStreaming:!0}),s.current=``,u.current=!1;let O=new AbortController;d.current=O;try{let a=await U(x,n,i,m,O.signal,g,_,b);if(!a){p.current(i);return}f.current=k(a,n=>{if(t({type:X.IncrementStreamEventCount}),n.type===`error`){let e=n.content||`Unknown error occurred`;v.current=e,r(e);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){if(n.partial?.content?.[0]?.id&&n.delta){let e=n.partial.content[0].id,r=n.partial.content[0].name;t({type:X.UpdateToolCallProgress,toolCallId:e,progress:{toolCallId:e,toolName:r,delta:n.delta,partial:n.partial}})}return}if(n.model&&t({type:X.SetStreamModel,model:n.model}),n.type===`thinking`||n.isThinking){let r=n.content??``;Gt(r,e.selectedThreadId),c.current+=r;let i=Y(l.current,`thinking`,r);l.current=i,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:i})}else if(n.type===`result`)u.current=!0,s.current=n.content??``,l.current=Oe(l.current,n.content??``),t({type:X.SetStreamContent,content:n.content??``});else{if(u.current)return;s.current+=n.content??``;let e=Y(l.current,`content`,n.content??``);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:n.content??``,segments:e})}}},()=>{p.current(i)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(i);return}v.current=e,r(e)},e=>{if(t({type:X.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=Y(l.current,`thinking`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=Oe(l.current,r),t({type:X.SetStreamContent,content:r});else{s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof ue){t({type:X.ResetStream}),o(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),v.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:X.ResetStream})}},[x,S,t]);(0,Q.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||T||n.threadId!==x)return;let r=setTimeout(()=>{t({type:X.ClearPendingChatMessage}),F(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,T,x,t,F]);let I=(0,Q.useMemo)(()=>x?w.filter(e=>e.threadId===x):[],[x,w]),L=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(T||!x||I.length===0||L.current)return;let[e]=I;L.current=!0,t({type:X.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{F(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),L.current=!1},0);return()=>{clearTimeout(n),L.current=!1}},[t,F,T,I,x]),{error:n,setError:r,handleSend:F,handleStop:M,isStreaming:T,selectedThreadId:x,queuedMessagesForThread:I,handleRemoveQueuedMessage:(0,Q.useCallback)(e=>{let n=I.find(t=>t.id===e);t({type:X.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||T||C.length>0||!x)&&F(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,F,T,C.length,I,x]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:o}}function qt(e){let t=(0,Z.c)(10),{open:n,onClose:r}=e,i=we(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(Le,{children:[(0,$.jsx)(Pe,{children:`Balance empty`}),(0,$.jsx)(Ne,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(Fe,{children:[o,(0,$.jsx)(Ie,{children:(0,$.jsx)(_,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Re,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Jt(e){let t=(0,Z.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(Xt),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(Yt),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Yt(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,$.jsx)(O,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(u,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(G,{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 Xt(e){return e.status===`done`}function Zt(){let e=(0,Z.c)(16),{todos:t}=(0,Q.useContext)(Ue),[n,r]=(0,Q.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Qt),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),s=(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=s):(o=e[2],s=e[3]);let l;e[4]!==a||e[5]!==t.length?(l=(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[s,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(c,{children:(0,$.jsx)(w,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,$.jsxs)(de,{className:`max-w-md`,children:[u,(0,$.jsx)(Jt,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,$.jsx)(x,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==l||e[14]!==f?(p=(0,$.jsxs)($.Fragment,{children:[l,f]}),e[13]=l,e[14]=f,e[15]=p):p=e[15],p}function Qt(e){return e.status===`done`}function $t(e){let t=(0,Z.c)(34),{messages:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?[]:r,t[0]=r,t[1]=i);let a=i,{state:s,dispatch:c}=Ee(),{isCreatingProject:l,selectedThreadId:u}=s,{handleSend:d,handleStop:f,isStreaming:p,queuedMessagesForThread:m,handleRemoveQueuedMessage:h,showEmptyBalanceDialog:g,setShowEmptyBalanceDialog:v}=Kt(),y=s.pendingChatMessage?.threadId===u,b=p||y,x=a.length>0,{hasChanges:S,changedFilesCount:C}=Ht(u??void 0),{setActiveMainTab:w}=ze(),T;t[2]!==c||t[3]!==u?(T=async()=>{if(u)try{let e=await J(u);c({type:X.ClearMessages}),console.log(`New conversation started:`,e);let t=await q(u);c({type:X.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=c,t[3]=u,t[4]=T):T=t[4];let E=T,D;t[5]===v?D=t[6]:(D=()=>v(!1),t[5]=v,t[6]=D);let O;t[7]!==g||t[8]!==D?(O=(0,$.jsx)(qt,{open:g,onClose:D}),t[7]=g,t[8]=D,t[9]=O):O=t[9];let k;t[10]!==C||t[11]!==E||t[12]!==S||t[13]!==x||t[14]!==w?(k=x&&(0,$.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8`,children:[(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:E,children:[(0,$.jsx)(n,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),S&&(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2 ml-2`,onClick:()=>w(`review`),children:[(0,$.jsx)(o,{className:`h-4 w-4 shrink-0`}),C,` `,C===1?`File`:`Files`,` Changed`]}),(0,$.jsx)(Zt,{})]}),t[10]=C,t[11]=E,t[12]=S,t[13]=x,t[14]=w,t[15]=k):k=t[15];let A=!u&&!l,j;t[16]!==b||t[17]!==h||t[18]!==d||t[19]!==f||t[20]!==m||t[21]!==A?(j=(0,$.jsx)(Tt,{onSend:d,onStop:f,isStreaming:b,disabled:A,initialValue:``,queuedMessages:m,onRemoveQueuedMessage:h,isOverlay:!1}),t[16]=b,t[17]=h,t[18]=d,t[19]=f,t[20]=m,t[21]=A,t[22]=j):j=t[22];let M;t[23]!==k||t[24]!==j?(M=(0,$.jsxs)(`div`,{className:`relative`,children:[k,j]}),t[23]=k,t[24]=j,t[25]=M):M=t[25];let N=u??void 0,P;t[26]===N?P=t[27]:(P=(0,$.jsx)(Wt,{threadId:N}),t[26]=N,t[27]=P);let F;t[28]!==P||t[29]!==M?(F=(0,$.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[M,P]}),t[28]=P,t[29]=M,t[30]=F):F=t[30];let I;return t[31]!==F||t[32]!==O?(I=(0,$.jsxs)($.Fragment,{children:[O,F]}),t[31]=F,t[32]=O,t[33]=I):I=t[33],I}export{He as _,Pt as a,Mt as c,$e as d,Ye as f,Ge as g,We as h,Nt as i,jt as l,Ke as m,Ht as n,Rt as o,Xe as p,Ot as r,At as s,$t as t,kt as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Qi as n,Wn as r,da as i,la as a,qi as o,ta as s}from"./dialogs-config-3Hr2GRdt.js";import{a as c,d as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,s as _,t as v,u as y}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Qi as n,Wn as r,da as i,la as a,qi as o,ta as s}from"./dialogs-config-3Hr2GRdt.js";import{a as c,d as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,s as _,t as v,u as y}from"./react-vendor-BX34Jw0L.js";var b=a(),x=e(i(),1),S=t(),C=y,w=u,T=x.forwardRef((e,t)=>{let i=(0,b.c)(14),a,o,s,c;i[0]===e?(a=i[1],o=i[2],s=i[3],c=i[4]):({className:o,inset:s,children:a,...c}=e,i[0]=e,i[1]=a,i[2]=o,i[3]=s,i[4]=c);let l=s&&`pl-8`,u;i[5]!==o||i[6]!==l?(u=r(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,o),i[5]=o,i[6]=l,i[7]=u):u=i[7];let d;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(n,{className:`ml-auto h-4 w-4`}),i[8]=d):d=i[8];let f;return i[9]!==a||i[10]!==c||i[11]!==t||i[12]!==u?(f=(0,S.jsxs)(p,{ref:t,className:u,...c,children:[a,d]}),i[9]=a,i[10]=c,i[11]=t,i[12]=u,i[13]=f):f=i[13],f});T.displayName=p.displayName;var E=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(g,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});E.displayName=g.displayName;var D=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(_,{children:(0,S.jsx)(m,{ref:t,className:o,...a})}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});D.displayName=m.displayName;var O=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(d,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});O.displayName=d.displayName;var k=x.forwardRef((e,t)=>{let n=(0,b.c)(14),i,a,o,l;n[0]===e?(i=n[1],a=n[2],o=n[3],l=n[4]):({className:o,children:a,checked:i,...l}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o,n[4]=l);let u;n[5]===o?u=n[6]:(u=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),n[5]=o,n[6]=u);let d;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(s,{className:`h-4 w-4`})})}),n[7]=d):d=n[7];let f;return n[8]!==i||n[9]!==a||n[10]!==l||n[11]!==t||n[12]!==u?(f=(0,S.jsxs)(v,{ref:t,className:u,checked:i,...l,children:[d,a]}),n[8]=i,n[9]=a,n[10]=l,n[11]=t,n[12]=u,n[13]=f):f=n[13],f});k.displayName=v.displayName;var A=x.forwardRef((e,t)=>{let n=(0,b.c)(12),i,a,s;n[0]===e?(i=n[1],a=n[2],s=n[3]):({className:a,children:i,...s}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=s);let l;n[4]===a?l=n[5]:(l=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),n[4]=a,n[5]=l);let u;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(o,{className:`h-2 w-2 fill-current`})})}),n[6]=u):u=n[6];let d;return n[7]!==i||n[8]!==s||n[9]!==t||n[10]!==l?(d=(0,S.jsxs)(f,{ref:t,className:l,...s,children:[u,i]}),n[7]=i,n[8]=s,n[9]=t,n[10]=l,n[11]=d):d=n[11],d});A.displayName=f.displayName;var j=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(h,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});j.displayName=h.displayName;var M=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`-mx-1 my-1 h-px bg-border`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(l,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});M.displayName=l.displayName;var N=e=>{let t=(0,b.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`ml-auto text-xs tracking-widest text-muted-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$i as n,Ai as r,Bt as i,Cr as a,Et as o,Hn as s,Ni as c,Pn as l,Qi as u,Rn as d,Un as f,Vn as p,Wn as m,Zr as h,at as g,bn as _,da as v,gi as y,ii as b,ji as x,kn as S,la as C,mi as w,pi as T,q as E,ri as D,ui as O,zn as ee}from"./dialogs-config-3Hr2GRdt.js";import{_ as k}from"./react-vendor-4OUTOTE0.js";import{a as A,t as j}from"./store-CJdxpohI.js";import{t as M}from"./textarea-Dg4M60Yx.js";import{c as N,s as P,u as te}from"./history-view-Cyhu-ped.js";import{l as ne,t as re}from"./chat-input-container-VXGAcgnU.js";import{t as F}from"./standard-list-item-DUKJ8HEG.js";import{n as ie}from"./utils-4yrqj6yI.js";import{t as ae}from"./page-toolbar-De9hbhUD.js";import{n as oe,r as se,t as I}from"./resizable-D62plzWh.js";import{a as L,n as R,r as ce,t as z}from"./context-menu-sx0fb5uQ.js";var B=e(v(),1),V=C(),H=a();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:o}),t[2]=o,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=(0,H.jsx)(S,{className:`flex-1`,children:n}),t[9]=n,t[10]=u);let d;t[11]===a?d=t[12]:(d=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=d);let f;return t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[l,u,d]}),t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function le(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return m(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function ue(e){return G[e]??`M`}function de(e){let t=(0,V.c)(37),{treeData:n,files:i,isLoading:a,error:o,selectedFileIndex:s,onFileSelect:l,onRevertFile:d}=e,f;t[0]===i?f=t[1]:(f=i.reduce(pe,0),t[0]=i,t[1]=f);let p=f,g;t[2]===i?g=t[3]:(g=i.reduce(q,0),t[2]=i,t[3]=g);let _=g,v=i.length===1?``:`s`,b;t[4]!==i.length||t[5]!==v?(b=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` file`,v]}),t[4]=i.length,t[5]=v,t[6]=b):b=t[6];let S;t[7]===p?S=t[8]:(S=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,p]}),t[7]=p,t[8]=S);let C;t[9]===_?C=t[10]:(C=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),t[9]=_,t[10]=C);let w;t[11]!==b||t[12]!==S||t[13]!==C?(w=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b,S,C]}),t[11]=b,t[12]=S,t[13]=C,t[14]=w):w=t[14];let T=w;if(a){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(y,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),t[15]=e):e=t[15];let n;return t[16]===T?n=t[17]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[16]=T,t[17]=n),n}if(o){let e;t[18]===o?e=t[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:o})}),t[18]=o,t[19]=e);let n;return t[20]!==T||t[21]!==e?(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[20]=T,t[21]=e,t[22]=n):n=t[22],n}if(i.length===0){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),t[23]=e):e=t[23];let n;return t[24]===T?n=t[25]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[24]=T,t[25]=n),n}let E;t[26]!==i||t[27]!==l||t[28]!==d||t[29]!==s?(E=(e,t)=>{let{isOpen:n,toggle:a}=t,o=!!e.children,f=(0,H.jsxs)(F,{onClick:()=>{o?a():e.fileIndex!==void 0&&l(e.fileIndex)},selected:!o&&e.fileIndex===s,className:`gap-1.5`,children:[o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{className:m(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)}),n?(0,H.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!o&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:ue(e.status)})]});return o?f:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:f}),(0,H.jsx)(R,{children:(0,H.jsxs)(ce,{onClick:()=>{e.fileIndex!==void 0&&d?.(i[e.fileIndex])},children:[(0,H.jsx)(h,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},t[26]=i,t[27]=l,t[28]=d,t[29]=s,t[30]=E):E=t[30];let D;t[31]!==E||t[32]!==n?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(ne,{nodes:n,defaultOpen:!0,resetKey:n,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:E})}),t[31]=E,t[32]=n,t[33]=D):D=t[33];let O;return t[34]!==T||t[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:D}),t[34]=T,t[35]=D,t[36]=O):O=t[36],O}function q(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(fe).length}function fe(e){return e.type===`delete`}function pe(e,t){return e+t.hunks.reduce(Y,0)}function Y(e,t){return e+t.changes.filter(me).length}function me(e){return e.type===`add`}function he(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function ge(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:i,initialComment:a,isEditing:o,onSave:c,onDelete:u,onClose:m}=e,[h,g]=(0,B.useState)((a===void 0?``:a)??``),_;t[0]!==c||t[1]!==h?(_=()=>{h.trim()&&c(h.trim())},t[0]=c,t[1]=h,t[2]=_):_=t[2];let v=_,y;t[3]===v?y=t[4]:(y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),v())},t[3]=v,t[4]=y);let b=y,x;t[5]===m?x=t[6]:(x=e=>{e||m()},t[5]=m,t[6]=x);let S;t[7]===r?S=t[8]:(S=(0,H.jsx)(s,{children:(0,H.jsxs)(f,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=S);let C=i||` `,w;t[9]===C?w=t[10]:(w=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:C}),t[9]=C,t[10]=w);let T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>g(e.target.value),t[11]=T):T=t[11];let E;t[12]!==b||t[13]!==h?(E=(0,H.jsx)(M,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:h,onChange:T,onKeyDown:b,rows:12,className:`resize-none text-sm`}),t[12]=b,t[13]=h,t[14]=E):E=t[14];let D;t[15]!==o||t[16]!==u?(D=o&&u&&(0,H.jsx)(l,{variant:`destructive`,size:`sm`,onClick:u,className:`mr-auto`,children:`Delete`}),t[15]=o,t[16]=u,t[17]=D):D=t[17];let O;t[18]===h?O=t[19]:(O=h.trim(),t[18]=h,t[19]=O);let k=!O,A;t[20]!==v||t[21]!==k?(A=(0,H.jsx)(l,{size:`sm`,onClick:v,disabled:k,children:`Save`}),t[20]=v,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==D||t[24]!==A?(j=(0,H.jsxs)(p,{className:`gap-2 sm:gap-0`,children:[D,A]}),t[23]=D,t[24]=A,t[25]=j):j=t[25];let N;t[26]!==j||t[27]!==S||t[28]!==w||t[29]!==E?(N=(0,H.jsxs)(ee,{className:`max-w-2xl`,children:[S,w,E,j]}),t[26]=j,t[27]=S,t[28]=w,t[29]=E,t[30]=N):N=t[30];let P;return t[31]!==n||t[32]!==N||t[33]!==x?(P=(0,H.jsx)(d,{open:n,onOpenChange:x,children:N}),t[31]=n,t[32]=N,t[33]=x,t[34]=P):P=t[34],P}function X({threadId:e,onExit:r}){let{state:a,dispatch:s}=A(),{resolvedTheme:c}=ie(),[d,f]=(0,B.useState)([]),[p,h]=(0,B.useState)(!0),[v,y]=(0,B.useState)(null),[x,S]=(0,B.useState)(0),[C,ee]=(0,B.useState)(!1),[M,ne]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>a.diffComments[e]??[],[a.diffComments,e]),L=(0,B.useCallback)(t=>{let n=a.diffComments[e]??[],r=typeof t==`function`?t(n):t;s({type:j.SetDiffComments,threadId:e,comments:r})},[s,e,a.diffComments]),[R,ce]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),ue=(0,B.useRef)(R),q=(0,B.useRef)({isFullView:C,selectedFileIndex:x,files:d}),J=(0,B.useRef)({original:[],modified:[]}),fe=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{ue.current=R},[R]),(0,B.useEffect)(()=>{q.current={isFullView:C,selectedFileIndex:x,files:d}},[C,x,d]);let pe=(0,B.useCallback)(()=>{F.current&&(M?F.current.expand():F.current.collapse())},[M]),Y=(0,B.useCallback)(async()=>{if(e){h(!0),y(null);try{f((await g(e)).files||[]),S(0)}catch(e){y(e instanceof Error?e.message:`Failed to load diff`)}finally{h(!1)}}},[e]);(0,B.useEffect)(()=>{Y()},[Y]);let me=(0,B.useCallback)(async t=>{try{await i(e,t.path),await Y()}catch(e){y(e instanceof Error?e.message:`Failed to revert file`)}},[e,Y]),X=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((a.diffComments[e]??[]).length>0){X.current=!0;return}o(e).then(t=>{t.diffComments&&t.diffComments.length>0&&s({type:j.SetDiffComments,threadId:e,comments:t.diffComments}),X.current=!0}).catch(()=>{X.current=!0})},[e]),(0,B.useEffect)(()=>{X.current&&_(e,{diffComments:I}).catch(()=>{})},[e,I]);let _e=(0,B.useMemo)(()=>le(d),[d]),Z=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},ve=(e,t,n)=>e.split(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$i as n,Ai as r,Bt as i,Cr as a,Et as o,Hn as s,Ni as c,Pn as l,Qi as u,Rn as d,Un as f,Vn as p,Wn as m,Zr as h,at as g,bn as _,da as v,gi as y,ii as b,ji as x,kn as S,la as C,mi as w,pi as T,q as E,ri as D,ui as O,zn as ee}from"./dialogs-config-3Hr2GRdt.js";import{_ as k}from"./react-vendor-BX34Jw0L.js";import{a as A,t as j}from"./store-xK3nfJ3V.js";import{t as M}from"./textarea-Dg4M60Yx.js";import{c as N,s as P,u as te}from"./history-view-Cyhu-ped.js";import{_ as ne,t as re}from"./chat-input-container-fUw0AY1R.js";import{t as F}from"./standard-list-item-DUKJ8HEG.js";import{n as ie}from"./utils-4yrqj6yI.js";import{t as ae}from"./page-toolbar-De9hbhUD.js";import{n as oe,r as se,t as I}from"./resizable-asBmgm9X.js";import{a as L,n as R,r as ce,t as z}from"./context-menu-5lS4H_pS.js";var B=e(v(),1),V=C(),H=a();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:o}),t[2]=o,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=(0,H.jsx)(S,{className:`flex-1`,children:n}),t[9]=n,t[10]=u);let d;t[11]===a?d=t[12]:(d=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=d);let f;return t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[l,u,d]}),t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function le(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return m(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function ue(e){return G[e]??`M`}function de(e){let t=(0,V.c)(37),{treeData:n,files:i,isLoading:a,error:o,selectedFileIndex:s,onFileSelect:l,onRevertFile:d}=e,f;t[0]===i?f=t[1]:(f=i.reduce(pe,0),t[0]=i,t[1]=f);let p=f,g;t[2]===i?g=t[3]:(g=i.reduce(q,0),t[2]=i,t[3]=g);let _=g,v=i.length===1?``:`s`,b;t[4]!==i.length||t[5]!==v?(b=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` file`,v]}),t[4]=i.length,t[5]=v,t[6]=b):b=t[6];let S;t[7]===p?S=t[8]:(S=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,p]}),t[7]=p,t[8]=S);let C;t[9]===_?C=t[10]:(C=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),t[9]=_,t[10]=C);let w;t[11]!==b||t[12]!==S||t[13]!==C?(w=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b,S,C]}),t[11]=b,t[12]=S,t[13]=C,t[14]=w):w=t[14];let T=w;if(a){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(y,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),t[15]=e):e=t[15];let n;return t[16]===T?n=t[17]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[16]=T,t[17]=n),n}if(o){let e;t[18]===o?e=t[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:o})}),t[18]=o,t[19]=e);let n;return t[20]!==T||t[21]!==e?(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[20]=T,t[21]=e,t[22]=n):n=t[22],n}if(i.length===0){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),t[23]=e):e=t[23];let n;return t[24]===T?n=t[25]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[24]=T,t[25]=n),n}let E;t[26]!==i||t[27]!==l||t[28]!==d||t[29]!==s?(E=(e,t)=>{let{isOpen:n,toggle:a}=t,o=!!e.children,f=(0,H.jsxs)(F,{onClick:()=>{o?a():e.fileIndex!==void 0&&l(e.fileIndex)},selected:!o&&e.fileIndex===s,className:`gap-1.5`,children:[o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{className:m(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)}),n?(0,H.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!o&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:ue(e.status)})]});return o?f:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:f}),(0,H.jsx)(R,{children:(0,H.jsxs)(ce,{onClick:()=>{e.fileIndex!==void 0&&d?.(i[e.fileIndex])},children:[(0,H.jsx)(h,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},t[26]=i,t[27]=l,t[28]=d,t[29]=s,t[30]=E):E=t[30];let D;t[31]!==E||t[32]!==n?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(ne,{nodes:n,defaultOpen:!0,resetKey:n,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:E})}),t[31]=E,t[32]=n,t[33]=D):D=t[33];let O;return t[34]!==T||t[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:D}),t[34]=T,t[35]=D,t[36]=O):O=t[36],O}function q(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(fe).length}function fe(e){return e.type===`delete`}function pe(e,t){return e+t.hunks.reduce(Y,0)}function Y(e,t){return e+t.changes.filter(me).length}function me(e){return e.type===`add`}function he(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function ge(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:i,initialComment:a,isEditing:o,onSave:c,onDelete:u,onClose:m}=e,[h,g]=(0,B.useState)((a===void 0?``:a)??``),_;t[0]!==c||t[1]!==h?(_=()=>{h.trim()&&c(h.trim())},t[0]=c,t[1]=h,t[2]=_):_=t[2];let v=_,y;t[3]===v?y=t[4]:(y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),v())},t[3]=v,t[4]=y);let b=y,x;t[5]===m?x=t[6]:(x=e=>{e||m()},t[5]=m,t[6]=x);let S;t[7]===r?S=t[8]:(S=(0,H.jsx)(s,{children:(0,H.jsxs)(f,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=S);let C=i||` `,w;t[9]===C?w=t[10]:(w=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:C}),t[9]=C,t[10]=w);let T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>g(e.target.value),t[11]=T):T=t[11];let E;t[12]!==b||t[13]!==h?(E=(0,H.jsx)(M,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:h,onChange:T,onKeyDown:b,rows:12,className:`resize-none text-sm`}),t[12]=b,t[13]=h,t[14]=E):E=t[14];let D;t[15]!==o||t[16]!==u?(D=o&&u&&(0,H.jsx)(l,{variant:`destructive`,size:`sm`,onClick:u,className:`mr-auto`,children:`Delete`}),t[15]=o,t[16]=u,t[17]=D):D=t[17];let O;t[18]===h?O=t[19]:(O=h.trim(),t[18]=h,t[19]=O);let k=!O,A;t[20]!==v||t[21]!==k?(A=(0,H.jsx)(l,{size:`sm`,onClick:v,disabled:k,children:`Save`}),t[20]=v,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==D||t[24]!==A?(j=(0,H.jsxs)(p,{className:`gap-2 sm:gap-0`,children:[D,A]}),t[23]=D,t[24]=A,t[25]=j):j=t[25];let N;t[26]!==j||t[27]!==S||t[28]!==w||t[29]!==E?(N=(0,H.jsxs)(ee,{className:`max-w-2xl`,children:[S,w,E,j]}),t[26]=j,t[27]=S,t[28]=w,t[29]=E,t[30]=N):N=t[30];let P;return t[31]!==n||t[32]!==N||t[33]!==x?(P=(0,H.jsx)(d,{open:n,onOpenChange:x,children:N}),t[31]=n,t[32]=N,t[33]=x,t[34]=P):P=t[34],P}function X({threadId:e,onExit:r}){let{state:a,dispatch:s}=A(),{resolvedTheme:c}=ie(),[d,f]=(0,B.useState)([]),[p,h]=(0,B.useState)(!0),[v,y]=(0,B.useState)(null),[x,S]=(0,B.useState)(0),[C,ee]=(0,B.useState)(!1),[M,ne]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>a.diffComments[e]??[],[a.diffComments,e]),L=(0,B.useCallback)(t=>{let n=a.diffComments[e]??[],r=typeof t==`function`?t(n):t;s({type:j.SetDiffComments,threadId:e,comments:r})},[s,e,a.diffComments]),[R,ce]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),ue=(0,B.useRef)(R),q=(0,B.useRef)({isFullView:C,selectedFileIndex:x,files:d}),J=(0,B.useRef)({original:[],modified:[]}),fe=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{ue.current=R},[R]),(0,B.useEffect)(()=>{q.current={isFullView:C,selectedFileIndex:x,files:d}},[C,x,d]);let pe=(0,B.useCallback)(()=>{F.current&&(M?F.current.expand():F.current.collapse())},[M]),Y=(0,B.useCallback)(async()=>{if(e){h(!0),y(null);try{f((await g(e)).files||[]),S(0)}catch(e){y(e instanceof Error?e.message:`Failed to load diff`)}finally{h(!1)}}},[e]);(0,B.useEffect)(()=>{Y()},[Y]);let me=(0,B.useCallback)(async t=>{try{await i(e,t.path),await Y()}catch(e){y(e instanceof Error?e.message:`Failed to revert file`)}},[e,Y]),X=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((a.diffComments[e]??[]).length>0){X.current=!0;return}o(e).then(t=>{t.diffComments&&t.diffComments.length>0&&s({type:j.SetDiffComments,threadId:e,comments:t.diffComments}),X.current=!0}).catch(()=>{X.current=!0})},[e]),(0,B.useEffect)(()=>{X.current&&_(e,{diffComments:I}).catch(()=>{})},[e,I]);let _e=(0,B.useMemo)(()=>le(d),[d]),Z=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},ve=(e,t,n)=>e.split(`
|
|
2
2
|
`).slice(t-1,n).join(`
|
|
3
3
|
`),ye=e=>{let t=Z(e);return t?t.startLine<=1:!0},be=e=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`})[e.split(`.`).pop()??``]||`plaintext`,Q=d[x],xe=Q?C?Q.oldContent:(()=>{let e=Z(Q);return e?ve(Q.oldContent,e.startLine,e.endLine):Q.oldContent})():``,Se=Q?C?Q.newContent:(()=>{let e=Z(Q);return e?ve(Q.newContent,e.startLine,e.endLine):Q.newContent})():``,$=(0,B.useCallback)(()=>{if(!fe.current)return;let e=G.current;if(!e)return;let{isFullView:t,selectedFileIndex:n,files:r}=q.current,i=K.current,a=ue.current,o=r[n];if(!o)return;let s=(e,r)=>{let s=t?null:Z(o),c=i.filter(e=>e.fileIndex===n&&e.side===r).map(e=>{let t=s?e.lineNumber-s.startLine+1:e.lineNumber;if(t<1)return null;let n=i.indexOf(e)===a;return{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:n?`diff-comment-active-line`:`diff-comment-marked-line`,glyphMarginHoverMessage:{value:e.comment}}}}).filter(e=>e!==null),l=r===`original`?J.current.original:J.current.modified,u=e.deltaDecorations(l,c);r===`original`?J.current.original=u:J.current.modified=u};s(e.getOriginalEditor(),`original`),s(e.getModifiedEditor(),`modified`)},[]);(0,B.useEffect)(()=>{$()},[$,I,R,x,C,Q]),(0,B.useEffect)(()=>()=>{G.current=null,J.current={original:[],modified:[]}},[x]),(0,B.useEffect)(()=>()=>{fe.current=!1,G.current&&=(G.current.getOriginalEditor().getModel()?.dispose(),G.current.getModifiedEditor().getModel()?.dispose(),G.current.dispose(),null),J.current={original:[],modified:[]}},[]);let Ce=(0,B.useCallback)(e=>{G.current=e;let t=(e,t)=>{e.onMouseDown(n=>{if(!n.target?.position)return;let r=n.target.position.lineNumber,{isFullView:i,selectedFileIndex:a,files:o}=q.current,s=o[a];if(!s)return;let c=i?null:Z(s),l=c?c.startLine+r-1:r,u=e.getModel()?.getLineContent(r)??``,d=K.current.find(e=>e.fileIndex===a&&e.lineNumber===l&&e.side===t);d?W(d):V({lineNumber:l,lineContent:u,side:t})})};t(e.getOriginalEditor(),`original`),t(e.getModifiedEditor(),`modified`),setTimeout(()=>{G.current===e&&$()},150)},[$]),we=(0,B.useCallback)(e=>{if(z&&Q){let t={id:`comment-${Date.now()}`,filePath:Q.path,fileIndex:x,lineNumber:z.lineNumber,lineContent:z.lineContent,comment:e,side:z.side};L(e=>[...e,t]),V(null)}else U&&(L(t=>t.map(t=>t.id===U.id?{...t,comment:e}:t)),W(null))},[z,U,Q,x,L]),Te=(0,B.useCallback)(()=>{U&&(L(e=>e.filter(e=>e.id!==U.id)),W(null))},[U,L]),Ee=(0,B.useCallback)(e=>{if(I.length===0)return;let t=(e%I.length+I.length)%I.length,n=I[t];ce(t),S(n.fileIndex),setTimeout(()=>{let e=G.current;if(!e)return;let t=d[n.fileIndex];if(!t)return;let r=C?null:Z(t),i=r?n.lineNumber-r.startLine+1:n.lineNumber;(n.side===`original`?e.getOriginalEditor():e.getModifiedEditor()).revealLineInCenter(Math.max(1,i)),$()},100)},[I,d,C,$]),De=(0,B.useCallback)(()=>{Ee((R??0)-1)},[Ee,R]),Oe=(0,B.useCallback)(()=>{Ee((R??-1)+1)},[Ee,R]),ke=(0,B.useCallback)(async()=>{let n=a.projectModelSelections[e];if(!n)try{let e=await t(),r=Object.values(e).flat();if(r.length>0)n=r[0];else{console.error(`No models available to process comments`);return}}catch(e){console.error(`Failed to load models:`,e);return}let i=n.id,o=n.provider;try{let{prompt:t}=await E(e,I);L([]),s({type:j.SetPendingChatMessage,message:{threadId:e,message:t,model:i,provider:o}}),r()}catch(e){console.error(`Failed to fix comments:`,e),typeof window<`u`&&window.alert(`Failed to process comments. Please try again.`)}},[I,a.projectModelSelections,s,e,r,L]),Ae={readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,lineNumbers:Q&&(C||ye(Q))?`on`:`off`,diffWordWrap:`on`,originalEditable:!1,automaticLayout:!0};return(0,H.jsxs)(`div`,{className:`diff-view-root flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`diff-body flex flex-1 overflow-hidden`,children:(0,H.jsxs)(se,{direction:`horizontal`,children:[(0,H.jsx)(oe,{ref:F,defaultSize:25,minSize:12,maxSize:40,collapsible:!0,collapsedSize:0,onCollapse:()=>ne(!0),onExpand:()=>ne(!1),className:`border-r border-transparent`,children:(0,H.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,H.jsx)(de,{treeData:_e,files:d,isLoading:p,error:v,selectedFileIndex:x,onFileSelect:S,onRevertFile:me})})}),(0,H.jsx)(he,{isOpen:!M}),(0,H.jsx)(oe,{className:`overflow-hidden bg-transparent`,children:(0,H.jsxs)(`div`,{className:`diff-editor-panel flex h-full bg-transparent flex-col overflow-hidden`,children:[(0,H.jsxs)(ae,{className:m(`bg-transparent`,M&&`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 justify-between`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:pe,children:[M?(0,H.jsx)(D,{className:`h-4 w-4`}):(0,H.jsx)(b,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle file tree`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Q?Q.path:`Review Changes`})]}),(0,H.jsxs)(`div`,{className:m(`flex items-center gap-2`,M&&`ml-0`,!M&&`ml-auto`,`md:ml-auto`),children:[(0,H.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>ee(e=>!e),disabled:!Q,className:`h-8 gap-1 px-2 text-xs`,children:C?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(O,{className:`h-3 w-3`}),` Show changes only`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(w,{className:`h-3 w-3`}),` Show full file`]})}),I.length>0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:De,disabled:(R??0)===0,children:(0,H.jsx)(n,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Previous comment`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:I.length===1?`1 Comment`:`Comment ${(R??0)+1} of ${I.length}`}),(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:Oe,disabled:(R??0)===I.length-1,children:(0,H.jsx)(u,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Next comment`})]})]}),I.length>0&&(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsxs)(l,{size:`sm`,onClick:ke,className:`h-8 gap-1 px-3 text-xs bg-foreground text-background hover:bg-foreground/90`,children:[(0,H.jsx)(T,{className:`h-3 w-3`}),`Fix all comments`]})}),(0,H.jsx)(N,{children:`Send all comments to Tarsk for resolution`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 bg-transparent relative`,children:[(0,H.jsx)(k,{height:`100%`,language:be(Q?.path||``),original:xe,modified:Se,theme:c===`dark`?`vs-dark`:`vs-light`,onMount:Ce,options:Ae},`diff-${x}`),(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0`,children:(0,H.jsx)(re,{})})]})]})})]})}),(0,H.jsx)(ge,{open:z!==null||U!==null,lineNumber:U?.lineNumber??z?.lineNumber??0,lineContent:U?.lineContent??z?.lineContent??``,initialComment:U?.comment,isEditing:U!==null,onSave:we,onDelete:Te,onClose:()=>{V(null),W(null)}},`${U?.id??``}-${z?.lineNumber??``}-${z?.side??``}`)]})}export{X as DiffView,X as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-
|
|
2
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,da as n,kn as r,la as i}from"./dialogs-config-3Hr2GRdt.js";import{vt as a}from"./react-vendor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-DdPiBm7Y.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-3Hr2GRdt.js","assets/api-XK7H2gI0.js","assets/alert-dialog-JOYww-on.js","assets/react-vendor-BX34Jw0L.js","assets/history-view-Cyhu-ped.js","assets/monaco-c-HyCuEi.js","assets/context-menu-5lS4H_pS.js","assets/standard-list-item-DUKJ8HEG.js","assets/use-toast-C3jyoS6i.js","assets/tab-context-D2auNMAI.js","assets/explorer-view-06kjYKL2.js","assets/page-toolbar-De9hbhUD.js","assets/store-xK3nfJ3V.js","assets/utils-4yrqj6yI.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,da as n,kn as r,la as i}from"./dialogs-config-3Hr2GRdt.js";import{vt as a}from"./react-vendor-BX34Jw0L.js";import{a as o}from"./store-xK3nfJ3V.js";import{n as s}from"./tab-context-D2auNMAI.js";import{n as c,r as l,t as u}from"./resizable-asBmgm9X.js";var d=i(),f=e(n(),1),p=t(),m=(0,f.lazy)(()=>a(()=>import(`./explorer-tree-DdPiBm7Y.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),h=(0,f.lazy)(()=>a(()=>import(`./explorer-view-06kjYKL2.js`),__vite__mapDeps([12,1,5,6,2,7,3,13,10,14,15])));function g(){let e=(0,d.c)(17),{state:t}=o(),n=t.selectedThreadId,[i,a]=(0,f.useState)(null),{pendingExplorerPath:g,setPendingExplorerPath:v,explorerClearPath:y,setExplorerClearPath:b}=s(),x,S;e[0]!==g||e[1]!==v?(x=()=>{g&&(a({name:g.split(`/`).pop()??g,type:`file`,path:g}),v(null))},S=[g,v],e[0]=g,e[1]=v,e[2]=x,e[3]=S):(x=e[2],S=e[3]),(0,f.useEffect)(x,S);let C,w;e[4]!==y||e[5]!==b?(C=()=>{y&&(a(e=>e&&(e.path===y||e.path.startsWith(y+`/`)?null:e)),b(null))},w=[y,b],e[4]=y,e[5]=b,e[6]=C,e[7]=w):(C=e[6],w=e[7]),(0,f.useEffect)(C,w);let T;e[8]!==i?.path||e[9]!==n?(T=(0,p.jsx)(c,{defaultSize:25,minSize:15,maxSize:50,className:`overflow-hidden border-r border-border`,children:(0,p.jsx)(r,{className:`h-full`,children:n?(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`space-y-1 px-2 py-2`,children:[1,2,3].map(_)}),children:(0,p.jsx)(m,{threadId:n,selectedPath:i?.path??null,onFileSelect:a})}):(0,p.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No thread selected.`})})}),e[8]=i?.path,e[9]=n,e[10]=T):T=e[10];let E;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(u,{withHandle:!0}),e[11]=E):E=e[11];let D;e[12]===i?D=e[13]:(D=(0,p.jsx)(c,{className:`overflow-hidden`,children:(0,p.jsx)(f.Suspense,{fallback:null,children:(0,p.jsx)(h,{selectedFile:i})})}),e[12]=i,e[13]=D);let O;return e[14]!==T||e[15]!==D?(O=(0,p.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,p.jsxs)(l,{direction:`horizontal`,className:`flex-1 overflow-hidden`,children:[T,E,D]})}),e[14]=T,e[15]=D,e[16]=O):O=e[16],O}function _(e){return(0,p.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e)}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ai as t,Cr as n,Ni as r,Qi as i,da as a,ea as o,gi as s,ji as c,la as l}from"./dialogs-config-3Hr2GRdt.js";import{t as u}from"./use-toast-C3jyoS6i.js";import{t as d}from"./standard-list-item-DUKJ8HEG.js";import{a as f,c as p,i as m,n as h,r as g,t as _}from"./alert-dialog-2Kcr7vcf.js";import{n as v}from"./tab-context-D2auNMAI.js";import{a as y,i as ee,n as b,r as x,t as S}from"./context-menu-sx0fb5uQ.js";import{n as C,o as w,r as T,s as E,t as D}from"./api-XK7H2gI0.js";var O=l(),k=e(a(),1),A=n();function te(e){let t=(0,O.c)(17),{defaultValue:n,onCommit:r,onCancel:i,level:a,basePadding:o,icon:s}=e,c=(0,k.useRef)(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current?.focus(),c.current?.select()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),(0,k.useEffect)(l,u);let f;t[2]!==i||t[3]!==r?(f=function(e){if(e.key===`Enter`){let e=c.current?.value.trim()??``;e?r(e):i()}else e.key===`Escape`&&i()},t[2]=i,t[3]=r,t[4]=f):f=t[4];let p=f,m;t[5]!==i||t[6]!==r?(m=function(){let e=c.current?.value.trim()??``;e?r(e):i()},t[5]=i,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==n||t[9]!==h||t[10]!==p?(g=(0,A.jsx)(`input`,{ref:c,defaultValue:n,onKeyDown:p,onBlur:h,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`,onClick:j}),t[8]=n,t[9]=h,t[10]=p,t[11]=g):g=t[11];let _;return t[12]!==o||t[13]!==s||t[14]!==a||t[15]!==g?(_=(0,A.jsxs)(d,{level:a,basePadding:o,children:[s,g]}),t[12]=o,t[13]=s,t[14]=a,t[15]=g,t[16]=_):_=t[16],_}function j(e){return e.stopPropagation()}function ne(e){let n=(0,O.c)(101),{node:a,level:l,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P}=e,F;n[0]!==f||n[1]!==a.path?(F=f.has(a.path),n[0]=f,n[1]=a.path,n[2]=F):F=n[2];let I=F,L;n[3]!==m||n[4]!==a.path?(L=m.has(a.path),n[3]=m,n[4]=a.path,n[5]=L):L=n[5];let R=L,z,B;if(n[6]!==f||n[7]!==I||n[8]!==R||n[9]!==l||n[10]!==p||n[11]!==m||n[12]!==g||n[13]!==a||n[14]!==P||n[15]!==T||n[16]!==j||n[17]!==w||n[18]!==E||n[19]!==D||n[20]!==k||n[21]!==v||n[22]!==C||n[23]!==_||n[24]!==h||n[25]!==u){B=Symbol.for(`react.early_return_sentinel`);bb0:{let e=p.get(a.path)??[];z=h===a.path;let O=g?.dirPath===a.path&&I;if(a.type===`folder`){let M=a.ignored?`opacity-50`:void 0,F;n[28]!==a||n[29]!==_?(F=e=>{e.stopPropagation(),_(a)},n[28]=a,n[29]=_,n[30]=F):F=n[30];let L;n[31]!==I||n[32]!==R?(L=(0,A.jsx)(`span`,{className:`text-muted-foreground w-3 flex-shrink-0`,children:R?(0,A.jsx)(s,{className:`h-3 w-3 animate-spin`}):I?(0,A.jsx)(o,{className:`h-3 w-3`}):(0,A.jsx)(i,{className:`h-3 w-3`})}),n[31]=I,n[32]=R,n[33]=L):L=n[33];let V;n[34]!==I||n[35]!==z||n[36]!==a||n[37]!==T||n[38]!==w?(V=z?(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(c,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:N,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`})]}):(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(c,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name})]}),n[34]=I,n[35]=z,n[36]=a,n[37]=T,n[38]=w,n[39]=V):V=n[39];let H;n[40]!==l||n[41]!==M||n[42]!==F||n[43]!==L||n[44]!==V?(H=(0,A.jsxs)(d,{level:l,basePadding:10,className:M,onClick:F,children:[L,V]}),n[40]=l,n[41]=M,n[42]=F,n[43]=L,n[44]=V,n[45]=H):H=n[45];let U=I&&(0,A.jsx)(`div`,{children:R&&!p.has(a.path)?(0,A.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded mx-4 my-1`}):(0,A.jsxs)(A.Fragment,{children:[O&&(0,A.jsx)(te,{defaultValue:``,level:l+1,basePadding:g.type===`folder`?10:22,icon:g.type===`folder`?(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:j,onCancel:P}),e.map(e=>(0,A.jsx)(ne,{node:e,level:l+1,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P},e.path))]})}),W;n[46]!==H||n[47]!==U?(W=(0,A.jsxs)(`div`,{children:[H,U]}),n[46]=H,n[47]=U,n[48]=W):W=n[48];let G=W,K;n[49]===G?K=n[50]:(K=(0,A.jsx)(y,{asChild:!0,children:G}),n[49]=G,n[50]=K);let q;n[51]!==a.path||n[52]!==D?(q=(0,A.jsx)(x,{onSelect:()=>D(a.path),children:`New File...`}),n[51]=a.path,n[52]=D,n[53]=q):q=n[53];let J;n[54]!==a.path||n[55]!==k?(J=(0,A.jsx)(x,{onSelect:()=>k(a.path),children:`New Folder...`}),n[54]=a.path,n[55]=k,n[56]=J):J=n[56];let Y;n[57]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,A.jsx)(ee,{}),n[57]=Y):Y=n[57];let X;n[58]!==a||n[59]!==C?(X=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),n[58]=a,n[59]=C,n[60]=X):X=n[60];let Z;n[61]!==a||n[62]!==E?(Z=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[61]=a,n[62]=E,n[63]=Z):Z=n[63];let Q;n[64]!==q||n[65]!==J||n[66]!==X||n[67]!==Z?(Q=(0,A.jsxs)(b,{children:[q,J,Y,X,Z]}),n[64]=q,n[65]=J,n[66]=X,n[67]=Z,n[68]=Q):Q=n[68];let $;n[69]!==K||n[70]!==Q?($=(0,A.jsxs)(S,{children:[K,Q]}),n[69]=K,n[70]=Q,n[71]=$):$=n[71],B=$;break bb0}}n[6]=f,n[7]=I,n[8]=R,n[9]=l,n[10]=p,n[11]=m,n[12]=g,n[13]=a,n[14]=P,n[15]=T,n[16]=j,n[17]=w,n[18]=E,n[19]=D,n[20]=k,n[21]=v,n[22]=C,n[23]=_,n[24]=h,n[25]=u,n[26]=z,n[27]=B}else z=n[26],B=n[27];if(B!==Symbol.for(`react.early_return_sentinel`))return B;let V=u===a.path,H=a.ignored?`opacity-50`:void 0,U;n[72]!==a||n[73]!==v?(U=()=>v(a),n[72]=a,n[73]=v,n[74]=U):U=n[74];let W;n[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),n[75]=W):W=n[75];let G;n[76]!==z||n[77]!==a||n[78]!==T||n[79]!==w?(G=z?(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:M,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`}):(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name}),n[76]=z,n[77]=a,n[78]=T,n[79]=w,n[80]=G):G=n[80];let K;n[81]!==l||n[82]!==V||n[83]!==H||n[84]!==U||n[85]!==G?(K=(0,A.jsxs)(d,{level:l,basePadding:22,selected:V,className:H,onClick:U,children:[W,G]}),n[81]=l,n[82]=V,n[83]=H,n[84]=U,n[85]=G,n[86]=K):K=n[86];let q=K,J;n[87]===q?J=n[88]:(J=(0,A.jsx)(y,{asChild:!0,children:q}),n[87]=q,n[88]=J);let Y;n[89]!==a||n[90]!==C?(Y=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),n[89]=a,n[90]=C,n[91]=Y):Y=n[91];let X;n[92]!==a||n[93]!==E?(X=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[92]=a,n[93]=E,n[94]=X):X=n[94];let Z;n[95]!==Y||n[96]!==X?(Z=(0,A.jsxs)(b,{children:[Y,X]}),n[95]=Y,n[96]=X,n[97]=Z):Z=n[97];let Q;return n[98]!==J||n[99]!==Z?(Q=(0,A.jsxs)(S,{children:[J,Z]}),n[98]=J,n[99]=Z,n[100]=Q):Q=n[100],Q}function M(e){return e.stopPropagation()}function N(e){return e.stopPropagation()}function P({threadId:e,selectedPath:n,onFileSelect:i}){let[a,o]=(0,k.useState)(new Map),[s,c]=(0,k.useState)(new Set),[l,d]=(0,k.useState)(new Set),[ee,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(null),{explorerRefreshTick:F,pendingExplorerPath:I}=v();async function L(t){if(!(!e||a.has(t))){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to load directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}}let R=(0,k.useCallback)(async t=>{if(e){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to reload directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}},[e]);(0,k.useEffect)(()=>{e&&(o(new Map),c(new Set),d(new Set),O(null),M(null),L(``))},[e]),(0,k.useEffect)(()=>{if(F>0&&e){R(``);for(let e of s)R(e)}},[F]),(0,k.useEffect)(()=>{if(!I||!e)return;let t=I.split(`/`);t.pop();let n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);if(n.length!==0){c(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});for(let e of n)L(e)}},[I,e]);function z(e){s.has(e.path)?c(t=>{let n=new Set(t);return n.delete(e.path),n}):(c(t=>new Set(t).add(e.path)),L(e.path))}function B(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function V(e){P(e)}async function H(){if(!N)return;let t=N;P(null);try{await T(e,t.path),await R(B(t.path)),c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n})}catch{u({title:`Error`,description:`Failed to move "${t.name}" to trash`,variant:`destructive`})}}function U(e){M(null),O(e.path)}async function W(t,n){if(n===t.name){O(null);return}O(null);try{await E(e,t.path,n),await R(B(t.path)),t.type===`folder`&&(c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}))}catch{u({title:`Error`,description:`Failed to rename "${t.name}"`,variant:`destructive`})}}function G(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`file`})}function K(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`folder`})}async function q(t){if(!j)return;let{dirPath:n,type:r}=j;M(null);try{r===`file`?await D(e,n,t):await C(e,n,t),await R(n)}catch{u({title:`Error`,description:`Failed to create ${r} "${t}"`,variant:`destructive`})}}function J(){M(null)}let Y=a.get(``)??[],X=l.has(``),Z=j?.dirPath===``?(0,A.jsx)(te,{defaultValue:``,level:0,basePadding:j.type===`folder`?10:22,icon:j.type===`folder`?(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:q,onCancel:J}):null;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Move to Trash`}),(0,A.jsxs)(f,{children:[`Move “`,N?.name,`” to trash?`]}),(0,A.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[(0,A.jsx)(g,{children:`Cancel`}),(0,A.jsx)(h,{onClick:()=>void H(),children:`Move to Trash`})]})]})}),(0,A.jsxs)(S,{children:[(0,A.jsx)(y,{asChild:!0,children:(0,A.jsx)(`div`,{className:`py-2 min-h-full`,children:X?(0,A.jsx)(`div`,{className:`space-y-1 px-2`,children:[1,2,3].map(e=>(0,A.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e))}):(0,A.jsxs)(A.Fragment,{children:[Z,Y.map(e=>(0,A.jsx)(ne,{node:e,level:0,selectedPath:n,expandedPaths:s,loadedDirs:a,loadingPaths:l,renamingPath:ee,newItemIn:j,onToggleFolder:z,onSelectFile:i,onStartRename:U,onCommitRename:W,onCancelRename:()=>O(null),onDelete:V,onNewFile:G,onNewFolder:K,onCommitNewItem:q,onCancelNewItem:J},e.path))]})})}),(0,A.jsxs)(b,{children:[(0,A.jsx)(x,{onSelect:()=>G(``),children:`New File...`}),(0,A.jsx)(x,{onSelect:()=>K(``),children:`New Folder...`})]})]})]})}export{P as default};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ai as t,Cr as n,Ni as r,Qi as i,da as a,ea as o,gi as s,ji as c,la as l}from"./dialogs-config-3Hr2GRdt.js";import{t as u}from"./use-toast-C3jyoS6i.js";import{t as d}from"./standard-list-item-DUKJ8HEG.js";import{a as f,c as p,i as m,n as h,r as g,t as _}from"./alert-dialog-JOYww-on.js";import{n as v}from"./tab-context-D2auNMAI.js";import{a as y,i as ee,n as b,r as x,t as S}from"./context-menu-5lS4H_pS.js";import{n as C,o as w,r as T,s as E,t as D}from"./api-XK7H2gI0.js";var O=l(),k=e(a(),1),A=n();function te(e){let t=(0,O.c)(17),{defaultValue:n,onCommit:r,onCancel:i,level:a,basePadding:o,icon:s}=e,c=(0,k.useRef)(null),l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current?.focus(),c.current?.select()},u=[],t[0]=l,t[1]=u):(l=t[0],u=t[1]),(0,k.useEffect)(l,u);let f;t[2]!==i||t[3]!==r?(f=function(e){if(e.key===`Enter`){let e=c.current?.value.trim()??``;e?r(e):i()}else e.key===`Escape`&&i()},t[2]=i,t[3]=r,t[4]=f):f=t[4];let p=f,m;t[5]!==i||t[6]!==r?(m=function(){let e=c.current?.value.trim()??``;e?r(e):i()},t[5]=i,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==n||t[9]!==h||t[10]!==p?(g=(0,A.jsx)(`input`,{ref:c,defaultValue:n,onKeyDown:p,onBlur:h,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`,onClick:j}),t[8]=n,t[9]=h,t[10]=p,t[11]=g):g=t[11];let _;return t[12]!==o||t[13]!==s||t[14]!==a||t[15]!==g?(_=(0,A.jsxs)(d,{level:a,basePadding:o,children:[s,g]}),t[12]=o,t[13]=s,t[14]=a,t[15]=g,t[16]=_):_=t[16],_}function j(e){return e.stopPropagation()}function ne(e){let n=(0,O.c)(101),{node:a,level:l,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P}=e,F;n[0]!==f||n[1]!==a.path?(F=f.has(a.path),n[0]=f,n[1]=a.path,n[2]=F):F=n[2];let I=F,L;n[3]!==m||n[4]!==a.path?(L=m.has(a.path),n[3]=m,n[4]=a.path,n[5]=L):L=n[5];let R=L,z,B;if(n[6]!==f||n[7]!==I||n[8]!==R||n[9]!==l||n[10]!==p||n[11]!==m||n[12]!==g||n[13]!==a||n[14]!==P||n[15]!==T||n[16]!==j||n[17]!==w||n[18]!==E||n[19]!==D||n[20]!==k||n[21]!==v||n[22]!==C||n[23]!==_||n[24]!==h||n[25]!==u){B=Symbol.for(`react.early_return_sentinel`);bb0:{let e=p.get(a.path)??[];z=h===a.path;let O=g?.dirPath===a.path&&I;if(a.type===`folder`){let M=a.ignored?`opacity-50`:void 0,F;n[28]!==a||n[29]!==_?(F=e=>{e.stopPropagation(),_(a)},n[28]=a,n[29]=_,n[30]=F):F=n[30];let L;n[31]!==I||n[32]!==R?(L=(0,A.jsx)(`span`,{className:`text-muted-foreground w-3 flex-shrink-0`,children:R?(0,A.jsx)(s,{className:`h-3 w-3 animate-spin`}):I?(0,A.jsx)(o,{className:`h-3 w-3`}):(0,A.jsx)(i,{className:`h-3 w-3`})}),n[31]=I,n[32]=R,n[33]=L):L=n[33];let V;n[34]!==I||n[35]!==z||n[36]!==a||n[37]!==T||n[38]!==w?(V=z?(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(c,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:N,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`})]}):(0,A.jsxs)(A.Fragment,{children:[I?(0,A.jsx)(c,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name})]}),n[34]=I,n[35]=z,n[36]=a,n[37]=T,n[38]=w,n[39]=V):V=n[39];let H;n[40]!==l||n[41]!==M||n[42]!==F||n[43]!==L||n[44]!==V?(H=(0,A.jsxs)(d,{level:l,basePadding:10,className:M,onClick:F,children:[L,V]}),n[40]=l,n[41]=M,n[42]=F,n[43]=L,n[44]=V,n[45]=H):H=n[45];let U=I&&(0,A.jsx)(`div`,{children:R&&!p.has(a.path)?(0,A.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded mx-4 my-1`}):(0,A.jsxs)(A.Fragment,{children:[O&&(0,A.jsx)(te,{defaultValue:``,level:l+1,basePadding:g.type===`folder`?10:22,icon:g.type===`folder`?(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:j,onCancel:P}),e.map(e=>(0,A.jsx)(ne,{node:e,level:l+1,selectedPath:u,expandedPaths:f,loadedDirs:p,loadingPaths:m,renamingPath:h,newItemIn:g,onToggleFolder:_,onSelectFile:v,onStartRename:C,onCommitRename:w,onCancelRename:T,onDelete:E,onNewFile:D,onNewFolder:k,onCommitNewItem:j,onCancelNewItem:P},e.path))]})}),W;n[46]!==H||n[47]!==U?(W=(0,A.jsxs)(`div`,{children:[H,U]}),n[46]=H,n[47]=U,n[48]=W):W=n[48];let G=W,K;n[49]===G?K=n[50]:(K=(0,A.jsx)(y,{asChild:!0,children:G}),n[49]=G,n[50]=K);let q;n[51]!==a.path||n[52]!==D?(q=(0,A.jsx)(x,{onSelect:()=>D(a.path),children:`New File...`}),n[51]=a.path,n[52]=D,n[53]=q):q=n[53];let J;n[54]!==a.path||n[55]!==k?(J=(0,A.jsx)(x,{onSelect:()=>k(a.path),children:`New Folder...`}),n[54]=a.path,n[55]=k,n[56]=J):J=n[56];let Y;n[57]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,A.jsx)(ee,{}),n[57]=Y):Y=n[57];let X;n[58]!==a||n[59]!==C?(X=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),n[58]=a,n[59]=C,n[60]=X):X=n[60];let Z;n[61]!==a||n[62]!==E?(Z=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[61]=a,n[62]=E,n[63]=Z):Z=n[63];let Q;n[64]!==q||n[65]!==J||n[66]!==X||n[67]!==Z?(Q=(0,A.jsxs)(b,{children:[q,J,Y,X,Z]}),n[64]=q,n[65]=J,n[66]=X,n[67]=Z,n[68]=Q):Q=n[68];let $;n[69]!==K||n[70]!==Q?($=(0,A.jsxs)(S,{children:[K,Q]}),n[69]=K,n[70]=Q,n[71]=$):$=n[71],B=$;break bb0}}n[6]=f,n[7]=I,n[8]=R,n[9]=l,n[10]=p,n[11]=m,n[12]=g,n[13]=a,n[14]=P,n[15]=T,n[16]=j,n[17]=w,n[18]=E,n[19]=D,n[20]=k,n[21]=v,n[22]=C,n[23]=_,n[24]=h,n[25]=u,n[26]=z,n[27]=B}else z=n[26],B=n[27];if(B!==Symbol.for(`react.early_return_sentinel`))return B;let V=u===a.path,H=a.ignored?`opacity-50`:void 0,U;n[72]!==a||n[73]!==v?(U=()=>v(a),n[72]=a,n[73]=v,n[74]=U):U=n[74];let W;n[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),n[75]=W):W=n[75];let G;n[76]!==z||n[77]!==a||n[78]!==T||n[79]!==w?(G=z?(0,A.jsx)(`input`,{autoFocus:!0,defaultValue:a.name,onKeyDown:e=>{if(e.key===`Enter`){let t=e.target.value.trim();t?w(a,t):T()}else e.key===`Escape`&&T()},onBlur:e=>{let t=e.target.value.trim();t?w(a,t):T()},onClick:M,className:`flex-1 min-w-0 bg-transparent outline-none border border-border rounded px-1 text-sm`}):(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:a.name}),n[76]=z,n[77]=a,n[78]=T,n[79]=w,n[80]=G):G=n[80];let K;n[81]!==l||n[82]!==V||n[83]!==H||n[84]!==U||n[85]!==G?(K=(0,A.jsxs)(d,{level:l,basePadding:22,selected:V,className:H,onClick:U,children:[W,G]}),n[81]=l,n[82]=V,n[83]=H,n[84]=U,n[85]=G,n[86]=K):K=n[86];let q=K,J;n[87]===q?J=n[88]:(J=(0,A.jsx)(y,{asChild:!0,children:q}),n[87]=q,n[88]=J);let Y;n[89]!==a||n[90]!==C?(Y=(0,A.jsx)(x,{onSelect:()=>C(a),children:`Rename...`}),n[89]=a,n[90]=C,n[91]=Y):Y=n[91];let X;n[92]!==a||n[93]!==E?(X=(0,A.jsx)(x,{onSelect:()=>E(a),className:`text-destructive focus:text-destructive`,children:`Delete`}),n[92]=a,n[93]=E,n[94]=X):X=n[94];let Z;n[95]!==Y||n[96]!==X?(Z=(0,A.jsxs)(b,{children:[Y,X]}),n[95]=Y,n[96]=X,n[97]=Z):Z=n[97];let Q;return n[98]!==J||n[99]!==Z?(Q=(0,A.jsxs)(S,{children:[J,Z]}),n[98]=J,n[99]=Z,n[100]=Q):Q=n[100],Q}function M(e){return e.stopPropagation()}function N(e){return e.stopPropagation()}function P({threadId:e,selectedPath:n,onFileSelect:i}){let[a,o]=(0,k.useState)(new Map),[s,c]=(0,k.useState)(new Set),[l,d]=(0,k.useState)(new Set),[ee,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(null),[N,P]=(0,k.useState)(null),{explorerRefreshTick:F,pendingExplorerPath:I}=v();async function L(t){if(!(!e||a.has(t))){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to load directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}}let R=(0,k.useCallback)(async t=>{if(e){d(e=>new Set(e).add(t));try{let n=await w(e,t);o(e=>new Map(e).set(t,n.entries))}catch{u({title:`Error`,description:`Failed to reload directory`,variant:`destructive`})}finally{d(e=>{let n=new Set(e);return n.delete(t),n})}}},[e]);(0,k.useEffect)(()=>{e&&(o(new Map),c(new Set),d(new Set),O(null),M(null),L(``))},[e]),(0,k.useEffect)(()=>{if(F>0&&e){R(``);for(let e of s)R(e)}},[F]),(0,k.useEffect)(()=>{if(!I||!e)return;let t=I.split(`/`);t.pop();let n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);if(n.length!==0){c(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});for(let e of n)L(e)}},[I,e]);function z(e){s.has(e.path)?c(t=>{let n=new Set(t);return n.delete(e.path),n}):(c(t=>new Set(t).add(e.path)),L(e.path))}function B(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function V(e){P(e)}async function H(){if(!N)return;let t=N;P(null);try{await T(e,t.path),await R(B(t.path)),c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n})}catch{u({title:`Error`,description:`Failed to move "${t.name}" to trash`,variant:`destructive`})}}function U(e){M(null),O(e.path)}async function W(t,n){if(n===t.name){O(null);return}O(null);try{await E(e,t.path,n),await R(B(t.path)),t.type===`folder`&&(c(e=>{let n=new Set(e);for(let e of n)(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}),o(e=>{let n=new Map(e);for(let e of n.keys())(e===t.path||e.startsWith(t.path+`/`))&&n.delete(e);return n}))}catch{u({title:`Error`,description:`Failed to rename "${t.name}"`,variant:`destructive`})}}function G(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`file`})}function K(e){O(null),s.has(e)||(c(t=>new Set(t).add(e)),L(e)),M({dirPath:e,type:`folder`})}async function q(t){if(!j)return;let{dirPath:n,type:r}=j;M(null);try{r===`file`?await D(e,n,t):await C(e,n,t),await R(n)}catch{u({title:`Error`,description:`Failed to create ${r} "${t}"`,variant:`destructive`})}}function J(){M(null)}let Y=a.get(``)??[],X=l.has(``),Z=j?.dirPath===``?(0,A.jsx)(te,{defaultValue:``,level:0,basePadding:j.type===`folder`?10:22,icon:j.type===`folder`?(0,A.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}):(0,A.jsx)(r,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),onCommit:q,onCancel:J}):null;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Move to Trash`}),(0,A.jsxs)(f,{children:[`Move “`,N?.name,`” to trash?`]}),(0,A.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[(0,A.jsx)(g,{children:`Cancel`}),(0,A.jsx)(h,{onClick:()=>void H(),children:`Move to Trash`})]})]})}),(0,A.jsxs)(S,{children:[(0,A.jsx)(y,{asChild:!0,children:(0,A.jsx)(`div`,{className:`py-2 min-h-full`,children:X?(0,A.jsx)(`div`,{className:`space-y-1 px-2`,children:[1,2,3].map(e=>(0,A.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e))}):(0,A.jsxs)(A.Fragment,{children:[Z,Y.map(e=>(0,A.jsx)(ne,{node:e,level:0,selectedPath:n,expandedPaths:s,loadedDirs:a,loadingPaths:l,renamingPath:ee,newItemIn:j,onToggleFolder:z,onSelectFile:i,onStartRename:U,onCommitRename:W,onCancelRename:()=>O(null),onDelete:V,onNewFile:G,onNewFolder:K,onCommitNewItem:q,onCancelNewItem:J},e.path))]})})}),(0,A.jsxs)(b,{children:[(0,A.jsx)(x,{onSelect:()=>G(``),children:`New File...`}),(0,A.jsx)(x,{onSelect:()=>K(``),children:`New Folder...`})]})]})]})}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Pi as n,Pn as r,da as i,gi as a}from"./dialogs-config-3Hr2GRdt.js";import{g as o}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Pi as n,Pn as r,da as i,gi as a}from"./dialogs-config-3Hr2GRdt.js";import{g as o}from"./react-vendor-BX34Jw0L.js";import{a as s}from"./store-xK3nfJ3V.js";import{t as c}from"./use-toast-C3jyoS6i.js";import{n as l}from"./utils-4yrqj6yI.js";import{t as u}from"./page-toolbar-De9hbhUD.js";import{a as d,c as f,i as p}from"./api-XK7H2gI0.js";var m=e(i(),1),h=t(),g=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`,`bmp`,`tiff`,`tif`]),_=new Set([`mp4`,`webm`,`mov`,`avi`]);function v(e){let t=e.split(`.`).pop()?.toLowerCase()??``;return g.has(t)?`image`:_.has(t)?`video`:null}function y(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,mdc:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`}[e.split(`.`).pop()??``]??`plaintext`}function b({selectedFile:e}){let{state:t}=s(),{resolvedTheme:i}=l(),g=t.selectedThreadId,_=(0,m.useRef)(null),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1);(0,m.useEffect)(()=>()=>{_.current&&=(_.current.getModel()?.dispose(),_.current.dispose(),null)},[]);async function O(){if(!(!g||!e)){D(!0);try{await f(g,e.path,b),C(b),c({title:`Saved`,description:`${e.name} saved successfully.`})}catch(e){c({title:`Error`,description:e instanceof Error?e.message:`Failed to save file`,variant:`destructive`})}finally{D(!1)}}}let k=(0,m.useCallback)(async e=>{if(g){T(!0);try{let t=await p(g,e.path);x(t.content),C(t.content)}catch(e){c({title:`Error`,description:e instanceof Error?e.message:`Failed to load file`,variant:`destructive`})}finally{T(!1)}}},[g]);return(0,m.useEffect)(()=>{e&&g?v(e.path)||k(e):(x(``),C(``))},[e,g,k]),g?(0,h.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,h.jsxs)(u,{className:`justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e?e.name:`Select a file to edit`}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e?e.path:`Browse and edit repository files`})]}),e&&!v(e.path)&&(0,h.jsx)(`div`,{className:`flex gap-1`,children:(0,h.jsxs)(r,{size:`sm`,onClick:()=>void O(),disabled:E||!b||b===S,children:[E?(0,h.jsx)(a,{className:`h-4 w-4 animate-spin`}):null,`Save`]})})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,h.jsx)(`div`,{className:`h-full relative overflow-hidden`,children:w?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(a,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):e&&v(e.path)===`image`?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 overflow-auto`,children:(0,h.jsx)(`img`,{src:d(g,e.path),alt:e.name,className:`max-w-full max-h-full object-contain`})}):e&&v(e.path)===`video`?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full p-4`,children:(0,h.jsx)(`video`,{src:d(g,e.path),controls:!0,className:`max-w-full max-h-full`})}):e?(0,h.jsx)(o,{height:`100%`,language:y(e.path),value:b,onChange:e=>x(e??``),onMount:e=>{_.current=e},theme:i===`dark`?`vs-dark`:`vs-light`,options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,fontSize:13,lineNumbers:`on`,renderLineHighlight:`line`,scrollbar:{vertical:`auto`,horizontal:`auto`}}}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-center p-8`,children:[(0,h.jsx)(n,{className:`h-10 w-10 text-muted-foreground/50`}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`No file selected`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Select a file from the tree to edit it`})]})]})})})]}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-center`,children:[(0,h.jsx)(n,{className:`h-8 w-8 text-muted-foreground`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a thread to browse its files`})]})}export{b as default};
|