agent-tower 0.4.12-beta.0 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/core/event-bus.d.ts +1 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.d.ts +1 -1
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/git/worktree.manager.d.ts.map +1 -1
- package/dist/git/worktree.manager.js +21 -2
- package/dist/git/worktree.manager.js.map +1 -1
- package/dist/output/msg-store.d.ts +5 -3
- package/dist/output/msg-store.d.ts.map +1 -1
- package/dist/output/msg-store.js +14 -5
- package/dist/output/msg-store.js.map +1 -1
- package/dist/output/types.d.ts +4 -0
- package/dist/output/types.d.ts.map +1 -1
- package/dist/output/types.js.map +1 -1
- package/dist/pipeline/agent-pipeline.js +2 -2
- package/dist/pipeline/agent-pipeline.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +7 -3
- package/dist/routes/sessions.js.map +1 -1
- package/dist/services/hibernation-scheduler.d.ts.map +1 -1
- package/dist/services/hibernation-scheduler.js +1 -0
- package/dist/services/hibernation-scheduler.js.map +1 -1
- package/dist/services/session-manager.js +2 -2
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +16 -4
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/socket/socket-gateway.js +2 -2
- package/dist/socket/socket-gateway.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BFrnOvUV.js → AgentDemoPage-BskuObus.js} +1 -1
- package/dist/web/assets/{DemoPage-DzKv8uDU.js → DemoPage-DM2NLFlQ.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-Co-8z-sL.js → GeneralSettingsPage-DggKcdQM.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-Do3Og7G9.js → NotificationSettingsPage-fDjeTfPh.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-7rYry6Ql.js → ProfileSettingsPage-CWVSxzJw.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-wvZc6KmL.js → ProjectKanbanPage-DHNpmw-4.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-7-FUoyM2.js → ProjectSettingsPage-Cf4D6UFs.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-DZsll4Bu.js → ProviderSettingsPage-A_AoWMBp.js} +7 -7
- package/dist/web/assets/{button-BCWr6Rvd.js → button-5iX1e_fm.js} +1 -1
- package/dist/web/assets/{chevron-down-DanWbYmL.js → chevron-down-BXQh2Wxh.js} +1 -1
- package/dist/web/assets/{chevron-right-DF-6zN98.js → chevron-right-Cpp4WiwB.js} +1 -1
- package/dist/web/assets/{circle-alert-CFdGx6uD.js → circle-alert-B4o7LpBN.js} +1 -1
- package/dist/web/assets/{circle-check-iVKaVABv.js → circle-check-0QrYHY8C.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-CC5lCZW2.js → code-block-OCS4YCEC-CyOCA4DG.js} +1 -1
- package/dist/web/assets/{confirm-dialog-B6ScE3zf.js → confirm-dialog-DnYr0-iE.js} +1 -1
- package/dist/web/assets/{folder-picker-CmwjQXjK.js → folder-picker-CTcrs_BC.js} +1 -1
- package/dist/web/assets/{index-bUdBNiUV.js → index-BLRui4ck.js} +2 -2
- package/dist/web/assets/{loader-circle-CdakhgnX.js → loader-circle-DvZK36Ga.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DlkW-f-_.js → mermaid-NOHMQCX5-xPQ5tFq8.js} +42 -42
- package/dist/web/assets/{modal-DjFx0vpU.js → modal-CvoxLn2x.js} +1 -1
- package/dist/web/assets/{pencil-BTHTFDLJ.js → pencil-CNuySmPC.js} +1 -1
- package/dist/web/assets/{rotate-ccw-DfJiT691.js → rotate-ccw-BusOGXw0.js} +1 -1
- package/dist/web/assets/{select-6YNbjKSC.js → select-DOJOMQ5p.js} +1 -1
- package/dist/web/assets/{use-profiles-cjE3ZHLR.js → use-profiles-CGAx71Yx.js} +1 -1
- package/dist/web/assets/{use-providers-CRsJrkvm.js → use-providers-RzfgfeZ2.js} +1 -1
- package/dist/web/index.html +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-
|
|
2
|
-
import{Q as Tr,o as ri,p as aa,v as la,w as ca,x as br,y as ha,z as ua,e as ze,A as da,B as fa,r as k,D as ma,E as pa,G as va,H as ga,I as ii,J as ni,K as _a,M as ba,N as xa,h as xe,R as J,O as Nt,u as he,j as a,s as kt,S as Ve,C as Pt,g as ue,f as Je,q as oe,d as ut,n as Rt,P as Sa,T as oi,U as ya,i as Ca,V as wa,t as ai,L as li,_ as un}from"./index-bUdBNiUV.js";import{h as Lr,b as Mr,d as Nr,c as Pr,i as Or,G as Is,u as dn,a as fn,Q as mn,e as pn,T as vn,P as ws,f as gn,S as ci}from"./mermaid-NOHMQCX5-DlkW-f-_.js";import{C as Ct,a as ss}from"./chevron-down-DanWbYmL.js";import{C as Ft}from"./chevron-right-DF-6zN98.js";import{P as xr,X as Fs,M as Br,T as _n}from"./modal-DjFx0vpU.js";import{C as Ea,A as bt,S as Te,T as _t}from"./log-adapter-CeKrvZcz.js";import{B as pt}from"./button-BCWr6Rvd.js";import{c as Se,t as hi}from"./utils-CkSf8FUe.js";import{F as ka,a as Ra,R as Da}from"./rotate-ccw-DfJiT691.js";import{L as Ue}from"./loader-circle-CdakhgnX.js";import{u as Hs}from"./use-providers-CRsJrkvm.js";import{T as bn,C as Sr}from"./confirm-dialog-B6ScE3zf.js";import{S as vs}from"./select-6YNbjKSC.js";var Aa=class extends Tr{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:ri()})}getOptimisticResult(e){return e.behavior=ri(),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:la(t,s.data),hasPreviousPage:aa(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ui(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ja(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ta=class extends ca{#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,br.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||!ha(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ui(s,m).forEach(f=>{f.destroy()}),ui(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=ua(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 Tr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ja(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&&br.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function La({queries:e,...t},s){const l=ze(),m=da(),v=fa(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ma(g);const n=l.getQueryCache().get(g.queryHash);pa(g,v,n)}),va(v);const[r]=k.useState(()=>new Ta(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(br.batchCalls(g)):ga,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const S=i.some((g,n)=>ii(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new Tr(l,d);if(ii(d,g))return ni(d,h,v);_a(g,m)&&ni(d,h,v)}return[]}):[];if(S.length>0)throw Promise.all(S);const y=i.find((g,n)=>{const d=C[n];return d&&ba({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(y?.error)throw y.error;return c(f())}function xn(e,t){return xa(e,Aa)}const Ma=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Sn=xe("arrow-down",Ma);const Na=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],yn=xe("arrow-right",Na);const Pa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cn=xe("arrow-up",Pa);const Oa=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],di=xe("circle-check-big",Oa);const Ba=[["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=xe("code-xml",Ba);const Ia=[["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"}]],fi=xe("copy",Ia);const Fa=[["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"}]],wn=xe("ellipsis-vertical",Fa);const Ha=[["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"}]],za=xe("file-braces-corner",Ha);const Wa=[["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=xe("file-code-corner",Wa);const $a=[["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"}]],Ua=xe("file-exclamation-point",$a);const qa=[["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"}]],En=xe("file-text",qa);const Ka=[["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"}]],kn=xe("folder-open",Ka);const Xa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ya=xe("gauge",Xa);const Va=[["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"}]],Ga=xe("git-branch",Va);const Qa=[["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"}]],Za=xe("git-fork",Qa);const Ja=[["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=xe("git-graph",Ja);const el=[["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"}]],Rn=xe("git-merge",el);const tl=[["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"}]],Ut=xe("history",tl);const sl=[["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"}]],Ir=xe("image",sl);const rl=[["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"}]],mi=xe("layers",rl);const il=[["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"}]],nl=xe("maximize",il);const ol=[["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"}]],al=xe("message-square",ol);const ll=[["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"}]],cl=xe("panel-left-close",ll);const hl=[["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"}]],ul=xe("panel-left-open",hl);const dl=[["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"}]],fl=xe("panel-right-close",dl);const ml=[["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"}]],pl=xe("panel-right-open",ml);const vl=[["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=xe("play",vl);const gl=[["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"}]],_l=xe("refresh-cw",gl);const bl=[["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"}]],xl=xe("shield",bl);const Sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=xe("terminal",Sl);const yl=[["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"}]],Cl=xe("zap",yl);const wl=[["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"}]],El=xe("zoom-in",wl);const kl=[["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"}]],Rl=xe("zoom-out",kl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function tt(e){var t,s;return e?qt(e)?e:Fr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Hr(e){const{Document:t}=tt(e);return e instanceof t}function cs(e){return qt(e)?!1:e instanceof tt(e).HTMLElement}function Dn(e){return e instanceof tt(e).SVGElement}function Kt(e){return e?qt(e)?e.document:Fr(e)?Hr(e)?e:cs(e)||Dn(e)?e.ownerDocument:document:document:document}const yt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return yt(()=>{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 Dl(){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 yt(()=>{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 rr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=rr[e]==null?0:rr[e]+1;return rr[e]=s,e+"-"+s},[e,t])}function An(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 $t=An(1),Ds=An(-1);function Al(e){return"clientX"in e&&"clientY"in e}function zr(e){if(!e)return!1;const{KeyboardEvent:t}=tt(e.target);return t&&e instanceof t}function jl(e){if(!e)return!1;const{TouchEvent:t}=tt(e.target);return t&&e instanceof t}function As(e){if(jl(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 Al(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}}}),pi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tl(e){return e.matches(pi)?e:e.querySelector(pi)}const Ll={display:"none"};function Ml(e){let{id:t,value:s}=e;return J.createElement("div",{id:t,style:Ll},s)}function Nl(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 J.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Pl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const jn=k.createContext(null);function Ol(e){const t=k.useContext(jn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bl(){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 Il={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-CvoxLn2x.js","assets/index-BLRui4ck.js","assets/index-BGvfX18x.css","assets/utils-CkSf8FUe.js","assets/folder-picker-CTcrs_BC.js","assets/chevron-right-Cpp4WiwB.js","assets/loader-circle-DvZK36Ga.js","assets/circle-alert-B4o7LpBN.js","assets/rotate-ccw-BusOGXw0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Q as Tr,o as ri,p as aa,v as la,w as ca,x as br,y as ha,z as ua,e as ze,A as da,B as fa,r as k,D as ma,E as pa,G as va,H as ga,I as ii,J as ni,K as _a,M as ba,N as xa,h as xe,R as J,O as Nt,u as he,j as a,s as kt,S as Ve,C as Pt,g as ue,f as Je,q as oe,d as ut,n as Rt,P as Sa,T as oi,U as ya,i as Ca,V as wa,t as ai,L as li,_ as un}from"./index-BLRui4ck.js";import{h as Lr,b as Mr,d as Nr,c as Pr,i as Or,G as Is,u as dn,a as fn,Q as mn,e as pn,T as vn,P as ws,f as gn,S as ci}from"./mermaid-NOHMQCX5-xPQ5tFq8.js";import{C as Ct,a as ss}from"./chevron-down-BXQh2Wxh.js";import{C as Ft}from"./chevron-right-Cpp4WiwB.js";import{P as xr,X as Fs,M as Br,T as _n}from"./modal-CvoxLn2x.js";import{C as Ea,A as bt,S as Te,T as _t}from"./log-adapter-CeKrvZcz.js";import{B as pt}from"./button-5iX1e_fm.js";import{c as Se,t as hi}from"./utils-CkSf8FUe.js";import{F as ka,a as Ra,R as Da}from"./rotate-ccw-BusOGXw0.js";import{L as Ue}from"./loader-circle-DvZK36Ga.js";import{u as Hs}from"./use-providers-RzfgfeZ2.js";import{T as bn,C as Sr}from"./confirm-dialog-DnYr0-iE.js";import{S as vs}from"./select-DOJOMQ5p.js";var Aa=class extends Tr{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:ri()})}getOptimisticResult(e){return e.behavior=ri(),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:la(t,s.data),hasPreviousPage:aa(t,s.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!c&&!o,isRefetching:v&&!f&&!p}}};function ui(e,t){const s=new Set(t);return e.filter(l=>!s.has(l))}function ja(e,t,s){const l=e.slice(0);return l[t]=s,l}var Ta=class extends ca{#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,br.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||!ha(f,p)});!i&&!c||(i&&(this.#c=l,this.#t=m),this.#e=v,this.hasListeners()&&(i&&(ui(s,m).forEach(f=>{f.destroy()}),ui(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=ua(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 Tr(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=ja(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&&br.batch(()=>{this.listeners.forEach(l=>{l(this.#e)})})}}};function La({queries:e,...t},s){const l=ze(),m=da(),v=fa(),C=k.useMemo(()=>e.map(g=>{const n=l.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,l,m]);C.forEach(g=>{ma(g);const n=l.getQueryCache().get(g.queryHash);pa(g,v,n)}),va(v);const[r]=k.useState(()=>new Ta(l,C,t)),[i,c,f]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(g=>o?r.subscribe(br.batchCalls(g)):ga,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),k.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const S=i.some((g,n)=>ii(C[n],g))?i.flatMap((g,n)=>{const d=C[n];if(d){const h=new Tr(l,d);if(ii(d,g))return ni(d,h,v);_a(g,m)&&ni(d,h,v)}return[]}):[];if(S.length>0)throw Promise.all(S);const y=i.find((g,n)=>{const d=C[n];return d&&ba({result:g,errorResetBoundary:v,throwOnError:d.throwOnError,query:l.getQueryCache().get(d.queryHash),suspense:d.suspense})});if(y?.error)throw y.error;return c(f())}function xn(e,t){return xa(e,Aa)}const Ma=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Sn=xe("arrow-down",Ma);const Na=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],yn=xe("arrow-right",Na);const Pa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cn=xe("arrow-up",Pa);const Oa=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],di=xe("circle-check-big",Oa);const Ba=[["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=xe("code-xml",Ba);const Ia=[["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"}]],fi=xe("copy",Ia);const Fa=[["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"}]],wn=xe("ellipsis-vertical",Fa);const Ha=[["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"}]],za=xe("file-braces-corner",Ha);const Wa=[["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=xe("file-code-corner",Wa);const $a=[["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"}]],Ua=xe("file-exclamation-point",$a);const qa=[["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"}]],En=xe("file-text",qa);const Ka=[["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"}]],kn=xe("folder-open",Ka);const Xa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ya=xe("gauge",Xa);const Va=[["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"}]],Ga=xe("git-branch",Va);const Qa=[["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"}]],Za=xe("git-fork",Qa);const Ja=[["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=xe("git-graph",Ja);const el=[["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"}]],Rn=xe("git-merge",el);const tl=[["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"}]],Ut=xe("history",tl);const sl=[["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"}]],Ir=xe("image",sl);const rl=[["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"}]],mi=xe("layers",rl);const il=[["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"}]],nl=xe("maximize",il);const ol=[["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"}]],al=xe("message-square",ol);const ll=[["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"}]],cl=xe("panel-left-close",ll);const hl=[["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"}]],ul=xe("panel-left-open",hl);const dl=[["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"}]],fl=xe("panel-right-close",dl);const ml=[["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"}]],pl=xe("panel-right-open",ml);const vl=[["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=xe("play",vl);const gl=[["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"}]],_l=xe("refresh-cw",gl);const bl=[["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"}]],xl=xe("shield",bl);const Sl=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Es=xe("terminal",Sl);const yl=[["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"}]],Cl=xe("zap",yl);const wl=[["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"}]],El=xe("zoom-in",wl);const kl=[["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"}]],Rl=xe("zoom-out",kl),Ws=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function tt(e){var t,s;return e?qt(e)?e:Fr(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Hr(e){const{Document:t}=tt(e);return e instanceof t}function cs(e){return qt(e)?!1:e instanceof tt(e).HTMLElement}function Dn(e){return e instanceof tt(e).SVGElement}function Kt(e){return e?qt(e)?e.document:Fr(e)?Hr(e)?e:cs(e)||Dn(e)?e.ownerDocument:document:document:document}const yt=Ws?k.useLayoutEffect:k.useEffect;function $s(e){const t=k.useRef(e);return yt(()=>{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 Dl(){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 yt(()=>{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 rr={};function Us(e,t){return k.useMemo(()=>{if(t)return t;const s=rr[e]==null?0:rr[e]+1;return rr[e]=s,e+"-"+s},[e,t])}function An(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 $t=An(1),Ds=An(-1);function Al(e){return"clientX"in e&&"clientY"in e}function zr(e){if(!e)return!1;const{KeyboardEvent:t}=tt(e.target);return t&&e instanceof t}function jl(e){if(!e)return!1;const{TouchEvent:t}=tt(e.target);return t&&e instanceof t}function As(e){if(jl(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 Al(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}}}),pi="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Tl(e){return e.matches(pi)?e:e.querySelector(pi)}const Ll={display:"none"};function Ml(e){let{id:t,value:s}=e;return J.createElement("div",{id:t,style:Ll},s)}function Nl(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 J.createElement("div",{id:t,style:m,role:"status","aria-live":l,"aria-atomic":!0},s)}function Pl(){const[e,t]=k.useState("");return{announce:k.useCallback(l=>{l!=null&&t(l)},[]),announcement:e}}const jn=k.createContext(null);function Ol(e){const t=k.useContext(jn);k.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Bl(){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 Il={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:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function zm({entry:e,type:t,workingDir:s}){const[l,m]=k.useState(!1),v=en[e.status]||en.M,C=Fm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("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:Se("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:Im(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(Ct,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Hm,{workingDir:s,filePath:e.path,type:t})]})}function tn({title:e,entries:t,type:s,workingDir:l,defaultOpen:m}){const{t:v}=he(),[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(Ct,{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(zm,{entry:i,type:s,workingDir:l},`${s}:${i.path}`))})]})}function Wm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m}=Co(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(Ue,{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(tn,{title:"Uncommitted",entries:v,type:"uncommitted",workingDir:e,defaultOpen:!0}),a.jsx(tn,{title:"Committed",entries:C,type:"committed",workingDir:e,defaultOpen:!1})]})}const gr=50,sn={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 $m(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Rt("{count}s ago",{count:s}):s<3600?Rt("{count}m ago",{count:Math.floor(s/60)}):s<86400?Rt("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Rt("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Um(e){const t=e.split("/");return t[t.length-1]||e}function qm(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Km({workingDir:e,hash:t,filePath:s}){const{t:l}=he(),{data:m,isLoading:v,isError:C}=ko(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(Ue,{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:Se("px-3 whitespace-pre",o,p),children:c},f)})})}function Xm({entry:e,workingDir:t,hash:s}){const[l,m]=k.useState(!1),v=sn[e.status]||sn.M,C=qm(e.path);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(r=>!r),className:Se("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:Se("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:Um(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(Ct,{size:14}):a.jsx(Ft,{size:14})})]}),l&&a.jsx(Km,{workingDir:t,hash:s,filePath:e.path})]})}function Ym({commit:e,workingDir:t}){const{t:s}=he(),[l,m]=k.useState(!1),{data:v,isLoading:C}=Eo(t,l?e.hash:null),r=v?.files||[];return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>m(i=>!i),className:Se("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:Se("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:$m(e.timestamp)})]})]}),a.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:l?a.jsx(Ct,{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(Ue,{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(Xm,{entry:i,workingDir:t,hash:e.hash},i.path))})]})]})}function Vm({workingDir:e}){const{t}=he(),{data:s,isLoading:l,isError:m,fetchNextPage:v,hasNextPage:C,isFetchingNextPage:r}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:c=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(gr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<gr?void 0:f.length*gr,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(Ue,{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(Ut,{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(Ym,{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(Ue,{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 Gm="/api",Qm=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Gm}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Zm=({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"})}),Jm={img:Zm};function ep({status:e}){const t={[ce.Running]:"bg-blue-500",[ce.Review]:"bg-amber-500",[ce.Pending]:"bg-neutral-400",[ce.Done]:"bg-emerald-500",[ce.Cancelled]:"bg-neutral-400"};return a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const tp=[{key:"chat",label:"Chat",icon:al},{key:"changes",label:"Changes",icon:is},{key:"history",label:"History",icon:Ut},{key:"workspace",label:"Workspace",icon:kn}];function sp({task:e,onBack:t,onDeleteTask:s,isDeleting:l}){const{t:m}=he(),[v,C]=k.useState("chat"),[r,i]=k.useState(""),[c,f]=k.useState(!1),[o,p]=k.useState(!1),[S,y]=k.useState(!1),g=k.useRef(null),n=k.useRef(null),d=k.useRef(null),h=k.useRef(null),{scrollRef:u,contentRef:_,isAtBottom:x,scrollToBottom:w}=Vn({resize:"smooth",initial:"instant"}),E=ze();k.useEffect(()=>{if(!S)return;const Y=ie=>{n.current&&!n.current.contains(ie.target)&&y(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[S]);const{data:b,isLoading:R}=Do(e.id),j=k.useMemo(()=>{if(!b)return null;const Y=b.filter(me=>me.status==="ACTIVE"&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]),ie=me=>{const it=me.createdAt,et=me.endedAt??me.startedAt??it;if(!et)return 0;const dt=Date.parse(et);return Number.isNaN(dt)?0:dt},Ce=me=>{const it=Y.filter(et=>me.includes(et.status));return it.length===0?null:it.sort((et,dt)=>ie(dt)-ie(et))[0]??null},_e=Ce([Te.RUNNING])??Ce([Te.PENDING])??Ce([Te.COMPLETED,Te.FAILED,Te.CANCELLED]);if(_e)return _e;const Qe=b.filter(me=>(me.status==="ABANDONED"||me.status==="MERGED"||me.status==="HIBERNATED")&&Array.isArray(me.sessions)).flatMap(me=>me.sessions??[]).filter(me=>[Te.COMPLETED,Te.FAILED,Te.CANCELLED].includes(me.status));return Qe.length===0?null:Qe.sort((me,it)=>ie(it)-ie(me))[0]??null},[b]),L=j?.id??"",M=j?.status===Te.RUNNING||j?.status===Te.PENDING,T=!!e.projectArchivedAt,B=!!e.projectRepoDeletedAt,I=m(B?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),H=k.useMemo(()=>!j||!b?!1:!b.some(ie=>ie.status==="ACTIVE"&&ie.sessions?.some(Ce=>Ce.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 Y of b)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return b[0]?.worktreePath}},[b]),O=Bo({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),$=Io({agentType:j?.agentType,workingDir:P,input:r,setInput:i,textareaRef:d,minHeight:40,maxHeight:140}),X=k.useMemo(()=>{if(b)return b.find(Y=>Y.status==="ACTIVE")?.id},[b]),K=k.useMemo(()=>{const Y=[];if(b&&b.length>0){const ie=b.some(_e=>_e.status==="ACTIVE");b.some(_e=>_e.sessions?.some(We=>We.status===Te.RUNNING||We.status===Te.PENDING))&&Y.push(m("正在运行的 Agent 将被停止")),ie&&(Y.push(m("分支上未合并的变更将丢失")),Y.push(m("关联的工作目录(worktree)将被清理")))}return Y},[b,m]),Q=Zr(),se=Gr(),D=To(),{isConnected:F,isLoadingSnapshot:U,logs:z,entries:ee,attach:V}=dn({sessionId:L,sessionStatus:j?.status,onExit:k.useCallback(()=>{E.invalidateQueries({queryKey:["workspaces"]})},[E])}),{todos:ne}=fn(ee),{files:ve,addFiles:fe,removeFile:Le,clear:re,buildMarkdownLinks:Be,hasFiles:ye,isUploading:ae}=Jr(),Me=k.useMemo(()=>{if(!j?.tokenUsage)return;const Y=j.tokenUsage;if(typeof Y.totalTokens=="number")return Y},[j?.tokenUsage]),Ke=Lo(z,Me);k.useEffect(()=>{L&&F&&V()},[L,F,V]);const Ae=k.useRef(null);k.useEffect(()=>{if(Ae.current!==e.id&&u.current){const Y=u.current;requestAnimationFrame(()=>{Y.scrollTop=Y.scrollHeight})}Ae.current=e.id},[e.id,u]);const Xe=k.useRef(!1),ge=k.useCallback(async()=>{if(!r.trim()&&!ye||!L||Xe.current||ae)return;Xe.current=!0;const Y=Be(),ie=[r.trim(),Y].filter(Boolean).join(`
|
|
82
82
|
|
|
83
|
-
`);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:L,message:ie,providerId:A??void 0},{onSuccess:()=>V(),onSettled:()=>{Xe.current=!1}})},[r,L,Q,V,ye,ae,Be,re,A]),rt=k.useCallback(async()=>{L&&(await D.mutateAsync(L),E.invalidateQueries({queryKey:["workspaces"]}))},[L,D,E]),Ye=k.useCallback(Y=>{const ie=Y.target.files;ie&&ie.length>0&&fe(Array.from(ie)),Y.target.value=""},[fe]),Ne=k.useCallback(Y=>{const ie=Y.clipboardData.items,Ce=[];for(const _e of ie)if(_e.kind==="file"){const We=_e.getAsFile();We&&Ce.push(We)}Ce.length>0&&(Y.preventDefault(),fe(Ce))},[fe]),Pe=k.useCallback(Y=>{i(Y.target.value);const ie=Y.target;ie.style.height="auto",ie.style.height=`${Math.max(40,Math.min(ie.scrollHeight,140))}px`},[]),He=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),we=k.useRef(null);return k.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let ie=!1;const Ce=()=>{we.current&&(we.current.style.height=`${Y.height}px`,we.current.style.top=`${Y.offsetTop}px`)},_e=()=>Ce(),We=()=>{ie||Ce()},Qe=()=>{ie=!0},me=()=>{ie=!1,requestAnimationFrame(Ce)};return Y.addEventListener("resize",_e),Y.addEventListener("scroll",We),document.addEventListener("touchstart",Qe,{passive:!0}),document.addEventListener("touchend",me,{passive:!0}),document.addEventListener("touchcancel",me,{passive:!0}),()=>{Y.removeEventListener("resize",_e),Y.removeEventListener("scroll",We),document.removeEventListener("touchstart",Qe),document.removeEventListener("touchend",me),document.removeEventListener("touchcancel",me)}},[]),k.useEffect(()=>{const Y=we.current;if(!Y)return;const ie=Ce=>{let _e=Ce.target;for(;_e&&_e!==Y;){if(_e.tagName==="TEXTAREA"){if(_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement;continue}const Qe=window.getComputedStyle(_e).overflowY;if((Qe==="auto"||Qe==="scroll")&&_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement}Ce.preventDefault()};return Y.addEventListener("touchmove",ie,{passive:!1}),()=>Y.removeEventListener("touchmove",ie)},[]),a.jsxs("div",{ref:we,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(ya,{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(ep,{status:e.status}),a.jsx("button",{onClick:He,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:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(wn,{size:16})}),S&&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),y(!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(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:tp.map(({key:Y,label:ie,icon:Ce})=>a.jsxs("button",{onClick:()=>C(Y),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(Ce,{size:13}),a.jsx("span",{children:ie})]},Y))})]}),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(mn,{urlTransform:Qm,components:Jm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(rn,{label:"Loading..."}):L?U?a.jsx(rn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:M?"Waiting for agent output...":"No logs recorded."}):a.jsx(pn,{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(pt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!x&&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(Sn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ne.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(vn,{todos:ne,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(pt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):L&&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:ve,onRemove:Le}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ne,onKeyDown:Y=>{$.handleKeyDown(Y)||O.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),ge())},rows:1,placeholder:M?"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:Ye}),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(No,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Gn,{usage:Ke}),M&&!r.trim()&&!ye?a.jsx("button",{onClick:rt,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(gn,{size:12})}):a.jsx("button",{onClick:ge,disabled:!r.trim()&&!ye||ae,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||ye)&&!ae?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Cn,{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(Wm,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Ro,{sessionId:L||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Mo,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(Sr,{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((Y,ie)=>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:Y})]},ie))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function rn({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 rp=Object.defineProperty,Bs=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable,nn=(e,t,s)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ar=(e,t)=>{for(var s in t||(t={}))zo.call(t,s)&&nn(e,s,t[s]);if(Bs)for(var s of Bs(t))Wo.call(t,s)&&nn(e,s,t[s]);return e},jr=(e,t)=>{var s={};for(var l in e)zo.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&&Wo.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 y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(f);if(this.drawCodewords(S),o==-1){let y=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<y&&(o=g,y=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,S=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,g;for(y=f;;y++){const u=de.getNumDataCodewords(y,c)*8,_=C.getTotalBits(i,y);if(_<=u){g=_;break}if(y>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])S&&g<=de.getNumDataCodewords(y,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(y),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(y,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(y,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,S=Math.floor(f/3);this.setFunctionModule(p,S,o),this.setFunctionModule(S,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)),S=i+o,y=c+f;0<=S&&S<this.size&&0<=y&&y<this.size&&this.setFunctionModule(S,y,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],S=Math.floor(de.getNumRawDataModules(c)/8),y=o-S%o,g=Math.floor(S/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let x=i.slice(_,_+g-p+(u<y?0:1));_+=x.length;const w=de.reedSolomonComputeRemainder(x,d);u<y&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,x)=>{(u!=g-p||x>=y)&&h.push(_[u])});return m(h.length==S),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 S=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][S]&&c<i.length*8&&(this.modules[g][S]=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 S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[p][n],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[n][p],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let S=0;S<this.size-1;S++){const y=this.modules[p][S];y==this.modules[p][S+1]&&y==this.modules[p+1][S]&&y==this.modules[p+1][S+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((S,y)=>S+(y?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((S,y)=>f[y]^=de.reedSolomonMultiply(S,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 Fe{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 Fe(Fe.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Fe.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 Fe(Fe.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Fe.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=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Fe(Fe.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Fe.isNumeric(i)?[Fe.makeNumeric(i)]:Fe.isAlphanumeric(i)?[Fe.makeAlphanumeric(i)]:[Fe.makeBytes(Fe.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 Fe(Fe.Mode.ECI,0,c)}static isNumeric(i){return Fe.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Fe.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 Wt=It;var ip={L:Wt.QrCode.Ecc.LOW,M:Wt.QrCode.Ecc.MEDIUM,Q:Wt.QrCode.Ecc.QUARTILE,H:Wt.QrCode.Ecc.HIGH},$o=128,Uo="L",qo="#FFFFFF",Ko="#000000",Xo=!1,Yo=1,np=4,op=0,ap=.1;function Vo(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 Go(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 lp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*ap),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 y=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-y),d=Math.ceil(i+f-g);p={x:y,y:g,w:n,h:d}}const S=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:S}}function cp(e,t){return t!=null?Math.max(Math.floor(t),0):e?np:op}function Qo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=J.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Wt.QrSegment.makeSegments(n)),g),[]);return Wt.QrCode.encodeSegments(y,ip[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=J.useMemo(()=>{let S=i.getModules();const y=cp(l,m),g=S.length+y*2,n=lp(S,C,y,v);return{cells:S,margin:y,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var hp=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),up=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,marginSize:p,imageSettings:S}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=jr(g,["style"]),h=S?.src,u=J.useRef(null),_=J.useRef(null),x=J.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=J.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:L}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:S,size:v});J.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&L.excavation!=null&&(H=Go(R,L.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,hp?I.fill(new Path2D(Vo(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(W,L.x+b,L.y+b,L.w,L.h)}}),J.useEffect(()=>{E(!1)},[h]);const M=Ar({height:v,width:v},n);let T=null;return h!=null&&(T=J.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:L?.crossOrigin})),J.createElement(J.Fragment,null,J.createElement("canvas",Ar({style:M,height:v,width:v,ref:x,role:"img"},d)),T)});up.displayName="QRCodeCanvas";var Zo=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,title:p,marginSize:S,imageSettings:y}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:S,imageSettings:y,size:v});let _=d,x=null;y!=null&&u!=null&&(u.excavation!=null&&(_=Go(d,u.excavation)),x=J.createElement("image",{href:y.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=Vo(_,n);return J.createElement("svg",Ar({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&J.createElement("title",null,p),J.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),J.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Zo.displayName="QRCodeSVG";function dp(){return ut({queryKey:oe.tunnel.status,queryFn:()=>ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function fp(){const e=ze();return Je({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ue.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function mp(){const e=ze();return Je({mutationFn:()=>ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function on(){const{t:e}=he(),{data:t}=dp(),s=fp(),l=mp(),[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),S=t?.running??!1,y=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const x=i.current.getBoundingClientRect();f({top:x.bottom+8,right:window.innerWidth-x.right})}},[m]);const d=k.useCallback(()=>{S?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[S,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:y,className:`p-1.5 rounded-md transition-colors ${S?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(S?"Tunnel active":"Share via tunnel"),children:y?a.jsx(Ue,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),S&&!y&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&S&&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(xl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Zo,{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:x=>x.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(fi,{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(fi,{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 an={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>un(()=>import("./modal-DjFx0vpU.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),_r=k.lazy(()=>un(()=>import("./folder-picker-CmwjQXjK.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),ln=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"})]}),cn=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),pp=260,vp=600,hn=400;function Lp(){const{t:e}=he(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(hn),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[S,y]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[x,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:L,clear:M,buildMarkdownLinks:T,isUploading:B}=Jr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(hn),N=k.useRef(null),P=ze(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=Ca(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(Nm),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Uf(D??""),z=La({queries:D?[]:Q.map(q=>({queryKey:oe.tasks.list(q.id),queryFn:()=>ue.get(`/projects/${q.id}/tasks`,{params:{limit:"500"}})}))}),ee=!D&&z.some(q=>q.isLoading),V=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const Z of z)Z.data?.data&&q.push(...Z.data.data);return q},[D,F,z]),ne=t&&V.some(q=>q.id===t)?t:null,ve=k.useMemo(()=>{const q=new Map;for(const Z of V){const le=Z.createdAt?new Date(Z.createdAt).getTime():0,pe=q.get(Z.projectId)??0;le>pe&&q.set(Z.projectId,le)}return[...Q].sort((Z,le)=>{const pe=q.get(Z.id)??(Z.createdAt?new Date(Z.createdAt).getTime():0);return(q.get(le.id)??(le.createdAt?new Date(le.createdAt).getTime():0))-pe})},[Q,V]),fe=k.useMemo(()=>ve.filter(q=>!q.archivedAt),[ve]),Le=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),Z=q?JSON.parse(q):{};return[...O].sort((le,pe)=>{const be=le.availability.type!=="NOT_FOUND",ke=pe.availability.type!=="NOT_FOUND";if(be!==ke)return be?-1:1;const st=Z[le.provider.id]??0;return(Z[pe.provider.id]??0)-st})},[O]),re=k.useMemo(()=>V.map(Om),[V]),Be=k.useMemo(()=>new Set,[]),ye=k.useMemo(()=>{if(!ne)return null;const q=V.find(le=>le.id===ne);if(!q)return null;const Z=Q.find(le=>le.id===q.projectId);if(!Z){const le=q.workspaces?.find(pe=>pe.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:ei(q.status),branch:le,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Bm(q,Z)},[ne,V,Q]),ae=wa(),Me=qf(u),Ke=Xf(),Ae=Kf(),Xe=k.useCallback(q=>{Ke.mutate(q,{onSuccess:()=>{ne===q&&s(null),P.invalidateQueries({queryKey:oe.tasks.all})}})},[Ke,ne,P]),ge=k.useCallback((q,Z)=>{Ae.mutate({id:q,status:Lm(Z)},{onError:()=>{ai.error(e("状态变更失败,该操作不被允许"))}})},[Ae,e]),rt=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=le=>{if(!H.current)return;const pe=le.clientX-W.current,be=Math.max(pp,Math.min(vp,A.current+pe));C(be)},Z=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Z),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z)}},[]);const Ye=k.useCallback(()=>{i(!0)},[]),Ne=k.useCallback(()=>{if(fe.length===0){ai.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),Z=localStorage.getItem("lastSelectedProviderId"),le=q&&fe.find(ke=>ke.id===q)?q:(D&&fe.find(ke=>ke.id===D)?.id)??fe[0]?.id??"";_(le);const pe=Le?.find(ke=>ke.availability.type!=="NOT_FOUND"),be=Z&&Le?.find(ke=>ke.provider.id===Z&&ke.availability.type!=="NOT_FOUND")?Z:pe?.provider.id??"";w(be),b("idle"),f(!0)},[fe,D,Le,e]),Pe=k.useCallback(()=>{i(!1),p(""),y("")},[]),He=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),M())},[E,M]),we=k.useCallback(async()=>{if(!(!o.trim()||!S.trim()))try{await ae.mutateAsync({name:o.trim(),repoPath:S.trim()}),Pe()}catch{}},[o,S,ae,Pe]),Y=Qr(),ie=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),Z=[d.trim(),q].filter(Boolean).join(`
|
|
83
|
+
`);i(""),re(),d.current&&(d.current.style.height="40px"),Q.mutate({id:L,message:ie,providerId:A??void 0},{onSuccess:()=>V(),onSettled:()=>{Xe.current=!1}})},[r,L,Q,V,ye,ae,Be,re,A]),rt=k.useCallback(async()=>{L&&(await D.mutateAsync(L),E.invalidateQueries({queryKey:["workspaces"]}))},[L,D,E]),Ye=k.useCallback(Y=>{const ie=Y.target.files;ie&&ie.length>0&&fe(Array.from(ie)),Y.target.value=""},[fe]),Ne=k.useCallback(Y=>{const ie=Y.clipboardData.items,Ce=[];for(const _e of ie)if(_e.kind==="file"){const We=_e.getAsFile();We&&Ce.push(We)}Ce.length>0&&(Y.preventDefault(),fe(Ce))},[fe]),Pe=k.useCallback(Y=>{i(Y.target.value);const ie=Y.target;ie.style.height="auto",ie.style.height=`${Math.max(40,Math.min(ie.scrollHeight,140))}px`},[]),He=k.useCallback(()=>{X&&se.mutate({workspaceId:X})},[X,se]),we=k.useRef(null);return k.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let ie=!1;const Ce=()=>{we.current&&(we.current.style.height=`${Y.height}px`,we.current.style.top=`${Y.offsetTop}px`)},_e=()=>Ce(),We=()=>{ie||Ce()},Qe=()=>{ie=!0},me=()=>{ie=!1,requestAnimationFrame(Ce)};return Y.addEventListener("resize",_e),Y.addEventListener("scroll",We),document.addEventListener("touchstart",Qe,{passive:!0}),document.addEventListener("touchend",me,{passive:!0}),document.addEventListener("touchcancel",me,{passive:!0}),()=>{Y.removeEventListener("resize",_e),Y.removeEventListener("scroll",We),document.removeEventListener("touchstart",Qe),document.removeEventListener("touchend",me),document.removeEventListener("touchcancel",me)}},[]),k.useEffect(()=>{const Y=we.current;if(!Y)return;const ie=Ce=>{let _e=Ce.target;for(;_e&&_e!==Y;){if(_e.tagName==="TEXTAREA"){if(_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement;continue}const Qe=window.getComputedStyle(_e).overflowY;if((Qe==="auto"||Qe==="scroll")&&_e.scrollHeight>_e.clientHeight)return;_e=_e.parentElement}Ce.preventDefault()};return Y.addEventListener("touchmove",ie,{passive:!1}),()=>Y.removeEventListener("touchmove",ie)},[]),a.jsxs("div",{ref:we,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(ya,{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(ep,{status:e.status}),a.jsx("button",{onClick:He,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:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:a.jsx(wn,{size:16})}),S&&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),y(!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(_n,{size:15}),a.jsx("span",{children:m("删除任务")})]})})]})]}),a.jsx("div",{className:"flex border-t border-neutral-100",children:tp.map(({key:Y,label:ie,icon:Ce})=>a.jsxs("button",{onClick:()=>C(Y),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${v===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[a.jsx(Ce,{size:13}),a.jsx("span",{children:ie})]},Y))})]}),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(mn,{urlTransform:Qm,components:Jm,children:e.description})}):a.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?a.jsx(rn,{label:"Loading..."}):L?U?a.jsx(rn,{label:"Loading logs..."}):z.length===0?a.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:M?"Waiting for agent output...":"No logs recorded."}):a.jsx(pn,{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(pt,{onClick:()=>f(!0),children:[a.jsx(Ot,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!x&&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(Sn,{size:12}),a.jsx("span",{children:m("回到底部")})]})]}),ne.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(vn,{todos:ne,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(pt,{size:"sm",onClick:()=>f(!0),children:[a.jsx(Ot,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):L&&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:ve,onRemove:Le}),a.jsx("textarea",{ref:d,value:r,onChange:Pe,onPaste:Ne,onKeyDown:Y=>{$.handleKeyDown(Y)||O.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),ge())},rows:1,placeholder:M?"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:Ye}),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(No,{providers:W,currentProviderId:A,agentType:j.agentType,onSelect:N}),a.jsx(Gn,{usage:Ke}),M&&!r.trim()&&!ye?a.jsx("button",{onClick:rt,disabled:D.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:a.jsx(gn,{size:12})}):a.jsx("button",{onClick:ge,disabled:!r.trim()&&!ye||ae,className:`p-1.5 rounded-lg transition-colors ${(r.trim()||ye)&&!ae?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:a.jsx(Cn,{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(Wm,{workingDir:P})}),v==="history"&&a.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a.jsx(Vm,{workingDir:P})}),v==="workspace"&&a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(Ro,{sessionId:L||void 0,workingDir:P,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:B})}),!T&&a.jsx(Mo,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),a.jsx(Sr,{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((Y,ie)=>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:Y})]},ie))})]}),confirmText:m("删除"),variant:"danger",isLoading:l})]})}function rn({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 rp=Object.defineProperty,Bs=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable,nn=(e,t,s)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ar=(e,t)=>{for(var s in t||(t={}))zo.call(t,s)&&nn(e,s,t[s]);if(Bs)for(var s of Bs(t))Wo.call(t,s)&&nn(e,s,t[s]);return e},jr=(e,t)=>{var s={};for(var l in e)zo.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&&Wo.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 y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(f);if(this.drawCodewords(S),o==-1){let y=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<y&&(o=g,y=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,S=!0){if(!(de.MIN_VERSION<=f&&f<=o&&o<=de.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,g;for(y=f;;y++){const u=de.getNumDataCodewords(y,c)*8,_=C.getTotalBits(i,y);if(_<=u){g=_;break}if(y>=o)throw new RangeError("Data too long")}for(const u of[de.Ecc.MEDIUM,de.Ecc.QUARTILE,de.Ecc.HIGH])S&&g<=de.getNumDataCodewords(y,u)*8&&(c=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(y),n);for(const _ of u.getData())n.push(_)}m(n.length==g);const d=de.getNumDataCodewords(y,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(y,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,S=Math.floor(f/3);this.setFunctionModule(p,S,o),this.setFunctionModule(S,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)),S=i+o,y=c+f;0<=S&&S<this.size&&0<=y&&y<this.size&&this.setFunctionModule(S,y,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],S=Math.floor(de.getNumRawDataModules(c)/8),y=o-S%o,g=Math.floor(S/o);let n=[];const d=de.reedSolomonComputeDivisor(p);for(let u=0,_=0;u<o;u++){let x=i.slice(_,_+g-p+(u<y?0:1));_+=x.length;const w=de.reedSolomonComputeRemainder(x,d);u<y&&x.push(0),n.push(x.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((_,x)=>{(u!=g-p||x>=y)&&h.push(_[u])});return m(h.length==S),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 S=f-p,g=(f+1&2)==0?this.size-1-o:o;!this.isFunction[g][S]&&c<i.length*8&&(this.modules[g][S]=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 S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[p][n],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size;p++){let S=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==S?(y++,y==5?i+=de.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),S||(i+=this.finderPenaltyCountPatterns(g)*de.PENALTY_N3),S=this.modules[n][p],y=1);i+=this.finderPenaltyTerminateAndCount(S,y,g)*de.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let S=0;S<this.size-1;S++){const y=this.modules[p][S];y==this.modules[p][S+1]&&y==this.modules[p+1][S]&&y==this.modules[p+1][S+1]&&(i+=de.PENALTY_N2)}let c=0;for(const p of this.modules)c=p.reduce((S,y)=>S+(y?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((S,y)=>f[y]^=de.reedSolomonMultiply(S,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 Fe{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 Fe(Fe.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Fe.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 Fe(Fe.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Fe.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=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f))*45;o+=Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f+1)),s(o,11,c)}return f<i.length&&s(Fe.ALPHANUMERIC_CHARSET.indexOf(i.charAt(f)),6,c),new Fe(Fe.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Fe.isNumeric(i)?[Fe.makeNumeric(i)]:Fe.isAlphanumeric(i)?[Fe.makeAlphanumeric(i)]:[Fe.makeBytes(Fe.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 Fe(Fe.Mode.ECI,0,c)}static isNumeric(i){return Fe.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Fe.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 Wt=It;var ip={L:Wt.QrCode.Ecc.LOW,M:Wt.QrCode.Ecc.MEDIUM,Q:Wt.QrCode.Ecc.QUARTILE,H:Wt.QrCode.Ecc.HIGH},$o=128,Uo="L",qo="#FFFFFF",Ko="#000000",Xo=!1,Yo=1,np=4,op=0,ap=.1;function Vo(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 Go(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 lp(e,t,s,l){if(l==null)return null;const m=e.length+s*2,v=Math.floor(t*ap),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 y=Math.floor(c),g=Math.floor(f),n=Math.ceil(r+c-y),d=Math.ceil(i+f-g);p={x:y,y:g,w:n,h:d}}const S=l.crossOrigin;return{x:c,y:f,h:i,w:r,excavation:p,opacity:o,crossOrigin:S}}function cp(e,t){return t!=null?Math.max(Math.floor(t),0):e?np:op}function Qo({value:e,level:t,minVersion:s,includeMargin:l,marginSize:m,imageSettings:v,size:C,boostLevel:r}){let i=J.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...Wt.QrSegment.makeSegments(n)),g),[]);return Wt.QrCode.encodeSegments(y,ip[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:c,margin:f,numCells:o,calculatedImageSettings:p}=J.useMemo(()=>{let S=i.getModules();const y=cp(l,m),g=S.length+y*2,n=lp(S,C,y,v);return{cells:S,margin:y,numCells:g,calculatedImageSettings:n}},[i,C,v,l,m]);return{qrcode:i,margin:f,cells:c,numCells:o,calculatedImageSettings:p}}var hp=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),up=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,marginSize:p,imageSettings:S}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,d=jr(g,["style"]),h=S?.src,u=J.useRef(null),_=J.useRef(null),x=J.useCallback(B=>{u.current=B,typeof s=="function"?s(B):s&&(s.current=B)},[s]),[w,E]=J.useState(!1),{margin:b,cells:R,numCells:j,calculatedImageSettings:L}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:p,imageSettings:S,size:v});J.useEffect(()=>{if(u.current!=null){const B=u.current,I=B.getContext("2d");if(!I)return;let H=R;const W=_.current,A=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&L.excavation!=null&&(H=Go(R,L.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,hp?I.fill(new Path2D(Vo(H,b))):R.forEach(function(O,$){O.forEach(function(X,K){X&&I.fillRect(K+b,$+b,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(W,L.x+b,L.y+b,L.w,L.h)}}),J.useEffect(()=>{E(!1)},[h]);const M=Ar({height:v,width:v},n);let T=null;return h!=null&&(T=J.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{E(!0)},ref:_,crossOrigin:L?.crossOrigin})),J.createElement(J.Fragment,null,J.createElement("canvas",Ar({style:M,height:v,width:v,ref:x,role:"img"},d)),T)});up.displayName="QRCodeCanvas";var Zo=J.forwardRef(function(t,s){const l=t,{value:m,size:v=$o,level:C=Uo,bgColor:r=qo,fgColor:i=Ko,includeMargin:c=Xo,minVersion:f=Yo,boostLevel:o,title:p,marginSize:S,imageSettings:y}=l,g=jr(l,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:d,numCells:h,calculatedImageSettings:u}=Qo({value:m,level:C,minVersion:f,boostLevel:o,includeMargin:c,marginSize:S,imageSettings:y,size:v});let _=d,x=null;y!=null&&u!=null&&(u.excavation!=null&&(_=Go(d,u.excavation)),x=J.createElement("image",{href:y.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=Vo(_,n);return J.createElement("svg",Ar({height:v,width:v,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&J.createElement("title",null,p),J.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),J.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),x)});Zo.displayName="QRCodeSVG";function dp(){return ut({queryKey:oe.tunnel.status,queryFn:()=>ue.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function fp(){const e=ze();return Je({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return ue.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function mp(){const e=ze();return Je({mutationFn:()=>ue.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function on(){const{t:e}=he(),{data:t}=dp(),s=fp(),l=mp(),[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),S=t?.running??!1,y=s.isPending,g=t?.shareableUrl,n=t?.token;k.useEffect(()=>{if(m&&i.current){const x=i.current.getBoundingClientRect();f({top:x.bottom+8,right:window.innerWidth-x.right})}},[m]);const d=k.useCallback(()=>{S?v(!0):s.mutate(void 0,{onSuccess:()=>v(!0)})},[S,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:y,className:`p-1.5 rounded-md transition-colors ${S?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:e(S?"Tunnel active":"Share via tunnel"),children:y?a.jsx(Ue,{size:16,className:"animate-spin"}):a.jsx(Is,{size:16})}),S&&!y&&a.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),m&&S&&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(xl,{size:12}),a.jsx("span",{children:e("Token protected")})]}),g&&a.jsx("div",{className:"flex justify-center py-3",children:a.jsx(Zo,{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:x=>x.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(fi,{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(fi,{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 an={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Gt=k.lazy(()=>un(()=>import("./modal-CvoxLn2x.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),_r=k.lazy(()=>un(()=>import("./folder-picker-CTcrs_BC.js"),__vite__mapDeps([4,1,2,3,5,6,7,8])).then(e=>({default:e.FolderPicker}))),ln=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"})]}),cn=a.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),pp=260,vp=600,hn=400;function Lp(){const{t:e}=he(),[t,s]=k.useState(null),[l,m]=k.useState(null),[v,C]=k.useState(hn),[r,i]=k.useState(!1),[c,f]=k.useState(!1),[o,p]=k.useState(""),[S,y]=k.useState(""),[g,n]=k.useState(""),[d,h]=k.useState(""),[u,_]=k.useState(""),[x,w]=k.useState(""),[E,b]=k.useState("idle"),{files:R,addFiles:j,removeFile:L,clear:M,buildMarkdownLinks:T,isUploading:B}=Jr(),I=k.useRef(null),H=k.useRef(!1),W=k.useRef(0),A=k.useRef(hn),N=k.useRef(null),P=ze(),{data:O,isLoading:$}=Hs(),{data:X,isLoading:K}=Ca(),Q=k.useMemo(()=>X?.data??[],[X?.data]),se=k.useMemo(()=>Q.map(Nm),[Q]),D=l&&Q.some(q=>q.id===l)?l:null,{data:F,isLoading:U}=Uf(D??""),z=La({queries:D?[]:Q.map(q=>({queryKey:oe.tasks.list(q.id),queryFn:()=>ue.get(`/projects/${q.id}/tasks`,{params:{limit:"500"}})}))}),ee=!D&&z.some(q=>q.isLoading),V=k.useMemo(()=>{if(D)return F?.data??[];const q=[];for(const Z of z)Z.data?.data&&q.push(...Z.data.data);return q},[D,F,z]),ne=t&&V.some(q=>q.id===t)?t:null,ve=k.useMemo(()=>{const q=new Map;for(const Z of V){const le=Z.createdAt?new Date(Z.createdAt).getTime():0,pe=q.get(Z.projectId)??0;le>pe&&q.set(Z.projectId,le)}return[...Q].sort((Z,le)=>{const pe=q.get(Z.id)??(Z.createdAt?new Date(Z.createdAt).getTime():0);return(q.get(le.id)??(le.createdAt?new Date(le.createdAt).getTime():0))-pe})},[Q,V]),fe=k.useMemo(()=>ve.filter(q=>!q.archivedAt),[ve]),Le=k.useMemo(()=>{if(!O)return[];const q=localStorage.getItem("providerUsageCount"),Z=q?JSON.parse(q):{};return[...O].sort((le,pe)=>{const be=le.availability.type!=="NOT_FOUND",ke=pe.availability.type!=="NOT_FOUND";if(be!==ke)return be?-1:1;const st=Z[le.provider.id]??0;return(Z[pe.provider.id]??0)-st})},[O]),re=k.useMemo(()=>V.map(Om),[V]),Be=k.useMemo(()=>new Set,[]),ye=k.useMemo(()=>{if(!ne)return null;const q=V.find(le=>le.id===ne);if(!q)return null;const Z=Q.find(le=>le.id===q.projectId);if(!Z){const le=q.workspaces?.find(pe=>pe.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:ei(q.status),branch:le,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Bm(q,Z)},[ne,V,Q]),ae=wa(),Me=qf(u),Ke=Xf(),Ae=Kf(),Xe=k.useCallback(q=>{Ke.mutate(q,{onSuccess:()=>{ne===q&&s(null),P.invalidateQueries({queryKey:oe.tasks.all})}})},[Ke,ne,P]),ge=k.useCallback((q,Z)=>{Ae.mutate({id:q,status:Lm(Z)},{onError:()=>{ai.error(e("状态变更失败,该操作不被允许"))}})},[Ae,e]),rt=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=le=>{if(!H.current)return;const pe=le.clientX-W.current,be=Math.max(pp,Math.min(vp,A.current+pe));C(be)},Z=()=>{H.current&&(H.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Z),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z)}},[]);const Ye=k.useCallback(()=>{i(!0)},[]),Ne=k.useCallback(()=>{if(fe.length===0){ai.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),Z=localStorage.getItem("lastSelectedProviderId"),le=q&&fe.find(ke=>ke.id===q)?q:(D&&fe.find(ke=>ke.id===D)?.id)??fe[0]?.id??"";_(le);const pe=Le?.find(ke=>ke.availability.type!=="NOT_FOUND"),be=Z&&Le?.find(ke=>ke.provider.id===Z&&ke.availability.type!=="NOT_FOUND")?Z:pe?.provider.id??"";w(be),b("idle"),f(!0)},[fe,D,Le,e]),Pe=k.useCallback(()=>{i(!1),p(""),y("")},[]),He=k.useCallback(()=>{E==="idle"&&(f(!1),n(""),h(""),_(""),w(""),b("idle"),M())},[E,M]),we=k.useCallback(async()=>{if(!(!o.trim()||!S.trim()))try{await ae.mutateAsync({name:o.trim(),repoPath:S.trim()}),Pe()}catch{}},[o,S,ae,Pe]),Y=Qr(),ie=k.useCallback(async()=>{if(!(!g.trim()||!u))try{const q=T(),Z=[d.trim(),q].filter(Boolean).join(`
|
|
84
84
|
|
|
85
85
|
`);b("creating-task");const le=await Me.mutateAsync({title:g.trim(),description:Z||void 0});if(localStorage.setItem("lastSelectedProjectId",u),x){localStorage.setItem("lastSelectedProviderId",x);const pe=localStorage.getItem("providerUsageCount"),be=pe?JSON.parse(pe):{};be[x]=(be[x]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(be))}if(x){const pe=[g.trim(),Z].filter(Boolean).join(`
|
|
86
86
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as se,u as B,r as l,g as ne,j as e,i as re,k as le,l as ae,m as ie,t as T}from"./index-bUdBNiUV.js";import{B as S}from"./button-BCWr6Rvd.js";import{S as oe}from"./select-6YNbjKSC.js";import{a as W,F as _,R as ce}from"./rotate-ccw-DfJiT691.js";import{X as J,P as Q,T as de,M as G}from"./modal-DjFx0vpU.js";import{FolderPicker as ue}from"./folder-picker-CmwjQXjK.js";import"./utils-CkSf8FUe.js";import"./chevron-down-DanWbYmL.js";import"./chevron-right-DF-6zN98.js";import"./loader-circle-CdakhgnX.js";import"./circle-alert-CFdGx6uD.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{h as se,u as B,r as l,g as ne,j as e,i as re,k as le,l as ae,m as ie,t as T}from"./index-BLRui4ck.js";import{B as S}from"./button-5iX1e_fm.js";import{S as oe}from"./select-DOJOMQ5p.js";import{a as W,F as _,R as ce}from"./rotate-ccw-BusOGXw0.js";import{X as J,P as Q,T as de,M as G}from"./modal-CvoxLn2x.js";import{FolderPicker as ue}from"./folder-picker-CTcrs_BC.js";import"./utils-CkSf8FUe.js";import"./chevron-down-BXQh2Wxh.js";import"./chevron-right-Cpp4WiwB.js";import"./loader-circle-DvZK36Ga.js";import"./circle-alert-B4o7LpBN.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};
|