agent-tower 0.5.2-beta.1 → 0.5.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -2
- package/dist/app.js.map +1 -1
- package/dist/app.test.js +67 -0
- package/dist/app.test.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/container.d.ts +2 -0
- package/dist/core/container.d.ts.map +1 -1
- package/dist/core/container.js +9 -1
- package/dist/core/container.js.map +1 -1
- package/dist/core/event-bus.d.ts +2 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/executors/__tests__/base.executor.test.d.ts +2 -0
- package/dist/executors/__tests__/base.executor.test.d.ts.map +1 -0
- package/dist/executors/__tests__/base.executor.test.js +264 -0
- package/dist/executors/__tests__/base.executor.test.js.map +1 -0
- package/dist/executors/__tests__/codex.executor.test.js +18 -1
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +61 -33
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +3 -4
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/execution-env.d.ts +7 -1
- package/dist/executors/execution-env.d.ts.map +1 -1
- package/dist/executors/execution-env.js +41 -2
- package/dist/executors/execution-env.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/http-client.d.ts +8 -2
- package/dist/mcp/http-client.d.ts.map +1 -1
- package/dist/mcp/http-client.js +4 -4
- package/dist/mcp/http-client.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +48 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/types.d.ts +6 -6
- package/dist/routes/__tests__/tasks.test.js +179 -0
- package/dist/routes/__tests__/tasks.test.js.map +1 -1
- package/dist/routes/git.d.ts.map +1 -1
- package/dist/routes/git.js +41 -1
- package/dist/routes/git.js.map +1 -1
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +10 -2
- package/dist/routes/tasks.js.map +1 -1
- package/dist/routes/team-runs.d.ts.map +1 -1
- package/dist/routes/team-runs.js +92 -2
- package/dist/routes/team-runs.js.map +1 -1
- package/dist/services/__tests__/project.service.test.js +85 -1
- package/dist/services/__tests__/project.service.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +84 -1
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/__tests__/task.service.test.js +190 -0
- package/dist/services/__tests__/task.service.test.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +173 -5
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/__tests__/team-run.service.test.js +162 -1
- package/dist/services/__tests__/team-run.service.test.js.map +1 -1
- package/dist/services/__tests__/team-scheduler.service.test.js +177 -5
- package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -1
- package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts +2 -0
- package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/workspace-git-watcher.service.test.js +148 -0
- package/dist/services/__tests__/workspace-git-watcher.service.test.js.map +1 -0
- package/dist/services/__tests__/workspace.service.test.js +43 -1
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/project.service.d.ts +28 -24
- package/dist/services/project.service.d.ts.map +1 -1
- package/dist/services/project.service.js +11 -0
- package/dist/services/project.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +44 -43
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +30 -3
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task-cleanup.service.d.ts +3 -1
- package/dist/services/task-cleanup.service.d.ts.map +1 -1
- package/dist/services/task-cleanup.service.js +6 -1
- package/dist/services/task-cleanup.service.js.map +1 -1
- package/dist/services/task.service.d.ts +96 -65
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +208 -15
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/team-run.service.d.ts +18 -0
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +234 -13
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/team-scheduler.service.d.ts +8 -4
- package/dist/services/team-scheduler.service.d.ts.map +1 -1
- package/dist/services/team-scheduler.service.js +42 -13
- package/dist/services/team-scheduler.service.js.map +1 -1
- package/dist/services/workspace-git-watcher.service.d.ts +62 -0
- package/dist/services/workspace-git-watcher.service.d.ts.map +1 -0
- package/dist/services/workspace-git-watcher.service.js +427 -0
- package/dist/services/workspace-git-watcher.service.js.map +1 -0
- package/dist/services/workspace.service.d.ts +99 -108
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +43 -6
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/socket/events.d.ts +1 -1
- package/dist/socket/events.d.ts.map +1 -1
- package/dist/socket/events.js.map +1 -1
- package/dist/socket/socket-gateway.d.ts.map +1 -1
- package/dist/socket/socket-gateway.js +5 -1
- package/dist/socket/socket-gateway.js.map +1 -1
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +52 -9
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +65 -1
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/AgentDemoPage-DRtgA1-w.js +1 -0
- package/dist/web/assets/{DemoPage-dkmp8Vvn.js → DemoPage-8g4kqlV1.js} +3 -3
- package/dist/web/assets/GeneralSettingsPage-b2dViAif.js +1 -0
- package/dist/web/assets/{MemberAvatar-pwugXGL4.js → MemberAvatar-BuaKw8fE.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-DCtnFBrk.js +1 -0
- package/dist/web/assets/ProfileSettingsPage-Hplbudpu.js +3 -0
- package/dist/web/assets/ProjectKanbanPage-UJVkISeV.js +89 -0
- package/dist/web/assets/ProjectSettingsPage-CnG-6FVF.js +2 -0
- package/dist/web/assets/ProviderSettingsPage-B-u7Av-v.js +54 -0
- package/dist/web/assets/SettingsMasterDetail-C7L4KTOf.js +1 -0
- package/dist/web/assets/TeamSettingsPage-DCsq_ojZ.js +1 -0
- package/dist/web/assets/arrow-left-BSle2OYV.js +1 -0
- package/dist/web/assets/check-COf1UbPe.js +1 -0
- package/dist/web/assets/chevron-down-Dj8_pYCl.js +1 -0
- package/dist/web/assets/chevron-right-BUCnUjsN.js +1 -0
- package/dist/web/assets/{chevron-up-BnCoaejn.js → chevron-up-BhzmceCN.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-DkMlYSza.js → code-block-OCS4YCEC-C9ZDvx5q.js} +1 -1
- package/dist/web/assets/{confirm-dialog-wsb35VpE.js → confirm-dialog-NY6uLJRk.js} +1 -1
- package/dist/web/assets/folder-picker-B5loyQsl.js +1 -0
- package/dist/web/assets/index-3iFMFw1l.css +1 -0
- package/dist/web/assets/index-DSFOeuuj.js +13 -0
- package/dist/web/assets/input-D67geHKZ.js +1 -0
- package/dist/web/assets/layers-Dl9LLqoY.js +1 -0
- package/dist/web/assets/loader-circle-CP1oxYjb.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-DoPzf-UA.js → mermaid-NOHMQCX5-C-bBE9vu.js} +4 -4
- package/dist/web/assets/message-square-Bwt_cqko.js +1 -0
- package/dist/web/assets/modal-0iwqEf_V.js +1 -0
- package/dist/web/assets/{pencil-CaJR6Dqm.js → pencil-CAgGPSMf.js} +1 -1
- package/dist/web/assets/rotate-ccw-CnfGwAnp.js +1 -0
- package/dist/web/assets/{select-CzeTYLO4.js → select-C0X1iRxk.js} +1 -1
- package/dist/web/assets/switch-D_KOTssd.js +1 -0
- package/dist/web/assets/textarea-DS-Evqsv.js +1 -0
- package/dist/web/assets/{upload-_2T21rVP.js → upload-CTsJ3wDk.js} +1 -1
- package/dist/web/assets/{use-profiles-BaCwGP06.js → use-profiles-CzdxiQuG.js} +1 -1
- package/dist/web/assets/{use-providers-Bwl7R5Ql.js → use-providers-BdxKwaE3.js} +1 -1
- package/dist/web/favicon.ico +0 -0
- package/dist/web/index.html +4 -4
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +10 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.js +1 -0
- package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +25 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +6 -5
- package/node_modules/@prisma/client/.prisma/client/index-browser.js +1 -0
- package/node_modules/@prisma/client/.prisma/client/index.d.ts +43 -0
- package/node_modules/@prisma/client/.prisma/client/index.js +6 -5
- package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
- package/node_modules/@prisma/client/.prisma/client/schema.prisma +2 -0
- package/node_modules/@prisma/client/.prisma/client/wasm.js +1 -0
- package/package.json +1 -1
- package/prisma/migrations/20260609000000_add_team_member_membership_status/migration.sql +3 -0
- package/prisma/schema.prisma +2 -0
- package/dist/web/assets/AgentDemoPage-CkhVcgZo.js +0 -1
- package/dist/web/assets/GeneralSettingsPage-B4DH6g3D.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-C-bPU_ZE.js +0 -1
- package/dist/web/assets/ProfileSettingsPage-Dlr6BmHb.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-7oEfjjWV.js +0 -89
- package/dist/web/assets/ProjectSettingsPage-DZZksq5G.js +0 -2
- package/dist/web/assets/ProviderSettingsPage-BWN7CEG6.js +0 -54
- package/dist/web/assets/SettingsSection-C-sMhXpf.js +0 -1
- package/dist/web/assets/TeamSettingsPage-924xpocx.js +0 -1
- package/dist/web/assets/arrow-left-UHjQiY5K.js +0 -1
- package/dist/web/assets/button-CUTjpRqw.js +0 -1
- package/dist/web/assets/check-CPkZgPjx.js +0 -1
- package/dist/web/assets/chevron-down-Bby7sJEv.js +0 -1
- package/dist/web/assets/chevron-right-DCC0lyoB.js +0 -1
- package/dist/web/assets/circle-check-BscClK07.js +0 -1
- package/dist/web/assets/folder-picker-B-X_nrS1.js +0 -1
- package/dist/web/assets/index-4hNWw0yi.css +0 -1
- package/dist/web/assets/index-CUJoWIuo.js +0 -13
- package/dist/web/assets/loader-circle-Cul4BuAa.js +0 -1
- package/dist/web/assets/message-square-C7Q71jFj.js +0 -1
- package/dist/web/assets/modal-25-qs8P5.js +0 -1
- package/dist/web/assets/rotate-ccw-Bvz7590n.js +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import{U as Vi,V as Bn,W as Ac,Y as Mc,Z as Dc,_ as Li,$ as Lc,a0 as Pc,k as st,a1 as Oc,a2 as Ic,r as w,a3 as Bc,a4 as Fc,a5 as zc,a6 as Hc,a7 as Fn,a8 as zn,a9 as Wc,aa as $c,ab as Uc,h as pe,ac as ae,P as Zt,i as wt,l as bt,m as ve,q as ce,u as le,j as t,X as Bt,g as Z,B as Ae,ad as ca,ae as da,af as ua,ag as ds,s as ha,ah as qc,ai as Kc,aj as Xc,t as lt,E as Qt,F as ot,G as vs,ak as fa,T as jt,al as Pi,v as Yc,L as Hn,am as ma,R as Wn,an as Gi,ao as pa,ap as ga,aq as va,ar as Vc,as as Gc,at as Qc,au as Zc,av as Jc,H as $n,aw as Un}from"./index-DSFOeuuj.js";import{S as Je,W as nt,a as Nt,C as Hs,A as It,T as Ot}from"./log-adapter-CtvxzS4j.js";import{C as Or}from"./confirm-dialog-NY6uLJRk.js";import{f as xa,c as _a,d as ba,b as ya,h as Sa,S as Ss,A as qn,P as Ir,Q as Qi,s as Zi,G as wa,u as Ca,a as ka,e as _r,T as br}from"./mermaid-NOHMQCX5-C-bBE9vu.js";import{C as ct}from"./chevron-down-Dj8_pYCl.js";import{C as Mt}from"./chevron-right-BUCnUjsN.js";import{b as ed,a as Ea,F as td,g as sd,h as rd,f as id,u as nd}from"./folder-picker-B5loyQsl.js";import{L as ws}from"./layers-Dl9LLqoY.js";import{L as Be}from"./loader-circle-CP1oxYjb.js";import{M as Tt}from"./MemberAvatar-BuaKw8fE.js";import{C as ja}from"./chevron-up-BhzmceCN.js";import{C as vt}from"./check-COf1UbPe.js";import{M as ks,P as Wt,a as Br,T as Ji}from"./modal-0iwqEf_V.js";import{S as as}from"./select-C0X1iRxk.js";import{u as Es}from"./use-providers-BdxKwaE3.js";import{M as en}from"./message-square-Bwt_cqko.js";import{U as Oi,C as od}from"./upload-CTsJ3wDk.js";import{A as Ws}from"./arrow-left-BSle2OYV.js";import{R as ad}from"./rotate-ccw-CnfGwAnp.js";var ld=class extends Vi{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Bn()})}getOptimisticResult(e){return e.behavior=Bn(),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,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:m,isRefetching:p,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,c=v&&i==="forward",u=m&&i==="forward",l=v&&i==="backward",g=m&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Mc(s,r.data),hasPreviousPage:Ac(s,r.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:n&&!c&&!l,isRefetching:p&&!u&&!g}}};function Kn(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function cd(e,s,r){const o=e.slice(0);return o[s]=r,o}var dd=class extends Dc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Li.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const m=o.map(u=>u.observer),p=m.map(u=>u.getCurrentResult()),v=r.length!==m.length,n=m.some((u,l)=>u!==r[l]),i=v||n,c=i?!0:p.some((u,l)=>{const g=this.#e[l];return!g||!Lc(u,g)});!i&&!c||(i&&(this.#c=o,this.#t=m),this.#e=p,this.hasListeners()&&(i&&(Kn(r,m).forEach(u=>{u.destroy()}),Kn(m,r).forEach(u=>{u.subscribe(l=>{this.#f(u,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),o=r.map(p=>p.observer.getOptimisticResult(p.defaultedQueryOptions)),m=r.map(p=>p.defaultedQueryOptions.queryHash);return[o,p=>this.#u(p??o,s,m),()=>this.#d(o,r)]}#d(e,s){return s.map((r,o)=>{const m=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{s.forEach(v=>{v.observer.trackProp(p)})})})}#u(e,s,r){if(s){const o=this.#l,m=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((p,v)=>p!==o[v]));return(!this.#s||this.#e!==this.#a||m||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Pc(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(o=>{const m=o.options.queryHash;if(!m)return;const p=s.get(m);p?p.push(o):s.set(m,[o])});const r=[];return e.forEach(o=>{const m=this.#r.defaultQueryOptions(o),v=s.get(m.queryHash)?.shift()??new Vi(this.#r,m);r.push({defaultedQueryOptions:m,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=cd(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Li.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function ud({queries:e,...s},r){const o=st(),m=Oc(),p=Ic(),v=w.useMemo(()=>e.map(x=>{const a=o.defaultQueryOptions(x);return a._optimisticResults=m?"isRestoring":"optimistic",a}),[e,o,m]);v.forEach(x=>{Bc(x);const a=o.getQueryCache().get(x.queryHash);Fc(x,p,a)}),zc(p);const[n]=w.useState(()=>new dd(o,v,s)),[i,c,u]=n.getOptimisticResult(v,s.combine),l=!m&&s.subscribed!==!1;w.useSyncExternalStore(w.useCallback(x=>l?n.subscribe(Li.batchCalls(x)):Hc,[n,l]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),w.useEffect(()=>{n.setQueries(v,s)},[v,s,n]);const _=i.some((x,a)=>Fn(v[a],x))?i.flatMap((x,a)=>{const h=v[a];if(h){const d=new Vi(o,h);if(Fn(h,x))return zn(h,d,p);Wc(x,m)&&zn(h,d,p)}return[]}):[];if(_.length>0)throw Promise.all(_);const y=i.find((x,a)=>{const h=v[a];return h&&$c({result:x,errorResetBoundary:p,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return c(u())}function tn(e,s){return Uc(e,ld)}const hd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],$s=pe("arrow-down",hd);const fd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],md=pe("arrow-right",fd);const pd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Fr=pe("arrow-up",pd);const gd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Na=pe("ban",gd);const vd=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],xd=pe("bot",vd);const _d=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bd=pe("chevron-left",_d);const yd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],xs=pe("clock-3",yd);const Sd=[["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"}]],Ys=pe("code-xml",Sd);const wd=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["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"}]],Xn=pe("copy-plus",wd);const Cd=[["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"}]],Yn=pe("copy",Cd);const kd=[["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"}]],Ra=pe("ellipsis-vertical",kd);const Ed=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],sn=pe("external-link",Ed);const jd=[["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"}]],Nd=pe("file-braces-corner",jd);const Rd=[["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"}]],yr=pe("file-code-corner",Rd);const Td=[["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"}]],Ad=pe("file-exclamation-point",Td);const Md=[["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"}]],rn=pe("file-text",Md);const Dd=[["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"}]],zr=pe("folder-open",Dd);const Ld=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Pd=pe("gauge",Ld);const Od=[["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"}]],nn=pe("git-branch",Od);const Id=[["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"}]],Vs=pe("git-graph",Id);const Bd=[["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"}]],Cs=pe("history",Bd);const Fd=[["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"}]],on=pe("image",Fd);const zd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Hd=pe("info",zd);const Wd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],$d=pe("lock-keyhole",Wd);const Ud=[["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"}]],qd=pe("maximize",Ud);const Kd=[["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"}]],Xd=pe("panel-left-close",Kd);const Yd=[["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"}]],Vd=pe("panel-left-open",Yd);const Gd=[["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"}]],Qd=pe("panel-right-close",Gd);const Zd=[["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"}]],Sr=pe("panel-right-open",Zd);const Jd=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],eu=pe("pen-line",Jd);const tu=[["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"}]],ls=pe("play",tu);const su=[["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"}]],Hr=pe("refresh-cw",su);const ru=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],iu=pe("save",ru);const nu=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],an=pe("search",nu);const ou=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ta=pe("settings-2",ou);const au=[["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"}]],Aa=pe("shield",au);const lu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Vn=pe("smartphone",lu);const cu=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],du=pe("square-pen",cu);const uu=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],wr=pe("terminal",uu);const hu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],cr=pe("user-plus",hu);const fu=[["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"}]],Ma=pe("zap",fu);const mu=[["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"}]],pu=pe("zoom-in",mu);const gu=[["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"}]],vu=pe("zoom-out",gu),Wr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function js(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function ln(e){return"nodeType"in e}function xt(e){var s,r;return e?js(e)?e:ln(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function cn(e){const{Document:s}=xt(e);return e instanceof s}function Gs(e){return js(e)?!1:e instanceof xt(e).HTMLElement}function Da(e){return e instanceof xt(e).SVGElement}function Ns(e){return e?js(e)?e.document:ln(e)?cn(e)?e:Gs(e)||Da(e)?e.ownerDocument:document:document:document}const $t=Wr?w.useLayoutEffect:w.useEffect;function $r(e){const s=w.useRef(e);return $t(()=>{s.current=e}),w.useCallback(function(){for(var r=arguments.length,o=new Array(r),m=0;m<r;m++)o[m]=arguments[m];return s.current==null?void 0:s.current(...o)},[])}function xu(){const e=w.useRef(null),s=w.useCallback((o,m)=>{e.current=setInterval(o,m)},[]),r=w.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Us(e,s){s===void 0&&(s=[e]);const r=w.useRef(e);return $t(()=>{r.current!==e&&(r.current=e)},s),r}function Qs(e,s){const r=w.useRef();return w.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Cr(e){const s=$r(e),r=w.useRef(null),o=w.useCallback(m=>{m!==r.current&&s?.(m,r.current),r.current=m},[]);return[r,o]}function kr(e){const s=w.useRef();return w.useEffect(()=>{s.current=e},[e]),s.current}let ui={};function Ur(e,s){return w.useMemo(()=>{if(s)return s;const r=ui[e]==null?0:ui[e]+1;return ui[e]=r,e+"-"+r},[e,s])}function La(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),m=1;m<r;m++)o[m-1]=arguments[m];return o.reduce((p,v)=>{const n=Object.entries(v);for(const[i,c]of n){const u=p[i];u!=null&&(p[i]=u+e*c)}return p},{...s})}}const ys=La(1),Er=La(-1);function _u(e){return"clientX"in e&&"clientY"in e}function dn(e){if(!e)return!1;const{KeyboardEvent:s}=xt(e.target);return s&&e instanceof s}function bu(e){if(!e)return!1;const{TouchEvent:s}=xt(e.target);return s&&e instanceof s}function jr(e){if(bu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return _u(e)?{x:e.clientX,y:e.clientY}:null}const qs=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[qs.Translate.toString(e),qs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),Gn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yu(e){return e.matches(Gn)?e:e.querySelector(Gn)}const Su={display:"none"};function wu(e){let{id:s,value:r}=e;return ae.createElement("div",{id:s,style:Su},r)}function Cu(e){let{id:s,announcement:r,ariaLiveType:o="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 ae.createElement("div",{id:s,style:m,role:"status","aria-live":o,"aria-atomic":!0},r)}function ku(){const[e,s]=w.useState("");return{announce:w.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const Pa=w.createContext(null);function Eu(e){const s=w.useContext(Pa);w.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function ju(){const[e]=w.useState(()=>new Set),s=w.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[w.useCallback(o=>{let{type:m,event:p}=o;e.forEach(v=>{var n;return(n=v[m])==null?void 0:n.call(v,p)})},[e]),s]}const Nu={draggable:`
|
|
2
|
+
To pick up a draggable item, press the space bar.
|
|
3
|
+
While dragging, use the arrow keys to move the item.
|
|
4
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
+
`},Ru={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Tu(e){let{announcements:s=Ru,container:r,hiddenTextDescribedById:o,screenReaderInstructions:m=Nu}=e;const{announce:p,announcement:v}=ku(),n=Ur("DndLiveRegion"),[i,c]=w.useState(!1);if(w.useEffect(()=>{c(!0)},[]),Eu(w.useMemo(()=>({onDragStart(l){let{active:g}=l;p(s.onDragStart({active:g}))},onDragMove(l){let{active:g,over:_}=l;s.onDragMove&&p(s.onDragMove({active:g,over:_}))},onDragOver(l){let{active:g,over:_}=l;p(s.onDragOver({active:g,over:_}))},onDragEnd(l){let{active:g,over:_}=l;p(s.onDragEnd({active:g,over:_}))},onDragCancel(l){let{active:g,over:_}=l;p(s.onDragCancel({active:g,over:_}))}}),[p,s])),!i)return null;const u=ae.createElement(ae.Fragment,null,ae.createElement(wu,{id:o,value:m.draggable}),ae.createElement(Cu,{id:n,announcement:v}));return r?Zt.createPortal(u,r):u}var tt;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(tt||(tt={}));function Nr(){}function Au(e,s){return w.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Mu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return w.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Dt=Object.freeze({x:0,y:0});function Du(e,s){const r=jr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Lu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Pu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Ou(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),m=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),v=m-o,n=p-r;if(o<m&&r<p){const i=s.width*s.height,c=e.width*e.height,u=v*n,l=u/(i+c-u);return Number(l.toFixed(4))}return 0}const Iu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const m=[];for(const p of o){const{id:v}=p,n=r.get(v);if(n){const i=Ou(n,s);i>0&&m.push({id:v,data:{droppableContainer:p,value:i}})}}return m.sort(Lu)};function Bu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Oa(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Dt}function Fu(e){return function(r){for(var o=arguments.length,m=new Array(o>1?o-1:0),p=1;p<o;p++)m[p-1]=arguments[p];return m.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const zu=Fu(1);function Ia(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Hu(e,s,r){const o=Ia(s);if(!o)return e;const{scaleX:m,scaleY:p,x:v,y:n}=o,i=e.left-v-(1-m)*parseFloat(r),c=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),u=m?e.width/m:e.width,l=p?e.height/p:e.height;return{width:u,height:l,top:c,right:i+u,bottom:c+l,left:i}}const Wu={ignoreTransform:!1};function Zs(e,s){s===void 0&&(s=Wu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:c,transformOrigin:u}=xt(e).getComputedStyle(e);c&&(r=Hu(r,c,u))}const{top:o,left:m,width:p,height:v,bottom:n,right:i}=r;return{top:o,left:m,width:p,height:v,bottom:n,right:i}}function Qn(e){return Zs(e,{ignoreTransform:!0})}function $u(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Uu(e,s){return s===void 0&&(s=xt(e).getComputedStyle(e)),s.position==="fixed"}function qu(e,s){s===void 0&&(s=xt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=s[m];return typeof p=="string"?r.test(p):!1})}function un(e,s){const r=[];function o(m){if(s!=null&&r.length>=s||!m)return r;if(cn(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!Gs(m)||Da(m)||r.includes(m))return r;const p=xt(e).getComputedStyle(m);return m!==e&&qu(m,p)&&r.push(m),Uu(m,p)?r:o(m.parentNode)}return e?o(e):r}function Ba(e){const[s]=un(e,1);return s??null}function hi(e){return!Wr||!e?null:js(e)?e:ln(e)?cn(e)||e===Ns(e).scrollingElement?window:Gs(e)?e:null:null}function Fa(e){return js(e)?e.scrollX:e.scrollLeft}function za(e){return js(e)?e.scrollY:e.scrollTop}function Ii(e){return{x:Fa(e),y:za(e)}}var at;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(at||(at={}));function Ha(e){return!Wr||!e?!1:e===document.scrollingElement}function Wa(e){const s={x:0,y:0},r=Ha(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},m=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:m,isLeft:p,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const Ku={x:.2,y:.2};function Xu(e,s,r,o,m){let{top:p,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),m===void 0&&(m=Ku);const{isTop:c,isBottom:u,isLeft:l,isRight:g}=Wa(e),_={x:0,y:0},y={x:0,y:0},x={height:s.height*m.y,width:s.width*m.x};return!c&&p<=s.top+x.height?(_.y=at.Backward,y.y=o*Math.abs((s.top+x.height-p)/x.height)):!u&&i>=s.bottom-x.height&&(_.y=at.Forward,y.y=o*Math.abs((s.bottom-x.height-i)/x.height)),!g&&n>=s.right-x.width?(_.x=at.Forward,y.x=o*Math.abs((s.right-x.width-n)/x.width)):!l&&v<=s.left+x.width&&(_.x=at.Backward,y.x=o*Math.abs((s.left+x.width-v)/x.width)),{direction:_,speed:y}}function Yu(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:v}=window;return{top:0,left:0,right:p,bottom:v,width:p,height:v}}const{top:s,left:r,right:o,bottom:m}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:m,width:e.clientWidth,height:e.clientHeight}}function $a(e){return e.reduce((s,r)=>ys(s,Ii(r)),Dt)}function Vu(e){return e.reduce((s,r)=>s+Fa(r),0)}function Gu(e){return e.reduce((s,r)=>s+za(r),0)}function Ua(e,s){if(s===void 0&&(s=Zs),!e)return;const{top:r,left:o,bottom:m,right:p}=s(e);Ba(e)&&(m<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Qu=[["x",["left","right"],Vu],["y",["top","bottom"],Gu]];class hn{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=un(r),m=$a(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,v,n]of Qu)for(const i of v)Object.defineProperty(this,i,{get:()=>{const c=n(o),u=m[p]-c;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Is{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var m;(m=this.target)==null||m.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Zu(e){const{EventTarget:s}=xt(e);return e instanceof s?e:Ns(e)}function fi(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Et;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Et||(Et={}));function Zn(e){e.preventDefault()}function Ju(e){e.stopPropagation()}var We;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(We||(We={}));const qa={start:[We.Space,We.Enter],cancel:[We.Esc],end:[We.Space,We.Enter,We.Tab]},eh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case We.Right:return{...r,x:r.x+25};case We.Left:return{...r,x:r.x-25};case We.Down:return{...r,y:r.y+25};case We.Up:return{...r,y:r.y-25}}};class Ka{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new Is(Ns(r)),this.windowListeners=new Is(xt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Et.Resize,this.handleCancel),this.windowListeners.add(Et.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Et.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Ua(o),r(Dt)}handleKeyDown(s){if(dn(s)){const{active:r,context:o,options:m}=this.props,{keyboardCodes:p=qa,coordinateGetter:v=eh,scrollBehavior:n="smooth"}=m,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:c}=o.current,u=c?{x:c.left,y:c.top}:Dt;this.referenceCoordinates||(this.referenceCoordinates=u);const l=v(s,{active:r,context:o.current,currentCoordinates:u});if(l){const g=Er(l,u),_={x:0,y:0},{scrollableAncestors:y}=o.current;for(const x of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:S,minScroll:k}=Wa(x),E=Yu(x),C={x:Math.min(a===We.Right?E.right-E.width/2:E.right,Math.max(a===We.Right?E.left:E.left+E.width/2,l.x)),y:Math.min(a===We.Down?E.bottom-E.height/2:E.bottom,Math.max(a===We.Down?E.top:E.top+E.height/2,l.y))},j=a===We.Right&&!d||a===We.Left&&!f,N=a===We.Down&&!b||a===We.Up&&!h;if(j&&C.x!==l.x){const M=x.scrollLeft+g.x,T=a===We.Right&&M<=S.x||a===We.Left&&M>=k.x;if(T&&!g.y){x.scrollTo({left:M,behavior:n});return}T?_.x=x.scrollLeft-M:_.x=a===We.Right?x.scrollLeft-S.x:x.scrollLeft-k.x,_.x&&x.scrollBy({left:-_.x,behavior:n});break}else if(N&&C.y!==l.y){const M=x.scrollTop+g.y,T=a===We.Down&&M<=S.y||a===We.Up&&M>=k.y;if(T&&!g.x){x.scrollTo({top:M,behavior:n});return}T?_.y=x.scrollTop-M:_.y=a===We.Down?x.scrollTop-S.y:x.scrollTop-k.y,_.y&&x.scrollBy({top:-_.y,behavior:n});break}}this.handleMove(s,ys(Er(l,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ka.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=qa,onActivation:m}=s,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Jn(e){return!!(e&&"distance"in e)}function eo(e){return!!(e&&"delay"in e)}class fn{constructor(s,r,o){var m;o===void 0&&(o=Zu(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:p}=s,{target:v}=p;this.props=s,this.events=r,this.document=Ns(v),this.documentListeners=new Is(this.document),this.listeners=new Is(o),this.windowListeners=new Is(xt(v)),this.initialCoordinates=(m=jr(p))!=null?m:Dt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Et.Resize,this.handleCancel),this.windowListeners.add(Et.DragStart,Zn),this.windowListeners.add(Et.VisibilityChange,this.handleCancel),this.windowListeners.add(Et.ContextMenu,Zn),this.documentListeners.add(Et.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(eo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Jn(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:m}=this.props;m(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Et.Click,Ju,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Et.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:m,props:p}=this,{onMove:v,options:{activationConstraint:n}}=p;if(!m)return;const i=(r=jr(s))!=null?r:Dt,c=Er(m,i);if(!o&&n){if(Jn(n)){if(n.tolerance!=null&&fi(c,n.tolerance))return this.handleCancel();if(fi(c,n.distance))return this.handleStart()}if(eo(n)&&fi(c,n.tolerance))return this.handleCancel();this.handlePending(n,c);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===We.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const th={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class mn extends fn{constructor(s){const{event:r}=s,o=Ns(r.target);super(s,th,o)}}mn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const sh={move:{name:"mousemove"},end:{name:"mouseup"}};var Bi;(function(e){e[e.RightClick=2]="RightClick"})(Bi||(Bi={}));class rh extends fn{constructor(s){super(s,sh,Ns(s.event.target))}}rh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Bi.RightClick?!1:(o?.({event:r}),!0)}}];const mi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ih extends fn{constructor(s){super(s,mi)}static setup(){return window.addEventListener(mi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(mi.move.name,s)};function s(){}}}ih.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:m}=r;return m.length>1?!1:(o?.({event:r}),!0)}}];var Bs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Bs||(Bs={}));var Rr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rr||(Rr={}));function nh(e){let{acceleration:s,activator:r=Bs.Pointer,canScroll:o,draggingRect:m,enabled:p,interval:v=5,order:n=Rr.TreeOrder,pointerCoordinates:i,scrollableAncestors:c,scrollableAncestorRects:u,delta:l,threshold:g}=e;const _=ah({delta:l,disabled:!p}),[y,x]=xu(),a=w.useRef({x:0,y:0}),h=w.useRef({x:0,y:0}),d=w.useMemo(()=>{switch(r){case Bs.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Bs.DraggableRect:return m}},[r,m,i]),f=w.useRef(null),b=w.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,C=a.current.y*h.current.y;k.scrollBy(E,C)},[]),S=w.useMemo(()=>n===Rr.TreeOrder?[...c].reverse():c,[n,c]);w.useEffect(()=>{if(!p||!c.length||!d){x();return}for(const k of S){if(o?.(k)===!1)continue;const E=c.indexOf(k),C=u[E];if(!C)continue;const{direction:j,speed:N}=Xu(k,C,d,s,g);for(const M of["x","y"])_[M][j[M]]||(N[M]=0,j[M]=0);if(N.x>0||N.y>0){x(),f.current=k,y(b,v),a.current=N,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},x()},[s,b,o,x,p,v,JSON.stringify(d),JSON.stringify(_),y,c,S,u,JSON.stringify(g)])}const oh={x:{[at.Backward]:!1,[at.Forward]:!1},y:{[at.Backward]:!1,[at.Forward]:!1}};function ah(e){let{delta:s,disabled:r}=e;const o=kr(s);return Qs(m=>{if(r||!o||!m)return oh;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[at.Backward]:m.x[at.Backward]||p.x===-1,[at.Forward]:m.x[at.Forward]||p.x===1},y:{[at.Backward]:m.y[at.Backward]||p.y===-1,[at.Forward]:m.y[at.Forward]||p.y===1}}},[r,s,o])}function lh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return Qs(m=>{var p;return s==null?null:(p=o??m)!=null?p:null},[o,s])}function ch(e,s){return w.useMemo(()=>e.reduce((r,o)=>{const{sensor:m}=o,p=m.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...p]},[]),[e,s])}var Ks;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ks||(Ks={}));var Fi;(function(e){e.Optimized="optimized"})(Fi||(Fi={}));const to=new Map;function dh(e,s){let{dragging:r,dependencies:o,config:m}=s;const[p,v]=w.useState(null),{frequency:n,measure:i,strategy:c}=m,u=w.useRef(e),l=a(),g=Us(l),_=w.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),y=w.useRef(null),x=Qs(h=>{if(l&&!r)return to;if(!h||h===to||u.current!==e||p!=null){const d=new Map;for(let f of e){if(!f)continue;if(p&&p.length>0&&!p.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const b=f.node.current,S=b?new hn(i(b),b):null;f.rect.current=S,S&&d.set(f.id,S)}return d}return h},[e,p,r,l,i]);return w.useEffect(()=>{u.current=e},[e]),w.useEffect(()=>{l||_()},[r,l]),w.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),w.useEffect(()=>{l||typeof n!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},n))},[n,l,_,...o]),{droppableRects:x,measureDroppableContainers:_,measuringScheduled:p!=null};function a(){switch(c){case Ks.Always:return!1;case Ks.BeforeDragging:return r;default:return!r}}}function pn(e,s){return Qs(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function uh(e,s){return pn(e,s)}function hh(e){let{callback:s,disabled:r}=e;const o=$r(s),m=w.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return w.useEffect(()=>()=>m?.disconnect(),[m]),m}function qr(e){let{callback:s,disabled:r}=e;const o=$r(s),m=w.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return w.useEffect(()=>()=>m?.disconnect(),[m]),m}function fh(e){return new hn(Zs(e),e)}function so(e,s,r){s===void 0&&(s=fh);const[o,m]=w.useState(null);function p(){m(i=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=i??r)!=null?c:null}const u=s(e);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const v=hh({callback(i){if(e)for(const c of i){const{type:u,target:l}=c;if(u==="childList"&&l instanceof HTMLElement&&l.contains(e)){p();break}}}}),n=qr({callback:p});return $t(()=>{p(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function mh(e){const s=pn(e);return Oa(e,s)}const ro=[];function ph(e){const s=w.useRef(e),r=Qs(o=>e?o&&o!==ro&&e&&s.current&&e.parentNode===s.current.parentNode?o:un(e):ro,[e]);return w.useEffect(()=>{s.current=e},[e]),r}function gh(e){const[s,r]=w.useState(null),o=w.useRef(e),m=w.useCallback(p=>{const v=hi(p.target);v&&r(n=>n?(n.set(v,Ii(v)),new Map(n)):null)},[]);return w.useEffect(()=>{const p=o.current;if(e!==p){v(p);const n=e.map(i=>{const c=hi(i);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,Ii(c)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(p)};function v(n){n.forEach(i=>{const c=hi(i);c?.removeEventListener("scroll",m)})}},[m,e]),w.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,v)=>ys(p,v),Dt):$a(e):Dt,[e,s])}function io(e,s){s===void 0&&(s=[]);const r=w.useRef(null);return w.useEffect(()=>{r.current=null},s),w.useEffect(()=>{const o=e!==Dt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Er(e,r.current):Dt}function vh(e){w.useEffect(()=>{if(!Wr)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function xh(e,s){return w.useMemo(()=>e.reduce((r,o)=>{let{eventName:m,handler:p}=o;return r[m]=v=>{p(v,s)},r},{}),[e,s])}function Xa(e){return w.useMemo(()=>e?$u(e):null,[e])}const no=[];function _h(e,s){s===void 0&&(s=Zs);const[r]=e,o=Xa(r?xt(r):null),[m,p]=w.useState(no);function v(){p(()=>e.length?e.map(i=>Ha(i)?o:new hn(s(i),i)):no)}const n=qr({callback:v});return $t(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),m}function Ya(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Gs(s)?s:e}function bh(e){let{measure:s}=e;const[r,o]=w.useState(null),m=w.useCallback(c=>{for(const{target:u}of c)if(Gs(u)){o(l=>{const g=s(u);return l?{...l,width:g.width,height:g.height}:g});break}},[s]),p=qr({callback:m}),v=w.useCallback(c=>{const u=Ya(c);p?.disconnect(),u&&p?.observe(u),o(u?s(u):null)},[s,p]),[n,i]=Cr(v);return w.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const yh=[{sensor:mn,options:{}},{sensor:Ka,options:{}}],Sh={current:{}},vr={draggable:{measure:Qn},droppable:{measure:Qn,strategy:Ks.WhileDragging,frequency:Fi.Optimized},dragOverlay:{measure:Zs}};class Fs extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const wh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Fs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Nr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:vr,measureDroppableContainers:Nr,windowRect:null,measuringScheduled:!1},Va={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Nr,draggableNodes:new Map,over:null,measureDroppableContainers:Nr},Js=w.createContext(Va),Ga=w.createContext(wh);function Ch(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Fs}}}function kh(e,s){switch(s.type){case tt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case tt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case tt.DragEnd:case tt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case tt.RegisterDroppable:{const{element:r}=s,{id:o}=r,m=new Fs(e.droppable.containers);return m.set(o,r),{...e,droppable:{...e.droppable,containers:m}}}case tt.SetDroppableDisabled:{const{id:r,key:o,disabled:m}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new Fs(e.droppable.containers);return v.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:v}}}case tt.UnregisterDroppable:{const{id:r,key:o}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const p=new Fs(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function Eh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:m}=w.useContext(Js),p=kr(o),v=kr(r?.id);return w.useEffect(()=>{if(!s&&!o&&p&&v!=null){if(!dn(p)||document.activeElement===p.target)return;const n=m.get(v);if(!n)return;const{activatorNode:i,node:c}=n;if(!i.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[i.current,c.current]){if(!u)continue;const l=yu(u);if(l){l.focus();break}}})}},[o,s,m,v,p]),null}function Qa(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...o}),r):r}function jh(e){return w.useMemo(()=>({draggable:{...vr.draggable,...e?.draggable},droppable:{...vr.droppable,...e?.droppable},dragOverlay:{...vr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Nh(e){let{activeNode:s,measure:r,initialRect:o,config:m=!0}=e;const p=w.useRef(!1),{x:v,y:n}=typeof m=="boolean"?{x:m,y:m}:m;$t(()=>{if(!v&&!n||!s){p.current=!1;return}if(p.current||!o)return;const c=s?.node.current;if(!c||c.isConnected===!1)return;const u=r(c),l=Oa(u,o);if(v||(l.x=0),n||(l.y=0),p.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=Ba(c);g&&g.scrollBy({top:l.y,left:l.x})}},[s,v,n,o,r])}const Kr=w.createContext({...Dt,scaleX:1,scaleY:1});var Gt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Gt||(Gt={}));const Rh=w.memo(function(s){var r,o,m,p;let{id:v,accessibility:n,autoScroll:i=!0,children:c,sensors:u=yh,collisionDetection:l=Iu,measuring:g,modifiers:_,...y}=s;const x=w.useReducer(kh,void 0,Ch),[a,h]=x,[d,f]=ju(),[b,S]=w.useState(Gt.Uninitialized),k=b===Gt.Initialized,{draggable:{active:E,nodes:C,translate:j},droppable:{containers:N}}=a,M=E!=null?C.get(E):null,T=w.useRef({initial:null,translated:null}),D=w.useMemo(()=>{var we;return E!=null?{id:E,data:(we=M?.data)!=null?we:Sh,rect:T}:null},[E,M]),B=w.useRef(null),[L,F]=w.useState(null),[z,A]=w.useState(null),P=Us(y,Object.values(y)),O=Ur("DndDescribedBy",v),I=w.useMemo(()=>N.getEnabled(),[N]),U=jh(g),{droppableRects:X,measureDroppableContainers:$,measuringScheduled:V}=dh(I,{dragging:k,dependencies:[j.x,j.y],config:U.droppable}),q=lh(C,E),R=w.useMemo(()=>z?jr(z):null,[z]),H=rt(),K=uh(q,U.draggable.measure);Nh({activeNode:E!=null?C.get(E):null,config:H.layoutShiftCompensation,initialRect:K,measure:U.draggable.measure});const W=so(q,U.draggable.measure,K),Q=so(q?q.parentElement:null),J=w.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=N.getNodeFor((r=J.current.over)==null?void 0:r.id),fe=bh({measure:U.dragOverlay.measure}),Ne=(o=fe.nodeRef.current)!=null?o:q,je=k?(m=fe.rect)!=null?m:W:null,se=!!(fe.nodeRef.current&&fe.rect),Oe=mh(se?null:W),Me=Xa(Ne?xt(Ne):null),Fe=ph(k?oe??q:null),ze=_h(Fe),Qe=Qa(_,{transform:{x:j.x-Oe.x,y:j.y-Oe.y,scaleX:1,scaleY:1},activatorEvent:z,active:D,activeNodeRect:W,containerNodeRect:Q,draggingNodeRect:je,over:J.current.over,overlayNodeRect:fe.rect,scrollableAncestors:Fe,scrollableAncestorRects:ze,windowRect:Me}),Te=R?ys(R,j):null,ee=gh(Fe),xe=io(ee),Re=io(ee,[W]),G=ys(Qe,xe),ne=je?zu(je,Qe):null,ue=D&&ne?l({active:D,collisionRect:ne,droppableRects:X,droppableContainers:I,pointerCoordinates:Te}):null,ye=Pu(ue,"id"),[Se,Y]=w.useState(null),ie=se?Qe:ys(Qe,Re),he=Bu(ie,(p=Se?.rect)!=null?p:null,W),_e=w.useRef(null),Ie=w.useCallback((we,ke)=>{let{sensor:Le,options:Ge}=ke;if(B.current==null)return;const dt=C.get(B.current);if(!dt)return;const et=we.nativeEvent,ft=new Le({active:B.current,activeNode:dt,event:et,options:Ge,context:J,onAbort(Ce){if(!C.get(Ce))return;const{onDragAbort:_t}=P.current,mt={id:Ce};_t?.(mt),d({type:"onDragAbort",event:mt})},onPending(Ce,ut,_t,mt){if(!C.get(Ce))return;const{onDragPending:Ue}=P.current,it={id:Ce,constraint:ut,initialCoordinates:_t,offset:mt};Ue?.(it),d({type:"onDragPending",event:it})},onStart(Ce){const ut=B.current;if(ut==null)return;const _t=C.get(ut);if(!_t)return;const{onDragStart:mt}=P.current,kt={activatorEvent:et,active:{id:ut,data:_t.data,rect:T}};Zt.unstable_batchedUpdates(()=>{mt?.(kt),S(Gt.Initializing),h({type:tt.DragStart,initialCoordinates:Ce,active:ut}),d({type:"onDragStart",event:kt}),F(_e.current),A(et)})},onMove(Ce){h({type:tt.DragMove,coordinates:Ce})},onEnd:Ct(tt.DragEnd),onCancel:Ct(tt.DragCancel)});_e.current=ft;function Ct(Ce){return async function(){const{active:_t,collisions:mt,over:kt,scrollAdjustedTranslate:Ue}=J.current;let it=null;if(_t&&Ue){const{cancelDrop:Ft}=P.current;it={activatorEvent:et,active:_t,collisions:mt,delta:Ue,over:kt},Ce===tt.DragEnd&&typeof Ft=="function"&&await Promise.resolve(Ft(it))&&(Ce=tt.DragCancel)}B.current=null,Zt.unstable_batchedUpdates(()=>{h({type:Ce}),S(Gt.Uninitialized),Y(null),F(null),A(null),_e.current=null;const Ft=Ce===tt.DragEnd?"onDragEnd":"onDragCancel";if(it){const zt=P.current[Ft];zt?.(it),d({type:Ft,event:it})}})}}},[C]),He=w.useCallback((we,ke)=>(Le,Ge)=>{const dt=Le.nativeEvent,et=C.get(Ge);if(B.current!==null||!et||dt.dndKit||dt.defaultPrevented)return;const ft={active:et};we(Le,ke.options,ft)===!0&&(dt.dndKit={capturedBy:ke.sensor},B.current=Ge,Ie(Le,ke))},[C,Ie]),Ve=ch(u,He);vh(u),$t(()=>{W&&b===Gt.Initializing&&S(Gt.Initialized)},[W,b]),w.useEffect(()=>{const{onDragMove:we}=P.current,{active:ke,activatorEvent:Le,collisions:Ge,over:dt}=J.current;if(!ke||!Le)return;const et={active:ke,activatorEvent:Le,collisions:Ge,delta:{x:G.x,y:G.y},over:dt};Zt.unstable_batchedUpdates(()=>{we?.(et),d({type:"onDragMove",event:et})})},[G.x,G.y]),w.useEffect(()=>{const{active:we,activatorEvent:ke,collisions:Le,droppableContainers:Ge,scrollAdjustedTranslate:dt}=J.current;if(!we||B.current==null||!ke||!dt)return;const{onDragOver:et}=P.current,ft=Ge.get(ye),Ct=ft&&ft.rect.current?{id:ft.id,rect:ft.rect.current,data:ft.data,disabled:ft.disabled}:null,Ce={active:we,activatorEvent:ke,collisions:Le,delta:{x:dt.x,y:dt.y},over:Ct};Zt.unstable_batchedUpdates(()=>{Y(Ct),et?.(Ce),d({type:"onDragOver",event:Ce})})},[ye]),$t(()=>{J.current={activatorEvent:z,active:D,activeNode:q,collisionRect:ne,collisions:ue,droppableRects:X,draggableNodes:C,draggingNode:Ne,draggingNodeRect:je,droppableContainers:N,over:Se,scrollableAncestors:Fe,scrollAdjustedTranslate:G},T.current={initial:je,translated:ne}},[D,q,ue,ne,C,Ne,je,X,N,Se,Fe,G]),nh({...H,delta:j,draggingRect:ne,pointerCoordinates:Te,scrollableAncestors:Fe,scrollableAncestorRects:ze});const $e=w.useMemo(()=>({active:D,activeNode:q,activeNodeRect:W,activatorEvent:z,collisions:ue,containerNodeRect:Q,dragOverlay:fe,draggableNodes:C,droppableContainers:N,droppableRects:X,over:Se,measureDroppableContainers:$,scrollableAncestors:Fe,scrollableAncestorRects:ze,measuringConfiguration:U,measuringScheduled:V,windowRect:Me}),[D,q,W,z,ue,Q,fe,C,N,X,Se,$,Fe,ze,U,V,Me]),De=w.useMemo(()=>({activatorEvent:z,activators:Ve,active:D,activeNodeRect:W,ariaDescribedById:{draggable:O},dispatch:h,draggableNodes:C,over:Se,measureDroppableContainers:$}),[z,Ve,D,W,h,O,C,Se,$]);return ae.createElement(Pa.Provider,{value:f},ae.createElement(Js.Provider,{value:De},ae.createElement(Ga.Provider,{value:$e},ae.createElement(Kr.Provider,{value:he},c)),ae.createElement(Eh,{disabled:n?.restoreFocus===!1})),ae.createElement(Tu,{...n,hiddenTextDescribedById:O}));function rt(){const we=L?.autoScrollEnabled===!1,ke=typeof i=="object"?i.enabled===!1:i===!1,Le=k&&!we&&!ke;return typeof i=="object"?{...i,enabled:Le}:{enabled:Le}}}),Th=w.createContext(null),oo="button",Ah="Draggable";function Mh(e){let{id:s,data:r,disabled:o=!1,attributes:m}=e;const p=Ur(Ah),{activators:v,activatorEvent:n,active:i,activeNodeRect:c,ariaDescribedById:u,draggableNodes:l,over:g}=w.useContext(Js),{role:_=oo,roleDescription:y="draggable",tabIndex:x=0}=m??{},a=i?.id===s,h=w.useContext(a?Kr:Th),[d,f]=Cr(),[b,S]=Cr(),k=xh(v,s),E=Us(r);$t(()=>(l.set(s,{id:s,key:p,node:d,activatorNode:b,data:E}),()=>{const j=l.get(s);j&&j.key===p&&l.delete(s)}),[l,s]);const C=w.useMemo(()=>({role:_,tabIndex:x,"aria-disabled":o,"aria-pressed":a&&_===oo?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[o,_,x,a,y,u.draggable]);return{active:i,activatorEvent:n,activeNodeRect:c,attributes:C,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:S,transform:h}}function Dh(){return w.useContext(Ga)}const Lh="Droppable",Ph={timeout:25};function Oh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:m}=e;const p=Ur(Lh),{active:v,dispatch:n,over:i,measureDroppableContainers:c}=w.useContext(Js),u=w.useRef({disabled:r}),l=w.useRef(!1),g=w.useRef(null),_=w.useRef(null),{disabled:y,updateMeasurementsFor:x,timeout:a}={...Ph,...m},h=Us(x??o),d=w.useCallback(()=>{if(!l.current){l.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),_.current=null},a)},[a]),f=qr({callback:d,disabled:y||!v}),b=w.useCallback((C,j)=>{f&&(j&&(f.unobserve(j),l.current=!1),C&&f.observe(C))},[f]),[S,k]=Cr(b),E=Us(s);return w.useEffect(()=>{!f||!S.current||(f.disconnect(),l.current=!1,f.observe(S.current))},[S,f]),w.useEffect(()=>(n({type:tt.RegisterDroppable,element:{id:o,key:p,disabled:r,node:S,rect:g,data:E}}),()=>n({type:tt.UnregisterDroppable,key:p,id:o})),[o]),w.useEffect(()=>{r!==u.current.disabled&&(n({type:tt.SetDroppableDisabled,id:o,key:p,disabled:r}),u.current.disabled=r)},[o,p,r,n]),{active:v,rect:g,isOver:i?.id===o,node:S,over:i,setNodeRef:k}}function Ih(e){let{animation:s,children:r}=e;const[o,m]=w.useState(null),[p,v]=w.useState(null),n=kr(r);return!r&&!o&&n&&m(n),$t(()=>{if(!p)return;const i=o?.key,c=o?.props.id;if(i==null||c==null){m(null);return}Promise.resolve(s(c,p)).then(()=>{m(null)})},[s,o,p]),ae.createElement(ae.Fragment,null,r,o?w.cloneElement(o,{ref:v}):null)}const Bh={x:0,y:0,scaleX:1,scaleY:1};function Fh(e){let{children:s}=e;return ae.createElement(Js.Provider,{value:Va},ae.createElement(Kr.Provider,{value:Bh},s))}const zh={position:"fixed",touchAction:"none"},Hh=e=>dn(e)?"transform 250ms ease":void 0,Wh=w.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:m,children:p,className:v,rect:n,style:i,transform:c,transition:u=Hh}=e;if(!n)return null;const l=m?c:{...c,scaleX:1,scaleY:1},g={...zh,width:n.width,height:n.height,top:n.top,left:n.left,transform:qs.Transform.toString(l),transformOrigin:m&&o?Du(o,n):void 0,transition:typeof u=="function"?u(o):u,...i};return ae.createElement(r,{className:v,style:g,ref:s},p)}),$h=e=>s=>{let{active:r,dragOverlay:o}=s;const m={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(m[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,c]of Object.entries(m))r.node.style.setProperty(i,c);v!=null&&v.active&&r.node.classList.remove(v.active)}},Uh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:qs.Transform.toString(s)},{transform:qs.Transform.toString(r)}]},qh={duration:250,easing:"ease",keyframes:Uh,sideEffects:$h({styles:{active:{opacity:"0"}}})};function Kh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:m}=e;return $r((p,v)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const c=Ya(v);if(!c)return;const{transform:u}=xt(v).getComputedStyle(v),l=Ia(u);if(!l)return;const g=typeof s=="function"?s:Xh(s);return Ua(i,m.draggable.measure),g({active:{id:p,data:n.data,node:i,rect:m.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:m.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:m,transform:l})})}function Xh(e){const{duration:s,easing:r,sideEffects:o,keyframes:m}={...qh,...e};return p=>{let{active:v,dragOverlay:n,transform:i,...c}=p;if(!s)return;const u={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},l={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},g={x:i.x-u.x,y:i.y-u.y,...l},_=m({...c,active:v,dragOverlay:n,transform:{initial:i,final:g}}),[y]=_,x=_[_.length-1];if(JSON.stringify(y)===JSON.stringify(x))return;const a=o?.({active:v,dragOverlay:n,...c}),h=n.node.animate(_,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let ao=0;function Yh(e){return w.useMemo(()=>{if(e!=null)return ao++,ao},[e])}const Vh=ae.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:m,transition:p,modifiers:v,wrapperElement:n="div",className:i,zIndex:c=999}=e;const{activatorEvent:u,active:l,activeNodeRect:g,containerNodeRect:_,draggableNodes:y,droppableContainers:x,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:S}=Dh(),k=w.useContext(Kr),E=Yh(l?.id),C=Qa(v,{activatorEvent:u,active:l,activeNodeRect:g,containerNodeRect:_,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:S}),j=pn(g),N=Kh({config:o,draggableNodes:y,droppableContainers:x,measuringConfiguration:d}),M=j?a.setRef:void 0;return ae.createElement(Fh,null,ae.createElement(Ih,{animation:N},l&&E?ae.createElement(Wh,{key:E,id:l.id,ref:M,as:n,activatorEvent:u,adjustScale:s,className:i,transition:p,rect:j,style:{zIndex:c,...m},transform:C},r):null))}),Za=768;function Gh(e){const s=window.matchMedia(`(max-width: ${Za-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Qh(){return window.innerWidth<Za}function Zh(){return!1}function Ja(){return w.useSyncExternalStore(Gh,Qh,Zh)}function gn(e){return wt({queryKey:ce.workspaces.list(e),queryFn:()=>ve.get(`/tasks/${e}/workspaces`),enabled:!!e})}function el(e){const s=st();return bt({mutationFn:r=>ve.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function Jh(){const e=st();return bt({mutationFn:({id:s,commitMessage:r})=>ve.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all}),e.invalidateQueries({queryKey:ce.git.all})},onError:()=>{e.invalidateQueries({queryKey:ce.git.all})}})}function ef(){const e=st();return bt({mutationFn:s=>ve.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function vn(){return bt({mutationFn:({workspaceId:e,editorType:s})=>ve.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function xn(e){return wt({queryKey:ce.workspaces.gitStatus(e),queryFn:()=>ve.get(`/workspaces/${e}/git-status`),enabled:!!e})}function tf(){const e=st();return bt({mutationFn:s=>ve.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function tl(){const e=st();return bt({mutationFn:s=>ve.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function sf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(v=>v.status===Je.RUNNING||v.status===Je.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function _n({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:m,workspaces:p,isLoading:v}){const{t:n}=le(),{data:i,isLoading:c}=gn(p===void 0&&e?o:""),u=p??i,l=p===void 0&&e&&c,g=w.useMemo(()=>sf(u,n),[u,n]);return t.jsx(Or,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:m})}),l?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((_,y)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:_})]},y))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||l})}const ge={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},zi={[ge.Review]:{label:"Review",icon:Sa,iconClass:"text-warning",accentClass:"text-warning"},[ge.Running]:{label:"Running",icon:ya,iconClass:"text-info",accentClass:"text-info"},[ge.Pending]:{label:"Pending",icon:ba,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ge.Done]:{label:"Done",icon:_a,iconClass:"text-success/80",accentClass:"text-success"},[ge.Cancelled]:{label:"Cancelled",icon:xa,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},rf=[ge.Review,ge.Running,ge.Pending,ge.Done,ge.Cancelled];function nf({task:e,status:s,isSelected:r,isAgentActive:o,project:m,onSelectTask:p,onTaskStatusChange:v,onDeleteTask:n,disableDrag:i}){const{t:c}=le(),u=!!e.projectArchivedAt,l=u||!!i,{attributes:g,listeners:_,setNodeRef:y,isDragging:x}=Mh({id:e.id,data:{task:e,fromStatus:s},disabled:l}),[a,h]=w.useState(null),[d,f]=w.useState(!1),b=w.useRef(null),S=w.useRef(null),k=w.useCallback(j=>{u||!v&&!n||(j.preventDefault(),h({x:j.clientX,y:j.clientY}))},[u,v,n]),E=w.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),C=w.useCallback(j=>{if(!i||u||!v&&!n)return;const N=j.touches[0];if(!N)return;const{clientX:M,clientY:T}=N;S.current=setTimeout(()=>{S.current=null,h({x:M,y:T})},500)},[i,u,v,n]);return w.useEffect(()=>{if(!a)return;const j=N=>{b.current&&!b.current.contains(N.target)&&h(null)};return document.addEventListener("mousedown",j),document.addEventListener("touchstart",j),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("touchstart",j)}},[a]),t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:y,onClick:()=>p(e.id),onContextMenu:k,onTouchStart:C,onTouchEnd:E,onTouchMove:E,className:`flex items-center gap-2.5 mx-2 px-2 py-2 rounded-md text-sm text-left transition-colors group
|
|
6
|
+
${x?"opacity-30":""}
|
|
7
|
+
${r?"bg-accent":"hover:bg-accent/50"}`,...l?{}:_,...l?{}:g,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:j,iconClass:N}=zi[s];return t.jsx(j,{className:`${N} ${s===ge.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),o&&t.jsxs("span",{className:"relative inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-success/70"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-success"})]}),m&&t.jsx("span",{className:"shrink-0 max-w-[96px] truncate text-xs text-muted-foreground/60",title:m.name,children:m.name})]}),a&&t.jsxs("div",{ref:b,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:a.x,top:a.y},children:[v&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:c("Move to")}),rf.filter(j=>j!==s).map(j=>{const{icon:N,label:M,accentClass:T}=zi[j];return t.jsxs("button",{onClick:()=>{v(e.id,j),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(N,{className:`w-3.5 h-3.5 ${T}`}),t.jsx("span",{className:"text-foreground/80",children:c(M)})]},j)})]}),n&&t.jsxs(t.Fragment,{children:[v&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{f(!0),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:c("Delete Task")})]})]})]}),t.jsx(_n,{isOpen:d,onClose:()=>f(!1),onConfirm:()=>{n?.(e.id),f(!1)},taskId:e.id,taskTitle:e.title})]})}const of=w.memo(function({title:s,tasks:r,status:o,defaultOpen:m,selectedTaskId:p,onSelectTask:v,projects:n,activeTaskIds:i,isDragging:c,dragFromStatus:u,onTaskStatusChange:l,onDeleteTask:g,disableDrag:_}){const{t:y}=le(),[x,a]=w.useState(m),h=r.length===0,d=c&&u===o,f=c&&u!==o,{setNodeRef:b,isOver:S}=Oh({id:`group-${o}`,data:{status:o}}),k=o===ge.Review,E=y(s),C=c?d&&(x||!0):x;return t.jsxs("div",{className:"mb-2",children:[t.jsxs("button",{onClick:()=>!c&&a(j=>!j),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:E}),k&&!h?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:C?t.jsx(ct,{size:12}):t.jsx(Mt,{size:12})})]}),f&&t.jsx("div",{ref:b,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
8
|
+
${S?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:S?y("Drop into {title}",{title:E}):y("Drop here")})}),C&&!f&&t.jsx("div",{ref:d?void 0:b,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
9
|
+
${S&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
10
|
+
${h&&c?"border border-dashed border-border mx-2":""}`,children:h?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:y("No tasks")}):r.map(j=>{const N=n.find(D=>D.id===j.projectId),M=p===j.id,T=i?.has(j.id)??!1;return t.jsx(nf,{task:j,status:o,isSelected:M,isAgentActive:T,project:N,onSelectTask:v,onTaskStatusChange:j.projectArchivedAt?void 0:l,onDeleteTask:j.projectArchivedAt?void 0:g,disableDrag:_},j.id)})})]})}),af=12,lf=50;function cf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:m}){const{t:p}=le(),[v,n]=w.useState(""),[i,c]=w.useState(0),u=w.useRef(null);w.useEffect(()=>{e&&(n(""),c(0))},[e]);const l=w.useMemo(()=>{const y=v.trim().toLowerCase();return y?r.filter(x=>x.title.toLowerCase().includes(y)).slice(0,lf):r.slice(0,af)},[r,v]);w.useEffect(()=>{c(0)},[v]),w.useEffect(()=>{u.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const g=w.useCallback(y=>{m(y),s()},[m,s]),_=w.useCallback(y=>{if(y.key==="Escape")y.preventDefault(),s();else if(y.key==="ArrowDown")y.preventDefault(),c(x=>Math.min(x+1,l.length-1));else if(y.key==="ArrowUp")y.preventDefault(),c(x=>Math.max(x-1,0));else if(y.key==="Enter"&&!y.nativeEvent.isComposing){y.preventDefault();const x=l[i];x&&g(x.id)}},[s,l,i,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(an,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:y=>n(y.target.value),onKeyDown:_,placeholder:p("Search tasks..."),"aria-label":p("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),l.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:p("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:l.map((y,x)=>{const a=o.find(f=>f.id===y.projectId),{icon:h,iconClass:d}=zi[y.status];return t.jsxs("button",{onClick:()=>g(y.id),onMouseEnter:()=>c(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
11
|
+
${x===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:y.title,children:y.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},y.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:p("No matching tasks")})]})]}):null}function df(e){const s={[ge.Review]:[],[ge.Running]:[],[ge.Pending]:[],[ge.Done]:[],[ge.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const uf=[{status:ge.Review,title:"Review",defaultOpen:!0},{status:ge.Running,title:"Running",defaultOpen:!0},{status:ge.Pending,title:"Pending",defaultOpen:!1},{status:ge.Done,title:"Done",defaultOpen:!1},{status:ge.Cancelled,title:"Cancelled",defaultOpen:!1}];function lo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:m,setFilterProjectId:p,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:c,activeTaskIds:u,onTaskStatusChange:l,onDeleteTask:g}){const{t:_}=le(),y=Ja(),[x,a]=w.useState(null),[h,d]=w.useState(null),[f,b]=w.useState(!1),S=Mu(Au(mn,{activationConstraint:{distance:8}})),k=w.useCallback(D=>{const B=D.active.data.current?.task,L=D.active.data.current?.fromStatus;B&&a(B),L&&d(L)},[]),E=w.useCallback(D=>{a(null),d(null);const{active:B,over:L}=D;if(!L)return;const F=B.data.current?.task,z=B.data.current?.fromStatus,A=L.data.current?.status;!F||!z||!A||F.projectArchivedAt||z!==A&&l?.(F.id,A)},[l]),C=m?e.filter(D=>D.projectId===m):e,M=!!!(m?s.find(D=>D.id===m)??null:null)?.archivedAt,T=df(C);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:_("New Project"),children:[t.jsx(ed,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!M,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
12
|
+
${c?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:_(M?"New Task":"Deleted projects are read-only"),children:[t.jsx(du,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Task")})]}),t.jsxs("button",{onClick:()=>b(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:_("Search"),children:[t.jsx(an,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("Search")})]})]}),C.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(ws,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:_("No tasks")}),M&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:_("New Task")}):null]}):t.jsxs(Rh,{sensors:S,onDragStart:k,onDragEnd:E,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:uf.map(({status:D,title:B,defaultOpen:L})=>t.jsx(of,{title:B,tasks:T[D],status:D,defaultOpen:L,selectedTaskId:r,onSelectTask:o,projects:s,activeTaskIds:u,isDragging:x!==null,dragFromStatus:h,onTaskStatusChange:l,onDeleteTask:g,disableDrag:y},D))}),t.jsx(Vh,{dropAnimation:null,children:x?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:x.title,children:x.title})}):null})]}),C.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:_("{count} tasks",{count:C.length})}),m?t.jsx("button",{onClick:()=>p(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:_("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:_("{count} tasks",{count:0})})}),t.jsx(cf,{isOpen:f,onClose:()=>b(!1),tasks:C,projects:s,onSelectTask:o})]})}const hf={damping:.7,stiffness:.05,mass:1.25},ff=70,mf=1e3/60,pf=350;let Xr=!1;globalThis.document?.addEventListener("mousedown",()=>{Xr=!0});globalThis.document?.addEventListener("mouseup",()=>{Xr=!1});globalThis.document?.addEventListener("click",()=>{Xr=!1});const bn=(e={})=>{const[s,r]=w.useState(!1),[o,m]=w.useState(e.initial!==!1),[p,v]=w.useState(!1),n=w.useRef(null);n.current=e;const i=w.useCallback(()=>{if(!Xr)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const f=d.getRangeAt(0);return f.commonAncestorContainer.contains(a.current)||a.current?.contains(f.commonAncestorContainer)},[]),c=w.useCallback(d=>{l.isAtBottom=d,m(d)},[]),u=w.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=w.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(f){a.current&&(a.current.scrollTop=f,l.ignoreScrollToTop=a.current.scrollTop)},get targetScrollTop(){return!a.current||!h.current?0:a.current.scrollHeight-1-a.current.clientHeight},get calculatedTargetScrollTop(){if(!a.current||!h.current)return 0;const{targetScrollTop:f}=this;if(!e.targetScrollTop)return f;if(d?.targetScrollTop===f)return d.calculatedScrollTop;const b=Math.max(Math.min(e.targetScrollTop(f,{scrollElement:a.current,contentElement:h.current}),f),0);return d={targetScrollTop:f,calculatedScrollTop:b},requestAnimationFrame(()=>{d=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ff}}},[]),g=w.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const f=Date.now()+(Number(d.wait)||0),b=gi(n.current,d.animation),{ignoreEscapes:S=!1}=d;let k,E=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=f+(d.duration??0);const C=async()=>{const j=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:N}=l,M=performance.now(),T=(M-(l.lastTick??M))/mf;if(l.animation||(l.animation={behavior:b,promise:j,ignoreEscapes:S}),l.animation.behavior===b&&(l.lastTick=M),i()||f>Date.now())return C();if(N<Math.min(E,l.calculatedTargetScrollTop)){if(l.animation?.behavior===b){if(b==="instant")return l.scrollTop=l.calculatedTargetScrollTop,C();l.velocity=(b.damping*l.velocity+b.stiffness*l.scrollDifference)/b.mass,l.accumulated+=l.velocity*T,l.scrollTop+=l.accumulated,l.scrollTop!==N&&(l.accumulated=0)}return C()}return k>Date.now()?(E=l.calculatedTargetScrollTop,C()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:gi(n.current,n.current.resize),ignoreEscapes:S,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return j.then(N=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),N))};return d.wait!==!0&&(l.animation=void 0),l.animation?.behavior===b?l.animation.promise:C()},[c,i,l]),_=w.useCallback(()=>{u(!0),c(!1)},[u,c]),y=w.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:f,ignoreScrollToTop:b}=l;let{lastScrollTop:S=f}=l;l.lastScrollTop=f,l.ignoreScrollToTop=void 0,b&&b>f&&(S=b),v(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||f===b)return;if(i()){u(!0),c(!1);return}const k=f>S,E=f<S;if(l.animation?.ignoreEscapes){l.scrollTop=S;return}E&&(u(!0),c(!1)),k&&u(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[u,c,i,l]),x=w.useCallback(({target:d,deltaY:f})=>{let b=d;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===a.current&&f<0&&a.current.scrollHeight>a.current.clientHeight&&!l.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,l]),a=co(d=>{a.current?.removeEventListener("scroll",y),a.current?.removeEventListener("wheel",x),d?.addEventListener("scroll",y,{passive:!0}),d?.addEventListener("wheel",x,{passive:!0})},[]),h=co(d=>{if(l.resizeObserver?.disconnect(),!d)return;let f;l.resizeObserver=new ResizeObserver(([b])=>{const{height:S}=b.contentRect,k=S-(f??S);if(l.resizeDifference=k,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),v(l.isNearBottom),k>=0){const E=gi(n.current,f?n.current.resize:n.current.initial);g({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:pf})}else l.isNearBottom&&(u(!1),c(!0));f=S,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===k&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:h,scrollRef:a,scrollToBottom:g,stopScroll:_,isAtBottom:o||p,isNearBottom:p,escapedFromLock:s,state:l}};function co(e,s){const r=w.useCallback(o=>(r.current=o,e(o)),s);return r}const pi=new Map;function gi(...e){const s={...hf};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,s.damping=m.damping??s.damping,s.stiffness=m.stiffness??s.stiffness,s.mass=m.mass??s.mass)}const o=JSON.stringify(s);return pi.has(o)||pi.set(o,Object.freeze(s)),r?"instant":pi.get(o)}function gf({content:e,children:s,className:r="",side:o="top"}){const m=o==="bottom"?"top-full mt-2":"bottom-full mb-2",p=o==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return t.jsxs("div",{className:`group/tooltip relative ${r}`,children:[s,t.jsxs("div",{className:`absolute ${m} left-1/2 -translate-x-1/2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-[100] shadow-lg`,children:[e,t.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function dr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function vf(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function yn({usage:e,tooltipSide:s="top"}){const{t:r}=le();if(!e)return null;const o=e.modelContextWindow,m=o?e.totalTokens/o:0,p=o?Math.min(Math.round(m*100),100):null,v=o?vf(m):"text-neutral-400",n=o?t.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:dr(e.totalTokens),max:dr(o)})}):t.jsx("span",{children:r("已使用: {used} tokens",{used:dr(e.totalTokens)})});return t.jsx(gf,{content:n,side:s,children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[t.jsx(Pd,{size:14,className:v}),t.jsxs("span",{className:`tabular-nums ${v}`,children:[dr(e.totalTokens),p!==null&&t.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const xf="/api";async function _f(e){const s=new FormData;s.append("file",e);const r=await fetch(`${xf}/attachments/upload`,{method:"POST",body:s});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error||`Upload failed (${r.status})`)}return r.json()}let bf=0;function Yr(){const[e,s]=w.useState([]),r=w.useRef(e);r.current=e;const o=w.useCallback(async l=>{const g=l.map(_=>({tempId:`tmp-${++bf}`,file:_,progress:0,status:"uploading"}));s(_=>[..._,...g]),await Promise.allSettled(g.map(async _=>{try{const y=await _f(_.file);s(x=>x.map(a=>a.tempId===_.tempId?{...a,status:"done",progress:100,attachment:y}:a))}catch(y){s(x=>x.map(a=>a.tempId===_.tempId?{...a,status:"error",error:y instanceof Error?y.message:"Upload failed"}:a))}}))},[]),m=w.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),p=w.useCallback(l=>{s(g=>g.filter(_=>_.tempId!==l))},[]),v=w.useCallback(()=>{s([])},[]),n=w.useCallback(l=>{l.length!==0&&s(g=>{const _=new Set(g.map(x=>x.attachment?.id??x.tempId)),y=l.filter(x=>{const a=x.attachment?.id??x.tempId;return _.has(a)?!1:(_.add(a),!0)});return y.length>0?[...g,...y]:g})},[]),i=w.useCallback(()=>{const l=m();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
|
|
13
|
+
`)},[m]),c=e.length>0,u=e.some(l=>l.status==="uploading");return{files:e,addFiles:o,removeFile:p,clear:v,restoreFiles:n,buildMarkdownLinks:i,getDoneAttachments:m,hasFiles:c,isUploading:u}}function yf(e){const s=w.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return wt({queryKey:["attachments","metadata",s],queryFn:()=>ve.get("/attachments/metadata",{params:{ids:s.join(",")}}),enabled:s.length>0,staleTime:300*1e3})}const Sf="/api";function wf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Vr({files:e,onRemove:s}){return e.length===0?null:t.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>t.jsx(Cf,{item:r,onRemove:s},r.tempId))})}function Cf({item:e,onRemove:s}){const r=e.file.type.startsWith("image/"),o=e.status==="error",m=e.status==="uploading";return t.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${o?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[r&&e.status==="done"&&e.attachment?t.jsx("img",{src:`${Sf}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):t.jsx("span",{className:"flex-shrink-0",children:m?t.jsx(Be,{size:16,className:"animate-spin text-neutral-400"}):r?t.jsx(on,{size:16,className:"text-neutral-400"}):t.jsx(rn,{size:16,className:"text-neutral-400"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate font-medium",children:e.file.name}),o?t.jsx("div",{className:"truncate text-red-500",children:e.error}):t.jsx("div",{className:"text-neutral-400",children:wf(e.file.size)})]}),t.jsx("button",{onClick:()=>s(e.tempId),className:"absolute -top-1.5 -right-1.5 hidden group-hover:flex items-center justify-center w-5 h-5 rounded-full bg-neutral-700 text-white hover:bg-neutral-900 transition-colors",children:t.jsx(Bt,{size:10})})]})}const kf=10,Ef=24,sl=kf*Ef,jf=8;function Nf(e,s=sl){return e>s+jf}function Rf(e,s){return e.includes(s)?e:[...e,s]}function Tf(e,s){return e.filter(r=>r!==s)}function Af(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const Gr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function uo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Mf(e,s=[],r=[]){const o=new Set(r.filter(p=>Gr.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...s.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!o.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,v)=>{const n=uo(p.sortTime)-uo(v.sortTime);return n!==0?n:p.order!==v.order?p.order-v.order:p.key.localeCompare(v.key)})}function Df(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function Lf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Pf(e,s){const r=e.reduce((m,p)=>(m[p.status]=(m[p.status]??0)+1,m),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([m,p])=>{const v=r[m];return v?`${v} ${s(p)}`:null}).filter(m=>!!m).join(" · ")}function Of(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function If({status:e}){const{t:s}=le();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(Df(e))})}function Bf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:m,isStopPending:p,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:c}=le(),[u,l]=w.useState(Of),g=w.useMemo(()=>e.filter(y=>Gr.has(y.status)).sort((y,x)=>Date.parse(x.updatedAt??x.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const _=Pf(g,c);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>l(y=>!y),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:c("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:_})]}),u?t.jsx(ct,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(ja,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(y=>{const x=s.get(y.memberId),a=r.get(y.workRequestId),h=!!(y.sessionId&&o),d=!!x,f=n===y.id,b=p&&v===y.memberId,S=a?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:S,className:Z("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>y.sessionId&&o?.(y.sessionId),onKeyDown:k=>{!h||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(y.sessionId))},children:[t.jsx(Tt,{name:x?.name??c("Agent"),avatar:x?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:x?.name??c("Agent")}),t.jsx("span",{className:Z("shrink-0",Lf(y.status)),children:t.jsx(If,{status:y.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&o?.(y.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:c("View log"),"aria-label":`${c("View log")} ${x?.name??c("Agent")}`,children:t.jsx(Sr,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:c("Stop"),"aria-label":`${c("Stop")} ${x?.name??c("Agent")}`,children:t.jsx(Ss,{size:12})})]}),d&&f&&x&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:c("Stop running work?")}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>m(x.id,!1),children:[t.jsx(Ss,{size:11}),t.jsx("span",{children:c(b?"Stopping":"Stop only")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>m(x.id,!0),children:[t.jsx(Na,{size:11}),t.jsx("span",{children:c(b?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Tr="/api",Ff=240;let ho=0;function zf(e,s){return ho+=1,{id:`pending-room-message-${Date.now()}-${ho}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Hf(e){return"pendingStatus"in e}const Wf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Tr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function $f(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Uf(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function qf(e,s){if(s.length===0)return e;const r=new Set(s.map(Uf));return e.split(`
|
|
14
|
+
`).map(o=>{const m=o.match(/^\s*/)?.[0]??"",p=o.trimStart();for(const v of r){if(p===v)return null;if(p.startsWith(`${v} `)||p.startsWith(`${v} `))return`${m}${p.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
|
+
`).replace(/\n{3,}/g,`
|
|
16
|
+
|
|
17
|
+
`).trim()}function Kf(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function fo(e,s){return e instanceof Error?e.message:s}function Xf(e,s=Ff){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Yf(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function Vf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(r)):!0}function mo(e){return e.membershipStatus!=="REMOVED"}function Gf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Qf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Zf(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const m=r.map(v=>Gf(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(m.length===0)return o;const p=m.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${p}`:p}function Jf(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function em({content:e,isUser:s}){return t.jsx("div",{className:Z("prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(Qi,{urlTransform:Wf,components:Zi,children:e})})}function tm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const m=s.filter(v=>v.mimeType.startsWith("image/")),p=new Map(m.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${Tr}${v.url}`;if(v.mimeType.startsWith("image/")){const c=p.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(m,c),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(rn,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:$f(v.sizeBytes)})]}),t.jsx(sn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function sm({content:e,attachmentIds:s,isUser:r,tone:o,onOpenImage:m}){const p=w.useMemo(()=>Array.from(new Set(s??[])),[s]),{data:v=[],isLoading:n}=yf(p),i=v.length>0?qf(e,v):e;return t.jsxs(t.Fragment,{children:[i.trim()&&t.jsx(nm,{content:i,isUser:r,tone:o}),t.jsx(tm,{hasAttachmentIds:p.length>0,attachments:v,isLoading:n,onOpenImage:m})]})}function rm({images:e,index:s,onClose:r,onSelect:o}){const m=e[s];if(!m)return null;const p=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Bt,{size:20})}),p&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(bd,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${Tr}${m.url}`,alt:m.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:m.originalName}),t.jsxs("a",{href:`${Tr}${m.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(sn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Mt,{size:24,"aria-hidden":!0})})]})}function im({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const p=[e.trim(),s].filter(Boolean).join(`
|
|
18
|
+
|
|
19
|
+
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function nm({content:e,isUser:s,tone:r=s?"user":"agent"}){const{t:o}=le(),m=w.useId(),p=w.useRef(null),[v,n]=w.useState(null),[i,c]=w.useState(!1),u=v?.content===e&&v.expanded,l=w.useCallback(()=>{const _=p.current;_&&c(Nf(_.scrollHeight))},[]);w.useLayoutEffect(()=>{l();const _=p.current;if(!_)return;const y=window.requestAnimationFrame(l),x=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return x?.observe(_),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(y),x?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=i&&!u;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:m,ref:p,onLoadCapture:l,className:Z("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:sl}:void 0,children:[t.jsx(em,{content:e,isUser:s}),g&&t.jsx("div",{className:Z("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",r==="system"?"to-amber-50":r==="user"?"to-neutral-900":"to-neutral-100")})]}),i&&t.jsxs("button",{type:"button","aria-expanded":u,"aria-controls":m,"aria-label":o(u?"Collapse message":"Expand full message"),onClick:()=>n({content:e,expanded:!u}),className:Z("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",r==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":r==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900"),children:[u?t.jsx(ja,{size:13}):t.jsx(ct,{size:13}),t.jsx("span",{children:o(u?"Collapse message":"Expand full message")})]})]})}function rl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:m,children:p,headerAddon:v,bubbleClassName:n,isPending:i}){return m?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:p})}):t.jsxs("div",{className:Z("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Tt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Z("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:Z("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(xs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Kf(r)}),v]}),t.jsx("div",{className:Z("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:p})]}),o&&t.jsx(Tt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function om({message:e,senderName:s,senderMember:r,memberById:o,displayContent:m,onOpenImage:p}){const{t:v}=le(),n=e.senderType==="user",i=e.senderType==="system",c=Hf(e)?e.pendingStatus:null,u=e.mentions??[],l=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",_=g?Qf(e,o):[],y=t.jsxs(t.Fragment,{children:[g&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:_.join(", "),children:[t.jsx($d,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),_.length>0?`: ${_.join(", ")}`:""]})]}),!i&&l>0&&u.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",l]}),c==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),c==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(rl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:n,isSystem:i,headerAddon:y,bubbleClassName:n&&c==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:c==="sending",children:t.jsx(sm,{content:m,attachmentIds:e.attachmentIds,isUser:n&&c!=="failed",tone:i?"system":void 0,onOpenImage:p})})}function am({request:e,member:s,onApprove:r,onReject:o,isActionPending:m,isApprovePending:p,isRejectPending:v}){const{t:n}=le();return t.jsx(rl,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(xs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Xf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:m,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(vt,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:o,children:[t.jsx(Bt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function il({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:m,onViewInvocationSession:p,compactComposer:v,centered:n}){const{t:i}=le(),c=ca(e.id),u=da(e.id),l=ua(e.id),[g,_]=w.useState(""),[y,x]=w.useState(!1),[a,h]=w.useState(null),[d,f]=w.useState(0),[b,S]=w.useState([]),[k,E]=w.useState(!1),[C,j]=w.useState(null),[N,M]=w.useState([]),[T,D]=w.useState(null),B=w.useRef(null),L=w.useRef(null),{files:F,addFiles:z,removeFile:A,clear:P,restoreFiles:O,buildMarkdownLinks:I,getDoneAttachments:U,isUploading:X}=Yr(),$=F.some(Y=>Y.status==="done"&&Y.attachment),[V,q]=w.useState(null),{scrollRef:R,contentRef:H,isAtBottom:K,scrollToBottom:W}=bn({resize:"smooth",initial:"instant"}),Q=w.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),J=w.useMemo(()=>(e.members??[]).filter(mo),[e.members]),oe=w.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),fe=w.useMemo(()=>{const Y=new Set(s.map(he=>he.id)),ie=N.filter(he=>!Y.has(he.id));return[...s,...ie].sort((he,_e)=>{const Ie=Date.parse(he.createdAt??""),He=Date.parse(_e.createdAt??"");return(Number.isNaN(Ie)?0:Ie)-(Number.isNaN(He)?0:He)})},[s,N]),Ne=w.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),je=w.useMemo(()=>Mf(fe,e.workRequests??[],e.invocations??[]),[fe,e.invocations,e.workRequests]),se=w.useMemo(()=>(e.invocations??[]).filter(Y=>Gr.has(Y.status)),[e.invocations]),Oe=w.useMemo(()=>b.map(Y=>Q.get(Y)).filter(Y=>!!Y).filter(mo),[Q,b]),Me=w.useMemo(()=>{const Y=a?.query??"";return J.filter(ie=>Vf(ie,Y)).sort((ie,he)=>{const _e=b.includes(ie.id),Ie=b.includes(he.id);return _e!==Ie?_e?1:-1:ie.name.localeCompare(he.name)})},[J,a?.query,b]),Fe=!r&&(y||!!a)&&Me.length>0,ze=w.useCallback((Y,ie)=>{if(ie==null){h(null);return}h(Yf(Y,ie)),f(0)},[]),Qe=w.useCallback(Y=>{S(He=>Rf(He,Y.id));const ie=`@${Y.name} `;if(a){const He=`${g.slice(0,a.start)}${ie}${g.slice(a.end)}`,Ve=a.start+ie.length;_(He),h(null),x(!1),requestAnimationFrame(()=>{B.current?.focus(),B.current?.setSelectionRange(Ve,Ve)});return}const he=g.length===0||/\s$/.test(g)?"":" ",_e=`${g}${he}${ie}`,Ie=_e.length;_(_e),x(!1),requestAnimationFrame(()=>{B.current?.focus(),B.current?.setSelectionRange(Ie,Ie)})},[g,a]),Te=w.useCallback(Y=>{S(ie=>Tf(ie,Y))},[]),ee=w.useCallback(Y=>{const ie=Y.target.value;_(ie),j(null);const he=Y.target;he.style.height="auto",he.style.height=`${Math.max(v?40:72,Math.min(he.scrollHeight,v?140:240))}px`,x(!1),ze(ie,he.selectionStart)},[v,ze]),xe=w.useCallback(Y=>{const ie=Y.target.files;ie&&ie.length>0&&(z(Array.from(ie)),j(null)),Y.target.value=""},[z]),Re=w.useCallback(Y=>{const ie=[];for(const he of Y.clipboardData.items)if(he.kind==="file"){const _e=he.getAsFile();_e&&ie.push(_e)}ie.length>0&&(Y.preventDefault(),z(ie),j(null))},[z]),G=w.useCallback(async()=>{if(r||k||X)return;const Y=I(),ie=U().map(De=>De.id),he=Af(b,J),_e=im({draft:g,attachmentMarkdown:Y,attachmentIds:ie,mentions:he});if(!_e||!g.trim()&&!$)return;const Ie=zf(e.id,_e),He=g,Ve=b,$e=F;M(De=>[...De,Ie]),_(""),S([]),x(!1),h(null),P(),B.current&&(B.current.style.height=v?"40px":"72px"),requestAnimationFrame(()=>W()),E(!0),j(null);try{const De=await m(_e);M(rt=>rt.filter(we=>we.id!==Ie.id)),De&&typeof De=="object"&&"id"in De&&requestAnimationFrame(()=>W())}catch(De){const rt=De instanceof Error?De.message:"Failed to send room message";M(we=>we.map(ke=>ke.id===Ie.id?{...ke,pendingStatus:"failed",error:rt}:ke)),_(we=>we.length===0?He:we),S(we=>we.length===0?Ve:we),O($e),j(rt),requestAnimationFrame(()=>W())}finally{E(!1)}},[J,F,I,P,v,g,U,$,k,X,m,r,O,W,b,e.id]),ne=w.useCallback(Y=>{const ie=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(Fe){if(Y.key==="ArrowDown"){Y.preventDefault(),f(he=>(he+1)%Me.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),f(he=>(he-1+Me.length)%Me.length);return}if(Y.key==="Enter"&&!ie||Y.key==="Tab"){Y.preventDefault();const he=Me[d]??Me[0];he&&Qe(he);return}if(Y.key==="Escape"){Y.preventDefault(),h(null),x(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!ie&&(Y.preventDefault(),G())},[Qe,G,d,Me,Fe]);w.useEffect(()=>{_(""),S([]),x(!1),h(null),j(null),M([]),P(),D(null),B.current&&(B.current.style.height=v?"40px":"72px")},[P,v,e.id]);const ue=c.isError?c.error:u.isError?u.error:null,ye=c.isPending||u.isPending,Se=w.useCallback((Y,ie)=>{l.mutate({memberId:Y,cancelQueued:ie},{onSuccess:()=>D(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[V&&t.jsx(rm,{images:V.images,index:V.index,onClose:()=>q(null),onSelect:Y=>q(ie=>ie&&{...ie,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:Z("h-full overflow-y-auto scrollbar-app-thin bg-white",v?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:H,className:Z(v?"space-y-2.5":"space-y-3",n&&"max-w-5xl mx-auto"),children:[je.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(ds,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:i("No room messages yet")})]}):je.map(Y=>{if(Y.kind==="pendingApproval"){const He=Y.request,Ve=Q.get(He.targetMemberId),$e=c.isPending&&c.variables===He.id,De=u.isPending&&u.variables===He.id;return t.jsx(am,{request:He,member:Ve,onApprove:()=>c.mutate(He.id),onReject:()=>u.mutate(He.id),isActionPending:ye,isApprovePending:$e,isRejectPending:De},Y.key)}const ie=Y.message,he=Jf(ie,Q,oe),_e=ie.senderType==="user"?i("你"):ie.senderType==="system"?i("System"):he?.name??i("Agent"),Ie=Zf(ie,Q);return t.jsx(om,{message:ie,senderName:_e,senderMember:he,memberById:Q,displayContent:Ie,onOpenImage:(He,Ve)=>q({images:He,index:Ve})},Y.key)}),ue&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:fo(ue,i("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:fo(l.error,i("Failed to stop member work"))})]})}),!K&&t.jsxs("button",{type:"button",onClick:()=>W(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx($s,{size:14}),t.jsx("span",{children:i("Back to bottom")})]})]}),t.jsx("div",{className:Z("shrink-0 border-t border-transparent bg-white",v?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Z(n&&"max-w-5xl mx-auto"),children:[t.jsx(Bf,{invocations:se,memberById:Q,workRequestById:Ne,onViewInvocationSession:p,onStopMember:Se,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:T,onToggleStopConfirm:Y=>D(ie=>ie===Y?null:Y)}),r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??i("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Fe&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:i(a?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Me.map((Y,ie)=>{const he=b.includes(Y.id),_e=ie===d;return t.jsxs("button",{type:"button",onMouseEnter:()=>f(ie),onMouseDown:Ie=>{Ie.preventDefault(),Qe(Y)},className:Z("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",_e?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Tt,{name:Y.name,avatar:Y.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:Y.name}),he&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(qn,{size:15,className:"text-neutral-400"})]},Y.id)})})]}),Oe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Oe.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Te(Y.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:i("Remove mention"),"aria-label":`${i("Remove mention")} ${Y.name}`,children:t.jsx(Bt,{size:12})})]},Y.id))}),t.jsx(Vr,{files:F,onRemove:A}),t.jsx("textarea",{ref:B,value:g,rows:v?1:void 0,onChange:ee,onKeyDown:ne,onPaste:Re,onClick:Y=>ze(g,Y.currentTarget.selectionStart),onSelect:Y=>ze(g,Y.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:Z("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",v?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:v?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Z("flex items-center justify-between",v?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:L,type:"file",multiple:!0,className:"hidden",onChange:xe}),t.jsx("button",{type:"button",onClick:()=>L.current?.click(),title:i("Upload file"),"aria-label":i("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Ir,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{x(Y=>!Y),h(null),requestAnimationFrame(()=>B.current?.focus())},disabled:Oe.length===0&&J.length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:Z("rounded-lg transition-colors",v?"p-1.5":"p-2",y?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Oe.length===0&&J.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(qn,{size:v?15:18})}),Oe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Oe.length," ",i("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{G()},disabled:r||k||X||!g.trim()&&!$,title:i(X?"Uploading...":k?"发送中...":"发送"),"aria-label":i(X?"Uploading...":k?"发送中...":"发送"),className:Z("rounded-lg transition-all duration-200",v?"p-1.5":"p-2",(g.trim()||$)&&!r&&!k&&!X?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",k||X?"opacity-70":""),children:t.jsx(Fr,{size:v?15:18})})]}),C&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:C})]})]})})]})}function lm(e){return e?e.slice(0,8):""}function po(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Sn(e){return e?.workspaceKind===nt.MAIN_DIRECTORY}function us(e){return e?Sn(e)?"Project directory":e.branchName:"—"}function Jt(e){return e?.workingDir||e?.worktreePath||void 0}function wn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),m=s?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(m&&p.id===m),c=i?"main":p.parentWorkspaceId?"child":"root",u=n?.name??(p.ownerMemberId?`Member ${lm(p.ownerMemberId)}`:void 0),l=Sn(p)?"Project directory":i?"Main workspace":c==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:c,roleLabel:i?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:u,parentBranchName:v?us(v):void 0,isMain:i}}).sort((p,v)=>{const n=c=>c.kind==="main"?0:c.kind==="child"?1:2,i=n(p)-n(v);return i!==0?i:po(p.workspace.createdAt)-po(v.workspace.createdAt)})}function nl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Nt.ACTIVE)?.id??e[0]?.id}function ol(e,s){return!e||e.status!==Nt.ACTIVE||Sn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function al(e,s,r){return e?.parentWorkspaceId?s?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Cn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},cm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],ll=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],dm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],cl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],um=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Ds(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Cn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ps(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Cn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function vi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Cn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function hm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function fm(e){return{name:e.name.trim(),aliases:hm(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function go(e,s){return e instanceof Error?e.message:s}function vo(e){return e.membershipStatus!=="REMOVED"}function Hi(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function xo(e){return Hi(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function _o(e){return ll.find(s=>s.value===e)?.label??e}function mm(e){return cl.find(s=>s.value===e)?.label??e}function Pt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function bo({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function pm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=le(),{data:m=[]}=ha(),{data:p=[]}=Es(),v=qc(r.id),n=Kc(r.id),i=Xc(r.id),c=w.useRef(!1),[u,l]=w.useState("edit"),[g,_]=w.useState(null),[y,x]=w.useState(""),[a,h]=w.useState(Ds()),[d,f]=w.useState(null),[b,S]=w.useState(null),k=r.members??[],E=w.useMemo(()=>k.filter(vo),[k]),C=w.useMemo(()=>b&&vo(b)&&!E.some(q=>q.id===b.id)?[...E,b]:E,[b,E]),j=g?E.find(q=>q.id===g)??null:null,N=b?.id===g?b:j,M=y?m.find(q=>q.id===y)??null:null,T=v.isPending||n.isPending||i.isPending,D=C.filter(Hi).length,B=w.useMemo(()=>{const q=p.map(({provider:R,availability:H})=>({value:R.id,label:R.name+(H.type==="NOT_FOUND"?o(" (不可用)"):""),disabled:H.type==="NOT_FOUND"}));return a.providerId&&!q.some(R=>R.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,p,o]);w.useEffect(()=>{if(!e){c.current=!1,S(null);return}if(c.current)return;c.current=!0;const q=C[0]??null;l(q?"edit":"add-preset"),_(q?.id??null),x(""),h(q?ps(q):Ds()),f(null)},[C,e]),w.useEffect(()=>{b&&E.some(q=>q.id===b.id)&&S(null)},[b,E]),w.useEffect(()=>{u==="add-preset"&&M&&h(vi(M))},[u,M]);const L=(q,R)=>{h(H=>({...H,[q]:R}))},F=(q,R)=>{h(H=>({...H,capabilities:{...H.capabilities,[q]:R}}))},z=q=>{l("edit"),_(q.id),x(""),h(ps(q))},A=()=>{l("add-preset"),_(null);const q=M??m[0]??null;x(q?.id??""),h(q?vi(q):Ds())},P=()=>{l("add-custom"),_(null),x(""),h(Ds())},O=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),I=u==="add-preset"?!!y:u==="edit"?!!(N&&O):O,U=async()=>{try{if(u==="add-preset"){if(!y)return;const R=await v.mutateAsync({memberPresetId:y});lt.success(o("Member added")),S(R),l("edit"),_(R.id),x(""),h(ps(R));return}const q=fm(a);if(!q.name||!q.providerId||!q.rolePrompt){lt.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const R=await v.mutateAsync({member:q});lt.success(o("Member added")),S(R),l("edit"),_(R.id),h(ps(R));return}if(N){const R=await n.mutateAsync({memberId:N.id,data:q});lt.success(o("Member updated")),S(H=>H?.id===R.id?R:H),_(R.id),h(ps(R))}}catch(q){lt.error(go(q,o("Failed to save member")))}},X=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const q=C.find(R=>R.id!==d.id)??null;_(q?.id??null),l(q?"edit":"add-preset"),h(q?ps(q):Ds())}S(q=>q?.id===d.id?null:q),f(null),lt.success(o("Member removed"))}catch(q){lt.error(go(q,o("Failed to remove member")))}},$=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(cr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(Xn,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:m.length===0?t.jsx(bo,{icon:t.jsx(cr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(Wt,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:m.map(q=>{const R=y===q.id;return t.jsxs("button",{type:"button",onClick:()=>{x(q.id),h(vi(q))},className:Z("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",R?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Tt,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(_o(q.workspacePolicy))," · ",o(mm(q.sessionPolicy))]})]}),R?t.jsx(vt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),V=()=>{const q=u==="edit";return q&&!N?t.jsx("div",{className:"p-5",children:t.jsx(bo,{icon:t.jsx(ds,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Wt,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Ta,{size:15,className:"text-neutral-500"}):t.jsx(Wt,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&N?t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:()=>f(N),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Ji,{size:13}),o("Remove")]}):t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(cr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&N?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Tt,{name:N.name,avatar:N.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Z("h-2 w-2 shrink-0 rounded-full",xo(N))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:N.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[N.providerId," · ",o(_o(N.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:R=>L("name",R.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:R=>L("aliasesText",R.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Provider")}),t.jsx(as,{value:a.providerId,onChange:R=>L("providerId",R),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:R=>L("avatar",R.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Workspace policy")}),t.jsx(as,{value:a.workspacePolicy,onChange:R=>L("workspacePolicy",R),options:ll.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Trigger policy")}),t.jsx(as,{value:a.triggerPolicy,onChange:R=>L("triggerPolicy",R),options:dm.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Session policy")}),t.jsx(as,{value:a.sessionPolicy,onChange:R=>L("sessionPolicy",R),options:cl.map(R=>({value:R.value,label:o(R.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Queue policy")}),t.jsx(as,{value:a.queueManagementPolicy,onChange:R=>L("queueManagementPolicy",R),options:um.map(R=>({value:R.value,label:o(R.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Pt,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:R=>L("rolePrompt",R.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Pt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:cm.map(R=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[R.key],onChange:H=>F(R.key,H.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(R.label)})]},R.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ks,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Ae,{type:"button",onClick:U,disabled:T||!I,children:o(T?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(ds,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[C.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(Wt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:C.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:C.map(q=>{const R=u==="edit"&&g===q.id;return t.jsxs("button",{type:"button",onClick:()=>z(q),className:Z("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",R?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Tt,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Z("h-1.5 w-1.5 shrink-0 rounded-full",xo(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(eu,{size:13,className:Z("shrink-0 text-neutral-300 transition-opacity",R?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:Z("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(cr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:P,disabled:T,className:Z("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Xn,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?$():V()})]})}),t.jsx(Or,{isOpen:!!d,onClose:()=>f(null),onConfirm:X,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&Hi(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(Br,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const gm=[],vm=[],xm=[],_m=240;function bm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const yo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function xi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function So(e,s){return e instanceof Error?e.message:s}function ym(e,s=_m){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function ur(e){return e?e.instructionPreview??ym(e.instruction):""}function Sm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function wm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Cm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function km(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Em(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function jm(e){switch(e){case Nt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Nt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Nt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Nt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Nm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Rm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Tm(e,s){return s.find(r=>r.memberId===e.id&&Gr.has(r.status))}function dl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:m}){const{t:p}=le(),v=ca(e.id),n=da(e.id),i=ua(e.id),[c,u]=w.useState(null),[l,g]=w.useState(null),[_,y]=w.useState(!1),[x,a]=w.useState(!1),h=e.members??gm,d=w.useMemo(()=>h.filter(L=>L.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??vm,b=e.invocations??xm,S=w.useMemo(()=>wn(s,e),[e,s]),k=w.useMemo(()=>new Map(f.map(L=>[L.id,L])),[f]),E=w.useMemo(()=>[...f].filter(L=>L.status==="PENDING_APPROVAL").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[f]),C=w.useMemo(()=>[...f].filter(L=>L.status==="QUEUED").sort((L,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[f]),j=w.useMemo(()=>[...h].map(L=>({member:L,status:bm(L.status)})).sort((L,F)=>yo[L.status]-yo[F.status]),[h]),N=v.isError?v.error:n.isError?n.error:null,M=v.isPending||n.isPending,T=S.find(L=>L.workspace.id===r),D=e.messages??[],B=j.filter(({status:L})=>L==="running"||L==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(pm,{isOpen:x,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ws,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:p("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[t.jsx(en,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[t.jsx(ds,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:B>0?`${B}/${d.length}`:d.length}),B>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),C.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(xs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:C.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(xs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(xs,{size:13}),t.jsx("span",{children:p("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(L=>{const F=h.find(P=>P.id===L.targetMemberId),z=v.isPending&&v.variables===L.id,A=n.isPending&&n.variables===L.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Tt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:ur(L)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(km(L.requesterType))}),t.jsx("span",{children:xi(L.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(L.id),disabled:M,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(vt,{size:11}),t.jsx("span",{className:"truncate",children:p(z?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(L.id),disabled:M,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Bt,{size:11}),t.jsx("span",{className:"truncate",children:p(A?"Rejecting":"Reject")})]})]})]},L.id)})}),N&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:So(N,p("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(ds,{size:13}),t.jsx("span",{children:p("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(Ta,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:L,status:F})=>{const z=Tm(L,b),A=Rm(b.filter(V=>V.memberId===L.id)),P=z?k.get(z.workRequestId):void 0,O=l===L.id,I=F==="running"||F==="waiting room reply",U=I&&!!z,X=c===L.id,$=i.isPending&&i.variables?.memberId===L.id;return t.jsxs("div",{className:Z("bg-white",O&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Tt,{name:L.name,avatar:L.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Z("h-1.5 w-1.5 shrink-0 rounded-full",Cm(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:L.name}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",wm(F)),children:p(Sm(F))})]}),I&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:ur(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>u(X?null:L.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:p("Stop"),"aria-label":p("Stop"),children:t.jsx(Ss,{size:12})}),z?.sessionId&&m&&t.jsx("button",{type:"button",onClick:()=>m(z.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(Sr,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(O?null:L.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":O,children:O?t.jsx(ct,{size:13}):t.jsx(Mt,{size:13})})]})]}),U&&X&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ss,{size:10}),t.jsx("span",{children:$&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:L.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Na,{size:10}),t.jsx("span",{children:$&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),O&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:L.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(V=>{const q=k.get(V.workRequestId),R=!!(V.sessionId&&m);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Z("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Em(V.status)),children:V.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:xi(V.updatedAt??V.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:ur(q)||V.workRequestId})]}),R&&t.jsxs("button",{type:"button",onClick:()=>V.sessionId&&m?.(V.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:p("View log"),"aria-label":p("View log"),children:[t.jsx(Sr,{size:10}),t.jsx("span",{children:p("Log")})]})]})},V.id)})})]}),j[j.length-1]?.member.id!==L.id&&!O&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},L.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:So(i.error,p("Failed to stop member work"))})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(xs,{size:13}),t.jsx("span",{children:p("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length})]}),t.jsx("div",{className:"space-y-1",children:C.map(L=>{const F=h.find(z=>z.id===L.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Tt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??L.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:ur(L)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:xi(L.createdAt)})]})},L.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(L=>!L),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":_,"aria-label":p("Workspaces"),children:[t.jsx(ws,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:us(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:S.length}),_?t.jsx(ct,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),_&&t.jsx("div",{className:"space-y-1.5",children:S.map(L=>{const F=r===L.workspace.id;return t.jsx("div",{className:Z("rounded-md border bg-white px-3 py-2",F?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(L.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Nm(L.roleLabel)),children:p(L.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",jm(L.workspace.status)),children:L.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:us(L.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[L.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",L.ownerName]}),L.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",L.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(L.workspace.id),disabled:!o||F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:p("View workspace"),children:[F?t.jsx(vt,{size:11}):t.jsx(nn,{size:11}),t.jsx("span",{children:p(F?"Selected":"Select")})]})]})},L.workspace.id)})})]}),E.length===0&&C.length===0&&j.every(({status:L})=>L==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var _i={exports:{}},wo;function Am(){return wo||(wo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var c=this&&this.__decorate||function(f,b,S,k){var E,C=arguments.length,j=C<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,S,k);else for(var N=f.length-1;N>=0;N--)(E=f[N])&&(j=(C<3?E(j):C>3?E(b,S,j):E(b,S))||j);return C>3&&j&&Object.defineProperty(b,S,j),j},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const l=i(9042),g=i(6114),_=i(9924),y=i(844),x=i(5596),a=i(4725),h=i(3656);let d=n.AccessibilityManager=class extends y.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
+
`)))),this.register(this._terminal.onA11yTab((S=>this._handleTab(S)))),this.register(this._terminal.onKey((S=>this._handleKey(S.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new x.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let b=0;b<f;b++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
21
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=f;E<=b;E++){const C=S.translateBufferLineToString(S.ydisp+E,!0),j=(S.ydisp+E+1).toString(),N=this._rowElements[E];N&&(C.length===0?N.innerText=" ":N.textContent=C,N.setAttribute("aria-posinset",j),N.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const S=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,C;if(b===0?(E=S,C=this._rowElements.pop(),this._rowContainer.removeChild(C)):(E=this._rowElements.shift(),C=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),C.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=d=c([u(1,a.IRenderService)],d)},3614:(v,n)=>{function i(g){return g.replace(/\r?\n/g,"\r")}function c(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function u(g,_,y,x){g=c(g=i(g),y.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),_.value=""}function l(g,_,y){const x=y.getBoundingClientRect(),a=g.clientX-x.left-10,h=g.clientY-x.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${a}px`,_.style.top=`${h}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=c,n.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},n.handlePasteEvent=function(g,_,y,x){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),_,y,x)},n.paste=u,n.moveTextAreaUnderMouseCursor=l,n.rightClickHandler=function(g,_,y,x,a){l(g,_,y),a&&x.rightClickSelect(g),_.value=x.selectionText,_.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const c=i(1505);n.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(u,l,g){this._css.set(u,l,g)}getCss(u,l){return this._css.get(u,l)}setColor(u,l,g){this._color.set(u,l,g)}getColor(u,l){return this._color.get(u,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,c,u,l){i.addEventListener(c,u,l);let g=!1;return{dispose:()=>{g||(g=!0,i.removeEventListener(c,u,l))}}}},6465:function(v,n,i){var c=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const l=i(3656),g=i(8460),_=i(844),y=i(2585);let x=n.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,d){this._element=a,this._mouseService=h,this._renderService=d,this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=a.composedPath();for(let f=0;f<d.length;f++){const b=d[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[S,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(S)&&(b=this._checkLinkProviderResult(S,a,b)):k.provideLinks(a.y,(E=>{var C,j;if(this._isMouseOut)return;const N=E?.map((M=>({link:M})));(C=this._activeProviderReplies)===null||C===void 0||C.set(S,N),b=this._checkLinkProviderResult(S,a,b),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let S=0;S<b.length;S++){const k=b[S],E=k.link.range.start.y<a?0:k.link.range.start.x,C=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=C;j++){if(d.has(j)){b.splice(S--,1);break}d.add(j)}}}}_checkLinkProviderResult(a,h,d){var f;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let S=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&b){const k=b.find((E=>this._linkAtPosition(E.link,h)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((C=>this._linkAtPosition(C.link,h)));if(E){d=!0,this._handleNewLink(E);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,b;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,b,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&((S=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||S===void 0?void 0:S.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(a,h){const d=a.range,f=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(a,h){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=f}_positionFromMouseEvent(a,h,d){const f=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,f,b){return{x1:a,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:b}}};n.Linkifier2=x=c([u(0,y.IBufferService)],x)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var c=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const l=i(511),g=i(2585);let _=n.OscLinkProvider=class{constructor(x,a,h){this._bufferService=x,this._optionsService=a,this._oscLinkService=h}provideLinks(x,a){var h;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,S=new l.CellData,k=d.getTrimmedLength();let E=-1,C=-1,j=!1;for(let N=0;N<k;N++)if(C!==-1||d.hasContent(N)){if(d.loadCell(N,S),S.hasExtendedAttrs()&&S.extended.urlId){if(C===-1){C=N,E=S.extended.urlId;continue}j=S.extended.urlId!==E}else C!==-1&&(j=!0);if(j||C!==-1&&N===k-1){const M=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(M){const T={start:{x:C+1,y:x},end:{x:N+(j||N!==k-1?0:1),y:x}};let D=!1;if(!b?.allowNonHttpProtocols)try{const B=new URL(M);["http:","https:"].includes(B.protocol)||(D=!0)}catch{D=!0}D||f.push({text:M,range:T,activate:(B,L)=>b?b.activate(B,L,T):y(0,L),hover:(B,L)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,B,L,T)},leave:(B,L)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.call(b,B,L,T)}})}j=!1,S.hasExtendedAttrs()&&S.extended.urlId?(C=N,E=S.extended.urlId):(C=-1,E=-1)}}a(f)}};function y(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
|
+
|
|
23
|
+
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=_=c([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],_)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,c){this._parentWindow=i,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,c,u){this._rowCount=u,i=i!==void 0?i:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const c=i(844);class u extends c.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,c.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=u},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const c=i(3614),u=i(3656),l=i(6465),g=i(9042),_=i(3730),y=i(1680),x=i(3107),a=i(5744),h=i(2950),d=i(1296),f=i(428),b=i(4269),S=i(5114),k=i(8934),E=i(3230),C=i(9312),j=i(4725),N=i(6731),M=i(8055),T=i(8969),D=i(8460),B=i(844),L=i(6114),F=i(8437),z=i(2584),A=i(7399),P=i(5941),O=i(9074),I=i(2585),U=i(5435),X=i(4567),$=typeof window<"u"?window.document:null;class V extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(R={}){super(R),this.browser=L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,K)=>this.refresh(H,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,B.toDisposable)((()=>{var H,K;this._customKeyEventHandler=void 0,(K=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(R){if(this._themeService)for(const H of R){let K,W="";switch(H.index){case 256:K="foreground",W="10";break;case 257:K="background",W="11";break;case 258:K="cursor",W="12";break;default:K="ansi",W="4;"+H.index}switch(H.type){case 0:const Q=M.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,P.toRgbString)(Q)}${z.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((J=>J.ansi[H.index]=M.rgba.toColor(...H.color)));else{const J=K;this._themeService.modifyColors((oe=>oe[J]=M.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(R){R?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(R){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(R),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var R;return(R=this.textarea)===null||R===void 0?void 0:R.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const R=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(R);if(!H)return;const K=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,Q=H.getWidth(K),J=this._renderService.dimensions.css.cell.width*Q,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,fe=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=fe+"px",this.textarea.style.top=oe+"px",this.textarea.style.width=J+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const R=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",R)),this.register((0,u.addDisposableDomListener)(this.element,"paste",R)),L.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),L.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(R=>this._keyUp(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(R=>this._keyDown(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(R=>this._keyPress(R)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(R=>this._compositionHelper.compositionupdate(R)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(R=>this._inputEvent(R)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(R){var H;if(!R)throw new Error("Terminal requires a parent element.");R.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=R.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),R.appendChild(this.element);const K=$.createDocumentFragment();this._viewportElement=$.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=$.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=$.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=$.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=$.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),L.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((W=>this._onRender.fire(W)))),this.onResize((W=>this._renderService.resize(W.cols,W.rows))),this._compositionView=$.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(K);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((W=>this.scrollLines(W.amount,W.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(C.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((W=>this.scrollLines(W.amount,W.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((W=>this._renderService.handleSelectionChanged(W.start,W.end,W.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((W=>{this.textarea.value=W,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((W=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(W=>this._selectionService.handleMouseDown(W)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const R=this,H=this.element;function K(J){const oe=R._mouseService.getMouseReportCoords(J,R.screenElement);if(!oe)return!1;let fe,Ne;switch(J.overrideType||J.type){case"mousemove":Ne=32,J.buttons===void 0?(fe=3,J.button!==void 0&&(fe=J.button<3?J.button:3)):fe=1&J.buttons?0:4&J.buttons?1:2&J.buttons?2:3;break;case"mouseup":Ne=0,fe=J.button<3?J.button:3;break;case"mousedown":Ne=1,fe=J.button<3?J.button:3;break;case"wheel":if(R.viewport.getLinesScrolled(J)===0)return!1;Ne=J.deltaY<0?0:1,fe=4;break;default:return!1}return!(Ne===void 0||fe===void 0||fe>4)&&R.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:fe,action:Ne,ctrl:J.ctrlKey,alt:J.altKey,shift:J.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Q={mouseup:J=>(K(J),J.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(J)),wheel:J=>(K(J),this.cancel(J,!0)),mousedrag:J=>{J.buttons&&K(J)},mousemove:J=>{J.buttons||K(J)}};this.register(this.coreMouseService.onProtocolChange((J=>{J?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(J)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&J?W.mousemove||(H.addEventListener("mousemove",Q.mousemove),W.mousemove=Q.mousemove):(H.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&J?W.wheel||(H.addEventListener("wheel",Q.wheel,{passive:!1}),W.wheel=Q.wheel):(H.removeEventListener("wheel",W.wheel),W.wheel=null),2&J?W.mouseup||(H.addEventListener("mouseup",Q.mouseup),W.mouseup=Q.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),H.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&J?W.mousedrag||(W.mousedrag=Q.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(H,"mousedown",(J=>{if(J.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(J))return K(J),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(J)}))),this.register((0,u.addDisposableDomListener)(H,"wheel",(J=>{if(!W.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(J);if(oe===0)return;const fe=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(J.deltaY<0?"A":"B");let Ne="";for(let je=0;je<Math.abs(oe);je++)Ne+=fe;return this.coreService.triggerDataEvent(Ne,!0),this.cancel(J,!0)}return this.viewport.handleWheel(J)?this.cancel(J):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(H,"touchstart",(J=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(J),this.cancel(J)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(H,"touchmove",(J=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(J)?void 0:this.cancel(J)}),{passive:!1}))}refresh(R,H){var K;(K=this._renderService)===null||K===void 0||K.refreshRows(R,H)}updateCursorStyle(R){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(R)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(R,H,K=0){var W;K===1?(super.scrollLines(R,H,K),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(R)}paste(R){(0,c.paste)(R,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(R){this._customKeyEventHandler=R}registerLinkProvider(R){return this.linkifier2.registerLinkProvider(R)}registerCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(R);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(R){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(R)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(R){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+R)}registerDecoration(R){return this._decorationService.registerDecoration(R)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(R,H,K){this._selectionService.setSelection(R,H,K)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var R;(R=this._selectionService)===null||R===void 0||R.clearSelection()}selectAll(){var R;(R=this._selectionService)===null||R===void 0||R.selectAll()}selectLines(R,H){var K;(K=this._selectionService)===null||K===void 0||K.selectLines(R,H)}_keyDown(R){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&R.altKey;if(!H&&!this._compositionHelper.keydown(R))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||R.key!=="Dead"&&R.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,A.evaluateKeyboardEvent)(R,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(R),K.type===3||K.type===2){const W=this.rows-1;return this.scrollLines(K.type===2?-W:W),this.cancel(R,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,R)||(K.cancel&&this.cancel(R,!0),!K.key||!!(R.key&&!R.ctrlKey&&!R.altKey&&!R.metaKey&&R.key.length===1&&R.key.charCodeAt(0)>=65&&R.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(K.key!==z.C0.ETX&&K.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||R.altKey||R.ctrlKey?this.cancel(R,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(R,H){const K=R.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||R.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||R.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?K:K&&(!H.keyCode||H.keyCode>47)}_keyUp(R){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(R)||this.focus(),this.updateCursorStyle(R),this._keyPressHandled=!1)}_keyPress(R){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(R)===!1)return!1;if(this.cancel(R),R.charCode)H=R.charCode;else if(R.which===null||R.which===void 0)H=R.keyCode;else{if(R.which===0||R.charCode===0)return!1;H=R.which}return!(!H||(R.altKey||R.ctrlKey||R.metaKey)&&!this._isThirdLevelShift(this.browser,R)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:R}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(R){if(R.data&&R.inputType==="insertText"&&(!R.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=R.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(R),!0}return!1}resize(R,H){R!==this.cols||H!==this.rows?super.resize(R,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(R,H){var K,W;(K=this._charSizeService)===null||K===void 0||K.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var R;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(R=this.viewport)===null||R===void 0||R.reset(),this.refresh(0,this.rows-1)}}reset(){var R,H;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(R=this._selectionService)===null||R===void 0||R.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var R;(R=this._renderService)===null||R===void 0||R.clearTextureAtlas()}_reportFocus(){var R;!((R=this.element)===null||R===void 0)&&R.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(R){if(this._renderService)switch(R){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${K};${H}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),Q=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${Q};${W}t`)}}cancel(R,H){if(this.options.cancelEvents||H)return R.preventDefault(),R.stopPropagation(),!1}}n.Terminal=V},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,c=1e3){this._renderCallback=i,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,c,u){this._rowCount=u,i=i!==void 0?i:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=l-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,c)}}},1680:function(v,n,i){var c=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,E=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,b);else for(var C=h.length-1;C>=0;C--)(S=h[C])&&(E=(k<3?S(E):k>3?S(d,f,E):S(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const l=i(3656),g=i(4725),_=i(8460),y=i(844),x=i(2585);let a=n.Viewport=class extends y.Disposable{constructor(h,d,f,b,S,k,E,C){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=b,this._charSizeService=S,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(C.colors),this.register(C.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let b,S="";const k=[],E=d??this._bufferService.buffer.lines.length,C=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const N=C.get(j);if(!N)continue;const M=(f=C.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(S+=N.translateToString(!M),!M||j===C.length-1){const T=document.createElement("div");T.textContent=S,k.push(T),S.length>0&&(b=T),S=""}}return{bufferElements:k,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};n.Viewport=a=c([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,n,i){var c=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const l=i(3656),g=i(4725),_=i(844),y=i(2585);let x=n.BufferDecorationRenderer=class extends _.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,l.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((b=>this._removeDecoration(b)))),this.register((0,_.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(d=a.options.x)!==null&&d!==void 0?d:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=x=c([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],x)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const c of this._zones)if(c.color===i.options.overviewRulerOptions.color&&c.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,i.marker.line))return;if(this._lineAdjacentToZone(c,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(c,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,c){return c>=i.startBufferLine&&c<=i.endBufferLine}_lineAdjacentToZone(i,c,u){return c>=i.startBufferLine-this._linePadding[u||"full"]&&c<=i.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(i,c){i.startBufferLine=Math.min(i.startBufferLine,c),i.endBufferLine=Math.max(i.endBufferLine,c)}}},5744:function(v,n,i){var c=this&&this.__decorate||function(b,S,k,E){var C,j=arguments.length,N=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,S,k,E);else for(var M=b.length-1;M>=0;M--)(C=b[M])&&(N=(j<3?C(N):j>3?C(S,k,N):C(S,k))||N);return j>3&&N&&Object.defineProperty(S,k,N),N},u=this&&this.__param||function(b,S){return function(k,E){S(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const l=i(5871),g=i(3656),_=i(4725),y=i(844),x=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,S,k,E,C,j,N){var M;super(),this._viewportElement=b,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=C,this._optionsService=j,this._coreBrowseService=N,this._colorZoneStore=new l.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(M=this._viewportElement.parentElement)===null||M===void 0||M.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=S,h.right=b,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=S,a.center=S,a.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const S of b)S.position!=="full"&&this._renderColorZone(S);for(const S of b)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(d[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,S){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=c([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,_.IRenderService),u(5,x.IOptionsService),u(6,_.ICoreBrowserService)],f)},2950:function(v,n,i){var c=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const l=i(4725),g=i(2585),_=i(2584);let y=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,h,d,f,b){this._textarea=x,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=b,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(x,"");this._dataAlreadySent=h,a.length>x.length?this._coreService.triggerDataEvent(h,!0):a.length<x.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=y=c([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,l.IRenderService)],y)},9806:(v,n)=>{function i(c,u,l){const g=l.getBoundingClientRect(),_=c.getComputedStyle(l),y=parseInt(_.getPropertyValue("padding-left")),x=parseInt(_.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-x]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(c,u,l,g,_,y,x,a,h){if(!y)return;const d=i(c,u,l);return d?(d[0]=Math.ceil((d[0]+(h?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),_),d):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const c=i(2584);function u(a,h,d,f){const b=a-l(a,d),S=h-l(h,d),k=Math.abs(b-S)-(function(E,C,j){let N=0;const M=E-l(E,j),T=C-l(C,j);for(let D=0;D<Math.abs(M-T);D++){const B=g(E,C)==="A"?-1:1,L=j.buffer.lines.get(M+B*D);L?.isWrapped&&N++}return N})(a,h,d);return x(k,y(g(a,h),f))}function l(a,h){let d=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function _(a,h,d,f,b,S){let k=a,E=h,C="";for(;k!==d||E!==f;)k+=b?1:-1,b&&k>S.cols-1?(C+=S.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!b&&k<0&&(C+=S.buffer.translateBufferLineToString(E,!1,0,a+1),k=S.cols-1,a=k,E--);return C+S.buffer.translateBufferLineToString(E,!1,a,k)}function y(a,h){const d=h?"O":"[";return c.C0.ESC+d+a}function x(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}n.moveToCellSequence=function(a,h,d,f){const b=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(C,j,N,M,T,D){return u(j,M,T,D).length===0?"":x(_(C,j,C,j-l(j,T),!1,T).length,y("D",D))})(b,S,0,h,d,f)+u(S,h,d,f)+(function(C,j,N,M,T,D){let B;B=u(j,M,T,D).length>0?M-l(M,T):j;const L=M,F=(function(z,A,P,O,I,U){let X;return X=u(P,O,I,U).length>0?O-l(O,I):A,z<P&&X<=O||z>=P&&X<O?"C":"D"})(C,j,N,M,T,D);return x(_(C,B,N,L,F==="C",T).length,y(F,D))})(b,S,a,h,d,f);let k;if(S===h)return k=b>a?"D":"C",x(Math.abs(b-a),y(k,f));k=S>h?"D":"C";const E=Math.abs(S-h);return x((function(C,j){return j.cols-C})(S>h?a:b,d)+(E-1)*d.cols+1+((S>h?b:a)-1),y(k,f))}},1296:function(v,n,i){var c=this&&this.__decorate||function(T,D,B,L){var F,z=arguments.length,A=z<3?D:L===null?L=Object.getOwnPropertyDescriptor(D,B):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,D,B,L);else for(var P=T.length-1;P>=0;P--)(F=T[P])&&(A=(z<3?F(A):z>3?F(D,B,A):F(D,B))||A);return z>3&&A&&Object.defineProperty(D,B,A),A},u=this&&this.__param||function(T,D){return function(B,L){D(B,L,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const l=i(3787),g=i(2550),_=i(2223),y=i(6171),x=i(4725),a=i(8055),h=i(8460),d=i(844),f=i(2585),b="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",C="xterm-focus",j="xterm-selection";let N=1,M=n.DomRenderer=class extends d.Disposable{constructor(T,D,B,L,F,z,A,P,O,I){super(),this._element=T,this._screenElement=D,this._viewportElement=B,this._linkifier2=L,this._charSizeService=z,this._optionsService=A,this._bufferService=P,this._coreBrowserService=O,this._themeService=I,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(b+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${S} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${S} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${S}.${C} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${C} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[B,L]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${B} { color: ${L.css}; }${this._terminalSelector} .${k}${B}.xterm-dim { color: ${a.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${E}${B} { background-color: ${L.css}; }`;D+=`${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${_.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let B=this._rowElements.length;B<=D;B++){const L=document.createElement("div");this._rowContainer.appendChild(L),this._rowElements.push(L)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(C)}handleFocus(){this._rowContainer.classList.add(C),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,B),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const L=T[1]-this._bufferService.buffer.ydisp,F=D[1]-this._bufferService.buffer.ydisp,z=Math.max(L,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(B){const O=T[0]>D[0];P.appendChild(this._createSelectionElement(z,O?D[0]:T[0],O?T[0]:D[0],A-z+1))}else{const O=L===z?T[0]:0,I=z===F?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,O,I));const U=A-z-1;if(P.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,U)),z!==A){const X=F===A?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,X))}}this._selectionContainer.appendChild(P)}_createSelectionElement(T,D,B,L=1){const F=document.createElement("div");return F.style.height=L*this.dimensions.css.cell.height+"px",F.style.top=T*this.dimensions.css.cell.height+"px",F.style.left=D*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(B-D)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const B=this._bufferService.buffer,L=B.ybase+B.y,F=Math.min(B.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=T;O<=D;O++){const I=O+B.ydisp,U=this._rowElements[O],X=B.lines.get(I);if(!U||!X)break;U.replaceChildren(...this._rowFactory.createRow(X,I,I===L,A,P,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,B,L,F,z){B<0&&(T=0),L<0&&(D=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),L=Math.max(Math.min(L,A),0),F=Math.min(F,this._bufferService.cols);const P=this._bufferService.buffer,O=P.ybase+P.y,I=Math.min(P.x,F-1),U=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,$=this._optionsService.rawOptions.cursorInactiveStyle;for(let V=B;V<=L;++V){const q=V+P.ydisp,R=this._rowElements[V],H=P.lines.get(q);if(!R||!H)break;R.replaceChildren(...this._rowFactory.createRow(H,q,q===O,X,$,I,U,this.dimensions.css.cell.width,this._widthCache,z?V===B?T:0:-1,z?(V===L?D:F)-1:-1))}}};n.DomRenderer=M=c([u(4,f.IInstantiationService),u(5,x.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],M)},3787:function(v,n,i){var c=this&&this.__decorate||function(k,E,C,j){var N,M=arguments.length,T=M<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,C):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,C,j);else for(var D=k.length-1;D>=0;D--)(N=k[D])&&(T=(M<3?N(T):M>3?N(E,C,T):N(E,C))||T);return M>3&&T&&Object.defineProperty(E,C,T),T},u=this&&this.__param||function(k,E){return function(C,j){E(C,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const l=i(2223),g=i(643),_=i(511),y=i(2585),x=i(8055),a=i(4725),h=i(4269),d=i(6171),f=i(3734);let b=n.DomRendererRowFactory=class{constructor(k,E,C,j,N,M,T){this._document=k,this._characterJoinerService=E,this._optionsService=C,this._coreBrowserService=j,this._coreService=N,this._decorationService=M,this._themeService=T,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,C){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=C}createRow(k,E,C,j,N,M,T,D,B,L,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let O,I=k.getNoBgTrimmedLength();C&&I<M+1&&(I=M+1);let U=0,X="",$=0,V=0,q=0,R=!1,H=0,K=!1,W=0;const Q=[],J=L!==-1&&F!==-1;for(let oe=0;oe<I;oe++){k.loadCell(oe,this._workCell);let fe=this._workCell.getWidth();if(fe===0)continue;let Ne=!1,je=oe,se=this._workCell;if(A.length>0&&oe===A[0][0]){Ne=!0;const Y=A.shift();se=new h.JoinedCellData(this._workCell,k.translateToString(!0,Y[0],Y[1]),Y[1]-Y[0]),je=Y[1]-1,fe=se.getWidth()}const Oe=this._isCellInSelection(oe,E),Me=C&&oe===M,Fe=J&&oe>=L&&oe<=F;let ze=!1;this._decorationService.forEachDecorationAtCell(oe,E,void 0,(Y=>{ze=!0}));let Qe=se.getChars()||g.WHITESPACE_CELL_CHAR;if(Qe===" "&&(se.isUnderline()||se.isOverline())&&(Qe=" "),W=fe*D-B.get(Qe,se.isBold(),se.isItalic()),O){if(U&&(Oe&&K||!Oe&&!K&&se.bg===$)&&(Oe&&K&&P.selectionForeground||se.fg===V)&&se.extended.ext===q&&Fe===R&&W===H&&!Me&&!Ne&&!ze){X+=Qe,U++;continue}U&&(O.textContent=X),O=this._document.createElement("span"),U=0,X=""}else O=this._document.createElement("span");if($=se.bg,V=se.fg,q=se.extended.ext,R=Fe,H=W,K=Oe,Ne&&M>=oe&&M<=je&&(M=oe),!this._coreService.isCursorHidden&&Me){if(Q.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&Q.push("xterm-cursor-blink"),Q.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":Q.push("xterm-cursor-outline");break;case"block":Q.push("xterm-cursor-block");break;case"bar":Q.push("xterm-cursor-bar");break;case"underline":Q.push("xterm-cursor-underline")}}if(se.isBold()&&Q.push("xterm-bold"),se.isItalic()&&Q.push("xterm-italic"),se.isDim()&&Q.push("xterm-dim"),X=se.isInvisible()?g.WHITESPACE_CELL_CHAR:se.getChars()||g.WHITESPACE_CELL_CHAR,se.isUnderline()&&(Q.push(`xterm-underline-${se.extended.underlineStyle}`),X===" "&&(X=" "),!se.isUnderlineColorDefault()))if(se.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(se.getUnderlineColor()).join(",")})`;else{let Y=se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&se.isBold()&&Y<8&&(Y+=8),O.style.textDecorationColor=P.ansi[Y].css}se.isOverline()&&(Q.push("xterm-overline"),X===" "&&(X=" ")),se.isStrikethrough()&&Q.push("xterm-strikethrough"),Fe&&(O.style.textDecoration="underline");let Te=se.getFgColor(),ee=se.getFgColorMode(),xe=se.getBgColor(),Re=se.getBgColorMode();const G=!!se.isInverse();if(G){const Y=Te;Te=xe,xe=Y;const ie=ee;ee=Re,Re=ie}let ne,ue,ye,Se=!1;switch(this._decorationService.forEachDecorationAtCell(oe,E,void 0,(Y=>{Y.options.layer!=="top"&&Se||(Y.backgroundColorRGB&&(Re=50331648,xe=Y.backgroundColorRGB.rgba>>8&16777215,ne=Y.backgroundColorRGB),Y.foregroundColorRGB&&(ee=50331648,Te=Y.foregroundColorRGB.rgba>>8&16777215,ue=Y.foregroundColorRGB),Se=Y.options.layer==="top")})),!Se&&Oe&&(ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,xe=ne.rgba>>8&16777215,Re=50331648,Se=!0,P.selectionForeground&&(ee=50331648,Te=P.selectionForeground.rgba>>8&16777215,ue=P.selectionForeground)),Se&&Q.push("xterm-decoration-top"),Re){case 16777216:case 33554432:ye=P.ansi[xe],Q.push(`xterm-bg-${xe}`);break;case 50331648:ye=x.rgba.toColor(xe>>16,xe>>8&255,255&xe),this._addStyle(O,`background-color:#${S((xe>>>0).toString(16),"0",6)}`);break;default:G?(ye=P.foreground,Q.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):ye=P.background}switch(ne||se.isDim()&&(ne=x.color.multiplyOpacity(ye,.5)),ee){case 16777216:case 33554432:se.isBold()&&Te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Te+=8),this._applyMinimumContrast(O,ye,P.ansi[Te],se,ne,void 0)||Q.push(`xterm-fg-${Te}`);break;case 50331648:const Y=x.rgba.toColor(Te>>16&255,Te>>8&255,255&Te);this._applyMinimumContrast(O,ye,Y,se,ne,ue)||this._addStyle(O,`color:#${S(Te.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,ye,P.foreground,se,ne,void 0)||G&&Q.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}Q.length&&(O.className=Q.join(" "),Q.length=0),Me||Ne||ze?O.textContent=X:U++,W!==this.defaultSpacing&&(O.style.letterSpacing=`${W}px`),z.push(O),oe=je}return O&&U&&(O.textContent=X),z}_applyMinimumContrast(k,E,C,j,N,M){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(N||M||(D=T.getColor(E.rgba,C.rgba)),D===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=x.color.ensureContrastRatio(N||E,M||C,B),T.setColor((N||E).rgba,(M||C).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const C=this._selectionStart,j=this._selectionEnd;return!(!C||!j)&&(this._columnSelectMode?C[0]<=j[0]?k>=C[0]&&E>=C[1]&&k<j[0]&&E<=j[1]:k<C[0]&&E>=C[1]&&k>=j[0]&&E<=j[1]:E>C[1]&&E<j[1]||C[1]===j[1]&&E===C[1]&&k>=C[0]&&k<j[0]||C[1]<j[1]&&E===j[1]&&k<j[0]||C[1]<j[1]&&E===C[1]&&k>=C[0])}};function S(k,E,C){for(;k.length<C;)k=E+k;return k}n.DomRendererRowFactory=b=c([u(1,a.ICharacterJoinerService),u(2,y.IOptionsService),u(3,a.ICoreBrowserService),u(4,y.ICoreService),u(5,y.IDecorationService),u(6,a.IThemeService)],b)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const c=i.createElement("span"),u=i.createElement("span");u.style.fontWeight="bold";const l=i.createElement("span");l.style.fontStyle="italic";const g=i.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,u,l,g],this._container.appendChild(c),this._container.appendChild(u),this._container.appendChild(l),this._container.appendChild(g),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,c,u,l){i===this._font&&c===this._fontSize&&u===this._weight&&l===this._weightBold||(this._font=i,this._fontSize=c,this._weight=u,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(i,c,u){let l=0;if(!c&&!u&&i.length===1&&(l=i.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(i,0);let g=i;c&&(g+="B"),u&&(g+="I");let _=this._holey.get(g);if(_===void 0){let y=0;c&&(y|=1),u&&(y|=2),_=this._measure(i,y),this._holey.set(g,_)}return _}_measure(i,c){const u=this._measureElements[c];return u.textContent=i.repeat(32),u.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const c=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(c){return 57508<=c&&c<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},n.excludeFromContrastRatioDemands=function(c){return i(c)||(function(u){return 9472<=u&&u<=9631})(c)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,c=this.selectionEnd;return!(!i||!c)&&(i[1]>c[1]||i[1]===c[1]&&i[0]>c[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var c=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const l=i(2585),g=i(8460),_=i(844);let y=n.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new x(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=y=c([u(2,l.IOptionsService)],y);class x{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var c=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,E=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,b);else for(var C=h.length-1;C>=0;C--)(S=h[C])&&(E=(k<3?S(E):k>3?S(d,f,E):S(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const l=i(3734),g=i(643),_=i(511),y=i(2585);class x extends l.AttributeData{constructor(d,f,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=x;let a=n.CharacterJoinerService=class ul{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const b=[],S=f.translateToString(!0);let k=0,E=0,C=0,j=f.getFg(0),N=f.getBg(0);for(let M=0;M<f.getTrimmedLength();M++)if(f.loadCell(M,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==N){if(M-k>1){const T=this._getJoinedRanges(S,C,E,f,k);for(let D=0;D<T.length;D++)b.push(T[D])}k=M,C=E,j=this._workCell.fg,N=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const M=this._getJoinedRanges(S,C,E,f,k);for(let T=0;T<M.length;T++)b.push(M[T])}return b}_getJoinedRanges(d,f,b,S,k){const E=d.substring(f,b);let C=[];try{C=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const N=this._characterJoiners[j].handler(E);for(let M=0;M<N.length;M++)ul._mergeRanges(C,N[M])}catch(N){console.error(N)}return this._stringRangesToCellRanges(C,S,k),C}_stringRangesToCellRanges(d,f,b){let S=0,k=!1,E=0,C=d[S];if(C){for(let j=b;j<this._bufferService.cols;j++){const N=f.getWidth(j),M=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&C[0]<=E&&(C[0]=j,k=!0),C[1]<=E){if(C[1]=j,C=d[++S],!C)break;C[0]<=E?(C[0]=j,k=!0):k=!1}E+=M}}C&&(C[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let b=!1;for(let S=0;S<d.length;S++){const k=d[S];if(b){if(f[1]<=k[0])return d[S-1][1]=f[1],d;if(f[1]<=k[1])return d[S-1][1]=Math.max(f[1],k[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(f[1]<=k[0])return d.splice(S,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),b=!0)}}return b?d[d.length-1][1]=f[1]:d.push(f),d}};n.CharacterJoinerService=a=c([u(0,y.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,c){this._textarea=i,this.window=c,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var c=this&&this.__decorate||function(y,x,a,h){var d,f=arguments.length,b=f<3?x:h===null?h=Object.getOwnPropertyDescriptor(x,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,x,a,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(b=(f<3?d(b):f>3?d(x,a,b):d(x,a))||b);return f>3&&b&&Object.defineProperty(x,a,b),b},u=this&&this.__param||function(y,x){return function(a,h){x(a,h,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const l=i(4725),g=i(9806);let _=n.MouseService=class{constructor(y,x){this._renderService=y,this._charSizeService=x}getCoords(y,x,a,h,d){return(0,g.getCoords)(window,y,x,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,x){const a=(0,g.getCoordsRelativeToElement)(window,y,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=_=c([u(0,l.IRenderService),u(1,l.ICharSizeService)],_)},3230:function(v,n,i){var c=this&&this.__decorate||function(b,S,k,E){var C,j=arguments.length,N=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,S,k,E);else for(var M=b.length-1;M>=0;M--)(C=b[M])&&(N=(j<3?C(N):j>3?C(S,k,N):C(S,k))||N);return j>3&&N&&Object.defineProperty(S,k,N),N},u=this&&this.__param||function(b,S){return function(k,E){S(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const l=i(3656),g=i(6193),_=i(5596),y=i(4725),x=i(8460),a=i(844),h=i(7226),d=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,S,k,E,C,j,N,M){if(super(),this._rowCount=b,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(C.onDecorationRegistered((()=>this._fullRefresh()))),this.register(C.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,l.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(M.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const T=new N.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(S),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,S,this._rowCount))}_renderRows(b,S){this._renderer.value&&(b=Math.min(b,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(b,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:S}),this._onRender.fire({start:b,end:S}),this._isNextRenderRedrawOnly=!0)}resize(b,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,S;this._renderer.value&&((S=(b=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,S))):this._renderer.value.handleResize(b,S),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,S,k){var E;this._selectionState.start=b,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(b,S,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};n.RenderService=f=c([u(2,d.IOptionsService),u(3,y.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,y.ICoreBrowserService),u(7,y.IThemeService)],f)},9312:function(v,n,i){var c=this&&this.__decorate||function(C,j,N,M){var T,D=arguments.length,B=D<3?j:M===null?M=Object.getOwnPropertyDescriptor(j,N):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(C,j,N,M);else for(var L=C.length-1;L>=0;L--)(T=C[L])&&(B=(D<3?T(B):D>3?T(j,N,B):T(j,N))||B);return D>3&&B&&Object.defineProperty(j,N,B),B},u=this&&this.__param||function(C,j){return function(N,M){j(N,M,C)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const l=i(9806),g=i(9504),_=i(456),y=i(4725),x=i(8460),a=i(844),h=i(6114),d=i(4841),f=i(511),b=i(2585),S=" ",k=new RegExp(S,"g");let E=n.SelectionService=class extends a.Disposable{constructor(C,j,N,M,T,D,B,L,F){super(),this._element=C,this._screenElement=j,this._linkifier=N,this._bufferService=M,this._coreService=T,this._mouseService=D,this._optionsService=B,this._renderService=L,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((z=>this._handleTrim(z))),this.register(this._bufferService.buffers.onBufferActivate((z=>this._handleBufferActivate(z)))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const C=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!C||!j||C[0]===j[0]&&C[1]===j[1])}get selectionText(){const C=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!C||!j)return"";const N=this._bufferService.buffer,M=[];if(this._activeSelectionMode===3){if(C[0]===j[0])return"";const T=C[0]<j[0]?C[0]:j[0],D=C[0]<j[0]?j[0]:C[0];for(let B=C[1];B<=j[1];B++){const L=N.translateBufferLineToString(B,!0,T,D);M.push(L)}}else{const T=C[1]===j[1]?j[0]:void 0;M.push(N.translateBufferLineToString(C[1],!0,C[0],T));for(let D=C[1]+1;D<=j[1]-1;D++){const B=N.lines.get(D),L=N.translateBufferLineToString(D,!0);B?.isWrapped?M[M.length-1]+=L:M.push(L)}if(C[1]!==j[1]){const D=N.lines.get(j[1]),B=N.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?M[M.length-1]+=B:M.push(B)}}return M.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
24
|
+
`:`
|
|
25
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(C){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&C&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(C){const j=this._getMouseBufferCoords(C),N=this._model.finalSelectionStart,M=this._model.finalSelectionEnd;return!!(N&&M&&j)&&this._areCoordsInSelection(j,N,M)}isCellInSelection(C,j){const N=this._model.finalSelectionStart,M=this._model.finalSelectionEnd;return!(!N||!M)&&this._areCoordsInSelection([C,j],N,M)}_areCoordsInSelection(C,j,N){return C[1]>j[1]&&C[1]<N[1]||j[1]===N[1]&&C[1]===j[1]&&C[0]>=j[0]&&C[0]<N[0]||j[1]<N[1]&&C[1]===N[1]&&C[0]<N[0]||j[1]<N[1]&&C[1]===j[1]&&C[0]>=j[0]}_selectWordAtCursor(C,j){var N,M;const T=(M=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||M===void 0?void 0:M.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(C);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(C,j){this._model.clearSelection(),C=Math.max(C,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,C],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(C){this._model.handleTrim(C)&&this.refresh()}_getMouseBufferCoords(C){const j=this._mouseService.getCoords(C,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(C){let j=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,C,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=N?0:(j>N&&(j-=N),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(C){return h.isMac?C.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:C.shiftKey}handleMouseDown(C){if(this._mouseDownTimeStamp=C.timeStamp,(C.button!==2||!this.hasSelection)&&C.button===0){if(!this._enabled){if(!this.shouldForceSelection(C))return;C.stopPropagation()}C.preventDefault(),this._dragScrollAmount=0,this._enabled&&C.shiftKey?this._handleIncrementalClick(C):C.detail===1?this._handleSingleClick(C):C.detail===2?this._handleDoubleClick(C):C.detail===3&&this._handleTripleClick(C),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(C){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(C))}_handleSingleClick(C){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(C)?3:0,this._model.selectionStart=this._getMouseBufferCoords(C),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(C){this._selectWordAtCursor(C,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(C){const j=this._getMouseBufferCoords(C);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(C){return C.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(C){if(C.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(C),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(C),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const N=this._bufferService.buffer;if(this._model.selectionEnd[1]<N.lines.length){const M=N.lines.get(this._model.selectionEnd[1]);M&&M.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const C=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(C.ydisp+this._bufferService.rows,C.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=C.ydisp),this.refresh()}}_handleMouseUp(C){const j=C.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&C.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(C,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const M=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(M,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const C=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,N=!(!C||!j||C[0]===j[0]&&C[1]===j[1]);N?C&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&C[0]===this._oldSelectionStart[0]&&C[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(C,j,N)):this._oldHasSelection&&this._fireOnSelectionChange(C,j,N)}_fireOnSelectionChange(C,j,N){this._oldSelectionStart=C,this._oldSelectionEnd=j,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(C){this.clearSelection(),this._trimListener.dispose(),this._trimListener=C.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(C,j){let N=j;for(let M=0;j>=M;M++){const T=C.loadCell(M,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:T>1&&j!==M&&(N+=T-1)}return N}setSelection(C,j,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[C,j],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(C){this._isClickInSelection(C)||(this._selectWordAtCursor(C,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(C,j,N=!0,M=!0){if(C[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(C[1]);if(!D)return;const B=T.translateBufferLineToString(C[1],!1);let L=this._convertViewportColToCharacterIndex(D,C[0]),F=L;const z=C[0]-L;let A=0,P=0,O=0,I=0;if(B.charAt(L)===" "){for(;L>0&&B.charAt(L-1)===" ";)L--;for(;F<B.length&&B.charAt(F+1)===" ";)F++}else{let $=C[0],V=C[0];D.getWidth($)===0&&(A++,$--),D.getWidth(V)===2&&(P++,V++);const q=D.getString(V).length;for(q>1&&(I+=q-1,F+=q-1);$>0&&L>0&&!this._isCharWordSeparator(D.loadCell($-1,this._workCell));){D.loadCell($-1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,$--):R>1&&(O+=R-1,L-=R-1),L--,$--}for(;V<D.length&&F+1<B.length&&!this._isCharWordSeparator(D.loadCell(V+1,this._workCell));){D.loadCell(V+1,this._workCell);const R=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,V++):R>1&&(I+=R-1,F+=R-1),F++,V++}}F++;let U=L+z-A+O,X=Math.min(this._bufferService.cols,F-L+A+P-O-I);if(j||B.slice(L,F).trim()!==""){if(N&&U===0&&D.getCodePoint(0)!==32){const $=T.lines.get(C[1]-1);if($&&D.isWrapped&&$.getCodePoint(this._bufferService.cols-1)!==32){const V=this._getWordAt([this._bufferService.cols-1,C[1]-1],!1,!0,!1);if(V){const q=this._bufferService.cols-V.start;U-=q,X+=q}}}if(M&&U+X===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const $=T.lines.get(C[1]+1);if($?.isWrapped&&$.getCodePoint(0)!==32){const V=this._getWordAt([0,C[1]+1],!1,!1,!0);V&&(X+=V.length)}}return{start:U,length:X}}}_selectWordAt(C,j){const N=this._getWordAt(C,j);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,C[1]--;this._model.selectionStart=[N.start,C[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(C){const j=this._getWordAt(C,!0);if(j){let N=C[1];for(;j.start<0;)j.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,N]}}_isCharWordSeparator(C){return C.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(C.getChars())>=0}_selectLineAt(C){const j=this._bufferService.buffer.getWrappedRangeForLine(C),N={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(N,this._bufferService.cols)}};n.SelectionService=E=c([u(3,b.IBufferService),u(4,b.ICoreService),u(5,y.IMouseService),u(6,b.IOptionsService),u(7,y.IRenderService),u(8,y.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const c=i(8343);n.ICharSizeService=(0,c.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),n.IMouseService=(0,c.createDecorator)("MouseService"),n.IRenderService=(0,c.createDecorator)("RenderService"),n.ISelectionService=(0,c.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(v,n,i){var c=this&&this.__decorate||function(E,C,j,N){var M,T=arguments.length,D=T<3?C:N===null?N=Object.getOwnPropertyDescriptor(C,j):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,C,j,N);else for(var B=E.length-1;B>=0;B--)(M=E[B])&&(D=(T<3?M(D):T>3?M(C,j,D):M(C,j))||D);return T>3&&D&&Object.defineProperty(C,j,D),D},u=this&&this.__param||function(E,C){return function(j,N){C(j,N,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const l=i(7239),g=i(8055),_=i(8460),y=i(844),x=i(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],C=[0,95,135,175,215,255];for(let j=0;j<216;j++){const N=C[j/36%6|0],M=C[j/6%6|0],T=C[j%6];E.push({css:g.channels.toCss(N,M,T),rgba:g.channels.toRgba(N,M,T)})}for(let j=0;j<24;j++){const N=8+10*j;E.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return E})());let S=n.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const C=this._colors;if(C.foreground=k(E.foreground,a),C.background=k(E.background,h),C.cursor=k(E.cursor,d),C.cursorAccent=k(E.cursorAccent,f),C.selectionBackgroundTransparent=k(E.selectionBackground,b),C.selectionBackgroundOpaque=g.color.blend(C.background,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,C.selectionBackgroundTransparent),C.selectionInactiveBackgroundOpaque=g.color.blend(C.background,C.selectionInactiveBackgroundTransparent),C.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,C.selectionForeground===g.NULL_COLOR&&(C.selectionForeground=void 0),g.color.isOpaque(C.selectionBackgroundTransparent)&&(C.selectionBackgroundTransparent=g.color.opacity(C.selectionBackgroundTransparent,.3)),g.color.isOpaque(C.selectionInactiveBackgroundTransparent)&&(C.selectionInactiveBackgroundTransparent=g.color.opacity(C.selectionInactiveBackgroundTransparent,.3)),C.ansi=n.DEFAULT_ANSI_COLORS.slice(),C.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),C.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),C.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),C.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),C.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),C.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),C.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),C.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),C.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),C.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),C.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),C.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),C.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),C.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),C.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),C.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(C.ansi.length-16,E.extendedAnsi.length);for(let N=0;N<j;N++)C.ansi[N+16]=k(E.extendedAnsi[N],n.DEFAULT_ANSI_COLORS[N+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let C=0;C<this._restoreColors.ansi.length;++C)this._colors.ansi[C]=this._restoreColors.ansi[C]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,C){if(E!==void 0)try{return g.css.toColor(E)}catch{}return C}n.ThemeService=S=c([u(0,x.IOptionsService)],S)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const c=i(8460),u=i(844);class l extends u.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(_){if(this._maxLength===_)return;const y=new Array(_);for(let x=0;x<Math.min(_,this.length);x++)y[x]=this._array[this._getCyclicIndex(x)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,y,...x){if(y){for(let a=_;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let a=this._length-1;a>=_;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(_+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:_,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,x){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let h=y-1;h>=0;h--)this.set(_+h+x,this.get(_+h));const a=_+y+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<y;a++)this.set(_+a+x,this.get(_+a))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}n.CircularList=l},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(c,u=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=u<=1?c[g]:c[g]&&i(c[g],u-1);return l}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const c=i(6114);let u=0,l=0,g=0,_=0;var y,x,a,h,d;function f(S){const k=S.toString(16);return k.length<2?"0"+k:k}function b(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,C,j){return j!==void 0?`#${f(k)}${f(E)}${f(C)}${f(j)}`:`#${f(k)}${f(E)}${f(C)}`},S.toRgba=function(k,E,C,j=255){return(k<<24|E<<16|C<<8|j)>>>0}})(y||(n.channels=y={})),(function(S){function k(E,C){return _=Math.round(255*C),[u,l,g]=d.toChannels(E.rgba),{css:y.toCss(u,l,g,_),rgba:y.toRgba(u,l,g,_)}}S.blend=function(E,C){if(_=(255&C.rgba)/255,_===1)return{css:C.css,rgba:C.rgba};const j=C.rgba>>24&255,N=C.rgba>>16&255,M=C.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,B=E.rgba>>8&255;return u=T+Math.round((j-T)*_),l=D+Math.round((N-D)*_),g=B+Math.round((M-B)*_),{css:y.toCss(u,l,g),rgba:y.toRgba(u,l,g)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,C,j){const N=d.ensureContrastRatio(E.rgba,C.rgba,j);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},S.opaque=function(E){const C=(255|E.rgba)>>>0;return[u,l,g]=d.toChannels(C),{css:y.toCss(u,l,g),rgba:C}},S.opacity=k,S.multiplyOpacity=function(E,C){return _=255&E.rgba,k(E,_*C/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(x||(n.color=x={})),(function(S){let k,E;if(!c.isNode){const C=document.createElement("canvas");C.width=1,C.height=1;const j=C.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return u=parseInt(C.slice(1,2).repeat(2),16),l=parseInt(C.slice(2,3).repeat(2),16),g=parseInt(C.slice(3,4).repeat(2),16),d.toColor(u,l,g);case 5:return u=parseInt(C.slice(1,2).repeat(2),16),l=parseInt(C.slice(2,3).repeat(2),16),g=parseInt(C.slice(3,4).repeat(2),16),_=parseInt(C.slice(4,5).repeat(2),16),d.toColor(u,l,g,_);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const j=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return u=parseInt(j[1]),l=parseInt(j[2]),g=parseInt(j[3]),_=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(u,l,g,_);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=C,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,l,g,_]=k.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,l,g,_),css:C}}})(a||(n.css=a={})),(function(S){function k(E,C,j){const N=E/255,M=C/255,T=j/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(h||(n.rgb=h={})),(function(S){function k(C,j,N){const M=C>>24&255,T=C>>16&255,D=C>>8&255;let B=j>>24&255,L=j>>16&255,F=j>>8&255,z=b(h.relativeLuminance2(B,L,F),h.relativeLuminance2(M,T,D));for(;z<N&&(B>0||L>0||F>0);)B-=Math.max(0,Math.ceil(.1*B)),L-=Math.max(0,Math.ceil(.1*L)),F-=Math.max(0,Math.ceil(.1*F)),z=b(h.relativeLuminance2(B,L,F),h.relativeLuminance2(M,T,D));return(B<<24|L<<16|F<<8|255)>>>0}function E(C,j,N){const M=C>>24&255,T=C>>16&255,D=C>>8&255;let B=j>>24&255,L=j>>16&255,F=j>>8&255,z=b(h.relativeLuminance2(B,L,F),h.relativeLuminance2(M,T,D));for(;z<N&&(B<255||L<255||F<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=b(h.relativeLuminance2(B,L,F),h.relativeLuminance2(M,T,D));return(B<<24|L<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(C,j,N){const M=h.relativeLuminance(C>>8),T=h.relativeLuminance(j>>8);if(b(M,T)<N){if(T<M){const L=k(C,j,N),F=b(M,h.relativeLuminance(L>>8));if(F<N){const z=E(C,j,N);return F>b(M,h.relativeLuminance(z>>8))?L:z}return L}const D=E(C,j,N),B=b(M,h.relativeLuminance(D>>8));if(B<N){const L=k(C,j,N);return B>b(M,h.relativeLuminance(L>>8))?D:L}return D}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]},S.toColor=function(C,j,N,M){return{css:y.toCss(C,j,N,M),rgba:y.toRgba(C,j,N,M)}}})(d||(n.rgba=d={})),n.toPaddedHex=f,n.contrastRatio=b},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const c=i(844),u=i(2585),l=i(4348),g=i(7866),_=i(744),y=i(7302),x=i(6975),a=i(8460),h=i(1753),d=i(1480),f=i(7994),b=i(9282),S=i(5435),k=i(5981),E=i(2660);let C=!1;class j extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((M=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(M.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(M){for(const T in M)this.optionsService.options[T]=M[T]}constructor(M){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new y.OptionsService(M)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(x.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(M,T){this._writeBuffer.write(M,T)}writeSync(M,T){this._logService.logLevel<=u.LogLevelEnum.WARN&&!C&&(this._logService.warn("writeSync is unreliable and will be removed soon."),C=!0),this._writeBuffer.writeSync(M,T)}resize(M,T){isNaN(M)||isNaN(T)||(M=Math.max(M,_.MINIMUM_COLS),T=Math.max(T,_.MINIMUM_ROWS),this._bufferService.resize(M,T))}scroll(M,T=!1){this._bufferService.scroll(M,T)}scrollLines(M,T,D){this._bufferService.scrollLines(M,T,D)}scrollPages(M){this.scrollLines(M*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(M){const T=M-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(M,T){return this._inputHandler.registerEscHandler(M,T)}registerDcsHandler(M,T){return this._inputHandler.registerDcsHandler(M,T)}registerCsiHandler(M,T){return this._inputHandler.registerCsiHandler(M,T)}registerOscHandler(M,T){return this._inputHandler.registerOscHandler(M,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let M=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?M=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(M=!0),M?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const M=[];M.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),M.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const T of M)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===i)return void this._listeners.splice(c,1)}}})),this._event}fire(i,c){const u=[];for(let l=0;l<this._listeners.length;l++)u.push(this._listeners[l]);for(let l=0;l<u.length;l++)u[l].call(void 0,i,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,c){return i((u=>c.fire(u)))}},5435:function(v,n,i){var c=this&&this.__decorate||function(z,A,P,O){var I,U=arguments.length,X=U<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,P):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(z,A,P,O);else for(var $=z.length-1;$>=0;$--)(I=z[$])&&(X=(U<3?I(X):U>3?I(A,P,X):I(A,P))||X);return U>3&&X&&Object.defineProperty(A,P,X),X},u=this&&this.__param||function(z,A){return function(P,O){A(P,O,z)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const l=i(2584),g=i(7116),_=i(2015),y=i(844),x=i(482),a=i(8437),h=i(8460),d=i(643),f=i(511),b=i(3734),S=i(2585),k=i(6242),E=i(6351),C=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function M(z,A){if(z>24)return A.setWinLines||!1;switch(z){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var T;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,O,I,U,X,$,V,q=new _.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=O,this._logService=I,this._optionsService=U,this._oscLinkService=X,this._coreMouseService=$,this._unicodeService=V,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new L(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._parser.setCsiHandlerFallback(((R,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:H.toArray()})})),this._parser.setEscHandlerFallback((R=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})})),this._parser.setExecuteHandlerFallback((R=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})})),this._parser.setOscHandlerFallback(((R,H,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:H,data:K})})),this._parser.setDcsHandlerFallback(((R,H,K)=>{H==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:H,payload:K})})),this._parser.setPrintHandler(((R,H,K)=>this.print(R,H,K))),this._parser.registerCsiHandler({final:"@"},(R=>this.insertChars(R))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R=>this.scrollLeft(R))),this._parser.registerCsiHandler({final:"A"},(R=>this.cursorUp(R))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R=>this.scrollRight(R))),this._parser.registerCsiHandler({final:"B"},(R=>this.cursorDown(R))),this._parser.registerCsiHandler({final:"C"},(R=>this.cursorForward(R))),this._parser.registerCsiHandler({final:"D"},(R=>this.cursorBackward(R))),this._parser.registerCsiHandler({final:"E"},(R=>this.cursorNextLine(R))),this._parser.registerCsiHandler({final:"F"},(R=>this.cursorPrecedingLine(R))),this._parser.registerCsiHandler({final:"G"},(R=>this.cursorCharAbsolute(R))),this._parser.registerCsiHandler({final:"H"},(R=>this.cursorPosition(R))),this._parser.registerCsiHandler({final:"I"},(R=>this.cursorForwardTab(R))),this._parser.registerCsiHandler({final:"J"},(R=>this.eraseInDisplay(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R=>this.eraseInDisplay(R,!0))),this._parser.registerCsiHandler({final:"K"},(R=>this.eraseInLine(R,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R=>this.eraseInLine(R,!0))),this._parser.registerCsiHandler({final:"L"},(R=>this.insertLines(R))),this._parser.registerCsiHandler({final:"M"},(R=>this.deleteLines(R))),this._parser.registerCsiHandler({final:"P"},(R=>this.deleteChars(R))),this._parser.registerCsiHandler({final:"S"},(R=>this.scrollUp(R))),this._parser.registerCsiHandler({final:"T"},(R=>this.scrollDown(R))),this._parser.registerCsiHandler({final:"X"},(R=>this.eraseChars(R))),this._parser.registerCsiHandler({final:"Z"},(R=>this.cursorBackwardTab(R))),this._parser.registerCsiHandler({final:"`"},(R=>this.charPosAbsolute(R))),this._parser.registerCsiHandler({final:"a"},(R=>this.hPositionRelative(R))),this._parser.registerCsiHandler({final:"b"},(R=>this.repeatPrecedingCharacter(R))),this._parser.registerCsiHandler({final:"c"},(R=>this.sendDeviceAttributesPrimary(R))),this._parser.registerCsiHandler({prefix:">",final:"c"},(R=>this.sendDeviceAttributesSecondary(R))),this._parser.registerCsiHandler({final:"d"},(R=>this.linePosAbsolute(R))),this._parser.registerCsiHandler({final:"e"},(R=>this.vPositionRelative(R))),this._parser.registerCsiHandler({final:"f"},(R=>this.hVPosition(R))),this._parser.registerCsiHandler({final:"g"},(R=>this.tabClear(R))),this._parser.registerCsiHandler({final:"h"},(R=>this.setMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R=>this.setModePrivate(R))),this._parser.registerCsiHandler({final:"l"},(R=>this.resetMode(R))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R=>this.resetModePrivate(R))),this._parser.registerCsiHandler({final:"m"},(R=>this.charAttributes(R))),this._parser.registerCsiHandler({final:"n"},(R=>this.deviceStatus(R))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R=>this.deviceStatusPrivate(R))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R=>this.softReset(R))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R=>this.setCursorStyle(R))),this._parser.registerCsiHandler({final:"r"},(R=>this.setScrollRegion(R))),this._parser.registerCsiHandler({final:"s"},(R=>this.saveCursor(R))),this._parser.registerCsiHandler({final:"t"},(R=>this.windowOptions(R))),this._parser.registerCsiHandler({final:"u"},(R=>this.restoreCursor(R))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R=>this.insertColumns(R))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R=>this.deleteColumns(R))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R=>this.selectProtected(R))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R=>this.requestMode(R,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R=>this.requestMode(R,!1))),this._parser.setExecuteHandler(l.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(l.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(l.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(l.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(l.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(l.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(l.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(l.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(l.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((R=>(this.setTitle(R),this.setIconName(R),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((R=>this.setIconName(R)))),this._parser.registerOscHandler(2,new k.OscHandler((R=>this.setTitle(R)))),this._parser.registerOscHandler(4,new k.OscHandler((R=>this.setOrReportIndexedColor(R)))),this._parser.registerOscHandler(8,new k.OscHandler((R=>this.setHyperlink(R)))),this._parser.registerOscHandler(10,new k.OscHandler((R=>this.setOrReportFgColor(R)))),this._parser.registerOscHandler(11,new k.OscHandler((R=>this.setOrReportBgColor(R)))),this._parser.registerOscHandler(12,new k.OscHandler((R=>this.setOrReportCursorColor(R)))),this._parser.registerOscHandler(104,new k.OscHandler((R=>this.restoreIndexedColor(R)))),this._parser.registerOscHandler(110,new k.OscHandler((R=>this.restoreFgColor(R)))),this._parser.registerOscHandler(111,new k.OscHandler((R=>this.restoreBgColor(R)))),this._parser.registerOscHandler(112,new k.OscHandler((R=>this.restoreCursorColor(R)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const R in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},(()=>this.selectCharset("("+R))),this._parser.registerEscHandler({intermediates:")",final:R},(()=>this.selectCharset(")"+R))),this._parser.registerEscHandler({intermediates:"*",final:R},(()=>this.selectCharset("*"+R))),this._parser.registerEscHandler({intermediates:"+",final:R},(()=>this.selectCharset("+"+R))),this._parser.registerEscHandler({intermediates:"-",final:R},(()=>this.selectCharset("-"+R))),this._parser.registerEscHandler({intermediates:".",final:R},(()=>this.selectCharset("."+R))),this._parser.registerEscHandler({intermediates:"/",final:R},(()=>this.selectCharset("/"+R)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((R=>(this._logService.error("Parsing error: ",R),R))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((R,H)=>this.requestStatusString(R,H))))}_preserveStack(A,P,O,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=O,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([A,new Promise(((P,O)=>setTimeout((()=>O("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,P){let O,I=this._activeBuffer.x,U=this._activeBuffer.y,X=0;const $=this._parseStack.paused;if($){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(O),O;I=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>N&&(X=this._parseStack.position+N)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(V=>String.fromCharCode(V))).join("")}"`),typeof A=="string"?A.split("").map((V=>V.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(A.length,N))),$||this._dirtyRowTracker.clearRange(),A.length>N)for(let V=X;V<A.length;V+=N){const q=V+N<A.length?V+N:A.length,R=typeof A=="string"?this._stringDecoder.decode(A.substring(V,q),this._parseBuffer):this._utf8Decoder.decode(A.subarray(V,q),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,R))return this._preserveStack(I,U,R,V),this._logSlowResolvingAsync(O),O}else if(!$){const V=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,V))return this._preserveStack(I,U,V,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===I&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,O){let I,U;const X=this._charsetService.charset,$=this._optionsService.rawOptions.screenReaderMode,V=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,H=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-P>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=P;W<O;++W){if(I=A[W],U=this._unicodeService.wcwidth(I),I<127&&X){const Q=X[String.fromCharCode(I)];Q&&(I=Q.charCodeAt(0))}if($&&this._onA11yChar.fire((0,x.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=V){if(q){for(;this._activeBuffer.x<V;)K.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=V-1,U===2)continue}if(R&&(K.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(H),H),K.getWidth(V-1)===2&&K.setCellFromCodePoint(V-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,I,U,H.fg,H.bg,H.extended),U>0)for(;--U;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,I):K.addCodepointToCell(this._activeBuffer.x-2,I)}O-P>0&&(K.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<V&&O-P>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,P){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,P):this._parser.registerCsiHandler(A,(O=>!M(O.params[0],this._optionsService.rawOptions.windowOptions)||P(O)))}registerDcsHandler(A,P){return this._parser.registerDcsHandler(A,new E.DcsHandler(P))}registerEscHandler(A,P){return this._parser.registerEscHandler(A,P)}registerOscHandler(A,P){return this._parser.registerOscHandler(A,new k.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=A,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+P)}cursorUp(A){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const P=A.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const P=A.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,P,O,I=!1,U=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);X.replaceCells(P,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),I&&(X.isWrapped=!1)}_resetBufferLine(A,P=!1){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);O&&(O.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),O.isWrapped=!1)}eraseInDisplay(A,P=!1){let O;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);O<this._bufferService.rows;O++)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(O);break;case 1:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(O+1).isWrapped=!1);O--;)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(O=this._bufferService.rows,this._dirtyRowTracker.markDirty(O-1);O--;)this._resetBufferLine(O,P);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(A,P=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;P--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y;let I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;P--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let P=A.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let P=A.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);I.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const P=A.params[0]||1,O=new Uint32Array(P);for(let I=0;I<P;++I)O[I]=this._parser.precedingCodepoint;return this.print(O,0,O.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,P){const O=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:U}=this._coreMouseService,X=this._coreService,{buffers:$,cols:V}=this._bufferService,{active:q,alt:R}=$,H=this._optionsService.rawOptions,K=oe=>oe?1:2,W=A.params[0];return Q=W,J=P?W===2?4:W===4?K(X.modes.insertMode):W===12?3:W===20?K(H.convertEol):0:W===1?K(O.applicationCursorKeys):W===3?H.windowOptions.setWinLines?V===80?2:V===132?1:0:0:W===6?K(O.origin):W===7?K(O.wraparound):W===8?3:W===9?K(I==="X10"):W===12?K(H.cursorBlink):W===25?K(!X.isCursorHidden):W===45?K(O.reverseWraparound):W===66?K(O.applicationKeypad):W===67?4:W===1e3?K(I==="VT200"):W===1002?K(I==="DRAG"):W===1003?K(I==="ANY"):W===1004?K(O.sendFocus):W===1005?4:W===1006?K(U==="SGR"):W===1015?4:W===1016?K(U==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?K(q===R):W===2004?K(O.bracketedPasteMode):0,X.triggerDataEvent(`${l.C0.ESC}[${P?"":"?"}${Q};${J}$y`),!0;var Q,J}_updateAttrColor(A,P,O,I,U){return P===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([O,I,U])):P===5&&(A&=-50331904,A|=33554432|255&O),A}_extractColor(A,P,O){const I=[0,0,-1,0,0,0];let U=0,X=0;do{if(I[X+U]=A.params[P+X],A.hasSubParams(P+X)){const $=A.getSubParams(P+X);let V=0;do I[1]===5&&(U=1),I[X+V+1+U]=$[V];while(++V<$.length&&V+X+1+U<I.length);break}if(I[1]===5&&X+U>=2||I[1]===2&&X+U>=5)break;I[1]&&(U=1)}while(++X+P<A.length&&X+U<I.length);for(let $=2;$<I.length;++$)I[$]===-1&&(I[$]=0);switch(I[0]){case 38:O.fg=this._updateAttrColor(O.fg,I[1],I[3],I[4],I[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,I[1],I[3],I[4],I[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,I[1],I[3],I[4],I[5])}return X}_processUnderline(A,P){P.extended=P.extended.clone(),(!~A||A>5)&&(A=1),P.extended.underlineStyle=A,P.fg|=268435456,A===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=A.length;let O;const I=this._curAttrData;for(let U=0;U<P;U++)O=A.params[U],O>=30&&O<=37?(I.fg&=-50331904,I.fg|=16777216|O-30):O>=40&&O<=47?(I.bg&=-50331904,I.bg|=16777216|O-40):O>=90&&O<=97?(I.fg&=-50331904,I.fg|=16777224|O-90):O>=100&&O<=107?(I.bg&=-50331904,I.bg|=16777224|O-100):O===0?this._processSGR0(I):O===1?I.fg|=134217728:O===3?I.bg|=67108864:O===4?(I.fg|=268435456,this._processUnderline(A.hasSubParams(U)?A.getSubParams(U)[0]:1,I)):O===5?I.fg|=536870912:O===7?I.fg|=67108864:O===8?I.fg|=1073741824:O===9?I.fg|=2147483648:O===2?I.bg|=134217728:O===21?this._processUnderline(2,I):O===22?(I.fg&=-134217729,I.bg&=-134217729):O===23?I.bg&=-67108865:O===24?(I.fg&=-268435457,this._processUnderline(0,I)):O===25?I.fg&=-536870913:O===27?I.fg&=-67108865:O===28?I.fg&=-1073741825:O===29?I.fg&=2147483647:O===39?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):O===49?(I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?U+=this._extractColor(A,U,I):O===53?I.bg|=1073741824:O===55?I.bg&=-1073741825:O===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):O===100?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",O);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${P};${O}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const P=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${P};${O}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const P=A.params[0]||1;switch(P){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const O=P%2==1;return this._optionsService.options.cursorBlink=O,!0}setScrollRegion(A){const P=A.params[0]||1;let O;return(A.length<2||(O=A.params[1])>this._bufferService.rows||O===0)&&(O=this._bufferService.rows),O>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=O-1,this._setCursor(0,0)),!0}windowOptions(A){if(!M(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const P=[],O=A.split(";");for(;O.length>1;){const I=O.shift(),U=O.shift();if(/^\d+$/.exec(I)){const X=parseInt(I);if(F(X))if(U==="?")P.push({type:0,index:X});else{const $=(0,C.parseColor)(U);$&&P.push({type:1,index:X,color:$})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(A){const P=A.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(A,P){this._getCurrentLinkId()&&this._finishHyperlink();const O=A.split(":");let I;const U=O.findIndex((X=>X.startsWith("id=")));return U!==-1&&(I=O[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,P){const O=A.split(";");for(let I=0;I<O.length&&!(P>=this._specialColors.length);++I,++P)if(O[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const U=(0,C.parseColor)(O[I]);U&&this._onColor.fire([{type:1,index:this._specialColors[P],color:U}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const P=[],O=A.split(";");for(let I=0;I<O.length;++I)if(/^\d+$/.exec(O[I])){const U=parseInt(O[I]);F(U)&&P.push({type:2,index:U})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(j[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const O=this._activeBuffer.ybase+this._activeBuffer.y+P,I=this._activeBuffer.lines.get(O);I&&(I.fill(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const O=this._bufferService.buffer,I=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${U}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${O.scrollTop+1};${O.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}n.InputHandler=B;let L=class{constructor(z){this._bufferService=z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(z){z<this.start?this.start=z:z>this.end&&(this.end=z)}markRangeDirty(z,A){z>A&&(D=z,z=A,A=D),z<this.start&&(this.start=z),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(z){return 0<=z&&z<256}L=c([u(0,S.IBufferService)],L)},844:(v,n)=>{function i(c){for(const u of c)u.dispose();c.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const u=this._disposables.indexOf(c);u!==-1&&this._disposables.splice(u,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var u;this._isDisposed||c===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},n.toDisposable=function(c){return{dispose:c}},n.disposeArray=i,n.getDisposeArrayDisposable=function(c){return{dispose:()=>i(c)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(u,l,g){this._data[u]||(this._data[u]={}),this._data[u][l]=g}get(u,l){return this._data[u]?this._data[u][l]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(c,u,l,g,_){this._data.get(c,u)||this._data.set(c,u,new i),this._data.get(c,u).set(l,g,_)}get(c,u,l,g){var _;return(_=this._data.get(c,u))===null||_===void 0?void 0:_.get(l,g)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,c=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const u=i.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),n.isIpad=c==="iPad",n.isIphone=c==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),n.isLinux=c.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(i=this._search(this._getKey(c)),this._array.splice(i,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const u=this._getKey(c);if(u===void 0||(i=this._search(u),i===-1)||this._getKey(this._array[i])!==u)return!1;do if(this._array[i]===c)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===u);return!1}*getKeyIterator(c){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===c)}forEachByKey(c,u){if(this._array.length!==0&&(i=this._search(c),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===c))do u(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===c)}values(){return[...this._array].values()}_search(c){let u=0,l=this._array.length-1;for(;l>=u;){let g=u+l>>1;const _=this._getKey(this._array[g]);if(_>c)l=g-1;else{if(!(_<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}u=g+1}}return u}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const c=i(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,x=0,a=_.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),x=Math.max(y,x),h=_.timeRemaining(),1.5*x>h)return a-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-y))}ms`),void this._start();a=h}this.clear()}}class l extends u{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}n.PriorityTaskQueue=l,n.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const c=i(643);n.updateWindowsModeWrappedState=function(u){const l=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=l?.get(u.cols-1),_=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);_&&g&&(_.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new i;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}n.AttributeData=i;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,g=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=g}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=c},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const c=i(6349),u=i(7226),l=i(3734),g=i(8437),_=i(4634),y=i(511),x=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(d,f,b){this._hasScrollback=d,this._optionsService=f,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new l.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new l.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let C=0;C<this.lines.length;C++)S+=+this.lines.get(C).resize(d,b);let E=0;if(this._rows<f)for(let C=this._rows;C<f;C++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,b)));else for(let C=this._rows;C>f;C--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const C=this.lines.length-k;C>0&&(this.lines.trimStart(C),this.ybase=Math.max(this.ybase-C,0),this.ydisp=Math.max(this.ydisp-C,0),this.savedY=Math.max(this.savedY-C,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(d,b);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const S=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,f,S.countRemoved)}}_reflowLargerAdjustViewport(d,f,b){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let C=this.lines.get(E);if(!C||!C.isWrapped&&C.getTrimmedLength()<=d)continue;const j=[C];for(;C.isWrapped&&E>0;)C=this.lines.get(--E),j.unshift(C);const N=this.ybase+this.y;if(N>=E&&N<E+j.length)continue;const M=j[j.length-1].getTrimmedLength(),T=(0,_.reflowSmallerGetNewLineLengths)(j,this._cols,d),D=T.length-j.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const L=[];for(let I=0;I<D;I++){const U=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);L.push(U)}L.length>0&&(S.push({start:E+j.length+k,newLines:L}),k+=L.length),j.push(...L);let F=T.length-1,z=T[F];z===0&&(F--,z=T[F]);let A=j.length-D-1,P=M;for(;A>=0;){const I=Math.min(P,z);if(j[F]===void 0)break;if(j[F].copyCellsFrom(j[A],P-I,z-I,I,!0),z-=I,z===0&&(F--,z=T[F]),P-=I,P===0){A--;const U=Math.max(A,0);P=(0,_.getWrappedLineTrimmedLength)(j,U,this._cols)}}for(let I=0;I<j.length;I++)T[I]<d&&j[I].setCell(T[I],b);let O=D-B;for(;O-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(S.length>0){const E=[],C=[];for(let F=0;F<this.lines.length;F++)C.push(this.lines.get(F));const j=this.lines.length;let N=j-1,M=0,T=S[M];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let F=Math.min(this.lines.maxLength-1,j+k-1);F>=0;F--)if(T&&T.start>N+D){for(let z=T.newLines.length-1;z>=0;z--)this.lines.set(F--,T.newLines[z]);F++,E.push({index:N+1,amount:T.newLines.length}),D+=T.newLines.length,T=S[++M]}else this.lines.set(F,C[N--]);let B=0;for(let F=E.length-1;F>=0;F--)E[F].index+=B,this.lines.onInsertEmitter.fire(E[F]),B+=E[F].amount;const L=Math.max(0,j+k-this.lines.maxLength);L>0&&this.lines.onTrimEmitter.fire(L)}}translateBufferLineToString(d,f,b=0,S){const k=this.lines.get(d);return k?k.translateToString(f,b,S):""}getWrappedRangeForLine(d){let f=d,b=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new a.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const c=i(3734),u=i(511),l=i(643),g=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let _=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||u.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],d=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,h){this._data[3*a+1]=h[l.CHAR_DATA_ATTR_INDEX],h[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return _=3*a,h.content=this._data[_+0],h.fg=this._data[_+1],h.bg=this._data[_+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,d,f,b,S){268435456&b&&(this._extendedAttrs[a]=S),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*a+0]=d)}insertCells(a,h,d,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs),h<this.length-a){const b=new u.CellData;for(let S=this.length-a-h-1;S>=0;--S)this.setCell(a+h+S,this.loadCell(a+S,b));for(let S=0;S<h;++S)this.setCell(a+S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs)}deleteCells(a,h,d,f){if(a%=this.length,h<this.length-a){const b=new u.CellData;for(let S=0;S<this.length-a-h;++S)this.setCell(a+S,this.loadCell(a+h+S,b));for(let S=this.length-h;S<this.length;++S)this.setCell(S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs)}replaceCells(a,h,d,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new c.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,d)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let S=0;S<f.length;S++){const k=parseInt(f[S],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let S=0;S<b.length;S++){const k=parseInt(b[S],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new y(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,d,f,b){const S=a._data;if(b)for(let E=f-1;E>=0;E--){for(let C=0;C<3;C++)this._data[3*(d+E)+C]=S[3*(h+E)+C];268435456&S[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let C=0;C<3;C++)this._data[3*(d+E)+C]=S[3*(h+E)+C];268435456&S[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const C=parseInt(k[E],10);C>=h&&(this._combined[C-h+d]=a._combined[C])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const b=this._data[3*h+0],S=2097151&b;f+=2097152&b?this._combined[h]:S?(0,g.stringFromCodePoint)(S):l.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}n.BufferLine=y},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,c){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return c*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(c,u,l){if(u===c.length-1)return c[u].getTrimmedLength();const g=!c[u].hasContent(l-1)&&c[u].getWidth(l-1)===1,_=c[u+1].getWidth(0)===2;return g&&_?l-1:l}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(c,u,l,g,_){const y=[];for(let x=0;x<c.length-1;x++){let a=x,h=c.get(++a);if(!h.isWrapped)continue;const d=[c.get(x)];for(;a<c.length&&h.isWrapped;)d.push(h),h=c.get(++a);if(g>=x&&g<a){x+=d.length-1;continue}let f=0,b=i(d,f,u),S=1,k=0;for(;S<d.length;){const C=i(d,S,u),j=C-k,N=l-b,M=Math.min(j,N);d[f].copyCellsFrom(d[S],k,b,M,!1),b+=M,b===l&&(f++,b=0),k+=M,k===C&&(S++,k=0),b===0&&f!==0&&d[f-1].getWidth(l-1)===2&&(d[f].copyCellsFrom(d[f-1],l-1,b++,1,!1),d[f-1].setCell(l-1,_))}d[f].replaceCells(b,l,_);let E=0;for(let C=d.length-1;C>0&&(C>f||d[C].getTrimmedLength()===0);C--)E++;E>0&&(y.push(x+d.length-E),y.push(E)),x+=d.length-1}return y},n.reflowLargerCreateNewLayout=function(c,u){const l=[];let g=0,_=u[g],y=0;for(let x=0;x<c.length;x++)if(_===x){const a=u[++g];c.onDeleteEmitter.fire({index:x-y,amount:a}),x+=a-1,y+=a,_=u[++g]}else l.push(x);return{layout:l,countRemoved:y}},n.reflowLargerApplyNewLayout=function(c,u){const l=[];for(let g=0;g<u.length;g++)l.push(c.get(u[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=u.length},n.reflowSmallerGetNewLineLengths=function(c,u,l){const g=[],_=c.map(((h,d)=>i(c,d,u))).reduce(((h,d)=>h+d));let y=0,x=0,a=0;for(;a<_;){if(_-a<l){g.push(_-a);break}y+=l;const h=i(c,x,u);y>h&&(y-=h,x++);const d=c[x].getWidth(y-1)===2;d&&y--;const f=d?l-1:l;g.push(f),a+=f}return g},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const c=i(8460),u=i(844),l=i(9092);class g extends u.Disposable{constructor(y,x){super(),this._optionsService=y,this._bufferService=x,this._onBufferActivate=this.register(new c.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,x){this._normal.resize(y,x),this._alt.resize(y,x),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}n.BufferSet=g},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const c=i(482),u=i(643),l=i(3734);class g extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const x=new g;return x.setFromCharData(y),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(y[u.CHAR_DATA_CHAR_INDEX].length===2){const a=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=y[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=g},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const c=i(8460),u=i(844);class l{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}n.Marker=l,l._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,c,u;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
|
|
26
|
+
`,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""})(i||(n.C0=i={})),(function(l){l.PAD="",l.HOP="",l.BPH="",l.NBH="",l.IND="",l.NEL="
",l.SSA="",l.ESA="",l.HTS="",l.HTJ="",l.VTS="",l.PLD="",l.PLU="",l.RI="",l.SS2="",l.SS3="",l.DCS="",l.PU1="",l.PU2="",l.STS="",l.CCH="",l.MW="",l.SPA="",l.EPA="",l.SOS="",l.SGCI="",l.SCI="",l.CSI="",l.ST="",l.OSC="",l.PM="",l.APC=""})(c||(n.C1=c={})),(function(l){l.ST=`${i.ESC}\\`})(u||(n.C1_ESCAPED=u={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const c=i(2584),u={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(l,g,_,y){const x={type:0,cancel:!1,key:void 0},a=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?x.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?x.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?x.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(x.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){x.key=c.C0.ESC+c.C0.DEL;break}x.key=c.C0.DEL;break;case 9:if(l.shiftKey){x.key=c.C0.ESC+"[Z";break}x.key=c.C0.HT,x.cancel=!0;break;case 13:x.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,x.cancel=!0;break;case 27:x.key=c.C0.ESC,l.altKey&&(x.key=c.C0.ESC+c.C0.ESC),x.cancel=!0;break;case 37:if(l.metaKey)break;a?(x.key=c.C0.ESC+"[1;"+(a+1)+"D",x.key===c.C0.ESC+"[1;3D"&&(x.key=c.C0.ESC+(_?"b":"[1;5D"))):x.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;a?(x.key=c.C0.ESC+"[1;"+(a+1)+"C",x.key===c.C0.ESC+"[1;3C"&&(x.key=c.C0.ESC+(_?"f":"[1;5C"))):x.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;a?(x.key=c.C0.ESC+"[1;"+(a+1)+"A",_||x.key!==c.C0.ESC+"[1;3A"||(x.key=c.C0.ESC+"[1;5A")):x.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;a?(x.key=c.C0.ESC+"[1;"+(a+1)+"B",_||x.key!==c.C0.ESC+"[1;3B"||(x.key=c.C0.ESC+"[1;5B")):x.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(x.key=c.C0.ESC+"[2~");break;case 46:x.key=a?c.C0.ESC+"[3;"+(a+1)+"~":c.C0.ESC+"[3~";break;case 36:x.key=a?c.C0.ESC+"[1;"+(a+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:x.key=a?c.C0.ESC+"[1;"+(a+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?x.type=2:l.ctrlKey?x.key=c.C0.ESC+"[5;"+(a+1)+"~":x.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?x.type=3:l.ctrlKey?x.key=c.C0.ESC+"[6;"+(a+1)+"~":x.key=c.C0.ESC+"[6~";break;case 112:x.key=a?c.C0.ESC+"[1;"+(a+1)+"P":c.C0.ESC+"OP";break;case 113:x.key=a?c.C0.ESC+"[1;"+(a+1)+"Q":c.C0.ESC+"OQ";break;case 114:x.key=a?c.C0.ESC+"[1;"+(a+1)+"R":c.C0.ESC+"OR";break;case 115:x.key=a?c.C0.ESC+"[1;"+(a+1)+"S":c.C0.ESC+"OS";break;case 116:x.key=a?c.C0.ESC+"[15;"+(a+1)+"~":c.C0.ESC+"[15~";break;case 117:x.key=a?c.C0.ESC+"[17;"+(a+1)+"~":c.C0.ESC+"[17~";break;case 118:x.key=a?c.C0.ESC+"[18;"+(a+1)+"~":c.C0.ESC+"[18~";break;case 119:x.key=a?c.C0.ESC+"[19;"+(a+1)+"~":c.C0.ESC+"[19~";break;case 120:x.key=a?c.C0.ESC+"[20;"+(a+1)+"~":c.C0.ESC+"[20~";break;case 121:x.key=a?c.C0.ESC+"[21;"+(a+1)+"~":c.C0.ESC+"[21~";break;case 122:x.key=a?c.C0.ESC+"[23;"+(a+1)+"~":c.C0.ESC+"[23~";break;case 123:x.key=a?c.C0.ESC+"[24;"+(a+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(_&&!y||!l.altKey||l.metaKey)!_||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?x.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(x.key=c.C0.US),l.key==="@"&&(x.key=c.C0.NUL)):l.keyCode===65&&(x.type=1);else{const h=u[l.keyCode],d=h?.[l.shiftKey?1:0];if(d)x.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const f=l.ctrlKey?l.keyCode-64:l.keyCode+32;let b=String.fromCharCode(f);l.shiftKey&&(b=b.toUpperCase()),x.key=c.C0.ESC+b}else if(l.keyCode===32)x.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let f=l.code.slice(3,4);l.shiftKey||(f=f.toLowerCase()),x.key=c.C0.ESC+f,x.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?x.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?x.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?x.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?x.key=c.C0.DEL:l.keyCode===219?x.key=c.C0.ESC:l.keyCode===220?x.key=c.C0.FS:l.keyCode===221&&(x.key=c.C0.GS)}return x}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,c=0,u=i.length){let l="";for(let g=c;g<u;++g){let _=i[g];_>65535?(_-=65536,l+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):l+=String.fromCharCode(_)}return l},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,c){const u=i.length;if(!u)return 0;let l=0,g=0;if(this._interim){const _=i.charCodeAt(g++);56320<=_&&_<=57343?c[l++]=1024*(this._interim-55296)+_-56320+65536:(c[l++]=this._interim,c[l++]=_),this._interim=0}for(let _=g;_<u;++_){const y=i.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=u)return this._interim=y,l;const x=i.charCodeAt(_);56320<=x&&x<=57343?c[l++]=1024*(y-55296)+x-56320+65536:(c[l++]=y,c[l++]=x)}else y!==65279&&(c[l++]=y)}return l}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,c){const u=i.length;if(!u)return 0;let l,g,_,y,x=0,a=0,h=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)S<<=6,S|=k;const C=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=C-E;for(;h<j;){if(h>=u)return 0;if(k=i[h++],(192&k)!=128){h--,b=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}b||(C===2?S<128?h--:c[x++]=S:C===3?S<2048||S>=55296&&S<=57343||S===65279||(c[x++]=S):S<65536||S>1114111||(c[x++]=S)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(l=i[f])||128&(g=i[f+1])||128&(_=i[f+2])||128&(y=i[f+3]));)c[x++]=l,c[x++]=g,c[x++]=_,c[x++]=y,f+=4;if(l=i[f++],l<128)c[x++]=l;else if((224&l)==192){if(f>=u)return this.interim[0]=l,x;if(g=i[f++],(192&g)!=128){f--;continue}if(a=(31&l)<<6|63&g,a<128){f--;continue}c[x++]=a}else if((240&l)==224){if(f>=u)return this.interim[0]=l,x;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=l,this.interim[1]=g,x;if(_=i[f++],(192&_)!=128){f--;continue}if(a=(15&l)<<12|(63&g)<<6|63&_,a<2048||a>=55296&&a<=57343||a===65279)continue;c[x++]=a}else if((248&l)==240){if(f>=u)return this.interim[0]=l,x;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=l,this.interim[1]=g,x;if(_=i[f++],(192&_)!=128){f--;continue}if(f>=u)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=_,x;if(y=i[f++],(192&y)!=128){f--;continue}if(a=(7&l)<<18|(63&g)<<12|(63&_)<<6|63&y,a<65536||a>1114111)continue;c[x++]=a}}return x}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],c=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let u;n.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let l=0;l<i.length;++l)u.fill(0,i[l][0],i[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?u[l]:(function(g,_){let y,x=0,a=_.length-1;if(g<_[0][0]||g>_[a][1])return!1;for(;a>=x;)if(y=x+a>>1,g>_[y][1])x=y+1;else{if(!(g<_[y][0]))return!0;a=y-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const c=i(8460),u=i(844);class l extends u.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const x=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,y);if(h){const f=b=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(x,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=l},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c=/^[\da-f]+$/;function u(l,g){const _=l.toString(16),y=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}n.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=i.exec(g);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,y=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(g.slice(_*x,_*x+_),16);y[x]=_===1?a<<4:_===2?a:_===3?a>>4:a>>8}return y}},n.toRgbString=function(l,g=16){const[_,y,x]=l;return`rgb:${u(_,g)}/${u(y,g)}/${u(x,g)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const c=i(482),u=i(8742),l=i(5770),g=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,x){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(x),{dispose:()=>{const h=a.indexOf(x);h!==-1&&a.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,x){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(y,x,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,x,a);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,x,a))}unhook(y,x=!0){if(this._active.length){let a=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(y),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const _=new u.Params;_.addParam(0),n.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,x,a){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,x,a),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let x=!1;if(this._hitLimit)x=!1;else if(y&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=_,this._data="",this._hitLimit=!1,a)));return this._params=_,this._data="",this._hitLimit=!1,x}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const c=i(844),u=i(8742),l=i(6242),g=i(6351);class _{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,b){this.table[d<<8|h]=f<<4|b}addMany(h,d,f,b){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=f<<4|b}}n.TransitionTable=_;const y=160;n.VT500_TRANSITION_TABLE=(function(){const a=new _(4095),h=Array.apply(null,Array(256)).map(((E,C)=>C)),d=(E,C)=>h.slice(E,C),f=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const S=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),S)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(y,0,2,0),a.add(y,8,5,8),a.add(y,6,0,6),a.add(y,11,0,11),a.add(y,13,13,13),a})();class x extends c.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,b)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<h.intermediates.length;++S){const k=h.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(d[0]>b||b>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=b,f}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const b=this._escHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const b=this._csiHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,d,f,b,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=S}parse(h,d,f){let b,S=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const C=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(b=C[j](this._params),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(b=C[j](),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=h[this._parseStack.chunkPos],b=this._oscParser.end(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let C=E;C<d;++C){switch(S=h[C],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let D=C+1;;++D){if(D>=d||(S=h[D])<32||S>126&&S<y){this._printHandler(h,C,D),C=D-1;break}if(++D>=d||(S=h[D])<32||S>126&&S<y){this._printHandler(h,C,D),C=D-1;break}if(++D>=d||(S=h[D])<32||S>126&&S<y){this._printHandler(h,C,D),C=D-1;break}if(++D>=d||(S=h[D])<32||S>126&&S<y){this._printHandler(h,C,D),C=D-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:C,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|S];let N=j?j.length-1:-1;for(;N>=0&&(b=j[N](this._params),b!==!0);N--)if(b instanceof Promise)return this._preserveStack(3,j,N,k,C),b;N<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++C<d&&(S=h[C])>47&&S<60);C--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const M=this._escHandlers[this._collect<<8|S];let T=M?M.length-1:-1;for(;T>=0&&(b=M[T](),b!==!0);T--)if(b instanceof Promise)return this._preserveStack(4,M,T,k,C),b;T<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let D=C+1;;++D)if(D>=d||(S=h[D])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,C,D),C=D-1;break}break;case 14:if(b=this._dcsParser.unhook(S!==24&&S!==26),b)return this._preserveStack(6,[],0,k,C),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let D=C+1;;D++)if(D>=d||(S=h[D])<32||S>127&&S<y){this._oscParser.put(h,C,D),C=D-1;break}break;case 6:if(b=this._oscParser.end(S!==24&&S!==26),b)return this._preserveStack(5,[],0,k,C),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=x},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const c=i(5770),u=i(482),l=[];n.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(_),{dispose:()=>{const x=y.indexOf(_);x!==-1&&y.splice(x,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,_,y){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(g,_,y);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,_,y))}start(){this.reset(),this._state=1}put(g,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const x=g[_++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&y-_>0&&this._put(g,_,y)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,y=_,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;x>=0&&(y=this._active[x].end(g),y!==!0);x--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,y;x--}for(;x>=0;x--)if(y=this._active[x].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=l,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,_,y){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,_,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,_}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let _=Array.isArray(l[0])?1:0;_<l.length;++_){const y=l[_];if(Array.isArray(y))for(let x=0;x<y.length;++x)g.addSubParam(y[x]);else g.addParam(y)}return g}constructor(l=32,g=32){if(this.maxLength=l,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new c(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let g=0;g<this.length;++g){l.push(this.params[g]);const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&l.push(Array.prototype.slice.call(this._subParams,_,y))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>i?i:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>i?i:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const g=this._subParamsIdx[l]>>8,_=255&this._subParamsIdx[l];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&(l[g]=this._subParams.slice(_,y))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[g-1];_[g-1]=~y?Math.min(10*y+l,i):l}}n.Params=c},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,c){const u={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(u),c.dispose=()=>this._wrappedAddonDispose(u),c.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let c=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===i){c=u;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(c,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const c=i(3785),u=i(511);n.BufferApiView=class{constructor(l,g){this._buffer=l,this.type=g}init(l){return this._buffer=l,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(l){const g=this._buffer.lines.get(l);if(g)return new c.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const c=i(511);n.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,l){if(!(u<0||u>=this._line.length))return l?(this._line.loadCell(u,l),l):this._line.loadCell(u,new c.CellData)}translateToString(u,l,g){return this._line.translateToString(u,l,g)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const c=i(8771),u=i(8460),l=i(844);class g extends l.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=g},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,c){return this._core.registerCsiHandler(i,(u=>c(u.toArray())))}addCsiHandler(i,c){return this.registerCsiHandler(i,c)}registerDcsHandler(i,c){return this._core.registerDcsHandler(i,((u,l)=>c(u,l.toArray())))}addDcsHandler(i,c){return this.registerDcsHandler(i,c)}registerEscHandler(i,c){return this._core.registerEscHandler(i,c)}addEscHandler(i,c){return this.registerEscHandler(i,c)}registerOscHandler(i,c){return this._core.registerOscHandler(i,c)}addOscHandler(i,c){return this.registerOscHandler(i,c)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var c=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const l=i(8460),g=i(844),_=i(5295),y=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let x=n.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=d.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=d.ybase+d.scrollTop,S=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;S===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(S+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=S-b+1;d.lines.shiftElements(b+1,k-1,-1),d.lines.set(S,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=x=c([u(0,y.IOptionsService)],x)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,c){this._charsets[i]=c,this.glevel===i&&(this.charset=c)}}},1753:function(v,n,i){var c=this&&this.__decorate||function(f,b,S,k){var E,C=arguments.length,j=C<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,S,k);else for(var N=f.length-1;N>=0;N--)(E=f[N])&&(j=(C<3?E(j):C>3?E(b,S,j):E(b,S))||j);return C>3&&j&&Object.defineProperty(b,S,j),j},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const l=i(2585),g=i(8460),_=i(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function x(f,b){let S=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(S|=64,S|=f.action):(S|=3&f.button,4&f.button&&(S|=64),8&f.button&&(S|=128),f.action===32?S|=32:f.action!==0||b||(S|=3)),S}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[x(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.x};${f.y}${b}`}};let d=n.CoreMouseService=class extends _.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(h))this.addEncoding(S,h[S]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,b,S){if(S){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};n.CoreMouseService=d=c([u(0,l.IBufferService),u(1,l.ICoreService)],d)},6975:function(v,n,i){var c=this&&this.__decorate||function(d,f,b,S){var k,E=arguments.length,C=E<3?f:S===null?S=Object.getOwnPropertyDescriptor(f,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(d,f,b,S);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(C=(E<3?k(C):E>3?k(f,b,C):k(f,b))||C);return E>3&&C&&Object.defineProperty(f,b,C),C},u=this&&this.__param||function(d,f){return function(b,S){f(b,S,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const l=i(1439),g=i(8460),_=i(844),y=i(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends _.Disposable{constructor(d,f,b){super(),this._bufferService=d,this._logService=f,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(x),this.decPrivateModes=(0,l.clone)(a)}reset(){this.modes=(0,l.clone)(x),this.decPrivateModes=(0,l.clone)(a)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};n.CoreService=h=c([u(0,y.IBufferService),u(1,y.ILogService),u(2,y.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const c=i(8055),u=i(8460),l=i(844),g=i(6106);let _=0,y=0;class x extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new a(d);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,b){var S,k,E;let C=0,j=0;for(const N of this._decorations.getKeyIterator(f))C=(S=N.options.x)!==null&&S!==void 0?S:0,j=C+((k=N.options.width)!==null&&k!==void 0?k:1),d>=C&&d<j&&(!b||((E=N.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&(yield N)}forEachDecorationAtCell(d,f,b,S){this._decorations.forEachByKey(f,(k=>{var E,C,j;_=(E=k.options.x)!==null&&E!==void 0?E:0,y=_+((C=k.options.width)!==null&&C!==void 0?C:1),d>=_&&d<y&&(!b||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&S(k)}))}}n.DecorationService=x;class a extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const c=i(2585),u=i(8343);class l{constructor(..._){this._entries=new Map;for(const[y,x]of _)this.set(y,x)}set(_,y){const x=this._entries.get(_);return this._entries.set(_,y),x}forEach(_){for(const[y,x]of this._entries.entries())_(y,x)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}n.ServiceCollection=l,n.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const y=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),x=[];for(const h of y){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);x.push(d)}const a=y.length>0?y[0].index:_.length;if(_.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${_.length} static arguments`);return new g(..._,...x)}}},7866:function(v,n,i){var c=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const l=i(844),g=i(2585),_={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,x=n.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};n.LogService=x=c([u(0,g.IOptionsService)],x),n.setTraceLogger=function(a){y=a},n.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...b){if(y.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,b);y.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const S=f.apply(this,b);return y.trace(`GlyphRenderer#${f.name} return`,S),S}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const c=i(8460),u=i(844),l=i(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in x)if(h in a)try{const d=x[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((h=>{h===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((h=>{x.indexOf(h)!==-1&&a()}))}_setupOptions(){const x=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:x.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[x]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:n.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=_},2660:function(v,n,i){var c=this&&this.__decorate||function(_,y,x,a){var h,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(_,y,x,a);else for(var b=_.length-1;b>=0;b--)(h=_[b])&&(f=(d<3?h(f):d>3?h(y,x,f):h(y,x))||f);return d>3&&f&&Object.defineProperty(y,x,f),f},u=this&&this.__param||function(_,y){return function(x,a){y(x,a,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const l=i(2585);let g=n.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const b=y.addMarker(y.ybase+y.y),S={data:_,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(S,b))),this._dataByLinkId.set(S.id,S),S.id}const x=_,a=this._getEntryIdKey(x),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const d=y.addMarker(y.ybase+y.y),f={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(_,y){const x=this._dataByLinkId.get(_);if(x&&x.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const x=_.lines.indexOf(y);x!==-1&&(_.lines.splice(x,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};n.OscLinkService=g=c([u(0,l.IBufferService)],g)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",c="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(u){return u[c]||[]},n.createDecorator=function(u){if(n.serviceRegistry.has(u))return n.serviceRegistry.get(u);const l=function(g,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,h){a[i]===a?a[c].push({id:x,index:h}):(a[c]=[{id:x,index:h}],a[i]=a)})(l,g,y)};return l.toString=()=>u,n.serviceRegistry.set(u,l),l}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const c=i(8343);var u;n.IBufferService=(0,c.createDecorator)("BufferService"),n.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),n.ICoreService=(0,c.createDecorator)("CoreService"),n.ICharsetService=(0,c.createDecorator)("CharsetService"),n.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"})(u||(n.LogLevelEnum=u={})),n.ILogService=(0,c.createDecorator)("LogService"),n.IOptionsService=(0,c.createDecorator)("OptionsService"),n.IOscLinkService=(0,c.createDecorator)("OscLinkService"),n.IUnicodeService=(0,c.createDecorator)("UnicodeService"),n.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const c=i(8460),u=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new u.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let g=0;const _=l.length;for(let y=0;y<_;++y){let x=l.charCodeAt(y);if(55296<=x&&x<=56319){if(++y>=_)return g+this.wcwidth(x);const a=l.charCodeAt(y);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(x)}return g}}}},o={};function m(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,m),i.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=m(9042),i=m(3236),c=m(844),u=m(5741),l=m(8285),g=m(7975),_=m(7090),y=["cols","rows"];class x extends c.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],f=(b,S)=>{this._checkReadonlyOptions(b),this._core.options[b]=S};for(const b in this._core.options){const S={get:d.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,S)}}_checkReadonlyOptions(h){if(y.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new l.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,f){this._verifyIntegers(h,d,f),this._core.select(h,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
|
|
27
|
+
`,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=x})(),p})()))})(_i)),_i.exports}var Mm=Am();var Dm=2,Lm=1,Pm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),m=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),v={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,c=o-n,u=m-i-s;return{cols:Math.max(Dm,Math.floor(u/e.css.cell.width)),rows:Math.max(Lm,Math.floor(c/e.css.cell.height))}}};function Om(e={}){const{cwd:s,cols:r,rows:o,onOutput:m,onExit:p}=e,[v,n]=w.useState(null),[i,c]=w.useState(()=>Qt.isConnected()),[u,l]=w.useState(!1),[g,_]=w.useState(!1),[y,x]=w.useState(!1),a=w.useRef({onOutput:m,onExit:p});a.current={onOutput:m,onExit:p};const h=w.useRef(null);h.current=v,w.useEffect(()=>{if(!v)return;const k=Qt.getSocket(),E=()=>{c(!0),l(!1),n(null),x(!0)},C=()=>{c(!1),l(!1)},j=D=>{D.terminalId===v&&a.current.onOutput?.(D.data)},N=D=>{D.terminalId===v&&(l(!1),a.current.onExit?.(D.exitCode),n(null))},M=D=>{D.terminalId===v&&l(!0)},T=D=>{D.terminalId===v&&l(!1)};return k.on("connect",E),k.on("disconnect",C),k.on(ot.TERMINAL_STDOUT,j),k.on(ot.TERMINAL_EXIT,N),k.on(ot.TERMINAL_SUBSCRIBED,M),k.on(ot.TERMINAL_UNSUBSCRIBED,T),c(k.connected),k.connected&&k.emit(vs.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&l(!0)}),()=>{k.off("connect",E),k.off("disconnect",C),k.off(ot.TERMINAL_STDOUT,j),k.off(ot.TERMINAL_EXIT,N),k.off(ot.TERMINAL_SUBSCRIBED,M),k.off(ot.TERMINAL_UNSUBSCRIBED,T),k.emit(vs.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=w.useCallback(async()=>{const k=Qt.getSocket();if(!k.connected)return null;_(!0);try{const E=await ve.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),x(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{_(!1)}},[s,r,o]),f=w.useCallback(async()=>{const k=h.current;if(k){try{await ve.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),l(!1)}},[]),b=w.useCallback(k=>{const E=h.current;if(!E)return;Qt.getSocket().emit(vs.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=w.useCallback((k,E)=>{const C=h.current;if(!C)return;Qt.getSocket().emit(vs.TERMINAL_RESIZE,{terminalId:C,cols:k,rows:E})},[]);return w.useEffect(()=>()=>{const k=h.current;k&&ve.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:u,isCreating:g,needsRecreate:y,create:d,destroy:f,sendInput:b,resize:S}}const Im={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Bm=ae.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:m}){const p=w.useRef(null),v=w.useRef(null),n=w.useRef(null),i=w.useRef(!1),{terminalId:c,isAttached:u,needsRecreate:l,create:g,sendInput:_,resize:y}=Om({cwd:s,onOutput:w.useCallback(x=>{v.current?.write(x)},[]),onExit:w.useCallback(x=>{v.current?.writeln(`\r
|
|
28
|
+
\x1B[90m[Process exited with code ${x}]\x1B[0m`),o?.(x)},[o])});return w.useEffect(()=>{if(!l)return;const x=v.current;x&&x.writeln(`\r
|
|
29
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[l,g]),w.useLayoutEffect(()=>{if(!p.current)return;const x=new Mm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Im,scrollback:5e3,convertEol:!0}),a=new Pm;x.loadAddon(a),x.open(p.current);const h=(d=0)=>{if(!(d>=5))try{const b=p.current;if(!b||b.clientWidth===0||b.clientHeight===0){setTimeout(()=>h(d+1),50);return}a.fit(),y(x.cols,x.rows)}catch{setTimeout(()=>h(d+1),50)}};return h(0),setTimeout(()=>h(1),100),v.current=x,n.current=a,()=>{x.dispose(),v.current=null,n.current=null}},[y]),w.useEffect(()=>{i.current||(i.current=!0,g())},[g]),w.useEffect(()=>{const x=v.current;if(!x||!u)return;const a=x.onData(h=>{_(h)});return()=>a.dispose()},[_,u]),w.useEffect(()=>{u&&m?.({sendInput:_})},[u,_,m]),w.useEffect(()=>{if(!r)return;const x=n.current,a=v.current,h=p.current;if(!x||!a||!h)return;let d=!1,f;const b=S=>{d||S>=5||(f=requestAnimationFrame(()=>{if(!d)if(h.clientWidth>0&&h.clientHeight>0)try{x.fit(),y(a.cols,a.rows)}catch{}else setTimeout(()=>b(S+1),30)}))};return b(0),()=>{d=!0,f!=null&&cancelAnimationFrame(f)}},[r,y]),w.useEffect(()=>{if(!p.current)return;const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=n.current,h=v.current,d=p.current;a&&h&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),y(h.cols,h.rows))}catch{}})});return x.observe(p.current),()=>x.disconnect()},[y]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!c&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:p,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Fm=ae.memo(function({commands:s,onSelect:r}){const{t:o}=le(),[m,p]=w.useState(!1),v=w.useRef(null),n=w.useRef(null);return w.useEffect(()=>{if(!m)return;const i=c=>{v.current&&!v.current.contains(c.target)&&n.current&&!n.current.contains(c.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[m]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>p(!m),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${m?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Ma,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(ct,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,c)=>t.jsxs("button",{onClick:()=>{r(i.command),p(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(ls,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},c))})})]})]})});let bi=0;function Co(){return bi+=1,{id:`shell-${bi}`,order:bi}}const zm=ae.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:m}=le(),[p,v]=w.useState(()=>[Co()]),[n,i]=w.useState(()=>p[0].id),c=w.useRef(new Map),u=w.useCallback(()=>{const x=Co();v(a=>[...a,x]),i(x.id)},[]),l=w.useCallback((x,a)=>{a.stopPropagation(),c.current.delete(x),v(h=>{const d=h.filter(f=>f.id!==x);return x===n&&d.length>0&&i(d[d.length-1].id),d})},[n]),g=w.useCallback(x=>{c.current.delete(x),v(a=>{const h=a.filter(d=>d.id!==x);return x===n&&h.length>0&&i(h[h.length-1].id),h})},[n]),_=w.useCallback((x,a)=>{c.current.set(x,a.sendInput)},[]),y=w.useCallback(x=>{const a=c.current.get(n);a&&a(x+"\r")},[n]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:p.map(x=>t.jsxs("button",{onClick:()=>i(x.id),className:Z("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",x.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(wr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:x.order})}),p.length>1&&t.jsx("span",{onClick:a=>l(x.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Bt,{size:10})})]},x.id))}),t.jsx("button",{onClick:u,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:m("New Terminal"),children:t.jsx(Wt,{size:14})}),o.length>0&&t.jsx(Fm,{commands:o,onSelect:y})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:p.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(wr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:u,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):p.map(x=>t.jsx("div",{className:"absolute inset-0",style:{display:x.id===n?"block":"none"},children:t.jsx(Bm,{cwd:s,isVisible:r&&x.id===n,onExit:()=>g(x.id),onReady:a=>_(x.id,a)})},x.id))})]})});function ko(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Hm(e){if(Array.isArray(e))return e}function Wm(e,s,r){return(s=Vm(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function $m(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,m,p,v,n=[],i=!0,c=!1;try{if(p=(r=r.call(e)).next,s!==0)for(;!(i=(o=p.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(u){c=!0,m=u}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(c)throw m}}return n}}function Um(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
30
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Eo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function jo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Eo(Object(r),!0).forEach(function(o){Wm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Eo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function qm(e,s){if(e==null)return{};var r,o,m=Km(e,s);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(m[r]=e[r])}return m}function Km(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Xm(e,s){return Hm(e)||$m(e,s)||Gm(e,s)||Um()}function Ym(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Vm(e){var s=Ym(e,"string");return typeof s=="symbol"?s:s+""}function Gm(e,s){if(e){if(typeof e=="string")return ko(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ko(e,s):void 0}}function Qm(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function No(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Ro(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?No(Object(r),!0).forEach(function(o){Qm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):No(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Zm(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(m,p){return p(m)},o)}}function Os(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function Ar(e){return{}.toString.call(e).includes("Object")}function Jm(e){return!Object.keys(e).length}function Xs(e){return typeof e=="function"}function ep(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function tp(e,s){return Ar(s)||es("changeType"),Object.keys(s).some(function(r){return!ep(e,r)})&&es("changeField"),s}function sp(e){Xs(e)||es("selectorType")}function rp(e){Xs(e)||Ar(e)||es("handlerType"),Ar(e)&&Object.values(e).some(function(s){return!Xs(s)})&&es("handlersType")}function ip(e){e||es("initialIsRequired"),Ar(e)||es("initialType"),Jm(e)&&es("initialContent")}function np(e,s){throw new Error(e[s]||e.default)}var op={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},es=Os(np)(op),hr={changes:tp,selector:sp,handler:rp,initial:ip};function ap(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hr.initial(e),hr.handler(s);var r={current:e},o=Os(dp)(r,s),m=Os(cp)(r),p=Os(hr.changes)(e),v=Os(lp)(r);function n(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return hr.selector(c),c(r.current)}function i(c){Zm(o,m,p,v)(c)}return[n,i]}function lp(e,s){return Xs(s)?s(e.current):s}function cp(e,s){return e.current=Ro(Ro({},e.current),s),s}function dp(e,s,r){return Xs(s)?s(e.current):Object.keys(r).forEach(function(o){var m;return(m=s[o])===null||m===void 0?void 0:m.call(s,e.current[o])}),r}var up={create:ap},hp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function fp(e){return function s(){for(var r=this,o=arguments.length,m=new Array(o),p=0;p<o;p++)m[p]=arguments[p];return m.length>=e.length?e.apply(this,m):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(m,n))}}}function mp(e){return{}.toString.call(e).includes("Object")}function pp(e){return e||To("configIsRequired"),mp(e)||To("configType"),e.urls?(gp(),{paths:{vs:e.urls.monacoBase}}):e}function gp(){console.warn(hl.deprecation)}function vp(e,s){throw new Error(e[s]||e.default)}var hl={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
31
|
+
You are using deprecated way of configuration.
|
|
32
|
+
|
|
33
|
+
Instead of using
|
|
34
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
35
|
+
use
|
|
36
|
+
monaco.config({ paths: { vs: '...' } })
|
|
37
|
+
|
|
38
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
+
`},To=fp(vp)(hl),xp={config:pp},_p=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(m){return r.reduceRight(function(p,v){return v(p)},m)}};function fl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],fl(e[r],s[r]))}),jo(jo({},e),s)}var bp={type:"cancelation",msg:"operation is manually canceled"};function yi(e){var s=!1,r=new Promise(function(o,m){e.then(function(p){return s?m(bp):o(p)}),e.catch(m)});return r.cancel=function(){return s=!0},r}var yp=["monaco"],Sp=up.create({config:hp,isInitialized:!1,resolve:null,reject:null,monaco:null}),ml=Xm(Sp,2),er=ml[0],Qr=ml[1];function wp(e){var s=xp.config(e),r=s.monaco,o=qm(s,yp);Qr(function(m){return{config:fl(m.config,o),monaco:r}})}function Cp(){var e=er(function(s){var r=s.monaco,o=s.isInitialized,m=s.resolve;return{monaco:r,isInitialized:o,resolve:m}});if(!e.isInitialized){if(Qr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),yi(Si);if(window.monaco&&window.monaco.editor)return pl(window.monaco),e.resolve(window.monaco),yi(Si);_p(kp,jp)(Np)}return yi(Si)}function kp(e){return document.body.appendChild(e)}function Ep(e){var s=document.createElement("script");return e&&(s.src=e),s}function jp(e){var s=er(function(o){var m=o.config,p=o.reject;return{config:m,reject:p}}),r=Ep("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Np(){var e=er(function(r){var o=r.config,m=r.resolve,p=r.reject;return{config:o,resolve:m,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;pl(o),e.resolve(o)},function(r){e.reject(r)})}function pl(e){er().monaco||Qr({monaco:e})}function Rp(){return er(function(e){var s=e.monaco;return s})}var Si=new Promise(function(e,s){return Qr({resolve:e,reject:s})}),gl={config:wp,init:Cp,__getMonacoInstance:Rp},Tp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},wi=Tp,Ap={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Mp=Ap;function Dp({children:e}){return ae.createElement("div",{style:Mp.container},e)}var Lp=Dp,Pp=Lp;function Op({width:e,height:s,isEditorReady:r,loading:o,_ref:m,className:p,wrapperProps:v}){return ae.createElement("section",{style:{...wi.wrapper,width:e,height:s},...v},!r&&ae.createElement(Pp,null,o),ae.createElement("div",{ref:m,style:{...wi.fullWidth,...!r&&wi.hide},className:p}))}var Ip=Op,vl=w.memo(Ip);function Bp(e){w.useEffect(e,[])}var xl=Bp;function Fp(e,s,r=!0){let o=w.useRef(!0);w.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var St=Fp;function zs(){}function _s(e,s,r,o){return zp(e,o)||Hp(e,s,r,o)}function zp(e,s){return e.editor.getModel(_l(e,s))}function Hp(e,s,r,o){return e.editor.createModel(s,r,o?_l(e,o):void 0)}function _l(e,s){return e.Uri.parse(s)}function Wp({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:c="light",loading:u="Loading...",options:l={},height:g="100%",width:_="100%",className:y,wrapperProps:x={},beforeMount:a=zs,onMount:h=zs}){let[d,f]=w.useState(!1),[b,S]=w.useState(!0),k=w.useRef(null),E=w.useRef(null),C=w.useRef(null),j=w.useRef(h),N=w.useRef(a),M=w.useRef(!1);xl(()=>{let L=gl.init();return L.then(F=>(E.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?B():L.cancel()}),St(()=>{if(k.current&&E.current){let L=k.current.getOriginalEditor(),F=_s(E.current,e||"",o||r||"text",p||"");F!==L.getModel()&&L.setModel(F)}},[p],d),St(()=>{if(k.current&&E.current){let L=k.current.getModifiedEditor(),F=_s(E.current,s||"",m||r||"text",v||"");F!==L.getModel()&&L.setModel(F)}},[v],d),St(()=>{let L=k.current.getModifiedEditor();L.getOption(E.current.editor.EditorOption.readOnly)?L.setValue(s||""):s!==L.getValue()&&(L.executeEdits("",[{range:L.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),L.pushUndoStop())},[s],d),St(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:L,modified:F}=k.current.getModel();E.current.editor.setModelLanguage(L,o||r||"text"),E.current.editor.setModelLanguage(F,m||r||"text")},[r,o,m],d),St(()=>{E.current?.editor.setTheme(c)},[c],d),St(()=>{k.current?.updateOptions(l)},[l],d);let T=w.useCallback(()=>{if(!E.current)return;N.current(E.current);let L=_s(E.current,e||"",o||r||"text",p||""),F=_s(E.current,s||"",m||r||"text",v||"");k.current?.setModel({original:L,modified:F})},[r,s,m,e,o,p,v]),D=w.useCallback(()=>{!M.current&&C.current&&(k.current=E.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...l}),T(),E.current?.editor.setTheme(c),f(!0),M.current=!0)},[l,c,T]);w.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),w.useEffect(()=>{!b&&!d&&D()},[b,d,D]);function B(){let L=k.current?.getModel();n||L?.original?.dispose(),i||L?.modified?.dispose(),k.current?.dispose()}return ae.createElement(vl,{width:_,height:g,isEditorReady:d,loading:u,_ref:C,className:y,wrapperProps:x})}var $p=Wp;w.memo($p);function Up(e){let s=w.useRef();return w.useEffect(()=>{s.current=e},[e]),s.current}var qp=Up,fr=new Map;function Kp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:m,path:p,theme:v="light",line:n,loading:i="Loading...",options:c={},overrideServices:u={},saveViewState:l=!0,keepCurrentModel:g=!1,width:_="100%",height:y="100%",className:x,wrapperProps:a={},beforeMount:h=zs,onMount:d=zs,onChange:f,onValidate:b=zs}){let[S,k]=w.useState(!1),[E,C]=w.useState(!0),j=w.useRef(null),N=w.useRef(null),M=w.useRef(null),T=w.useRef(d),D=w.useRef(h),B=w.useRef(),L=w.useRef(o),F=qp(p),z=w.useRef(!1),A=w.useRef(!1);xl(()=>{let I=gl.init();return I.then(U=>(j.current=U)&&C(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>N.current?O():I.cancel()}),St(()=>{let I=_s(j.current,e||o||"",s||m||"",p||r||"");I!==N.current?.getModel()&&(l&&fr.set(F,N.current?.saveViewState()),N.current?.setModel(I),l&&N.current?.restoreViewState(fr.get(p)))},[p],S),St(()=>{N.current?.updateOptions(c)},[c],S),St(()=>{!N.current||o===void 0||(N.current.getOption(j.current.editor.EditorOption.readOnly)?N.current.setValue(o):o!==N.current.getValue()&&(A.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),N.current.pushUndoStop(),A.current=!1))},[o],S),St(()=>{let I=N.current?.getModel();I&&m&&j.current?.editor.setModelLanguage(I,m)},[m],S),St(()=>{n!==void 0&&N.current?.revealLine(n)},[n],S),St(()=>{j.current?.editor.setTheme(v)},[v],S);let P=w.useCallback(()=>{if(!(!M.current||!j.current)&&!z.current){D.current(j.current);let I=p||r,U=_s(j.current,o||e||"",s||m||"",I||"");N.current=j.current?.editor.create(M.current,{model:U,automaticLayout:!0,...c},u),l&&N.current.restoreViewState(fr.get(I)),j.current.editor.setTheme(v),n!==void 0&&N.current.revealLine(n),k(!0),z.current=!0}},[e,s,r,o,m,p,c,u,l,v,n]);w.useEffect(()=>{S&&T.current(N.current,j.current)},[S]),w.useEffect(()=>{!E&&!S&&P()},[E,S,P]),L.current=o,w.useEffect(()=>{S&&f&&(B.current?.dispose(),B.current=N.current?.onDidChangeModelContent(I=>{A.current||f(N.current.getValue(),I)}))},[S,f]),w.useEffect(()=>{if(S){let I=j.current.editor.onDidChangeMarkers(U=>{let X=N.current.getModel()?.uri;if(X&&U.find($=>$.path===X.path)){let $=j.current.editor.getModelMarkers({resource:X});b?.($)}});return()=>{I?.dispose()}}return()=>{}},[S,b]);function O(){B.current?.dispose(),g?l&&fr.set(p,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return ae.createElement(vl,{width:_,height:y,isEditorReady:S,loading:i,_ref:M,className:x,wrapperProps:a})}var Xp=Kp,Yp=w.memo(Xp),Vp=Yp,Rt=function(e,s){return Number(e.toFixed(s))},Gp=function(e,s){return typeof e=="number"?e:s},Ye=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Qp=function(e){return-Math.cos(e*Math.PI)/2+.5},Zp=function(e){return e},Jp=function(e){return e*e},eg=function(e){return e*(2-e)},tg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},sg=function(e){return e*e*e},rg=function(e){return--e*e*e+1},ig=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},ng=function(e){return e*e*e*e},og=function(e){return 1- --e*e*e*e},ag=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},lg=function(e){return e*e*e*e*e},cg=function(e){return 1+--e*e*e*e*e},dg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},bl={easeOut:Qp,linear:Zp,easeInQuad:Jp,easeOutQuad:eg,easeInOutQuad:tg,easeInCubic:sg,easeOutCubic:rg,easeInOutCubic:ig,easeInQuart:ng,easeOutQuart:og,easeInOutQuart:ag,easeInQuint:lg,easeOutQuint:cg,easeInOutQuint:dg},yl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},At=function(e){e.mounted&&(yl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Sl(e,s,r,o){if(e.mounted){var m=new Date().getTime(),p=1;At(e),e.animation=function(){if(!e.mounted)return yl(e.animation);var v=new Date().getTime()-m,n=v/r,i=bl[s],c=i(n);v>=r?(o(p),e.animation=null):e.animation&&(o(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ug(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function rs(e,s,r,o){var m=ug(s);if(!(!e.mounted||!m)){var p=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,c=v.positionY,u=s.scale-n,l=s.positionX-i,g=s.positionY-c;r===0?p(s.scale,s.positionX,s.positionY):Sl(e,o,r,function(_){var y=n+u*_,x=i+l*_,a=c+g*_;p(y,x,a)})}}function hg(e,s,r){var o=e.offsetWidth,m=e.offsetHeight,p=s.offsetWidth,v=s.offsetHeight,n=p*r,i=v*r,c=o-n,u=m-i;return{wrapperWidth:o,wrapperHeight:m,newContentWidth:n,newDiffWidth:c,newContentHeight:i,newDiffHeight:u}}var fg=function(e,s,r,o,m,p,v){var n=e>s?r*(v?1:.5):0,i=o>m?p*(v?1:.5):0,c=e-s-n,u=n,l=o-m-i,g=i;return{minPositionX:c,maxPositionX:u,minPositionY:l,maxPositionY:g}},kn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=hg(r,o,s),v=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,c=p.newDiffWidth,u=p.newContentHeight,l=p.newDiffHeight,g=fg(v,i,c,n,u,l,!!m);return g},Wi=function(e,s,r,o){return o?e<s?Rt(s,2):e>r?Rt(r,2):Rt(e,2):Rt(e,2)},cs=function(e,s){var r=kn(e,s);return e.bounds=r,r};function tr(e,s,r,o,m,p,v){var n=r.minPositionX,i=r.minPositionY,c=r.maxPositionX,u=r.maxPositionY,l=0,g=0;v&&(l=m,g=p);var _=Wi(e,n-l,c+l,o),y=Wi(s,i-g,u+g,o);return{x:_,y}}function Zr(e,s,r,o,m,p){var v=e.transformState,n=v.scale,i=v.positionX,c=v.positionY,u=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:c};var l=i-s*u,g=c-r*u,_=tr(l,g,m,p,0,0,null);return _}function sr(e,s,r,o,m){var p=m?o:0,v=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Ao=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,m=e.wrapperComponent,p=s.target,v="shadowRoot"in p&&"composedPath"in s,n=v?s.composedPath().some(function(u){return u instanceof Element?m?.contains(u):!1}):m?.contains(p),i=o&&p&&n;if(!i)return!1;var c=Jr(p,r);return!c},Mo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,m=o.panning.disabled,p=s&&r&&!m;return!!p},mg=function(e,s){var r=e.transformState,o=r.positionX,m=r.positionY;e.isPanning=!0;var p=s.clientX,v=s.clientY;e.startCoords={x:p-o,y:v-m}},pg=function(e,s){var r=s.touches,o=e.transformState,m=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-m,y:i-p}}};function gg(e){var s=e.transformState,r=s.positionX,o=s.positionY,m=s.scale,p=e.setup,v=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,c=e.wrapperComponent;if(!(v||!c||!e.bounds)){var u=e.bounds,l=u.maxPositionX,g=u.minPositionX,_=u.maxPositionY,y=u.minPositionY,x=r>l||r<g,a=o>_||o<y,h=r>l?c.offsetWidth:e.setup.minPositionX||0,d=o>_?c.offsetHeight:e.setup.minPositionY||0,f=Zr(e,h,d,m,e.bounds,n||i),b=f.x,S=f.y;return{scale:m,positionX:x?b:r,positionY:a?S:o}}}function wl(e,s,r,o,m){var p=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,c=i.scale,u=i.positionX,l=i.positionY;if(!(v===null||n===null||s===u&&r===l)){var g=tr(s,r,n,p,o,m,v),_=g.x,y=g.y;e.setTransformState(c,_,y)}}var vg=function(e,s,r){var o=e.startCoords,m=e.transformState,p=e.setup.panning,v=p.lockAxisX,n=p.lockAxisY,i=m.positionX,c=m.positionY;if(!o)return{x:i,y:c};var u=s-o.x,l=r-o.y,g=v?i:u,_=n?c:l;return{x:g,y:_}},ss=function(e,s){var r=e.setup,o=e.transformState,m=o.scale,p=r.minScale,v=r.disablePadding;return s>0&&m>=p&&!v?s:0},xg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,v=m.disabled,n=!v||p>1||!o||s;return!!n},_g=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,m=e.setup,p=m.disabled,v=m.velocityAnimation,n=e.transformState.scale,i=v.disabled,c=!i||n>1||!p||s;return!(!c||!r||!o)};function bg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,m=r.animationTime,p=r.sensitivity;return o?m*s*p:m}function Do(e,s,r,o,m,p,v,n,i,c){if(m){if(s>v&&r>v){var u=v+(e-v)*c;return u>i?i:u<v?v:u}if(s<p&&r<p){var u=p+(e-p)*c;return u<n?n:u>p?p:u}}return o?s:Wi(e,p,v,m)}function yg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function Sg(e,s){var r=xg(e);if(r){var o=e.lastMousePosition,m=e.velocityTime,p=e.setup,v=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&m&&v){var c=yg(v,n),u=s.x-o.x,l=s.y-o.y,g=u/c,_=l/c,y=i-m,x=u*u+l*l,a=Math.sqrt(x)/y;e.velocity={velocityX:g,velocityY:_,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function wg(e){var s=e.velocity,r=e.bounds,o=e.setup,m=e.wrapperComponent,p=_g(e);if(!(!p||!s||!r||!m)){var v=s.velocityX,n=s.velocityY,i=s.total,c=r.maxPositionX,u=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,_=o.limitToBounds,y=o.alignmentAnimation,x=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=x.animationType,b=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,C=bg(e,i),j=Math.max(C,E),N=ss(e,b),M=ss(e,S),T=N*m.offsetWidth/100,D=M*m.offsetHeight/100,B=c+T,L=u-T,F=l+D,z=g-D,A=e.transformState,P=new Date().getTime();Sl(e,f,j,function(O){var I=e.transformState,U=I.scale,X=I.positionX,$=I.positionY,V=new Date().getTime()-P,q=V/E,R=bl[y.animationType],H=1-R(Math.min(1,q)),K=1-O,W=X+v*K,Q=$+n*K,J=Do(W,A.positionX,X,d,_,u,c,L,B,H),oe=Do(Q,A.positionY,$,h,_,g,l,z,F,H);(X!==W||$!==Q)&&e.setTransformState(U,J,oe)})}}function Lo(e,s){var r=e.transformState.scale;At(e),cs(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?pg(e,s):mg(e,s)}function En(e,s){var r=e.transformState.scale,o=e.setup,m=o.minScale,p=o.alignmentAnimation,v=p.disabled,n=p.sizeX,i=p.sizeY,c=p.animationTime,u=p.animationType,l=v||r<m||!n&&!i;if(!l){var g=gg(e);g&&rs(e,g,s??c,u)}}function Po(e,s,r){var o=e.startCoords,m=e.setup,p=m.alignmentAnimation,v=p.sizeX,n=p.sizeY;if(o){var i=vg(e,s,r),c=i.x,u=i.y,l=ss(e,v),g=ss(e,n);Sg(e,{x:c,y:u}),wl(e,c,u,l,g)}}function Cg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),v=m?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,c=v?.width||0,u=v?.height||0,l=n<c||i<u,g=!s&&r&&r?.total>.1&&l;g?wg(e):En(e)}}function jn(e,s,r,o){var m=e.setup,p=m.minScale,v=m.maxScale,n=m.limitToBounds,i=sr(Rt(s,2),p,v,0,!1),c=cs(e,i),u=Zr(e,r,o,i,c,n),l=u.x,g=u.y;return{scale:i,positionX:l,positionY:g}}function Cl(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,c=i.disabled,u=i.animationTime,l=i.animationType,g=c||o>=v;if((o>=1||n)&&En(e),!(g||!m||!e.mounted)){var _=s||m.offsetWidth/2,y=r||m.offsetHeight/2,x=jn(e,v,_,y);x&&rs(e,x,u,l)}}var ts=function(){return ts=Object.assign||function(s){for(var r,o=1,m=arguments.length;o<m;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},ts.apply(this,arguments)};function Oo(e,s,r){for(var o=0,m=s.length,p;o<m;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var mr={scale:1,positionX:0,positionY:0},Ls={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},$i={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},kl=function(e){var s,r,o,m;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:mr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:mr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:mr.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:mr.positionY}},Io=function(e){var s=ts({},Ls);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",m=typeof Ls[r]<"u";if(m&&o){var p=Object.prototype.toString.call(Ls[r]),v=p==="[object Object]",n=p==="[object Array]";v?s[r]=ts(ts({},Ls[r]),e[r]):n?s[r]=Oo(Oo([],Ls[r],!0),e[r]):s[r]=e[r]}}),s},El=function(e,s,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.maxScale,n=p.minScale,i=p.zoomAnimation,c=p.smooth,u=i.size;if(!m)throw new Error("Wrapper is not mounted");var l=c?o*Math.exp(s*r):o+s*r,g=sr(Rt(l,3),n,v,u,!1);return g};function jl(e,s,r,o,m){var p=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,c=v.positionY;if(!p)return console.error("No WrapperComponent found");var u=p.offsetWidth,l=p.offsetHeight,g=(u/2-i)/n,_=(l/2-c)/n,y=El(e,s,r),x=jn(e,y,g,_);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");rs(e,x,o,m)}function Nl(e,s,r,o){var m=e.setup,p=e.wrapperComponent,v=m.limitToBounds,n=kl(e.props),i=e.transformState,c=i.scale,u=i.positionX,l=i.positionY;if(p){var g=kn(e,n.scale),_=tr(n.positionX,n.positionY,g,v,0,0,p),y={scale:n.scale,positionX:_.x,positionY:_.y};c===n.scale&&u===n.positionX&&l===n.positionY||(o?.(),rs(e,y,s,r))}}function kg(e,s,r,o){var m=e.getBoundingClientRect(),p=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(m.x-v.x+n)/o.scale,y:(m.y-v.y+i)/o.scale}}function Eg(e,s,r){var o=e.wrapperComponent,m=e.contentComponent,p=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,c=v.maxScale;if(!o||!m)return p;var u=o.getBoundingClientRect(),l=s.getBoundingClientRect(),g=kg(s,o,m,p),_=g.x,y=g.y,x=l.width/p.scale,a=l.height/p.scale,h=o.offsetWidth/x,d=o.offsetHeight/a,f=sr(r||Math.min(h,d),i,c,0,!1),b=(u.width-x*f)/2,S=(u.height-a*f)/2,k=(u.left-_)*f+b,E=(u.top-y)*f+S,C=kn(e,f),j=tr(k,E,C,n,0,0,o),N=j.x,M=j.y;return{positionX:N,positionY:M,scale:f}}var jg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),jl(e,1,s,r,o)}},Ng=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),jl(e,-1,s,r,o)}},Rg=function(e){return function(s,r,o,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,c=v.scale,u=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!l)){var _={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?c:o};rs(e,_,m,p)}}},Tg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Nl(e,s,r)}},Ag=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var m=e.transformState,p=e.wrapperComponent,v=e.contentComponent;if(p&&v){var n=Rl(s||m.scale,p,v);rs(e,n,r,o)}}},Mg=function(e){return function(s,r,o,m){o===void 0&&(o=600),m===void 0&&(m="easeOut"),At(e);var p=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(p&&v&&p.contains(v)){var n=Eg(e,v,r);rs(e,n,o,m)}}},Mr=function(e){return{instance:e,zoomIn:jg(e),zoomOut:Ng(e),setTransform:Rg(e),resetTransform:Tg(e),centerView:Ag(e),zoomToElement:Mg(e)}},Ui=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,Ui(e)),Object.assign(s,Mr(e)),s},Ci=!1;function ki(){try{var e={get passive(){return Ci=!0,!1}};return e}catch{return Ci=!1,Ci}}var pr=".".concat($i.wrapperClass),Jr=function(e,s){return s.some(function(r){return e.matches("".concat(pr," ").concat(r,", ").concat(pr," .").concat(r,", ").concat(pr," ").concat(r," *, ").concat(pr," .").concat(r," *"))})},qi=function(e){e&&clearTimeout(e)},Dg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Rl=function(e,s,r){var o=r.offsetWidth*e,m=r.offsetHeight*e,p=(s.offsetWidth-o)/2,v=(s.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:v}};function Lg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Pg=function(e,s){var r=e.setup.wheel,o=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,c=s.target,u=n&&!i&&!o&&c;if(!u||m&&!s.ctrlKey||p&&s.ctrlKey)return!1;var l=Jr(c,v);return!l},Og=function(e){return e?e.deltaY<0?1:-1:0};function Ig(e,s){var r=Og(e),o=Gp(s,r);return o}function Tl(e,s,r){var o=s.getBoundingClientRect(),m=0,p=0;if("clientX"in e)m=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var v=e.touches[0];m=(v.clientX-o.left)/r,p=(v.clientY-o.top)/r}return(Number.isNaN(m)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:m,y:p}}var Bg=function(e,s,r,o,m){var p=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,c=n.minScale,u=n.zoomAnimation,l=n.disablePadding,g=u.size,_=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=p+s*r,x=o?!1:!_,a=sr(Rt(y,3),c,i,g,x&&!l);return a},Fg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,m=e.setup,p=m.maxScale,v=m.minScale;return r?o<p||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},zg=function(e,s){var r=e.setup.pinch,o=r.disabled,m=r.excluded,p=e.isInitialized,v=s.target,n=p&&!o&&v;if(!n)return!1;var i=Jr(v,m);return!i},Hg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,m=r&&!s&&o;return!!m},Wg=function(e,s,r){var o=r.getBoundingClientRect(),m=e.touches,p=Rt(m[0].clientX-o.left,5),v=Rt(m[0].clientY-o.top,5),n=Rt(m[1].clientX-o.left,5),i=Rt(m[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(v+i)/2/s}},Al=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},$g=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,m=e.setup,p=m.maxScale,v=m.minScale,n=m.zoomAnimation,i=m.disablePadding,c=n.size,u=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var l=s/o,g=l*r;return sr(Rt(g,2),v,p,c,!u&&!i)},Ug=160,qg=100,Kg=function(e,s){var r=e.props,o=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(At(e),Ye(qe(e),s,o),Ye(qe(e),s,m))},Xg=function(e,s){var r=e.props,o=r.onWheel,m=r.onZoom,p=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,c=v.limitToBounds,u=v.centerZoomedOut,l=v.zoomAnimation,g=v.wheel,_=v.disablePadding,y=v.smooth,x=l.size,a=l.disabled,h=g.step,d=g.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Ig(s,null),b=y?d*Math.abs(s.deltaY):h,S=Bg(e,f,b,!s.ctrlKey);if(i!==S){var k=cs(e,S),E=Tl(s,p,i),C=a||x===0||u||_,j=c&&C,N=Zr(e,E.x,E.y,S,k,j),M=N.x,T=N.y;e.previousWheelEvent=s,e.setTransformState(S,M,T),Ye(qe(e),s,o),Ye(qe(e),s,m)}},Yg=function(e,s){var r=e.props,o=r.onWheelStop,m=r.onZoomStop;qi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Cl(e,s.x,s.y),e.wheelAnimationTimer=null)},qg);var p=Fg(e,s);p&&(qi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ye(qe(e),s,o),Ye(qe(e),s,m))},Ug))},Ml=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var m=s/2,p=r/2;return{x:m,y:p}},Vg=function(e,s){var r=Al(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Ml(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,At(e)},Gg=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,c=v.zoomAnimation,u=v.alignmentAnimation,l=c.disabled,g=c.size;if(!(o===null||!r)){var _=Wg(s,p,r);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var y=Al(s),x=$g(e,y),a=Ml(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===p&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=cs(e,x),b=l||g===0||i,S=n&&b,k=Zr(e,_.x,_.y,x,f,S),E=k.x,C=k.y;e.pinchMidpoint=_,e.lastDistance=y;var j=u.sizeX,N=u.sizeY,M=ss(e,j),T=ss(e,N),D=E+h,B=C+d,L=tr(D,B,f,n,M,T,m),F=L.x,z=L.y;e.setTransformState(x,F,z)}}}},Qg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Cl(e,s?.x,s?.y)},Dl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;qi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ye(qe(e),s,r)},o)},Zg=function(e,s){var r=e.props,o=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,n=p.animationType;Ye(qe(e),s,o),Nl(e,v,n,function(){return Ye(qe(e),s,m)}),Dl(e,s)};function Jg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function ev(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,v=m.scale,n=e.props,i=n.onZoomStart,c=n.onZoom,u=r.doubleClick,l=u.disabled,g=u.mode,_=u.step,y=u.animationTime,x=u.animationType;if(!l&&!o){if(g==="reset")return Zg(e,s);if(!p)return console.error("No ContentComponent found");var a=Jg(g,e.transformState.scale),h=El(e,a,_);if(v!==h){Ye(qe(e),s,i);var d=Tl(s,p,v),f=jn(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ye(qe(e),s,c),rs(e,f,y,x),Dl(e,s)}}}var tv=function(e,s){var r=e.isInitialized,o=e.setup,m=e.wrapperComponent,p=o.doubleClick,v=p.disabled,n=p.excluded,i=s.target,c=m?.contains(i),u=r&&i&&c&&!v;if(!u)return!1;var l=Jr(i,n);return!l},sv=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,cs(r,r.transformState.scale),r.setup=Io(o)},this.initializeWindowEvents=function(){var o,m,p=ki(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,m,p=ki(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),At(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(o){var m=ki();o.addEventListener("wheel",r.onWheelZoom,m),o.addEventListener("dblclick",r.onDoubleClick,m),o.addEventListener("touchstart",r.onTouchPanningStart,m),o.addEventListener("touchmove",r.onTouchPanning,m),o.addEventListener("touchend",r.onTouchPanningStop,m)},this.handleInitialize=function(o,m){var p=!1,v=r.setup.centerOnInit,n=function(i,c){for(var u=0,l=i;u<l.length;u++){var g=l[u];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(qe(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,m))if(v&&!p){var c=m.offsetWidth,u=m.offsetHeight;(c>0||u>0)&&(p=!0,r.setCenter())}else At(r),cs(r,r.transformState.scale),En(r,0)}),r.observer.observe(o),r.observer.observe(m)},this.onWheelZoom=function(o){var m=r.setup.disabled;if(!m){var p=Pg(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Kg(r,o),Xg(r,o),Yg(r,o))}}},this.onWheelPanning=function(o){var m=r.setup,p=m.disabled,v=m.wheel,n=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,c=i.positionX,u=i.positionY,l=c-o.deltaX,g=u-o.deltaY,_=n.lockAxisX?c:l,y=n.lockAxisY?u:g,x=r.setup.alignmentAnimation,a=x.sizeX,h=x.sizeY,d=ss(r,a),f=ss(r,h);_===c&&y===u||wl(r,_,y,d,f)}},this.onPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Ao(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),At(r),Lo(r,o),Ye(qe(r),o,p)))}}},this.onPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var v=Mo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Po(r,o.clientX,o.clientY),Ye(qe(r),o,p))}}},this.onPanningStop=function(o){var m=r.props.onPanningStop;r.isPanning&&(Cg(r),Ye(qe(r),o,m))},this.onPinchStart=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinchingStart,n=p.onZoomStart;if(!m){var i=zg(r,o);i&&(Vg(r,o),At(r),Ye(qe(r),o,v),Ye(qe(r),o,n))}},this.onPinch=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinching,n=p.onZoom;if(!m){var i=Hg(r);i&&(o.preventDefault(),o.stopPropagation(),Gg(r,o),Ye(qe(r),o,v),Ye(qe(r),o,n))}},this.onPinchStop=function(o){var m=r.props,p=m.onPinchingStop,v=m.onZoomStop;r.pinchStartScale&&(Qg(r),Ye(qe(r),o,p),Ye(qe(r),o,v))},this.onTouchPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Ao(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,At(r);var i=o.touches,c=i.length===1,u=i.length===2;c&&(At(r),Lo(r,o),Ye(qe(r),o,p)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(m)return;var v=Mo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Po(r,n.clientX,n.clientY),Ye(qe(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var m=r.setup.disabled;if(!m){var p=tv(r,o);p&&ev(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(m){return r.pressedKeys[m]}):!0},this.setTransformState=function(o,m,p){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(m)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=m,r.transformState.positionY=p,r.applyTransformation();var n=qe(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Ye(n,{scale:o,positionX:m,positionY:p},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Rl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,m,p){return r.props.customTransform?r.props.customTransform(o,m,p):Dg(o,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,m=o.scale,p=o.positionX,v=o.positionY,n=r.handleTransformStyles(p,v,m);r.contentComponent.style.transform=n}},this.getContext=function(){return qe(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,m){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=m,cs(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=qe(r);Ye(p,void 0,r.props.onInit)},this.props=s,this.setup=Io(this.props),this.transformState=kl(this.props)}return e})(),ei=ae.createContext(null),rv=function(e,s){return typeof e=="function"?e(s):e},iv=ae.forwardRef(function(e,s){var r=w.useRef(new sv(e)).current,o=rv(e.children,Mr(r));return w.useImperativeHandle(s,function(){return Mr(r)},[r]),w.useEffect(function(){r.update(e)},[r,e]),ae.createElement(ei.Provider,{value:r},o)});ae.forwardRef(function(e,s){var r=w.useRef(null),o=w.useContext(ei);return w.useEffect(function(){return o.onChange(function(m){if(r.current){var p=0,v=0;r.current.style.transform=o.handleTransformStyles(p,v,1/m.instance.transformState.scale)}})},[o]),ae.createElement("div",ts({},e,{ref:Lg([r,s])}))});function nv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",r==="top"&&o.firstChild?o.insertBefore(m,o.firstChild):o.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var ov=`.transform-component-module_wrapper__SPB86 {
|
|
40
|
+
position: relative;
|
|
41
|
+
width: -moz-fit-content;
|
|
42
|
+
width: fit-content;
|
|
43
|
+
height: -moz-fit-content;
|
|
44
|
+
height: fit-content;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
47
|
+
-webkit-user-select: none; /* Safari */
|
|
48
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
49
|
+
-moz-user-select: none; /* Firefox */
|
|
50
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
51
|
+
user-select: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
transform: translate3d(0, 0, 0);
|
|
55
|
+
}
|
|
56
|
+
.transform-component-module_content__FBWxo {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-wrap: wrap;
|
|
59
|
+
width: -moz-fit-content;
|
|
60
|
+
width: fit-content;
|
|
61
|
+
height: -moz-fit-content;
|
|
62
|
+
height: fit-content;
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
transform-origin: 0% 0%;
|
|
66
|
+
}
|
|
67
|
+
.transform-component-module_content__FBWxo img {
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
}
|
|
70
|
+
`,Bo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};nv(ov);var av=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,c=i===void 0?{}:i,u=e.contentProps,l=u===void 0?{}:u,g=w.useContext(ei),_=g.init,y=g.cleanupWindowEvents,x=w.useRef(null),a=w.useRef(null);return w.useEffect(function(){var h=x.current,d=a.current;return h!==null&&d!==null&&_&&_?.(h,d),function(){y?.()}},[]),ae.createElement("div",ts({},c,{ref:x,className:"".concat($i.wrapperClass," ").concat(Bo.wrapper," ").concat(o),style:v}),ae.createElement("div",ts({},l,{ref:a,className:"".concat($i.contentClass," ").concat(Bo.content," ").concat(p),style:n}),s))},Ll=function(){var e=w.useContext(ei);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},lv=function(){var e=Ll();return Mr(e)};function cv(e){var s=Ll(),r=w.useState(e(Ui(s))),o=r[0],m=r[1];return w.useEffect(function(){var p=!0,v=s.onChange(function(n){p&&m(e(Ui(n.instance)))});return function(){v(),p=!1}},[e,s]),o}function dv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function uv(e,s){return wt({queryKey:ce.files.tree(e||"",s),queryFn:()=>ve.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function hv(e,s){return wt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>ve.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function fv(e){const s=st();return w.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function mv(){const e=st();return bt({mutationFn:s=>ve.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),m=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:m?.language||dv(r.path)})}})}function pv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function gv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const vv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function xv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&vv.has(s)?on:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?yr:s==="json"?Nd:s==="md"||s==="mdx"||s==="txt"?rn:td}const Fo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:m,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:Z("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:m}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),Pl=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})=>{const{t:n}=le(),{data:i,isLoading:c,isError:u}=uv(e,s),l=w.useMemo(()=>i?.items??[],[i?.items]);return c?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const h=pv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(Fo,{depth:r,onClick:()=>m(h),rightIcon:d?t.jsx(ct,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(zr,{size:14,className:"text-amber-500"}):t.jsx(Ea,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Pl,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})]},h)}const _=gv(s,g.name),y=xv(g),x=v===_,a=y===on;return t.jsx(Fo,{depth:r,active:x,onClick:()=>p(_),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},_)})})},_v=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:m})=>{const{t:p}=le(),[v,n]=w.useState(()=>new Set),i=fv(e),c=w.useCallback(u=>{n(l=>{const g=new Set(l);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:Z("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:t.jsx(Hr,{size:13})}),m&&t.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Collapse file tree"),children:t.jsx(Xd,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Pl,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:c,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},bv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function yv(e){const s=e.split(".").pop()?.toLowerCase();return s?bv.has(s):!1}function Sv(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const wv=({filePath:e})=>{const{t:s}=le(),{zoomIn:r,zoomOut:o,centerView:m}=lv(),p=cv(n=>n.state.scale),v=Math.round(p*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(vu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>m(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(pu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>m(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(qd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Cv=({workingDir:e,filePath:s})=>{const{t:r}=le(),[o,m]=w.useState(!1),p=Sv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(iv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(wv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(av,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function kv(e){const s=e.split("/");return s[s.length-1]||e}function Ev(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const jv=({active:e,name:s,isDirty:r,onClick:o,onClose:m})=>{const{t:p}=le();return t.jsxs("button",{type:"button",onClick:o,className:Z("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:Z("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:m,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Bt,{size:12})})]})},Nv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=le(),[m,p]=w.useState([]),[v,n]=w.useState(null),i=mv(),[c,u]=w.useState(280),[l,g]=w.useState(!1),[_,y]=w.useState(!1),x=w.useRef(280),a=w.useCallback(()=>{g(D=>(D?u(x.current):x.current=c,!D))},[c]),h=w.useCallback(D=>{D.preventDefault(),y(!0);const B=D.clientX,L=c,F=A=>{const P=A.clientX-B,O=Math.min(480,Math.max(160,L+P));u(O)},z=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);w.useEffect(()=>{p([]),n(null)},[e]);const d=w.useMemo(()=>m.find(D=>D.path===v)||null,[m,v]),{data:f,isFetching:b,isError:S,error:k}=hv(e,d?.isImage?null:v);w.useEffect(()=>{!v||!f||p(D=>D.map(B=>B.path!==v||B.isDirty||B.loaded?B:{...B,language:f.language||B.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[v,f]);const E=w.useCallback(D=>{p(B=>{if(B.find(z=>z.path===D))return B;const F=yv(D);return[...B,{path:D,name:kv(D),language:Ev(D),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),n(D)},[]),C=w.useCallback(D=>{p(B=>{const L=B.filter(F=>F.path!==D);return n(F=>F!==D?F:L.length?L[L.length-1].path:null),L})},[]),j=w.useCallback(D=>{p(B=>B.map(L=>{if(L.path!==v)return L;const F=D!==L.savedContent;return{...L,content:D,isDirty:F}}))},[v]),N=w.useCallback(async()=>{r||!e||!d||(await i.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(D=>D.map(B=>B.path===d.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[d,r,i,e]),M=w.useRef(()=>{});w.useEffect(()=>{M.current=()=>{N().catch(()=>{})}},[N]),w.useEffect(()=>{const D=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),M.current())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[r]);const T=w.useCallback((D,B)=>{D.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{M.current()})},[]);return t.jsxs("div",{className:Z("flex h-full overflow-hidden bg-white",s),style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:c,transition:_?"none":"width 0.15s ease"},children:l?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:o("Expand file tree"),children:t.jsx(Vd,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(_v,{workingDir:e,onFileSelect:E,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!l&&t.jsx("div",{onMouseDown:h,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[m.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):m.map(D=>t.jsx(jv,{active:D.path===v,name:D.name,isDirty:D.isDirty,onClick:()=>n(D.path),onClose:B=>{B.stopPropagation(),C(D.path)}},D.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),i.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!i.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(Cv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(Vp,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:D=>j(D??""),onMount:T,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!d.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Be,{size:14,className:"animate-spin"}),o("Loading file...")]})}),S&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[o("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("No workspace selected.")})})]})]})};function Nn(e){return wt({queryKey:ce.git.changes(e||""),queryFn:()=>ve.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function Ol(e,s,r){return wt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>ve.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Rn(e,s){return wt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>ve.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Tn(e,s,r){return wt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ve.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Rv({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:m,isPending:p,error:v,onConfirm:n}){const{t:i}=le(),[c,u]=w.useState(""),[l,g]=w.useState(!1);w.useEffect(()=>{e&&(g(!1),u(m??""))},[e]),w.useEffect(()=>{l||!e||u(m??"")},[m,l,e]);const _=()=>{p||s()};return t.jsx(ks,{isOpen:e,onClose:_,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:_,disabled:p,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(c.trim()||void 0),disabled:p,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:p?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Oi,{size:14}),i("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(md,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:c,onChange:y=>{g(!0),u(y.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!c.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function gs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Tv(e){if(!(e instanceof fa)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Hs.REBASE&&s.conflictOp!==Hs.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:gs(s,"sourceBranch"),targetBranch:gs(s,"targetBranch"),sourceWorktreePath:gs(s,"sourceWorktreePath"),targetWorktreePath:gs(s,"targetWorktreePath"),sourceWorkspaceId:gs(s,"sourceWorkspaceId"),targetWorkspaceId:gs(s,"targetWorkspaceId")}}function zo(e,s,r,o){const m=Tv(e);if(m){r(m);return}o(e instanceof Error?e.message:s)}function Il({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:m,onRefreshCommitMessage:p,onConflict:v,onResolveConflicts:n}){const{t:i}=le(),{data:c,isLoading:u}=xn(e),l=tf(),g=Jh(),_=tl(),[y,x]=w.useState(!1),[a,h]=w.useState(null);if(w.useEffect(()=>{y&&p?.()},[y,p]),u||!c)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const d=c.conflictedFiles.length>0,f=c.operation!=="idle",b=c.hasUncommittedChanges||c.untrackedCount>0,S=c.uncommittedCount+c.untrackedCount,k=!d&&!f&&!b,E=c.operation==="idle"&&c.ahead===0&&c.behind===0&&!b&&!d,C=()=>{h(null),l.mutate(e,{onError:T=>{zo(T,i("更新失败,请稍后重试"),D=>v(D),h)}})},j=()=>{h(null),x(!0)},N=T=>{h(null),g.mutate({id:e,commitMessage:T},{onSuccess:()=>x(!1),onError:D=>{zo(D,i("提交失败,请稍后重试"),B=>{x(!1),v(B)},h)}})},M=()=>{g.isPending||(x(!1),h(null))};return E?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Hd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),b&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Ad,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:S})})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(Br,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:c.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:_.isPending?i("正在撤销..."):i("撤销操作")})]})]}),f&&!d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:c.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(od,{size:12}),_.isPending?i("正在撤销..."):i("撤销操作")]})]}),!d&&!f&&(c.behind>0||c.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:c.behind})}),t.jsxs("button",{onClick:C,disabled:!k||l.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Hr,{size:12}),l.isPending?i("正在同步..."):i("同步更新")]})]}),c.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:m??c.ahead})}),c.behind===0&&!b?t.jsxs("button",{onClick:j,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Oi,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Oi,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(Rv,{isOpen:y,onClose:M,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:a,onConfirm:N})]})}const Ei=50,ji=400,Ho={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"},Wo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Bl(e){const s=e.split("/");return s[s.length-1]||e}function Av(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Mv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?jt("{count}s ago",{count:r}):r<3600?jt("{count}m ago",{count:Math.floor(r/60)}):r<86400?jt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?jt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function xr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Ki=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:Z("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Dv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},Fl=({diff:e})=>{const{t:s}=le(),[r,o]=w.useState(!1),m=w.useMemo(()=>e.split(`
|
|
71
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const p=!r&&m.length>ji,v=p?m.slice(0,ji):m;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(Dv,{line:n,lineNum:i+1},i)),p&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:m.length-ji})})]})},Lv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:m}=le(),{data:p,isLoading:v,isError:n}=Ol(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:m("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:m("差异加载失败")}):t.jsx(Fl,{diff:p?.diff||""})},Pv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:m}=le(),{data:p,isLoading:v,isError:n}=Tn(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:m("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:m("差异加载失败")}):t.jsx(Fl,{diff:p?.diff||""})},Ni=({entry:e,source:s,workingDir:r,flash:o,registerNode:m})=>{const[p,v]=w.useState(!1),[n,i]=w.useState(!1),c=w.useRef(null),u=xr(s,e.path);w.useEffect(()=>(m(u,c.current),()=>m(u,null)),[u,m]),w.useEffect(()=>{const _=c.current;if(!_||n)return;const y=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(i(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(_),()=>y.disconnect()},[n]);const l=Ho[e.status]||Ho.M,g=Av(e.path);return t.jsxs("div",{ref:c,"data-card-key":u,className:Z("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(_=>!_),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[p?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(ct,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Bl(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Ki,{additions:e.additions,deletions:e.deletions})]}),!p&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Lv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(Pv,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function Ov(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let m=s;for(let p=0;p<o.length-1;p++){const v=o[p];m.dirs.has(v)||m.dirs.set(v,{name:v,path:m.path?`${m.path}/${v}`:v,dirs:new Map,files:[]}),m=m.dirs.get(v)}m.files.push(r)}return zl(s)}function zl(e){const s=new Map;for(const r of e.dirs.values()){let o=zl(r);for(;o.dirs.size===1&&o.files.length===0;){const m=[...o.dirs.values()][0];o={...m,name:`${o.name}/${m.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const Iv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[m,p]=w.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[m?t.jsx(zr,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ea,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),m&&t.jsx(Hl,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Hl=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((m,p)=>m.name.localeCompare(p.name)).map(m=>t.jsx(Iv,{dir:m,depth:s,activeKey:r,onSelect:o},m.path)),e.files.slice().sort((m,p)=>m.path.localeCompare(p.path)).map(m=>{const p=r===m.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(m),className:Z("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",p?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:m.path,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full shrink-0",Wo[m.status]||Wo.M)}),t.jsx("span",{className:Z("text-xs truncate",p?"text-foreground font-medium":"text-foreground/90"),children:Bl(m.path)})]},m.cardKey)})]}),Bv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=le(),{data:m,isLoading:p,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=tn({queryKey:ce.git.log(e),queryFn:({pageParam:u=0})=>ve.get("/git/log",{params:{workingDir:e,limit:String(Ei),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,l)=>u.commits.length<Ei?void 0:l.length*Ei}),c=m?.pages.flatMap(u=>u.commits)||[];return p?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Be,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):c.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[c.map(u=>{const l=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:Z("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",l?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",l?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Z("block text-xs truncate",l?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",Mv(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Fv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,canRunGitOperations:p,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:c}=le(),[u,l]=w.useState({kind:"overview"}),[g,_]=w.useState(""),[y,x]=w.useState(null),[a,h]=w.useState(null),{data:d,isLoading:f,isError:b}=Nn(e),S=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:E}=Rn(e,S),C=w.useRef(new Map),j=w.useRef(null),N=w.useRef(null),M=w.useCallback(($,V)=>{V?C.current.set($,V):C.current.delete($)},[]),{uncommitted:T,committed:D,commitFiles:B}=w.useMemo(()=>{const $=R=>!g.trim()||R.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const R={kind:"commit",hash:u.commit.hash},H=(k?.files||[]).filter($).map(K=>({...K,cardKey:xr(R,K.path)}));return{uncommitted:[],committed:[],commitFiles:H}}const V=(d?.uncommitted||[]).filter($).map(R=>({...R,cardKey:xr({kind:"working",diffType:"uncommitted"},R.path)})),q=(d?.committed||[]).filter($).map(R=>({...R,cardKey:xr({kind:"working",diffType:"committed"},R.path)}));return{uncommitted:V,committed:q,commitFiles:[]}},[u,d,k,g]),L=u.kind==="commit"?B:[...T,...D],F=w.useMemo(()=>Ov(L),[L]),z=w.useMemo(()=>{let $=0,V=0;for(const q of L)$+=q.additions??0,V+=q.deletions??0;return{additions:$,deletions:V,files:L.length}},[L]),A=w.useCallback(()=>{const $=j.current;if(!$)return;const V=$.getBoundingClientRect().top;let q=null,R=Number.NEGATIVE_INFINITY;for(const[H,K]of C.current){const W=K.getBoundingClientRect().top-V;W<=48&&W>R&&(R=W,q=H)}if(!q){let H=null,K=Number.POSITIVE_INFINITY;for(const[W,Q]of C.current){const J=Q.getBoundingClientRect().top-V;J<K&&(K=J,H=W)}q=H}x(q)},[]);w.useEffect(()=>{const $=j.current;if(!$)return;let V=0;const q=()=>{cancelAnimationFrame(V),V=requestAnimationFrame(A)};return $.addEventListener("scroll",q,{passive:!0}),()=>{$.removeEventListener("scroll",q),cancelAnimationFrame(V)}},[A]);const P=w.useCallback($=>{const V=C.current.get($.cardKey);V&&(V.scrollIntoView({behavior:"smooth",block:"start"}),x($.cardKey),h($.cardKey),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>h(null),1200))},[]),O=w.useCallback($=>{l(V=>V.kind==="commit"&&V.commit.hash===$.hash?{kind:"overview"}:{kind:"commit",commit:$}),_(""),x(null),j.current?.scrollTo({top:0})},[]),I=w.useCallback(()=>{l({kind:"overview"}),_(""),x(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:c("未选择工作区")});const U=p&&s&&r&&o,X=u.kind==="commit"?E:f;return t.jsxs("div",{className:"flex flex-col h-full bg-background",children:[U&&n&&i&&t.jsx(Il,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:m,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Vs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:c("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:c("{count} 个文件",{count:z.files})}),t.jsx(Ki,{additions:z.additions,deletions:z.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Ws,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Ws,{size:12}),c("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(Ki,{className:"ml-auto",additions:z.additions,deletions:z.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:X?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map($=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},$))}):b&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:c("变更加载失败")}):L.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(yr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?c("没有匹配筛选条件的文件"):u.kind==="commit"?c("该提交没有文件变更"):c("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map($=>t.jsx(Ni,{entry:$,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===$.cardKey,registerNode:M},$.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:c("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map($=>t.jsx(Ni,{entry:$,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===$.cardKey,registerNode:M},$.cardKey))})]}),D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:c("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map($=>t.jsx(Ni,{entry:$,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===$.cardKey,registerNode:M},$.cardKey))})]})]})}),t.jsxs("aside",{className:"w-60 shrink-0 border-l border-border flex flex-col min-h-0",children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(an,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:$=>_($.target.value),placeholder:c("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:L.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?c("无匹配文件"):c("暂无变更文件")}):t.jsx(Hl,{node:F,depth:0,activeKey:y,onSelect:P})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Cs,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:c("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Bv,{workingDir:e,selectedHash:S,onSelectCommit:O})})]})]})]})]})},Ri=50,$o={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 zv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?jt("{count}s ago",{count:r}):r<3600?jt("{count}m ago",{count:Math.floor(r/60)}):r<86400?jt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?jt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Hv(e){const s=e.split("/");return s[s.length-1]||e}function Wv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const $v=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},Uv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=le(),{data:m,isLoading:p,isError:v}=Tn(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
|
|
72
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((c,u)=>t.jsx($v,{line:c,lineNum:u+1},u))})},qv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:m}=le(),{data:p,isLoading:v}=Rn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Be,{size:12,className:"animate-spin"}),t.jsx("span",{children:m("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:m("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const c=$o[i.status]||$o.M,u=Wv(i.path);return t.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),o(i.path)},className:Z("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Hv(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},Kv=({workingDir:e})=>{const{t:s}=le(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:n}=tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:S=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(Ri),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,k)=>S.commits.length<Ri?void 0:k.length*Ri,enabled:!!e}),i=r?.pages.flatMap(S=>S.commits)||[],[c,u]=w.useState(null),[l,g]=w.useState(null),[_,y]=w.useState(280),[x,a]=w.useState(!1),h=w.useCallback(S=>{S.preventDefault(),a(!0);const k=S.clientX,E=_,C=N=>{const M=Math.min(480,Math.max(180,E+(N.clientX-k)));y(M)},j=()=>{a(!1),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",j)},[_]),d=S=>{c===S?(u(null),g(null)):(u(S),g(null))},f=w.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(m)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(i.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Cs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const b=i.find(S=>S.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:_},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cs,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:i.length})]})}),t.jsxs("div",{ref:f,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[i.map(S=>{const k=c===S.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:Z("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Z("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:S.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:S.message}),t.jsx(Mt,{size:12,className:Z("shrink-0 text-muted-foreground/70 transition-transform",k&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:S.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:zv(S.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[S.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:S.body}),t.jsx(qv,{workingDir:e,hash:S.hash,selectedPath:l,onSelectFile:g})]})]},S.hash)}),v&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(yr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:l}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",b?.shortHash,")"]})]}),t.jsx(Uv,{workingDir:e,hash:c,filePath:l})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(yr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function Xv(e){return wt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const s=await ve.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function Yv(e){const s=st();return bt({mutationFn:r=>ve.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:ce.previews.status(e)}),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function Vv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Gv({workspaceId:e,readOnly:s}){const{t:r}=le(),{data:o,isLoading:m,refetch:p,isFetching:v}=Xv(e),n=Yv(e),[i,c]=w.useState(""),[u,l]=w.useState(0);w.useEffect(()=>{c(o?.target??"")},[o?.target]);const g=w.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${u}`,[u,o?.ready,o?.viewUrl]),_=async()=>{if(e)try{await n.mutateAsync(i.trim()||null),l(x=>x+1),lt.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");lt.error(a)}},y=async()=>{await p(),l(x=>x+1)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:i,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),_())},disabled:s||n.isPending,placeholder:Vv(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"}),t.jsxs(Ae,{type:"button",size:"sm",variant:"outline",onClick:_,disabled:s||n.isPending,title:r("Save preview target"),children:[n.isPending?t.jsx(Be,{className:"animate-spin"}):t.jsx(iu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Ae,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Be,{className:"animate-spin"}):t.jsx(Hr,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Ae,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(sn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:m?r("Checking preview target..."):o?.ready?`${r("Proxying")} ${o.target}`:o?.configured?`${r("Preview target is not reachable")}${o.error?`: ${o.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:o?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function Qv(e){switch(e){case Nt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Nt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Nt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Nt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Uo(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Zv(e){return e.length<=34?e:`...${e.slice(-31)}`}function Wl({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:m,className:p,buttonClassName:v}){const{t:n}=le(),[i,c]=w.useState(!1),u=w.useRef(null),l=w.useMemo(()=>wn(e,s),[e,s]),g=l.find(_=>_.workspace.id===r)??l[0];return w.useEffect(()=>{if(!i)return;const _=y=>{u.current&&!u.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[i]),l.length<=1?null:t.jsxs("div",{ref:u,className:Z("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),disabled:m,className:Z("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(ws,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Uo(g.roleLabel)),children:n(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Zv(us(g.workspace))}),t.jsx(ct,{size:13,className:Z("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:l.map(_=>{const y=_.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(_.workspace.id),c(!1)},className:Z("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:y?t.jsx(vt,{size:13}):t.jsx(nn,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(_.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Uo(_.roleLabel)),children:n(_.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Qv(_.workspace.status)),children:_.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:us(_.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[_.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",_.ownerName]}),_.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",_.parentBranchName]}),t.jsx("span",{children:_.workspace.id.slice(0,8)})]})]})]},_.workspace.id)})})]})}const Jv=[{key:"review",label:"Changes",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Ys,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(wr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(wa,{size:14})}],e0=[{key:"history",label:"History",icon:t.jsx(Cs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Ys,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(wr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(wa,{size:14})}],t0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{onClick:s,className:Z("flex items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),$l=ae.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:m,projectId:p,hideChanges:v,readOnly:n,repoDeleted:i,teamRun:c,teamStatus:u,gitProps:l,workspaces:g,selectedWorkspaceId:_,onSelectWorkspace:y,tabRef:x}){const{t:a}=le(),h=w.useMemo(()=>{const N=v?e0:Jv,M=n?N.filter(T=>T.key!=="terminal"):N;return c?[{key:"team-status",label:"Team Status",icon:t.jsx(ds,{size:14})},...M]:M},[v,n,c]),[d,f]=w.useState(v?"history":"review");w.useImperativeHandle(x,()=>({setTab:N=>f(N)}),[]);const{data:b}=sd(p??""),S=w.useMemo(()=>{if(!b?.quickCommands)return[];try{return JSON.parse(b.quickCommands)}catch{return[]}},[b?.quickCommands]),[k,E]=w.useState([]),C=w.useRef(void 0);w.useEffect(()=>{m&&m!==C.current&&(C.current=m,E(N=>N.includes(m)?N:[...N,m]))},[m]),w.useEffect(()=>{n&&d==="terminal"&&f(v?"history":"review")},[d,v,n]),w.useEffect(()=>{c||d!=="team-status"||f(v?"history":"review")},[d,v,c]);const j=!!y&&wn(g,c).length>1;return t.jsxs("div",{className:Z("flex flex-col h-full bg-white",s),children:[n&&t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:a(i?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),t.jsx("div",{className:"flex items-center px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:h.map(N=>t.jsx(t0,{active:d===N.key,onClick:()=>f(N.key),icon:N.icon,label:a(N.label)},N.key))}),t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[j&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Wl,{workspaces:g,teamRun:c,selectedWorkspaceId:_,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[d==="team-status"&&c&&u,d==="editor"&&t.jsx(Nv,{workingDir:m,readOnly:n}),k.map(N=>{const M=d==="terminal"&&m===N;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:M?"block":"none"},children:t.jsx(zm,{cwd:N,isVisible:M,quickCommands:S})},N)}),d==="preview"&&t.jsx(Gv,{workspaceId:o,readOnly:n}),d==="review"&&t.jsx(Fv,{workingDir:m,workspaceId:o,branchName:l?.branchName,targetBranch:l?.targetBranch,commitMessage:l?.commitMessage,canRunGitOperations:l?.canRunGitOperations,onRefreshCommitMessage:l?.onRefreshCommitMessage,onConflict:l?.onConflict,onResolveConflicts:l?.onResolveConflicts}),d==="history"&&t.jsx(Kv,{workingDir:m})]})]})]})}),qo=1500,s0=3e3;function r0(e){const[s,r]=w.useState(null),o=w.useRef(0),m=w.useRef(null),p=w.useRef(null);return w.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Qt.connect(),i=u=>{r(u),p.current=setTimeout(()=>r(null),s0)},c=u=>{if(u.taskId!==e)return;const l={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),m.current=null,o.current===0&&(o.current=Date.now()),r(l);return}const g=o.current>0?Date.now()-o.current:0,_=qo-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),m.current=l,p.current=setTimeout(()=>i(l),qo)):_>0?(m.current=l,v(),p.current=setTimeout(()=>i(l),_)):i(l)};return n.on(ot.WORKSPACE_SETUP_PROGRESS,c),()=>{n.off(ot.WORKSPACE_SETUP_PROGRESS,c),v(),o.current=0,m.current=null}},[e]),s}function An(){const e=st();return bt({mutationFn:s=>ve.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.sessions.detail(r)}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function Ul(){const e=st();return bt({mutationFn:s=>ve.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.sessions.detail(r)})}})}function Mn(){const e=st();return bt({mutationFn:({id:s,message:r,providerId:o})=>ve.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function ql(e,s){return w.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[e,s])}function Kl({isOpen:e,onClose:s,taskId:r,taskTitle:o,taskDescription:m,taskPrompt:p}){const{t:v}=le(),[n,i]=w.useState(""),[c,u]=w.useState(""),[l,g]=w.useState(nt.WORKTREE),[_,y]=w.useState("idle"),[x,a]=w.useState(null),h=st(),d=el(r),f=An(),{data:b,isLoading:S}=Es();w.useEffect(()=>{if(!e||!b)return;const M=b.find(T=>T.availability.type!=="NOT_FOUND");M&&i(M.provider.id)},[e,b]),w.useEffect(()=>{if(e){const M=[o];m&&M.push(m),u(p?.trim()||M.join(`
|
|
73
|
+
|
|
74
|
+
`)),g(nt.WORKTREE),y("idle"),a(null)}},[e,o,m,p]);const k=_!=="idle",E=async()=>{if(!(!n||!c.trim())){a(null);try{y("creating-workspace");const M=await d.mutateAsync({workspaceKind:l});y("creating-session");const T=await ve.post(`/workspaces/${M.id}/sessions`,{providerId:n,prompt:c.trim()});y("starting-session"),await f.mutateAsync(T.id),await h.invalidateQueries({queryKey:ce.workspaces.list(r)}),y("idle"),s()}catch(M){y("idle"),a(M instanceof Error?M.message:v("启动失败,请重试"))}}},C={idle:v("启动"),"creating-workspace":v("创建工作空间..."),"creating-session":v("创建会话..."),"starting-session":v("启动 Agent...")},j=(b??[]).map(({provider:M,availability:T})=>{const D=T.type!=="NOT_FOUND";return{value:M.id,label:D?M.name:`${M.name}${v(" (不可用)")}`,disabled:!D}}),N=[{value:nt.WORKTREE,label:v("工作树模式")},{value:nt.MAIN_DIRECTORY,label:v("本地模式")}];return t.jsx(ks,{isOpen:e,onClose:k?()=>{}:s,title:v("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{variant:"outline",onClick:s,disabled:k,children:v("取消")}),t.jsx(Ae,{onClick:E,disabled:k||!n||!c.trim(),children:C[_]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("Agent")}),t.jsx(as,{value:n,onChange:i,options:j,placeholder:v(S?"加载中...":"选择 Agent"),disabled:k||S})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("模式")}),t.jsx(as,{value:l,onChange:M=>g(M),options:N,disabled:k})]})]}),l===nt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:v("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:v("任务描述")}),t.jsx("textarea",{value:c,onChange:M=>u(M.target.value),rows:5,disabled:k,placeholder:v("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),x&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:x})]})})}function Xl(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function i0(e,s,r){const o=e?.providerId??r?.providerId??null,m=o?s?.find(n=>n.provider.id===o)?.provider:null,p=m?.name??o??e?.agentType??r?.agentType??null;if(!p)return null;const v=o&&m?.name&&o!==m.name?`${m.name} (${o})`:p;return{label:p,title:v}}function Yl({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:v="top"}){const{t:n}=le(),i=i0(e,s,{providerId:m,agentType:p});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(Ys,{size:o?12:14,className:"shrink-0 text-neutral-400"}),t.jsx("span",{className:"min-w-0 truncate",children:Pi(i.label,o?12:18)})]}),t.jsx(yn,{usage:r,tooltipSide:v})]})}function Ko(e,s,r,o){if(r.filter(v=>v===o).length<=1)return e;const p=r.slice(0,s+1).filter(v=>v===o).length;return`${e} #${p}`}function n0(e){return Object.values(e).filter(Boolean).length}function Vl({mode:e,setMode:s,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:v=!1}){const{t:n}=le(),{data:i}=Es(),{data:c,isError:u,isFetching:l,isLoading:g,refetch:_}=ha(),{data:y,isError:x,isFetching:a,isLoading:h,refetch:d}=Yc(),f=w.useMemo(()=>new Map((i??[]).map(({provider:N,availability:M})=>[N.id,N.name+(M.type==="NOT_FOUND"?n(" (不可用)"):"")])),[i,n]),b=w.useMemo(()=>new Map((c??[]).map(N=>[N.id,N])),[c]),S=w.useMemo(()=>new Map((y??[]).map(N=>[N.id,N])),[y]),k=w.useMemo(()=>m.map(N=>b.get(N)).filter(N=>!!N),[b,m]);w.useEffect(()=>{c!==void 0&&p(N=>{const M=N.filter(T=>b.has(T));return M.length===N.length&&M.every((T,D)=>T===N[D])?N:M})},[c,b,p]),w.useEffect(()=>{y!==void 0&&o(N=>!N||S.has(N)?N:null)},[o,S,y]);const E=N=>{v||o(M=>M===N?null:N)},C=N=>{v||p(M=>[...M,N])},j=N=>{v||p(M=>M.filter((T,D)=>D!==N))};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 shrink-0",children:n("执行模式")}),t.jsxs("div",{className:"inline-flex rounded-md bg-white p-0.5 shadow-sm",children:[t.jsxs("button",{type:"button",onClick:()=>!v&&s("AUTO"),disabled:v,className:Z("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(Ma,{size:11}),n("自动模式")]}),t.jsxs("button",{type:"button",onClick:()=>!v&&s("CONFIRM"),disabled:v,className:Z("flex items-center gap-1.5 rounded px-2.5 py-1 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-neutral-800 text-white shadow-sm font-medium":"text-neutral-500 hover:text-neutral-700"),children:[t.jsx(Aa,{size:11}),n("确认模式")]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("section",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium text-neutral-500 mb-1.5",children:n("团队模板")}),x?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("团队模板加载失败")}),t.jsx("button",{type:"button",onClick:()=>{d()},disabled:v||a,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):h?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(Be,{size:12,className:"animate-spin"}),n("加载中...")]}):(y??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有团队模板"),t.jsx(Hn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1.5",children:(y??[]).map(N=>{const M=N.id===r,T=N.members?.length??0,D=N.members?.map(L=>L.memberPresetId)??[],B=N.members?.slice(0,3).map((L,F)=>Ko(L.memberPreset?.name??L.memberPresetId,F,D,L.memberPresetId)).join(", ");return t.jsx("button",{type:"button",onClick:()=>E(N.id),disabled:v,className:Z("w-full rounded-lg px-3 py-2 text-left transition-all disabled:cursor-not-allowed disabled:opacity-60",M?"bg-blue-50 ring-1 ring-blue-200":"bg-white hover:bg-white/80"),children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Z("text-xs truncate",M?"font-medium text-blue-800":"text-neutral-800"),children:N.name}),t.jsxs("span",{className:"text-[10px] text-neutral-400 shrink-0",children:[T,n("人")]})]}),B&&t.jsx("div",{className:"mt-0.5 text-[10px] text-neutral-400 truncate",children:B})]}),M&&t.jsx(vt,{size:13,className:"shrink-0 text-blue-600"})]})},N.id)})})]}),t.jsxs("section",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:n("追加成员")}),k.length>0&&t.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-blue-600 text-[9px] font-medium text-white px-1",children:k.length})]}),k.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:k.map((N,M)=>{const T=Ko(N.name,M,m,N.id);return t.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded bg-blue-50 text-[10px] text-neutral-700",children:[t.jsx(Tt,{name:N.name,avatar:N.avatar,className:"h-3.5 w-3.5 text-[7px]"}),t.jsx("span",{className:"max-w-[80px] truncate",children:T}),t.jsx("button",{type:"button",onClick:()=>j(M),disabled:v,className:"p-0.5 text-neutral-400 hover:text-red-500 disabled:opacity-30 rounded",children:t.jsx(Bt,{size:9})})]},`${N.id}-${M}`)})}),u?t.jsxs("div",{className:"rounded-lg bg-red-50 px-3 py-2.5 text-xs text-red-600",children:[t.jsx("span",{children:n("成员预设加载失败")}),t.jsx("button",{type:"button",onClick:()=>{_()},disabled:v||l,className:"ml-2 underline hover:no-underline",children:n("重试")})]}):g?t.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-neutral-400",children:[t.jsx(Be,{size:12,className:"animate-spin"}),n("加载中...")]}):(c??[]).length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-3 text-xs text-neutral-400",children:[n("当前没有成员预设"),t.jsx(Hn,{to:"/settings/team",className:"ml-1.5 text-blue-500 hover:underline",children:n("去创建")})]}):t.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:(c??[]).map(N=>{const M=m.filter(B=>B===N.id).length,T=f.get(N.providerId)??N.providerId,D=n0(N.capabilities);return t.jsxs("button",{type:"button",onClick:()=>C(N.id),disabled:v,className:Z("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left transition-all",v&&"cursor-not-allowed opacity-60","bg-white hover:bg-white/80"),children:[t.jsx(Tt,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs text-neutral-800 truncate",children:N.name}),t.jsxs("div",{className:"text-[10px] text-neutral-400 truncate",children:[T," · ",D,"/10"]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[M>0&&t.jsxs("span",{className:"text-[9px] text-blue-600 font-medium",children:["×",M]}),t.jsx(Wt,{size:12,className:"text-neutral-300"})]})]},N.id)})})]})]})]})}function o0({isOpen:e,onClose:s,taskId:r}){const{t:o}=le(),[m,p]=w.useState("AUTO"),[v,n]=w.useState(null),[i,c]=w.useState([]),[u,l]=w.useState(null),g=ma();w.useEffect(()=>{e&&(p("AUTO"),n(null),c([]),l(null))},[e]);const _=g.isPending,y=!!v||i.length>0,x=async()=>{if(!_){if(!v&&i.length===0){l(o("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:m,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof fa&&h.status===409){l(o("该任务已经存在 TeamRun。请刷新后再试。"));return}l(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=_||!y;return t.jsxs(ks,{isOpen:e,onClose:_?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:_,children:o("取消")}),t.jsx(Ae,{type:"button",onClick:x,disabled:a,children:o(_?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Vl,{mode:m,setMode:p,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:c,disabled:_}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function Gl({providers:e,currentProviderId:s,agentType:r,onSelect:o}){const{t:m}=le(),[p,v]=w.useState(!1),n=w.useRef(null),i=e.filter(u=>String(u.provider.agentType)===r),c=e.find(u=>u.provider.id===s);return w.useEffect(()=>{function u(l){n.current&&!n.current.contains(l.target)&&v(!1)}if(p)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[p]),i.length<=1?t.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[t.jsx(Wn,{size:14,className:"shrink-0"}),t.jsx("span",{children:c?.provider.name?Pi(c.provider.name,12):r})]}):t.jsxs("div",{className:"relative",ref:n,children:[t.jsxs("button",{onClick:()=>v(!p),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${c?.provider.name??r} (click to change)`,children:[t.jsx(Wn,{size:14,className:"shrink-0"}),t.jsx("span",{children:c?.provider.name?Pi(c.provider.name,12):r}),t.jsx(ct,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[t.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),i.map(u=>t.jsxs("button",{onClick:()=>{o(u.provider.id),v(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${u.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate max-w-[120px]",children:u.provider.name}),u.provider.isDefault&&t.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),u.provider.id===s&&t.jsx(vt,{size:14,className:"shrink-0"})]},u.provider.id))]})]})}function a0({commands:e,selectedIndex:s,query:r,hasCatalog:o,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:n,insertionHint:i="Enter / Tab to insert",compact:c=!1,onSelect:u}){const l=c?"px-1.5 pb-1.5":"px-2 pb-2",g=c?"px-2 py-1.5":"px-2.5 py-2",_=c?"max-h-36":"max-h-48";return t.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:i})]}),e.length===0?t.jsx("div",{className:`${c?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?n??`No matches for ${p}${r}`:v}):t.jsx("div",{className:`${l} ${_} overflow-y-auto`,children:e.map((y,x)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(y),className:`w-full rounded-lg border text-left transition-colors ${x===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?t.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),t.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Vt=12,gr=8;function Dr({open:e,anchorRef:s,commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:u,compact:l=!1,onSelect:g}){const _=w.useRef(null),[y,x]=w.useState(null);return w.useLayoutEffect(()=>{if(!e){x(null);return}const a=s.current;if(!a)return;let h=0;const d=()=>{const S=s.current;if(!S)return;const k=S.getBoundingClientRect(),E=window.innerWidth,C=window.innerHeight,j=l?260:320,N=l?E-Vt*2:560,M=Math.min(Math.max(k.width,j),Math.max(j,N)),T=Math.min(Math.max(Vt,k.left),Math.max(Vt,E-Vt-M)),D=C-k.bottom-gr-Vt,B=k.top-gr-Vt,L=_.current?.offsetHeight??(l?220:280),F=l?240:320,z=D<180&&B>D,P=Math.max(120,Math.min(F,z?B:D)),O=z?Math.max(Vt,k.top-gr-Math.min(L,P)):Math.min(C-Vt-Math.min(L,P),k.bottom+gr);x({top:O,left:T,width:M,maxHeight:P})},f=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};f();const b=new ResizeObserver(f);return b.observe(a),_.current&&b.observe(_.current),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),window.visualViewport?.addEventListener("resize",f),window.visualViewport?.addEventListener("scroll",f),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),window.visualViewport?.removeEventListener("resize",f),window.visualViewport?.removeEventListener("scroll",f)}},[s,r.length,l,e,m,o]),!e||!y||typeof document>"u"?null:Zt.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:_,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:t.jsx(a0,{commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:n,emptyCatalogMessage:i,emptyQueryMessage:c,insertionHint:u,compact:l,onSelect:g})})}),document.body)}function l0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=le(),m=tl();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const p=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 px-4 py-3 rounded-lg border border-amber-200 bg-amber-50 flex items-center gap-3",children:[t.jsx(Br,{size:18,className:"text-amber-600 shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-amber-900",children:o("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:s.conflictedFiles.length})})}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(Ae,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:o("中止操作")}),t.jsx(Ae,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Ql(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
+
`):"- 未获取到冲突文件列表"}function Zl(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function c0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function d0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function u0(e,s,r,o,m){const p=Ql(r),v=Zl(m);return o===Hs.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
76
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...c0(e,m)].join(`
|
|
77
|
+
`)}function h0(e){const s=e.conflictOp===Hs.REBASE?"Rebase":"Merge",r=Ql(e.conflictedFiles),o=[...Zl(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Hs.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":d0(e)].join(`
|
|
78
|
+
`)}function f0(e){if(e.teamRunId)return{type:"team_room",message:h0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:u0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Jl({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:m,sourceBranch:p,targetBranch:v,operation:n,worktreePath:i,mergeAborted:c,mergeStrategy:u,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sessions:x,currentSessionId:a,teamRunId:h}){const{t:d}=le(),[f,b]=w.useState(""),S=Mn(),k=Gi(h??""),E=vn(),C=!!h,j=a||f,N=C?k.isPending:S.isPending,M=()=>{const F=f0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:c,mergeStrategy:u,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sourceBranch:p,targetBranch:v,conflictedFiles:m,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{lt.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",B=!C&&!a&&x.length>0,L=C||!!j;return t.jsx(ks,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ae,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Ae,{onClick:M,disabled:!L||N,children:d(N?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:m.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:F},F))})]}),C&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),B&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:F=>b(F.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),x.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!C&&!j&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function m0({agentType:e,workingDir:s}){return wt({queryKey:ce.system.slashCommandCatalog(e,s),queryFn:async()=>(await ve.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function p0(e,s){const r=new Set,o=[];for(const m of[...e,...s]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),o.push(m.kind?m:{...m,kind:"builtin"}))}return o}function ti(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function g0(e){return ti(e.command)}function v0(e,s){if(!s)return 1e3;const r=g0(e),o=e.aliases?.map(ti)??[],m=[r,...o];let p=0;for(const n of m)n===s?p=Math.max(p,500):n.startsWith(s)?p=Math.max(p,400-(n.length-s.length)):n.includes(s)&&(p=Math.max(p,250-n.indexOf(s)));return p>0?p:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function Xo(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:ti(s[2]),replaceStart:r}}function ec(e,s){const r=ti(s);return r?e.map((o,m)=>({command:o,index:m,score:v0(o,r)})).filter(o=>o.score>0).sort((o,m)=>m.score-o.score||o.index-m.index||o.command.command.localeCompare(m.command.command)).map(o=>o.command):e.slice()}const x0=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],_0=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],b0=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],y0=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],S0={[It.CODEX]:x0,[It.CLAUDE_CODE]:_0,[It.GEMINI_CLI]:b0,[It.CURSOR_AGENT]:y0};function tc(e){return e.trim().toLowerCase().replace(/^\//,"")}function w0(e){return e?(S0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function C0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?tc(s[1]):null}function k0(e,s){return ec(e,tc(s))}function E0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function sc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[n,i]=w.useState(0),{data:c=[]}=m0({agentType:e,workingDir:s}),u=w.useMemo(()=>p0(w0(e),c),[e,c]),l=w.useMemo(()=>C0(r),[r]),g=w.useMemo(()=>l===null?[]:k0(u,l),[u,l]),_=w.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,v))}px`)},[v,p,m]);w.useEffect(()=>{i(0)},[e,l]),w.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const y=w.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const f=m.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,m]),x=w.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):E0(a)?(a.preventDefault(),y(g[n]??g[0]),!0):!1,[y,g,l,n]);return{allCommands:u,query:l,filteredCommands:g,selectedIndex:n,setSelectedIndex:i,applyCommand:y,handleKeyDown:x}}function j0({agentType:e,workingDir:s}){return wt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await ve.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===It.CODEX,staleTime:3e4})}function N0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function rc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[n,i]=w.useState(0),{data:c=[]}=j0({agentType:e,workingDir:s}),l=w.useMemo(()=>e===It.CODEX?Xo(r):null,[e,r])?.query??null,g=w.useMemo(()=>l===null?[]:ec(c,l),[l,c]),_=w.useCallback(()=>{const a=m.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,v))}px`)},[v,p,m]);w.useEffect(()=>{i(0)},[e,l]),w.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const y=w.useCallback(a=>{const h=Xo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=m.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,m]),x=w.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):N0(a)?(a.preventDefault(),y(g[n]??g[0]),!0):!1,[y,g,l,n]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:y,handleKeyDown:x}}const R0="/api",T0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${R0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,A0=675,Yo=320,Vo=1200;function M0(){const{t:e}=le();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Go=[{status:ge.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Sa,{className:"w-3 h-3"})},{status:ge.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(ya,{className:"w-3 h-3"})},{status:ge.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(ba,{className:"w-3 h-3"})},{status:ge.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(_a,{className:"w-3 h-3"})},{status:ge.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(xa,{className:"w-3 h-3"})}];function D0({status:e,onChangeStatus:s}){const{t:r}=le(),[o,m]=w.useState(!1),p=w.useRef(null);w.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=Go.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&m(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:Go.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function L0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o}){const{t:m}=le(),[p,v]=w.useState(""),[n,i]=w.useState(!1),[c,u]=w.useState(!1),[l,g]=w.useState(!1),[_,y]=w.useState(!1),[x,a]=w.useState(!1),[h,d]=w.useState(!1),[f,b]=w.useState(null),S=w.useRef(null),[k,E]=w.useState(!1),[C,j]=w.useState(null),[N,M]=w.useState(void 0),[T,D]=w.useState(!1),B=w.useRef(null),L=w.useRef(null),F=w.useRef(null),z=w.useRef(null),{scrollRef:A,contentRef:P,isAtBottom:O,scrollToBottom:I}=bn({resize:"smooth",initial:"instant"}),[U,X]=w.useState(A0),[$,V]=w.useState(!0),[q,R]=w.useState(!1),H=w.useRef(0),K=w.useRef(0),W=w.useRef(null),{data:Q,isLoading:J}=gn(e?.id??""),oe=r0(e?.id),{data:fe}=pa(e?.id??""),{data:Ne}=ga(fe?.id??""),je=Gi(fe?.id??""),se=fe??null,Oe=!!se,Me=fe===null,Fe=!!(e?.id&&fe===null),{data:ze,isLoading:Qe}=va(e?.id??"",Fe);w.useEffect(()=>{D(!1),j(null),M(void 0)},[e?.id]);const Te=w.useMemo(()=>nl(Q,se,N),[N,se,Q]);w.useEffect(()=>{N&&!Q?.some(te=>te.id===N)&&M(void 0)},[N,Q]);const ee=w.useMemo(()=>Q?.find(te=>te.id===Te),[Te,Q]),xe=ee?.status===Nt.ACTIVE?ee.id:void 0,Re=ol(ee,se);w.useEffect(()=>{if(!T||!Q)return;Q.some(de=>de.status==="ACTIVE"&&de.sessions&&de.sessions.length>0)&&D(!1)},[Q,T]);const G=w.useMemo(()=>{if(T||!Q)return null;const te=ht=>{const di=ht.createdAt,Ms=ht.endedAt??ht.startedAt??di;if(!Ms)return 0;const ms=Date.parse(Ms);return Number.isNaN(ms)?0:ms},de=(ht,di)=>{const Ms=ht.filter(ms=>di.includes(ms.status));return Ms.length===0?null:Ms.sort((ms,Tc)=>te(Tc)-te(ms))[0]??null},Xe=Q.filter(ht=>ht.status==="ACTIVE"&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]),yt=de(Xe,[Je.RUNNING])??de(Xe,[Je.PENDING])??de(Xe,[Je.COMPLETED,Je.FAILED,Je.CANCELLED]);if(yt)return yt;const gt=Q.filter(ht=>(ht.status==="MERGED"||ht.status==="ABANDONED"||ht.status==="HIBERNATED")&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]);return de(gt,[Je.COMPLETED,Je.FAILED,Je.CANCELLED])},[Q,T]),ne=G?.id??"",ue=Oe?C??"":ne,ye=w.useMemo(()=>{if(!C||!Q)return null;for(const te of Q){const de=te.sessions?.find(Xe=>Xe.id===C);if(de)return de}return null},[C,Q]),Se=w.useMemo(()=>{if(!C||!se?.invocations)return null;const te=se.invocations.filter(de=>de.sessionId===C);return te.length===0?null:te.sort((de,Xe)=>{const yt=Date.parse(de.updatedAt??de.createdAt??""),gt=Date.parse(Xe.updatedAt??Xe.createdAt??"");return(Number.isNaN(gt)?0:gt)-(Number.isNaN(yt)?0:yt)})[0]??null},[C,se?.invocations]),Y=w.useMemo(()=>!Se?.memberId||!se?.members?null:se.members.find(te=>te.id===Se.memberId)??null,[Se?.memberId,se?.members]),ie=C?ye:G??null,he=ie?.status===Je.RUNNING||ie?.status===Je.PENDING,_e=!!e?.projectArchivedAt,Ie=!!e?.projectRepoDeletedAt,He=m(Ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Ve}=Es(),[$e,De]=w.useState(null);w.useEffect(()=>{De(G?.providerId??null)},[G?.providerId]);const rt=w.useMemo(()=>!G||!Q?!1:!Q.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Xe=>Xe.id===G.id)),[G,Q]),we=w.useMemo(()=>{if(!(!Q||T)){if(ee)return Jt(ee);for(const te of Q)if(te.status==="ACTIVE"&&Jt(te))return Jt(te);return Jt(Q[0])}},[T,ee,Q]),ke=sc({agentType:G?.agentType,workingDir:we,input:p,setInput:v,textareaRef:F,minHeight:60,maxHeight:300}),Le=rc({agentType:G?.agentType,workingDir:we,input:p,setInput:v,textareaRef:F,minHeight:60,maxHeight:300}),{data:Ge}=xn(Re?xe??"":""),dt=ee?.sessions??[],et=us(ee),ft=ee?.commitMessage,Ct=w.useMemo(()=>al(ee,Q,e?.mainBranch??""),[ee,e?.mainBranch,Q]),Ce=w.useMemo(()=>Ge?.conflictOp&&Ge.conflictedFiles.length>0?{conflictOp:Ge.conflictOp,conflictedFiles:Ge.conflictedFiles}:f,[Ge?.conflictOp,Ge?.conflictedFiles,f]),ut=Ce?.targetWorkspaceId??xe,_t=Ce?.targetWorktreePath??ee?.worktreePath,mt=Ce?.sourceBranch??et,kt=Ce?.targetBranch??Ct,Ue=st(),it=w.useCallback(async()=>e?.id?Ue.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ve.get(`/tasks/${e.id}/body`)}):null,[Ue,e?.id]),Ft=w.useCallback(()=>e?.id?Ue.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Ue]);w.useEffect(()=>{if(!k)return;const te=de=>{L.current&&!L.current.contains(de.target)&&E(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[k]);const zt=Mn(),Rs=vn(),Ut=Vc(),is=el(e?.id??""),rr=An(),fs=ef(),qt=w.useMemo(()=>!Q||Q.some(de=>de.status==="ACTIVE")?null:Q.find(de=>de.status==="HIBERNATED")??null,[Q]),ns=w.useRef(null);w.useEffect(()=>{qt&&ns.current!==qt.id&&(fs.isPending||(ns.current=qt.id,fs.mutate(qt.id,{onSettled:()=>{ns.current=null}})))},[qt,fs]);const ir=w.useCallback(async()=>{if(!e?.id)return;const te=G?.providerId??Ve?.find(de=>de.availability.type!=="NOT_FOUND")?.provider.id;if(te){y(!1),a(!0);try{const Xe=(await it())?.prompt??e.title;await Ut.mutateAsync(e.id),D(!0);const yt=await is.mutateAsync({}),gt=await ve.post(`/workspaces/${yt.id}/sessions`,{providerId:te,prompt:Xe});await rr.mutateAsync(gt.id),await Ue.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(de){console.error("[retry] failed:",de),D(!1)}finally{a(!1)}}},[e?.id,e?.title,G?.providerId,Ve,it,Ut,is,rr,Ue]),nr=w.useCallback(async()=>{e?.id&&(await it(),i(!0))},[it,e?.id]),si=w.useCallback(()=>{ee?.id&&Rs.mutate({workspaceId:ee.id})},[Rs,ee?.id]),or=w.useCallback(()=>{!e?.id||!s||(s(e.id),g(!1))},[e?.id,s]),ar=w.useCallback(te=>{j(te),requestAnimationFrame(()=>{I()})},[I]),ri=w.useCallback(()=>{j(null)},[]),Ts=w.useCallback(te=>{b(te??null),d(!0)},[]),ii=w.useCallback(te=>je.mutateAsync(te),[je]),Kt=w.useCallback(()=>{Ue.invalidateQueries({queryKey:Gc.all})},[Ue]),{isConnected:Xt,isLoadingSnapshot:re,logs:me,entries:Ke,attach:Pe}=Ca({sessionId:ue,sessionStatus:ie?.status,onExit:w.useCallback(()=>{Ue.invalidateQueries({queryKey:["workspaces"]})},[Ue])});w.useEffect(()=>{if(!e?.id)return;const te=Qt.connect();te.emit(vs.SUBSCRIBE,{topic:"task",id:e.id});const de=gt=>{gt.taskId===e.id&&(Ue.invalidateQueries({queryKey:["tasks"]}),Kt())},Xe=gt=>{gt.taskId===e.id&&(Ue.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),Kt())},yt=gt=>{gt.taskId===e.id&&(Ue.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),Kt())};return te.on(ot.TASK_UPDATED,de),te.on(ot.WORKSPACE_COMMIT_MESSAGE_UPDATED,Xe),te.on(ot.WORKSPACE_HIBERNATED,yt),()=>{te.off(ot.TASK_UPDATED,de),te.off(ot.WORKSPACE_COMMIT_MESSAGE_UPDATED,Xe),te.off(ot.WORKSPACE_HIBERNATED,yt),te.emit(vs.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Ue,Kt]),w.useEffect(()=>{if(!ue)return;const te=Qt.connect(),de=Xe=>{Xe.sessionId===ue&&(Ue.invalidateQueries({queryKey:["workspaces"]}),Kt())};return te.on(ot.SESSION_COMPLETED,de),()=>{te.off(ot.SESSION_COMPLETED,de)}},[ue,Ue,Kt]);const{todos:pt}=ka(Ke),{files:Lt,addFiles:Ee,removeFile:Yt,clear:Ht,buildMarkdownLinks:os,hasFiles:As,isUploading:lr}=Yr(),bc=w.useMemo(()=>Xl(ie),[ie?.tokenUsage]),Ln=ql(me,bc);w.useEffect(()=>{ue&&Xt&&Pe()},[ue,Xt,Pe]);const Pn=w.useRef(e?.id);w.useEffect(()=>{if(Pn.current!==e?.id&&A.current){const te=A.current;requestAnimationFrame(()=>{te.scrollTop=te.scrollHeight})}Pn.current=e?.id},[e?.id,A]);const ni=Ul(),oi=w.useRef(!1),On=w.useCallback(async()=>{if(!p.trim()&&!As||!ue||oi.current||lr)return;oi.current=!0;const te=os(),de=[p.trim(),te].filter(Boolean).join(`
|
|
79
|
+
|
|
80
|
+
`);v(""),Ht(),F.current&&(F.current.style.height="60px"),zt.mutate({id:ue,message:de,providerId:$e??void 0},{onSuccess:()=>{Pe()},onSettled:()=>{oi.current=!1}})},[p,ue,zt,Pe,As,lr,os,Ht,$e]),yc=w.useCallback(async()=>{ue&&(await ni.mutateAsync(ue),Ue.invalidateQueries({queryKey:["workspaces"]}))},[ue,ni,Ue]),Sc=w.useCallback(te=>{const de=te.target.files;de&&de.length>0&&Ee(Array.from(de)),te.target.value=""},[Ee]),wc=w.useCallback(te=>{const de=te.clipboardData.items,Xe=[];for(const yt of de)if(yt.kind==="file"){const gt=yt.getAsFile();gt&&Xe.push(gt)}Xe.length>0&&(te.preventDefault(),Ee(Xe))},[Ee]),[In,ai]=w.useState(!1),Cc=w.useCallback(te=>{te.preventDefault(),ai(!0)},[]),kc=w.useCallback(te=>{te.preventDefault(),ai(!1)},[]),Ec=w.useCallback(te=>{te.preventDefault(),ai(!1);const de=te.dataTransfer.files;de.length>0&&Ee(Array.from(de))},[Ee]),li=w.useCallback(te=>{const de=te.clientX-H.current,Xe=Math.max(Yo,Math.min(K.current+de,Vo));W.current&&(W.current.style.width=`${Xe}px`)},[]),ci=w.useCallback(()=>{if(R(!1),W.current){const te=W.current.getBoundingClientRect().width;X(Math.max(Yo,Math.min(Math.round(te),Vo)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);w.useEffect(()=>{if(q)return document.addEventListener("mousemove",li),document.addEventListener("mouseup",ci),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",li),document.removeEventListener("mouseup",ci),document.body.style.cursor="",document.body.style.userSelect=""}},[q,li,ci]);const jc=w.useCallback(te=>{te.preventDefault(),H.current=te.clientX,K.current=U,R(!0)},[U]),Nc=w.useCallback(()=>{V(te=>!te)},[]),Rc=w.useCallback(te=>{v(te.target.value);const de=te.target;de.style.height="auto";const Xe=de.scrollHeight;de.style.height=`${Math.max(60,Math.min(Xe,300))}px`},[]);return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(D0,{status:e.status,onChangeStatus:!_e&&o?te=>o(e.id,te):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:si,disabled:!we||_e,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:t.jsx(Ys,{size:16})}),t.jsx("button",{onClick:Nc,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:m("Toggle Workspace"),children:$?t.jsx(Qd,{size:16}):t.jsx(Sr,{size:16})}),(s||Me)&&!_e&&t.jsxs("div",{className:"relative",ref:L,children:[t.jsx("button",{onClick:()=>E(te=>!te),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:m("More actions"),children:t.jsx(Ra,{size:16})}),k&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[Me&&t.jsxs("button",{onClick:()=>{u(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Wt,{size:15}),t.jsx("span",{children:m("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{y(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ad,{size:15}),t.jsx("span",{children:m("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{g(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Ji,{size:15}),t.jsx("span",{children:m("删除任务")})]})]})]})]})]})]})]}),Re&&xe&&Ge&&t.jsx(l0,{workspaceId:xe,gitStatus:Ge,onResolve:()=>Ts()}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{ref:W,className:`flex flex-col bg-background relative ${$?"flex-shrink-0":"flex-1"}`,style:{width:$?U:"100%"},children:Oe&&se?C?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:m("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:C})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Yl,{session:ie,providers:Ve,usage:Ln,providerIdFallback:Y?.providerId,agentTypeFallback:ie?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:ri,children:[t.jsx(Ws,{size:13}),t.jsx("span",{children:m("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:P,className:`w-full ${$?"":"max-w-5xl mx-auto"}`,children:re?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):me.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:m(he?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(_r,{logs:me})})}),!O&&t.jsxs("button",{onClick:()=>I(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":m("Scroll to bottom"),children:[t.jsx($s,{size:14}),t.jsx("span",{children:m("回到底部")})]})]}),pt.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:`${$?"":"max-w-5xl mx-auto"}`,children:t.jsx(br,{todos:pt})})})]}):t.jsx(il,{teamRun:se,messages:Ne??se.messages??[],readOnly:_e,readOnlyMessage:He,onSendMessage:ii,onViewInvocationSession:ar,centered:!$}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:A,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:P,className:`w-full min-w-0 ${$?"":"max-w-5xl mx-auto"}`,children:[(Qe||ze?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Qe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:m("Loading...")}):ze?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(Qi,{urlTransform:T0,components:Zi,children:ze.body})}):null}),oe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[oe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:oe.currentIndex,total:oe.totalCommands,command:oe.currentCommand})})]}),oe.status==="completed"&&t.jsx("span",{className:"text-success",children:m("Setup 完成")}),oe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:m("Setup 失败: {error}",{error:oe.error})})]}),J?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:m("Loading...")})]}):ne?re?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):me.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:m(he?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(_r,{logs:me}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(ls,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:m(_e?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:_e?He:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!_e&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Ae,{onClick:nr,children:[t.jsx(ls,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),Me&&t.jsxs(Ae,{variant:"outline",onClick:()=>u(!0),children:[t.jsx(Wt,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!O&&t.jsxs("button",{onClick:()=>I(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":m("Scroll to bottom"),children:[t.jsx($s,{size:14}),t.jsx("span",{children:m("回到底部")})]})]}),pt.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:`${$?"":"max-w-5xl mx-auto"}`,children:t.jsx(br,{todos:pt})})}),_e?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:`${$?"":"max-w-5xl mx-auto"}`,children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:He})})}):rt?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:`${$?"":"max-w-5xl mx-auto"}`,children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:m("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:nr,children:[t.jsx(ls,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Cc,onDragLeave:kc,onDrop:Ec,children:[t.jsx("div",{className:`${$?"":"max-w-5xl mx-auto"}`,children:t.jsxs("div",{ref:B,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${In?"border-info bg-info/5":"border-border"}`,children:[t.jsx(Vr,{files:Lt,onRemove:Yt}),t.jsx("textarea",{ref:F,value:p,onChange:Rc,onPaste:wc,onKeyDown:te=>{Le.handleKeyDown(te)||ke.handleKeyDown(te)||te.key==="Enter"&&!te.shiftKey&&!te.repeat&&!te.nativeEvent.isComposing&&te.nativeEvent.keyCode!==229&&(te.preventDefault(),On())},rows:1,placeholder:m(In?"Drop files here...":ne&&!he?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:z,type:"file",multiple:!0,className:"hidden",onChange:Sc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>z.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:m("Upload file"),children:t.jsx(Ir,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[G&&Ve&&t.jsx(Gl,{providers:Ve,currentProviderId:$e,agentType:G.agentType,onSelect:De}),t.jsx(yn,{usage:Ln}),he&&!p.trim()&&!As?t.jsx("button",{onClick:yc,disabled:ni.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ss,{size:14})}):t.jsx("button",{onClick:On,disabled:!p.trim()&&!As||lr,className:`p-2 rounded-lg transition-all duration-200 ${(p.trim()||As)&&!lr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Fr,{size:18})})]})]})]})}),t.jsx(Dr,{open:ke.query!==null,anchorRef:B,commands:ke.filteredCommands,selectedIndex:ke.selectedIndex,query:ke.query??"",hasCatalog:ke.allCommands.length>0,onSelect:ke.applyCommand}),t.jsx(Dr,{open:Le.query!==null,anchorRef:B,commands:Le.filteredSkills,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Le.applySkill})]})]})}),$&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/50 transition-colors z-30 flex-shrink-0 border-l border-border",onMouseDown:jc}),$&&t.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:t.jsx($l,{sessionId:ne||void 0,workspaceId:Te,workingDir:we,projectId:e.projectId,readOnly:_e,repoDeleted:Ie,teamRun:se,teamStatus:se?t.jsx(dl,{teamRun:se,workspaces:Q,selectedWorkspaceId:Te,onSelectWorkspace:M,onViewInvocationSession:ar}):void 0,workspaces:Q,selectedWorkspaceId:Te,onSelectWorkspace:M,tabRef:S,gitProps:Re&&xe?{branchName:et,targetBranch:Ct,commitMessage:ft,canRunGitOperations:!0,onRefreshCommitMessage:Ft,onConflict:Ts,onResolveConflicts:()=>Ts()}:void 0})})]}),!_e&&t.jsx(Kl,{isOpen:n,onClose:()=>i(!1),taskId:e.id,taskTitle:ze?.title??e.title,taskDescription:ze?.body??"",taskPrompt:ze?.prompt}),Me&&!_e&&t.jsx(o0,{isOpen:c,onClose:()=>u(!1),taskId:e.id}),Re&&ut&&Ce&&t.jsx(Jl,{open:h,onOpenChange:te=>{d(te),te||b(null)},workspaceId:ut,conflictOp:Ce.conflictOp,conflictedFiles:Ce.conflictedFiles,sourceBranch:mt,targetBranch:kt,operation:Ge?.operation,worktreePath:_t,mergeAborted:Ce.mergeAborted,mergeStrategy:Ce.mergeStrategy,sourceWorkspaceId:Ce.sourceWorkspaceId,targetWorkspaceId:Ce.targetWorkspaceId,sourceWorktreePath:Ce.sourceWorktreePath,targetWorktreePath:Ce.targetWorktreePath,sessions:dt,currentSessionId:Oe?void 0:ne,teamRunId:se?.id}),t.jsx(Or,{isOpen:_,onClose:()=>y(!1),onConfirm:ir,title:m("重新开始任务"),description:t.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:x}),t.jsx(_n,{isOpen:l,onClose:()=>g(!1),onConfirm:or,taskId:e.id,taskTitle:e.title,workspaces:Q,isLoading:r})]}):t.jsx(M0,{})}function Dn(e){switch(e){case Ot.TODO:return ge.Pending;case Ot.IN_PROGRESS:return ge.Running;case Ot.IN_REVIEW:return ge.Review;case Ot.DONE:return ge.Done;case Ot.CANCELLED:return ge.Cancelled}}function P0(e){switch(e){case ge.Pending:return Ot.TODO;case ge.Running:return Ot.IN_PROGRESS;case ge.Review:return Ot.IN_REVIEW;case ge.Done:return Ot.DONE;case ge.Cancelled:return Ot.CANCELLED}}function O0(e){switch(e){case It.CLAUDE_CODE:return"Claude Code";case It.GEMINI_CLI:return"Gemini CLI";case It.CURSOR_AGENT:return"Cursor Agent";case It.CODEX:return"Codex"}}const Lr=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function ic(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function nc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function oc(e){return e?e.workspaceKind===nt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function I0(e){return{id:e.id,name:e.name,color:e.color||Lr[ic(e.name,Lr.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function B0(e){const s=nc(e);if(!s)return{agent:"—",branch:"—"};const r=oc(s),o=s.sessions;if(o&&o.length>0){const m=o[o.length-1];return{agent:O0(m.agentType),branch:r}}return{agent:"—",branch:r}}function F0(e){const{agent:s,branch:r}=B0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Dn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function z0(e,s,r){const o=nc(e.workspaces,r),m=oc(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Lr[ic(s.name,Lr.length)],title:e.titlePreview??e.title,status:Dn(e.status),branch:m,mainBranch:o?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const Qo={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 H0(e){const s=e.split("/");return s[s.length-1]||e}function W0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function $0({workingDir:e,filePath:s,type:r}){const{t:o}=le(),{data:m,isLoading:p,isError:v}=Ol(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
81
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,u)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",l,g),children:c},u)})})}function U0({entry:e,type:s,workingDir:r}){const[o,m]=w.useState(!1),p=Qo[e.status]||Qo.M,v=W0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:Z("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:H0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(ct,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx($0,{workingDir:r,filePath:e.path,type:s})]})}function Zo({title:e,entries:s,type:r,workingDir:o,defaultOpen:m}){const{t:p}=le(),[v,n]=w.useState(m);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(ct,{size:14}):t.jsx(Mt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(U0,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function q0({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:m}=Nn(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(m)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const p=r?.uncommitted||[],v=r?.committed||[];return p.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Vs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(Zo,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(Zo,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Ti=50,Jo={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 K0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?jt("{count}s ago",{count:r}):r<3600?jt("{count}m ago",{count:Math.floor(r/60)}):r<86400?jt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?jt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function X0(e){const s=e.split("/");return s[s.length-1]||e}function Y0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function V0({workingDir:e,hash:s,filePath:r}){const{t:o}=le(),{data:m,isLoading:p,isError:v}=Tn(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=m?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
82
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((c,u)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",l,g),children:c},u)})})}function G0({entry:e,workingDir:s,hash:r}){const[o,m]=w.useState(!1),p=Jo[e.status]||Jo.M,v=Y0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(n=>!n),className:Z("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:X0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(ct,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(V0,{workingDir:s,hash:r,filePath:e.path})]})}function Q0({commit:e,workingDir:s}){const{t:r}=le(),[o,m]=w.useState(!1),{data:p,isLoading:v}=Rn(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>m(i=>!i),className:Z("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:Z("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:K0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(ct,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(G0,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function Z0({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:n}=tn({queryKey:ce.git.log(e||""),queryFn:({pageParam:c=0})=>ve.get("/git/log",{params:{workingDir:e||"",limit:String(Ti),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,u)=>c.commits.length<Ti?void 0:u.length*Ti,enabled:!!e}),i=r?.pages.flatMap(c=>c.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Cs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(c=>t.jsx(Q0,{commit:c,workingDir:e},c.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const J0="/api",ex=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${J0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function tx({status:e}){const s={[ge.Running]:"bg-blue-500",[ge.Review]:"bg-amber-500",[ge.Pending]:"bg-neutral-400",[ge.Done]:"bg-emerald-500",[ge.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const sx=[{key:"chat",label:"Chat",icon:en},{key:"changes",label:"Changes",icon:Vs},{key:"history",label:"History",icon:Cs},{key:"workspace",label:"Workspace",icon:zr}],rx=[{key:"chat",label:"Team room",icon:en},{key:"team-status",label:"Team Status",icon:ds},{key:"changes",label:"Changes",icon:Vs},{key:"workspace",label:"Workspace",icon:zr}];function ix({task:e,onBack:s,onDeleteTask:r,isDeleting:o}){const{t:m}=le(),[p,v]=w.useState("chat"),[n,i]=w.useState(""),[c,u]=w.useState(!1),[l,g]=w.useState(!1),[_,y]=w.useState(!1),[x,a]=w.useState(null),[h,d]=w.useState(void 0),f=w.useRef(null),b=w.useRef(null),S=w.useRef(null),k=w.useRef(null),{scrollRef:E,contentRef:C,isAtBottom:j,scrollToBottom:N}=bn({resize:"smooth",initial:"instant"}),M=st();w.useEffect(()=>{if(!_)return;const re=me=>{b.current&&!b.current.contains(me.target)&&y(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[_]);const{data:T,isLoading:D}=gn(e.id),{data:B}=pa(e.id),{data:L}=ga(B?.id??""),F=Gi(B?.id??""),z=B??null,A=z?rx:sx,P=B===null,{data:O,isLoading:I}=va(e.id,P);w.useEffect(()=>{d(void 0),a(null)},[e.id]),w.useEffect(()=>{z&&p==="history"&&v("chat"),!z&&p==="team-status"&&v("chat")},[p,z]);const U=w.useMemo(()=>nl(T,z,h),[h,z,T]);w.useEffect(()=>{h&&!T?.some(re=>re.id===h)&&d(void 0)},[h,T]);const X=w.useMemo(()=>T?.find(re=>re.id===U),[U,T]),$=w.useMemo(()=>{if(T){if(X)return Jt(X);for(const re of T)if(re.status==="ACTIVE"&&Jt(re))return Jt(re);return Jt(T[0])}},[X,T]),V=X?.status===Nt.ACTIVE?X.id:void 0,q=ol(X,z),R=X?.branchName??"",H=X?.commitMessage,K=w.useMemo(()=>al(X,T,e?.mainBranch??""),[X,e?.mainBranch,T]),{data:W}=xn(V??""),{data:Q}=Nn($),J=Q?.committed?.length,[oe,fe]=w.useState(!1),[Ne,je]=w.useState(null),se=w.useMemo(()=>W?.conflictOp&&W.conflictedFiles.length>0?{conflictOp:W.conflictOp,conflictedFiles:W.conflictedFiles}:Ne,[W?.conflictOp,W?.conflictedFiles,Ne]),Oe=se?.targetWorkspaceId??V,Me=se?.targetWorktreePath??X?.worktreePath,Fe=se?.sourceBranch??R,ze=se?.targetBranch??K,Qe=X?.sessions??[],Te=w.useCallback(re=>{je(re??null),fe(!0)},[]),ee=w.useCallback(()=>e?.id?M.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,M]),xe=w.useCallback(async()=>M.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ve.get(`/tasks/${e.id}/body`)}),[M,e.id]),Re=w.useMemo(()=>{if(!T)return null;const re=T.filter(Ee=>Ee.status==="ACTIVE"&&Array.isArray(Ee.sessions)).flatMap(Ee=>Ee.sessions??[]),me=Ee=>{const Yt=Ee.createdAt,Ht=Ee.endedAt??Ee.startedAt??Yt;if(!Ht)return 0;const os=Date.parse(Ht);return Number.isNaN(os)?0:os},Ke=Ee=>{const Yt=re.filter(Ht=>Ee.includes(Ht.status));return Yt.length===0?null:Yt.sort((Ht,os)=>me(os)-me(Ht))[0]??null},Pe=Ke([Je.RUNNING])??Ke([Je.PENDING])??Ke([Je.COMPLETED,Je.FAILED,Je.CANCELLED]);if(Pe)return Pe;const Lt=T.filter(Ee=>(Ee.status==="ABANDONED"||Ee.status==="MERGED"||Ee.status==="HIBERNATED")&&Array.isArray(Ee.sessions)).flatMap(Ee=>Ee.sessions??[]).filter(Ee=>[Je.COMPLETED,Je.FAILED,Je.CANCELLED].includes(Ee.status));return Lt.length===0?null:Lt.sort((Ee,Yt)=>me(Yt)-me(Ee))[0]??null},[T]),G=Re?.id??"",ne=z?x??"":G,ue=w.useMemo(()=>{if(!x||!T)return null;for(const re of T){const me=re.sessions?.find(Ke=>Ke.id===x);if(me)return me}return null},[x,T]),ye=w.useMemo(()=>{if(!x||!z?.invocations)return null;const re=z.invocations.filter(me=>me.sessionId===x);return re.length===0?null:re.sort((me,Ke)=>{const Pe=Date.parse(me.updatedAt??me.createdAt??""),pt=Date.parse(Ke.updatedAt??Ke.createdAt??"");return(Number.isNaN(pt)?0:pt)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[x,z?.invocations]),Se=w.useMemo(()=>!ye?.memberId||!z?.members?null:z.members.find(re=>re.id===ye.memberId)??null,[ye?.memberId,z?.members]),Y=x?ue:Re??null,ie=Y?.status===Je.RUNNING||Y?.status===Je.PENDING,he=!!e.projectArchivedAt,_e=!!e.projectRepoDeletedAt,Ie=m(_e?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),He=w.useMemo(()=>!Re||!T?!1:!T.some(me=>me.status==="ACTIVE"&&me.sessions?.some(Ke=>Ke.id===Re.id)),[Re,T]),{data:Ve}=Es(),[$e,De]=w.useState(null),rt=$e?.sessionId===G?$e.providerId:Re?.providerId??null,we=w.useCallback(re=>{De({sessionId:G,providerId:re})},[G]),ke=sc({agentType:Re?.agentType,workingDir:$,input:n,setInput:i,textareaRef:S,minHeight:40,maxHeight:140}),Le=rc({agentType:Re?.agentType,workingDir:$,input:n,setInput:i,textareaRef:S,minHeight:40,maxHeight:140}),Ge=$&&X?X.id:void 0,dt=Mn(),et=vn(),ft=Ul(),{isConnected:Ct,isLoadingSnapshot:Ce,logs:ut,entries:_t,attach:mt}=Ca({sessionId:ne,sessionStatus:Y?.status,onExit:w.useCallback(()=>{M.invalidateQueries({queryKey:["workspaces"]})},[M])}),{todos:kt}=ka(_t),{files:Ue,addFiles:it,removeFile:Ft,clear:zt,buildMarkdownLinks:Rs,hasFiles:Ut,isUploading:is}=Yr(),rr=w.useMemo(()=>Xl(Y),[Y?.tokenUsage]),fs=ql(ut,rr);w.useEffect(()=>{ne&&Ct&&mt()},[ne,Ct,mt]);const qt=w.useRef(null);w.useEffect(()=>{if(qt.current!==e.id&&E.current){const re=E.current;requestAnimationFrame(()=>{re.scrollTop=re.scrollHeight})}qt.current=e.id},[e.id,E]);const ns=w.useRef(!1),ir=w.useCallback(async()=>{if(!n.trim()&&!Ut||!G||ns.current||is)return;ns.current=!0;const re=Rs(),me=[n.trim(),re].filter(Boolean).join(`
|
|
83
|
+
|
|
84
|
+
`);i(""),zt(),S.current&&(S.current.style.height="40px"),dt.mutate({id:G,message:me,providerId:rt??void 0},{onSuccess:()=>mt(),onSettled:()=>{ns.current=!1}})},[n,G,dt,mt,Ut,is,Rs,zt,rt]),nr=w.useCallback(async()=>{G&&(await ft.mutateAsync(G),M.invalidateQueries({queryKey:["workspaces"]}))},[G,ft,M]),si=w.useCallback(re=>F.mutateAsync(re),[F]),or=w.useCallback(re=>{a(re),v("chat"),requestAnimationFrame(()=>{N()})},[N]),ar=w.useCallback(()=>{a(null)},[]),ri=w.useCallback(re=>{const me=re.target.files;me&&me.length>0&&it(Array.from(me)),re.target.value=""},[it]),Ts=w.useCallback(re=>{const me=re.clipboardData.items,Ke=[];for(const Pe of me)if(Pe.kind==="file"){const pt=Pe.getAsFile();pt&&Ke.push(pt)}Ke.length>0&&(re.preventDefault(),it(Ke))},[it]),ii=w.useCallback(re=>{i(re.target.value);const me=re.target;me.style.height="auto",me.style.height=`${Math.max(40,Math.min(me.scrollHeight,140))}px`},[]),Kt=w.useCallback(()=>{Ge&&et.mutate({workspaceId:Ge})},[et,Ge]),Xt=w.useRef(null);return w.useEffect(()=>{const re=window.visualViewport;if(!re)return;let me=!1;const Ke=()=>{Xt.current&&(Xt.current.style.height=`${re.height}px`,Xt.current.style.top=`${re.offsetTop}px`)},Pe=()=>Ke(),pt=()=>{me||Ke()},Lt=()=>{me=!0},Ee=()=>{me=!1,requestAnimationFrame(Ke)};return re.addEventListener("resize",Pe),re.addEventListener("scroll",pt),document.addEventListener("touchstart",Lt,{passive:!0}),document.addEventListener("touchend",Ee,{passive:!0}),document.addEventListener("touchcancel",Ee,{passive:!0}),()=>{re.removeEventListener("resize",Pe),re.removeEventListener("scroll",pt),document.removeEventListener("touchstart",Lt),document.removeEventListener("touchend",Ee),document.removeEventListener("touchcancel",Ee)}},[]),w.useEffect(()=>{const re=Xt.current;if(!re)return;const me=Ke=>{let Pe=Ke.target;for(;Pe&&Pe!==re;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const Lt=window.getComputedStyle(Pe).overflowY;if((Lt==="auto"||Lt==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Ke.preventDefault()};return re.addEventListener("touchmove",me,{passive:!1}),()=>re.removeEventListener("touchmove",me)},[]),t.jsxs("div",{ref:Xt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ws,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.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("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(tx,{status:e.status}),t.jsx("button",{onClick:Kt,disabled:!Ge||he,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Ys,{size:16})}),r&&!he&&t.jsxs("div",{className:"relative",ref:b,children:[t.jsx("button",{onClick:()=>y(re=>!re),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Ra,{size:16})}),_&&t.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:t.jsxs("button",{onClick:()=>{g(!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:[t.jsx(Ji,{size:15}),t.jsx("span",{children:m("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:re,label:me,icon:Ke})=>t.jsxs("button",{onClick:()=>v(re),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${p===re?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ke,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:m(me)})]},re))})]}),p==="chat"&&(z?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:x?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:x})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Yl,{session:Y,providers:Ve,usage:fs,compact:!0,providerIdFallback:Se?.providerId,agentTypeFallback:Y?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:ar,children:[t.jsx(Ws,{size:12}),t.jsx("span",{children:m("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:C,children:Ce?t.jsx(Ai,{label:m("Loading logs...")}):ut.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:m(ie?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(_r,{logs:ut})})}),!j&&t.jsxs("button",{onClick:()=>N(),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":m("Scroll to bottom"),children:[t.jsx($s,{size:12}),t.jsx("span",{children:m("回到底部")})]})]}),kt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(br,{todos:kt,compact:!0})})]}):t.jsx(il,{teamRun:z,messages:L??z.messages??[],readOnly:he,readOnlyMessage:Ie,onSendMessage:si,onViewInvocationSession:or,compactComposer:!0})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:C,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:I?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:m("Loading...")}):O?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(Qi,{urlTransform:ex,components:Zi,children:O.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),D?t.jsx(Ai,{label:"Loading..."}):G?Ce?t.jsx(Ai,{label:"Loading logs..."}):ut.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:ie?"Waiting for agent output...":"No logs recorded."}):t.jsx(_r,{logs:ut}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(ls,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:he?Ie:m("选择一个 Agent 来执行此任务")}),!he&&t.jsxs(Ae,{onClick:async()=>{await xe(),u(!0)},children:[t.jsx(ls,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!j&&t.jsxs("button",{onClick:()=>N(),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:[t.jsx($s,{size:12}),t.jsx("span",{children:m("回到底部")})]})]}),kt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(br,{todos:kt,compact:!0})}),he?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:Ie})}):He?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:async()=>{await xe(),u(!0)},children:[t.jsx(ls,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):G&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[t.jsxs("div",{ref:f,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(Vr,{files:Ue,onRemove:Ft}),t.jsx("textarea",{ref:S,value:n,onChange:ii,onPaste:Ts,onKeyDown:re=>{Le.handleKeyDown(re)||ke.handleKeyDown(re)||re.key==="Enter"&&!re.shiftKey&&!re.repeat&&!re.nativeEvent.isComposing&&re.nativeEvent.keyCode!==229&&(re.preventDefault(),ir())},rows:1,placeholder:ie?"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}}),t.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:ri}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>k.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Ir,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Re&&Ve&&t.jsx(Gl,{providers:Ve,currentProviderId:rt,agentType:Re.agentType,onSelect:we}),t.jsx(yn,{usage:fs}),ie&&!n.trim()&&!Ut?t.jsx("button",{onClick:nr,disabled:ft.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ss,{size:12})}):t.jsx("button",{onClick:ir,disabled:!n.trim()&&!Ut||is,className:`p-1.5 rounded-lg transition-colors ${(n.trim()||Ut)&&!is?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Fr,{size:15})})]})]})]}),t.jsx(Dr,{open:ke.query!==null,anchorRef:f,commands:ke.filteredCommands,selectedIndex:ke.selectedIndex,query:ke.query??"",hasCatalog:ke.allCommands.length>0,compact:!0,onSelect:ke.applyCommand}),t.jsx(Dr,{open:Le.query!==null,anchorRef:f,commands:Le.filteredSkills,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Le.applySkill})]})]})),p==="team-status"&&z&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(dl,{teamRun:z,workspaces:T,selectedWorkspaceId:U,onSelectWorkspace:d,onViewInvocationSession:or})}),p==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[T&&T.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Wl,{workspaces:T,teamRun:z,selectedWorkspaceId:U,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),q&&V&&t.jsx("div",{className:"shrink-0",children:t.jsx(Il,{workspaceId:V,branchName:R,targetBranch:K,commitMessage:H,committedFileCount:J,onRefreshCommitMessage:ee,onConflict:Te,onResolveConflicts:()=>Te()})}),t.jsx(q0,{workingDir:$})]}),p==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Z0,{workingDir:$})}),p==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx($l,{sessionId:G||void 0,workspaceId:U,workingDir:$,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:he,repoDeleted:_e})}),!he&&t.jsx(Kl,{isOpen:c,onClose:()=>u(!1),taskId:e.id,taskTitle:O?.title??e.title,taskDescription:O?.body??"",taskPrompt:O?.prompt}),t.jsx(_n,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},taskId:e.id,taskTitle:e.title,workspaces:T,isLoading:o}),oe&&se&&Oe&&t.jsx(Jl,{open:oe,onOpenChange:re=>{fe(re),re||je(null)},workspaceId:Oe,conflictOp:se.conflictOp,conflictedFiles:se.conflictedFiles,sourceBranch:Fe,targetBranch:ze,operation:W?.operation,worktreePath:Me,mergeAborted:se.mergeAborted,mergeStrategy:se.mergeStrategy,sourceWorkspaceId:se.sourceWorkspaceId,targetWorkspaceId:se.targetWorkspaceId,sourceWorktreePath:se.sourceWorktreePath,targetWorktreePath:se.targetWorktreePath,sessions:Qe,currentSessionId:z?void 0:G,teamRunId:z?.id})]})}function Ai({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var nx=Object.defineProperty,Pr=Object.getOwnPropertySymbols,ac=Object.prototype.hasOwnProperty,lc=Object.prototype.propertyIsEnumerable,ea=(e,s,r)=>s in e?nx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Xi=(e,s)=>{for(var r in s||(s={}))ac.call(s,r)&&ea(e,r,s[r]);if(Pr)for(var r of Pr(s))lc.call(s,r)&&ea(e,r,s[r]);return e},Yi=(e,s)=>{var r={};for(var o in e)ac.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Pr)for(var o of Pr(e))s.indexOf(o)<0&&lc.call(e,o)&&(r[o]=e[o]);return r};var hs;(e=>{const s=class be{constructor(i,c,u,l){if(this.version=i,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],i<be.MIN_VERSION||i>be.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(u);if(this.drawCodewords(_),l==-1){let y=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<y&&(l=x,y=a),this.applyMask(x)}}m(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(i,c){const u=e.QrSegment.makeSegments(i);return be.encodeSegments(u,c)}static encodeBinary(i,c){const u=e.QrSegment.makeBytes(i);return be.encodeSegments([u],c)}static encodeSegments(i,c,u=1,l=40,g=-1,_=!0){if(!(be.MIN_VERSION<=u&&u<=l&&l<=be.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,x;for(y=u;;y++){const f=be.getNumDataCodewords(y,c)*8,b=v.getTotalBits(i,y);if(b<=f){x=b;break}if(y>=l)throw new RangeError("Data too long")}for(const f of[be.Ecc.MEDIUM,be.Ecc.QUARTILE,be.Ecc.HIGH])_&&x<=be.getNumDataCodewords(y,f)*8&&(c=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(y),a);for(const b of f.getData())a.push(b)}m(a.length==x);const h=be.getNumDataCodewords(y,c)*8;m(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),m(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,b)=>d[b>>>3]|=f<<7-(b&7)),new be(y,c,d,g)}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 u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%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 u=0;u<c;u++)for(let l=0;l<c;l++)u==0&&l==0||u==0&&l==c-1||u==c-1&&l==0||this.drawAlignmentPattern(i[u],i[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const c=this.errorCorrectionLevel.formatBits<<3|i;let u=c;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const l=(c<<10|u)^21522;m(l>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(l,g));this.setFunctionModule(8,7,o(l,6)),this.setFunctionModule(8,8,o(l,7)),this.setFunctionModule(7,8,o(l,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(l,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(l,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(l,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const c=this.version<<12|i;m(c>>>18==0);for(let u=0;u<18;u++){const l=o(c,u),g=this.size-11+u%3,_=Math.floor(u/3);this.setFunctionModule(g,_,l),this.setFunctionModule(_,g,l)}}drawFinderPattern(i,c){for(let u=-4;u<=4;u++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(u)),_=i+l,y=c+u;0<=_&&_<this.size&&0<=y&&y<this.size&&this.setFunctionModule(_,y,g!=2&&g!=4)}}drawAlignmentPattern(i,c){for(let u=-2;u<=2;u++)for(let l=-2;l<=2;l++)this.setFunctionModule(i+l,c+u,Math.max(Math.abs(l),Math.abs(u))!=1)}setFunctionModule(i,c,u){this.modules[c][i]=u,this.isFunction[c][i]=!0}addEccAndInterleave(i){const c=this.version,u=this.errorCorrectionLevel;if(i.length!=be.getNumDataCodewords(c,u))throw new RangeError("Invalid argument");const l=be.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c],g=be.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c],_=Math.floor(be.getNumRawDataModules(c)/8),y=l-_%l,x=Math.floor(_/l);let a=[];const h=be.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<l;f++){let S=i.slice(b,b+x-g+(f<y?0:1));b+=S.length;const k=be.reedSolomonComputeRemainder(S,h);f<y&&S.push(0),a.push(S.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((b,S)=>{(f!=x-g||S>=y)&&d.push(b[f])});return m(d.length==_),d}drawCodewords(i){if(i.length!=Math.floor(be.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const _=u-g,x=(u+1&2)==0?this.size-1-l:l;!this.isFunction[x][_]&&c<i.length*8&&(this.modules[x][_]=o(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 u=0;u<this.size;u++){let l;switch(i){case 0:l=(u+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=u%3==0;break;case 3:l=(u+c)%3==0;break;case 4:l=(Math.floor(u/3)+Math.floor(c/2))%2==0;break;case 5:l=u*c%2+u*c%3==0;break;case 6:l=(u*c%2+u*c%3)%2==0;break;case 7:l=((u+c)%2+u*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][u]&&l&&(this.modules[c][u]=!this.modules[c][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==_?(y++,y==5?i+=be.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,x),_||(i+=this.finderPenaltyCountPatterns(x)*be.PENALTY_N3),_=this.modules[g][a],y=1);i+=this.finderPenaltyTerminateAndCount(_,y,x)*be.PENALTY_N3}for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==_?(y++,y==5?i+=be.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,x),_||(i+=this.finderPenaltyCountPatterns(x)*be.PENALTY_N3),_=this.modules[a][g],y=1);i+=this.finderPenaltyTerminateAndCount(_,y,x)*be.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let _=0;_<this.size-1;_++){const y=this.modules[g][_];y==this.modules[g][_+1]&&y==this.modules[g+1][_]&&y==this.modules[g+1][_+1]&&(i+=be.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((_,y)=>_+(y?1:0),c);const u=this.size*this.size,l=Math.ceil(Math.abs(c*20-u*10)/u)-1;return m(0<=l&&l<=9),i+=l*be.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 u=[6];for(let l=this.size-7;u.length<i;l-=c)u.splice(1,0,l);return u}}static getNumRawDataModules(i){if(i<be.MIN_VERSION||i>be.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;c-=(25*u-10)*u-55,i>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(i,c){return Math.floor(be.getNumRawDataModules(i)/8)-be.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i]*be.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 l=0;l<i-1;l++)c.push(0);c.push(1);let u=1;for(let l=0;l<i;l++){for(let g=0;g<c.length;g++)c[g]=be.reedSolomonMultiply(c[g],u),g+1<c.length&&(c[g]^=c[g+1]);u=be.reedSolomonMultiply(u,2)}return c}static reedSolomonComputeRemainder(i,c){let u=c.map(l=>0);for(const l of i){const g=l^u.shift();u.push(0),c.forEach((_,y)=>u[y]^=be.reedSolomonMultiply(_,g))}return u}static reedSolomonMultiply(i,c){if(i>>>8||c>>>8)throw new RangeError("Byte out of range");let u=0;for(let l=7;l>=0;l--)u=u<<1^(u>>>7)*285,u^=(c>>>l&1)*i;return m(u>>>8==0),u}finderPenaltyCountPatterns(i){const c=i[1];m(c<=this.size*3);const u=c>0&&i[2]==c&&i[3]==c*3&&i[4]==c&&i[5]==c;return(u&&i[0]>=c*4&&i[6]>=c?1:0)+(u&&i[6]>=c*4&&i[0]>=c?1:0)}finderPenaltyTerminateAndCount(i,c,u){return i&&(this.finderPenaltyAddHistory(c,u),c=0),c+=this.size,this.finderPenaltyAddHistory(c,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,c){c[0]==0&&(i+=this.size),c.pop(),c.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.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]],s.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=s;function r(n,i,c){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)c.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function m(n){if(!n)throw new Error("Assertion error")}const p=class Ze{constructor(i,c,u){if(this.mode=i,this.numChars=c,this.bitData=u,c<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let c=[];for(const u of i)r(u,8,c);return new Ze(Ze.Mode.BYTE,i.length,c)}static makeNumeric(i){if(!Ze.isNumeric(i))throw new RangeError("String contains non-numeric characters");let c=[];for(let u=0;u<i.length;){const l=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+l),10),l*3+1,c),u+=l}return new Ze(Ze.Mode.NUMERIC,i.length,c)}static makeAlphanumeric(i){if(!Ze.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],u;for(u=0;u+2<=i.length;u+=2){let l=Ze.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;l+=Ze.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(l,11,c)}return u<i.length&&r(Ze.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,c),new Ze(Ze.Mode.ALPHANUMERIC,i.length,c)}static makeSegments(i){return i==""?[]:Ze.isNumeric(i)?[Ze.makeNumeric(i)]:Ze.isAlphanumeric(i)?[Ze.makeAlphanumeric(i)]:[Ze.makeBytes(Ze.toUtf8ByteArray(i))]}static makeEci(i){let c=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,c);else if(i<16384)r(2,2,c),r(i,14,c);else if(i<1e6)r(6,3,c),r(i,21,c);else throw new RangeError("ECI assignment value out of range");return new Ze(Ze.Mode.ECI,0,c)}static isNumeric(i){return Ze.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return Ze.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,c){let u=0;for(const l of i){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;u+=4+g+l.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let c=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?c.push(i.charCodeAt(u)):(c.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return c}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(hs||(hs={}));(e=>{(s=>{const r=class{constructor(m,p){this.ordinal=m,this.formatBits=p}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(hs||(hs={}));(e=>{(s=>{const r=class{constructor(m,p){this.modeBits=m,this.numBitsCharCount=p}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(hs||(hs={}));var bs=hs;var ox={L:bs.QrCode.Ecc.LOW,M:bs.QrCode.Ecc.MEDIUM,Q:bs.QrCode.Ecc.QUARTILE,H:bs.QrCode.Ecc.HIGH},cc=128,dc="L",uc="#FFFFFF",hc="#000000",fc=!1,mc=1,ax=4,lx=0,cx=.1;function pc(e,s=0){const r=[];return e.forEach(function(o,m){let p=null;o.forEach(function(v,n){if(!v&&p!==null){r.push(`M${p+s} ${m+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!v)return;p===null?r.push(`M${n+s},${m+s} h1v1H${n+s}z`):r.push(`M${p+s},${m+s} h${n+1-p}v1H${p+s}z`);return}v&&p===null&&(p=n)})}),r.join("")}function gc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((m,p)=>p<s.x||p>=s.x+s.w?m:!1))}function dx(e,s,r,o){if(o==null)return null;const m=e.length+r*2,p=Math.floor(s*cx),v=m/s,n=(o.width||p)*v,i=(o.height||p)*v,c=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,l=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let y=Math.floor(c),x=Math.floor(u),a=Math.ceil(n+c-y),h=Math.ceil(i+u-x);g={x:y,y:x,w:a,h}}const _=o.crossOrigin;return{x:c,y:u,h:i,w:n,excavation:g,opacity:l,crossOrigin:_}}function ux(e,s){return s!=null?Math.max(Math.floor(s),0):e?ax:lx}function vc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:m,imageSettings:p,size:v,boostLevel:n}){let i=ae.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...bs.QrSegment.makeSegments(a)),x),[]);return bs.QrCode.encodeSegments(y,ox[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:c,margin:u,numCells:l,calculatedImageSettings:g}=ae.useMemo(()=>{let _=i.getModules();const y=ux(o,m),x=_.length+y*2,a=dx(_,v,y,p);return{cells:_,margin:y,numCells:x,calculatedImageSettings:a}},[i,v,p,o,m]);return{qrcode:i,margin:u,cells:c,numCells:l,calculatedImageSettings:g}}var hx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),fx=ae.forwardRef(function(s,r){const o=s,{value:m,size:p=cc,level:v=dc,bgColor:n=uc,fgColor:i=hc,includeMargin:c=fc,minVersion:u=mc,boostLevel:l,marginSize:g,imageSettings:_}=o,x=Yi(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,h=Yi(x,["style"]),d=_?.src,f=ae.useRef(null),b=ae.useRef(null),S=ae.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,E]=ae.useState(!1),{margin:C,cells:j,numCells:N,calculatedImageSettings:M}=vc({value:m,level:v,minVersion:u,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:_,size:p});ae.useEffect(()=>{if(f.current!=null){const B=f.current,L=B.getContext("2d");if(!L)return;let F=j;const z=b.current,A=M!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&M.excavation!=null&&(F=gc(j,M.excavation));const P=window.devicePixelRatio||1;B.height=B.width=p*P;const O=p/N*P;L.scale(O,O),L.fillStyle=n,L.fillRect(0,0,N,N),L.fillStyle=i,hx?L.fill(new Path2D(pc(F,C))):j.forEach(function(I,U){I.forEach(function(X,$){X&&L.fillRect($+C,U+C,1,1)})}),M&&(L.globalAlpha=M.opacity),A&&L.drawImage(z,M.x+C,M.y+C,M.w,M.h)}}),ae.useEffect(()=>{E(!1)},[d]);const T=Xi({height:p,width:p},a);let D=null;return d!=null&&(D=ae.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:b,crossOrigin:M?.crossOrigin})),ae.createElement(ae.Fragment,null,ae.createElement("canvas",Xi({style:T,height:p,width:p,ref:S,role:"img"},h)),D)});fx.displayName="QRCodeCanvas";var xc=ae.forwardRef(function(s,r){const o=s,{value:m,size:p=cc,level:v=dc,bgColor:n=uc,fgColor:i=hc,includeMargin:c=fc,minVersion:u=mc,boostLevel:l,title:g,marginSize:_,imageSettings:y}=o,x=Yi(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=vc({value:m,level:v,minVersion:u,boostLevel:l,includeMargin:c,marginSize:_,imageSettings:y,size:p});let b=h,S=null;y!=null&&f!=null&&(f.excavation!=null&&(b=gc(h,f.excavation)),S=ae.createElement("image",{href:y.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=pc(b,a);return ae.createElement("svg",Xi({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!g&&ae.createElement("title",null,g),ae.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ae.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),S)});xc.displayName="QRCodeSVG";function _c(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function mx(){return wt({queryKey:ce.tunnel.status,queryFn:()=>ve.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function px(){const e=st();return bt({mutationFn:()=>ve.post("/tunnel/start",{port:_c()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function gx(){const e=st();return bt({mutationFn:()=>ve.post("/tunnel/regenerate",{port:_c()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function vx(){const e=st();return bt({mutationFn:()=>ve.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function xx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function _x(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function bx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function ta(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const m=Math.round(o/60);return m<24?`${m}h ago`:`${Math.round(m/24)}d ago`}function Ps(e){const s=e?.trim();return s||null}function yx(e){if(!e)return"";const s=[Ps(e.lastLocalError),Ps(e.lastRemoteError),Ps(e.lastError)].filter(m=>m!==null),r=Ps(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Ps(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
85
|
+
`)}function sa(){const{t:e}=le(),{data:s}=mx(),r=px(),o=vx(),m=gx(),[p,v]=w.useState(!1),[n,i]=w.useState(null),c=w.useRef(null),[u,l]=w.useState({top:0,right:0}),[g,_]=w.useState(!1),[y,x]=w.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=m.isPending,f=s?.shareableUrl,b=s?.token,S=xx(s),k=_x(s),E=yx(s);w.useEffect(()=>{if(p&&c.current){const B=c.current.getBoundingClientRect();l({top:B.bottom+8,right:window.innerWidth-B.right})}},[p]);const C=w.useCallback(()=>{v(!0)},[a]),j=w.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),N=w.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),M=w.useCallback(()=>{b&&(navigator.clipboard.writeText(b),i("token"),setTimeout(()=>i(null),2e3))},[b]),T=w.useCallback(()=>{o.mutate(),v(!1),_(!1),x(!1)},[o]),D=w.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{x(!1),v(!0)}})},[m]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:c,onClick:C,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?t.jsx(Be,{size:16,className:"animate-spin"}):S.icon==="warn"?t.jsx(Br,{size:16}):t.jsx(Vn,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),p&&!a&&Zt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(Vn,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Bt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Be,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&Zt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(bx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Bt,{size:14})})]}),b&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Aa,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(xc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:B=>B.target.select()}),t.jsx("button",{onClick:N,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(vt,{size:14,className:"text-emerald-500"}):t.jsx(Yn,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:ta(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:ta(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>_(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:b}),t.jsx("button",{onClick:M,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:n==="token"?t.jsx(vt,{size:14,className:"text-emerald-500"}):t.jsx(Yn,{size:14})})]})]}),y&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!y&&t.jsxs("button",{onClick:()=>x(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Hr,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.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:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Mi({isOpen:e,onClose:s}){const{t:r}=le(),o=rd(),[m,p]=w.useState(""),[v,n]=w.useState(""),[i,c]=w.useState(null),[u,l]=w.useState(!1),[g,_]=w.useState(!1),y=m.trim(),x=v.trim(),a=u||o.isPending,h=w.useMemo(()=>!!(y&&x&&!a),[y,x,a]),d=w.useCallback(()=>{p(""),n(""),c(null),_(!1)},[]),f=w.useCallback(()=>{a||(d(),s())},[a,s,d]);w.useEffect(()=>{e||d()},[e,d]);const b=w.useCallback(async E=>{try{await o.mutateAsync({name:y,repoPath:x,initEmptyRepo:E}),d(),s()}catch(C){const j=C instanceof Error?C.message:r("Failed to create project");c(j),lt.error(j)}},[o,s,d,r,y,x]),S=w.useCallback(async()=>{if(!(!y||!x||a)){c(null),l(!0);try{const E=await ve.get("/filesystem/validate",{params:{path:x}});if(E.valid){await b(!1);return}if(E.reason==="no_git"&&E.isEmpty){_(!0);return}if(E.reason==="no_git"){c(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}c(E.error??r("Selected path is not a valid directory"))}catch(E){c(E instanceof Error?E.message:r("Could not check repository path"))}finally{l(!1)}}},[b,a,r,y,x]),k=w.useCallback(()=>{_(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(ks,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:S,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:m,onChange:E=>p(E.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),t.jsx(id,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(Or,{isOpen:g,onClose:()=>{o.isPending||_(!1)},onConfirm:k,title:r("Initialize Git repository?"),description:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:o.isPending})]})}const Sx="/assets/agent-tower-logo-COx9gy77.png";function ra({className:e="h-7 w-7"}){return t.jsx("img",{src:Sx,alt:"Agent Tower",className:`block shrink-0 object-contain ${e}`})}const wx={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function ia({projects:e,providers:s,isProvidersLoading:r,onSubmit:o,defaultProjectId:m="",defaultProviderId:p="",onProjectChange:v,createStep:n}){const{t:i}=le(),[c,u]=w.useState(""),[l,g]=w.useState(m),[_,y]=w.useState(p),[x,a]=w.useState("SOLO"),[h,d]=w.useState(nt.WORKTREE),[f,b]=w.useState("AUTO"),[S,k]=w.useState(null),[E,C]=w.useState([]),[j,N]=w.useState(!1),[M,T]=w.useState(!1),[D,B]=w.useState(!1),[L,F]=w.useState(!1),z=w.useRef(null),A=w.useRef(null),P=w.useRef(null),O=w.useRef(null),I=w.useRef(null),{files:U,addFiles:X,removeFile:$,clear:V,buildMarkdownLinks:q,isUploading:R}=Yr();w.useEffect(()=>{g(m),v?.(m)},[m,v]),w.useEffect(()=>{y(p)},[p]),w.useEffect(()=>{if(!M)return;const ee=xe=>{z.current&&!z.current.contains(xe.target)&&T(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[M]),w.useEffect(()=>{if(!D)return;const ee=xe=>{A.current&&!A.current.contains(xe.target)&&B(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[D]),w.useEffect(()=>{if(!L)return;const ee=xe=>{P.current&&!P.current.contains(xe.target)&&F(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[L]);const H=w.useMemo(()=>e.find(ee=>ee.id===l),[e,l]),K=w.useMemo(()=>s.find(ee=>ee.id===_),[s,_]),W=h===nt.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),Q=n!=="idle",J=!!S||E.length>0,oe=!Q&&!R&&c.trim().length>0&&!!l&&(x==="TEAM"?J:!!_),fe=w.useCallback(async()=>{if(!oe)return;const ee=q();try{await o({title:c.trim(),description:"",projectId:l,providerId:_,mode:x,workspaceMode:x==="SOLO"?h:nt.WORKTREE,teamRunMode:f,teamTemplateId:S,memberPresetIds:E,attachmentLinks:ee}),u(""),V()}catch{}},[oe,c,l,_,x,h,f,S,E,o,q,V]),Ne=w.useCallback(ee=>{ee.key==="Enter"&&!ee.shiftKey&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),fe())},[fe]),je=w.useCallback(ee=>{const xe=ee.target.files;xe&&xe.length>0&&X(Array.from(xe)),ee.target.value=""},[X]),se=w.useCallback(ee=>{g(ee),v?.(ee),T(!1)},[v]),Oe=w.useCallback(ee=>{const xe=ee.clipboardData.items,Re=[];for(const G of xe)if(G.kind==="file"){const ne=G.getAsFile();ne&&Re.push(ne)}Re.length>0&&(ee.preventDefault(),X(Re))},[X]),[Me,Fe]=w.useState(!1),ze=w.useCallback(ee=>{ee.preventDefault(),Fe(!0)},[]),Qe=w.useCallback(ee=>{ee.preventDefault(),Fe(!1)},[]),Te=w.useCallback(ee=>{ee.preventDefault(),Fe(!1);const xe=ee.dataTransfer.files;xe.length>0&&X(Array.from(xe))},[X]);return t.jsxs("div",{className:"w-full",children:[t.jsxs("div",{className:Z("relative bg-background rounded-xl border transition-colors duration-200","hover:border-ring/40 focus-within:border-ring/60",Me?"border-info bg-info/5":"border-border",Q&&"opacity-80"),onDragOver:ze,onDragLeave:Qe,onDrop:Te,children:[U.length>0&&t.jsx("div",{className:"px-4 pt-3",children:t.jsx(Vr,{files:U,onRemove:$})}),t.jsx("textarea",{ref:O,value:c,onChange:ee=>u(ee.target.value),onKeyDown:Ne,onPaste:Oe,placeholder:i("Describe your task..."),disabled:Q,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-base text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"80px",maxHeight:"200px",fieldSizing:"content"}}),Me&&t.jsx("div",{className:"px-4 pb-2",children:t.jsx("div",{className:"flex items-center justify-center py-3 border-2 border-dashed border-border rounded-lg text-sm text-muted-foreground",children:i("Drop files here")})}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>I.current?.click(),disabled:Q||R,className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:t.jsx(Ir,{size:18})}),t.jsx("input",{ref:I,type:"file",multiple:!0,onChange:je,className:"hidden"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[R&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin"}),i("Uploading...")]}),Q&&t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin"}),i(wx[n])]}),!Q&&!R&&x==="TEAM"&&!J&&c.trim().length>0&&t.jsx("span",{className:"text-[11px] text-warning",children:i("请选择团队模板或追加成员")}),oe&&t.jsxs("span",{className:"hidden sm:inline text-[11px] text-muted-foreground/60 select-none",children:["⏎ ",i("创建")]}),t.jsx("button",{type:"button",onClick:fe,disabled:!oe,className:Z("p-2 rounded-lg transition-all duration-200",oe?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"),title:i("Create & Start"),children:t.jsx(Fr,{size:16})})]})]})]}),t.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5",children:[t.jsxs("div",{className:"relative",ref:z,children:[t.jsxs("button",{type:"button",onClick:()=>{Q||T(ee=>!ee)},disabled:Q,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",H?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx("span",{className:"size-2 rounded-full shrink-0",style:{backgroundColor:H?.color??"var(--muted-foreground)"}}),t.jsx("span",{className:"max-w-[120px] truncate",children:H?.name??i("Project")}),t.jsx(ct,{size:12,className:Z("text-muted-foreground/70 transition-transform",M&&"rotate-180")})]}),M&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:e.map(ee=>t.jsxs("button",{type:"button",onClick:()=>se(ee.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:ee.color??"var(--muted-foreground)"}}),t.jsx("span",{className:Z("truncate flex-1",ee.id===l?"text-foreground font-medium":"text-muted-foreground"),children:ee.name}),t.jsx(vt,{size:14,className:Z("ml-2 shrink-0",ee.id===l?"opacity-100":"opacity-0")})]},ee.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsxs("button",{type:"button",onClick:()=>{Q||B(ee=>!ee)},disabled:Q,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",K?"text-foreground/80":"text-muted-foreground/70"),children:[t.jsx(xd,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[120px] truncate",children:K?.name??i(r?"Loading...":"Agent")}),t.jsx(ct,{size:12,className:Z("text-muted-foreground/70 transition-transform",D&&"rotate-180")})]}),D&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(ee=>t.jsxs("button",{type:"button",disabled:!ee.available,onClick:()=>{y(ee.id),B(!1)},className:Z("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",!ee.available&&"opacity-40 cursor-not-allowed"),children:[t.jsx(vt,{size:14,className:Z("mr-2 shrink-0",ee.id===_?"opacity-100":"opacity-0")}),t.jsxs("span",{className:Z("truncate",ee.id===_?"text-foreground font-medium":"text-muted-foreground"),children:[ee.name,ee.available?"":i(" (unavailable)")]})]},ee.id))})]}),x==="SOLO"&&t.jsxs("div",{className:"relative",ref:P,children:[t.jsxs("button",{type:"button",onClick:()=>{Q||F(ee=>!ee)},disabled:Q,className:Z("flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","text-foreground/80"),children:[t.jsx(nn,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"max-w-[96px] truncate",children:W}),t.jsx(ct,{size:12,className:Z("text-muted-foreground/70 transition-transform",L&&"rotate-180")})]}),L&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-40 bg-background border border-border rounded-lg shadow-lg shadow-black/5 py-1 z-50",children:[t.jsxs("button",{type:"button",onClick:()=>{d(nt.WORKTREE),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(vt,{size:14,className:Z("mr-2 shrink-0",h===nt.WORKTREE?"opacity-100":"opacity-0")}),t.jsx("span",{className:Z("truncate",h===nt.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:i("工作树模式")})]}),t.jsxs("button",{type:"button",onClick:()=>{d(nt.MAIN_DIRECTORY),F(!1)},className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-muted/50 transition-colors",children:[t.jsx(vt,{size:14,className:Z("mr-2 shrink-0",h===nt.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),t.jsx("span",{className:Z("truncate",h===nt.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:i("本地模式")})]})]})]}),t.jsxs("div",{className:"ml-auto inline-flex items-center rounded-lg border border-border/70 bg-muted/50 p-0.5",children:[t.jsx("button",{type:"button",onClick:()=>{Q||x==="SOLO"||(a("SOLO"),N(!1))},disabled:Q,className:Z("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="SOLO"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:i("Switch to Solo Agent"),children:i("单人")}),t.jsx("button",{type:"button",onClick:()=>{Q||x==="TEAM"||(a("TEAM"),F(!1),d(nt.WORKTREE),N(!0))},disabled:Q,className:Z("px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-40 disabled:cursor-not-allowed",x==="TEAM"?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground/80"),title:i("Switch to TeamRun"),children:i("团队")})]})]}),x==="SOLO"&&h===nt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2",children:t.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-2.5 py-1.5 text-[11px] leading-relaxed text-warning",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})}),x==="TEAM"&&j&&t.jsxs("div",{className:"mt-2 rounded-xl bg-muted/50 px-4 pt-3 pb-4",children:[t.jsx("div",{className:"mb-2.5",children:t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:i("团队协作配置")})}),t.jsx(Vl,{mode:f,setMode:b,selectedTemplateId:S,setSelectedTemplateId:k,selectedMemberPresetIds:E,setSelectedMemberPresetIds:C,disabled:Q})]})]})}const na=t.jsx("span",{className:"font-semibold text-foreground tracking-tight text-base",children:"Agent Tower"});function oa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o}){const{t:m}=le(),[p,v]=w.useState(!1),n=e.filter(c=>!c.archivedAt),i=s?e.find(c=>c.id===s)??null:null;return t.jsxs("div",{className:"relative flex items-center min-w-0",children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>v(c=>!c),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[i?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${i.color.replace("text-","bg-")}`}):t.jsx(ws,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:i?i.name:m("All Projects")}),t.jsx(ct,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`})]}),p?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>v(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),v(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(ws,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(vt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:n.map(c=>{const u=s===c.id;return t.jsxs("button",{onClick:()=>{r(c.id),v(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${c.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${u?"text-foreground font-medium":"text-muted-foreground"}`,children:c.name}),u?t.jsx(vt,{size:14,className:"text-foreground shrink-0"}):null]},c.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{v(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(Wt,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function aa(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const Cx=260,kx=600,la=400,Ex=100,Di=1e3;function Yx(){const{t:e,locale:s}=le(),[r,o]=w.useState(null),[m,p]=w.useState(null),[v,n]=w.useState(la),[i,c]=w.useState(!1),[u,l]=w.useState("idle"),g=w.useRef(!1),_=w.useRef(0),y=w.useRef(la),x=w.useRef(null),a=st(),{data:h,isLoading:d}=Es(),{data:f,isLoading:b}=nd({limit:Ex}),S=w.useMemo(()=>f?.data??[],[f?.data]),k=w.useMemo(()=>S.map(I0),[S]),E=m&&S.some(G=>G.id===m)?m:null,{data:C,isLoading:j}=Qc(E??"",{limit:Di}),N=ud({queries:E?[]:S.map(G=>({queryKey:ce.tasks.list(G.id,{limit:Di}),queryFn:()=>ve.get(`/projects/${G.id}/tasks`,{params:{limit:String(Di)}})}))}),M=!E&&N.some(G=>G.isLoading),T=w.useMemo(()=>{if(E)return C?.data??[];const G=[];for(const ne of N)ne.data?.data&&G.push(...ne.data.data);return G},[E,C,N]),[D,B]=w.useState(null),L=w.useMemo(()=>r&&T.some(G=>G.id===r)?r:D&&r===D?D:null,[r,T,D]);w.useEffect(()=>{D&&T.some(G=>G.id===D)&&B(null)},[D,T]);const F=w.useMemo(()=>{const G=new Map;for(const ne of T){const ue=ne.createdAt?new Date(ne.createdAt).getTime():0,ye=G.get(ne.projectId)??0;ue>ye&&G.set(ne.projectId,ue)}return[...S].sort((ne,ue)=>{const ye=G.get(ne.id)??(ne.createdAt?new Date(ne.createdAt).getTime():0);return(G.get(ue.id)??(ue.createdAt?new Date(ue.createdAt).getTime():0))-ye})},[S,T]),z=w.useMemo(()=>F.filter(G=>!G.archivedAt),[F]),A=w.useMemo(()=>{if(!h)return[];const G=localStorage.getItem("providerUsageCount"),ne=G?JSON.parse(G):{};return[...h].sort((ue,ye)=>{const Se=ue.availability.type!=="NOT_FOUND",Y=ye.availability.type!=="NOT_FOUND";if(Se!==Y)return Se?-1:1;const ie=ne[ue.provider.id]??0;return(ne[ye.provider.id]??0)-ie})},[h]),P=w.useMemo(()=>T.map(F0),[T]),O=w.useMemo(()=>new Set,[]),I=w.useMemo(()=>{if(!L)return null;const G=T.find(ue=>ue.id===L);if(!G)return null;const ne=S.find(ue=>ue.id===G.projectId);if(!ne){const ue=us(G.workspaces?.find(ye=>ye.status==="ACTIVE")??G.workspaces?.[0]);return{id:G.id,projectId:G.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:G.title,status:Dn(G.status),branch:ue,mainBranch:"main",description:G.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return z0(G,ne)},[L,T,S]),U=ma(),X=Zc(),$=Jc(),V=w.useCallback(G=>{X.mutate(G,{onSuccess:()=>{L===G&&o(null),a.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{lt.error(e("删除任务失败"))}})},[X,L,a,e]),q=w.useCallback((G,ne)=>{$.mutate({id:G,status:P0(ne)},{onError:()=>{lt.error(e("状态变更失败,该操作不被允许"))}})},[$,e]),R=w.useCallback(G=>{G.preventDefault(),g.current=!0,_.current=G.clientX,y.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);w.useEffect(()=>{const G=ue=>{if(!g.current)return;const ye=ue.clientX-_.current,Se=Math.max(Cx,Math.min(kx,y.current+ye));n(Se)},ne=()=>{g.current&&(g.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",G),document.addEventListener("mouseup",ne),()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",ne)}},[]);const H=w.useCallback(()=>{c(!0)},[]),K=w.useCallback(()=>{if(z.length===0){lt.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[z,e]),W=w.useCallback(()=>{c(!1)},[]),Q=An(),J=w.useCallback(async G=>{const{title:ne,description:ue,projectId:ye,providerId:Se,mode:Y,workspaceMode:ie,teamRunMode:he,teamTemplateId:_e,memberPresetIds:Ie,attachmentLinks:He}=G,Ve=[ue,He].filter(Boolean).join(`
|
|
86
|
+
|
|
87
|
+
`);let $e=null;try{if(l("creating-task"),$e=await ve.post(`/projects/${ye}/tasks`,{title:ne,description:Ve||void 0}),localStorage.setItem("lastSelectedProjectId",ye),Y==="SOLO"&&Se){localStorage.setItem("lastSelectedProviderId",Se);const De=localStorage.getItem("providerUsageCount"),rt=De?JSON.parse(De):{};rt[Se]=(rt[Se]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(rt))}if(Y==="TEAM")l("creating-teamrun"),await U.mutateAsync({taskId:$e.id,mode:he,..._e?{teamTemplateId:_e}:{},...Ie.length>0?{memberPresetIds:Ie}:{}});else if(Se){const De=[$e.title,$e.description].filter(Boolean).join(`
|
|
88
|
+
|
|
89
|
+
`);l("creating-workspace");const rt=await ve.post(`/tasks/${$e.id}/workspaces`,{workspaceKind:ie});l("creating-session");const we=await ve.post(`/workspaces/${rt.id}/sessions`,{providerId:Se,prompt:De});l("starting-session"),await Q.mutateAsync(we.id),await a.invalidateQueries({queryKey:ce.workspaces.list($e.id)})}E&&ye!==E&&p(null),B($e.id),o($e.id),l("idle"),a.invalidateQueries({queryKey:ce.tasks.all}),a.invalidateQueries({queryKey:ce.projects.all})}catch(De){if(l("idle"),$e&&Y==="TEAM"){try{await X.mutateAsync($e.id)}catch{}throw lt.error(e("TeamRun 创建失败,请检查团队配置后重试")),De}else if($e)E&&ye!==E&&p(null),B($e.id),o($e.id),a.invalidateQueries({queryKey:ce.tasks.all}),a.invalidateQueries({queryKey:ce.projects.all}),lt.error(e("任务已创建,但启动 Agent 失败,可在详情中重试"));else throw lt.error(De instanceof Error?De.message:e("Failed to create task")),De}},[U,Q,X,a,e,E]),oe=b||j||M,fe=w.useMemo(()=>z.map(G=>({id:G.id,name:G.name,color:k.find(ne=>ne.id===G.id)?.color})),[z,k]),Ne=w.useMemo(()=>A.map(({provider:G,availability:ne})=>({id:G.id,name:G.name,available:ne.type!=="NOT_FOUND"})),[A]),je=w.useMemo(()=>{if(E&&z.find(ne=>ne.id===E))return E;const G=localStorage.getItem("lastSelectedProjectId");return G&&z.find(ne=>ne.id===G)?G:z[0]?.id??""},[z,E]),[se,Oe]=w.useState(je);w.useEffect(()=>{Oe(je)},[je]);const Me=w.useMemo(()=>z.find(G=>G.id===se)?.name??z.find(G=>G.id===je)?.name??e("Project"),[z,se,je,e]),Fe=s==="zh-CN"?`你需要在 ${Me} 中做点什么?`:`What do you need to do in ${Me}?`,ze=w.useMemo(()=>{const G=localStorage.getItem("lastSelectedProviderId");return G&&A.find(ue=>ue.provider.id===G&&ue.availability.type!=="NOT_FOUND")?G:A.find(ue=>ue.availability.type!=="NOT_FOUND")?.provider.id??""},[A]),Qe=Ja(),[Te,ee]=w.useState(!1),xe=w.useCallback(()=>{if(z.length===0){lt.error(e("没有可用项目,请先创建或恢复项目"));return}ee(!0)},[z,e]),Re=w.useCallback(async G=>{await J(G),ee(!1)},[J]);return Qe?Te?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>ee(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-2xl tracking-tight leading-tight text-foreground mb-6 break-words",children:Fe}),t.jsx(ia,{projects:fe,providers:Ne,isProvidersLoading:d,onSubmit:Re,defaultProjectId:je,defaultProviderId:ze,onProjectChange:Oe,createStep:u})]})]}):L&&I?t.jsxs(t.Fragment,{children:[t.jsx(ix,{task:I,onBack:()=>o(null),onDeleteTask:I.projectArchivedAt?void 0:V,isDeleting:X.isPending}),t.jsx(Mi,{isOpen:i,onClose:W})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ra,{}),na,t.jsx(oa,{projects:k,filterProjectId:E,setFilterProjectId:p,onCreateProject:H})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(sa,{}),t.jsx("button",{onClick:()=>Un.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx($n,{size:16})})]})]}),oe&&P.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(aa,{})}):t.jsx(lo,{tasks:P,projects:k,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:"100%",onCreateTask:xe,onCreateProject:H,activeTaskIds:O,onTaskStatusChange:q})]}),t.jsx(Mi,{isOpen:i,onClose:W})]}):t.jsxs("div",{ref:x,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ra,{}),na,t.jsx(oa,{projects:k,filterProjectId:E,setFilterProjectId:p,onCreateProject:H})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(sa,{}),t.jsx("button",{onClick:()=>Un.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",children:t.jsx($n,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[oe&&P.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(aa,{})}):t.jsx(lo,{tasks:P,projects:k,selectedTaskId:L,onSelectTask:o,filterProjectId:E,setFilterProjectId:p,width:v,onCreateTask:K,onCreateProject:H,isCreateActive:!L,activeTaskIds:O,onTaskStatusChange:q,onDeleteTask:V}),t.jsx("div",{onMouseDown:R,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:L&&I?t.jsx(L0,{task:I,onDeleteTask:I.projectArchivedAt?void 0:V,isDeleting:X.isPending,onTaskStatusChange:I.projectArchivedAt?void 0:q}):L&&!I?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-3xl tracking-tight leading-tight text-foreground mb-8 break-words",children:Fe}),t.jsx(ia,{projects:fe,providers:Ne,isProvidersLoading:d,onSubmit:J,defaultProjectId:je,defaultProviderId:ze,onProjectChange:Oe,createStep:u})]})})})]}),t.jsx(Mi,{isOpen:i,onClose:W})]})}export{Yx as ProjectKanbanPage};
|