agent-tower 0.3.16 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/executors/claude-code.executor.d.ts +2 -0
  2. package/dist/executors/claude-code.executor.d.ts.map +1 -1
  3. package/dist/executors/claude-code.executor.js +8 -0
  4. package/dist/executors/claude-code.executor.js.map +1 -1
  5. package/dist/web/assets/{AgentDemoPage-HesErDgP.js → AgentDemoPage-2AqgX6Cf.js} +1 -1
  6. package/dist/web/assets/{DemoPage-_JvTlAiA.js → DemoPage-DyFtRa8x.js} +1 -1
  7. package/dist/web/assets/{GeneralSettingsPage-CJ9zjMoZ.js → GeneralSettingsPage-B6uXd3Wp.js} +1 -1
  8. package/dist/web/assets/{NotificationSettingsPage-DulSelTy.js → NotificationSettingsPage-B0m5t4qH.js} +1 -1
  9. package/dist/web/assets/{ProfileSettingsPage-D6bXZqqi.js → ProfileSettingsPage-CwRQ5Wr1.js} +1 -1
  10. package/dist/web/assets/{ProjectKanbanPage-CMIFryFy.js → ProjectKanbanPage-DwSI2gad.js} +3 -3
  11. package/dist/web/assets/{ProjectSettingsPage-w-ch_TzQ.js → ProjectSettingsPage-BxGCUc3h.js} +1 -1
  12. package/dist/web/assets/{ProviderSettingsPage-fdnDecHo.js → ProviderSettingsPage-BF3I_Oba.js} +9 -9
  13. package/dist/web/assets/{button-DWEfhrOb.js → button-Dh8FHptl.js} +1 -1
  14. package/dist/web/assets/{chevron-down-r1WqxE7T.js → chevron-down-B-UCtkpw.js} +1 -1
  15. package/dist/web/assets/{chevron-right-BoX1HZb8.js → chevron-right-CIJ95cIu.js} +1 -1
  16. package/dist/web/assets/{circle-alert-Dsf4sjes.js → circle-alert-DwzV6nbB.js} +1 -1
  17. package/dist/web/assets/{circle-check-ClwRPrUg.js → circle-check-MgjzSuSN.js} +1 -1
  18. package/dist/web/assets/{code-block-OCS4YCEC-DgzIFFQa.js → code-block-OCS4YCEC-DVFIuiT3.js} +1 -1
  19. package/dist/web/assets/{confirm-dialog-CHgJE4TL.js → confirm-dialog-B4CDGom7.js} +1 -1
  20. package/dist/web/assets/{folder-picker-CWyzaOjA.js → folder-picker-CzSKXweo.js} +1 -1
  21. package/dist/web/assets/{index-Dz23RytL.js → index-CFjAe6OM.js} +6 -6
  22. package/dist/web/assets/{loader-circle-6llnjfOV.js → loader-circle-BiT33tiH.js} +1 -1
  23. package/dist/web/assets/{mermaid-NOHMQCX5-DFcKyU--.js → mermaid-NOHMQCX5-BeW1Fb1_.js} +3 -3
  24. package/dist/web/assets/{modal-BlrEFlKt.js → modal-hQOddjel.js} +1 -1
  25. package/dist/web/assets/{pencil-BYLehKfm.js → pencil-Ca4AsZLH.js} +1 -1
  26. package/dist/web/assets/{rotate-ccw-Ca8el0Vt.js → rotate-ccw-Dx6ZIa1R.js} +1 -1
  27. package/dist/web/assets/{select-BSrh_Wca.js → select-DN0KH4Bi.js} +1 -1
  28. package/dist/web/assets/{use-profiles-D0vf97yX.js → use-profiles-CUlWd_po.js} +1 -1
  29. package/dist/web/index.html +1 -1
  30. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-BlrEFlKt.js","assets/index-Dz23RytL.js","assets/index-CnQr7qh9.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CWyzaOjA.js","assets/chevron-right-BoX1HZb8.js","assets/loader-circle-6llnjfOV.js","assets/circle-alert-Dsf4sjes.js","assets/rotate-ccw-Ca8el0Vt.js"])))=>i.map(i=>d[i]);
2
- import{Q as jr,l as ti,m as ra,n as ia,o as na,p as _r,v as oa,w as aa,b as We,x as la,y as ca,r as k,z as ha,A as ua,B as da,D as fa,E as si,G as ri,H as ma,I as pa,J as va,e as _e,R as ee,K as Nt,u as ce,j as a,s as wt,S as Qe,C as Pt,d as fe,c as Ze,q as le,a as ht,k as Et,M as ga,N as ii,O as _a,f as ba,P as xa,t as ni,L as oi,_ as cn}from"./index-Dz23RytL.js";import{h as Tr,b as Lr,d as Mr,c as Nr,i as Pr,G as Is,u as hn,a as un,Q as dn,e as fn,T as mn,P as ws,f as pn,S as ai}from"./mermaid-NOHMQCX5-DFcKyU--.js";import{C as xt,a as ss}from"./chevron-down-r1WqxE7T.js";import{C as Ft}from"./chevron-right-BoX1HZb8.js";import{P as br,X as Fs,M as Or,T as vn}from"./modal-BlrEFlKt.js";import{u as Hs,T as gn,g as Sa,A as _t,S as Le,C as xr,h as gt}from"./confirm-dialog-CHgJE4TL.js";import"./log-adapter-50wgehrc.js";import{B as dt}from"./button-DWEfhrOb.js";import{c as ye,t as li}from"./utils-CkSf8FUe.js";import{F as ya,a as Ca,R as wa}from"./rotate-ccw-Ca8el0Vt.js";import{L as ze}from"./loader-circle-6llnjfOV.js";import{S as vs}from"./select-BSrh_Wca.js";var Ea=class extends jr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ti()})}getOptimisticResult(e){return e.behavior=ti(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",f=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ia(t,s.data),hasPreviousPage:ra(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ci(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ka(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ra=class extends na{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,_r.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=l.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),C=s.length!==m.length,r=m.some((f,o)=>f!==s[o]),i=C||r,c=i?!0:v.some((f,o)=>{const p=this.#e[o];return!p||!oa(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ci(s,m).forEach(f=>{f.destroy()}),ci(m,s).forEach(f=>{f.subscribe(o=>{this.#f(f,o)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[l,v=>this.#u(v??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(C=>{C.observer.trackProp(v)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((v,C)=>v!==l[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=aa(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const v=t.get(m);v?v.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),C=t.get(m.queryHash)?.shift()??new jr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ka(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&_r.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Da({queries:e,...t},s){const l=We(),m=la(),v=ca(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ha(g);const n=l.getQueryCache().get(g.queryHash);ua(g,v,n)}),da(v);const[r]=k.useState(()=>new Ra(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(_r.batchCalls(g)):fa,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const x=i.some((g,n)=>si(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new jr(l,d);if(si(d,g))return ri(d,h,v);ma(g,m)&&ri(d,h,v)}return[]}):[];if(x.length>0)throw Promise.all(x);const S=i.find((g,n)=>{const d=C[n];return d&&pa({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(S?.error)throw S.error;return c(f())}function _n(e,t){return va(e,Ea)}const Aa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bn=_e("arrow-down",Aa);const ja=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xn=_e("arrow-right",ja);const Ta=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sn=_e("arrow-up",Ta);const La=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hi=_e("circle-check-big",La);const Ma=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],zs=_e("code-xml",Ma);const Na=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ui=_e("copy",Na);const Pa=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],yn=_e("ellipsis-vertical",Pa);const Oa=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Ba=_e("file-braces-corner",Oa);const Ia=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],rs=_e("file-code-corner",Ia);const Fa=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ha=_e("file-exclamation-point",Fa);const za=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Cn=_e("file-text",za);const Wa=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],wn=_e("folder-open",Wa);const $a=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ua=_e("gauge",$a);const qa=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Ka=_e("git-branch",qa);const Xa=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Ya=_e("git-fork",Xa);const Va=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],is=_e("git-graph",Va);const Ga=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],En=_e("git-merge",Ga);const Qa=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],qt=_e("history",Qa);const Za=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Br=_e("image",Za);const Ja=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],di=_e("layers",Ja);const el=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],tl=_e("maximize",el);const sl=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],rl=_e("message-square",sl);const il=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],nl=_e("panel-left-close",il);const ol=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],al=_e("panel-left-open",ol);const ll=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],cl=_e("panel-right-close",ll);const hl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],ul=_e("panel-right-open",hl);const dl=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Ot=_e("play",dl);const fl=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ml=_e("refresh-cw",fl);const pl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],vl=_e("shield",pl);const gl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=_e("terminal",gl);const _l=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bl=_e("zap",_l);const xl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Sl=_e("zoom-in",xl);const yl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Cl=_e("zoom-out",yl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Je(e){var t,s;return e?Kt(e)?e:Ir(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Fr(e){const{Document:t}=Je(e);return e instanceof t}function cs(e){return Kt(e)?!1:e instanceof Je(e).HTMLElement}function kn(e){return e instanceof Je(e).SVGElement}function Xt(e){return e?Kt(e)?e.document:Ir(e)?Fr(e)?e:cs(e)||kn(e)?e.ownerDocument:document:document:document}const bt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return bt(()=>{t.current=e}),k.useCallback(function(){for(var s=arguments.length,l=new Array(s),m=0;m<s;m++)l[m]=arguments[m];return t.current==null?void 0:t.current(...l)},[])}function wl(){const e=k.useRef(null),t=k.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=k.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function ns(e,t){t===void 0&&(t=[e]);const s=k.useRef(e);return bt(()=>{s.current!==e&&(s.current=e)},t),s}function hs(e,t){const s=k.useRef();return k.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ks(e){const t=$s(e),s=k.useRef(null),l=k.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function Rs(e){const t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}let sr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=sr[e]==null?0:sr[e]+1;return sr[e]=s,e+"-"+s},[e,t])}function Rn(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((v,C)=>{const r=Object.entries(C);for(const[i,c]of r){const f=v[i];f!=null&&(v[i]=f+e*c)}return v},{...t})}}const Ut=Rn(1),Ds=Rn(-1);function El(e){return"clientX"in e&&"clientY"in e}function Hr(e){if(!e)return!1;const{KeyboardEvent:t}=Je(e.target);return t&&e instanceof t}function kl(e){if(!e)return!1;const{TouchEvent:t}=Je(e.target);return t&&e instanceof t}function As(e){if(kl(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return El(e)?{x:e.clientX,y:e.clientY}:null}const os=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[os.Translate.toString(e),os.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),fi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Rl(e){return e.matches(fi)?e:e.querySelector(fi)}const Dl={display:"none"};function Al(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Dl},s)}function jl(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Tl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const Dn=k.createContext(null);function Ll(e){const t=k.useContext(Dn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ml(){const[e]=k.useState(()=>new Set),t=k.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[k.useCallback(l=>{let{type:m,event:v}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,v)})},[e]),t]}const Nl={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-hQOddjel.js","assets/index-CFjAe6OM.js","assets/index-CnQr7qh9.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CzSKXweo.js","assets/chevron-right-CIJ95cIu.js","assets/loader-circle-BiT33tiH.js","assets/circle-alert-DwzV6nbB.js","assets/rotate-ccw-Dx6ZIa1R.js"])))=>i.map(i=>d[i]);
2
+ import{Q as jr,l as ti,m as ra,n as ia,o as na,p as _r,v as oa,w as aa,b as We,x as la,y as ca,r as k,z as ha,A as ua,B as da,D as fa,E as si,G as ri,H as ma,I as pa,J as va,e as _e,R as ee,K as Nt,u as ce,j as a,s as wt,S as Qe,C as Pt,d as fe,c as Ze,q as le,a as ht,k as Et,M as ga,N as ii,O as _a,f as ba,P as xa,t as ni,L as oi,_ as cn}from"./index-CFjAe6OM.js";import{h as Tr,b as Lr,d as Mr,c as Nr,i as Pr,G as Is,u as hn,a as un,Q as dn,e as fn,T as mn,P as ws,f as pn,S as ai}from"./mermaid-NOHMQCX5-BeW1Fb1_.js";import{C as xt,a as ss}from"./chevron-down-B-UCtkpw.js";import{C as Ft}from"./chevron-right-CIJ95cIu.js";import{P as br,X as Fs,M as Or,T as vn}from"./modal-hQOddjel.js";import{u as Hs,T as gn,g as Sa,A as _t,S as Le,C as xr,h as gt}from"./confirm-dialog-B4CDGom7.js";import"./log-adapter-50wgehrc.js";import{B as dt}from"./button-Dh8FHptl.js";import{c as ye,t as li}from"./utils-CkSf8FUe.js";import{F as ya,a as Ca,R as wa}from"./rotate-ccw-Dx6ZIa1R.js";import{L as ze}from"./loader-circle-BiT33tiH.js";import{S as vs}from"./select-DN0KH4Bi.js";var Ea=class extends jr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ti()})}getOptimisticResult(e){return e.behavior=ti(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,l=super.createResult(e,t),{isFetching:m,isRefetching:v,isError:C,isRefetchError:r}=l,i=s.fetchMeta?.fetchMore?.direction,c=C&&i==="forward",f=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ia(t,s.data),hasPreviousPage:ra(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ci(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ka(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ra=class extends na{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,_r.batch(()=>{const s=this.#t,l=this.#d(this.#i);l.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=l.map(f=>f.observer),v=m.map(f=>f.getCurrentResult()),C=s.length!==m.length,r=m.some((f,o)=>f!==s[o]),i=C||r,c=i?!0:v.some((f,o)=>{const p=this.#e[o];return!p||!oa(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ci(s,m).forEach(f=>{f.destroy()}),ci(m,s).forEach(f=>{f.subscribe(o=>{this.#f(f,o)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),l=s.map(v=>v.observer.getOptimisticResult(v.defaultedQueryOptions)),m=s.map(v=>v.defaultedQueryOptions.queryHash);return[l,v=>this.#u(v??l,t,m),()=>this.#h(l,s)]}#h(e,t){return t.map((s,l)=>{const m=e[l];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,v=>{t.forEach(C=>{C.observer.trackProp(v)})})})}#u(e,t,s){if(t){const l=this.#l,m=s!==void 0&&l!==void 0&&(l.length!==s.length||s.some((v,C)=>v!==l[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=aa(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(l=>{const m=l.options.queryHash;if(!m)return;const v=t.get(m);v?v.push(l):t.set(m,[l])});const s=[];return e.forEach(l=>{const m=this.#r.defaultQueryOptions(l),C=t.get(m.queryHash)?.shift()??new jr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ka(this.#e,s,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&_r.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function Da({queries:e,...t},s){const l=We(),m=la(),v=ca(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ha(g);const n=l.getQueryCache().get(g.queryHash);ua(g,v,n)}),da(v);const[r]=k.useState(()=>new Ra(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(_r.batchCalls(g)):fa,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const x=i.some((g,n)=>si(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new jr(l,d);if(si(d,g))return ri(d,h,v);ma(g,m)&&ri(d,h,v)}return[]}):[];if(x.length>0)throw Promise.all(x);const S=i.find((g,n)=>{const d=C[n];return d&&pa({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(S?.error)throw S.error;return c(f())}function _n(e,t){return va(e,Ea)}const Aa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bn=_e("arrow-down",Aa);const ja=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xn=_e("arrow-right",ja);const Ta=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sn=_e("arrow-up",Ta);const La=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hi=_e("circle-check-big",La);const Ma=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],zs=_e("code-xml",Ma);const Na=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ui=_e("copy",Na);const Pa=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],yn=_e("ellipsis-vertical",Pa);const Oa=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Ba=_e("file-braces-corner",Oa);const Ia=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],rs=_e("file-code-corner",Ia);const Fa=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ha=_e("file-exclamation-point",Fa);const za=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Cn=_e("file-text",za);const Wa=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],wn=_e("folder-open",Wa);const $a=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ua=_e("gauge",$a);const qa=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Ka=_e("git-branch",qa);const Xa=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Ya=_e("git-fork",Xa);const Va=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],is=_e("git-graph",Va);const Ga=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],En=_e("git-merge",Ga);const Qa=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],qt=_e("history",Qa);const Za=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Br=_e("image",Za);const Ja=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],di=_e("layers",Ja);const el=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],tl=_e("maximize",el);const sl=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],rl=_e("message-square",sl);const il=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],nl=_e("panel-left-close",il);const ol=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],al=_e("panel-left-open",ol);const ll=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],cl=_e("panel-right-close",ll);const hl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],ul=_e("panel-right-open",hl);const dl=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Ot=_e("play",dl);const fl=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ml=_e("refresh-cw",fl);const pl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],vl=_e("shield",pl);const gl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=_e("terminal",gl);const _l=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bl=_e("zap",_l);const xl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Sl=_e("zoom-in",xl);const yl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Cl=_e("zoom-out",yl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Je(e){var t,s;return e?Kt(e)?e:Ir(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Fr(e){const{Document:t}=Je(e);return e instanceof t}function cs(e){return Kt(e)?!1:e instanceof Je(e).HTMLElement}function kn(e){return e instanceof Je(e).SVGElement}function Xt(e){return e?Kt(e)?e.document:Ir(e)?Fr(e)?e:cs(e)||kn(e)?e.ownerDocument:document:document:document}const bt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return bt(()=>{t.current=e}),k.useCallback(function(){for(var s=arguments.length,l=new Array(s),m=0;m<s;m++)l[m]=arguments[m];return t.current==null?void 0:t.current(...l)},[])}function wl(){const e=k.useRef(null),t=k.useCallback((l,m)=>{e.current=setInterval(l,m)},[]),s=k.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function ns(e,t){t===void 0&&(t=[e]);const s=k.useRef(e);return bt(()=>{s.current!==e&&(s.current=e)},t),s}function hs(e,t){const s=k.useRef();return k.useMemo(()=>{const l=e(s.current);return s.current=l,l},[...t])}function ks(e){const t=$s(e),s=k.useRef(null),l=k.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,l]}function Rs(e){const t=k.useRef();return k.useEffect(()=>{t.current=e},[e]),t.current}let sr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=sr[e]==null?0:sr[e]+1;return sr[e]=s,e+"-"+s},[e,t])}function Rn(e){return function(t){for(var s=arguments.length,l=new Array(s>1?s-1:0),m=1;m<s;m++)l[m-1]=arguments[m];return l.reduce((v,C)=>{const r=Object.entries(C);for(const[i,c]of r){const f=v[i];f!=null&&(v[i]=f+e*c)}return v},{...t})}}const Ut=Rn(1),Ds=Rn(-1);function El(e){return"clientX"in e&&"clientY"in e}function Hr(e){if(!e)return!1;const{KeyboardEvent:t}=Je(e.target);return t&&e instanceof t}function kl(e){if(!e)return!1;const{TouchEvent:t}=Je(e.target);return t&&e instanceof t}function As(e){if(kl(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return El(e)?{x:e.clientX,y:e.clientY}:null}const os=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[os.Translate.toString(e),os.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:l}=e;return t+" "+s+"ms "+l}}}),fi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Rl(e){return e.matches(fi)?e:e.querySelector(fi)}const Dl={display:"none"};function Al(e){let{id:t,value:s}=e;return ee.createElement("div",{id:t,style:Dl},s)}function jl(e){let{id:t,announcement:s,ariaLiveType:l="assertive"}=e;const m={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ee.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Tl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const Dn=k.createContext(null);function Ll(e){const t=k.useContext(Dn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ml(){const[e]=k.useState(()=>new Set),t=k.useCallback(l=>(e.add(l),()=>e.delete(l)),[e]);return[k.useCallback(l=>{let{type:m,event:v}=l;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,v)})},[e]),t]}const Nl={draggable:`
3
3
  To pick up a draggable item, press the space bar.
4
4
  While dragging, use the arrow keys to move the item.
5
5
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -80,7 +80,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
80
80
  `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:ye("px-3 whitespace-pre",o,p),children:c},f)})})}function Bm({entry:e,type:t,workingDir:s}){const[l,m]=k.useState(!1),v=Zi[e.status]||Zi.M,C=Pm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:ye("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:ye("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Nm(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Om,{workingDir:s,filePath:e.path,type:t})]})}function Ji({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=ce(),[C,r]=k.useState(m);return t.length===0?null:a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>r(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[a.jsx("span",{className:"text-neutral-400",children:C?a.jsx(xt,{size:14}):a.jsx(Ft,{size:14})}),a.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:v(e)}),a.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),C&&a.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(i=>a.jsx(Bm,{entry:i,type:s,workingDir:l},`${s}:${i.path}`))})]})}function Im({workingDir:e}){const{t}=ce(),{data:s,isLoading:l,isError:m}=bo(e);if(!e)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(l)return a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(ze,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const v=s?.uncommitted||[],C=s?.committed||[];return v.length+C.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(is,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx(Ji,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(Ji,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const vr=50,en={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Fm(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Et("{count}s ago",{count:s}):s<3600?Et("{count}m ago",{count:Math.floor(s/60)}):s<86400?Et("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Et("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Hm(e){const t=e.split("/");return t[t.length-1]||e}function zm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Wm({workingDir:e,hash:t,filePath:s}){const{t:l}=ce(),{data:m,isLoading:v,isError:C}=yo(e,t,s);if(v)return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[a.jsx(ze,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(C)return a.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:l("Failed to load diff.")});const r=m?.diff||"";if(!r.trim())return a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:l("No diff content available.")});const i=r.split(`
81
81
  `);return a.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,f)=>{let o="",p="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(o="bg-emerald-950/40",p="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(o="bg-red-950/40",p="text-red-400"):c.startsWith("@@")&&(o="bg-blue-950/30",p="text-blue-400"),a.jsx("div",{className:ye("px-3 whitespace-pre",o,p),children:c},f)})})}function $m({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=zm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:ye("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("span",{className:ye("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",v),children:e.status}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Hm(e.path)}),C&&a.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),a.jsx("span",{className:"text-neutral-400 shrink-0",children:l?a.jsx(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Wm,{workingDir:t,hash:s,filePath:e.path})]})}function Um({commit:e,workingDir:t}){const{t:s}=ce(),[l,m]=k.useState(!1),{data:v,isLoading:C}=So(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:ye("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",l&&"bg-neutral-50"),children:[a.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:a.jsx("div",{className:ye("w-2.5 h-2.5 rounded-full shrink-0",l?"bg-blue-500":"bg-neutral-300")})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),a.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[a.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),a.jsx("span",{className:"text-[11px] text-neutral-400",children:Fm(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(xt,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&a.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),C?a.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[a.jsx(ze,{size:14,className:"animate-spin"}),a.jsx("span",{className:"text-xs",children:s("Loading files...")})]}):r.length===0?a.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:s("No files changed")}):a.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>a.jsx($m,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function qm({workingDir:e}){const{t}=ce(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=_n({queryKey:le.git.log(e||""),queryFn:({pageParam:c=0})=>fe.get("/git/log",{params:{workingDir:e||"",limit:String(vr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<vr?void 0:f.length*vr,enabled:!!e}),i=s?.pages.flatMap(c=>c.commits)||[];return e?l?a.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[a.jsx(ze,{size:16,className:"animate-spin mr-2"}),a.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?a.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):i.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[a.jsx(qt,{size:28,className:"mb-3"}),a.jsx("span",{className:"text-sm",children:t("No commit history")})]}):a.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[a.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(c=>a.jsx(Um,{commit:c,workingDir:e},c.hash))}),C&&a.jsx("button",{type:"button",onClick:()=>v(),disabled:r,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:r?a.jsxs(a.Fragment,{children:[a.jsx(ze,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const Km="/api",Xm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Km}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ym=({src:e,alt:t,...s})=>a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:a.jsx("img",{src:e,alt:t,...s,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer active:opacity-90 transition-opacity"})}),Vm={img:Ym};function Gm({status:e}){const t={[ae.Running]:"bg-blue-500",[ae.Review]:"bg-amber-500",[ae.Pending]:"bg-neutral-400",[ae.Done]:"bg-emerald-500",[ae.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Qm=[{key:"chat",label:"Chat",icon:rl},{key:"changes",label:"Changes",icon:is},{key:"history",label:"History",icon:qt},{key:"workspace",label:"Workspace",icon:wn}];function Zm({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=ce(),[v,C]=k.useState("chat"),[r,i]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[x,S]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:y,scrollToBottom:w}=qn({resize:"smooth",initial:"instant"}),E=We();k.useEffect(()=>{if(!x)return;const V=Z=>{n.current&&!n.current.contains(Z.target)&&S(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[x]);const{data:b,isLoading:R}=wo(e.id),j=k.useMemo(()=>{if(!b)return null;const V=b.filter(pe=>pe.status==="ACTIVE"&&Array.isArray(pe.sessions)).flatMap(pe=>pe.sessions??[]),Z=pe=>{const et=pe.createdAt,Ge=pe.endedAt??pe.startedAt??et;if(!Ge)return 0;const nt=Date.parse(Ge);return Number.isNaN(nt)?0:nt},xe=pe=>{const et=V.filter(Ge=>pe.includes(Ge.status));return et.length===0?null:et.sort((Ge,nt)=>Z(nt)-Z(Ge))[0]??null},Se=xe([Le.RUNNING])??xe([Le.PENDING])??xe([Le.COMPLETED,Le.FAILED,Le.CANCELLED]);if(Se)return Se;const Xe=b.filter(pe=>(pe.status==="ABANDONED"||pe.status==="MERGED")&&Array.isArray(pe.sessions)).flatMap(pe=>pe.sessions??[]).filter(pe=>[Le.COMPLETED,Le.FAILED,Le.CANCELLED].includes(pe.status));return Xe.length===0?null:Xe.sort((pe,et)=>Z(et)-Z(pe))[0]??null},[b]),M=j?.id??"",L=j?.status===Le.RUNNING||j?.status===Le.PENDING,T=!!e.projectArchivedAt,B=!!e.projectRepoDeletedAt,I=m(B?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),H=k.useMemo(()=>!j||!b?!1:!b.some(Z=>Z.status==="ACTIVE"&&Z.sessions?.some(xe=>xe.id===j.id)),[j,b]),{data:W}=Hs(),[A,N]=k.useState(null);k.useEffect(()=>{N(j?.providerId??null)},[j?.providerId]);const P=k.useMemo(()=>{if(b){for(const V of b)if(V.status==="ACTIVE"&&V.worktreePath)return V.worktreePath;return b[0]?.worktreePath}},[b]),O=Mo({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),$=No({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),X=k.useMemo(()=>{if(b)return b.find(V=>V.status==="ACTIVE")?.id},[b]),K=k.useMemo(()=>{const V=[];if(b&&b.length>0){const Z=b.some(Se=>Se.status==="ACTIVE");b.some(Se=>Se.sessions?.some(He=>He.status===Le.RUNNING||He.status===Le.PENDING))&&V.push(m("正在运行的 Agent 将被停止")),Z&&(V.push(m("分支上未合并的变更将丢失")),V.push(m("关联的工作目录(worktree)将被清理")))}return V},[b,m]),Q=Qr(),se=Vr(),D=Ro(),{isConnected:F,isLoadingSnapshot:U,logs:z,entries:te,attach:Y}=hn({sessionId:M,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:ie}=un(te),{files:ge,addFiles:me,removeFile:Me,clear:re,buildMarkdownLinks:Be,hasFiles:Ce,isUploading:oe}=Zr(),Ne=k.useMemo(()=>{if(!j?.tokenUsage)return;const V=j.tokenUsage;if(typeof V.totalTokens=="number")return V},[j?.tokenUsage]),qe=Do(z,Ne);k.useEffect(()=>{M&&F&&Y()},[M,F,Y]),k.useEffect(()=>{w()},[e.id,w]);const Re=k.useRef(!1),Ve=k.useCallback(async()=>{if(!r.trim()&&!Ce||!M||Re.current||oe)return;Re.current=!0;const V=Be(),Z=[r.trim(),V].filter(Boolean).join(`
82
82
 
83
- `);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:M,message:Z,providerId:A??void 0},{onSuccess:()=>Y(),onSettled:()=>{Re.current=!1}})},[r,M,Q,Y,Ce,oe,Be,re,A]),be=k.useCallback(async()=>{M&&(await D.mutateAsync(M),E.invalidateQueries({queryKey:["workspaces"]}))},[M,D,E]),st=k.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&me(Array.from(Z)),V.target.value=""},[me]),Ke=k.useCallback(V=>{const Z=V.clipboardData.items,xe=[];for(const Se of Z)if(Se.kind==="file"){const He=Se.getAsFile();He&&xe.push(He)}xe.length>0&&(V.preventDefault(),me(xe))},[me]),Pe=k.useCallback(V=>{i(V.target.value);const Z=V.target;Z.style.height="auto",Z.style.height=`${Math.max(40,Math.min(Z.scrollHeight,140))}px`},[]),Oe=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),De=k.useRef(null);return k.useEffect(()=>{const V=window.visualViewport;if(!V)return;let Z=!1;const xe=()=>{De.current&&(De.current.style.height=`${V.height}px`,De.current.style.top=`${V.offsetTop}px`)},Se=()=>xe(),He=()=>{Z||xe()},Xe=()=>{Z=!0},pe=()=>{Z=!1,requestAnimationFrame(xe)};return V.addEventListener("resize",Se),V.addEventListener("scroll",He),document.addEventListener("touchstart",Xe,{passive:!0}),document.addEventListener("touchend",pe,{passive:!0}),document.addEventListener("touchcancel",pe,{passive:!0}),()=>{V.removeEventListener("resize",Se),V.removeEventListener("scroll",He),document.removeEventListener("touchstart",Xe),document.removeEventListener("touchend",pe),document.removeEventListener("touchcancel",pe)}},[]),k.useEffect(()=>{const V=De.current;if(!V)return;const Z=xe=>{let Se=xe.target;for(;Se&&Se!==V;){if(Se.tagName==="TEXTAREA"){if(Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement;continue}const Xe=window.getComputedStyle(Se).overflowY;if((Xe==="auto"||Xe==="scroll")&&Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement}xe.preventDefault()};return V.addEventListener("touchmove",Z,{passive:!1}),()=>V.removeEventListener("touchmove",Z)},[]),a.jsxs("div",{ref:De,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[a.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[a.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[a.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:a.jsx(_a,{size:18})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),a.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[a.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(Gm,{status:e.status}),a.jsx("button",{onClick:Oe,disabled:!X||T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(zs,{size:16})}),s&&!T&&a.jsxs("div",{className:"relative",ref:n,children:[a.jsx("button",{onClick:()=>S(V=>!V),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(yn,{size:16})}),x&&a.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:a.jsxs("button",{onClick:()=>{p(!0),S(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:Qm.map(({key:V,label:Z,icon:xe})=>a.jsxs("button",{onClick:()=>C(V),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===V?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(xe,{size:13}),a.jsx("span",{children:Z})]},V))})]}),v==="chat"&&a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:u,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:_,children:[a.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx(dn,{urlTransform:Xm,components:Vm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(tn,{label:"Loading..."}):M?U?a.jsx(tn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:L?"Waiting for agent output...":"No logs recorded."}):a.jsx(fn,{logs:z}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:a.jsx(Ot,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:T?I:m("选择一个 Agent 来执行此任务")}),!T&&a.jsxs(dt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!y&&a.jsxs("button",{onClick:()=>w(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(bn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ie.length>0&&a.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:a.jsx(mn,{todos:ie,compact:!0})}),T?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:I})}):H?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[a.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),a.jsxs(dt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):M&&a.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[a.jsxs("div",{ref:g,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Ns,{files:ge,onRemove:Me}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ke,onKeyDown:V=>{$.handleKeyDown(V)||O.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),Ve())},rows:1,placeholder:L?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:st}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[a.jsx("div",{className:"flex items-center gap-0.5",children:a.jsx("button",{onClick:()=>h.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ws,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[j&&W&&a.jsx(jo,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Kn,{usage:qe}),L&&!r.trim()&&!Ce?a.jsx("button",{onClick:be,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(pn,{size:12})}):a.jsx("button",{onClick:Ve,disabled:!r.trim()&&!Ce||oe,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||Ce)&&!oe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Sn,{size:15})})]})]})]}),a.jsx(Ps,{open:O.query!==null,anchorRef:g,commands:O.filteredCommands,selectedIndex:O.selectedIndex,query:O.query??"",hasCatalog:O.allCommands.length>0,compact:!0,onSelect:O.applyCommand}),a.jsx(Ps,{open:$.query!==null,anchorRef:g,commands:$.filteredSkills,selectedIndex:$.selectedIndex,query:$.query??"",hasCatalog:$.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:$.applySkill})]})]}),v==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Im,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(qm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Co,{sessionId:M||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Ao,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(xr,{isOpen:o,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),K.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:K.map((V,Z)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:V})]},Z))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function tn({label:e}){return a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:e})]})}var Jm=Object.defineProperty,Bs=Object.getOwnPropertySymbols,Io=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,sn=(e,t,s)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dr=(e,t)=>{for(var s in t||(t={}))Io.call(t,s)&&sn(e,s,t[s]);if(Bs)for(var s of Bs(t))Fo.call(t,s)&&sn(e,s,t[s]);return e},Ar=(e,t)=>{var s={};for(var l in e)Io.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&Bs)for(var l of Bs(e))t.indexOf(l)<0&&Fo.call(e,l)&&(s[l]=e[l]);return s};var It;(e=>{const t=class de{constructor(i,c,f,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(f);if(this.drawCodewords(x),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const f=e.QrSegment.makeSegments(i);return de.encodeSegments(f,c)}static encodeBinary(i,c){const f=e.QrSegment.makeBytes(i);return de.encodeSegments([f],c)}static encodeSegments(i,c,f=1,o=40,p=-1,x=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=f;;S++){const u=de.getNumDataCodewords(S,c)*8,_=C.getTotalBits(i,S);if(_<=u){g=_;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])x&&g<=de.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(S,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let f=0;f<c;f++)for(let o=0;o<c;o++)f==0&&o==0||f==0&&o==c-1||f==c-1&&o==0||this.drawAlignmentPattern(i[f],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const o=(c<<10|f)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(o,p));this.setFunctionModule(8,7,l(o,6)),this.setFunctionModule(8,8,l(o,7)),this.setFunctionModule(7,8,l(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let f=0;f<12;f++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let f=0;f<18;f++){const o=l(c,f),p=this.size-11+f%3,x=Math.floor(f/3);this.setFunctionModule(p,x,o),this.setFunctionModule(x,p,o)}}drawFinderPattern(i,c){for(let f=-4;f<=4;f++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(f)),x=i+o,S=c+f;0<=x&&x<this.size&&0<=S&&S<this.size&&this.setFunctionModule(x,S,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let f=-2;f<=2;f++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+f,Math.max(Math.abs(o),Math.abs(f))!=1)}setFunctionModule(i,c,f){this.modules[c][i]=f,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,f=this.errorCorrectionLevel;if(i.length!=de.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const o=de.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=de.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],x=Math.floor(de.getNumRawDataModules(c)/8),S=o-x%o,g=Math.floor(x/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let y=i.slice(_,_+g-p+(u<S?0:1));_+=y.length;const w=de.reedSolomonComputeRemainder(y,d);u<S&&y.push(0),n.push(y.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,y)=>{(u!=g-p||y>=S)&&h.push(_[u])});return m(h.length==x),h}drawCodewords(i){if(i.length!=Math.floor(de.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const x=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][x]&&c<i.length*8&&(this.modules[g][x]=l(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let o;switch(i){case 0:o=(f+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=f%3==0;break;case 3:o=(f+c)%3==0;break;case 4:o=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:o=f*c%2+f*c%3==0;break;case 6:o=(f*c%2+f*c%3)%2==0;break;case 7:o=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&o&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let x=0;x<this.size-1;x++){const S=this.modules[p][x];S==this.modules[p][x+1]&&S==this.modules[p+1][x]&&S==this.modules[p+1][x+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((x,S)=>x+(S?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),i+=o*de.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let f=[6];for(let o=this.size-7;f.length<i;o-=c)f.splice(1,0,o);return f}}static getNumRawDataModules(i){if(i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const f=Math.floor(i/7)+2;c-=(25*f-10)*f-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(de.getNumRawDataModules(i)/8)-de.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*de.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<i-1;o++)c.push(0);c.push(1);let f=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=de.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=de.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(i,c){let f=c.map(o=>0);for(const o of i){const p=o^f.shift();f.push(0),c.forEach((x,S)=>f[S]^=de.reedSolomonMultiply(x,p))}return f}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let o=7;o>=0;o--)f=f<<1^(f>>>7)*285,f^=(c>>>o&1)*i;return m(f>>>8==0),f}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const f=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(f&&i[0]>=c*4&&i[6]>=c?1:0)+(f&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,f){return i&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(r,i,c){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let f=i-1;f>=0;f--)c.push(r>>>f&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const v=class Ie{constructor(i,c,f){if(this.mode=i,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(i){let c=[];for(const f of i)s(f,8,c);return new Ie(Ie.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ie.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<i.length;){const o=Math.min(i.length-f,3);s(parseInt(i.substring(f,f+o),10),o*3+1,c),f+=o}return new Ie(Ie.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ie.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=i.length;f+=2){let o=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Ie(Ie.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ie.isNumeric(i)?[Ie.makeNumeric(i)]:Ie.isAlphanumeric(i)?[Ie.makeAlphanumeric(i)]:[Ie.makeBytes(Ie.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,c);else if(i<16384)s(2,2,c),s(i,14,c);else if(i<1e6)s(6,3,c),s(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Ie(Ie.Mode.ECI,0,c)}static isNumeric(i){return Ie.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ie.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let f=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;f+=4+p+o.bitData.length}return f}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let f=0;f<i.length;f++)i.charAt(f)!="%"?c.push(i.charCodeAt(f)):(c.push(parseInt(i.substring(f+1,f+3),16)),f+=2);return c}};v.NUMERIC_REGEX=/^[0-9]*$/,v.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,v.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=v;e.QrSegment=v})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.ordinal=m,this.formatBits=v}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.modeBits=m,this.numBitsCharCount=v}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(It||(It={}));var $t=It;var ep={L:$t.QrCode.Ecc.LOW,M:$t.QrCode.Ecc.MEDIUM,Q:$t.QrCode.Ecc.QUARTILE,H:$t.QrCode.Ecc.HIGH},Ho=128,zo="L",Wo="#FFFFFF",$o="#000000",Uo=!1,qo=1,tp=4,sp=0,rp=.1;function Ko(e,t=0){const s=[];return e.forEach(function(l,m){let v=null;l.forEach(function(C,r){if(!C&&v!==null){s.push(`M${v+t} ${m+t}h${r-v}v1H${v+t}z`),v=null;return}if(r===l.length-1){if(!C)return;v===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${v+t},${m+t} h${r+1-v}v1H${v+t}z`);return}C&&v===null&&(v=r)})}),s.join("")}function Xo(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function ip(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*rp),C=m/t,r=(l.width||v)*C,i=(l.height||v)*C,c=l.x==null?e.length/2-r/2:l.x*C,f=l.y==null?e.length/2-i/2:l.y*C,o=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let S=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-S),d=Math.ceil(i+f-g);p={x:S,y:g,w:n,h:d}}const x=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:x}}function np(e,t){return t!=null?Math.max(Math.floor(t),0):e?tp:sp}function Yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...$t.QrSegment.makeSegments(n)),g),[]);return $t.QrCode.encodeSegments(S,ep[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let x=i.getModules();const S=np(l,m),g=x.length+S*2,n=ip(x,C,S,v);return{cells:x,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var op=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ap=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,marginSize:p,imageSettings:x}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=Ar(g,["style"]),h=x?.src,u=ee.useRef(null),_=ee.useRef(null),y=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=ee.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:M}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:x,size:v});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=M!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&M.excavation!=null&&(H=Xo(R,M.excavation));const N=window.devicePixelRatio||1;B.height=B.width=v*N;const P=v/j*N;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,op?I.fill(new Path2D(Ko(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),M&&(I.globalAlpha=M.opacity),A&&I.drawImage(W,M.x+b,M.y+b,M.w,M.h)}}),ee.useEffect(()=>{E(!1)},[h]);const L=Dr({height:v,width:v},n);let T=null;return h!=null&&(T=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:M?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",Dr({style:L,height:v,width:v,ref:y,role:"img"},d)),T)});ap.displayName="QRCodeCanvas";var Vo=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,title:p,marginSize:x,imageSettings:S}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:x,imageSettings:S,size:v});let _=d,y=null;S!=null&&u!=null&&(u.excavation!=null&&(_=Xo(d,u.excavation)),y=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Ko(_,n);return ee.createElement("svg",Dr({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),y)});Vo.displayName="QRCodeSVG";function lp(){return ht({queryKey:le.tunnel.status,queryFn:()=>fe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function cp(){const e=We();return Ze({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return fe.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function hp(){const e=We();return Ze({mutationFn:()=>fe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function rn(){const{t:e}=ce(),{data:t}=lp(),s=cp(),l=hp(),[m,v]=k.useState(!1),[C,r]=k.useState(null),i=k.useRef(null),[c,f]=k.useState({top:0,right:0}),[o,p]=k.useState(!1),x=t?.running??!1,S=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const y=i.current.getBoundingClientRect();f({top:y.bottom+8,right:window.innerWidth-y.right})}},[m]);const d=k.useCallback(()=>{x?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[x,s]),h=k.useCallback(()=>{g&&(navigator.clipboard.writeText(g),r("url"),setTimeout(()=>r(null),2e3))},[g]),u=k.useCallback(()=>{n&&(navigator.clipboard.writeText(n),r("token"),setTimeout(()=>r(null),2e3))},[n]),_=k.useCallback(()=>{l.mutate(),v(!1),p(!1)},[l]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:i,onClick:d,disabled:S,className:`p-1.5 rounded-md transition-colors ${x?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(x?"Tunnel active":"Share via tunnel"),children:S?a.jsx(ze,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),x&&!S&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&x&&Nt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:c.top,right:c.right},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),e("Tunnel Active")]}),a.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(Fs,{size:14})})]}),n&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[a.jsx(vl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Vo,{value:g,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:g??t?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:y=>y.target.select()}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:e("Copy shareable link"),children:C==="url"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(ui,{size:14})})]}),n&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>p(!o),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(o?"Hide token":"Show token")}),o&&a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:n}),a.jsx("button",{onClick:u,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:C==="token"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(ui,{size:14})})]})]}),a.jsx("button",{onClick:_,disabled:l.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:l.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}const nn={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>cn(()=>import("./modal-BlrEFlKt.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),gr=k.lazy(()=>cn(()=>import("./folder-picker-CWyzaOjA.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),on=a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),an=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),up=260,dp=600,ln=400;function Rp(){const{t:e}=ce(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(ln),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[x,S]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[y,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:M,clear:L,buildMarkdownLinks:T,isUploading:B}=Zr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(ln),N=k.useRef(null),P=We(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=ba(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(km),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Of(D??""),z=Da({queries:D?[]:Q.map(q=>({queryKey:le.tasks.list(q.id),queryFn:()=>fe.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),te=!D&&z.some(q=>q.isLoading),Y=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const J of z)J.data?.data&&q.push(...J.data.data);return q},[D,F,z]),ie=t&&Y.some(q=>q.id===t)?t:null,ge=k.useMemo(()=>{const q=new Map;for(const J of Y){const he=J.createdAt?new Date(J.createdAt).getTime():0,ue=q.get(J.projectId)??0;he>ue&&q.set(J.projectId,he)}return[...Q].sort((J,he)=>{const ue=q.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(q.get(he.id)??(he.createdAt?new Date(he.createdAt).getTime():0))-ue})},[Q,Y]),me=k.useMemo(()=>ge.filter(q=>!q.archivedAt),[ge]),Me=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),J=q?JSON.parse(q):{};return[...O].sort((he,ue)=>{const ve=he.availability.type!=="NOT_FOUND",Ae=ue.availability.type!=="NOT_FOUND";if(ve!==Ae)return ve?-1:1;const mt=J[he.provider.id]??0;return(J[ue.provider.id]??0)-mt})},[O]),re=k.useMemo(()=>Y.map(Dm),[Y]),Be=k.useMemo(()=>new Set,[]),Ce=k.useMemo(()=>{if(!ie)return null;const q=Y.find(he=>he.id===ie);if(!q)return null;const J=Q.find(he=>he.id===q.projectId);if(!J){const he=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Jr(q.status),branch:he,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Am(q,J)},[ie,Y,Q]),oe=xa(),Ne=Bf(u),qe=Ff(),Re=If(),Ve=k.useCallback(q=>{qe.mutate(q,{onSuccess:()=>{ie===q&&s(null),P.invalidateQueries({queryKey:le.tasks.all})}})},[qe,ie,P]),be=k.useCallback((q,J)=>{Re.mutate({id:q,status:wm(J)},{onError:()=>{ni.error(e("状态变更失败,该操作不被允许"))}})},[Re,e]),st=k.useCallback(q=>{q.preventDefault(),H.current=!0,W.current=q.clientX,A.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);k.useEffect(()=>{const q=he=>{if(!H.current)return;const ue=he.clientX-W.current,ve=Math.max(up,Math.min(dp,A.current+ue));C(ve)},J=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",J)}},[]);const Ke=k.useCallback(()=>{i(!0)},[]),Pe=k.useCallback(()=>{if(me.length===0){ni.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),J=localStorage.getItem("lastSelectedProviderId"),he=q&&me.find(Ae=>Ae.id===q)?q:(D&&me.find(Ae=>Ae.id===D)?.id)??me[0]?.id??"";_(he);const ue=Me?.find(Ae=>Ae.availability.type!=="NOT_FOUND"),ve=J&&Me?.find(Ae=>Ae.provider.id===J&&Ae.availability.type!=="NOT_FOUND")?J:ue?.provider.id??"";w(ve),b("idle"),f(!0)},[me,D,Me,e]),Oe=k.useCallback(()=>{i(!1),p(""),S("")},[]),De=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),L())},[E,L]),V=k.useCallback(async()=>{if(!(!o.trim()||!x.trim()))try{await oe.mutateAsync({name:o.trim(),repoPath:x.trim()}),Oe()}catch{}},[o,x,oe,Oe]),Z=Gr(),xe=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),J=[d.trim(),q].filter(Boolean).join(`
83
+ `);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:M,message:Z,providerId:A??void 0},{onSuccess:()=>Y(),onSettled:()=>{Re.current=!1}})},[r,M,Q,Y,Ce,oe,Be,re,A]),be=k.useCallback(async()=>{M&&(await D.mutateAsync(M),E.invalidateQueries({queryKey:["workspaces"]}))},[M,D,E]),st=k.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&me(Array.from(Z)),V.target.value=""},[me]),Ke=k.useCallback(V=>{const Z=V.clipboardData.items,xe=[];for(const Se of Z)if(Se.kind==="file"){const He=Se.getAsFile();He&&xe.push(He)}xe.length>0&&(V.preventDefault(),me(xe))},[me]),Pe=k.useCallback(V=>{i(V.target.value);const Z=V.target;Z.style.height="auto",Z.style.height=`${Math.max(40,Math.min(Z.scrollHeight,140))}px`},[]),Oe=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),De=k.useRef(null);return k.useEffect(()=>{const V=window.visualViewport;if(!V)return;let Z=!1;const xe=()=>{De.current&&(De.current.style.height=`${V.height}px`,De.current.style.top=`${V.offsetTop}px`)},Se=()=>xe(),He=()=>{Z||xe()},Xe=()=>{Z=!0},pe=()=>{Z=!1,requestAnimationFrame(xe)};return V.addEventListener("resize",Se),V.addEventListener("scroll",He),document.addEventListener("touchstart",Xe,{passive:!0}),document.addEventListener("touchend",pe,{passive:!0}),document.addEventListener("touchcancel",pe,{passive:!0}),()=>{V.removeEventListener("resize",Se),V.removeEventListener("scroll",He),document.removeEventListener("touchstart",Xe),document.removeEventListener("touchend",pe),document.removeEventListener("touchcancel",pe)}},[]),k.useEffect(()=>{const V=De.current;if(!V)return;const Z=xe=>{let Se=xe.target;for(;Se&&Se!==V;){if(Se.tagName==="TEXTAREA"){if(Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement;continue}const Xe=window.getComputedStyle(Se).overflowY;if((Xe==="auto"||Xe==="scroll")&&Se.scrollHeight>Se.clientHeight)return;Se=Se.parentElement}xe.preventDefault()};return V.addEventListener("touchmove",Z,{passive:!1}),()=>V.removeEventListener("touchmove",Z)},[]),a.jsxs("div",{ref:De,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[a.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[a.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[a.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:a.jsx(_a,{size:18})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),a.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[a.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&a.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),a.jsx("span",{className:"text-neutral-300",children:"/"}),a.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),a.jsx(Gm,{status:e.status}),a.jsx("button",{onClick:Oe,disabled:!X||T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:a.jsx(zs,{size:16})}),s&&!T&&a.jsxs("div",{className:"relative",ref:n,children:[a.jsx("button",{onClick:()=>S(V=>!V),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(yn,{size:16})}),x&&a.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:a.jsxs("button",{onClick:()=>{p(!0),S(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[a.jsx(vn,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:Qm.map(({key:V,label:Z,icon:xe})=>a.jsxs("button",{onClick:()=>C(V),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===V?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(xe,{size:13}),a.jsx("span",{children:Z})]},V))})]}),v==="chat"&&a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{ref:u,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:a.jsxs("div",{ref:_,children:[a.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?a.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:a.jsx(dn,{urlTransform:Xm,components:Vm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(tn,{label:"Loading..."}):M?U?a.jsx(tn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:L?"Waiting for agent output...":"No logs recorded."}):a.jsx(fn,{logs:z}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:a.jsx(Ot,{size:20,className:"text-neutral-400 ml-0.5"})}),a.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),a.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:T?I:m("选择一个 Agent 来执行此任务")}),!T&&a.jsxs(dt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!y&&a.jsxs("button",{onClick:()=>w(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[a.jsx(bn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ie.length>0&&a.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:a.jsx(mn,{todos:ie,compact:!0})}),T?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:I})}):H?a.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[a.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),a.jsxs(dt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):M&&a.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[a.jsxs("div",{ref:g,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[a.jsx(Ns,{files:ge,onRemove:Me}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ke,onKeyDown:V=>{$.handleKeyDown(V)||O.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),Ve())},rows:1,placeholder:L?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),a.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:st}),a.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[a.jsx("div",{className:"flex items-center gap-0.5",children:a.jsx("button",{onClick:()=>h.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:a.jsx(ws,{size:15})})}),a.jsxs("div",{className:"flex items-center gap-1",children:[j&&W&&a.jsx(jo,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Kn,{usage:qe}),L&&!r.trim()&&!Ce?a.jsx("button",{onClick:be,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(pn,{size:12})}):a.jsx("button",{onClick:Ve,disabled:!r.trim()&&!Ce||oe,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||Ce)&&!oe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Sn,{size:15})})]})]})]}),a.jsx(Ps,{open:O.query!==null,anchorRef:g,commands:O.filteredCommands,selectedIndex:O.selectedIndex,query:O.query??"",hasCatalog:O.allCommands.length>0,compact:!0,onSelect:O.applyCommand}),a.jsx(Ps,{open:$.query!==null,anchorRef:g,commands:$.filteredSkills,selectedIndex:$.selectedIndex,query:$.query??"",hasCatalog:$.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:$.applySkill})]})]}),v==="changes"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Im,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(qm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Co,{sessionId:M||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Ao,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(xr,{isOpen:o,onClose:()=>p(!1),onConfirm:()=>{s?.(e.id),p(!1)},title:m("删除任务"),description:a.jsxs(a.Fragment,{children:[a.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),K.length>0&&a.jsx("ul",{className:"mt-2 space-y-1",children:K.map((V,Z)=>a.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[a.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),a.jsx("span",{children:V})]},Z))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function tn({label:e}){return a.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[a.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),a.jsx("span",{className:"text-sm",children:e})]})}var Jm=Object.defineProperty,Bs=Object.getOwnPropertySymbols,Io=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,sn=(e,t,s)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dr=(e,t)=>{for(var s in t||(t={}))Io.call(t,s)&&sn(e,s,t[s]);if(Bs)for(var s of Bs(t))Fo.call(t,s)&&sn(e,s,t[s]);return e},Ar=(e,t)=>{var s={};for(var l in e)Io.call(e,l)&&t.indexOf(l)<0&&(s[l]=e[l]);if(e!=null&&Bs)for(var l of Bs(e))t.indexOf(l)<0&&Fo.call(e,l)&&(s[l]=e[l]);return s};var It;(e=>{const t=class de{constructor(i,c,f,o){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let S=0;S<this.size;S++)p.push(!1);for(let S=0;S<this.size;S++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(f);if(this.drawCodewords(x),o==-1){let S=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<S&&(o=g,S=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,c){const f=e.QrSegment.makeSegments(i);return de.encodeSegments(f,c)}static encodeBinary(i,c){const f=e.QrSegment.makeBytes(i);return de.encodeSegments([f],c)}static encodeSegments(i,c,f=1,o=40,p=-1,x=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let S,g;for(S=f;;S++){const u=de.getNumDataCodewords(S,c)*8,_=C.getTotalBits(i,S);if(_<=u){g=_;break}if(S>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])x&&g<=de.getNumDataCodewords(S,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(S),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(S,c)*8;m(n.length<=d),s(0,Math.min(4,d-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<d;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,_)=>h[_>>>3]|=u<<7-(_&7)),new de(S,c,h,p)}getModule(i,c){return 0<=i&&i<this.size&&0<=c&&c<this.size&&this.modules[c][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),c=i.length;for(let f=0;f<c;f++)for(let o=0;o<c;o++)f==0&&o==0||f==0&&o==c-1||f==c-1&&o==0||this.drawAlignmentPattern(i[f],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let f=c;for(let p=0;p<10;p++)f=f<<1^(f>>>9)*1335;const o=(c<<10|f)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,l(o,p));this.setFunctionModule(8,7,l(o,6)),this.setFunctionModule(8,8,l(o,7)),this.setFunctionModule(7,8,l(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,l(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,l(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,l(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let f=0;f<12;f++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let f=0;f<18;f++){const o=l(c,f),p=this.size-11+f%3,x=Math.floor(f/3);this.setFunctionModule(p,x,o),this.setFunctionModule(x,p,o)}}drawFinderPattern(i,c){for(let f=-4;f<=4;f++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(f)),x=i+o,S=c+f;0<=x&&x<this.size&&0<=S&&S<this.size&&this.setFunctionModule(x,S,p!=2&&p!=4)}}drawAlignmentPattern(i,c){for(let f=-2;f<=2;f++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,c+f,Math.max(Math.abs(o),Math.abs(f))!=1)}setFunctionModule(i,c,f){this.modules[c][i]=f,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,f=this.errorCorrectionLevel;if(i.length!=de.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const o=de.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],p=de.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],x=Math.floor(de.getNumRawDataModules(c)/8),S=o-x%o,g=Math.floor(x/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let y=i.slice(_,_+g-p+(u<S?0:1));_+=y.length;const w=de.reedSolomonComputeRemainder(y,d);u<S&&y.push(0),n.push(y.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,y)=>{(u!=g-p||y>=S)&&h.push(_[u])});return m(h.length==x),h}drawCodewords(i){if(i.length!=Math.floor(de.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const x=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][x]&&c<i.length*8&&(this.modules[g][x]=l(i[c>>>3],7-(c&7)),c++)}}m(c==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let o;switch(i){case 0:o=(f+c)%2==0;break;case 1:o=c%2==0;break;case 2:o=f%3==0;break;case 3:o=(f+c)%3==0;break;case 4:o=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:o=f*c%2+f*c%3==0;break;case 6:o=(f*c%2+f*c%3)%2==0;break;case 7:o=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&o&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[p][n],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let x=!1,S=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==x?(S++,S==5?i+=de.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,g),x||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),x=this.modules[n][p],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let x=0;x<this.size-1;x++){const S=this.modules[p][x];S==this.modules[p][x+1]&&S==this.modules[p+1][x]&&S==this.modules[p+1][x+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((x,S)=>x+(S?1:0),c);const f=this.size*this.size,o=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=o&&o<=9),i+=o*de.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let f=[6];for(let o=this.size-7;f.length<i;o-=c)f.splice(1,0,o);return f}}static getNumRawDataModules(i){if(i<de.MIN_VERSION||i>de.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const f=Math.floor(i/7)+2;c-=(25*f-10)*f-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(de.getNumRawDataModules(i)/8)-de.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*de.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let c=[];for(let o=0;o<i-1;o++)c.push(0);c.push(1);let f=1;for(let o=0;o<i;o++){for(let p=0;p<c.length;p++)c[p]=de.reedSolomonMultiply(c[p],f),p+1<c.length&&(c[p]^=c[p+1]);f=de.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(i,c){let f=c.map(o=>0);for(const o of i){const p=o^f.shift();f.push(0),c.forEach((x,S)=>f[S]^=de.reedSolomonMultiply(x,p))}return f}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let o=7;o>=0;o--)f=f<<1^(f>>>7)*285,f^=(c>>>o&1)*i;return m(f>>>8==0),f}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const f=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(f&&i[0]>=c*4&&i[6]>=c?1:0)+(f&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,f){return i&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(r,i,c){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let f=i-1;f>=0;f--)c.push(r>>>f&1)}function l(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const v=class Ie{constructor(i,c,f){if(this.mode=i,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(i){let c=[];for(const f of i)s(f,8,c);return new Ie(Ie.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ie.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<i.length;){const o=Math.min(i.length-f,3);s(parseInt(i.substring(f,f+o),10),o*3+1,c),f+=o}return new Ie(Ie.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ie.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=i.length;f+=2){let o=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Ie.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Ie(Ie.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ie.isNumeric(i)?[Ie.makeNumeric(i)]:Ie.isAlphanumeric(i)?[Ie.makeAlphanumeric(i)]:[Ie.makeBytes(Ie.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,c);else if(i<16384)s(2,2,c),s(i,14,c);else if(i<1e6)s(6,3,c),s(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Ie(Ie.Mode.ECI,0,c)}static isNumeric(i){return Ie.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ie.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let f=0;for(const o of i){const p=o.mode.numCharCountBits(c);if(o.numChars>=1<<p)return 1/0;f+=4+p+o.bitData.length}return f}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let f=0;f<i.length;f++)i.charAt(f)!="%"?c.push(i.charCodeAt(f)):(c.push(parseInt(i.substring(f+1,f+3),16)),f+=2);return c}};v.NUMERIC_REGEX=/^[0-9]*$/,v.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,v.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=v;e.QrSegment=v})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.ordinal=m,this.formatBits=v}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(It||(It={}));(e=>{(t=>{const s=class{constructor(m,v){this.modeBits=m,this.numBitsCharCount=v}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(It||(It={}));var $t=It;var ep={L:$t.QrCode.Ecc.LOW,M:$t.QrCode.Ecc.MEDIUM,Q:$t.QrCode.Ecc.QUARTILE,H:$t.QrCode.Ecc.HIGH},Ho=128,zo="L",Wo="#FFFFFF",$o="#000000",Uo=!1,qo=1,tp=4,sp=0,rp=.1;function Ko(e,t=0){const s=[];return e.forEach(function(l,m){let v=null;l.forEach(function(C,r){if(!C&&v!==null){s.push(`M${v+t} ${m+t}h${r-v}v1H${v+t}z`),v=null;return}if(r===l.length-1){if(!C)return;v===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${v+t},${m+t} h${r+1-v}v1H${v+t}z`);return}C&&v===null&&(v=r)})}),s.join("")}function Xo(e,t){return e.slice().map((s,l)=>l<t.y||l>=t.y+t.h?s:s.map((m,v)=>v<t.x||v>=t.x+t.w?m:!1))}function ip(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*rp),C=m/t,r=(l.width||v)*C,i=(l.height||v)*C,c=l.x==null?e.length/2-r/2:l.x*C,f=l.y==null?e.length/2-i/2:l.y*C,o=l.opacity==null?1:l.opacity;let p=null;if(l.excavate){let S=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-S),d=Math.ceil(i+f-g);p={x:S,y:g,w:n,h:d}}const x=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:x}}function np(e,t){return t!=null?Math.max(Math.floor(t),0):e?tp:sp}function Yo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=ee.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...$t.QrSegment.makeSegments(n)),g),[]);return $t.QrCode.encodeSegments(S,ep[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=ee.useMemo(()=>{let x=i.getModules();const S=np(l,m),g=x.length+S*2,n=ip(x,C,S,v);return{cells:x,margin:S,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var op=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ap=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,marginSize:p,imageSettings:x}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=Ar(g,["style"]),h=x?.src,u=ee.useRef(null),_=ee.useRef(null),y=ee.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=ee.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:M}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:x,size:v});ee.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=M!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&M.excavation!=null&&(H=Xo(R,M.excavation));const N=window.devicePixelRatio||1;B.height=B.width=v*N;const P=v/j*N;I.scale(P,P),I.fillStyle=r,I.fillRect(0,0,j,j),I.fillStyle=i,op?I.fill(new Path2D(Ko(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),M&&(I.globalAlpha=M.opacity),A&&I.drawImage(W,M.x+b,M.y+b,M.w,M.h)}}),ee.useEffect(()=>{E(!1)},[h]);const L=Dr({height:v,width:v},n);let T=null;return h!=null&&(T=ee.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:M?.crossOrigin})),ee.createElement(ee.Fragment,null,ee.createElement("canvas",Dr({style:L,height:v,width:v,ref:y,role:"img"},d)),T)});ap.displayName="QRCodeCanvas";var Vo=ee.forwardRef(function(t,s){const l=t,{value:m,size:v=Ho,level:C=zo,bgColor:r=Wo,fgColor:i=$o,includeMargin:c=Uo,minVersion:f=qo,boostLevel:o,title:p,marginSize:x,imageSettings:S}=l,g=Ar(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Yo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:x,imageSettings:S,size:v});let _=d,y=null;S!=null&&u!=null&&(u.excavation!=null&&(_=Xo(d,u.excavation)),y=ee.createElement("image",{href:S.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=Ko(_,n);return ee.createElement("svg",Dr({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&ee.createElement("title",null,p),ee.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),ee.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),y)});Vo.displayName="QRCodeSVG";function lp(){return ht({queryKey:le.tunnel.status,queryFn:()=>fe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function cp(){const e=We();return Ze({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return fe.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function hp(){const e=We();return Ze({mutationFn:()=>fe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function rn(){const{t:e}=ce(),{data:t}=lp(),s=cp(),l=hp(),[m,v]=k.useState(!1),[C,r]=k.useState(null),i=k.useRef(null),[c,f]=k.useState({top:0,right:0}),[o,p]=k.useState(!1),x=t?.running??!1,S=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const y=i.current.getBoundingClientRect();f({top:y.bottom+8,right:window.innerWidth-y.right})}},[m]);const d=k.useCallback(()=>{x?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[x,s]),h=k.useCallback(()=>{g&&(navigator.clipboard.writeText(g),r("url"),setTimeout(()=>r(null),2e3))},[g]),u=k.useCallback(()=>{n&&(navigator.clipboard.writeText(n),r("token"),setTimeout(()=>r(null),2e3))},[n]),_=k.useCallback(()=>{l.mutate(),v(!1),p(!1)},[l]);return a.jsxs("div",{className:"relative",children:[a.jsx("button",{ref:i,onClick:d,disabled:S,className:`p-1.5 rounded-md transition-colors ${x?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(x?"Tunnel active":"Share via tunnel"),children:S?a.jsx(ze,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),x&&!S&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&x&&Nt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),a.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:c.top,right:c.right},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),e("Tunnel Active")]}),a.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:a.jsx(Fs,{size:14})})]}),n&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[a.jsx(vl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Vo,{value:g,size:160})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{readOnly:!0,value:g??t?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:y=>y.target.select()}),a.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:e("Copy shareable link"),children:C==="url"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(ui,{size:14})})]}),n&&a.jsxs("div",{className:"mt-2",children:[a.jsx("button",{onClick:()=>p(!o),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(o?"Hide token":"Show token")}),o&&a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:n}),a.jsx("button",{onClick:u,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:C==="token"?a.jsx(ss,{size:14,className:"text-emerald-500"}):a.jsx(ui,{size:14})})]})]}),a.jsx("button",{onClick:_,disabled:l.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:l.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}const nn={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>cn(()=>import("./modal-hQOddjel.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),gr=k.lazy(()=>cn(()=>import("./folder-picker-CzSKXweo.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),on=a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[a.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),a.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),an=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),up=260,dp=600,ln=400;function Rp(){const{t:e}=ce(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(ln),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[x,S]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[y,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:M,clear:L,buildMarkdownLinks:T,isUploading:B}=Zr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(ln),N=k.useRef(null),P=We(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=ba(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(km),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Of(D??""),z=Da({queries:D?[]:Q.map(q=>({queryKey:le.tasks.list(q.id),queryFn:()=>fe.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),te=!D&&z.some(q=>q.isLoading),Y=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const J of z)J.data?.data&&q.push(...J.data.data);return q},[D,F,z]),ie=t&&Y.some(q=>q.id===t)?t:null,ge=k.useMemo(()=>{const q=new Map;for(const J of Y){const he=J.createdAt?new Date(J.createdAt).getTime():0,ue=q.get(J.projectId)??0;he>ue&&q.set(J.projectId,he)}return[...Q].sort((J,he)=>{const ue=q.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(q.get(he.id)??(he.createdAt?new Date(he.createdAt).getTime():0))-ue})},[Q,Y]),me=k.useMemo(()=>ge.filter(q=>!q.archivedAt),[ge]),Me=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),J=q?JSON.parse(q):{};return[...O].sort((he,ue)=>{const ve=he.availability.type!=="NOT_FOUND",Ae=ue.availability.type!=="NOT_FOUND";if(ve!==Ae)return ve?-1:1;const mt=J[he.provider.id]??0;return(J[ue.provider.id]??0)-mt})},[O]),re=k.useMemo(()=>Y.map(Dm),[Y]),Be=k.useMemo(()=>new Set,[]),Ce=k.useMemo(()=>{if(!ie)return null;const q=Y.find(he=>he.id===ie);if(!q)return null;const J=Q.find(he=>he.id===q.projectId);if(!J){const he=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Jr(q.status),branch:he,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Am(q,J)},[ie,Y,Q]),oe=xa(),Ne=Bf(u),qe=Ff(),Re=If(),Ve=k.useCallback(q=>{qe.mutate(q,{onSuccess:()=>{ie===q&&s(null),P.invalidateQueries({queryKey:le.tasks.all})}})},[qe,ie,P]),be=k.useCallback((q,J)=>{Re.mutate({id:q,status:wm(J)},{onError:()=>{ni.error(e("状态变更失败,该操作不被允许"))}})},[Re,e]),st=k.useCallback(q=>{q.preventDefault(),H.current=!0,W.current=q.clientX,A.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);k.useEffect(()=>{const q=he=>{if(!H.current)return;const ue=he.clientX-W.current,ve=Math.max(up,Math.min(dp,A.current+ue));C(ve)},J=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",J)}},[]);const Ke=k.useCallback(()=>{i(!0)},[]),Pe=k.useCallback(()=>{if(me.length===0){ni.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),J=localStorage.getItem("lastSelectedProviderId"),he=q&&me.find(Ae=>Ae.id===q)?q:(D&&me.find(Ae=>Ae.id===D)?.id)??me[0]?.id??"";_(he);const ue=Me?.find(Ae=>Ae.availability.type!=="NOT_FOUND"),ve=J&&Me?.find(Ae=>Ae.provider.id===J&&Ae.availability.type!=="NOT_FOUND")?J:ue?.provider.id??"";w(ve),b("idle"),f(!0)},[me,D,Me,e]),Oe=k.useCallback(()=>{i(!1),p(""),S("")},[]),De=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),L())},[E,L]),V=k.useCallback(async()=>{if(!(!o.trim()||!x.trim()))try{await oe.mutateAsync({name:o.trim(),repoPath:x.trim()}),Oe()}catch{}},[o,x,oe,Oe]),Z=Gr(),xe=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),J=[d.trim(),q].filter(Boolean).join(`
84
84
 
85
85
  `);b("creating-task");const he=await Ne.mutateAsync({title:g.trim(),description:J||void 0});if(localStorage.setItem("lastSelectedProjectId",u),y){localStorage.setItem("lastSelectedProviderId",y);const ue=localStorage.getItem("providerUsageCount"),ve=ue?JSON.parse(ue):{};ve[y]=(ve[y]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ve))}if(y){const ue=[g.trim(),J].filter(Boolean).join(`
86
86
 
@@ -1,2 +1,2 @@
1
- import{e as se,u as B,r as l,d as ne,j as e,f as re,g as le,h as ae,i as ie,t as T}from"./index-Dz23RytL.js";import{B as S}from"./button-DWEfhrOb.js";import{S as oe}from"./select-BSrh_Wca.js";import{a as W,F as _,R as ce}from"./rotate-ccw-Ca8el0Vt.js";import{X as J,P as Q,T as de,M as G}from"./modal-BlrEFlKt.js";import{FolderPicker as ue}from"./folder-picker-CWyzaOjA.js";import"./utils-CkSf8FUe.js";import"./chevron-down-r1WqxE7T.js";import"./chevron-right-BoX1HZb8.js";import"./loader-circle-6llnjfOV.js";import"./circle-alert-Dsf4sjes.js";const xe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],me=se("folder-plus",xe);function pe({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=B(),[i,c]=l.useState(""),[x,h]=l.useState([]),[N,r]=l.useState(!1),[u,y]=l.useState(-1),m=l.useRef(null),f=l.useRef(null),P=l.useRef(void 0),F=l.useCallback(async s=>{if(!b||!s){h([]),r(!1);return}try{const a=await ne.get("/filesystem/complete",{params:{basePath:b,prefix:s}});h(a.results),r(a.results.length>0),y(-1)}catch{h([]),r(!1)}},[b]);l.useEffect(()=>{if(clearTimeout(P.current),!i){h([]),r(!1);return}return P.current=setTimeout(()=>F(i),200),()=>clearTimeout(P.current)},[i,F]),l.useEffect(()=>{const s=a=>{f.current&&!f.current.contains(a.target)&&m.current&&!m.current.contains(a.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const a=s.trim();!a||t.includes(a)||(g([...t,a]),c(""),r(!1),m.current?.focus())},z=s=>{g(t.filter((a,w)=>w!==s))},D=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,a)=>{a.stopPropagation(),k(s.path.replace(/\/$/,""))},A=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(a=>Math.min(a+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(a=>Math.max(a-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?D(x[u]):k(i)):s.key==="Escape"&&r(!1):s.key==="Enter"&&(s.preventDefault(),k(i)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>z(a),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:m,type:"text",value:i,onChange:s=>c(s.target.value),onKeyDown:A,onFocus:()=>{i&&x.length>0&&r(!0)},placeholder:v??o("输入文件路径..."),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:()=>k(i),disabled:!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:f,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:x.map((s,a)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${a===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:w=>C(s,w),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:o("添加此目录"),children:e.jsx(me,{size:14})})]},s.path))})]})]})}function he({value:t,onChange:g}){const{t:b}=B(),[v,o]=l.useState(""),[i,c]=l.useState(""),x=()=>{const r=v.trim(),u=i.trim();!r||!u||(g([...t,{name:r,command:u}]),o(""),c(""))},h=r=>{g(t.filter((u,y)=>y!==r))},N=r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&r.nativeEvent.keyCode!==229&&(r.preventDefault(),x())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((r,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:r.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:r.command}),e.jsx("button",{onClick:()=>h(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:r=>o(r.target.value),onKeyDown:N,placeholder:b("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:i,onChange:r=>c(r.target.value),onKeyDown:N,placeholder:b("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:x,disabled:!v.trim()||!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function fe(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function je(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function $(t){return typeof t.color!="string"||t.color.trim()===""?"bg-neutral-400":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-neutral-400"}function De(){const{t}=B(),{data:g,isLoading:b}=re({limit:100,includeArchived:!0}),v=le(),o=ae(),i=ie(),[c,x]=l.useState(""),[h,N]=l.useState(null),[r,u]=l.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=l.useState(!1),[f,P]=l.useState(null),[F,k]=l.useState(!1),[z,D]=l.useState(!1),[C,A]=l.useState(!1),[s,a]=l.useState(!1),[w,I]=l.useState(""),R=g?.data??[],j=l.useMemo(()=>R.filter(n=>!n.archivedAt),[R]),E=l.useMemo(()=>R.filter(n=>n.archivedAt),[R]),d=j.find(n=>n.id===c),q=l.useMemo(()=>R.find(n=>n.id===f)??null,[f,R]);if(l.useEffect(()=>{!c&&j.length>0&&x(j[0].id)},[j,c]),l.useEffect(()=>{if(h){j.some(n=>n.id===h)&&(x(h),N(null));return}c&&!j.some(n=>n.id===c)&&(x(j[0]?.id??""),m(!1))},[j,h,c]),l.useEffect(()=>{d&&!y&&u({copyFiles:fe(d.copyFiles),setupScript:d.setupScript??"",quickCommands:je(d.quickCommands)})},[d,y]),b)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("加载中...")});if(R.length===0)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("暂无项目,请先创建项目")});const H=j.map(n=>({value:n.id,label:n.name})),V=()=>{c&&v.mutate({id:c,copyFiles:r.copyFiles.length>0?r.copyFiles.join(", "):null,setupScript:r.setupScript.trim()||null,quickCommands:r.quickCommands.length>0?JSON.stringify(r.quickCommands):null},{onSuccess:()=>m(!1)})},X=n=>{N(null),x(n),m(!1)},Z=()=>{d&&(P(d.id),A(!1),a(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),A(!1),a(!1))},Y=async()=>{if(f)try{await o.mutateAsync({id:f,deleteRepo:C}),T.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},ee=n=>{const p=E.find(U=>U.id===n);P(n),I(p?.repoDeletedAt?p.repoPath:""),D(!0)},M=()=>{i.isPending||(D(!1),P(null),I(""))},te=async()=>{if(!(!f||q?.repoDeletedAt&&!w.trim()))try{const p=await i.mutateAsync({id:f,repoPath:w.trim()||void 0});T.success(t("项目已恢复"));for(const U of p.warnings)T.warning(U);m(!1),N(p.project.id),x(p.project.id),M()}catch{}},K=q?.name??t("this project"),L=!!q?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl space-y-8",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("项目配置")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("配置当前项目的 worktree 初始化行为,并在此页统一管理删除与恢复。")})]}),j.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-700 mb-2",children:t("选择项目")}),e.jsx(oe,{value:c,onChange:X,options:H,placeholder:t("选择项目...")})]}),d?e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(d)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:d.name})]}),e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:d.repoPath}),d.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",d.repoRemoteUrl]}):null]}),e.jsxs("div",{className:"flex flex-col items-stretch gap-2 md:items-end",children:[e.jsxs(S,{size:"sm",variant:"destructive",onClick:Z,disabled:o.isPending||i.isPending,children:[e.jsx(de,{size:14}),t("删除项目")]}),e.jsx("p",{className:"text-[11px] text-neutral-500 md:max-w-56 md:text-right",children:t("删除后项目会从默认列表隐藏,但历史任务、workspace 与会话记录仍会保留。")})]})]})}):null]}):e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("当前没有可配置的项目。你可以先创建项目,或在下方恢复已删除项目。")})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("自动复制文件")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 时自动从主仓库复制的文件或目录。支持 glob 模式。")}),e.jsx(pe,{value:r.copyFiles,onChange:n=>{u(p=>({...p,copyFiles:n})),m(!0)},repoPath:d.repoPath}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-2",children:t("适用于不在 git 管理中但启动必需的文件,如 .env、node_modules、数据库文件等")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 后自动执行的命令,每行一条,按顺序执行。")}),e.jsx("textarea",{value:r.setupScript,onChange:n=>{u(p=>({...p,setupScript:n.target.value})),m(!0)},placeholder:`pnpm install
1
+ import{e as se,u as B,r as l,d as ne,j as e,f as re,g as le,h as ae,i as ie,t as T}from"./index-CFjAe6OM.js";import{B as S}from"./button-Dh8FHptl.js";import{S as oe}from"./select-DN0KH4Bi.js";import{a as W,F as _,R as ce}from"./rotate-ccw-Dx6ZIa1R.js";import{X as J,P as Q,T as de,M as G}from"./modal-hQOddjel.js";import{FolderPicker as ue}from"./folder-picker-CzSKXweo.js";import"./utils-CkSf8FUe.js";import"./chevron-down-B-UCtkpw.js";import"./chevron-right-CIJ95cIu.js";import"./loader-circle-BiT33tiH.js";import"./circle-alert-DwzV6nbB.js";const xe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],me=se("folder-plus",xe);function pe({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=B(),[i,c]=l.useState(""),[x,h]=l.useState([]),[N,r]=l.useState(!1),[u,y]=l.useState(-1),m=l.useRef(null),f=l.useRef(null),P=l.useRef(void 0),F=l.useCallback(async s=>{if(!b||!s){h([]),r(!1);return}try{const a=await ne.get("/filesystem/complete",{params:{basePath:b,prefix:s}});h(a.results),r(a.results.length>0),y(-1)}catch{h([]),r(!1)}},[b]);l.useEffect(()=>{if(clearTimeout(P.current),!i){h([]),r(!1);return}return P.current=setTimeout(()=>F(i),200),()=>clearTimeout(P.current)},[i,F]),l.useEffect(()=>{const s=a=>{f.current&&!f.current.contains(a.target)&&m.current&&!m.current.contains(a.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const a=s.trim();!a||t.includes(a)||(g([...t,a]),c(""),r(!1),m.current?.focus())},z=s=>{g(t.filter((a,w)=>w!==s))},D=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,a)=>{a.stopPropagation(),k(s.path.replace(/\/$/,""))},A=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(a=>Math.min(a+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(a=>Math.max(a-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?D(x[u]):k(i)):s.key==="Escape"&&r(!1):s.key==="Enter"&&(s.preventDefault(),k(i)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>z(a),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:m,type:"text",value:i,onChange:s=>c(s.target.value),onKeyDown:A,onFocus:()=>{i&&x.length>0&&r(!0)},placeholder:v??o("输入文件路径..."),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:()=>k(i),disabled:!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:f,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:x.map((s,a)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${a===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:w=>C(s,w),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:o("添加此目录"),children:e.jsx(me,{size:14})})]},s.path))})]})]})}function he({value:t,onChange:g}){const{t:b}=B(),[v,o]=l.useState(""),[i,c]=l.useState(""),x=()=>{const r=v.trim(),u=i.trim();!r||!u||(g([...t,{name:r,command:u}]),o(""),c(""))},h=r=>{g(t.filter((u,y)=>y!==r))},N=r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&r.nativeEvent.keyCode!==229&&(r.preventDefault(),x())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((r,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:r.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:r.command}),e.jsx("button",{onClick:()=>h(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:r=>o(r.target.value),onKeyDown:N,placeholder:b("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:i,onChange:r=>c(r.target.value),onKeyDown:N,placeholder:b("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:x,disabled:!v.trim()||!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function fe(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function je(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function $(t){return typeof t.color!="string"||t.color.trim()===""?"bg-neutral-400":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-neutral-400"}function De(){const{t}=B(),{data:g,isLoading:b}=re({limit:100,includeArchived:!0}),v=le(),o=ae(),i=ie(),[c,x]=l.useState(""),[h,N]=l.useState(null),[r,u]=l.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=l.useState(!1),[f,P]=l.useState(null),[F,k]=l.useState(!1),[z,D]=l.useState(!1),[C,A]=l.useState(!1),[s,a]=l.useState(!1),[w,I]=l.useState(""),R=g?.data??[],j=l.useMemo(()=>R.filter(n=>!n.archivedAt),[R]),E=l.useMemo(()=>R.filter(n=>n.archivedAt),[R]),d=j.find(n=>n.id===c),q=l.useMemo(()=>R.find(n=>n.id===f)??null,[f,R]);if(l.useEffect(()=>{!c&&j.length>0&&x(j[0].id)},[j,c]),l.useEffect(()=>{if(h){j.some(n=>n.id===h)&&(x(h),N(null));return}c&&!j.some(n=>n.id===c)&&(x(j[0]?.id??""),m(!1))},[j,h,c]),l.useEffect(()=>{d&&!y&&u({copyFiles:fe(d.copyFiles),setupScript:d.setupScript??"",quickCommands:je(d.quickCommands)})},[d,y]),b)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("加载中...")});if(R.length===0)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("暂无项目,请先创建项目")});const H=j.map(n=>({value:n.id,label:n.name})),V=()=>{c&&v.mutate({id:c,copyFiles:r.copyFiles.length>0?r.copyFiles.join(", "):null,setupScript:r.setupScript.trim()||null,quickCommands:r.quickCommands.length>0?JSON.stringify(r.quickCommands):null},{onSuccess:()=>m(!1)})},X=n=>{N(null),x(n),m(!1)},Z=()=>{d&&(P(d.id),A(!1),a(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),A(!1),a(!1))},Y=async()=>{if(f)try{await o.mutateAsync({id:f,deleteRepo:C}),T.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},ee=n=>{const p=E.find(U=>U.id===n);P(n),I(p?.repoDeletedAt?p.repoPath:""),D(!0)},M=()=>{i.isPending||(D(!1),P(null),I(""))},te=async()=>{if(!(!f||q?.repoDeletedAt&&!w.trim()))try{const p=await i.mutateAsync({id:f,repoPath:w.trim()||void 0});T.success(t("项目已恢复"));for(const U of p.warnings)T.warning(U);m(!1),N(p.project.id),x(p.project.id),M()}catch{}},K=q?.name??t("this project"),L=!!q?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl space-y-8",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("项目配置")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("配置当前项目的 worktree 初始化行为,并在此页统一管理删除与恢复。")})]}),j.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-700 mb-2",children:t("选择项目")}),e.jsx(oe,{value:c,onChange:X,options:H,placeholder:t("选择项目...")})]}),d?e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(d)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:d.name})]}),e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:d.repoPath}),d.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",d.repoRemoteUrl]}):null]}),e.jsxs("div",{className:"flex flex-col items-stretch gap-2 md:items-end",children:[e.jsxs(S,{size:"sm",variant:"destructive",onClick:Z,disabled:o.isPending||i.isPending,children:[e.jsx(de,{size:14}),t("删除项目")]}),e.jsx("p",{className:"text-[11px] text-neutral-500 md:max-w-56 md:text-right",children:t("删除后项目会从默认列表隐藏,但历史任务、workspace 与会话记录仍会保留。")})]})]})}):null]}):e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("当前没有可配置的项目。你可以先创建项目,或在下方恢复已删除项目。")})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("自动复制文件")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 时自动从主仓库复制的文件或目录。支持 glob 模式。")}),e.jsx(pe,{value:r.copyFiles,onChange:n=>{u(p=>({...p,copyFiles:n})),m(!0)},repoPath:d.repoPath}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-2",children:t("适用于不在 git 管理中但启动必需的文件,如 .env、node_modules、数据库文件等")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 后自动执行的命令,每行一条,按顺序执行。")}),e.jsx("textarea",{value:r.setupScript,onChange:n=>{u(p=>({...p,setupScript:n.target.value})),m(!0)},placeholder:`pnpm install
2
2
  pnpm run setup`,rows:4,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 resize-none"}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-1",children:t("命令在 worktree 目录下执行,单条命令超时 5 分钟,失败不会阻断后续命令")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("常用命令")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("在终端中可快速执行的命令,不会自动运行。")}),e.jsx(he,{value:r.quickCommands,onChange:n=>{u(p=>({...p,quickCommands:n})),m(!0)}})]})]}):null,e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("已删除项目")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("这些项目不会出现在主看板里,但历史记录仍保留;如源码已删除,恢复时需要重新绑定 repoPath。")})]}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-2.5 py-1 text-[11px] font-medium text-neutral-500",children:E.length})]}),E.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("暂无已删除项目")}):e.jsx("div",{className:"space-y-3",children:E.map(n=>e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-white px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(n)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:n.name}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:t("已删除")}),n.repoDeletedAt?e.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:t("源码已删除")}):null]}),n.repoDeletedAt?e.jsx("p",{className:"text-xs text-neutral-500",children:t("本地源码目录已删除,相关 Git/代码能力已禁用。恢复时需要重新绑定一个有效仓库路径。")}):e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:n.repoPath}),n.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",n.repoRemoteUrl]}):null]}),e.jsxs(S,{size:"sm",variant:"outline",onClick:()=>ee(n.id),disabled:o.isPending||i.isPending,children:[e.jsx(ce,{size:14}),t("恢复")]})]})},n.id))})]}),y&&d?e.jsx("div",{className:"sticky bottom-6 flex justify-end",children:e.jsx(S,{size:"sm",onClick:V,disabled:v.isPending,children:v.isPending?t("保存中..."):t("保存")})}):null]}),e.jsx(G,{isOpen:F,onClose:O,title:t("Delete Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",onClick:O,disabled:o.isPending,children:t("Cancel")}),e.jsx(S,{variant:"destructive",onClick:Y,disabled:o.isPending||C&&!s,children:o.isPending?t("Deleting..."):t("Delete Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-neutral-600 leading-relaxed",children:t("项目「{title}」将从默认项目列表隐藏,但历史任务、workspace 和会话记录仍会保留。",{title:K})}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-3",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:n=>{A(n.target.checked),n.target.checked||a(!1)},className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:t("同时删除本地项目文件")}),e.jsx("p",{className:"mt-1 text-xs text-neutral-500",children:t("勾选后会删除 repoPath 指向的本地仓库目录,并禁用代码/Git 相关能力。")})]})]}),C?e.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-red-700",children:t("勾选后会连项目文件一起删除,请谨慎选择。")}),e.jsx("p",{className:"mt-1 text-xs text-red-600",children:t("恢复该项目时需要重新绑定一个有效的 Git 仓库路径。")}),e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-xs text-red-700",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:n=>a(n.target.checked),className:"mt-0.5"}),e.jsx("span",{children:t("我已确认这会删除本地项目文件")})]})]}):null,o.isError?e.jsx("p",{className:"text-xs text-red-500",children:o.error instanceof Error?o.error.message:t("Failed to delete project")}):null]})}),e.jsx(G,{isOpen:z,onClose:M,title:t("Restore Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",onClick:M,disabled:i.isPending,children:t("Cancel")}),e.jsx(S,{onClick:te,disabled:i.isPending||L&&!w.trim(),children:i.isPending?t("Restoring..."):t("Restore Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-neutral-600 leading-relaxed",children:L?t("项目「{title}」的本地仓库文件已删除。恢复前需要重新绑定一个有效的 Git 仓库路径。",{title:K}):t("恢复后,项目会重新出现在默认项目列表中。")}),L?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:t("Repository Path")}),e.jsx(ue,{value:w,onChange:I}),e.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:t("Agent Tower 会尽量校验仓库 identity;如果 remote URL 或目录名不同,会给出警告但允许继续。")})]}):null,i.isError?e.jsx("p",{className:"text-xs text-red-500",children:i.error instanceof Error?i.error.message:t("Failed to restore project")}):null]})})]})}export{De as ProjectSettingsPage};