agent-tower 0.5.1-beta.1 → 0.5.1-beta.2
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/output/claude-code-parser.d.ts +5 -0
- package/dist/output/claude-code-parser.d.ts.map +1 -1
- package/dist/output/claude-code-parser.js +35 -0
- package/dist/output/claude-code-parser.js.map +1 -1
- package/dist/output/codex-parser.d.ts +4 -0
- package/dist/output/codex-parser.d.ts.map +1 -1
- package/dist/output/codex-parser.js +22 -1
- package/dist/output/codex-parser.js.map +1 -1
- package/dist/output/cursor-agent-parser.d.ts +8 -0
- package/dist/output/cursor-agent-parser.d.ts.map +1 -1
- package/dist/output/cursor-agent-parser.js +52 -1
- package/dist/output/cursor-agent-parser.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-Br2XUyNc.js → AgentDemoPage-CEWSskKz.js} +1 -1
- package/dist/web/assets/{DemoPage-Dw8RL61j.js → DemoPage-DVt_gGQE.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-CpupA0Qp.js → GeneralSettingsPage-B7DbUzT6.js} +1 -1
- package/dist/web/assets/{MemberAvatar-DvGQuA7A.js → MemberAvatar--HnaCo5f.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-0TYhYGa4.js → NotificationSettingsPage-BklUEhB2.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-C3qYBdsA.js → ProfileSettingsPage-Be7yYwbc.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-B1H-Pj1x.js → ProjectKanbanPage-BZR3HX3_.js} +34 -34
- package/dist/web/assets/{ProjectSettingsPage-AIN1Pxbk.js → ProjectSettingsPage-Cj1h7G2-.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-DNQKSYg4.js → ProviderSettingsPage-l244dDeI.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-CdyMT_6g.js → TeamSettingsPage-CXp-7kqb.js} +1 -1
- package/dist/web/assets/{button-Cnx2yh9y.js → button-Cc_0rVdG.js} +1 -1
- package/dist/web/assets/{chevron-down-CJTng4ec.js → chevron-down-DAto5uxR.js} +1 -1
- package/dist/web/assets/{chevron-right-rgLspEZW.js → chevron-right-fcp8yUcf.js} +1 -1
- package/dist/web/assets/{chevron-up-CjrOgQfJ.js → chevron-up-BkPAyFXE.js} +1 -1
- package/dist/web/assets/{circle-check-ACwpALiG.js → circle-check-BmWaxH2e.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-ejo0CncN.js → code-block-OCS4YCEC-U8rjjKMO.js} +1 -1
- package/dist/web/assets/{confirm-dialog-Db3n5snN.js → confirm-dialog-D0R59Lv2.js} +1 -1
- package/dist/web/assets/{folder-picker-m3uOAk4a.js → folder-picker-COVJdb7m.js} +1 -1
- package/dist/web/assets/{index-qjgMInkM.js → index-BCz-PlSG.js} +6 -6
- package/dist/web/assets/index-BjIvVVfi.css +1 -0
- package/dist/web/assets/{loader-circle-CMJj5mzD.js → loader-circle-B0dxeUg4.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-BZ4uwHMI.js → mermaid-NOHMQCX5-CfVlHQvQ.js} +3 -3
- package/dist/web/assets/{modal-wCjKEnyL.js → modal-kzH1vcBa.js} +1 -1
- package/dist/web/assets/{pencil-rLXiz6ol.js → pencil-DvjVNKIw.js} +1 -1
- package/dist/web/assets/{select-Bw8cQdGZ.js → select-Xt2WadPY.js} +1 -1
- package/dist/web/assets/{upload-BTpZgwhL.js → upload-dtpXWuCN.js} +1 -1
- package/dist/web/assets/{use-profiles-BYamxPb-.js → use-profiles-oZ63gfvO.js} +1 -1
- package/dist/web/assets/{use-providers-Dr0j9gES.js → use-providers-BVrApYJA.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
- package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-uh9c20Vz.css +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-
|
|
2
|
-
import{Q as hi,x as ln,y as Bl,z as Fl,A as zl,B as ei,D as Hl,E as Wl,e as Ge,G as $l,H as Ul,r as C,I as ql,J as Kl,K as Xl,M as Vl,N as cn,O as dn,P as Yl,R as Gl,T as Ql,h as xe,U as ie,V as Ut,u as ae,j as s,d as xt,g as ge,W as Co,X as ko,Y as Eo,Z as mr,v as Ot,S as dt,C as es,f as ht,q as de,w as It,t as ns,i as Zl,k as Jl,L as Qs,_ as jo,$ as No,a0 as un,a1 as fi,a2 as Ao,a3 as To,a4 as ec,a5 as ti,a6 as hn,a7 as tc}from"./index-qjgMInkM.js";import{h as mi,b as pi,d as gi,c as vi,i as _i,f as os,A as fn,P as pr,Q as xi,s as bi,G as yi,u as Ro,a as Mo,e as Zs,T as Do,S as mn}from"./mermaid-NOHMQCX5-BZ4uwHMI.js";import{C as bt,a as Tt}from"./chevron-down-CJTng4ec.js";import{C as Mt}from"./chevron-right-rgLspEZW.js";import{P as as,X as Ht,M as Ms,T as Si}from"./modal-wCjKEnyL.js";import{W as Et,C as ws,A as At,S as Xe,T as Nt}from"./log-adapter-i7kNXXup.js";import{B as Ie}from"./button-Cnx2yh9y.js";import{L as $e}from"./loader-circle-CMJj5mzD.js";import{M as Xt}from"./MemberAvatar-DvGQuA7A.js";import{c as te,t as si}from"./utils-CkSf8FUe.js";import{C as wi}from"./chevron-up-CjrOgQfJ.js";import{a as sc,F as rc,f as ic,R as nc,g as oc,e as ac,u as lc}from"./folder-picker-m3uOAk4a.js";import{u as Ds}from"./use-providers-Dr0j9gES.js";import{T as Ci,C as Js}from"./confirm-dialog-Db3n5snN.js";import{S as pn}from"./select-Bw8cQdGZ.js";var cc=class extends hi{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ln()})}getOptimisticResult(e){return e.behavior=ln(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:r}=e,o=super.createResult(e,t),{isFetching:m,isRefetching:p,isError:v,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,c=v&&n==="forward",f=m&&n==="forward",l=v&&n==="backward",g=m&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fl(t,r.data),hasPreviousPage:Bl(t,r.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:i&&!c&&!l,isRefetching:p&&!f&&!g}}};function gn(e,t){const r=new Set(t);return e.filter(o=>!r.has(o))}function dc(e,t,r){const o=e.slice(0);return o[t]=r,o}var uc=class extends zl{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,ei.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=o.map(f=>f.observer),p=m.map(f=>f.getCurrentResult()),v=r.length!==m.length,i=m.some((f,l)=>f!==r[l]),n=v||i,c=n?!0:p.some((f,l)=>{const g=this.#e[l];return!g||!Hl(f,g)});!n&&!c||(n&&(this.#c=o,this.#t=m),this.#e=p,this.hasListeners()&&(n&&(gn(r,m).forEach(f=>{f.destroy()}),gn(m,r).forEach(f=>{f.subscribe(l=>{this.#f(f,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){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,t,m),()=>this.#d(o,r)]}#d(e,t){return t.map((r,o)=>{const m=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{t.forEach(v=>{v.observer.trackProp(p)})})})}#u(e,t,r){if(t){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||t!==this.#o)&&(this.#o=t,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Wl(this.#s,t(e))),this.#s}return e}#h(e){const t=new Map;this.#t.forEach(o=>{const m=o.options.queryHash;if(!m)return;const p=t.get(m);p?p.push(o):t.set(m,[o])});const r=[];return e.forEach(o=>{const m=this.#r.defaultQueryOptions(o),v=t.get(m.queryHash)?.shift()??new hi(this.#r,m);r.push({defaultedQueryOptions:m,observer:v})}),r}#f(e,t){const r=this.#t.indexOf(e);r!==-1&&(this.#e=dc(this.#e,r,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),r=this.#u(t,this.#n?.combine);e!==r&&ei.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function hc({queries:e,...t},r){const o=Ge(),m=$l(),p=Ul(),v=C.useMemo(()=>e.map(_=>{const a=o.defaultQueryOptions(_);return a._optimisticResults=m?"isRestoring":"optimistic",a}),[e,o,m]);v.forEach(_=>{ql(_);const a=o.getQueryCache().get(_.queryHash);Kl(_,p,a)}),Xl(p);const[i]=C.useState(()=>new uc(o,v,t)),[n,c,f]=i.getOptimisticResult(v,t.combine),l=!m&&t.subscribed!==!1;C.useSyncExternalStore(C.useCallback(_=>l?i.subscribe(ei.batchCalls(_)):Vl,[i,l]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,t)},[v,t,i]);const x=n.some((_,a)=>cn(v[a],_))?n.flatMap((_,a)=>{const h=v[a];if(h){const d=new hi(o,h);if(cn(h,_))return dn(h,d,p);Yl(_,m)&&dn(h,d,p)}return[]}):[];if(x.length>0)throw Promise.all(x);const y=n.find((_,a)=>{const h=v[a];return h&&Gl({result:_,errorResetBoundary:p,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return c(f())}function Lo(e,t){return Ql(e,cc)}const fc=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Cs=xe("arrow-down",fc);const mc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Po=xe("arrow-right",mc);const pc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ki=xe("arrow-up",pc);const gc=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oo=xe("ban",gc);const vc=[["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"}]],_c=xe("bot",vc);const xc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bc=xe("chevron-left",xc);const yc=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],vn=xe("circle-check-big",yc);const Sc=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ts=xe("clock-3",Sc);const wc=[["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"}]],Ls=xe("code-xml",wc);const Cc=[["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"}]],_n=xe("copy",Cc);const kc=[["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"}]],Io=xe("ellipsis-vertical",kc);const Ec=[["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"}]],Ei=xe("external-link",Ec);const jc=[["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"}]],Nc=xe("file-braces-corner",jc);const Ac=[["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"}]],ks=xe("file-code-corner",Ac);const Tc=[["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"}]],Rc=xe("file-exclamation-point",Tc);const Mc=[["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"}]],ji=xe("file-text",Mc);const Dc=[["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"}]],Ni=xe("folder-open",Dc);const Lc=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Pc=xe("gauge",Lc);const Oc=[["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"}]],Ai=xe("git-branch",Oc);const Ic=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Bc=xe("git-fork",Ic);const Fc=[["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"}]],ls=xe("git-graph",Fc);const zc=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],Bo=xe("git-merge",zc);const Hc=[["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=xe("history",Hc);const Wc=[["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"}]],Ti=xe("image",Wc);const $c=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ds=xe("layers",$c);const Uc=[["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"}]],qc=xe("lock-keyhole",Uc);const Kc=[["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"}]],Xc=xe("maximize",Kc);const Vc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],er=xe("message-square",Vc);const Yc=[["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"}]],Gc=xe("panel-left-close",Yc);const Qc=[["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"}]],Zc=xe("panel-left-open",Qc);const Jc=[["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"}]],ed=xe("panel-right-close",Jc);const td=[["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"}]],Ri=xe("panel-right-open",td);const sd=[["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"}]],qt=xe("play",sd);const rd=[["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"}]],Es=xe("refresh-cw",rd);const id=[["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"}]],nd=xe("save",id);const od=[["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"}]],ad=xe("shield",od);const ld=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],tr=xe("terminal",ld);const cd=[["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"}]],dd=xe("zap",cd);const ud=[["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"}]],hd=xe("zoom-in",ud);const fd=[["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"}]],md=xe("zoom-out",fd),gr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function us(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Mi(e){return"nodeType"in e}function vt(e){var t,r;return e?us(e)?e:Mi(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Di(e){const{Document:t}=vt(e);return e instanceof t}function Ps(e){return us(e)?!1:e instanceof vt(e).HTMLElement}function Fo(e){return e instanceof vt(e).SVGElement}function hs(e){return e?us(e)?e.document:Mi(e)?Di(e)?e:Ps(e)||Fo(e)?e.ownerDocument:document:document:document}const Rt=gr?C.useLayoutEffect:C.useEffect;function vr(e){const t=C.useRef(e);return Rt(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,o=new Array(r),m=0;m<r;m++)o[m]=arguments[m];return t.current==null?void 0:t.current(...o)},[])}function pd(){const e=C.useRef(null),t=C.useCallback((o,m)=>{e.current=setInterval(o,m)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function js(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Rt(()=>{r.current!==e&&(r.current=e)},t),r}function Os(e,t){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...t])}function sr(e){const t=vr(e),r=C.useRef(null),o=C.useCallback(m=>{m!==r.current&&t?.(m,r.current),r.current=m},[]);return[r,o]}function rr(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Pr={};function _r(e,t){return C.useMemo(()=>{if(t)return t;const r=Pr[e]==null?0:Pr[e]+1;return Pr[e]=r,e+"-"+r},[e,t])}function zo(e){return function(t){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 i=Object.entries(v);for(const[n,c]of i){const f=p[n];f!=null&&(p[n]=f+e*c)}return p},{...t})}}const is=zo(1),ir=zo(-1);function gd(e){return"clientX"in e&&"clientY"in e}function Li(e){if(!e)return!1;const{KeyboardEvent:t}=vt(e.target);return t&&e instanceof t}function vd(e){if(!e)return!1;const{TouchEvent:t}=vt(e.target);return t&&e instanceof t}function nr(e){if(vd(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return gd(e)?{x:e.clientX,y:e.clientY}:null}const Ns=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Ns.Translate.toString(e),Ns.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:o}=e;return t+" "+r+"ms "+o}}}),xn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function _d(e){return e.matches(xn)?e:e.querySelector(xn)}const xd={display:"none"};function bd(e){let{id:t,value:r}=e;return ie.createElement("div",{id:t,style:xd},r)}function yd(e){let{id:t,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 ie.createElement("div",{id:t,style:m,role:"status","aria-live":o,"aria-atomic":!0},r)}function Sd(){const[e,t]=C.useState("");return{announce:C.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Ho=C.createContext(null);function wd(e){const t=C.useContext(Ho);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Cd(){const[e]=C.useState(()=>new Set),t=C.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[C.useCallback(o=>{let{type:m,event:p}=o;e.forEach(v=>{var i;return(i=v[m])==null?void 0:i.call(v,p)})},[e]),t]}const kd={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-kzH1vcBa.js","assets/index-BCz-PlSG.js","assets/index-BjIvVVfi.css","assets/utils-CkSf8FUe.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Q as di,x as an,y as Bl,z as Fl,A as zl,B as Zr,D as Hl,E as Wl,e as Ge,G as $l,H as Ul,r as C,I as ql,J as Kl,K as Xl,M as Vl,N as ln,O as cn,P as Yl,R as Gl,T as Ql,h as ye,U as ie,V as qt,u as ae,j as s,d as bt,g as ge,W as Co,X as ko,Y as Eo,Z as Ss,v as It,S as dt,C as Jt,f as ht,q as de,w as Bt,t as is,i as Zl,k as Jl,L as Ys,_ as jo,$ as No,a0 as dn,a1 as ui,a2 as Ao,a3 as Ro,a4 as ec,a5 as Jr,a6 as un,a7 as tc}from"./index-BCz-PlSG.js";import{h as hi,b as fi,d as mi,c as pi,i as gi,f as ns,A as hn,P as hr,Q as vi,s as _i,G as xi,u as To,a as Mo,e as Gs,T as Do,S as fn}from"./mermaid-NOHMQCX5-CfVlHQvQ.js";import{C as vt,a as Rt}from"./chevron-down-DAto5uxR.js";import{C as Tt}from"./chevron-right-fcp8yUcf.js";import{P as os,X as Wt,M as Rs,T as bi}from"./modal-kzH1vcBa.js";import{W as Et,C as ws,A as At,S as Xe,T as Nt}from"./log-adapter-i7kNXXup.js";import{B as Ie}from"./button-Cc_0rVdG.js";import{L as $e}from"./loader-circle-B0dxeUg4.js";import{M as Mt}from"./MemberAvatar--HnaCo5f.js";import{c as te,t as ei}from"./utils-CkSf8FUe.js";import{C as yi}from"./chevron-up-BkPAyFXE.js";import{a as sc,F as rc,f as ic,R as nc,g as oc,e as ac,u as lc}from"./folder-picker-COVJdb7m.js";import{u as Ts}from"./use-providers-BVrApYJA.js";import{T as Si,C as Qs}from"./confirm-dialog-D0R59Lv2.js";import{S as mn}from"./select-Xt2WadPY.js";var cc=class extends di{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:an()})}getOptimisticResult(e){return e.behavior=an(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:r}=e,o=super.createResult(e,t),{isFetching:m,isRefetching:p,isError:v,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,c=v&&n==="forward",f=m&&n==="forward",l=v&&n==="backward",g=m&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fl(t,r.data),hasPreviousPage:Bl(t,r.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:i&&!c&&!l,isRefetching:p&&!f&&!g}}};function pn(e,t){const r=new Set(t);return e.filter(o=>!r.has(o))}function dc(e,t,r){const o=e.slice(0);return o[t]=r,o}var uc=class extends zl{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,Zr.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const m=o.map(f=>f.observer),p=m.map(f=>f.getCurrentResult()),v=r.length!==m.length,i=m.some((f,l)=>f!==r[l]),n=v||i,c=n?!0:p.some((f,l)=>{const g=this.#e[l];return!g||!Hl(f,g)});!n&&!c||(n&&(this.#c=o,this.#t=m),this.#e=p,this.hasListeners()&&(n&&(pn(r,m).forEach(f=>{f.destroy()}),pn(m,r).forEach(f=>{f.subscribe(l=>{this.#f(f,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){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,t,m),()=>this.#d(o,r)]}#d(e,t){return t.map((r,o)=>{const m=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?m:r.observer.trackResult(m,p=>{t.forEach(v=>{v.observer.trackProp(p)})})})}#u(e,t,r){if(t){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||t!==this.#o)&&(this.#o=t,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Wl(this.#s,t(e))),this.#s}return e}#h(e){const t=new Map;this.#t.forEach(o=>{const m=o.options.queryHash;if(!m)return;const p=t.get(m);p?p.push(o):t.set(m,[o])});const r=[];return e.forEach(o=>{const m=this.#r.defaultQueryOptions(o),v=t.get(m.queryHash)?.shift()??new di(this.#r,m);r.push({defaultedQueryOptions:m,observer:v})}),r}#f(e,t){const r=this.#t.indexOf(e);r!==-1&&(this.#e=dc(this.#e,r,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),r=this.#u(t,this.#n?.combine);e!==r&&Zr.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function hc({queries:e,...t},r){const o=Ge(),m=$l(),p=Ul(),v=C.useMemo(()=>e.map(_=>{const a=o.defaultQueryOptions(_);return a._optimisticResults=m?"isRestoring":"optimistic",a}),[e,o,m]);v.forEach(_=>{ql(_);const a=o.getQueryCache().get(_.queryHash);Kl(_,p,a)}),Xl(p);const[i]=C.useState(()=>new uc(o,v,t)),[n,c,f]=i.getOptimisticResult(v,t.combine),l=!m&&t.subscribed!==!1;C.useSyncExternalStore(C.useCallback(_=>l?i.subscribe(Zr.batchCalls(_)):Vl,[i,l]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,t)},[v,t,i]);const b=n.some((_,a)=>ln(v[a],_))?n.flatMap((_,a)=>{const h=v[a];if(h){const d=new di(o,h);if(ln(h,_))return cn(h,d,p);Yl(_,m)&&cn(h,d,p)}return[]}):[];if(b.length>0)throw Promise.all(b);const y=n.find((_,a)=>{const h=v[a];return h&&Gl({result:_,errorResetBoundary:p,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return c(f())}function Lo(e,t){return Ql(e,cc)}const fc=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Cs=ye("arrow-down",fc);const mc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Po=ye("arrow-right",mc);const pc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],wi=ye("arrow-up",pc);const gc=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oo=ye("ban",gc);const vc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_c=ye("chevron-left",vc);const xc=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],gn=ye("circle-check-big",xc);const bc=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],es=ye("clock-3",bc);const yc=[["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"}]],Ms=ye("code-xml",yc);const Sc=[["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"}]],vn=ye("copy",Sc);const wc=[["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"}]],Io=ye("ellipsis-vertical",wc);const Cc=[["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"}]],Ci=ye("external-link",Cc);const kc=[["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"}]],Ec=ye("file-braces-corner",kc);const jc=[["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"}]],ks=ye("file-code-corner",jc);const Nc=[["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"}]],Ac=ye("file-exclamation-point",Nc);const Rc=[["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"}]],ki=ye("file-text",Rc);const Tc=[["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"}]],Ei=ye("folder-open",Tc);const Mc=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Dc=ye("gauge",Mc);const Lc=[["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"}]],ji=ye("git-branch",Lc);const Pc=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Oc=ye("git-fork",Pc);const Ic=[["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"}]],as=ye("git-graph",Ic);const Bc=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],Bo=ye("git-merge",Bc);const Fc=[["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"}]],ls=ye("history",Fc);const zc=[["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"}]],Ni=ye("image",zc);const Hc=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],cs=ye("layers",Hc);const Wc=[["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"}]],$c=ye("lock-keyhole",Wc);const Uc=[["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"}]],qc=ye("maximize",Uc);const Kc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Ai=ye("message-square",Kc);const Xc=[["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"}]],Vc=ye("panel-left-close",Xc);const Yc=[["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"}]],Gc=ye("panel-left-open",Yc);const Qc=[["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"}]],Zc=ye("panel-right-close",Qc);const Jc=[["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"}]],Zs=ye("panel-right-open",Jc);const ed=[["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"}]],Kt=ye("play",ed);const td=[["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"}]],Ri=ye("refresh-cw",td);const sd=[["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"}]],rd=ye("save",sd);const id=[["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"}]],nd=ye("shield",id);const od=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Js=ye("terminal",od);const ad=[["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"}]],ld=ye("zap",ad);const cd=[["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"}]],dd=ye("zoom-in",cd);const ud=[["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"}]],hd=ye("zoom-out",ud),fr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ds(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ti(e){return"nodeType"in e}function _t(e){var t,r;return e?ds(e)?e:Ti(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Mi(e){const{Document:t}=_t(e);return e instanceof t}function Ds(e){return ds(e)?!1:e instanceof _t(e).HTMLElement}function Fo(e){return e instanceof _t(e).SVGElement}function us(e){return e?ds(e)?e.document:Ti(e)?Mi(e)?e:Ds(e)||Fo(e)?e.ownerDocument:document:document:document}const Dt=fr?C.useLayoutEffect:C.useEffect;function mr(e){const t=C.useRef(e);return Dt(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,o=new Array(r),m=0;m<r;m++)o[m]=arguments[m];return t.current==null?void 0:t.current(...o)},[])}function fd(){const e=C.useRef(null),t=C.useCallback((o,m)=>{e.current=setInterval(o,m)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function Es(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Dt(()=>{r.current!==e&&(r.current=e)},t),r}function Ls(e,t){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...t])}function er(e){const t=mr(e),r=C.useRef(null),o=C.useCallback(m=>{m!==r.current&&t?.(m,r.current),r.current=m},[]);return[r,o]}function tr(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Dr={};function pr(e,t){return C.useMemo(()=>{if(t)return t;const r=Dr[e]==null?0:Dr[e]+1;return Dr[e]=r,e+"-"+r},[e,t])}function zo(e){return function(t){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 i=Object.entries(v);for(const[n,c]of i){const f=p[n];f!=null&&(p[n]=f+e*c)}return p},{...t})}}const rs=zo(1),sr=zo(-1);function md(e){return"clientX"in e&&"clientY"in e}function Di(e){if(!e)return!1;const{KeyboardEvent:t}=_t(e.target);return t&&e instanceof t}function pd(e){if(!e)return!1;const{TouchEvent:t}=_t(e.target);return t&&e instanceof t}function rr(e){if(pd(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return md(e)?{x:e.clientX,y:e.clientY}:null}const js=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[js.Translate.toString(e),js.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:o}=e;return t+" "+r+"ms "+o}}}),_n="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function gd(e){return e.matches(_n)?e:e.querySelector(_n)}const vd={display:"none"};function _d(e){let{id:t,value:r}=e;return ie.createElement("div",{id:t,style:vd},r)}function xd(e){let{id:t,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 ie.createElement("div",{id:t,style:m,role:"status","aria-live":o,"aria-atomic":!0},r)}function bd(){const[e,t]=C.useState("");return{announce:C.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Ho=C.createContext(null);function yd(e){const t=C.useContext(Ho);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Sd(){const[e]=C.useState(()=>new Set),t=C.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[C.useCallback(o=>{let{type:m,event:p}=o;e.forEach(v=>{var i;return(i=v[m])==null?void 0:i.call(v,p)})},[e]),t]}const wd={draggable:`
|
|
3
3
|
To pick up a draggable item, press the space bar.
|
|
4
4
|
While dragging, use the arrow keys to move the item.
|
|
5
5
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},Ed={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function jd(e){let{announcements:t=Ed,container:r,hiddenTextDescribedById:o,screenReaderInstructions:m=kd}=e;const{announce:p,announcement:v}=Sd(),i=_r("DndLiveRegion"),[n,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),wd(C.useMemo(()=>({onDragStart(l){let{active:g}=l;p(t.onDragStart({active:g}))},onDragMove(l){let{active:g,over:x}=l;t.onDragMove&&p(t.onDragMove({active:g,over:x}))},onDragOver(l){let{active:g,over:x}=l;p(t.onDragOver({active:g,over:x}))},onDragEnd(l){let{active:g,over:x}=l;p(t.onDragEnd({active:g,over:x}))},onDragCancel(l){let{active:g,over:x}=l;p(t.onDragCancel({active:g,over:x}))}}),[p,t])),!n)return null;const f=ie.createElement(ie.Fragment,null,ie.createElement(bd,{id:o,value:m.draggable}),ie.createElement(yd,{id:i,announcement:v}));return r?Ut.createPortal(f,r):f}var lt;(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"})(lt||(lt={}));function or(){}function Nd(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Ad(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return C.useMemo(()=>[...t].filter(o=>o!=null),[...t])}const jt=Object.freeze({x:0,y:0});function Td(e,t){const r=nr(e);if(!r)return"0 0";const o={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return o.x+"% "+o.y+"%"}function Rd(e,t){let{data:{value:r}}=e,{data:{value:o}}=t;return o-r}function Md(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Dd(e,t){const r=Math.max(t.top,e.top),o=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),p=Math.min(t.top+t.height,e.top+e.height),v=m-o,i=p-r;if(o<m&&r<p){const n=t.width*t.height,c=e.width*e.height,f=v*i,l=f/(n+c-f);return Number(l.toFixed(4))}return 0}const Ld=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:o}=e;const m=[];for(const p of o){const{id:v}=p,i=r.get(v);if(i){const n=Dd(i,t);n>0&&m.push({id:v,data:{droppableContainer:p,value:n}})}}return m.sort(Rd)};function Pd(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function Wo(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:jt}function Od(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,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const Id=Od(1);function $o(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Bd(e,t,r){const o=$o(t);if(!o)return e;const{scaleX:m,scaleY:p,x:v,y:i}=o,n=e.left-v-(1-m)*parseFloat(r),c=e.top-i-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),f=m?e.width/m:e.width,l=p?e.height/p:e.height;return{width:f,height:l,top:c,right:n+f,bottom:c+l,left:n}}const Fd={ignoreTransform:!1};function Is(e,t){t===void 0&&(t=Fd);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=vt(e).getComputedStyle(e);c&&(r=Bd(r,c,f))}const{top:o,left:m,width:p,height:v,bottom:i,right:n}=r;return{top:o,left:m,width:p,height:v,bottom:i,right:n}}function bn(e){return Is(e,{ignoreTransform:!0})}function zd(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Hd(e,t){return t===void 0&&(t=vt(e).getComputedStyle(e)),t.position==="fixed"}function Wd(e,t){t===void 0&&(t=vt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=t[m];return typeof p=="string"?r.test(p):!1})}function Pi(e,t){const r=[];function o(m){if(t!=null&&r.length>=t||!m)return r;if(Di(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!Ps(m)||Fo(m)||r.includes(m))return r;const p=vt(e).getComputedStyle(m);return m!==e&&Wd(m,p)&&r.push(m),Hd(m,p)?r:o(m.parentNode)}return e?o(e):r}function Uo(e){const[t]=Pi(e,1);return t??null}function Or(e){return!gr||!e?null:us(e)?e:Mi(e)?Di(e)||e===hs(e).scrollingElement?window:Ps(e)?e:null:null}function qo(e){return us(e)?e.scrollX:e.scrollLeft}function Ko(e){return us(e)?e.scrollY:e.scrollTop}function ri(e){return{x:qo(e),y:Ko(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Xo(e){return!gr||!e?!1:e===document.scrollingElement}function Vo(e){const t={x:0,y:0},r=Xo(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<=t.y,p=e.scrollLeft<=t.x,v=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:m,isLeft:p,isBottom:v,isRight:i,maxScroll:o,minScroll:t}}const $d={x:.2,y:.2};function Ud(e,t,r,o,m){let{top:p,left:v,right:i,bottom:n}=r;o===void 0&&(o=10),m===void 0&&(m=$d);const{isTop:c,isBottom:f,isLeft:l,isRight:g}=Vo(e),x={x:0,y:0},y={x:0,y:0},_={height:t.height*m.y,width:t.width*m.x};return!c&&p<=t.top+_.height?(x.y=ut.Backward,y.y=o*Math.abs((t.top+_.height-p)/_.height)):!f&&n>=t.bottom-_.height&&(x.y=ut.Forward,y.y=o*Math.abs((t.bottom-_.height-n)/_.height)),!g&&i>=t.right-_.width?(x.x=ut.Forward,y.x=o*Math.abs((t.right-_.width-i)/_.width)):!l&&v<=t.left+_.width&&(x.x=ut.Backward,y.x=o*Math.abs((t.left+_.width-v)/_.width)),{direction:x,speed:y}}function qd(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:t,left:r,right:o,bottom:m}=e.getBoundingClientRect();return{top:t,left:r,right:o,bottom:m,width:e.clientWidth,height:e.clientHeight}}function Yo(e){return e.reduce((t,r)=>is(t,ri(r)),jt)}function Kd(e){return e.reduce((t,r)=>t+qo(r),0)}function Xd(e){return e.reduce((t,r)=>t+Ko(r),0)}function Go(e,t){if(t===void 0&&(t=Is),!e)return;const{top:r,left:o,bottom:m,right:p}=t(e);Uo(e)&&(m<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Vd=[["x",["left","right"],Kd],["y",["top","bottom"],Xd]];class Oi{constructor(t,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=Pi(r),m=Yo(o);this.rect={...t},this.width=t.width,this.height=t.height;for(const[p,v,i]of Vd)for(const n of v)Object.defineProperty(this,n,{get:()=>{const c=i(o),f=m[p]-c;return this.rect[n]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class xs{constructor(t){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=t}add(t,r,o){var m;(m=this.target)==null||m.addEventListener(t,r,o),this.listeners.push([t,r,o])}}function Yd(e){const{EventTarget:t}=vt(e);return e instanceof t?e:hs(e)}function Ir(e,t){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+o**2)>t:"x"in t&&"y"in t?r>t.x&&o>t.y:"x"in t?r>t.x:"y"in t?o>t.y:!1}var wt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(wt||(wt={}));function yn(e){e.preventDefault()}function Gd(e){e.stopPropagation()}var ze;(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"})(ze||(ze={}));const Qo={start:[ze.Space,ze.Enter],cancel:[ze.Esc],end:[ze.Space,ze.Enter,ze.Tab]},Qd=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case ze.Right:return{...r,x:r.x+25};case ze.Left:return{...r,x:r.x-25};case ze.Down:return{...r,y:r.y+25};case ze.Up:return{...r,y:r.y-25}}};class Zo{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new xs(hs(r)),this.windowListeners=new xs(vt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,o=t.node.current;o&&Go(o),r(jt)}handleKeyDown(t){if(Li(t)){const{active:r,context:o,options:m}=this.props,{keyboardCodes:p=Qo,coordinateGetter:v=Qd,scrollBehavior:i="smooth"}=m,{code:n}=t;if(p.end.includes(n)){this.handleEnd(t);return}if(p.cancel.includes(n)){this.handleCancel(t);return}const{collisionRect:c}=o.current,f=c?{x:c.left,y:c.top}:jt;this.referenceCoordinates||(this.referenceCoordinates=f);const l=v(t,{active:r,context:o.current,currentCoordinates:f});if(l){const g=ir(l,f),x={x:0,y:0},{scrollableAncestors:y}=o.current;for(const _ of y){const a=t.code,{isTop:h,isRight:d,isLeft:u,isBottom:b,maxScroll:S,minScroll:E}=Vo(_),j=qd(_),w={x:Math.min(a===ze.Right?j.right-j.width/2:j.right,Math.max(a===ze.Right?j.left:j.left+j.width/2,l.x)),y:Math.min(a===ze.Down?j.bottom-j.height/2:j.bottom,Math.max(a===ze.Down?j.top:j.top+j.height/2,l.y))},k=a===ze.Right&&!d||a===ze.Left&&!u,N=a===ze.Down&&!b||a===ze.Up&&!h;if(k&&w.x!==l.x){const L=_.scrollLeft+g.x,R=a===ze.Right&&L<=S.x||a===ze.Left&&L>=E.x;if(R&&!g.y){_.scrollTo({left:L,behavior:i});return}R?x.x=_.scrollLeft-L:x.x=a===ze.Right?_.scrollLeft-S.x:_.scrollLeft-E.x,x.x&&_.scrollBy({left:-x.x,behavior:i});break}else if(N&&w.y!==l.y){const L=_.scrollTop+g.y,R=a===ze.Down&&L<=S.y||a===ze.Up&&L>=E.y;if(R&&!g.x){_.scrollTo({top:L,behavior:i});return}R?x.y=_.scrollTop-L:x.y=a===ze.Down?_.scrollTop-S.y:_.scrollTop-E.y,x.y&&_.scrollBy({top:-x.y,behavior:i});break}}this.handleMove(t,is(ir(l,this.referenceCoordinates),x))}}}handleMove(t,r){const{onMove:o}=this.props;t.preventDefault(),o(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Zo.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:o=Qo,onActivation:m}=t,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const i=p.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Sn(e){return!!(e&&"distance"in e)}function wn(e){return!!(e&&"delay"in e)}class Ii{constructor(t,r,o){var m;o===void 0&&(o=Yd(t.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=t,this.events=r;const{event:p}=t,{target:v}=p;this.props=t,this.events=r,this.document=hs(v),this.documentListeners=new xs(this.document),this.listeners=new xs(o),this.windowListeners=new xs(vt(v)),this.initialCoordinates=(m=nr(p))!=null?m:jt,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:t,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.DragStart,yn),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),this.windowListeners.add(wt.ContextMenu,yn),this.documentListeners.add(wt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(wn(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Sn(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(t,r){const{active:o,onPending:m}=this.props;m(o,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(wt.Click,Gd,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wt.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:o,initialCoordinates:m,props:p}=this,{onMove:v,options:{activationConstraint:i}}=p;if(!m)return;const n=(r=nr(t))!=null?r:jt,c=ir(m,n);if(!o&&i){if(Sn(i)){if(i.tolerance!=null&&Ir(c,i.tolerance))return this.handleCancel();if(Ir(c,i.distance))return this.handleStart()}if(wn(i)&&Ir(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),v(n)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===ze.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Zd={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Bi extends Ii{constructor(t){const{event:r}=t,o=hs(r.target);super(t,Zd,o)}}Bi.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Jd={move:{name:"mousemove"},end:{name:"mouseup"}};var ii;(function(e){e[e.RightClick=2]="RightClick"})(ii||(ii={}));class eu extends Ii{constructor(t){super(t,Jd,hs(t.event.target))}}eu.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;return r.button===ii.RightClick?!1:(o?.({event:r}),!0)}}];const Br={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class tu extends Ii{constructor(t){super(t,Br)}static setup(){return window.addEventListener(Br.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Br.move.name,t)};function t(){}}}tu.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;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 ar;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ar||(ar={}));function su(e){let{acceleration:t,activator:r=bs.Pointer,canScroll:o,draggingRect:m,enabled:p,interval:v=5,order:i=ar.TreeOrder,pointerCoordinates:n,scrollableAncestors:c,scrollableAncestorRects:f,delta:l,threshold:g}=e;const x=iu({delta:l,disabled:!p}),[y,_]=pd(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case bs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case bs.DraggableRect:return m}},[r,m,n]),u=C.useRef(null),b=C.useCallback(()=>{const E=u.current;if(!E)return;const j=a.current.x*h.current.x,w=a.current.y*h.current.y;E.scrollBy(j,w)},[]),S=C.useMemo(()=>i===ar.TreeOrder?[...c].reverse():c,[i,c]);C.useEffect(()=>{if(!p||!c.length||!d){_();return}for(const E of S){if(o?.(E)===!1)continue;const j=c.indexOf(E),w=f[j];if(!w)continue;const{direction:k,speed:N}=Ud(E,w,d,t,g);for(const L of["x","y"])x[L][k[L]]||(N[L]=0,k[L]=0);if(N.x>0||N.y>0){_(),u.current=E,y(b,v),a.current=N,h.current=k;return}}a.current={x:0,y:0},h.current={x:0,y:0},_()},[t,b,o,_,p,v,JSON.stringify(d),JSON.stringify(x),y,c,S,f,JSON.stringify(g)])}const ru={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function iu(e){let{delta:t,disabled:r}=e;const o=rr(t);return Os(m=>{if(r||!o||!m)return ru;const p={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[ut.Backward]:m.x[ut.Backward]||p.x===-1,[ut.Forward]:m.x[ut.Forward]||p.x===1},y:{[ut.Backward]:m.y[ut.Backward]||p.y===-1,[ut.Forward]:m.y[ut.Forward]||p.y===1}}},[r,t,o])}function nu(e,t){const r=t!=null?e.get(t):void 0,o=r?r.node.current:null;return Os(m=>{var p;return t==null?null:(p=o??m)!=null?p:null},[o,t])}function ou(e,t){return C.useMemo(()=>e.reduce((r,o)=>{const{sensor:m}=o,p=m.activators.map(v=>({eventName:v.eventName,handler:t(v.handler,o)}));return[...r,...p]},[]),[e,t])}var As;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(As||(As={}));var ni;(function(e){e.Optimized="optimized"})(ni||(ni={}));const Cn=new Map;function au(e,t){let{dragging:r,dependencies:o,config:m}=t;const[p,v]=C.useState(null),{frequency:i,measure:n,strategy:c}=m,f=C.useRef(e),l=a(),g=js(l),x=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(u=>!d.includes(u))))},[g]),y=C.useRef(null),_=Os(h=>{if(l&&!r)return Cn;if(!h||h===Cn||f.current!==e||p!=null){const d=new Map;for(let u of e){if(!u)continue;if(p&&p.length>0&&!p.includes(u.id)&&u.rect.current){d.set(u.id,u.rect.current);continue}const b=u.node.current,S=b?new Oi(n(b),b):null;u.rect.current=S,S&&d.set(u.id,S)}return d}return h},[e,p,r,l,n]);return C.useEffect(()=>{f.current=e},[e]),C.useEffect(()=>{l||x()},[r,l]),C.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),C.useEffect(()=>{l||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{x(),y.current=null},i))},[i,l,x,...o]),{droppableRects:_,measureDroppableContainers:x,measuringScheduled:p!=null};function a(){switch(c){case As.Always:return!1;case As.BeforeDragging:return r;default:return!r}}}function Fi(e,t){return Os(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function lu(e,t){return Fi(e,t)}function cu(e){let{callback:t,disabled:r}=e;const o=vr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function xr(e){let{callback:t,disabled:r}=e;const o=vr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function du(e){return new Oi(Is(e),e)}function kn(e,t,r){t===void 0&&(t=du);const[o,m]=C.useState(null);function p(){m(n=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=n??r)!=null?c:null}const f=t(e);return JSON.stringify(n)===JSON.stringify(f)?n:f})}const v=cu({callback(n){if(e)for(const c of n){const{type:f,target:l}=c;if(f==="childList"&&l instanceof HTMLElement&&l.contains(e)){p();break}}}}),i=xr({callback:p});return Rt(()=>{p(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),o}function uu(e){const t=Fi(e);return Wo(e,t)}const En=[];function hu(e){const t=C.useRef(e),r=Os(o=>e?o&&o!==En&&e&&t.current&&e.parentNode===t.current.parentNode?o:Pi(e):En,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function fu(e){const[t,r]=C.useState(null),o=C.useRef(e),m=C.useCallback(p=>{const v=Or(p.target);v&&r(i=>i?(i.set(v,ri(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const p=o.current;if(e!==p){v(p);const i=e.map(n=>{const c=Or(n);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,ri(c)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{v(e),v(p)};function v(i){i.forEach(n=>{const c=Or(n);c?.removeEventListener("scroll",m)})}},[m,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((p,v)=>is(p,v),jt):Yo(e):jt,[e,t])}function jn(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const o=e!==jt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?ir(e,r.current):jt}function mu(e){C.useEffect(()=>{if(!gr)return;const t=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function pu(e,t){return C.useMemo(()=>e.reduce((r,o)=>{let{eventName:m,handler:p}=o;return r[m]=v=>{p(v,t)},r},{}),[e,t])}function Jo(e){return C.useMemo(()=>e?zd(e):null,[e])}const Nn=[];function gu(e,t){t===void 0&&(t=Is);const[r]=e,o=Jo(r?vt(r):null),[m,p]=C.useState(Nn);function v(){p(()=>e.length?e.map(n=>Xo(n)?o:new Oi(t(n),n)):Nn)}const i=xr({callback:v});return Rt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),m}function ea(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ps(t)?t:e}function vu(e){let{measure:t}=e;const[r,o]=C.useState(null),m=C.useCallback(c=>{for(const{target:f}of c)if(Ps(f)){o(l=>{const g=t(f);return l?{...l,width:g.width,height:g.height}:g});break}},[t]),p=xr({callback:m}),v=C.useCallback(c=>{const f=ea(c);p?.disconnect(),f&&p?.observe(f),o(f?t(f):null)},[t,p]),[i,n]=sr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const _u=[{sensor:Bi,options:{}},{sensor:Zo,options:{}}],xu={current:{}},Gs={draggable:{measure:bn},droppable:{measure:bn,strategy:As.WhileDragging,frequency:ni.Optimized},dragOverlay:{measure:Is}};class ys extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,o;return(r=(o=this.get(t))==null?void 0:o.node.current)!=null?r:void 0}}const bu={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ys,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:or},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gs,measureDroppableContainers:or,windowRect:null,measuringScheduled:!1},ta={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:or,draggableNodes:new Map,over:null,measureDroppableContainers:or},Bs=C.createContext(ta),sa=C.createContext(bu);function yu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ys}}}function Su(e,t){switch(t.type){case lt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case lt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case lt.DragEnd:case lt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case lt.RegisterDroppable:{const{element:r}=t,{id:o}=r,m=new ys(e.droppable.containers);return m.set(o,r),{...e,droppable:{...e.droppable,containers:m}}}case lt.SetDroppableDisabled:{const{id:r,key:o,disabled:m}=t,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new ys(e.droppable.containers);return v.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:v}}}case lt.UnregisterDroppable:{const{id:r,key:o}=t,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const p=new ys(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function wu(e){let{disabled:t}=e;const{active:r,activatorEvent:o,draggableNodes:m}=C.useContext(Bs),p=rr(o),v=rr(r?.id);return C.useEffect(()=>{if(!t&&!o&&p&&v!=null){if(!Li(p)||document.activeElement===p.target)return;const i=m.get(v);if(!i)return;const{activatorNode:n,node:c}=i;if(!n.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[n.current,c.current]){if(!f)continue;const l=_d(f);if(l){l.focus();break}}})}},[o,t,m,v,p]),null}function ra(e,t){let{transform:r,...o}=t;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...o}),r):r}function Cu(e){return C.useMemo(()=>({draggable:{...Gs.draggable,...e?.draggable},droppable:{...Gs.droppable,...e?.droppable},dragOverlay:{...Gs.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function ku(e){let{activeNode:t,measure:r,initialRect:o,config:m=!0}=e;const p=C.useRef(!1),{x:v,y:i}=typeof m=="boolean"?{x:m,y:m}:m;Rt(()=>{if(!v&&!i||!t){p.current=!1;return}if(p.current||!o)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=r(c),l=Wo(f,o);if(v||(l.x=0),i||(l.y=0),p.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=Uo(c);g&&g.scrollBy({top:l.y,left:l.x})}},[t,v,i,o,r])}const br=C.createContext({...jt,scaleX:1,scaleY:1});var Pt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Pt||(Pt={}));const Eu=C.memo(function(t){var r,o,m,p;let{id:v,accessibility:i,autoScroll:n=!0,children:c,sensors:f=_u,collisionDetection:l=Ld,measuring:g,modifiers:x,...y}=t;const _=C.useReducer(Su,void 0,yu),[a,h]=_,[d,u]=Cd(),[b,S]=C.useState(Pt.Uninitialized),E=b===Pt.Initialized,{draggable:{active:j,nodes:w,translate:k},droppable:{containers:N}}=a,L=j!=null?w.get(j):null,R=C.useRef({initial:null,translated:null}),M=C.useMemo(()=>{var Me;return j!=null?{id:j,data:(Me=L?.data)!=null?Me:xu,rect:R}:null},[j,L]),D=C.useRef(null),[I,F]=C.useState(null),[z,A]=C.useState(null),P=js(y,Object.values(y)),O=_r("DndDescribedBy",v),B=C.useMemo(()=>N.getEnabled(),[N]),$=Cu(g),{droppableRects:Y,measureDroppableContainers:Q,measuringScheduled:Z}=au(B,{dragging:E,dependencies:[k.x,k.y],config:$.droppable}),he=nu(w,j),T=C.useMemo(()=>z?nr(z):null,[z]),H=ct(),U=lu(he,$.draggable.measure);ku({activeNode:j!=null?w.get(j):null,config:H.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const W=kn(he,$.draggable.measure,U),se=kn(he?he.parentElement:null),K=C.useRef({activatorEvent:null,active:null,activeNode:he,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ce=N.getNodeFor((r=K.current.over)==null?void 0:r.id),pe=vu({measure:$.dragOverlay.measure}),be=(o=pe.nodeRef.current)!=null?o:he,De=E?(m=pe.rect)!=null?m:W:null,ne=!!(pe.nodeRef.current&&pe.rect),_e=uu(ne?null:W),He=Jo(be?vt(be):null),we=hu(E?ce??he:null),Le=gu(we),ke=ra(x,{transform:{x:k.x-_e.x,y:k.y-_e.y,scaleX:1,scaleY:1},activatorEvent:z,active:M,activeNodeRect:W,containerNodeRect:se,draggingNodeRect:De,over:K.current.over,overlayNodeRect:pe.rect,scrollableAncestors:we,scrollableAncestorRects:Le,windowRect:He}),Ee=T?is(T,k):null,Ue=fu(we),ye=jn(Ue),Je=jn(Ue,[W]),Ce=is(ke,ye),Ne=De?Id(De,ke):null,tt=M&&Ne?l({active:M,collisionRect:Ne,droppableRects:Y,droppableContainers:B,pointerCoordinates:Ee}):null,X=Md(tt,"id"),[J,ee]=C.useState(null),fe=ne?ke:is(ke,Je),qe=Pd(fe,(p=J?.rect)!=null?p:null,W),Ae=C.useRef(null),Ve=C.useCallback((Me,Pe)=>{let{sensor:et,options:ft}=Pe;if(D.current==null)return;const ot=w.get(D.current);if(!ot)return;const st=Me.nativeEvent,Oe=new et({active:D.current,activeNode:ot,event:st,options:ft,context:K,onAbort(Ye){if(!w.get(Ye))return;const{onDragAbort:rt}=P.current,V={id:Ye};rt?.(V),d({type:"onDragAbort",event:V})},onPending(Ye,mt,rt,V){if(!w.get(Ye))return;const{onDragPending:je}=P.current,q={id:Ye,constraint:mt,initialCoordinates:rt,offset:V};je?.(q),d({type:"onDragPending",event:q})},onStart(Ye){const mt=D.current;if(mt==null)return;const rt=w.get(mt);if(!rt)return;const{onDragStart:V}=P.current,le={activatorEvent:st,active:{id:mt,data:rt.data,rect:R}};Ut.unstable_batchedUpdates(()=>{V?.(le),S(Pt.Initializing),h({type:lt.DragStart,initialCoordinates:Ye,active:mt}),d({type:"onDragStart",event:le}),F(Ae.current),A(st)})},onMove(Ye){h({type:lt.DragMove,coordinates:Ye})},onEnd:_t(lt.DragEnd),onCancel:_t(lt.DragCancel)});Ae.current=Oe;function _t(Ye){return async function(){const{active:rt,collisions:V,over:le,scrollAdjustedTranslate:je}=K.current;let q=null;if(rt&&je){const{cancelDrop:re}=P.current;q={activatorEvent:st,active:rt,collisions:V,delta:je,over:le},Ye===lt.DragEnd&&typeof re=="function"&&await Promise.resolve(re(q))&&(Ye=lt.DragCancel)}D.current=null,Ut.unstable_batchedUpdates(()=>{h({type:Ye}),S(Pt.Uninitialized),ee(null),F(null),A(null),Ae.current=null;const re=Ye===lt.DragEnd?"onDragEnd":"onDragCancel";if(q){const me=P.current[re];me?.(q),d({type:re,event:q})}})}}},[w]),nt=C.useCallback((Me,Pe)=>(et,ft)=>{const ot=et.nativeEvent,st=w.get(ft);if(D.current!==null||!st||ot.dndKit||ot.defaultPrevented)return;const Oe={active:st};Me(et,Pe.options,Oe)===!0&&(ot.dndKit={capturedBy:Pe.sensor},D.current=ft,Ve(et,Pe))},[w,Ve]),Fe=ou(f,nt);mu(f),Rt(()=>{W&&b===Pt.Initializing&&S(Pt.Initialized)},[W,b]),C.useEffect(()=>{const{onDragMove:Me}=P.current,{active:Pe,activatorEvent:et,collisions:ft,over:ot}=K.current;if(!Pe||!et)return;const st={active:Pe,activatorEvent:et,collisions:ft,delta:{x:Ce.x,y:Ce.y},over:ot};Ut.unstable_batchedUpdates(()=>{Me?.(st),d({type:"onDragMove",event:st})})},[Ce.x,Ce.y]),C.useEffect(()=>{const{active:Me,activatorEvent:Pe,collisions:et,droppableContainers:ft,scrollAdjustedTranslate:ot}=K.current;if(!Me||D.current==null||!Pe||!ot)return;const{onDragOver:st}=P.current,Oe=ft.get(X),_t=Oe&&Oe.rect.current?{id:Oe.id,rect:Oe.rect.current,data:Oe.data,disabled:Oe.disabled}:null,Ye={active:Me,activatorEvent:Pe,collisions:et,delta:{x:ot.x,y:ot.y},over:_t};Ut.unstable_batchedUpdates(()=>{ee(_t),st?.(Ye),d({type:"onDragOver",event:Ye})})},[X]),Rt(()=>{K.current={activatorEvent:z,active:M,activeNode:he,collisionRect:Ne,collisions:tt,droppableRects:Y,draggableNodes:w,draggingNode:be,draggingNodeRect:De,droppableContainers:N,over:J,scrollableAncestors:we,scrollAdjustedTranslate:Ce},R.current={initial:De,translated:Ne}},[M,he,tt,Ne,w,be,De,Y,N,J,we,Ce]),su({...H,delta:k,draggingRect:Ne,pointerCoordinates:Ee,scrollableAncestors:we,scrollableAncestorRects:Le});const yt=C.useMemo(()=>({active:M,activeNode:he,activeNodeRect:W,activatorEvent:z,collisions:tt,containerNodeRect:se,dragOverlay:pe,draggableNodes:w,droppableContainers:N,droppableRects:Y,over:J,measureDroppableContainers:Q,scrollableAncestors:we,scrollableAncestorRects:Le,measuringConfiguration:$,measuringScheduled:Z,windowRect:He}),[M,he,W,z,tt,se,pe,w,N,Y,J,Q,we,Le,$,Z,He]),Qe=C.useMemo(()=>({activatorEvent:z,activators:Fe,active:M,activeNodeRect:W,ariaDescribedById:{draggable:O},dispatch:h,draggableNodes:w,over:J,measureDroppableContainers:Q}),[z,Fe,M,W,h,O,w,J,Q]);return ie.createElement(Ho.Provider,{value:u},ie.createElement(Bs.Provider,{value:Qe},ie.createElement(sa.Provider,{value:yt},ie.createElement(br.Provider,{value:qe},c)),ie.createElement(wu,{disabled:i?.restoreFocus===!1})),ie.createElement(jd,{...i,hiddenTextDescribedById:O}));function ct(){const Me=I?.autoScrollEnabled===!1,Pe=typeof n=="object"?n.enabled===!1:n===!1,et=E&&!Me&&!Pe;return typeof n=="object"?{...n,enabled:et}:{enabled:et}}}),ju=C.createContext(null),An="button",Nu="Draggable";function Au(e){let{id:t,data:r,disabled:o=!1,attributes:m}=e;const p=_r(Nu),{activators:v,activatorEvent:i,active:n,activeNodeRect:c,ariaDescribedById:f,draggableNodes:l,over:g}=C.useContext(Bs),{role:x=An,roleDescription:y="draggable",tabIndex:_=0}=m??{},a=n?.id===t,h=C.useContext(a?br:ju),[d,u]=sr(),[b,S]=sr(),E=pu(v,t),j=js(r);Rt(()=>(l.set(t,{id:t,key:p,node:d,activatorNode:b,data:j}),()=>{const k=l.get(t);k&&k.key===p&&l.delete(t)}),[l,t]);const w=C.useMemo(()=>({role:x,tabIndex:_,"aria-disabled":o,"aria-pressed":a&&x===An?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[o,x,_,a,y,f.draggable]);return{active:n,activatorEvent:i,activeNodeRect:c,attributes:w,isDragging:a,listeners:o?void 0:E,node:d,over:g,setNodeRef:u,setActivatorNodeRef:S,transform:h}}function Tu(){return C.useContext(sa)}const Ru="Droppable",Mu={timeout:25};function Du(e){let{data:t,disabled:r=!1,id:o,resizeObserverConfig:m}=e;const p=_r(Ru),{active:v,dispatch:i,over:n,measureDroppableContainers:c}=C.useContext(Bs),f=C.useRef({disabled:r}),l=C.useRef(!1),g=C.useRef(null),x=C.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:a}={...Mu,...m},h=js(_??o),d=C.useCallback(()=>{if(!l.current){l.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),u=xr({callback:d,disabled:y||!v}),b=C.useCallback((w,k)=>{u&&(k&&(u.unobserve(k),l.current=!1),w&&u.observe(w))},[u]),[S,E]=sr(b),j=js(t);return C.useEffect(()=>{!u||!S.current||(u.disconnect(),l.current=!1,u.observe(S.current))},[S,u]),C.useEffect(()=>(i({type:lt.RegisterDroppable,element:{id:o,key:p,disabled:r,node:S,rect:g,data:j}}),()=>i({type:lt.UnregisterDroppable,key:p,id:o})),[o]),C.useEffect(()=>{r!==f.current.disabled&&(i({type:lt.SetDroppableDisabled,id:o,key:p,disabled:r}),f.current.disabled=r)},[o,p,r,i]),{active:v,rect:g,isOver:n?.id===o,node:S,over:n,setNodeRef:E}}function Lu(e){let{animation:t,children:r}=e;const[o,m]=C.useState(null),[p,v]=C.useState(null),i=rr(r);return!r&&!o&&i&&m(i),Rt(()=>{if(!p)return;const n=o?.key,c=o?.props.id;if(n==null||c==null){m(null);return}Promise.resolve(t(c,p)).then(()=>{m(null)})},[t,o,p]),ie.createElement(ie.Fragment,null,r,o?C.cloneElement(o,{ref:v}):null)}const Pu={x:0,y:0,scaleX:1,scaleY:1};function Ou(e){let{children:t}=e;return ie.createElement(Bs.Provider,{value:ta},ie.createElement(br.Provider,{value:Pu},t))}const Iu={position:"fixed",touchAction:"none"},Bu=e=>Li(e)?"transform 250ms ease":void 0,Fu=C.forwardRef((e,t)=>{let{as:r,activatorEvent:o,adjustScale:m,children:p,className:v,rect:i,style:n,transform:c,transition:f=Bu}=e;if(!i)return null;const l=m?c:{...c,scaleX:1,scaleY:1},g={...Iu,width:i.width,height:i.height,top:i.top,left:i.left,transform:Ns.Transform.toString(l),transformOrigin:m&&o?Td(o,i):void 0,transition:typeof f=="function"?f(o):f,...n};return ie.createElement(r,{className:v,style:g,ref:t},p)}),zu=e=>t=>{let{active:r,dragOverlay:o}=t;const m={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[i,n]of Object.entries(p.active))n!==void 0&&(m[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(p!=null&&p.dragOverlay)for(const[i,n]of Object.entries(p.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[n,c]of Object.entries(m))r.node.style.setProperty(n,c);v!=null&&v.active&&r.node.classList.remove(v.active)}},Hu=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:Ns.Transform.toString(t)},{transform:Ns.Transform.toString(r)}]},Wu={duration:250,easing:"ease",keyframes:Hu,sideEffects:zu({styles:{active:{opacity:"0"}}})};function $u(e){let{config:t,draggableNodes:r,droppableContainers:o,measuringConfiguration:m}=e;return vr((p,v)=>{if(t===null)return;const i=r.get(p);if(!i)return;const n=i.node.current;if(!n)return;const c=ea(v);if(!c)return;const{transform:f}=vt(v).getComputedStyle(v),l=$o(f);if(!l)return;const g=typeof t=="function"?t:Uu(t);return Go(n,m.draggable.measure),g({active:{id:p,data:i.data,node:n,rect:m.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:v,rect:m.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:m,transform:l})})}function Uu(e){const{duration:t,easing:r,sideEffects:o,keyframes:m}={...Wu,...e};return p=>{let{active:v,dragOverlay:i,transform:n,...c}=p;if(!t)return;const f={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},l={scaleX:n.scaleX!==1?v.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?v.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-f.x,y:n.y-f.y,...l},x=m({...c,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=x,_=x[x.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const a=o?.({active:v,dragOverlay:i,...c}),h=i.node.animate(x,{duration:t,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let Tn=0;function qu(e){return C.useMemo(()=>{if(e!=null)return Tn++,Tn},[e])}const Ku=ie.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:o,style:m,transition:p,modifiers:v,wrapperElement:i="div",className:n,zIndex:c=999}=e;const{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:x,draggableNodes:y,droppableContainers:_,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:u,scrollableAncestorRects:b,windowRect:S}=Tu(),E=C.useContext(br),j=qu(l?.id),w=ra(v,{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:u,scrollableAncestorRects:b,transform:E,windowRect:S}),k=Fi(g),N=$u({config:o,draggableNodes:y,droppableContainers:_,measuringConfiguration:d}),L=k?a.setRef:void 0;return ie.createElement(Ou,null,ie.createElement(Lu,{animation:N},l&&j?ie.createElement(Fu,{key:j,id:l.id,ref:L,as:i,activatorEvent:f,adjustScale:t,className:n,transition:p,rect:k,style:{zIndex:c,...m},transform:w},r):null))}),ia=768;function Xu(e){const t=window.matchMedia(`(max-width: ${ia-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Vu(){return window.innerWidth<ia}function Yu(){return!1}function na(){return C.useSyncExternalStore(Xu,Vu,Yu)}const ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Gu=[{status:ve.Review,label:"Review",icon:mi,color:"text-amber-600"},{status:ve.Running,label:"Running",icon:pi,color:"text-blue-600"},{status:ve.Pending,label:"Pending",icon:gi,color:"text-neutral-600"},{status:ve.Done,label:"Done",icon:vi,color:"text-emerald-600"},{status:ve.Cancelled,label:"Cancelled",icon:_i,color:"text-neutral-500"}];function Qu({task:e,status:t,isSelected:r,isAgentActive:o,project:m,onSelectTask:p,onTaskStatusChange:v,onDeleteTask:i,disableDrag:n}){const{t:c}=ae(),f=!!e.projectArchivedAt,l=f||!!n,{attributes:g,listeners:x,setNodeRef:y,isDragging:_}=Au({id:e.id,data:{task:e,fromStatus:t},disabled:l}),[a,h]=C.useState(null),d=C.useRef(null),u=C.useRef(null),b=C.useCallback(j=>{f||!v&&!i||(j.preventDefault(),h({x:j.clientX,y:j.clientY}))},[f,v,i]),S=C.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),E=C.useCallback(j=>{if(!n||f||!v&&!i)return;const w=j.touches[0];if(!w)return;const{clientX:k,clientY:N}=w;u.current=setTimeout(()=>{u.current=null,h({x:k,y:N})},500)},[n,f,v,i]);return C.useEffect(()=>{if(!a)return;const j=w=>{d.current&&!d.current.contains(w.target)&&h(null)};return document.addEventListener("mousedown",j),document.addEventListener("touchstart",j),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("touchstart",j)}},[a]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:y,onClick:()=>p(e.id),onContextMenu:b,onTouchStart:E,onTouchEnd:S,onTouchMove:S,className:`flex items-start pl-7 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
6
|
+
`},Cd={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function kd(e){let{announcements:t=Cd,container:r,hiddenTextDescribedById:o,screenReaderInstructions:m=wd}=e;const{announce:p,announcement:v}=bd(),i=pr("DndLiveRegion"),[n,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),yd(C.useMemo(()=>({onDragStart(l){let{active:g}=l;p(t.onDragStart({active:g}))},onDragMove(l){let{active:g,over:b}=l;t.onDragMove&&p(t.onDragMove({active:g,over:b}))},onDragOver(l){let{active:g,over:b}=l;p(t.onDragOver({active:g,over:b}))},onDragEnd(l){let{active:g,over:b}=l;p(t.onDragEnd({active:g,over:b}))},onDragCancel(l){let{active:g,over:b}=l;p(t.onDragCancel({active:g,over:b}))}}),[p,t])),!n)return null;const f=ie.createElement(ie.Fragment,null,ie.createElement(_d,{id:o,value:m.draggable}),ie.createElement(xd,{id:i,announcement:v}));return r?qt.createPortal(f,r):f}var lt;(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"})(lt||(lt={}));function ir(){}function Ed(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function jd(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return C.useMemo(()=>[...t].filter(o=>o!=null),[...t])}const jt=Object.freeze({x:0,y:0});function Nd(e,t){const r=rr(e);if(!r)return"0 0";const o={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return o.x+"% "+o.y+"%"}function Ad(e,t){let{data:{value:r}}=e,{data:{value:o}}=t;return o-r}function Rd(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function Td(e,t){const r=Math.max(t.top,e.top),o=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),p=Math.min(t.top+t.height,e.top+e.height),v=m-o,i=p-r;if(o<m&&r<p){const n=t.width*t.height,c=e.width*e.height,f=v*i,l=f/(n+c-f);return Number(l.toFixed(4))}return 0}const Md=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:o}=e;const m=[];for(const p of o){const{id:v}=p,i=r.get(v);if(i){const n=Td(i,t);n>0&&m.push({id:v,data:{droppableContainer:p,value:n}})}}return m.sort(Ad)};function Dd(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function Wo(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:jt}function Ld(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,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const Pd=Ld(1);function $o(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Od(e,t,r){const o=$o(t);if(!o)return e;const{scaleX:m,scaleY:p,x:v,y:i}=o,n=e.left-v-(1-m)*parseFloat(r),c=e.top-i-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),f=m?e.width/m:e.width,l=p?e.height/p:e.height;return{width:f,height:l,top:c,right:n+f,bottom:c+l,left:n}}const Id={ignoreTransform:!1};function Ps(e,t){t===void 0&&(t=Id);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=_t(e).getComputedStyle(e);c&&(r=Od(r,c,f))}const{top:o,left:m,width:p,height:v,bottom:i,right:n}=r;return{top:o,left:m,width:p,height:v,bottom:i,right:n}}function xn(e){return Ps(e,{ignoreTransform:!0})}function Bd(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Fd(e,t){return t===void 0&&(t=_t(e).getComputedStyle(e)),t.position==="fixed"}function zd(e,t){t===void 0&&(t=_t(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const p=t[m];return typeof p=="string"?r.test(p):!1})}function Li(e,t){const r=[];function o(m){if(t!=null&&r.length>=t||!m)return r;if(Mi(m)&&m.scrollingElement!=null&&!r.includes(m.scrollingElement))return r.push(m.scrollingElement),r;if(!Ds(m)||Fo(m)||r.includes(m))return r;const p=_t(e).getComputedStyle(m);return m!==e&&zd(m,p)&&r.push(m),Fd(m,p)?r:o(m.parentNode)}return e?o(e):r}function Uo(e){const[t]=Li(e,1);return t??null}function Lr(e){return!fr||!e?null:ds(e)?e:Ti(e)?Mi(e)||e===us(e).scrollingElement?window:Ds(e)?e:null:null}function qo(e){return ds(e)?e.scrollX:e.scrollLeft}function Ko(e){return ds(e)?e.scrollY:e.scrollTop}function ti(e){return{x:qo(e),y:Ko(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Xo(e){return!fr||!e?!1:e===document.scrollingElement}function Vo(e){const t={x:0,y:0},r=Xo(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<=t.y,p=e.scrollLeft<=t.x,v=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:m,isLeft:p,isBottom:v,isRight:i,maxScroll:o,minScroll:t}}const Hd={x:.2,y:.2};function Wd(e,t,r,o,m){let{top:p,left:v,right:i,bottom:n}=r;o===void 0&&(o=10),m===void 0&&(m=Hd);const{isTop:c,isBottom:f,isLeft:l,isRight:g}=Vo(e),b={x:0,y:0},y={x:0,y:0},_={height:t.height*m.y,width:t.width*m.x};return!c&&p<=t.top+_.height?(b.y=ut.Backward,y.y=o*Math.abs((t.top+_.height-p)/_.height)):!f&&n>=t.bottom-_.height&&(b.y=ut.Forward,y.y=o*Math.abs((t.bottom-_.height-n)/_.height)),!g&&i>=t.right-_.width?(b.x=ut.Forward,y.x=o*Math.abs((t.right-_.width-i)/_.width)):!l&&v<=t.left+_.width&&(b.x=ut.Backward,y.x=o*Math.abs((t.left+_.width-v)/_.width)),{direction:b,speed:y}}function $d(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:t,left:r,right:o,bottom:m}=e.getBoundingClientRect();return{top:t,left:r,right:o,bottom:m,width:e.clientWidth,height:e.clientHeight}}function Yo(e){return e.reduce((t,r)=>rs(t,ti(r)),jt)}function Ud(e){return e.reduce((t,r)=>t+qo(r),0)}function qd(e){return e.reduce((t,r)=>t+Ko(r),0)}function Go(e,t){if(t===void 0&&(t=Ps),!e)return;const{top:r,left:o,bottom:m,right:p}=t(e);Uo(e)&&(m<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Kd=[["x",["left","right"],Ud],["y",["top","bottom"],qd]];class Pi{constructor(t,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=Li(r),m=Yo(o);this.rect={...t},this.width=t.width,this.height=t.height;for(const[p,v,i]of Kd)for(const n of v)Object.defineProperty(this,n,{get:()=>{const c=i(o),f=m[p]-c;return this.rect[n]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class _s{constructor(t){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=t}add(t,r,o){var m;(m=this.target)==null||m.addEventListener(t,r,o),this.listeners.push([t,r,o])}}function Xd(e){const{EventTarget:t}=_t(e);return e instanceof t?e:us(e)}function Pr(e,t){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+o**2)>t:"x"in t&&"y"in t?r>t.x&&o>t.y:"x"in t?r>t.x:"y"in t?o>t.y:!1}var wt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(wt||(wt={}));function bn(e){e.preventDefault()}function Vd(e){e.stopPropagation()}var ze;(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"})(ze||(ze={}));const Qo={start:[ze.Space,ze.Enter],cancel:[ze.Esc],end:[ze.Space,ze.Enter,ze.Tab]},Yd=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case ze.Right:return{...r,x:r.x+25};case ze.Left:return{...r,x:r.x-25};case ze.Down:return{...r,y:r.y+25};case ze.Up:return{...r,y:r.y-25}}};class Zo{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new _s(us(r)),this.windowListeners=new _s(_t(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,o=t.node.current;o&&Go(o),r(jt)}handleKeyDown(t){if(Di(t)){const{active:r,context:o,options:m}=this.props,{keyboardCodes:p=Qo,coordinateGetter:v=Yd,scrollBehavior:i="smooth"}=m,{code:n}=t;if(p.end.includes(n)){this.handleEnd(t);return}if(p.cancel.includes(n)){this.handleCancel(t);return}const{collisionRect:c}=o.current,f=c?{x:c.left,y:c.top}:jt;this.referenceCoordinates||(this.referenceCoordinates=f);const l=v(t,{active:r,context:o.current,currentCoordinates:f});if(l){const g=sr(l,f),b={x:0,y:0},{scrollableAncestors:y}=o.current;for(const _ of y){const a=t.code,{isTop:h,isRight:d,isLeft:u,isBottom:x,maxScroll:S,minScroll:k}=Vo(_),E=$d(_),w={x:Math.min(a===ze.Right?E.right-E.width/2:E.right,Math.max(a===ze.Right?E.left:E.left+E.width/2,l.x)),y:Math.min(a===ze.Down?E.bottom-E.height/2:E.bottom,Math.max(a===ze.Down?E.top:E.top+E.height/2,l.y))},j=a===ze.Right&&!d||a===ze.Left&&!u,T=a===ze.Down&&!x||a===ze.Up&&!h;if(j&&w.x!==l.x){const L=_.scrollLeft+g.x,N=a===ze.Right&&L<=S.x||a===ze.Left&&L>=k.x;if(N&&!g.y){_.scrollTo({left:L,behavior:i});return}N?b.x=_.scrollLeft-L:b.x=a===ze.Right?_.scrollLeft-S.x:_.scrollLeft-k.x,b.x&&_.scrollBy({left:-b.x,behavior:i});break}else if(T&&w.y!==l.y){const L=_.scrollTop+g.y,N=a===ze.Down&&L<=S.y||a===ze.Up&&L>=k.y;if(N&&!g.x){_.scrollTo({top:L,behavior:i});return}N?b.y=_.scrollTop-L:b.y=a===ze.Down?_.scrollTop-S.y:_.scrollTop-k.y,b.y&&_.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(t,rs(sr(l,this.referenceCoordinates),b))}}}handleMove(t,r){const{onMove:o}=this.props;t.preventDefault(),o(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Zo.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:o=Qo,onActivation:m}=t,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const i=p.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function yn(e){return!!(e&&"distance"in e)}function Sn(e){return!!(e&&"delay"in e)}class Oi{constructor(t,r,o){var m;o===void 0&&(o=Xd(t.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=t,this.events=r;const{event:p}=t,{target:v}=p;this.props=t,this.events=r,this.document=us(v),this.documentListeners=new _s(this.document),this.listeners=new _s(o),this.windowListeners=new _s(_t(v)),this.initialCoordinates=(m=rr(p))!=null?m:jt,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:t,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(wt.Resize,this.handleCancel),this.windowListeners.add(wt.DragStart,bn),this.windowListeners.add(wt.VisibilityChange,this.handleCancel),this.windowListeners.add(wt.ContextMenu,bn),this.documentListeners.add(wt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Sn(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(yn(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(t,r){const{active:o,onPending:m}=this.props;m(o,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(wt.Click,Vd,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wt.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:o,initialCoordinates:m,props:p}=this,{onMove:v,options:{activationConstraint:i}}=p;if(!m)return;const n=(r=rr(t))!=null?r:jt,c=sr(m,n);if(!o&&i){if(yn(i)){if(i.tolerance!=null&&Pr(c,i.tolerance))return this.handleCancel();if(Pr(c,i.distance))return this.handleStart()}if(Sn(i)&&Pr(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),v(n)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===ze.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Gd={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ii extends Oi{constructor(t){const{event:r}=t,o=us(r.target);super(t,Gd,o)}}Ii.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Qd={move:{name:"mousemove"},end:{name:"mouseup"}};var si;(function(e){e[e.RightClick=2]="RightClick"})(si||(si={}));class Zd extends Oi{constructor(t){super(t,Qd,us(t.event.target))}}Zd.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;return r.button===si.RightClick?!1:(o?.({event:r}),!0)}}];const Or={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Jd extends Oi{constructor(t){super(t,Or)}static setup(){return window.addEventListener(Or.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Or.move.name,t)};function t(){}}}Jd.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:o}=t;const{touches:m}=r;return m.length>1?!1:(o?.({event:r}),!0)}}];var xs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(xs||(xs={}));var nr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(nr||(nr={}));function eu(e){let{acceleration:t,activator:r=xs.Pointer,canScroll:o,draggingRect:m,enabled:p,interval:v=5,order:i=nr.TreeOrder,pointerCoordinates:n,scrollableAncestors:c,scrollableAncestorRects:f,delta:l,threshold:g}=e;const b=su({delta:l,disabled:!p}),[y,_]=fd(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case xs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case xs.DraggableRect:return m}},[r,m,n]),u=C.useRef(null),x=C.useCallback(()=>{const k=u.current;if(!k)return;const E=a.current.x*h.current.x,w=a.current.y*h.current.y;k.scrollBy(E,w)},[]),S=C.useMemo(()=>i===nr.TreeOrder?[...c].reverse():c,[i,c]);C.useEffect(()=>{if(!p||!c.length||!d){_();return}for(const k of S){if(o?.(k)===!1)continue;const E=c.indexOf(k),w=f[E];if(!w)continue;const{direction:j,speed:T}=Wd(k,w,d,t,g);for(const L of["x","y"])b[L][j[L]]||(T[L]=0,j[L]=0);if(T.x>0||T.y>0){_(),u.current=k,y(x,v),a.current=T,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},_()},[t,x,o,_,p,v,JSON.stringify(d),JSON.stringify(b),y,c,S,f,JSON.stringify(g)])}const tu={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function su(e){let{delta:t,disabled:r}=e;const o=tr(t);return Ls(m=>{if(r||!o||!m)return tu;const p={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[ut.Backward]:m.x[ut.Backward]||p.x===-1,[ut.Forward]:m.x[ut.Forward]||p.x===1},y:{[ut.Backward]:m.y[ut.Backward]||p.y===-1,[ut.Forward]:m.y[ut.Forward]||p.y===1}}},[r,t,o])}function ru(e,t){const r=t!=null?e.get(t):void 0,o=r?r.node.current:null;return Ls(m=>{var p;return t==null?null:(p=o??m)!=null?p:null},[o,t])}function iu(e,t){return C.useMemo(()=>e.reduce((r,o)=>{const{sensor:m}=o,p=m.activators.map(v=>({eventName:v.eventName,handler:t(v.handler,o)}));return[...r,...p]},[]),[e,t])}var Ns;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ns||(Ns={}));var ri;(function(e){e.Optimized="optimized"})(ri||(ri={}));const wn=new Map;function nu(e,t){let{dragging:r,dependencies:o,config:m}=t;const[p,v]=C.useState(null),{frequency:i,measure:n,strategy:c}=m,f=C.useRef(e),l=a(),g=Es(l),b=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(u=>!d.includes(u))))},[g]),y=C.useRef(null),_=Ls(h=>{if(l&&!r)return wn;if(!h||h===wn||f.current!==e||p!=null){const d=new Map;for(let u of e){if(!u)continue;if(p&&p.length>0&&!p.includes(u.id)&&u.rect.current){d.set(u.id,u.rect.current);continue}const x=u.node.current,S=x?new Pi(n(x),x):null;u.rect.current=S,S&&d.set(u.id,S)}return d}return h},[e,p,r,l,n]);return C.useEffect(()=>{f.current=e},[e]),C.useEffect(()=>{l||b()},[r,l]),C.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),C.useEffect(()=>{l||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{b(),y.current=null},i))},[i,l,b,...o]),{droppableRects:_,measureDroppableContainers:b,measuringScheduled:p!=null};function a(){switch(c){case Ns.Always:return!1;case Ns.BeforeDragging:return r;default:return!r}}}function Bi(e,t){return Ls(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function ou(e,t){return Bi(e,t)}function au(e){let{callback:t,disabled:r}=e;const o=mr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function gr(e){let{callback:t,disabled:r}=e;const o=mr(t),m=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return C.useEffect(()=>()=>m?.disconnect(),[m]),m}function lu(e){return new Pi(Ps(e),e)}function Cn(e,t,r){t===void 0&&(t=lu);const[o,m]=C.useState(null);function p(){m(n=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=n??r)!=null?c:null}const f=t(e);return JSON.stringify(n)===JSON.stringify(f)?n:f})}const v=au({callback(n){if(e)for(const c of n){const{type:f,target:l}=c;if(f==="childList"&&l instanceof HTMLElement&&l.contains(e)){p();break}}}}),i=gr({callback:p});return Dt(()=>{p(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),o}function cu(e){const t=Bi(e);return Wo(e,t)}const kn=[];function du(e){const t=C.useRef(e),r=Ls(o=>e?o&&o!==kn&&e&&t.current&&e.parentNode===t.current.parentNode?o:Li(e):kn,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function uu(e){const[t,r]=C.useState(null),o=C.useRef(e),m=C.useCallback(p=>{const v=Lr(p.target);v&&r(i=>i?(i.set(v,ti(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const p=o.current;if(e!==p){v(p);const i=e.map(n=>{const c=Lr(n);return c?(c.addEventListener("scroll",m,{passive:!0}),[c,ti(c)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{v(e),v(p)};function v(i){i.forEach(n=>{const c=Lr(n);c?.removeEventListener("scroll",m)})}},[m,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((p,v)=>rs(p,v),jt):Yo(e):jt,[e,t])}function En(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const o=e!==jt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?sr(e,r.current):jt}function hu(e){C.useEffect(()=>{if(!fr)return;const t=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function fu(e,t){return C.useMemo(()=>e.reduce((r,o)=>{let{eventName:m,handler:p}=o;return r[m]=v=>{p(v,t)},r},{}),[e,t])}function Jo(e){return C.useMemo(()=>e?Bd(e):null,[e])}const jn=[];function mu(e,t){t===void 0&&(t=Ps);const[r]=e,o=Jo(r?_t(r):null),[m,p]=C.useState(jn);function v(){p(()=>e.length?e.map(n=>Xo(n)?o:new Pi(t(n),n)):jn)}const i=gr({callback:v});return Dt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),m}function ea(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ds(t)?t:e}function pu(e){let{measure:t}=e;const[r,o]=C.useState(null),m=C.useCallback(c=>{for(const{target:f}of c)if(Ds(f)){o(l=>{const g=t(f);return l?{...l,width:g.width,height:g.height}:g});break}},[t]),p=gr({callback:m}),v=C.useCallback(c=>{const f=ea(c);p?.disconnect(),f&&p?.observe(f),o(f?t(f):null)},[t,p]),[i,n]=er(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const gu=[{sensor:Ii,options:{}},{sensor:Zo,options:{}}],vu={current:{}},Vs={draggable:{measure:xn},droppable:{measure:xn,strategy:Ns.WhileDragging,frequency:ri.Optimized},dragOverlay:{measure:Ps}};class bs extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,o;return(r=(o=this.get(t))==null?void 0:o.node.current)!=null?r:void 0}}const _u={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new bs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ir},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Vs,measureDroppableContainers:ir,windowRect:null,measuringScheduled:!1},ta={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ir,draggableNodes:new Map,over:null,measureDroppableContainers:ir},Os=C.createContext(ta),sa=C.createContext(_u);function xu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new bs}}}function bu(e,t){switch(t.type){case lt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case lt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case lt.DragEnd:case lt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case lt.RegisterDroppable:{const{element:r}=t,{id:o}=r,m=new bs(e.droppable.containers);return m.set(o,r),{...e,droppable:{...e.droppable,containers:m}}}case lt.SetDroppableDisabled:{const{id:r,key:o,disabled:m}=t,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new bs(e.droppable.containers);return v.set(r,{...p,disabled:m}),{...e,droppable:{...e.droppable,containers:v}}}case lt.UnregisterDroppable:{const{id:r,key:o}=t,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const p=new bs(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function yu(e){let{disabled:t}=e;const{active:r,activatorEvent:o,draggableNodes:m}=C.useContext(Os),p=tr(o),v=tr(r?.id);return C.useEffect(()=>{if(!t&&!o&&p&&v!=null){if(!Di(p)||document.activeElement===p.target)return;const i=m.get(v);if(!i)return;const{activatorNode:n,node:c}=i;if(!n.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[n.current,c.current]){if(!f)continue;const l=gd(f);if(l){l.focus();break}}})}},[o,t,m,v,p]),null}function ra(e,t){let{transform:r,...o}=t;return e!=null&&e.length?e.reduce((m,p)=>p({transform:m,...o}),r):r}function Su(e){return C.useMemo(()=>({draggable:{...Vs.draggable,...e?.draggable},droppable:{...Vs.droppable,...e?.droppable},dragOverlay:{...Vs.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function wu(e){let{activeNode:t,measure:r,initialRect:o,config:m=!0}=e;const p=C.useRef(!1),{x:v,y:i}=typeof m=="boolean"?{x:m,y:m}:m;Dt(()=>{if(!v&&!i||!t){p.current=!1;return}if(p.current||!o)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=r(c),l=Wo(f,o);if(v||(l.x=0),i||(l.y=0),p.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=Uo(c);g&&g.scrollBy({top:l.y,left:l.x})}},[t,v,i,o,r])}const vr=C.createContext({...jt,scaleX:1,scaleY:1});var Ot;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ot||(Ot={}));const Cu=C.memo(function(t){var r,o,m,p;let{id:v,accessibility:i,autoScroll:n=!0,children:c,sensors:f=gu,collisionDetection:l=Md,measuring:g,modifiers:b,...y}=t;const _=C.useReducer(bu,void 0,xu),[a,h]=_,[d,u]=Sd(),[x,S]=C.useState(Ot.Uninitialized),k=x===Ot.Initialized,{draggable:{active:E,nodes:w,translate:j},droppable:{containers:T}}=a,L=E!=null?w.get(E):null,N=C.useRef({initial:null,translated:null}),R=C.useMemo(()=>{var Me;return E!=null?{id:E,data:(Me=L?.data)!=null?Me:vu,rect:N}:null},[E,L]),D=C.useRef(null),[I,F]=C.useState(null),[z,A]=C.useState(null),P=Es(y,Object.values(y)),O=pr("DndDescribedBy",v),B=C.useMemo(()=>T.getEnabled(),[T]),W=Su(g),{droppableRects:V,measureDroppableContainers:Q,measuringScheduled:Z}=nu(B,{dragging:k,dependencies:[j.x,j.y],config:W.droppable}),he=ru(w,E),M=C.useMemo(()=>z?rr(z):null,[z]),H=ct(),U=ou(he,W.draggable.measure);wu({activeNode:E!=null?w.get(E):null,config:H.layoutShiftCompensation,initialRect:U,measure:W.draggable.measure});const $=Cn(he,W.draggable.measure,U),se=Cn(he?he.parentElement:null),K=C.useRef({activatorEvent:null,active:null,activeNode:he,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ce=T.getNodeFor((r=K.current.over)==null?void 0:r.id),pe=pu({measure:W.dragOverlay.measure}),xe=(o=pe.nodeRef.current)!=null?o:he,De=k?(m=pe.rect)!=null?m:$:null,ne=!!(pe.nodeRef.current&&pe.rect),_e=cu(ne?null:$),He=Jo(xe?_t(xe):null),we=du(k?ce??he:null),Le=mu(we),ke=ra(b,{transform:{x:j.x-_e.x,y:j.y-_e.y,scaleX:1,scaleY:1},activatorEvent:z,active:R,activeNodeRect:$,containerNodeRect:se,draggingNodeRect:De,over:K.current.over,overlayNodeRect:pe.rect,scrollableAncestors:we,scrollableAncestorRects:Le,windowRect:He}),Ee=M?rs(M,j):null,Ue=uu(we),be=En(Ue),Je=En(Ue,[$]),Ce=rs(ke,be),Ne=De?Pd(De,ke):null,tt=R&&Ne?l({active:R,collisionRect:Ne,droppableRects:V,droppableContainers:B,pointerCoordinates:Ee}):null,X=Rd(tt,"id"),[J,ee]=C.useState(null),fe=ne?ke:rs(ke,Je),qe=Dd(fe,(p=J?.rect)!=null?p:null,$),Ae=C.useRef(null),Ve=C.useCallback((Me,Pe)=>{let{sensor:et,options:ft}=Pe;if(D.current==null)return;const ot=w.get(D.current);if(!ot)return;const st=Me.nativeEvent,Oe=new et({active:D.current,activeNode:ot,event:st,options:ft,context:K,onAbort(Ye){if(!w.get(Ye))return;const{onDragAbort:rt}=P.current,Y={id:Ye};rt?.(Y),d({type:"onDragAbort",event:Y})},onPending(Ye,mt,rt,Y){if(!w.get(Ye))return;const{onDragPending:je}=P.current,q={id:Ye,constraint:mt,initialCoordinates:rt,offset:Y};je?.(q),d({type:"onDragPending",event:q})},onStart(Ye){const mt=D.current;if(mt==null)return;const rt=w.get(mt);if(!rt)return;const{onDragStart:Y}=P.current,le={activatorEvent:st,active:{id:mt,data:rt.data,rect:N}};qt.unstable_batchedUpdates(()=>{Y?.(le),S(Ot.Initializing),h({type:lt.DragStart,initialCoordinates:Ye,active:mt}),d({type:"onDragStart",event:le}),F(Ae.current),A(st)})},onMove(Ye){h({type:lt.DragMove,coordinates:Ye})},onEnd:xt(lt.DragEnd),onCancel:xt(lt.DragCancel)});Ae.current=Oe;function xt(Ye){return async function(){const{active:rt,collisions:Y,over:le,scrollAdjustedTranslate:je}=K.current;let q=null;if(rt&&je){const{cancelDrop:re}=P.current;q={activatorEvent:st,active:rt,collisions:Y,delta:je,over:le},Ye===lt.DragEnd&&typeof re=="function"&&await Promise.resolve(re(q))&&(Ye=lt.DragCancel)}D.current=null,qt.unstable_batchedUpdates(()=>{h({type:Ye}),S(Ot.Uninitialized),ee(null),F(null),A(null),Ae.current=null;const re=Ye===lt.DragEnd?"onDragEnd":"onDragCancel";if(q){const me=P.current[re];me?.(q),d({type:re,event:q})}})}}},[w]),nt=C.useCallback((Me,Pe)=>(et,ft)=>{const ot=et.nativeEvent,st=w.get(ft);if(D.current!==null||!st||ot.dndKit||ot.defaultPrevented)return;const Oe={active:st};Me(et,Pe.options,Oe)===!0&&(ot.dndKit={capturedBy:Pe.sensor},D.current=ft,Ve(et,Pe))},[w,Ve]),Fe=iu(f,nt);hu(f),Dt(()=>{$&&x===Ot.Initializing&&S(Ot.Initialized)},[$,x]),C.useEffect(()=>{const{onDragMove:Me}=P.current,{active:Pe,activatorEvent:et,collisions:ft,over:ot}=K.current;if(!Pe||!et)return;const st={active:Pe,activatorEvent:et,collisions:ft,delta:{x:Ce.x,y:Ce.y},over:ot};qt.unstable_batchedUpdates(()=>{Me?.(st),d({type:"onDragMove",event:st})})},[Ce.x,Ce.y]),C.useEffect(()=>{const{active:Me,activatorEvent:Pe,collisions:et,droppableContainers:ft,scrollAdjustedTranslate:ot}=K.current;if(!Me||D.current==null||!Pe||!ot)return;const{onDragOver:st}=P.current,Oe=ft.get(X),xt=Oe&&Oe.rect.current?{id:Oe.id,rect:Oe.rect.current,data:Oe.data,disabled:Oe.disabled}:null,Ye={active:Me,activatorEvent:Pe,collisions:et,delta:{x:ot.x,y:ot.y},over:xt};qt.unstable_batchedUpdates(()=>{ee(xt),st?.(Ye),d({type:"onDragOver",event:Ye})})},[X]),Dt(()=>{K.current={activatorEvent:z,active:R,activeNode:he,collisionRect:Ne,collisions:tt,droppableRects:V,draggableNodes:w,draggingNode:xe,draggingNodeRect:De,droppableContainers:T,over:J,scrollableAncestors:we,scrollAdjustedTranslate:Ce},N.current={initial:De,translated:Ne}},[R,he,tt,Ne,w,xe,De,V,T,J,we,Ce]),eu({...H,delta:j,draggingRect:Ne,pointerCoordinates:Ee,scrollableAncestors:we,scrollableAncestorRects:Le});const yt=C.useMemo(()=>({active:R,activeNode:he,activeNodeRect:$,activatorEvent:z,collisions:tt,containerNodeRect:se,dragOverlay:pe,draggableNodes:w,droppableContainers:T,droppableRects:V,over:J,measureDroppableContainers:Q,scrollableAncestors:we,scrollableAncestorRects:Le,measuringConfiguration:W,measuringScheduled:Z,windowRect:He}),[R,he,$,z,tt,se,pe,w,T,V,J,Q,we,Le,W,Z,He]),Qe=C.useMemo(()=>({activatorEvent:z,activators:Fe,active:R,activeNodeRect:$,ariaDescribedById:{draggable:O},dispatch:h,draggableNodes:w,over:J,measureDroppableContainers:Q}),[z,Fe,R,$,h,O,w,J,Q]);return ie.createElement(Ho.Provider,{value:u},ie.createElement(Os.Provider,{value:Qe},ie.createElement(sa.Provider,{value:yt},ie.createElement(vr.Provider,{value:qe},c)),ie.createElement(yu,{disabled:i?.restoreFocus===!1})),ie.createElement(kd,{...i,hiddenTextDescribedById:O}));function ct(){const Me=I?.autoScrollEnabled===!1,Pe=typeof n=="object"?n.enabled===!1:n===!1,et=k&&!Me&&!Pe;return typeof n=="object"?{...n,enabled:et}:{enabled:et}}}),ku=C.createContext(null),Nn="button",Eu="Draggable";function ju(e){let{id:t,data:r,disabled:o=!1,attributes:m}=e;const p=pr(Eu),{activators:v,activatorEvent:i,active:n,activeNodeRect:c,ariaDescribedById:f,draggableNodes:l,over:g}=C.useContext(Os),{role:b=Nn,roleDescription:y="draggable",tabIndex:_=0}=m??{},a=n?.id===t,h=C.useContext(a?vr:ku),[d,u]=er(),[x,S]=er(),k=fu(v,t),E=Es(r);Dt(()=>(l.set(t,{id:t,key:p,node:d,activatorNode:x,data:E}),()=>{const j=l.get(t);j&&j.key===p&&l.delete(t)}),[l,t]);const w=C.useMemo(()=>({role:b,tabIndex:_,"aria-disabled":o,"aria-pressed":a&&b===Nn?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[o,b,_,a,y,f.draggable]);return{active:n,activatorEvent:i,activeNodeRect:c,attributes:w,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:u,setActivatorNodeRef:S,transform:h}}function Nu(){return C.useContext(sa)}const Au="Droppable",Ru={timeout:25};function Tu(e){let{data:t,disabled:r=!1,id:o,resizeObserverConfig:m}=e;const p=pr(Au),{active:v,dispatch:i,over:n,measureDroppableContainers:c}=C.useContext(Os),f=C.useRef({disabled:r}),l=C.useRef(!1),g=C.useRef(null),b=C.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:a}={...Ru,...m},h=Es(_??o),d=C.useCallback(()=>{if(!l.current){l.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),b.current=null},a)},[a]),u=gr({callback:d,disabled:y||!v}),x=C.useCallback((w,j)=>{u&&(j&&(u.unobserve(j),l.current=!1),w&&u.observe(w))},[u]),[S,k]=er(x),E=Es(t);return C.useEffect(()=>{!u||!S.current||(u.disconnect(),l.current=!1,u.observe(S.current))},[S,u]),C.useEffect(()=>(i({type:lt.RegisterDroppable,element:{id:o,key:p,disabled:r,node:S,rect:g,data:E}}),()=>i({type:lt.UnregisterDroppable,key:p,id:o})),[o]),C.useEffect(()=>{r!==f.current.disabled&&(i({type:lt.SetDroppableDisabled,id:o,key:p,disabled:r}),f.current.disabled=r)},[o,p,r,i]),{active:v,rect:g,isOver:n?.id===o,node:S,over:n,setNodeRef:k}}function Mu(e){let{animation:t,children:r}=e;const[o,m]=C.useState(null),[p,v]=C.useState(null),i=tr(r);return!r&&!o&&i&&m(i),Dt(()=>{if(!p)return;const n=o?.key,c=o?.props.id;if(n==null||c==null){m(null);return}Promise.resolve(t(c,p)).then(()=>{m(null)})},[t,o,p]),ie.createElement(ie.Fragment,null,r,o?C.cloneElement(o,{ref:v}):null)}const Du={x:0,y:0,scaleX:1,scaleY:1};function Lu(e){let{children:t}=e;return ie.createElement(Os.Provider,{value:ta},ie.createElement(vr.Provider,{value:Du},t))}const Pu={position:"fixed",touchAction:"none"},Ou=e=>Di(e)?"transform 250ms ease":void 0,Iu=C.forwardRef((e,t)=>{let{as:r,activatorEvent:o,adjustScale:m,children:p,className:v,rect:i,style:n,transform:c,transition:f=Ou}=e;if(!i)return null;const l=m?c:{...c,scaleX:1,scaleY:1},g={...Pu,width:i.width,height:i.height,top:i.top,left:i.left,transform:js.Transform.toString(l),transformOrigin:m&&o?Nd(o,i):void 0,transition:typeof f=="function"?f(o):f,...n};return ie.createElement(r,{className:v,style:g,ref:t},p)}),Bu=e=>t=>{let{active:r,dragOverlay:o}=t;const m={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[i,n]of Object.entries(p.active))n!==void 0&&(m[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(p!=null&&p.dragOverlay)for(const[i,n]of Object.entries(p.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[n,c]of Object.entries(m))r.node.style.setProperty(n,c);v!=null&&v.active&&r.node.classList.remove(v.active)}},Fu=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:js.Transform.toString(t)},{transform:js.Transform.toString(r)}]},zu={duration:250,easing:"ease",keyframes:Fu,sideEffects:Bu({styles:{active:{opacity:"0"}}})};function Hu(e){let{config:t,draggableNodes:r,droppableContainers:o,measuringConfiguration:m}=e;return mr((p,v)=>{if(t===null)return;const i=r.get(p);if(!i)return;const n=i.node.current;if(!n)return;const c=ea(v);if(!c)return;const{transform:f}=_t(v).getComputedStyle(v),l=$o(f);if(!l)return;const g=typeof t=="function"?t:Wu(t);return Go(n,m.draggable.measure),g({active:{id:p,data:i.data,node:n,rect:m.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:v,rect:m.dragOverlay.measure(c)},droppableContainers:o,measuringConfiguration:m,transform:l})})}function Wu(e){const{duration:t,easing:r,sideEffects:o,keyframes:m}={...zu,...e};return p=>{let{active:v,dragOverlay:i,transform:n,...c}=p;if(!t)return;const f={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},l={scaleX:n.scaleX!==1?v.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?v.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-f.x,y:n.y-f.y,...l},b=m({...c,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=b,_=b[b.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const a=o?.({active:v,dragOverlay:i,...c}),h=i.node.animate(b,{duration:t,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let An=0;function $u(e){return C.useMemo(()=>{if(e!=null)return An++,An},[e])}const Uu=ie.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:o,style:m,transition:p,modifiers:v,wrapperElement:i="div",className:n,zIndex:c=999}=e;const{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:b,draggableNodes:y,droppableContainers:_,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:u,scrollableAncestorRects:x,windowRect:S}=Nu(),k=C.useContext(vr),E=$u(l?.id),w=ra(v,{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:b,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:u,scrollableAncestorRects:x,transform:k,windowRect:S}),j=Bi(g),T=Hu({config:o,draggableNodes:y,droppableContainers:_,measuringConfiguration:d}),L=j?a.setRef:void 0;return ie.createElement(Lu,null,ie.createElement(Mu,{animation:T},l&&E?ie.createElement(Iu,{key:E,id:l.id,ref:L,as:i,activatorEvent:f,adjustScale:t,className:n,transition:p,rect:j,style:{zIndex:c,...m},transform:w},r):null))}),ia=768;function qu(e){const t=window.matchMedia(`(max-width: ${ia-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Ku(){return window.innerWidth<ia}function Xu(){return!1}function na(){return C.useSyncExternalStore(qu,Ku,Xu)}const ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Vu=[{status:ve.Review,label:"Review",icon:hi,color:"text-amber-600"},{status:ve.Running,label:"Running",icon:fi,color:"text-blue-600"},{status:ve.Pending,label:"Pending",icon:mi,color:"text-neutral-600"},{status:ve.Done,label:"Done",icon:pi,color:"text-emerald-600"},{status:ve.Cancelled,label:"Cancelled",icon:gi,color:"text-neutral-500"}];function Yu({task:e,status:t,isSelected:r,isAgentActive:o,project:m,onSelectTask:p,onTaskStatusChange:v,onDeleteTask:i,disableDrag:n}){const{t:c}=ae(),f=!!e.projectArchivedAt,l=f||!!n,{attributes:g,listeners:b,setNodeRef:y,isDragging:_}=ju({id:e.id,data:{task:e,fromStatus:t},disabled:l}),[a,h]=C.useState(null),d=C.useRef(null),u=C.useRef(null),x=C.useCallback(E=>{f||!v&&!i||(E.preventDefault(),h({x:E.clientX,y:E.clientY}))},[f,v,i]),S=C.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),k=C.useCallback(E=>{if(!n||f||!v&&!i)return;const w=E.touches[0];if(!w)return;const{clientX:j,clientY:T}=w;u.current=setTimeout(()=>{u.current=null,h({x:j,y:T})},500)},[n,f,v,i]);return C.useEffect(()=>{if(!a)return;const E=w=>{d.current&&!d.current.contains(w.target)&&h(null)};return document.addEventListener("mousedown",E),document.addEventListener("touchstart",E),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("touchstart",E)}},[a]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:y,onClick:()=>p(e.id),onContextMenu:x,onTouchStart:k,onTouchEnd:S,onTouchMove:S,className:`flex items-start pl-7 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
|
|
7
7
|
${_?"opacity-30":""}
|
|
8
|
-
${r?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l?{}:
|
|
9
|
-
${S?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:s.jsx("span",{className:"text-xs font-medium",children:S?y("Drop into {title}",{title:
|
|
8
|
+
${r?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l?{}:b,...l?{}:g,children:[s.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ve.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ve.Review&&s.jsx(hi,{className:r?"text-amber-600":"text-neutral-500"}),t===ve.Running&&s.jsx(fi,{className:"animate-pulse"}),t===ve.Pending&&s.jsx(mi,{}),t===ve.Done&&s.jsx(pi,{className:"text-neutral-400"}),t===ve.Cancelled&&s.jsx(gi,{className:"text-neutral-400"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center",children:[s.jsx("span",{className:`mr-1 max-w-[45%] shrink-0 truncate font-medium ${m?.color||"text-neutral-500"}`,title:m?.name,children:m?.name}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:"/"}),s.jsx("span",{className:`ml-1 min-w-0 flex-1 truncate ${r?"text-neutral-900":"text-neutral-700"}`,title:e.title,children:e.title}),e.projectArchivedAt&&s.jsx("span",{className:"ml-1.5 inline-flex shrink-0 items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),o&&s.jsxs("span",{className:"relative ml-1.5 inline-flex h-2 w-2 shrink-0 align-middle",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),s.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${r?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),a&&s.jsxs("div",{ref:d,className:"fixed z-[100] w-44 bg-white rounded-lg border border-neutral-200 shadow-xl py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:a.x,top:a.y},children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:c("Move to")}),Vu.filter(E=>E.status!==t).map(E=>{const w=E.icon;return s.jsxs("button",{onClick:()=>{v(e.id,E.status),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[s.jsx(w,{className:`w-3.5 h-3.5 ${E.color}`}),s.jsx("span",{className:"text-neutral-700",children:c(E.label)})]},E.status)})]}),i&&s.jsxs(s.Fragment,{children:[v&&s.jsx("div",{className:"my-1 border-t border-neutral-100"}),s.jsxs("button",{onClick:()=>{i(e.id),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors",children:[s.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:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),s.jsx("span",{children:c("Delete Task")})]})]})]})]})}const Gu=C.memo(function({title:t,tasks:r,status:o,defaultOpen:m,selectedTaskId:p,onSelectTask:v,projects:i,activeTaskIds:n,isDragging:c,dragFromStatus:f,onTaskStatusChange:l,onDeleteTask:g,disableDrag:b}){const{t:y}=ae(),[_,a]=C.useState(m),h=r.length===0,d=c&&f===o,u=c&&f!==o,{setNodeRef:x,isOver:S}=Tu({id:`group-${o}`,data:{status:o}}),k=o===ve.Review,E=y(t),w=c?d&&(_||!0):_;return s.jsxs("div",{className:"mb-2",children:[s.jsxs("button",{onClick:()=>!c&&a(j=>!j),className:"flex items-center w-full px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx("span",{className:"mr-2 text-neutral-400",children:w?s.jsx(vt,{size:14}):s.jsx(Tt,{size:14})}),s.jsx("span",{className:"flex-1 text-left",children:E}),k&&!h?s.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:r.length}):s.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",r.length,")"]})]}),u&&s.jsx("div",{ref:x,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
+
${S?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:s.jsx("span",{className:"text-xs font-medium",children:S?y("Drop into {title}",{title:E}):y("Drop here")})}),w&&!u&&s.jsx("div",{ref:d?void 0:x,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
|
|
10
10
|
${S&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
|
|
11
|
-
${h&&c?"border border-dashed border-neutral-300":""}`,children:h?s.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-7",children:y("No tasks")}):r.map(k=>{const N=i.find(M=>M.id===k.projectId),L=p===k.id,R=n?.has(k.id)??!1;return s.jsx(Qu,{task:k,status:o,isSelected:L,isAgentActive:R,project:N,onSelectTask:v,onTaskStatusChange:k.projectArchivedAt?void 0:l,onDeleteTask:k.projectArchivedAt?void 0:g,disableDrag:x},k.id)})})]})});function Ju(e){const t={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)t[r.status].push(r);return t}const eh=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function Rn({tasks:e=[],projects:t=[],selectedTaskId:r,onSelectTask:o,filterProjectId:m,setFilterProjectId:p,width:v=320,onCreateProject:i,onCreateTask:n,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:l}){const{t:g}=ae(),x=na(),[y,_]=C.useState(!1),[a,h]=C.useState(null),[d,u]=C.useState(null),b=Ad(Nd(Bi,{activationConstraint:{distance:8}})),S=C.useCallback(D=>{const I=D.active.data.current?.task,F=D.active.data.current?.fromStatus;I&&h(I),F&&u(F)},[]),E=C.useCallback(D=>{h(null),u(null);const{active:I,over:F}=D;if(!F)return;const z=I.data.current?.task,A=I.data.current?.fromStatus,P=F.data.current?.status;!z||!A||!P||z.projectArchivedAt||A!==P&&f?.(z.id,P)},[f]),j=m?e.filter(D=>D.projectId===m):e,w=m?t.find(D=>D.id===m)??null:null,k=t.filter(D=>!D.archivedAt),L=!!!w?.archivedAt,R=Ju(j),M=v==="100%";return s.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${M?"":"border-r border-neutral-200"}`,style:{width:v},children:[s.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[s.jsxs("div",{className:"relative flex-1 mr-2",children:[s.jsxs("button",{onClick:()=>_(D=>!D),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),s.jsx("span",{className:"truncate",children:w.name})]}):s.jsxs(s.Fragment,{children:[s.jsx(ds,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),s.jsx("span",{children:g("All Projects")})]}),s.jsx(bt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${y?"rotate-180":""}`})]}),y?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>_(!1)}),s.jsxs("div",{className:"absolute left-0 top-full mt-1 w-56 bg-white border border-neutral-200 rounded-lg shadow-xl shadow-neutral-200/50 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[s.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:g("Select View")}),s.jsxs("button",{onClick:()=>{p(null),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded border border-neutral-200 bg-neutral-50 text-neutral-500 group-hover:border-neutral-300",children:s.jsx(ds,{size:12})}),s.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:g("All Projects")})]}),m===null?s.jsx(Tt,{size:14,className:"text-neutral-900"}):null]}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),k.map(D=>{const I=m===D.id,F=D.color.replace("text-","bg-");return s.jsxs("button",{onClick:()=>{p(D.id),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${F}`}),s.jsx("span",{className:I?"text-neutral-900 font-medium":"text-neutral-600",children:D.name})]}),I?s.jsx(Tt,{size:14,className:"text-neutral-900"}):null]},D.id)}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),s.jsxs("button",{onClick:()=>{_(!1),i?.()},className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx(as,{size:14}),s.jsx("span",{children:g("Create New Project...")})]})]})]}):null]}),s.jsx("button",{onClick:n,disabled:!L,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:g(L?"New Task":"Deleted projects are read-only"),children:s.jsx(as,{size:18})})]}),s.jsxs(Eu,{sensors:b,onDragStart:S,onDragEnd:E,children:[s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin py-4 relative",children:eh.map(({status:D,title:I,defaultOpen:F})=>s.jsx(Zu,{title:I,tasks:R[D],status:D,defaultOpen:F,selectedTaskId:r,onSelectTask:o,projects:t,activeTaskIds:c,isDragging:a!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:l,disableDrag:x},D))}),s.jsx(Ku,{dropAnimation:null,children:a?s.jsx("div",{className:"bg-white shadow-lg rounded-md border border-neutral-200 px-4 py-2 text-sm max-w-[280px] opacity-90",children:s.jsx("span",{className:"block truncate font-medium text-neutral-700",title:a.title,children:a.title})}):null})]}),j.length>0?s.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[s.jsx("span",{children:g("{count} tasks",{count:j.length})}),m?s.jsx("button",{onClick:()=>p(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:g("Clear filter")}):null]}):s.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:s.jsx("span",{children:g("{count} tasks",{count:0})})})]})}const th={damping:.7,stiffness:.05,mass:1.25},sh=70,rh=1e3/60,ih=350;let yr=!1;globalThis.document?.addEventListener("mousedown",()=>{yr=!0});globalThis.document?.addEventListener("mouseup",()=>{yr=!1});globalThis.document?.addEventListener("click",()=>{yr=!1});const zi=(e={})=>{const[t,r]=C.useState(!1),[o,m]=C.useState(e.initial!==!1),[p,v]=C.useState(!1),i=C.useRef(null);i.current=e;const n=C.useCallback(()=>{if(!yr)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const u=d.getRangeAt(0);return u.commonAncestorContainer.contains(a.current)||a.current?.contains(u.commonAncestorContainer)},[]),c=C.useCallback(d=>{l.isAtBottom=d,m(d)},[]),f=C.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=C.useMemo(()=>{let d;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(u){a.current&&(a.current.scrollTop=u,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:u}=this;if(!e.targetScrollTop)return u;if(d?.targetScrollTop===u)return d.calculatedScrollTop;const b=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:a.current,contentElement:h.current}),u),0);return d={targetScrollTop:u,calculatedScrollTop:b},requestAnimationFrame(()=>{d=void 0}),b},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=sh}}},[]),g=C.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const u=Date.now()+(Number(d.wait)||0),b=zr(i.current,d.animation),{ignoreEscapes:S=!1}=d;let E,j=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{E=Date.now()}):E=u+(d.duration??0);const w=async()=>{const k=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:N}=l,L=performance.now(),R=(L-(l.lastTick??L))/rh;if(l.animation||(l.animation={behavior:b,promise:k,ignoreEscapes:S}),l.animation.behavior===b&&(l.lastTick=L),n()||u>Date.now())return w();if(N<Math.min(j,l.calculatedTargetScrollTop)){if(l.animation?.behavior===b){if(b==="instant")return l.scrollTop=l.calculatedTargetScrollTop,w();l.velocity=(b.damping*l.velocity+b.stiffness*l.scrollDifference)/b.mass,l.accumulated+=l.velocity*R,l.scrollTop+=l.accumulated,l.scrollTop!==N&&(l.accumulated=0)}return w()}return E>Date.now()?(j=l.calculatedTargetScrollTop,w()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:zr(i.current,i.current.resize),ignoreEscapes:S,duration:Math.max(0,E-Date.now())||void 0}):l.isAtBottom)});return k.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:w()},[c,n,l]),x=C.useCallback(()=>{f(!0),c(!1)},[f,c]),y=C.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:u,ignoreScrollToTop:b}=l;let{lastScrollTop:S=u}=l;l.lastScrollTop=u,l.ignoreScrollToTop=void 0,b&&b>u&&(S=b),v(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||u===b)return;if(n()){f(!0),c(!1);return}const E=u>S,j=u<S;if(l.animation?.ignoreEscapes){l.scrollTop=S;return}j&&(f(!0),c(!1)),E&&f(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[f,c,n,l]),_=C.useCallback(({target:d,deltaY:u})=>{let b=d;for(;!["scroll","auto"].includes(getComputedStyle(b).overflow);){if(!b.parentElement)return;b=b.parentElement}b===a.current&&u<0&&a.current.scrollHeight>a.current.clientHeight&&!l.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,l]),a=Mn(d=>{a.current?.removeEventListener("scroll",y),a.current?.removeEventListener("wheel",_),d?.addEventListener("scroll",y,{passive:!0}),d?.addEventListener("wheel",_,{passive:!0})},[]),h=Mn(d=>{if(l.resizeObserver?.disconnect(),!d)return;let u;l.resizeObserver=new ResizeObserver(([b])=>{const{height:S}=b.contentRect,E=S-(u??S);if(l.resizeDifference=E,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),v(l.isNearBottom),E>=0){const j=zr(i.current,u?i.current.resize:i.current.initial);g({animation:j,wait:!0,preserveScrollPosition:!0,duration:j==="instant"?void 0:ih})}else l.isNearBottom&&(f(!1),c(!0));u=S,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===E&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:h,scrollRef:a,scrollToBottom:g,stopScroll:x,isAtBottom:o||p,isNearBottom:p,escapedFromLock:t,state:l}};function Mn(e,t){const r=C.useCallback(o=>(r.current=o,e(o)),t);return r}const Fr=new Map;function zr(...e){const t={...th};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,t.damping=m.damping??t.damping,t.stiffness=m.stiffness??t.stiffness,t.mass=m.mass??t.mass)}const o=JSON.stringify(t);return Fr.has(o)||Fr.set(o,Object.freeze(t)),r?"instant":Fr.get(o)}function nh({content:e,children:t,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 s.jsxs("div",{className:`group/tooltip relative ${r}`,children:[t,s.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,s.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function Us(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function oh(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Hi({usage:e,tooltipSide:t="top"}){const{t:r}=ae();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?oh(m):"text-neutral-400",i=o?s.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:Us(e.totalTokens),max:Us(o)})}):s.jsx("span",{children:r("已使用: {used} tokens",{used:Us(e.totalTokens)})});return s.jsx(nh,{content:i,side:t,children:s.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:[s.jsx(Pc,{size:14,className:v}),s.jsxs("span",{className:`tabular-nums ${v}`,children:[Us(e.totalTokens),p!==null&&s.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const ah="/api";async function lh(e){const t=new FormData;t.append("file",e);const r=await fetch(`${ah}/attachments/upload`,{method:"POST",body:t});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error||`Upload failed (${r.status})`)}return r.json()}let ch=0;function Sr(){const[e,t]=C.useState([]),r=C.useRef(e);r.current=e;const o=C.useCallback(async l=>{const g=l.map(x=>({tempId:`tmp-${++ch}`,file:x,progress:0,status:"uploading"}));t(x=>[...x,...g]),await Promise.allSettled(g.map(async x=>{try{const y=await lh(x.file);t(_=>_.map(a=>a.tempId===x.tempId?{...a,status:"done",progress:100,attachment:y}:a))}catch(y){t(_=>_.map(a=>a.tempId===x.tempId?{...a,status:"error",error:y instanceof Error?y.message:"Upload failed"}:a))}}))},[]),m=C.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),p=C.useCallback(l=>{t(g=>g.filter(x=>x.tempId!==l))},[]),v=C.useCallback(()=>{t([])},[]),i=C.useCallback(l=>{l.length!==0&&t(g=>{const x=new Set(g.map(_=>_.attachment?.id??_.tempId)),y=l.filter(_=>{const a=_.attachment?.id??_.tempId;return x.has(a)?!1:(x.add(a),!0)});return y.length>0?[...g,...y]:g})},[]),n=C.useCallback(()=>{const l=m();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
|
|
12
|
-
`)},[m]),c=e.length>0,f=e.some(l=>l.status==="uploading");return{files:e,addFiles:o,removeFile:p,clear:v,restoreFiles:i,buildMarkdownLinks:n,getDoneAttachments:m,hasFiles:c,isUploading:f}}function
|
|
11
|
+
${h&&c?"border border-dashed border-neutral-300":""}`,children:h?s.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-7",children:y("No tasks")}):r.map(j=>{const T=i.find(R=>R.id===j.projectId),L=p===j.id,N=n?.has(j.id)??!1;return s.jsx(Yu,{task:j,status:o,isSelected:L,isAgentActive:N,project:T,onSelectTask:v,onTaskStatusChange:j.projectArchivedAt?void 0:l,onDeleteTask:j.projectArchivedAt?void 0:g,disableDrag:b},j.id)})})]})});function Qu(e){const t={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)t[r.status].push(r);return t}const Zu=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function Rn({tasks:e=[],projects:t=[],selectedTaskId:r,onSelectTask:o,filterProjectId:m,setFilterProjectId:p,width:v=320,onCreateProject:i,onCreateTask:n,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:l}){const{t:g}=ae(),b=na(),[y,_]=C.useState(!1),[a,h]=C.useState(null),[d,u]=C.useState(null),x=jd(Ed(Ii,{activationConstraint:{distance:8}})),S=C.useCallback(D=>{const I=D.active.data.current?.task,F=D.active.data.current?.fromStatus;I&&h(I),F&&u(F)},[]),k=C.useCallback(D=>{h(null),u(null);const{active:I,over:F}=D;if(!F)return;const z=I.data.current?.task,A=I.data.current?.fromStatus,P=F.data.current?.status;!z||!A||!P||z.projectArchivedAt||A!==P&&f?.(z.id,P)},[f]),E=m?e.filter(D=>D.projectId===m):e,w=m?t.find(D=>D.id===m)??null:null,j=t.filter(D=>!D.archivedAt),L=!!!w?.archivedAt,N=Qu(E),R=v==="100%";return s.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${R?"":"border-r border-neutral-200"}`,style:{width:v},children:[s.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[s.jsxs("div",{className:"relative flex-1 mr-2",children:[s.jsxs("button",{onClick:()=>_(D=>!D),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[m&&w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),s.jsx("span",{className:"truncate",children:w.name})]}):s.jsxs(s.Fragment,{children:[s.jsx(cs,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),s.jsx("span",{children:g("All Projects")})]}),s.jsx(vt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${y?"rotate-180":""}`})]}),y?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>_(!1)}),s.jsxs("div",{className:"absolute left-0 top-full mt-1 w-56 bg-white border border-neutral-200 rounded-lg shadow-xl shadow-neutral-200/50 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[s.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:g("Select View")}),s.jsxs("button",{onClick:()=>{p(null),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded border border-neutral-200 bg-neutral-50 text-neutral-500 group-hover:border-neutral-300",children:s.jsx(cs,{size:12})}),s.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:g("All Projects")})]}),m===null?s.jsx(Rt,{size:14,className:"text-neutral-900"}):null]}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),j.map(D=>{const I=m===D.id,F=D.color.replace("text-","bg-");return s.jsxs("button",{onClick:()=>{p(D.id),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${F}`}),s.jsx("span",{className:I?"text-neutral-900 font-medium":"text-neutral-600",children:D.name})]}),I?s.jsx(Rt,{size:14,className:"text-neutral-900"}):null]},D.id)}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),s.jsxs("button",{onClick:()=>{_(!1),i?.()},className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx(os,{size:14}),s.jsx("span",{children:g("Create New Project...")})]})]})]}):null]}),s.jsx("button",{onClick:n,disabled:!L,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:g(L?"New Task":"Deleted projects are read-only"),children:s.jsx(os,{size:18})})]}),s.jsxs(Cu,{sensors:x,onDragStart:S,onDragEnd:k,children:[s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin py-4 relative",children:Zu.map(({status:D,title:I,defaultOpen:F})=>s.jsx(Gu,{title:I,tasks:N[D],status:D,defaultOpen:F,selectedTaskId:r,onSelectTask:o,projects:t,activeTaskIds:c,isDragging:a!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:l,disableDrag:b},D))}),s.jsx(Uu,{dropAnimation:null,children:a?s.jsx("div",{className:"bg-white shadow-lg rounded-md border border-neutral-200 px-4 py-2 text-sm max-w-[280px] opacity-90",children:s.jsx("span",{className:"block truncate font-medium text-neutral-700",title:a.title,children:a.title})}):null})]}),E.length>0?s.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[s.jsx("span",{children:g("{count} tasks",{count:E.length})}),m?s.jsx("button",{onClick:()=>p(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:g("Clear filter")}):null]}):s.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:s.jsx("span",{children:g("{count} tasks",{count:0})})})]})}const Ju={damping:.7,stiffness:.05,mass:1.25},eh=70,th=1e3/60,sh=350;let _r=!1;globalThis.document?.addEventListener("mousedown",()=>{_r=!0});globalThis.document?.addEventListener("mouseup",()=>{_r=!1});globalThis.document?.addEventListener("click",()=>{_r=!1});const Fi=(e={})=>{const[t,r]=C.useState(!1),[o,m]=C.useState(e.initial!==!1),[p,v]=C.useState(!1),i=C.useRef(null);i.current=e;const n=C.useCallback(()=>{if(!_r)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const u=d.getRangeAt(0);return u.commonAncestorContainer.contains(a.current)||a.current?.contains(u.commonAncestorContainer)},[]),c=C.useCallback(d=>{l.isAtBottom=d,m(d)},[]),f=C.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=C.useMemo(()=>{let d;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return a.current?.scrollTop??0},set scrollTop(u){a.current&&(a.current.scrollTop=u,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:u}=this;if(!e.targetScrollTop)return u;if(d?.targetScrollTop===u)return d.calculatedScrollTop;const x=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:a.current,contentElement:h.current}),u),0);return d={targetScrollTop:u,calculatedScrollTop:x},requestAnimationFrame(()=>{d=void 0}),x},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=eh}}},[]),g=C.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const u=Date.now()+(Number(d.wait)||0),x=Br(i.current,d.animation),{ignoreEscapes:S=!1}=d;let k,E=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=u+(d.duration??0);const w=async()=>{const j=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:T}=l,L=performance.now(),N=(L-(l.lastTick??L))/th;if(l.animation||(l.animation={behavior:x,promise:j,ignoreEscapes:S}),l.animation.behavior===x&&(l.lastTick=L),n()||u>Date.now())return w();if(T<Math.min(E,l.calculatedTargetScrollTop)){if(l.animation?.behavior===x){if(x==="instant")return l.scrollTop=l.calculatedTargetScrollTop,w();l.velocity=(x.damping*l.velocity+x.stiffness*l.scrollDifference)/x.mass,l.accumulated+=l.velocity*N,l.scrollTop+=l.accumulated,l.scrollTop!==T&&(l.accumulated=0)}return w()}return k>Date.now()?(E=l.calculatedTargetScrollTop,w()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:Br(i.current,i.current.resize),ignoreEscapes:S,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return j.then(T=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),T))};return d.wait!==!0&&(l.animation=void 0),l.animation?.behavior===x?l.animation.promise:w()},[c,n,l]),b=C.useCallback(()=>{f(!0),c(!1)},[f,c]),y=C.useCallback(({target:d})=>{if(d!==a.current)return;const{scrollTop:u,ignoreScrollToTop:x}=l;let{lastScrollTop:S=u}=l;l.lastScrollTop=u,l.ignoreScrollToTop=void 0,x&&x>u&&(S=x),v(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||u===x)return;if(n()){f(!0),c(!1);return}const k=u>S,E=u<S;if(l.animation?.ignoreEscapes){l.scrollTop=S;return}E&&(f(!0),c(!1)),k&&f(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[f,c,n,l]),_=C.useCallback(({target:d,deltaY:u})=>{let x=d;for(;!["scroll","auto"].includes(getComputedStyle(x).overflow);){if(!x.parentElement)return;x=x.parentElement}x===a.current&&u<0&&a.current.scrollHeight>a.current.clientHeight&&!l.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,l]),a=Tn(d=>{a.current?.removeEventListener("scroll",y),a.current?.removeEventListener("wheel",_),d?.addEventListener("scroll",y,{passive:!0}),d?.addEventListener("wheel",_,{passive:!0})},[]),h=Tn(d=>{if(l.resizeObserver?.disconnect(),!d)return;let u;l.resizeObserver=new ResizeObserver(([x])=>{const{height:S}=x.contentRect,k=S-(u??S);if(l.resizeDifference=k,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),v(l.isNearBottom),k>=0){const E=Br(i.current,u?i.current.resize:i.current.initial);g({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:sh})}else l.isNearBottom&&(f(!1),c(!0));u=S,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===k&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:h,scrollRef:a,scrollToBottom:g,stopScroll:b,isAtBottom:o||p,isNearBottom:p,escapedFromLock:t,state:l}};function Tn(e,t){const r=C.useCallback(o=>(r.current=o,e(o)),t);return r}const Ir=new Map;function Br(...e){const t={...Ju};let r=!1;for(const m of e){if(m==="instant"){r=!0;continue}typeof m=="object"&&(r=!1,t.damping=m.damping??t.damping,t.stiffness=m.stiffness??t.stiffness,t.mass=m.mass??t.mass)}const o=JSON.stringify(t);return Ir.has(o)||Ir.set(o,Object.freeze(t)),r?"instant":Ir.get(o)}function rh({content:e,children:t,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 s.jsxs("div",{className:`group/tooltip relative ${r}`,children:[t,s.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,s.jsx("div",{className:`absolute ${p} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function Ws(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ih(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function zi({usage:e,tooltipSide:t="top"}){const{t:r}=ae();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?ih(m):"text-neutral-400",i=o?s.jsx("span",{children:r("上下文: {used} / {max} tokens",{used:Ws(e.totalTokens),max:Ws(o)})}):s.jsx("span",{children:r("已使用: {used} tokens",{used:Ws(e.totalTokens)})});return s.jsx(rh,{content:i,side:t,children:s.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:[s.jsx(Dc,{size:14,className:v}),s.jsxs("span",{className:`tabular-nums ${v}`,children:[Ws(e.totalTokens),p!==null&&s.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const nh="/api";async function oh(e){const t=new FormData;t.append("file",e);const r=await fetch(`${nh}/attachments/upload`,{method:"POST",body:t});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error||`Upload failed (${r.status})`)}return r.json()}let ah=0;function xr(){const[e,t]=C.useState([]),r=C.useRef(e);r.current=e;const o=C.useCallback(async l=>{const g=l.map(b=>({tempId:`tmp-${++ah}`,file:b,progress:0,status:"uploading"}));t(b=>[...b,...g]),await Promise.allSettled(g.map(async b=>{try{const y=await oh(b.file);t(_=>_.map(a=>a.tempId===b.tempId?{...a,status:"done",progress:100,attachment:y}:a))}catch(y){t(_=>_.map(a=>a.tempId===b.tempId?{...a,status:"error",error:y instanceof Error?y.message:"Upload failed"}:a))}}))},[]),m=C.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),p=C.useCallback(l=>{t(g=>g.filter(b=>b.tempId!==l))},[]),v=C.useCallback(()=>{t([])},[]),i=C.useCallback(l=>{l.length!==0&&t(g=>{const b=new Set(g.map(_=>_.attachment?.id??_.tempId)),y=l.filter(_=>{const a=_.attachment?.id??_.tempId;return b.has(a)?!1:(b.add(a),!0)});return y.length>0?[...g,...y]:g})},[]),n=C.useCallback(()=>{const l=m();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
|
|
12
|
+
`)},[m]),c=e.length>0,f=e.some(l=>l.status==="uploading");return{files:e,addFiles:o,removeFile:p,clear:v,restoreFiles:i,buildMarkdownLinks:n,getDoneAttachments:m,hasFiles:c,isUploading:f}}function lh(e){const t=C.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return bt({queryKey:["attachments","metadata",t],queryFn:()=>ge.get("/attachments/metadata",{params:{ids:t.join(",")}}),enabled:t.length>0,staleTime:300*1e3})}const ch="/api";function dh(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function br({files:e,onRemove:t}){return e.length===0?null:s.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>s.jsx(uh,{item:r,onRemove:t},r.tempId))})}function uh({item:e,onRemove:t}){const r=e.file.type.startsWith("image/"),o=e.status==="error",m=e.status==="uploading";return s.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?s.jsx("img",{src:`${ch}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):s.jsx("span",{className:"flex-shrink-0",children:m?s.jsx($e,{size:16,className:"animate-spin text-neutral-400"}):r?s.jsx(Ni,{size:16,className:"text-neutral-400"}):s.jsx(ki,{size:16,className:"text-neutral-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-medium",children:e.file.name}),o?s.jsx("div",{className:"truncate text-red-500",children:e.error}):s.jsx("div",{className:"text-neutral-400",children:dh(e.file.size)})]}),s.jsx("button",{onClick:()=>t(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:s.jsx(Wt,{size:10})})]})}const hh=10,fh=24,oa=hh*fh,mh=8;function ph(e,t=oa){return e>t+mh}function gh(e,t){return e.includes(t)?e:[...e,t]}function vh(e,t){return e.filter(r=>r!==t)}function _h(e,t){const r=new Map(t.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const yr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Mn(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function xh(e,t=[],r=[]){const o=new Set(r.filter(p=>yr.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...t.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 i=Mn(p.sortTime)-Mn(v.sortTime);return i!==0?i:p.order!==v.order?p.order-v.order:p.key.localeCompare(v.key)})}function bh(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 yh(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 Sh(e,t){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} ${t(p)}`:null}).filter(m=>!!m).join(" · ")}function wh(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Ch({status:e}){const{t}=ae();return e==="RUNNING"?s.jsxs(s.Fragment,{children:[t("Working"),s.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[s.jsx("span",{children:"."}),s.jsx("span",{className:"active-work-dots__second",children:"."}),s.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):s.jsx(s.Fragment,{children:t(bh(e))})}function kh({invocations:e,memberById:t,workRequestById:r,onViewInvocationSession:o,onStopMember:m,isStopPending:p,stoppingMemberId:v,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:c}=ae(),[f,l]=C.useState(wh),g=C.useMemo(()=>e.filter(y=>yr.has(y.status)).sort((y,_)=>Date.parse(_.updatedAt??_.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const b=Sh(g,c);return s.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[s.jsxs("button",{type:"button",onClick:()=>l(y=>!y),"aria-expanded":f,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:[s.jsxs("span",{className:"min-w-0 truncate",children:[s.jsx("span",{className:"font-medium text-neutral-800",children:c("Active work")}),s.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),s.jsx("span",{children:b})]}),f?s.jsx(vt,{size:15,className:"shrink-0 text-neutral-400"}):s.jsx(yi,{size:15,className:"shrink-0 text-neutral-400"})]}),f&&s.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(y=>{const _=t.get(y.memberId),a=r.get(y.workRequestId),h=!!(y.sessionId&&o),d=!!_,u=i===y.id,x=p&&v===y.memberId,S=a?.instruction??y.workRequestId;return s.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[s.jsxs("div",{title:S,className:te("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:[s.jsx(Mt,{name:_?.name??c("Agent"),avatar:_?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[s.jsx("span",{className:"truncate font-medium text-neutral-800",children:_?.name??c("Agent")}),s.jsx("span",{className:te("shrink-0",yh(y.status)),children:s.jsx(Ch,{status:y.status})})]}),h&&s.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")} ${_?.name??c("Agent")}`,children:s.jsx(Zs,{size:13})}),d&&s.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:x,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")} ${_?.name??c("Agent")}`,children:s.jsx(ns,{size:12})})]}),d&&u&&_&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[s.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:c("Stop running work?")}),s.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:x,onClick:()=>m(_.id,!1),children:[s.jsx(ns,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop only")})]}),s.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:x,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>m(_.id,!0),children:[s.jsx(Oo,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const or="/api";let Dn=0;function Eh(e,t){return Dn+=1,{id:`pending-room-message-${Date.now()}-${Dn}`,teamRunId:e,senderType:t.senderType??"user",senderId:t.senderId??null,senderInvocationId:t.senderInvocationId??null,kind:t.kind??((t.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:t.content,mentions:t.mentions??[],workRequestIds:[],artifactRefs:t.artifactRefs??[],attachmentIds:t.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function jh(e){return"pendingStatus"in e}const Nh=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${or}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Ah(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Rh(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Th(e,t){if(t.length===0)return e;const r=new Set(t.map(Rh));return e.split(`
|
|
13
13
|
`).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(`
|
|
14
14
|
`).replace(/\n{3,}/g,`
|
|
15
15
|
|
|
16
|
-
`).trim()}function
|
|
16
|
+
`).trim()}function Mh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ln(e,t){return e instanceof Error?e.message:t}function Dh(e,t){const o=e.slice(0,t).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:t,query:o[2]??""}}function Lh(e,t){const r=t.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(m=>m.toLowerCase().includes(r)):!0}function Ph(e,t){return e.label??t.get(e.memberId)?.name??e.memberId}function Oh(e,t){return(e.recipientMemberIds??[]).map(r=>t.get(r)?.name??r)}function Ih(e,t){const r=e.mentions??[];if(r.length===0)return e.content;const o=r.map(p=>Ph(p,t)).filter(p=>p&&!e.content.includes(`@${p}`));if(o.length===0)return e.content;const m=o.map(p=>`@${p}`).join(" ");return e.content.trimEnd()?`${e.content.trimEnd()} ${m}`:m}function Bh(e,t,r){if(e.senderType!=="agent")return null;if(e.senderId&&t.has(e.senderId))return t.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&t.has(o.memberId))return t.get(o.memberId)??null}return null}function Fh({content:e,isUser:t}){return s.jsx("div",{className:te("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",t?["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:s.jsx(vi,{urlTransform:Nh,components:_i,children:e})})}function zh({hasAttachmentIds:e,attachments:t,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&t.length===0)return s.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(t.length===0)return null;const m=t.filter(v=>v.mimeType.startsWith("image/")),p=new Map(m.map((v,i)=>[v.id,i]));return s.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:t.map(v=>{const i=`${or}${v.url}`;if(v.mimeType.startsWith("image/")){const c=p.get(v.id)??0;return s.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:[s.jsx("img",{src:i,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),s.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 s.jsxs("a",{href:i,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:[s.jsx(ki,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-medium",children:v.originalName}),s.jsx("span",{className:"text-neutral-400",children:Ah(v.sizeBytes)})]}),s.jsx(Ci,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Hh({content:e,attachmentIds:t,isUser:r,tone:o,onOpenImage:m}){const p=C.useMemo(()=>Array.from(new Set(t??[])),[t]),{data:v=[],isLoading:i}=lh(p),n=v.length>0?Th(e,v):e;return s.jsxs(s.Fragment,{children:[n.trim()&&s.jsx(Uh,{content:n,isUser:r,tone:o}),s.jsx(zh,{hasAttachmentIds:p.length>0,attachments:v,isLoading:i,onOpenImage:m})]})}function Wh({images:e,index:t,onClose:r,onSelect:o}){const m=e[t];if(!m)return null;const p=t>0,v=t<e.length-1;return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[s.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:s.jsx(Wt,{size:20})}),p&&s.jsx("button",{type:"button",onClick:()=>o(t-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:s.jsx(_c,{size:24,"aria-hidden":!0})}),s.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[s.jsx("img",{src:`${or}${m.url}`,alt:m.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[s.jsx("span",{className:"max-w-[70vw] truncate",children:m.originalName}),s.jsxs("a",{href:`${or}${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:[s.jsx(Ci,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&s.jsx("button",{type:"button",onClick:()=>o(t+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:s.jsx(Tt,{size:24,"aria-hidden":!0})})]})}function $h({draft:e,attachmentMarkdown:t,attachmentIds:r,mentions:o}){const p=[e.trim(),t].filter(Boolean).join(`
|
|
17
17
|
|
|
18
|
-
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Kh({content:e,isUser:t,tone:r=t?"user":"agent"}){const{t:o}=ae(),m=C.useId(),p=C.useRef(null),[v,i]=C.useState(null),[n,c]=C.useState(!1),f=v?.content===e&&v.expanded,l=C.useCallback(()=>{const x=p.current;x&&c(vh(x.scrollHeight))},[]);C.useLayoutEffect(()=>{l();const x=p.current;if(!x)return;const y=window.requestAnimationFrame(l),_=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return _?.observe(x),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(y),_?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=n&&!f;return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{id:m,ref:p,onLoadCapture:l,className:te("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:oa}:void 0,children:[s.jsx(Hh,{content:e,isUser:t}),g&&s.jsx("div",{className:te("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")})]}),n&&s.jsxs("button",{type:"button","aria-expanded":f,"aria-controls":m,"aria-label":o(f?"Collapse message":"Expand full message"),onClick:()=>i({content:e,expanded:!f}),className:te("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:[f?s.jsx(wi,{size:13}):s.jsx(bt,{size:13}),s.jsx("span",{children:o(f?"Collapse message":"Expand full message")})]})]})}function aa({senderName:e,avatar:t,createdAt:r,isUser:o,isSystem:m,children:p,headerAddon:v,bubbleClassName:i,isPending:n}){return m?s.jsx("div",{className:"flex justify-center",children:s.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})}):s.jsxs("div",{className:te("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&s.jsx(Xt,{name:e,avatar:t??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:te("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[s.jsxs("div",{className:te("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:[s.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),s.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),s.jsx(ts,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"shrink-0",children:Lh(r)}),v]}),s.jsx("div",{className:te("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",i,n?"opacity-70":""),children:p})]}),o&&s.jsx(Xt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Xh({message:e,senderName:t,senderMember:r,memberById:o,displayContent:m,onOpenImage:p}){const{t:v}=ae(),i=e.senderType==="user",n=e.senderType==="system",c=Ah(e)?e.pendingStatus:null,f=e.mentions??[],l=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",x=g?Bh(e,o):[],y=s.jsxs(s.Fragment,{children:[g&&s.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:x.join(", "),children:[s.jsx(qc,{size:10}),s.jsxs("span",{className:"truncate",children:[v("Private"),x.length>0?`: ${x.join(", ")}`:""]})]}),!n&&l>0&&f.length===0&&s.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"&&s.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"&&s.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 s.jsx(aa,{senderName:t,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:n,headerAddon:y,bubbleClassName:i&&c==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:c==="sending",children:s.jsx($h,{content:m,attachmentIds:e.attachmentIds,isUser:i&&c!=="failed",tone:n?"system":void 0,onOpenImage:p})})}function Vh({request:e,member:t,onApprove:r,onReject:o,isActionPending:m,isApprovePending:p,isRejectPending:v}){const{t:i}=ae();return s.jsx(aa,{senderName:t?.name??i("Agent"),avatar:t?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.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:[s.jsx(ts,{size:11}),i("Pending approval")]}),s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),s.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instruction}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(Ie,{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:[s.jsx(Tt,{size:12}),s.jsx("span",{children:i(p?"Approving":"Approve")})]}),s.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:o,children:[s.jsx(Ht,{size:12}),s.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function la({teamRun:e,messages:t,readOnly:r,readOnlyMessage:o,onSendMessage:m,onViewInvocationSession:p,compactComposer:v}){const{t:i}=ae(),n=Co(e.id),c=ko(e.id),f=Eo(e.id),[l,g]=C.useState(""),[x,y]=C.useState(!1),[_,a]=C.useState(null),[h,d]=C.useState(0),[u,b]=C.useState([]),[S,E]=C.useState(!1),[j,w]=C.useState(null),[k,N]=C.useState([]),[L,R]=C.useState(null),M=C.useRef(null),D=C.useRef(null),{files:I,addFiles:F,removeFile:z,clear:A,restoreFiles:P,buildMarkdownLinks:O,getDoneAttachments:B,isUploading:$}=Sr(),Y=I.some(X=>X.status==="done"&&X.attachment),[Q,Z]=C.useState(null),{scrollRef:he,contentRef:T,isAtBottom:H,scrollToBottom:U}=zi({resize:"smooth",initial:"instant"}),W=C.useMemo(()=>new Map((e.members??[]).map(X=>[X.id,X])),[e.members]),se=C.useMemo(()=>new Map((e.invocations??[]).map(X=>[X.id,X])),[e.invocations]),K=C.useMemo(()=>{const X=new Set(t.map(ee=>ee.id)),J=k.filter(ee=>!X.has(ee.id));return[...t,...J].sort((ee,fe)=>{const qe=Date.parse(ee.createdAt??""),Ae=Date.parse(fe.createdAt??"");return(Number.isNaN(qe)?0:qe)-(Number.isNaN(Ae)?0:Ae)})},[t,k]),ce=C.useMemo(()=>new Map((e.workRequests??[]).map(X=>[X.id,X])),[e.workRequests]),pe=C.useMemo(()=>yh(K,e.workRequests??[],e.invocations??[]),[K,e.invocations,e.workRequests]),be=C.useMemo(()=>(e.invocations??[]).filter(X=>Ts.has(X.status)),[e.invocations]),De=C.useMemo(()=>u.map(X=>W.get(X)).filter(X=>!!X),[W,u]),ne=C.useMemo(()=>{const X=_?.query??"";return(e.members??[]).filter(J=>Oh(J,X)).sort((J,ee)=>{const fe=u.includes(J.id),qe=u.includes(ee.id);return fe!==qe?fe?1:-1:J.name.localeCompare(ee.name)})},[_?.query,u,e.members]),_e=!r&&(x||!!_)&&ne.length>0,He=C.useCallback((X,J)=>{if(J==null){a(null);return}a(Ph(X,J)),d(0)},[]),we=C.useCallback(X=>{b(Ae=>_h(Ae,X.id));const J=`@${X.name} `;if(_){const Ae=`${l.slice(0,_.start)}${J}${l.slice(_.end)}`,Ve=_.start+J.length;g(Ae),a(null),y(!1),requestAnimationFrame(()=>{M.current?.focus(),M.current?.setSelectionRange(Ve,Ve)});return}const ee=l.length===0||/\s$/.test(l)?"":" ",fe=`${l}${ee}${J}`,qe=fe.length;g(fe),y(!1),requestAnimationFrame(()=>{M.current?.focus(),M.current?.setSelectionRange(qe,qe)})},[l,_]),Le=C.useCallback(X=>{b(J=>xh(J,X))},[]),ke=C.useCallback(X=>{const J=X.target.value;g(J),w(null);const ee=X.target;ee.style.height="auto",ee.style.height=`${Math.max(v?40:72,Math.min(ee.scrollHeight,v?140:240))}px`,y(!1),He(J,ee.selectionStart)},[v,He]),Ee=C.useCallback(X=>{const J=X.target.files;J&&J.length>0&&(F(Array.from(J)),w(null)),X.target.value=""},[F]),Ue=C.useCallback(X=>{const J=[];for(const ee of X.clipboardData.items)if(ee.kind==="file"){const fe=ee.getAsFile();fe&&J.push(fe)}J.length>0&&(X.preventDefault(),F(J),w(null))},[F]),ye=C.useCallback(async()=>{if(r||S||$)return;const X=O(),J=B().map(Fe=>Fe.id),ee=bh(u,e.members??[]),fe=qh({draft:l,attachmentMarkdown:X,attachmentIds:J,mentions:ee});if(!fe||!l.trim()&&!Y)return;const qe=Nh(e.id,fe),Ae=l,Ve=u,nt=I;N(Fe=>[...Fe,qe]),g(""),b([]),y(!1),a(null),A(),M.current&&(M.current.style.height=v?"40px":"72px"),requestAnimationFrame(()=>U()),E(!0),w(null);try{const Fe=await m(fe);N(yt=>yt.filter(Qe=>Qe.id!==qe.id)),Fe&&typeof Fe=="object"&&"id"in Fe&&requestAnimationFrame(()=>U())}catch(Fe){const yt=Fe instanceof Error?Fe.message:"Failed to send room message";N(Qe=>Qe.map(ct=>ct.id===qe.id?{...ct,pendingStatus:"failed",error:yt}:ct)),g(Qe=>Qe.length===0?Ae:Qe),b(Qe=>Qe.length===0?Ve:Qe),P(nt),w(yt),requestAnimationFrame(()=>U())}finally{E(!1)}},[I,O,A,v,l,B,Y,S,$,m,r,P,U,u,e.id,e.members]),Je=C.useCallback(X=>{const J=X.nativeEvent.isComposing||X.nativeEvent.keyCode===229;if(_e){if(X.key==="ArrowDown"){X.preventDefault(),d(ee=>(ee+1)%ne.length);return}if(X.key==="ArrowUp"){X.preventDefault(),d(ee=>(ee-1+ne.length)%ne.length);return}if(X.key==="Enter"&&!J||X.key==="Tab"){X.preventDefault();const ee=ne[h]??ne[0];ee&&we(ee);return}if(X.key==="Escape"){X.preventDefault(),a(null),y(!1);return}}X.key==="Enter"&&!X.shiftKey&&!X.repeat&&!J&&(X.preventDefault(),ye())},[we,ye,h,ne,_e]);C.useEffect(()=>{g(""),b([]),y(!1),a(null),w(null),N([]),A(),R(null),M.current&&(M.current.style.height=v?"40px":"72px")},[A,v,e.id]);const Ce=n.isError?n.error:c.isError?c.error:null,Ne=n.isPending||c.isPending,tt=C.useCallback((X,J)=>{f.mutate({memberId:X,cancelQueued:J},{onSuccess:()=>R(null)})},[f]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Q&&s.jsx(Uh,{images:Q.images,index:Q.index,onClose:()=>Z(null),onSelect:X=>Z(J=>J&&{...J,index:X})}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:he,className:te("h-full overflow-y-auto scrollbar-app-thin bg-white",v?"px-3 py-3":"px-4 py-4"),children:s.jsxs("div",{ref:T,className:te(v?"space-y-2.5":"space-y-3"),children:[pe.length===0?s.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:[s.jsx(mr,{size:24,className:"text-neutral-400"}),s.jsx("span",{className:"text-sm",children:i("No room messages yet")})]}):pe.map(X=>{if(X.kind==="pendingApproval"){const Ae=X.request,Ve=W.get(Ae.targetMemberId),nt=n.isPending&&n.variables===Ae.id,Fe=c.isPending&&c.variables===Ae.id;return s.jsx(Vh,{request:Ae,member:Ve,onApprove:()=>n.mutate(Ae.id),onReject:()=>c.mutate(Ae.id),isActionPending:Ne,isApprovePending:nt,isRejectPending:Fe},X.key)}const J=X.message,ee=zh(J,W,se),fe=J.senderType==="user"?i("你"):J.senderType==="system"?i("System"):ee?.name??i("Agent"),qe=Fh(J,W);return s.jsx(Xh,{message:J,senderName:fe,senderMember:ee,memberById:W,displayContent:qe,onOpenImage:(Ae,Ve)=>Z({images:Ae,index:Ve})},X.key)}),Ce&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Pn(Ce,i("Failed to update work request"))}),f.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Pn(f.error,i("Failed to stop member work"))})]})}),!H&&s.jsxs("button",{type:"button",onClick:()=>U(),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:[s.jsx(Cs,{size:14}),s.jsx("span",{children:i("Back to bottom")})]})]}),s.jsxs("div",{className:te("shrink-0 border-t border-transparent bg-white",v?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:[s.jsx(jh,{invocations:be,memberById:W,workRequestById:ce,onViewInvocationSession:p,onStopMember:tt,isStopPending:f.isPending,stoppingMemberId:f.variables?.memberId??null,stopPromptInvocationId:L,onToggleStopConfirm:X=>R(J=>J===X?null:X)}),r?s.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")}):s.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:[_e&&s.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:[s.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:i(_?"Mention members":"Team members")}),s.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:ne.map((X,J)=>{const ee=u.includes(X.id),fe=J===h;return s.jsxs("button",{type:"button",onMouseEnter:()=>d(J),onMouseDown:qe=>{qe.preventDefault(),we(X)},className:te("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",fe?"bg-neutral-100":"hover:bg-neutral-50"),children:[s.jsx(Xt,{name:X.name,avatar:X.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:X.name}),ee&&s.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:[X.providerId,X.id.slice(0,8)].filter(Boolean).join(" · ")})]}),s.jsx(fn,{size:15,className:"text-neutral-400"})]},X.id)})})]}),De.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:De.map(X=>s.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:[s.jsxs("span",{className:"truncate font-medium",children:["@",X.name]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:X.id.slice(0,8)}),s.jsx("button",{type:"button",onClick:()=>Le(X.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")} ${X.name}`,children:s.jsx(Ht,{size:12})})]},X.id))}),s.jsx(wr,{files:I,onRemove:z}),s.jsx("textarea",{ref:M,value:l,rows:v?1:void 0,onChange:ke,onKeyDown:Je,onPaste:Ue,onClick:X=>He(l,X.currentTarget.selectionStart),onSelect:X=>He(l,X.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:te("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}}),s.jsxs("div",{className:te("flex items-center justify-between",v?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{ref:D,type:"file",multiple:!0,className:"hidden",onChange:Ee}),s.jsx("button",{type:"button",onClick:()=>D.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:s.jsx(pr,{size:18})}),s.jsx("button",{type:"button",onClick:()=>{y(X=>!X),a(null),requestAnimationFrame(()=>M.current?.focus())},disabled:De.length===0&&(e.members??[]).length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:te("rounded-lg transition-colors",v?"p-1.5":"p-2",x?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",De.length===0&&(e.members??[]).length===0?"cursor-not-allowed opacity-50":""),children:s.jsx(fn,{size:v?15:18})}),De.length>0&&s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[De.length," ",i("selected")]})]}),s.jsx("button",{type:"button",onClick:()=>{ye()},disabled:r||S||$||!l.trim()&&!Y,title:i($?"Uploading...":S?"发送中...":"发送"),"aria-label":i($?"Uploading...":S?"发送中...":"发送"),className:te("rounded-lg transition-all duration-200",v?"p-1.5":"p-2",(l.trim()||Y)&&!r&&!S&&!$?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",S||$?"opacity-70":""),children:s.jsx(ki,{size:v?15:18})})]}),j&&s.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:j})]})]})]})}function Yh(e){return e?e.slice(0,8):""}function On(e){const t=e?Date.parse(e):0;return Number.isNaN(t)?0:t}function ca(e,t){if(!e?.length)return[];const r=new Map((t?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),m=t?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,i=p.ownerMemberId?r.get(p.ownerMemberId):void 0,n=!!(m&&p.id===m),c=n?"main":p.parentWorkspaceId?"child":"root",f=i?.name??(p.ownerMemberId?`Member ${Yh(p.ownerMemberId)}`:void 0),l=n?"Main workspace":c==="child"?f?`${f} workspace`:"Child workspace":t?"Root workspace":"Workspace";return{workspace:p,kind:c,roleLabel:n?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:f,parentBranchName:v?.branchName,isMain:n}}).sort((p,v)=>{const i=c=>c.kind==="main"?0:c.kind==="child"?1:2,n=i(p)-i(v);return n!==0?n:On(p.workspace.createdAt)-On(v.workspace.createdAt)})}function da(e,t,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:t?.mainWorkspaceId&&e.some(o=>o.id===t.mainWorkspaceId)?t.mainWorkspaceId:e.find(o=>o.status===Et.ACTIVE)?.id??e[0]?.id}function Gh(e,t){return!e||e.status!==Et.ACTIVE?!1:!t||e.parentWorkspaceId?!0:!!(t.mainWorkspaceId&&e.id===t.mainWorkspaceId)}function Qh(e,t,r){return e?.parentWorkspaceId?t?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Zh=[],Jh=[],ef=[];function Zt(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function In(e,t){return e instanceof Error?e.message:t}function tf(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"idle":return"Idle"}}function sf(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"idle":return"border-neutral-200 bg-white text-neutral-500"}}function rf(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function nf(e){switch(e){case"queue":return"Queue if busy";case"cancel_current_and_start":return"Cancel current if busy"}}function of(e){switch(e){case"new_per_request":return"New session per request";case"resume_last":return"Resume last session"}}function af(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 lf(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function cf(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 df(e){return[...e].sort((t,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(t.updatedAt??t.createdAt??""))}function Hr(e){return e?`${e.slice(0,8)}...`:""}function uf(e,t,r){const o=t.filter(p=>p.memberId===e.id);if(o.some(p=>p.status==="RUNNING"))return"running";if(o.some(p=>p.status==="WAITING_ROOM_REPLY"))return"waiting room reply";if(o.some(p=>p.status==="QUEUED"))return"queued";if(o.some(p=>p.status==="SESSION_ENDED"))return"session ended";const m=r.find(p=>p.targetMemberId===e.id&&(p.status==="PENDING_APPROVAL"||p.status==="QUEUED"));return m?.status==="PENDING_APPROVAL"?"pending approval":m?.status==="QUEUED"?"queued":"idle"}function ua({teamRun:e,workspaces:t,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:m}){const{t:p}=ae(),v=Co(e.id),i=ko(e.id),n=Eo(e.id),[c,f]=C.useState(null),[l,g]=C.useState(null),x=e.members??Zh,y=e.workRequests??Jh,_=e.invocations??ef,a=C.useMemo(()=>ca(t,e),[e,t]),h=C.useMemo(()=>new Map(y.map(k=>[k.id,k])),[y]),d=e.messages?.length??0,u=C.useMemo(()=>_.filter(k=>Ts.has(k.status)).sort((k,N)=>Date.parse(N.updatedAt??N.createdAt??"")-Date.parse(k.updatedAt??k.createdAt??"")),[_]),b=C.useMemo(()=>[..._].filter(k=>k.status==="COMPLETED"||k.status==="FAILED"||k.status==="CANCELLED").sort((k,N)=>Date.parse(N.updatedAt??N.createdAt??"")-Date.parse(k.updatedAt??k.createdAt??"")).slice(0,6),[_]),S=C.useMemo(()=>[...y].filter(k=>k.status==="PENDING_APPROVAL").sort((k,N)=>Date.parse(N.updatedAt??N.createdAt??"")-Date.parse(k.updatedAt??k.createdAt??"")),[y]),E=C.useMemo(()=>[...y].filter(k=>k.status==="QUEUED").sort((k,N)=>Date.parse(N.updatedAt??N.createdAt??"")-Date.parse(k.updatedAt??k.createdAt??"")),[y]),j=v.isError?v.error:i.isError?i.error:null,w=v.isPending||i.isPending;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(ds,{size:14,className:"text-neutral-500 shrink-0"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),s.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:[s.jsx("span",{children:p("Team mode")}),s.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-4 space-y-4",children:[s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(er,{size:13}),s.jsx("span",{children:p("Team room")})]}),s.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-neutral-500",children:[s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[p("Messages"),": ",d]}),s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[p("Team mode"),": ",e.mode]}),e.reviewReason&&s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[p("Review reason"),": ",e.reviewReason]})]})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(ds,{size:13}),s.jsx("span",{children:p("Workspaces")})]}),s.jsx("div",{className:"space-y-2",children:a.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No workspace")}):a.map(k=>{const N=r===k.workspace.id;return s.jsx("div",{className:te("rounded-md border bg-white px-3 py-2",N?"border-neutral-400 shadow-sm":"border-neutral-200"),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(k.displayName)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",cf(k.roleLabel)),children:p(k.roleLabel)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",lf(k.workspace.status)),children:k.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:k.workspace.branchName}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[k.ownerName&&s.jsxs("span",{children:[p("Owner"),": ",k.ownerName]}),k.parentBranchName&&s.jsxs("span",{children:[p("Parent"),": ",k.parentBranchName]}),s.jsxs("span",{children:[p("Workspace"),": ",Hr(k.workspace.id)]})]})]}),s.jsxs("button",{type:"button",onClick:()=>o?.(k.workspace.id),disabled:!o||N,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:[N?s.jsx(Tt,{size:11}):s.jsx(Ai,{size:11}),s.jsx("span",{children:p(N?"Selected":"Select")})]})]})},k.workspace.id)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(ts,{size:13}),s.jsx("span",{children:p("Pending approval")})]}),s.jsx("div",{className:"space-y-2",children:S.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No pending approvals")}):S.map(k=>{const N=x.find(M=>M.id===k.targetMemberId),L=v.isPending&&v.variables===k.id,R=i.isPending&&i.variables===k.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:N?.name??k.targetMemberId}),s.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-neutral-500 line-clamp-3",children:k.instruction})]}),s.jsx("span",{className:"shrink-0 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:p("Pending approval")})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] text-neutral-500",children:[s.jsxs("span",{children:[p("Requester"),": ",p(rf(k.requesterType))]}),s.jsx("span",{children:Zt(k.createdAt)}),s.jsx("span",{children:p(nf(k.ifBusy))}),s.jsxs("span",{children:[p("Cancel queued"),": ",p(k.cancelQueued?"Yes":"No")]})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>v.mutate(k.id),disabled:w,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",title:p("Approve"),children:[s.jsx(Tt,{size:11}),s.jsx("span",{className:"truncate",children:p(L?"Approving":"Approve")})]}),s.jsxs("button",{type:"button",onClick:()=>i.mutate(k.id),disabled:w,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",title:p("Reject"),children:[s.jsx(Ht,{size:11}),s.jsx("span",{className:"truncate",children:p(R?"Rejecting":"Reject")})]})]})]},k.id)})}),j&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:In(j,p("Failed to update work request"))})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(mr,{size:13}),s.jsx("span",{children:p("Members")})]}),s.jsx("div",{className:"space-y-2",children:x.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No members")}):x.map(k=>{const N=uf(k,_,y),L=df(_.filter(D=>D.memberId===k.id)),R=L[0],M=l===k.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white",children:[s.jsxs("button",{type:"button",onClick:()=>g(M?null:k.id),className:"flex w-full items-start justify-between gap-3 px-3 py-2 text-left transition-colors hover:bg-neutral-50",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Xt,{name:k.name,avatar:k.avatar}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:k.name}),s.jsxs("div",{className:"truncate text-[11px] text-neutral-500",children:[k.providerId," · ",k.workspacePolicy," · ",p(of(k.sessionPolicy))]}),R&&s.jsxs("div",{className:"mt-0.5 truncate text-[11px] text-neutral-400",children:[p("Latest"),": ",R.status," · ",Zt(R.updatedAt??R.createdAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("span",{className:te("rounded-full border px-2 py-0.5 text-[10px] font-medium capitalize",sf(N)),children:p(tf(N))}),M?s.jsx(bt,{size:14,className:"text-neutral-400"}):s.jsx(Mt,{size:14,className:"text-neutral-400"})]})]}),M&&s.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:L.length})]}),L.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-xs text-neutral-500",children:p("No invocation history")}):s.jsx("div",{className:"space-y-1.5",children:L.map(D=>{const I=h.get(D.workRequestId),F=!!(D.sessionId&&m);return s.jsx("div",{className:"rounded-md border border-neutral-100 bg-neutral-50/70 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:te("rounded-full border px-1.5 py-0.5 text-[10px] font-medium",af(D.status)),children:D.status}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:Zt(D.updatedAt??D.createdAt)})]}),s.jsx("div",{className:"mt-1 truncate text-[11px] text-neutral-500",children:I?.instruction??D.workRequestId}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[s.jsxs("span",{children:[p("Invocation"),": ",Hr(D.id)]}),D.sessionId&&s.jsxs("span",{children:[p("Session"),": ",Hr(D.sessionId)]})]})]}),s.jsxs("button",{type:"button",onClick:()=>D.sessionId&&m?.(D.sessionId),disabled:!F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:p("View details"),children:[s.jsx(Ri,{size:11}),s.jsx("span",{children:p("View log")})]})]})},D.id)})})]})]},k.id)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(er,{size:13}),s.jsx("span",{children:p("Queue")})]}),s.jsx("div",{className:"space-y-2",children:E.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No queued work requests")}):E.map(k=>{const N=x.find(L=>L.id===k.targetMemberId);return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:N?.name??k.targetMemberId}),s.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500 line-clamp-2",children:k.instruction})]})}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(k.createdAt)})]})]},k.id)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(_c,{size:13}),s.jsx("span",{children:p("Active invocations")})]}),s.jsx("div",{className:"space-y-2",children:u.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No active invocations")}):u.map(k=>{const N=x.find(D=>D.id===k.memberId),L=Ts.has(k.status)&&!!N,R=c===k.id,M=n.isPending&&n.variables?.memberId===N?.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:N?.name??k.memberId}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:[k.status," · ",k.sessionId?k.sessionId.slice(0,8):k.id.slice(0,8)]})]}),L?s.jsxs("button",{type:"button",onClick:()=>f(R?null:k.id),disabled:n.isPending,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("Stop"),children:[s.jsx(os,{size:10}),s.jsx("span",{children:p("Stop")})]}):s.jsx(Es,{size:12,className:"text-neutral-400 shrink-0"})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(k.updatedAt??k.createdAt)})]}),L&&R&&s.jsxs("div",{className:"mt-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[s.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),s.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:N.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:n.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-neutral-200 bg-white px-2 py-1 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(os,{size:10}),s.jsx("span",{children:M&&n.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:N.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:n.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 py-1 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(Oo,{size:10}),s.jsx("span",{children:M&&n.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]})]},k.id)})}),n.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:In(n.error,p("Failed to stop member work"))})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(Es,{size:13}),s.jsx("span",{children:p("Recently completed")})]}),s.jsx("div",{className:"space-y-2",children:b.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:p("No completed invocations")}):b.map(k=>{const N=x.find(L=>L.id===k.memberId);return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:N?.name??k.memberId}),s.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:k.status})]}),s.jsx("span",{className:"rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-600",children:k.status})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(k.updatedAt??k.createdAt)})]})]},k.id)})})]})]})]})}var Wr={exports:{}},Bn;function hf(){return Bn||(Bn=1,(function(e,t){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,i,n){var c=this&&this.__decorate||function(u,b,S,E){var j,w=arguments.length,k=w<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,S):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(u,b,S,E);else for(var N=u.length-1;N>=0;N--)(j=u[N])&&(k=(w<3?j(k):w>3?j(b,S,k):j(b,S))||k);return w>3&&k&&Object.defineProperty(b,S,k),k},f=this&&this.__param||function(u,b){return function(S,E){b(S,E,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const l=n(9042),g=n(6114),x=n(9924),y=n(844),_=n(5596),a=n(4725),h=n(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(u,b){super(),this._terminal=u,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 x.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(`
|
|
19
|
-
`)))),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 _.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(u){for(let
|
|
20
|
-
`&&(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(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,b){this._liveRegionDebouncer.refresh(u,b,this._terminal.rows)}_renderRows(u,b){const S=this._terminal.buffer,E=S.lines.length.toString();for(let j=u;j<=b;j++){const w=S.translateBufferLineToString(S.ydisp+j,!0),k=(S.ydisp+j+1).toString(),N=this._rowElements[j];N&&(w.length===0?N.innerText=" ":N.textContent=w,N.setAttribute("aria-posinset",k),N.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,b){const S=u.target,E=this._rowElements[b===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==E)return;let j,w;if(b===0?(j=S,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(j=this._rowElements.shift(),w=S,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const k=this._createAccessibilityTreeNode();this._rowElements.unshift(k),this._rowContainer.insertAdjacentElement("afterbegin",k)}else{const k=this._createAccessibilityTreeNode();this._rowElements.push(k),this._rowContainer.appendChild(k)}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(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){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>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_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 u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=c([f(1,a.IRenderService)],d)},3614:(v,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function c(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function f(g,x,y,_){g=c(g=n(g),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),x.value=""}function l(g,x,y){const _=y.getBoundingClientRect(),a=g.clientX-_.left-10,h=g.clientY-_.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=c,i.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,x,y,_){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),x,y,_)},i.paste=f,i.moveTextAreaUnderMouseCursor=l,i.rightClickHandler=function(g,x,y,_,a){l(g,x,y),a&&_.rightClickSelect(g),x.value=_.selectionText,x.select()}},7239:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=n(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,l,g){this._css.set(f,l,g)}getCss(f,l){return this._css.get(f,l)}setColor(f,l,g){this._color.set(f,l,g)}getColor(f,l){return this._color.get(f,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,c,f,l){n.addEventListener(c,f,l);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(c,f,l))}}}},6465:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var b,S=arguments.length,E=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(a,h,d,u);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(E=(S<3?b(E):S>3?b(h,d,E):b(h,d))||E);return S>3&&E&&Object.defineProperty(h,d,E),E},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const l=n(3656),g=n(8460),x=n(844),y=n(2585);let _=i.Linkifier2=class extends x.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,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.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 u=0;u<d.length;u++){const b=d[u];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,u;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((S=>{S?.forEach((E=>{E.link.dispose&&E.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[S,E]of this._linkProviders.entries())h?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(S)&&(b=this._checkLinkProviderResult(S,a,b)):E.provideLinks(a.y,(j=>{var w,k;if(this._isMouseOut)return;const N=j?.map((L=>({link:L})));(w=this._activeProviderReplies)===null||w===void 0||w.set(S,N),b=this._checkLinkProviderResult(S,a,b),((k=this._activeProviderReplies)===null||k===void 0?void 0:k.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let u=0;u<h.size;u++){const b=h.get(u);if(b)for(let S=0;S<b.length;S++){const E=b[S],j=E.link.range.start.y<a?0:E.link.range.start.x,w=E.link.range.end.y>a?this._bufferService.cols:E.link.range.end.x;for(let k=j;k<=w;k++){if(d.has(k)){b.splice(S--,1);break}d.add(k)}}}}_checkLinkProviderResult(a,h,d){var u;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let S=!1;for(let E=0;E<a;E++)this._activeProviderReplies.has(E)&&!this._activeProviderReplies.get(E)||(S=!0);if(!S&&b){const E=b.find((j=>this._linkAtPosition(j.link,h)));E&&(d=!0,this._handleNewLink(E))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let E=0;E<this._activeProviderReplies.size;E++){const j=(u=this._activeProviderReplies.get(E))===null||u===void 0?void 0:u.find((w=>this._linkAtPosition(w.link,h)));if(j){d=!0,this._handleNewLink(j);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,x.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,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:d=>{var u,b;!((u=this._currentLink)===null||u===void 0)&&u.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,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.underline},set:d=>{var u,b,S;!((u=this._currentLink)===null||u===void 0)&&u.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 u=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>=u&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(u,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 u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-u-1,d.end.x,d.end.y-u-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=u}_positionFromMouseEvent(a,h,d){const u=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,u,b){return{x1:a,y1:h,x2:d,y2:u,cols:this._bufferService.cols,fg:b}}};i.Linkifier2=_=c([f(0,y.IBufferService)],_)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,n){var c=this&&this.__decorate||function(_,a,h,d){var u,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(_,a,h,d);else for(var E=_.length-1;E>=0;E--)(u=_[E])&&(S=(b<3?u(S):b>3?u(a,h,S):u(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},f=this&&this.__param||function(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const l=n(511),g=n(2585);let x=i.OscLinkProvider=class{constructor(_,a,h){this._bufferService=_,this._optionsService=a,this._oscLinkService=h}provideLinks(_,a){var h;const d=this._bufferService.buffer.lines.get(_-1);if(!d)return void a(void 0);const u=[],b=this._optionsService.rawOptions.linkHandler,S=new l.CellData,E=d.getTrimmedLength();let j=-1,w=-1,k=!1;for(let N=0;N<E;N++)if(w!==-1||d.hasContent(N)){if(d.loadCell(N,S),S.hasExtendedAttrs()&&S.extended.urlId){if(w===-1){w=N,j=S.extended.urlId;continue}k=S.extended.urlId!==j}else w!==-1&&(k=!0);if(k||w!==-1&&N===E-1){const L=(h=this._oscLinkService.getLinkData(j))===null||h===void 0?void 0:h.uri;if(L){const R={start:{x:w+1,y:_},end:{x:N+(k||N!==E-1?0:1),y:_}};let M=!1;if(!b?.allowNonHttpProtocols)try{const D=new URL(L);["http:","https:"].includes(D.protocol)||(M=!0)}catch{M=!0}M||u.push({text:L,range:R,activate:(D,I)=>b?b.activate(D,I,R):y(0,I),hover:(D,I)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,D,I,R)},leave:(D,I)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.call(b,D,I,R)}})}k=!1,S.hasExtendedAttrs()&&S.extended.urlId?(w=N,j=S.extended.urlId):(w=-1,j=-1)}}a(u)}};function y(_,a){if(confirm(`Do you want to navigate to ${a}?
|
|
18
|
+
`);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Uh({content:e,isUser:t,tone:r=t?"user":"agent"}){const{t:o}=ae(),m=C.useId(),p=C.useRef(null),[v,i]=C.useState(null),[n,c]=C.useState(!1),f=v?.content===e&&v.expanded,l=C.useCallback(()=>{const b=p.current;b&&c(ph(b.scrollHeight))},[]);C.useLayoutEffect(()=>{l();const b=p.current;if(!b)return;const y=window.requestAnimationFrame(l),_=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return _?.observe(b),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(y),_?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=n&&!f;return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{id:m,ref:p,onLoadCapture:l,className:te("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:oa}:void 0,children:[s.jsx(Fh,{content:e,isUser:t}),g&&s.jsx("div",{className:te("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")})]}),n&&s.jsxs("button",{type:"button","aria-expanded":f,"aria-controls":m,"aria-label":o(f?"Collapse message":"Expand full message"),onClick:()=>i({content:e,expanded:!f}),className:te("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:[f?s.jsx(yi,{size:13}):s.jsx(vt,{size:13}),s.jsx("span",{children:o(f?"Collapse message":"Expand full message")})]})]})}function aa({senderName:e,avatar:t,createdAt:r,isUser:o,isSystem:m,children:p,headerAddon:v,bubbleClassName:i,isPending:n}){return m?s.jsx("div",{className:"flex justify-center",children:s.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})}):s.jsxs("div",{className:te("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&s.jsx(Mt,{name:e,avatar:t??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:te("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[s.jsxs("div",{className:te("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:[s.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),s.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),s.jsx(es,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"shrink-0",children:Mh(r)}),v]}),s.jsx("div",{className:te("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",i,n?"opacity-70":""),children:p})]}),o&&s.jsx(Mt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function qh({message:e,senderName:t,senderMember:r,memberById:o,displayContent:m,onOpenImage:p}){const{t:v}=ae(),i=e.senderType==="user",n=e.senderType==="system",c=jh(e)?e.pendingStatus:null,f=e.mentions??[],l=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",b=g?Oh(e,o):[],y=s.jsxs(s.Fragment,{children:[g&&s.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:b.join(", "),children:[s.jsx($c,{size:10}),s.jsxs("span",{className:"truncate",children:[v("Private"),b.length>0?`: ${b.join(", ")}`:""]})]}),!n&&l>0&&f.length===0&&s.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"&&s.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"&&s.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 s.jsx(aa,{senderName:t,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:n,headerAddon:y,bubbleClassName:i&&c==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:c==="sending",children:s.jsx(Hh,{content:m,attachmentIds:e.attachmentIds,isUser:i&&c!=="failed",tone:n?"system":void 0,onOpenImage:p})})}function Kh({request:e,member:t,onApprove:r,onReject:o,isActionPending:m,isApprovePending:p,isRejectPending:v}){const{t:i}=ae();return s.jsx(aa,{senderName:t?.name??i("Agent"),avatar:t?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.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:[s.jsx(es,{size:11}),i("Pending approval")]}),s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),s.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instruction}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(Ie,{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:[s.jsx(Rt,{size:12}),s.jsx("span",{children:i(p?"Approving":"Approve")})]}),s.jsxs(Ie,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:o,children:[s.jsx(Wt,{size:12}),s.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function la({teamRun:e,messages:t,readOnly:r,readOnlyMessage:o,onSendMessage:m,onViewInvocationSession:p,compactComposer:v}){const{t:i}=ae(),n=Co(e.id),c=ko(e.id),f=Eo(e.id),[l,g]=C.useState(""),[b,y]=C.useState(!1),[_,a]=C.useState(null),[h,d]=C.useState(0),[u,x]=C.useState([]),[S,k]=C.useState(!1),[E,w]=C.useState(null),[j,T]=C.useState([]),[L,N]=C.useState(null),R=C.useRef(null),D=C.useRef(null),{files:I,addFiles:F,removeFile:z,clear:A,restoreFiles:P,buildMarkdownLinks:O,getDoneAttachments:B,isUploading:W}=xr(),V=I.some(X=>X.status==="done"&&X.attachment),[Q,Z]=C.useState(null),{scrollRef:he,contentRef:M,isAtBottom:H,scrollToBottom:U}=Fi({resize:"smooth",initial:"instant"}),$=C.useMemo(()=>new Map((e.members??[]).map(X=>[X.id,X])),[e.members]),se=C.useMemo(()=>new Map((e.invocations??[]).map(X=>[X.id,X])),[e.invocations]),K=C.useMemo(()=>{const X=new Set(t.map(ee=>ee.id)),J=j.filter(ee=>!X.has(ee.id));return[...t,...J].sort((ee,fe)=>{const qe=Date.parse(ee.createdAt??""),Ae=Date.parse(fe.createdAt??"");return(Number.isNaN(qe)?0:qe)-(Number.isNaN(Ae)?0:Ae)})},[t,j]),ce=C.useMemo(()=>new Map((e.workRequests??[]).map(X=>[X.id,X])),[e.workRequests]),pe=C.useMemo(()=>xh(K,e.workRequests??[],e.invocations??[]),[K,e.invocations,e.workRequests]),xe=C.useMemo(()=>(e.invocations??[]).filter(X=>yr.has(X.status)),[e.invocations]),De=C.useMemo(()=>u.map(X=>$.get(X)).filter(X=>!!X),[$,u]),ne=C.useMemo(()=>{const X=_?.query??"";return(e.members??[]).filter(J=>Lh(J,X)).sort((J,ee)=>{const fe=u.includes(J.id),qe=u.includes(ee.id);return fe!==qe?fe?1:-1:J.name.localeCompare(ee.name)})},[_?.query,u,e.members]),_e=!r&&(b||!!_)&&ne.length>0,He=C.useCallback((X,J)=>{if(J==null){a(null);return}a(Dh(X,J)),d(0)},[]),we=C.useCallback(X=>{x(Ae=>gh(Ae,X.id));const J=`@${X.name} `;if(_){const Ae=`${l.slice(0,_.start)}${J}${l.slice(_.end)}`,Ve=_.start+J.length;g(Ae),a(null),y(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(Ve,Ve)});return}const ee=l.length===0||/\s$/.test(l)?"":" ",fe=`${l}${ee}${J}`,qe=fe.length;g(fe),y(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(qe,qe)})},[l,_]),Le=C.useCallback(X=>{x(J=>vh(J,X))},[]),ke=C.useCallback(X=>{const J=X.target.value;g(J),w(null);const ee=X.target;ee.style.height="auto",ee.style.height=`${Math.max(v?40:72,Math.min(ee.scrollHeight,v?140:240))}px`,y(!1),He(J,ee.selectionStart)},[v,He]),Ee=C.useCallback(X=>{const J=X.target.files;J&&J.length>0&&(F(Array.from(J)),w(null)),X.target.value=""},[F]),Ue=C.useCallback(X=>{const J=[];for(const ee of X.clipboardData.items)if(ee.kind==="file"){const fe=ee.getAsFile();fe&&J.push(fe)}J.length>0&&(X.preventDefault(),F(J),w(null))},[F]),be=C.useCallback(async()=>{if(r||S||W)return;const X=O(),J=B().map(Fe=>Fe.id),ee=_h(u,e.members??[]),fe=$h({draft:l,attachmentMarkdown:X,attachmentIds:J,mentions:ee});if(!fe||!l.trim()&&!V)return;const qe=Eh(e.id,fe),Ae=l,Ve=u,nt=I;T(Fe=>[...Fe,qe]),g(""),x([]),y(!1),a(null),A(),R.current&&(R.current.style.height=v?"40px":"72px"),requestAnimationFrame(()=>U()),k(!0),w(null);try{const Fe=await m(fe);T(yt=>yt.filter(Qe=>Qe.id!==qe.id)),Fe&&typeof Fe=="object"&&"id"in Fe&&requestAnimationFrame(()=>U())}catch(Fe){const yt=Fe instanceof Error?Fe.message:"Failed to send room message";T(Qe=>Qe.map(ct=>ct.id===qe.id?{...ct,pendingStatus:"failed",error:yt}:ct)),g(Qe=>Qe.length===0?Ae:Qe),x(Qe=>Qe.length===0?Ve:Qe),P(nt),w(yt),requestAnimationFrame(()=>U())}finally{k(!1)}},[I,O,A,v,l,B,V,S,W,m,r,P,U,u,e.id,e.members]),Je=C.useCallback(X=>{const J=X.nativeEvent.isComposing||X.nativeEvent.keyCode===229;if(_e){if(X.key==="ArrowDown"){X.preventDefault(),d(ee=>(ee+1)%ne.length);return}if(X.key==="ArrowUp"){X.preventDefault(),d(ee=>(ee-1+ne.length)%ne.length);return}if(X.key==="Enter"&&!J||X.key==="Tab"){X.preventDefault();const ee=ne[h]??ne[0];ee&&we(ee);return}if(X.key==="Escape"){X.preventDefault(),a(null),y(!1);return}}X.key==="Enter"&&!X.shiftKey&&!X.repeat&&!J&&(X.preventDefault(),be())},[we,be,h,ne,_e]);C.useEffect(()=>{g(""),x([]),y(!1),a(null),w(null),T([]),A(),N(null),R.current&&(R.current.style.height=v?"40px":"72px")},[A,v,e.id]);const Ce=n.isError?n.error:c.isError?c.error:null,Ne=n.isPending||c.isPending,tt=C.useCallback((X,J)=>{f.mutate({memberId:X,cancelQueued:J},{onSuccess:()=>N(null)})},[f]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Q&&s.jsx(Wh,{images:Q.images,index:Q.index,onClose:()=>Z(null),onSelect:X=>Z(J=>J&&{...J,index:X})}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:he,className:te("h-full overflow-y-auto scrollbar-app-thin bg-white",v?"px-3 py-3":"px-4 py-4"),children:s.jsxs("div",{ref:M,className:te(v?"space-y-2.5":"space-y-3"),children:[pe.length===0?s.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:[s.jsx(Ss,{size:24,className:"text-neutral-400"}),s.jsx("span",{className:"text-sm",children:i("No room messages yet")})]}):pe.map(X=>{if(X.kind==="pendingApproval"){const Ae=X.request,Ve=$.get(Ae.targetMemberId),nt=n.isPending&&n.variables===Ae.id,Fe=c.isPending&&c.variables===Ae.id;return s.jsx(Kh,{request:Ae,member:Ve,onApprove:()=>n.mutate(Ae.id),onReject:()=>c.mutate(Ae.id),isActionPending:Ne,isApprovePending:nt,isRejectPending:Fe},X.key)}const J=X.message,ee=Bh(J,$,se),fe=J.senderType==="user"?i("你"):J.senderType==="system"?i("System"):ee?.name??i("Agent"),qe=Ih(J,$);return s.jsx(qh,{message:J,senderName:fe,senderMember:ee,memberById:$,displayContent:qe,onOpenImage:(Ae,Ve)=>Z({images:Ae,index:Ve})},X.key)}),Ce&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ln(Ce,i("Failed to update work request"))}),f.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ln(f.error,i("Failed to stop member work"))})]})}),!H&&s.jsxs("button",{type:"button",onClick:()=>U(),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:[s.jsx(Cs,{size:14}),s.jsx("span",{children:i("Back to bottom")})]})]}),s.jsxs("div",{className:te("shrink-0 border-t border-transparent bg-white",v?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:[s.jsx(kh,{invocations:xe,memberById:$,workRequestById:ce,onViewInvocationSession:p,onStopMember:tt,isStopPending:f.isPending,stoppingMemberId:f.variables?.memberId??null,stopPromptInvocationId:L,onToggleStopConfirm:X=>N(J=>J===X?null:X)}),r?s.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")}):s.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:[_e&&s.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:[s.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:i(_?"Mention members":"Team members")}),s.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:ne.map((X,J)=>{const ee=u.includes(X.id),fe=J===h;return s.jsxs("button",{type:"button",onMouseEnter:()=>d(J),onMouseDown:qe=>{qe.preventDefault(),we(X)},className:te("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",fe?"bg-neutral-100":"hover:bg-neutral-50"),children:[s.jsx(Mt,{name:X.name,avatar:X.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:X.name}),ee&&s.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:[X.providerId,X.id.slice(0,8)].filter(Boolean).join(" · ")})]}),s.jsx(hn,{size:15,className:"text-neutral-400"})]},X.id)})})]}),De.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:De.map(X=>s.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:[s.jsxs("span",{className:"truncate font-medium",children:["@",X.name]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:X.id.slice(0,8)}),s.jsx("button",{type:"button",onClick:()=>Le(X.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")} ${X.name}`,children:s.jsx(Wt,{size:12})})]},X.id))}),s.jsx(br,{files:I,onRemove:z}),s.jsx("textarea",{ref:R,value:l,rows:v?1:void 0,onChange:ke,onKeyDown:Je,onPaste:Ue,onClick:X=>He(l,X.currentTarget.selectionStart),onSelect:X=>He(l,X.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:te("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}}),s.jsxs("div",{className:te("flex items-center justify-between",v?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{ref:D,type:"file",multiple:!0,className:"hidden",onChange:Ee}),s.jsx("button",{type:"button",onClick:()=>D.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:s.jsx(hr,{size:18})}),s.jsx("button",{type:"button",onClick:()=>{y(X=>!X),a(null),requestAnimationFrame(()=>R.current?.focus())},disabled:De.length===0&&(e.members??[]).length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:te("rounded-lg transition-colors",v?"p-1.5":"p-2",b?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",De.length===0&&(e.members??[]).length===0?"cursor-not-allowed opacity-50":""),children:s.jsx(hn,{size:v?15:18})}),De.length>0&&s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[De.length," ",i("selected")]})]}),s.jsx("button",{type:"button",onClick:()=>{be()},disabled:r||S||W||!l.trim()&&!V,title:i(W?"Uploading...":S?"发送中...":"发送"),"aria-label":i(W?"Uploading...":S?"发送中...":"发送"),className:te("rounded-lg transition-all duration-200",v?"p-1.5":"p-2",(l.trim()||V)&&!r&&!S&&!W?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",S||W?"opacity-70":""),children:s.jsx(wi,{size:v?15:18})})]}),E&&s.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:E})]})]})]})}function Xh(e){return e?e.slice(0,8):""}function Pn(e){const t=e?Date.parse(e):0;return Number.isNaN(t)?0:t}function ca(e,t){if(!e?.length)return[];const r=new Map((t?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),m=t?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,i=p.ownerMemberId?r.get(p.ownerMemberId):void 0,n=!!(m&&p.id===m),c=n?"main":p.parentWorkspaceId?"child":"root",f=i?.name??(p.ownerMemberId?`Member ${Xh(p.ownerMemberId)}`:void 0),l=n?"Main workspace":c==="child"?f?`${f} workspace`:"Child workspace":t?"Root workspace":"Workspace";return{workspace:p,kind:c,roleLabel:n?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:f,parentBranchName:v?.branchName,isMain:n}}).sort((p,v)=>{const i=c=>c.kind==="main"?0:c.kind==="child"?1:2,n=i(p)-i(v);return n!==0?n:Pn(p.workspace.createdAt)-Pn(v.workspace.createdAt)})}function da(e,t,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:t?.mainWorkspaceId&&e.some(o=>o.id===t.mainWorkspaceId)?t.mainWorkspaceId:e.find(o=>o.status===Et.ACTIVE)?.id??e[0]?.id}function Vh(e,t){return!e||e.status!==Et.ACTIVE?!1:!t||e.parentWorkspaceId?!0:!!(t.mainWorkspaceId&&e.id===t.mainWorkspaceId)}function Yh(e,t,r){return e?.parentWorkspaceId?t?.find(m=>m.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Gh=[],Qh=[],Zh=[];function Jh(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";default:return"idle"}}const On={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5};function Fr(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function In(e,t){return e instanceof Error?e.message:t}function ef(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"idle":return"Idle"}}function tf(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"idle":return"border-neutral-200 bg-white text-neutral-500"}}function sf(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"idle":return"bg-neutral-300"}}function rf(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function nf(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 of(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function af(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 lf(e){return[...e].sort((t,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(t.updatedAt??t.createdAt??""))}function cf(e,t){return t.find(r=>r.memberId===e.id&&yr.has(r.status))}function ua({teamRun:e,workspaces:t,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:m}){const{t:p}=ae(),v=Co(e.id),i=ko(e.id),n=Eo(e.id),[c,f]=C.useState(null),[l,g]=C.useState(null),[b,y]=C.useState(!1),_=e.members??Gh,a=e.workRequests??Qh,h=e.invocations??Zh,d=C.useMemo(()=>ca(t,e),[e,t]),u=C.useMemo(()=>new Map(a.map(N=>[N.id,N])),[a]),x=C.useMemo(()=>[...a].filter(N=>N.status==="PENDING_APPROVAL").sort((N,R)=>Date.parse(R.updatedAt??R.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")),[a]),S=C.useMemo(()=>[...a].filter(N=>N.status==="QUEUED").sort((N,R)=>Date.parse(R.updatedAt??R.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")),[a]),k=C.useMemo(()=>[..._].map(N=>({member:N,status:Jh(N.status)})).sort((N,R)=>On[N.status]-On[R.status]),[_]),E=v.isError?v.error:i.isError?i.error:null,w=v.isPending||i.isPending,j=d.find(N=>N.workspace.id===r),T=e.messages??[],L=k.filter(({status:N})=>N==="running"||N==="waiting room reply").length;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(cs,{size:14,className:"text-neutral-500 shrink-0"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),s.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:[s.jsx("span",{children:p("Team mode")}),s.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),s.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:[s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[s.jsx(Ai,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:T.length})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[s.jsx(Ss,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:L>0?`${L}/${_.length}`:_.length}),L>0&&s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),S.length>0&&s.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[s.jsx(es,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"tabular-nums",children:S.length})]}),x.length>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[s.jsx(es,{size:11}),s.jsx("span",{className:"tabular-nums",children:x.length})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[x.length>0&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[s.jsx(es,{size:13}),s.jsx("span",{children:p("Pending approval")}),s.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:x.length})]}),s.jsx("div",{className:"space-y-1.5",children:x.map(N=>{const R=_.find(F=>F.id===N.targetMemberId),D=v.isPending&&v.variables===N.id,I=i.isPending&&i.variables===N.id;return s.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[s.jsx("div",{className:"flex items-start justify-between gap-2",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Mt,{name:R?.name??"Agent",avatar:R?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:R?.name??N.targetMemberId})]}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:N.instruction})]})}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[s.jsx("span",{children:p(rf(N.requesterType))}),s.jsx("span",{children:Fr(N.createdAt)})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>v.mutate(N.id),disabled:w,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:[s.jsx(Rt,{size:11}),s.jsx("span",{className:"truncate",children:p(D?"Approving":"Approve")})]}),s.jsxs("button",{type:"button",onClick:()=>i.mutate(N.id),disabled:w,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:[s.jsx(Wt,{size:11}),s.jsx("span",{className:"truncate",children:p(I?"Rejecting":"Reject")})]})]})]},N.id)})}),E&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:In(E,p("Failed to update work request"))})]}),s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(Ss,{size:13}),s.jsx("span",{children:p("Members")}),s.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:_.length})]}),_.length===0?s.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):s.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:k.map(({member:N,status:R})=>{const D=cf(N,h),I=lf(h.filter(W=>W.memberId===N.id)),F=D?u.get(D.workRequestId):void 0,z=l===N.id,A=R==="running"||R==="waiting room reply",P=A&&!!D,O=c===N.id,B=n.isPending&&n.variables?.memberId===N.id;return s.jsxs("div",{className:te("bg-white",z&&"bg-neutral-50/50"),children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsx(Mt,{name:N.name,avatar:N.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:te("h-1.5 w-1.5 shrink-0 rounded-full",sf(R))}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:N.name}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",tf(R)),children:p(ef(R))})]}),A&&F?.instruction&&s.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:F.instruction})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[P&&s.jsx("button",{type:"button",onClick:()=>f(O?null:N.id),disabled:n.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:s.jsx(ns,{size:12})}),D?.sessionId&&m&&s.jsx("button",{type:"button",onClick:()=>m(D.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:s.jsx(Zs,{size:12})}),s.jsx("button",{type:"button",onClick:()=>g(z?null:N.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":z,children:z?s.jsx(vt,{size:13}):s.jsx(Tt,{size:13})})]})]}),P&&O&&s.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[s.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:N.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:n.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:[s.jsx(ns,{size:10}),s.jsx("span",{children:B&&n.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),s.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:N.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:n.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:[s.jsx(Oo,{size:10}),s.jsx("span",{children:B&&n.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),z&&s.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[s.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[s.jsx("span",{children:N.providerId}),s.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),s.jsx("span",{children:N.workspacePolicy}),s.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),s.jsx("span",{children:N.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),s.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:I.length})]}),I.length===0?s.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):s.jsx("div",{className:"space-y-1",children:I.map(W=>{const V=u.get(W.workRequestId),Q=!!(W.sessionId&&m);return s.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:te("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",nf(W.status)),children:W.status}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:Fr(W.updatedAt??W.createdAt)})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:V?.instruction??W.workRequestId})]}),Q&&s.jsxs("button",{type:"button",onClick:()=>W.sessionId&&m?.(W.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:[s.jsx(Zs,{size:10}),s.jsx("span",{children:p("Log")})]})]})},W.id)})})]}),k[k.length-1]?.member.id!==N.id&&!z&&s.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},N.id)})}),n.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:In(n.error,p("Failed to stop member work"))})]}),S.length>0&&s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(es,{size:13}),s.jsx("span",{children:p("Queue")}),s.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:S.length})]}),s.jsx("div",{className:"space-y-1",children:S.map(N=>{const R=_.find(D=>D.id===N.targetMemberId);return s.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Mt,{name:R?.name??"Agent",avatar:R?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:R?.name??N.targetMemberId})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:N.instruction})]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Fr(N.createdAt)})]})},N.id)})})]}),d.length>0&&s.jsxs("section",{className:"space-y-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>y(N=>!N),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":b,"aria-label":p("Workspaces"),children:[s.jsx(cs,{size:13}),s.jsx("span",{children:p("Workspaces")}),s.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[j&&s.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:j.workspace.branchName}),s.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:d.length}),b?s.jsx(vt,{size:13,className:"text-neutral-400"}):s.jsx(Tt,{size:13,className:"text-neutral-400"})]})]}),b&&s.jsx("div",{className:"space-y-1.5",children:d.map(N=>{const R=r===N.workspace.id;return s.jsx("div",{className:te("rounded-md border bg-white px-3 py-2",R?"border-neutral-400 shadow-sm":"border-neutral-200"),children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(N.displayName)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",af(N.roleLabel)),children:p(N.roleLabel)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",of(N.workspace.status)),children:N.workspace.status})]}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:N.workspace.branchName}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[N.ownerName&&s.jsxs("span",{children:[p("Owner"),": ",N.ownerName]}),N.parentBranchName&&s.jsxs("span",{children:[p("Parent"),": ",N.parentBranchName]})]})]}),s.jsxs("button",{type:"button",onClick:()=>o?.(N.workspace.id),disabled:!o||R,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:[R?s.jsx(Rt,{size:11}):s.jsx(ji,{size:11}),s.jsx("span",{children:p(R?"Selected":"Select")})]})]})},N.workspace.id)})})]}),x.length===0&&S.length===0&&k.every(({status:N})=>N==="idle")&&s.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var zr={exports:{}},Bn;function df(){return Bn||(Bn=1,(function(e,t){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,i,n){var c=this&&this.__decorate||function(u,x,S,k){var E,w=arguments.length,j=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,x,S,k);else for(var T=u.length-1;T>=0;T--)(E=u[T])&&(j=(w<3?E(j):w>3?E(x,S,j):E(x,S))||j);return w>3&&j&&Object.defineProperty(x,S,j),j},f=this&&this.__param||function(u,x){return function(S,k){x(S,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const l=n(9042),g=n(6114),b=n(9924),y=n(844),_=n(5596),a=n(4725),h=n(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(u,x){super(),this._terminal=u,this._renderService=x,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 b.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(`
|
|
19
|
+
`)))),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 _.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(u){for(let x=0;x<u;x++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
|
|
20
|
+
`&&(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(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,x){this._liveRegionDebouncer.refresh(u,x,this._terminal.rows)}_renderRows(u,x){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=u;E<=x;E++){const w=S.translateBufferLineToString(S.ydisp+E,!0),j=(S.ydisp+E+1).toString(),T=this._rowElements[E];T&&(w.length===0?T.innerText=" ":T.textContent=w,T.setAttribute("aria-posinset",j),T.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,x){const S=u.target,k=this._rowElements[x===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==k)return;let E,w;if(x===0?(E=S,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(E=this._rowElements.shift(),w=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),x===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(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_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 u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=c([f(1,a.IRenderService)],d)},3614:(v,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function c(g,b){return b?"\x1B[200~"+g+"\x1B[201~":g}function f(g,b,y,_){g=c(g=n(g),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),b.value=""}function l(g,b,y){const _=y.getBoundingClientRect(),a=g.clientX-_.left-10,h=g.clientY-_.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${a}px`,b.style.top=`${h}px`,b.style.zIndex="1000",b.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=c,i.copyHandler=function(g,b){g.clipboardData&&g.clipboardData.setData("text/plain",b.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,b,y,_){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),b,y,_)},i.paste=f,i.moveTextAreaUnderMouseCursor=l,i.rightClickHandler=function(g,b,y,_,a){l(g,b,y),a&&_.rightClickSelect(g),b.value=_.selectionText,b.select()}},7239:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=n(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,l,g){this._css.set(f,l,g)}getCss(f,l){return this._css.get(f,l)}setColor(f,l,g){this._color.set(f,l,g)}getColor(f,l){return this._color.get(f,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,c,f,l){n.addEventListener(c,f,l);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(c,f,l))}}}},6465:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(x=a[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const l=n(3656),g=n(8460),b=n(844),y=n(2585);let _=i.Linkifier2=class extends b.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,b.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,b.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 u=0;u<d.length;u++){const x=d[u];if(x.classList.contains("xterm"))break;if(x.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,u;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 x=!1;for(const[S,k]of this._linkProviders.entries())h?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(S)&&(x=this._checkLinkProviderResult(S,a,x)):k.provideLinks(a.y,(E=>{var w,j;if(this._isMouseOut)return;const T=E?.map((L=>({link:L})));(w=this._activeProviderReplies)===null||w===void 0||w.set(S,T),x=this._checkLinkProviderResult(S,a,x),((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 u=0;u<h.size;u++){const x=h.get(u);if(x)for(let S=0;S<x.length;S++){const k=x[S],E=k.link.range.start.y<a?0:k.link.range.start.x,w=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=w;j++){if(d.has(j)){x.splice(S--,1);break}d.add(j)}}}}_checkLinkProviderResult(a,h,d){var u;if(!this._activeProviderReplies)return d;const x=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&&x){const k=x.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=(u=this._activeProviderReplies.get(k))===null||u===void 0?void 0:u.find((w=>this._linkAtPosition(w.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,b.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,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:d=>{var u,x;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((x=this._element)===null||x===void 0||x.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.underline},set:d=>{var u,x,S;!((u=this._currentLink)===null||u===void 0)&&u.state&&((S=(x=this._currentLink)===null||x===void 0?void 0:x.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 u=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,x=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=x&&(this._clearCurrentLink(u,x),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(a,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=this._bufferService.buffer.ydisp,x=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-u-1,d.end.x,d.end.y-u-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(x)}_linkLeave(a,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.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,u=a.range.end.y*this._bufferService.cols+a.range.end.x,x=h.y*this._bufferService.cols+h.x;return d<=x&&x<=u}_positionFromMouseEvent(a,h,d){const u=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,u,x){return{x1:a,y1:h,x2:d,y2:u,cols:this._bufferService.cols,fg:x}}};i.Linkifier2=_=c([f(0,y.IBufferService)],_)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,n){var c=this&&this.__decorate||function(_,a,h,d){var u,x=arguments.length,S=x<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,a,h,d);else for(var k=_.length-1;k>=0;k--)(u=_[k])&&(S=(x<3?u(S):x>3?u(a,h,S):u(a,h))||S);return x>3&&S&&Object.defineProperty(a,h,S),S},f=this&&this.__param||function(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const l=n(511),g=n(2585);let b=i.OscLinkProvider=class{constructor(_,a,h){this._bufferService=_,this._optionsService=a,this._oscLinkService=h}provideLinks(_,a){var h;const d=this._bufferService.buffer.lines.get(_-1);if(!d)return void a(void 0);const u=[],x=this._optionsService.rawOptions.linkHandler,S=new l.CellData,k=d.getTrimmedLength();let E=-1,w=-1,j=!1;for(let T=0;T<k;T++)if(w!==-1||d.hasContent(T)){if(d.loadCell(T,S),S.hasExtendedAttrs()&&S.extended.urlId){if(w===-1){w=T,E=S.extended.urlId;continue}j=S.extended.urlId!==E}else w!==-1&&(j=!0);if(j||w!==-1&&T===k-1){const L=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(L){const N={start:{x:w+1,y:_},end:{x:T+(j||T!==k-1?0:1),y:_}};let R=!1;if(!x?.allowNonHttpProtocols)try{const D=new URL(L);["http:","https:"].includes(D.protocol)||(R=!0)}catch{R=!0}R||u.push({text:L,range:N,activate:(D,I)=>x?x.activate(D,I,N):y(0,I),hover:(D,I)=>{var F;return(F=x?.hover)===null||F===void 0?void 0:F.call(x,D,I,N)},leave:(D,I)=>{var F;return(F=x?.leave)===null||F===void 0?void 0:F.call(x,D,I,N)}})}j=!1,S.hasExtendedAttrs()&&S.extended.urlId?(w=T,E=S.extended.urlId):(w=-1,E=-1)}}a(u)}};function y(_,a){if(confirm(`Do you want to navigate to ${a}?
|
|
21
21
|
|
|
22
|
-
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")}}i.OscLinkProvider=x=c([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],x)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,c){this._parentWindow=n,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,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 n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=n(844);class f 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)}}i.ScreenDprMonitor=f},3236:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=n(3614),f=n(3656),l=n(6465),g=n(9042),x=n(3730),y=n(1680),_=n(3107),a=n(5744),h=n(2950),d=n(1296),u=n(428),b=n(4269),S=n(5114),E=n(8934),j=n(3230),w=n(9312),k=n(4725),N=n(6731),L=n(8055),R=n(8969),M=n(8460),D=n(844),I=n(6114),F=n(8437),z=n(2584),A=n(7399),P=n(5941),O=n(9074),B=n(2585),$=n(5435),Y=n(4567),Q=typeof window<"u"?window.document:null;class Z extends R.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(T={}){super(T),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new D.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,U)=>this.refresh(H,U)))),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,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,D.toDisposable)((()=>{var H,U;this._customKeyEventHandler=void 0,(U=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||U===void 0||U.removeChild(this.element)})))}_handleColorEvent(T){if(this._themeService)for(const H of T){let U,W="";switch(H.index){case 256:U="foreground",W="10";break;case 257:U="background",W="11";break;case 258:U="cursor",W="12";break;default:U="ansi",W="4;"+H.index}switch(H.type){case 0:const se=L.color.toColorRGB(U==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[U]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,P.toRgbString)(se)}${z.C1_ESCAPED.ST}`);break;case 1:if(U==="ansi")this._themeService.modifyColors((K=>K.ansi[H.index]=L.rgba.toColor(...H.color)));else{const K=U;this._themeService.modifyColors((ce=>ce[K]=L.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(T){T?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(T){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(T),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var T;return(T=this.textarea)===null||T===void 0?void 0:T.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 T=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(T);if(!H)return;const U=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,se=H.getWidth(U),K=this._renderService.dimensions.css.cell.width*se,ce=this.buffer.y*this._renderService.dimensions.css.cell.height,pe=U*this._renderService.dimensions.css.cell.width;this.textarea.style.left=pe+"px",this.textarea.style.top=ce+"px",this.textarea.style.width=K+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const T=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",T)),this.register((0,f.addDisposableDomListener)(this.element,"paste",T)),I.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(T=>this._keyUp(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(T=>this._keyDown(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(T=>this._keyPress(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(T=>this._compositionHelper.compositionupdate(T)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(T=>this._inputEvent(T)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(T){var H;if(!T)throw new Error("Terminal requires a parent element.");T.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=T.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),T.appendChild(this.element);const U=Q.createDocumentFragment();this._viewportElement=Q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),U.appendChild(this._viewportElement),this._viewportScrollArea=Q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=Q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=Q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),U.appendChild(this.screenElement),this.textarea=Q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.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(k.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(k.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(k.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(k.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(k.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=Q.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(U);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(E.MouseService),this._instantiationService.setService(k.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(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(k.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,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,f.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(Y.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 T=this,H=this.element;function U(K){const ce=T._mouseService.getMouseReportCoords(K,T.screenElement);if(!ce)return!1;let pe,be;switch(K.overrideType||K.type){case"mousemove":be=32,K.buttons===void 0?(pe=3,K.button!==void 0&&(pe=K.button<3?K.button:3)):pe=1&K.buttons?0:4&K.buttons?1:2&K.buttons?2:3;break;case"mouseup":be=0,pe=K.button<3?K.button:3;break;case"mousedown":be=1,pe=K.button<3?K.button:3;break;case"wheel":if(T.viewport.getLinesScrolled(K)===0)return!1;be=K.deltaY<0?0:1,pe=4;break;default:return!1}return!(be===void 0||pe===void 0||pe>4)&&T.coreMouseService.triggerMouseEvent({col:ce.col,row:ce.row,x:ce.x,y:ce.y,button:pe,action:be,ctrl:K.ctrlKey,alt:K.altKey,shift:K.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:K=>(U(K),K.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(K)),wheel:K=>(U(K),this.cancel(K,!0)),mousedrag:K=>{K.buttons&&U(K)},mousemove:K=>{K.buttons||U(K)}};this.register(this.coreMouseService.onProtocolChange((K=>{K?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(K)),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&K?W.mousemove||(H.addEventListener("mousemove",se.mousemove),W.mousemove=se.mousemove):(H.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&K?W.wheel||(H.addEventListener("wheel",se.wheel,{passive:!1}),W.wheel=se.wheel):(H.removeEventListener("wheel",W.wheel),W.wheel=null),2&K?W.mouseup||(H.addEventListener("mouseup",se.mouseup),W.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),H.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&K?W.mousedrag||(W.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(H,"mousedown",(K=>{if(K.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(K))return U(K),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(K)}))),this.register((0,f.addDisposableDomListener)(H,"wheel",(K=>{if(!W.wheel){if(!this.buffer.hasScrollback){const ce=this.viewport.getLinesScrolled(K);if(ce===0)return;const pe=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(K.deltaY<0?"A":"B");let be="";for(let De=0;De<Math.abs(ce);De++)be+=pe;return this.coreService.triggerDataEvent(be,!0),this.cancel(K,!0)}return this.viewport.handleWheel(K)?this.cancel(K):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(H,"touchstart",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(K),this.cancel(K)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(H,"touchmove",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(K)?void 0:this.cancel(K)}),{passive:!1}))}refresh(T,H){var U;(U=this._renderService)===null||U===void 0||U.refreshRows(T,H)}updateCursorStyle(T){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(T)?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(T,H,U=0){var W;U===1?(super.scrollLines(T,H,U),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(T)}paste(T){(0,c.paste)(T,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(T){this._customKeyEventHandler=T}registerLinkProvider(T){return this.linkifier2.registerLinkProvider(T)}registerCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(T);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(T)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(T){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+T)}registerDecoration(T){return this._decorationService.registerDecoration(T)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(T,H,U){this._selectionService.setSelection(T,H,U)}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 T;(T=this._selectionService)===null||T===void 0||T.clearSelection()}selectAll(){var T;(T=this._selectionService)===null||T===void 0||T.selectAll()}selectLines(T,H){var U;(U=this._selectionService)===null||U===void 0||U.selectLines(T,H)}_keyDown(T){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&T.altKey;if(!H&&!this._compositionHelper.keydown(T))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||T.key!=="Dead"&&T.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const U=(0,A.evaluateKeyboardEvent)(T,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(T),U.type===3||U.type===2){const W=this.rows-1;return this.scrollLines(U.type===2?-W:W),this.cancel(T,!0)}return U.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,T)||(U.cancel&&this.cancel(T,!0),!U.key||!!(T.key&&!T.ctrlKey&&!T.altKey&&!T.metaKey&&T.key.length===1&&T.key.charCodeAt(0)>=65&&T.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(U.key!==z.C0.ETX&&U.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:U.key,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(U.key,!0),!this.optionsService.rawOptions.screenReaderMode||T.altKey||T.ctrlKey?this.cancel(T,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(T,H){const U=T.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||T.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||T.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?U:U&&(!H.keyCode||H.keyCode>47)}_keyUp(T){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(T)||this.focus(),this.updateCursorStyle(T),this._keyPressHandled=!1)}_keyPress(T){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;if(this.cancel(T),T.charCode)H=T.charCode;else if(T.which===null||T.which===void 0)H=T.keyCode;else{if(T.which===0||T.charCode===0)return!1;H=T.which}return!(!H||(T.altKey||T.ctrlKey||T.metaKey)&&!this._isThirdLevelShift(this.browser,T)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(T){if(T.data&&T.inputType==="insertText"&&(!T.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=T.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(T),!0}return!1}resize(T,H){T!==this.cols||H!==this.rows?super.resize(T,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(T,H){var U,W;(U=this._charSizeService)===null||U===void 0||U.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var T;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}),(T=this.viewport)===null||T===void 0||T.reset(),this.refresh(0,this.rows-1)}}reset(){var T,H;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(T=this._selectionService)===null||T===void 0||T.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var T;(T=this._renderService)===null||T===void 0||T.clearTextureAtlas()}_reportFocus(){var T;!((T=this.element)===null||T===void 0)&&T.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(T){if(this._renderService)switch(T){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),U=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${U};${H}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${se};${W}t`)}}cancel(T,H){if(this.options.cancelEvents||H)return T.preventDefault(),T.stopPropagation(),!1}}i.Terminal=Z},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,c=1e3){this._renderCallback=n,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,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,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c)}}},1680:function(v,i,n){var c=this&&this.__decorate||function(h,d,u,b){var S,E=arguments.length,j=E<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,u):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,u,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(E<3?S(j):E>3?S(d,u,j):S(d,u))||j);return E>3&&j&&Object.defineProperty(d,u,j),j},f=this&&this.__param||function(h,d){return function(u,b){d(u,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const l=n(3656),g=n(4725),x=n(8460),y=n(844),_=n(2585);let a=i.Viewport=class extends y.Disposable{constructor(h,d,u,b,S,E,j,w){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=u,this._optionsService=b,this._charSizeService=S,this._renderService=E,this._coreBrowserService=j,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 x.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((k=>this._activeBuffer=k.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((k=>this._renderDimensions=k))),this._handleThemeChange(w.colors),this.register(w.onChangeColors((k=>this._handleThemeChange(k)))),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 u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&u<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 u;let b,S="";const E=[],j=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let k=h;k<j;k++){const N=w.get(k);if(!N)continue;const L=(u=w.get(k+1))===null||u===void 0?void 0:u.isWrapped;if(S+=N.translateToString(!L),!L||k===w.length-1){const R=document.createElement("div");R.textContent=S,E.push(R),S.length>0&&(b=R),S=""}}return{bufferElements:E,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 u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&d.altKey||u==="ctrl"&&d.ctrlKey||u==="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))}};i.Viewport=a=c([f(2,_.IBufferService),f(3,_.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],a)},3107:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var b,S=arguments.length,E=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(a,h,d,u);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(E=(S<3?b(E):S>3?b(h,d,E):b(h,d))||E);return S>3&&E&&Object.defineProperty(h,d,E),E},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const l=n(3656),g=n(4725),x=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,d,u){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=u,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,x.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 u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),u.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.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&&(u.style.display="none"),this._refreshXPosition(a,u),u}_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 u=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=u?u*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()}};i.BufferDecorationRenderer=_=c([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,g.IRenderService)],_)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.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(n){if(n.options.overviewRulerOptions){for(const c of this._zones)if(c.color===n.options.overviewRulerOptions.color&&c.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,n.marker.line))return;if(this._lineAdjacentToZone(c,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(c,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,c){return c>=n.startBufferLine&&c<=n.endBufferLine}_lineAdjacentToZone(n,c,f){return c>=n.startBufferLine-this._linePadding[f||"full"]&&c<=n.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(n,c){n.startBufferLine=Math.min(n.startBufferLine,c),n.endBufferLine=Math.max(n.endBufferLine,c)}}},5744:function(v,i,n){var c=this&&this.__decorate||function(b,S,E,j){var w,k=arguments.length,N=k<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,S,E,j);else for(var L=b.length-1;L>=0;L--)(w=b[L])&&(N=(k<3?w(N):k>3?w(S,E,N):w(S,E))||N);return k>3&&N&&Object.defineProperty(S,E,N),N},f=this&&this.__param||function(b,S){return function(E,j){S(E,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const l=n(5871),g=n(3656),x=n(4725),y=n(844),_=n(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 u=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,S,E,j,w,k,N){var L;super(),this._viewportElement=b,this._screenElement=S,this._bufferService=E,this._decorationService=j,this._renderService=w,this._optionsService=k,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(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var M;(M=this._canvas)===null||M===void 0||M.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})))}};i.OverviewRulerRenderer=u=c([f(2,_.IBufferService),f(3,_.IDecorationService),f(4,x.IRenderService),f(5,_.IOptionsService),f(6,x.ICoreBrowserService)],u)},2950:function(v,i,n){var c=this&&this.__decorate||function(_,a,h,d){var u,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(_,a,h,d);else for(var E=_.length-1;E>=0;E--)(u=_[E])&&(S=(b<3?u(S):b>3?u(a,h,S):u(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},f=this&&this.__param||function(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const l=n(4725),g=n(2585),x=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,a,h,d,u,b){this._textarea=_,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=u,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){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 _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(_,"");this._dataAlreadySent=h,a.length>_.length?this._coreService.triggerDataEvent(h,!0):a.length<_.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===_.length&&a!==_&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(_){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,u=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"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=u+"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"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=c([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,l.IRenderService)],y)},9806:(v,i)=>{function n(c,f,l){const g=l.getBoundingClientRect(),x=c.getComputedStyle(l),y=parseInt(x.getPropertyValue("padding-left")),_=parseInt(x.getPropertyValue("padding-top"));return[f.clientX-g.left-y,f.clientY-g.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(c,f,l,g,x,y,_,a,h){if(!y)return;const d=n(c,f,l);return d?(d[0]=Math.ceil((d[0]+(h?_/2:0))/_),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),x),d):void 0}},9504:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=n(2584);function f(a,h,d,u){const b=a-l(a,d),S=h-l(h,d),E=Math.abs(b-S)-(function(j,w,k){let N=0;const L=j-l(j,k),R=w-l(w,k);for(let M=0;M<Math.abs(L-R);M++){const D=g(j,w)==="A"?-1:1,I=k.buffer.lines.get(L+D*M);I?.isWrapped&&N++}return N})(a,h,d);return _(E,y(g(a,h),u))}function l(a,h){let d=0,u=h.buffer.lines.get(a),b=u?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,u=h.buffer.lines.get(--a),b=u?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function x(a,h,d,u,b,S){let E=a,j=h,w="";for(;E!==d||j!==u;)E+=b?1:-1,b&&E>S.cols-1?(w+=S.buffer.translateBufferLineToString(j,!1,a,E),E=0,a=0,j++):!b&&E<0&&(w+=S.buffer.translateBufferLineToString(j,!1,0,a+1),E=S.cols-1,a=E,j--);return w+S.buffer.translateBufferLineToString(j,!1,a,E)}function y(a,h){const d=h?"O":"[";return c.C0.ESC+d+a}function _(a,h){a=Math.floor(a);let d="";for(let u=0;u<a;u++)d+=h;return d}i.moveToCellSequence=function(a,h,d,u){const b=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,k,N,L,R,M){return f(k,L,R,M).length===0?"":_(x(w,k,w,k-l(k,R),!1,R).length,y("D",M))})(b,S,0,h,d,u)+f(S,h,d,u)+(function(w,k,N,L,R,M){let D;D=f(k,L,R,M).length>0?L-l(L,R):k;const I=L,F=(function(z,A,P,O,B,$){let Y;return Y=f(P,O,B,$).length>0?O-l(O,B):A,z<P&&Y<=O||z>=P&&Y<O?"C":"D"})(w,k,N,L,R,M);return _(x(w,D,N,I,F==="C",R).length,y(F,M))})(b,S,a,h,d,u);let E;if(S===h)return E=b>a?"D":"C",_(Math.abs(b-a),y(E,u));E=S>h?"D":"C";const j=Math.abs(S-h);return _((function(w,k){return k.cols-w})(S>h?a:b,d)+(j-1)*d.cols+1+((S>h?b:a)-1),y(E,u))}},1296:function(v,i,n){var c=this&&this.__decorate||function(R,M,D,I){var F,z=arguments.length,A=z<3?M:I===null?I=Object.getOwnPropertyDescriptor(M,D):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(R,M,D,I);else for(var P=R.length-1;P>=0;P--)(F=R[P])&&(A=(z<3?F(A):z>3?F(M,D,A):F(M,D))||A);return z>3&&A&&Object.defineProperty(M,D,A),A},f=this&&this.__param||function(R,M){return function(D,I){M(D,I,R)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const l=n(3787),g=n(2550),x=n(2223),y=n(6171),_=n(4725),a=n(8055),h=n(8460),d=n(844),u=n(2585),b="xterm-dom-renderer-owner-",S="xterm-rows",E="xterm-fg-",j="xterm-bg-",w="xterm-focus",k="xterm-selection";let N=1,L=i.DomRenderer=class extends d.Disposable{constructor(R,M,D,I,F,z,A,P,O,B){super(),this._element=R,this._screenElement=M,this._viewportElement=D,this._linkifier2=I,this._charSizeService=z,this._optionsService=A,this._bufferService=P,this._coreBrowserService=O,this._themeService=B,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(k),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(($=>this._injectCss($)))),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(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),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 R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),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/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),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 D of this._rowElements)D.style.width=`${this.dimensions.css.canvas.width}px`,D.style.height=`${this.dimensions.css.cell.height}px`,D.style.lineHeight=`${this.dimensions.css.cell.height}px`,D.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${S} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${S} .xterm-dim { color: ${a.color.multiplyOpacity(R.foreground,.5).css};}`,M+=`${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;}`,M+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",M+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,M+=`${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${w} .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: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${k} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${k} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${k} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[D,I]of R.ansi.entries())M+=`${this._terminalSelector} .${E}${D} { color: ${I.css}; }${this._terminalSelector} .${E}${D}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${j}${D} { background-color: ${I.css}; }`;M+=`${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(R.background).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${j}${x.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,M){for(let D=this._rowElements.length;D<=M;D++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,M){this._refreshRowElements(R,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,M,D){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,M,D),this.renderRows(0,this._bufferService.rows-1),!R||!M)return;const I=R[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,z=Math.max(I,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(D){const O=R[0]>M[0];P.appendChild(this._createSelectionElement(z,O?M[0]:R[0],O?R[0]:M[0],A-z+1))}else{const O=I===z?R[0]:0,B=z===F?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,O,B));const $=A-z-1;if(P.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,$)),z!==A){const Y=F===A?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,Y))}}this._selectionContainer.appendChild(P)}_createSelectionElement(R,M,D,I=1){const F=document.createElement("div");return F.style.height=I*this.dimensions.css.cell.height+"px",F.style.top=R*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(D-M)+"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 R of this._rowElements)R.replaceChildren()}renderRows(R,M){const D=this._bufferService.buffer,I=D.ybase+D.y,F=Math.min(D.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=R;O<=M;O++){const B=O+D.ydisp,$=this._rowElements[O],Y=D.lines.get(B);if(!$||!Y)break;$.replaceChildren(...this._rowFactory.createRow(Y,B,B===I,A,P,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,M,D,I,F,z){D<0&&(R=0),I<0&&(M=0);const A=this._bufferService.rows-1;D=Math.max(Math.min(D,A),0),I=Math.max(Math.min(I,A),0),F=Math.min(F,this._bufferService.cols);const P=this._bufferService.buffer,O=P.ybase+P.y,B=Math.min(P.x,F-1),$=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=D;Z<=I;++Z){const he=Z+P.ydisp,T=this._rowElements[Z],H=P.lines.get(he);if(!T||!H)break;T.replaceChildren(...this._rowFactory.createRow(H,he,he===O,Y,Q,B,$,this.dimensions.css.cell.width,this._widthCache,z?Z===D?R:0:-1,z?(Z===I?M:F)-1:-1))}}};i.DomRenderer=L=c([f(4,u.IInstantiationService),f(5,_.ICharSizeService),f(6,u.IOptionsService),f(7,u.IBufferService),f(8,_.ICoreBrowserService),f(9,_.IThemeService)],L)},3787:function(v,i,n){var c=this&&this.__decorate||function(E,j,w,k){var N,L=arguments.length,R=L<3?j:k===null?k=Object.getOwnPropertyDescriptor(j,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(E,j,w,k);else for(var M=E.length-1;M>=0;M--)(N=E[M])&&(R=(L<3?N(R):L>3?N(j,w,R):N(j,w))||R);return L>3&&R&&Object.defineProperty(j,w,R),R},f=this&&this.__param||function(E,j){return function(w,k){j(w,k,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const l=n(2223),g=n(643),x=n(511),y=n(2585),_=n(8055),a=n(4725),h=n(4269),d=n(6171),u=n(3734);let b=i.DomRendererRowFactory=class{constructor(E,j,w,k,N,L,R){this._document=E,this._characterJoinerService=j,this._optionsService=w,this._coreBrowserService=k,this._coreService=N,this._decorationService=L,this._themeService=R,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(E,j,w){this._selectionStart=E,this._selectionEnd=j,this._columnSelectMode=w}createRow(E,j,w,k,N,L,R,M,D,I,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(j),P=this._themeService.colors;let O,B=E.getNoBgTrimmedLength();w&&B<L+1&&(B=L+1);let $=0,Y="",Q=0,Z=0,he=0,T=!1,H=0,U=!1,W=0;const se=[],K=I!==-1&&F!==-1;for(let ce=0;ce<B;ce++){E.loadCell(ce,this._workCell);let pe=this._workCell.getWidth();if(pe===0)continue;let be=!1,De=ce,ne=this._workCell;if(A.length>0&&ce===A[0][0]){be=!0;const ee=A.shift();ne=new h.JoinedCellData(this._workCell,E.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),De=ee[1]-1,pe=ne.getWidth()}const _e=this._isCellInSelection(ce,j),He=w&&ce===L,we=K&&ce>=I&&ce<=F;let Le=!1;this._decorationService.forEachDecorationAtCell(ce,j,void 0,(ee=>{Le=!0}));let ke=ne.getChars()||g.WHITESPACE_CELL_CHAR;if(ke===" "&&(ne.isUnderline()||ne.isOverline())&&(ke=" "),W=pe*M-D.get(ke,ne.isBold(),ne.isItalic()),O){if($&&(_e&&U||!_e&&!U&&ne.bg===Q)&&(_e&&U&&P.selectionForeground||ne.fg===Z)&&ne.extended.ext===he&&we===T&&W===H&&!He&&!be&&!Le){Y+=ke,$++;continue}$&&(O.textContent=Y),O=this._document.createElement("span"),$=0,Y=""}else O=this._document.createElement("span");if(Q=ne.bg,Z=ne.fg,he=ne.extended.ext,T=we,H=W,U=_e,be&&L>=ce&&L<=De&&(L=ce),!this._coreService.isCursorHidden&&He){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&se.push("xterm-cursor-blink"),se.push(k==="bar"?"xterm-cursor-bar":k==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(ne.isBold()&&se.push("xterm-bold"),ne.isItalic()&&se.push("xterm-italic"),ne.isDim()&&se.push("xterm-dim"),Y=ne.isInvisible()?g.WHITESPACE_CELL_CHAR:ne.getChars()||g.WHITESPACE_CELL_CHAR,ne.isUnderline()&&(se.push(`xterm-underline-${ne.extended.underlineStyle}`),Y===" "&&(Y=" "),!ne.isUnderlineColorDefault()))if(ne.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(ne.getUnderlineColor()).join(",")})`;else{let ee=ne.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ne.isBold()&&ee<8&&(ee+=8),O.style.textDecorationColor=P.ansi[ee].css}ne.isOverline()&&(se.push("xterm-overline"),Y===" "&&(Y=" ")),ne.isStrikethrough()&&se.push("xterm-strikethrough"),we&&(O.style.textDecoration="underline");let Ee=ne.getFgColor(),Ue=ne.getFgColorMode(),ye=ne.getBgColor(),Je=ne.getBgColorMode();const Ce=!!ne.isInverse();if(Ce){const ee=Ee;Ee=ye,ye=ee;const fe=Ue;Ue=Je,Je=fe}let Ne,tt,X,J=!1;switch(this._decorationService.forEachDecorationAtCell(ce,j,void 0,(ee=>{ee.options.layer!=="top"&&J||(ee.backgroundColorRGB&&(Je=50331648,ye=ee.backgroundColorRGB.rgba>>8&16777215,Ne=ee.backgroundColorRGB),ee.foregroundColorRGB&&(Ue=50331648,Ee=ee.foregroundColorRGB.rgba>>8&16777215,tt=ee.foregroundColorRGB),J=ee.options.layer==="top")})),!J&&_e&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,ye=Ne.rgba>>8&16777215,Je=50331648,J=!0,P.selectionForeground&&(Ue=50331648,Ee=P.selectionForeground.rgba>>8&16777215,tt=P.selectionForeground)),J&&se.push("xterm-decoration-top"),Je){case 16777216:case 33554432:X=P.ansi[ye],se.push(`xterm-bg-${ye}`);break;case 50331648:X=_.rgba.toColor(ye>>16,ye>>8&255,255&ye),this._addStyle(O,`background-color:#${S((ye>>>0).toString(16),"0",6)}`);break;default:Ce?(X=P.foreground,se.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):X=P.background}switch(Ne||ne.isDim()&&(Ne=_.color.multiplyOpacity(X,.5)),Ue){case 16777216:case 33554432:ne.isBold()&&Ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ee+=8),this._applyMinimumContrast(O,X,P.ansi[Ee],ne,Ne,void 0)||se.push(`xterm-fg-${Ee}`);break;case 50331648:const ee=_.rgba.toColor(Ee>>16&255,Ee>>8&255,255&Ee);this._applyMinimumContrast(O,X,ee,ne,Ne,tt)||this._addStyle(O,`color:#${S(Ee.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,X,P.foreground,ne,Ne,void 0)||Ce&&se.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}se.length&&(O.className=se.join(" "),se.length=0),He||be||Le?O.textContent=Y:$++,W!==this.defaultSpacing&&(O.style.letterSpacing=`${W}px`),z.push(O),ce=De}return O&&$&&(O.textContent=Y),z}_applyMinimumContrast(E,j,w,k,N,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(k.getCode()))return!1;const R=this._getContrastCache(k);let M;if(N||L||(M=R.getColor(j.rgba,w.rgba)),M===void 0){const D=this._optionsService.rawOptions.minimumContrastRatio/(k.isDim()?2:1);M=_.color.ensureContrastRatio(N||j,L||w,D),R.setColor((N||j).rgba,(L||w).rgba,M??null)}return!!M&&(this._addStyle(E,`color:${M.css}`),!0)}_getContrastCache(E){return E.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(E,j){E.setAttribute("style",`${E.getAttribute("style")||""}${j};`)}_isCellInSelection(E,j){const w=this._selectionStart,k=this._selectionEnd;return!(!w||!k)&&(this._columnSelectMode?w[0]<=k[0]?E>=w[0]&&j>=w[1]&&E<k[0]&&j<=k[1]:E<w[0]&&j>=w[1]&&E>=k[0]&&j<=k[1]:j>w[1]&&j<k[1]||w[1]===k[1]&&j===w[1]&&E>=w[0]&&E<k[0]||w[1]<k[1]&&j===k[1]&&E<k[0]||w[1]<k[1]&&j===w[1]&&E>=w[0])}};function S(E,j,w){for(;E.length<w;)E=j+E;return E}i.DomRendererRowFactory=b=c([f(1,a.ICharacterJoinerService),f(2,y.IOptionsService),f(3,a.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,a.IThemeService)],b)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.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=n.createElement("span"),f=n.createElement("span");f.style.fontWeight="bold";const l=n.createElement("span");l.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,f,l,g],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(l),this._container.appendChild(g),n.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(n,c,f,l){n===this._font&&c===this._fontSize&&f===this._weight&&l===this._weightBold||(this._font=n,this._fontSize=c,this._weight=f,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(n,c,f){let l=0;if(!c&&!f&&n.length===1&&(l=n.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(n,0);let g=n;c&&(g+="B"),f&&(g+="I");let x=this._holey.get(g);if(x===void 0){let y=0;c&&(y|=1),f&&(y|=2),x=this._measure(n,y),this._holey.set(g,x)}return x}_measure(n,c){const f=this._measureElements[c];return f.textContent=n.repeat(32),f.offsetWidth/32}}},2223:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function n(c){return 57508<=c&&c<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return n(c)||(function(f){return 9472<=f&&f<=9631})(c)},i.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,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,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 n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,c=this.selectionEnd;return!(!n||!c)&&(n[1]>c[1]||n[1]===c[1]&&n[0]>c[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var b,S=arguments.length,E=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(a,h,d,u);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(E=(S<3?b(E):S>3?b(h,d,E):b(h,d))||E);return S>3&&E&&Object.defineProperty(h,d,E),E},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const l=n(2585),g=n(8460),x=n(844);let y=i.CharSizeService=class extends x.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 _(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())}};i.CharSizeService=y=c([f(2,l.IOptionsService)],y);class _{constructor(h,d,u){this._document=h,this._parentElement=d,this._optionsService=u,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,i,n){var c=this&&this.__decorate||function(h,d,u,b){var S,E=arguments.length,j=E<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,u):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,u,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(E<3?S(j):E>3?S(d,u,j):S(d,u))||j);return E>3&&j&&Object.defineProperty(d,u,j),j},f=this&&this.__param||function(h,d){return function(u,b){d(u,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const l=n(3734),g=n(643),x=n(511),y=n(2585);class _ extends l.AttributeData{constructor(d,u,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=u,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()]}}i.JoinedCellData=_;let a=i.CharacterJoinerService=class ha{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const u={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(u),u.id}deregister(d){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===d)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(d);if(!u||u.length===0)return[];const b=[],S=u.translateToString(!0);let E=0,j=0,w=0,k=u.getFg(0),N=u.getBg(0);for(let L=0;L<u.getTrimmedLength();L++)if(u.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==k||this._workCell.bg!==N){if(L-E>1){const R=this._getJoinedRanges(S,w,j,u,E);for(let M=0;M<R.length;M++)b.push(R[M])}E=L,w=j,k=this._workCell.fg,N=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-E>1){const L=this._getJoinedRanges(S,w,j,u,E);for(let R=0;R<L.length;R++)b.push(L[R])}return b}_getJoinedRanges(d,u,b,S,E){const j=d.substring(u,b);let w=[];try{w=this._characterJoiners[0].handler(j)}catch(k){console.error(k)}for(let k=1;k<this._characterJoiners.length;k++)try{const N=this._characterJoiners[k].handler(j);for(let L=0;L<N.length;L++)ha._mergeRanges(w,N[L])}catch(N){console.error(N)}return this._stringRangesToCellRanges(w,S,E),w}_stringRangesToCellRanges(d,u,b){let S=0,E=!1,j=0,w=d[S];if(w){for(let k=b;k<this._bufferService.cols;k++){const N=u.getWidth(k),L=u.getString(k).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!E&&w[0]<=j&&(w[0]=k,E=!0),w[1]<=j){if(w[1]=k,w=d[++S],!w)break;w[0]<=j?(w[0]=k,E=!0):E=!1}j+=L}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,u){let b=!1;for(let S=0;S<d.length;S++){const E=d[S];if(b){if(u[1]<=E[0])return d[S-1][1]=u[1],d;if(u[1]<=E[1])return d[S-1][1]=Math.max(u[1],E[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(u[1]<=E[0])return d.splice(S,0,u),d;if(u[1]<=E[1])return E[0]=Math.min(u[0],E[0]),d;u[0]<E[1]&&(E[0]=Math.min(u[0],E[0]),b=!0)}}return b?d[d.length-1][1]=u[1]:d.push(u),d}};i.CharacterJoinerService=a=c([f(0,y.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,c){this._textarea=n,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,i,n){var c=this&&this.__decorate||function(y,_,a,h){var d,u=arguments.length,b=u<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,_,a,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(b=(u<3?d(b):u>3?d(_,a,b):d(_,a))||b);return u>3&&b&&Object.defineProperty(_,a,b),b},f=this&&this.__param||function(y,_){return function(a,h){_(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const l=n(4725),g=n(9806);let x=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,a,h,d){return(0,g.getCoords)(window,y,_,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,_){const a=(0,g.getCoordsRelativeToElement)(window,y,_);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])}}};i.MouseService=x=c([f(0,l.IRenderService),f(1,l.ICharSizeService)],x)},3230:function(v,i,n){var c=this&&this.__decorate||function(b,S,E,j){var w,k=arguments.length,N=k<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(b,S,E,j);else for(var L=b.length-1;L>=0;L--)(w=b[L])&&(N=(k<3?w(N):k>3?w(S,E,N):w(S,E))||N);return k>3&&N&&Object.defineProperty(S,E,N),N},f=this&&this.__param||function(b,S){return function(E,j){S(E,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const l=n(3656),g=n(6193),x=n(5596),y=n(4725),_=n(8460),a=n(844),h=n(7226),d=n(2585);let u=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,S,E,j,w,k,N,L){if(super(),this._rowCount=b,this._charSizeService=j,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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((R,M)=>this._renderRows(R,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(k.onResize((()=>this._fullRefresh()))),this.register(k.buffers.onBufferActivate((()=>{var R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()}))),this.register(E.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.onDecorationRemoved((()=>this._fullRefresh()))),this.register(E.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(k.cols,k.rows),this._fullRefresh()}))),this.register(E.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(k.buffer.y,k.buffer.y,!0)))),this.register((0,l.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const R=new N.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});R.observe(S),this.register({dispose:()=>R.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,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(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,E){var j;this._selectionState.start=b,this._selectionState.end=S,this._selectionState.columnSelectMode=E,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(b,S,E)}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()}};i.RenderService=u=c([f(2,d.IOptionsService),f(3,y.ICharSizeService),f(4,d.IDecorationService),f(5,d.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],u)},9312:function(v,i,n){var c=this&&this.__decorate||function(w,k,N,L){var R,M=arguments.length,D=M<3?k:L===null?L=Object.getOwnPropertyDescriptor(k,N):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(w,k,N,L);else for(var I=w.length-1;I>=0;I--)(R=w[I])&&(D=(M<3?R(D):M>3?R(k,N,D):R(k,N))||D);return M>3&&D&&Object.defineProperty(k,N,D),D},f=this&&this.__param||function(w,k){return function(N,L){k(N,L,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const l=n(9806),g=n(9504),x=n(456),y=n(4725),_=n(8460),a=n(844),h=n(6114),d=n(4841),u=n(511),b=n(2585),S=" ",E=new RegExp(S,"g");let j=i.SelectionService=class extends a.Disposable{constructor(w,k,N,L,R,M,D,I,F){super(),this._element=w,this._screenElement=k,this._linkifier=N,this._bufferService=L,this._coreService=R,this._mouseService=M,this._optionsService=D,this._renderService=I,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.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 x.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 w=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!w||!k||w[0]===k[0]&&w[1]===k[1])}get selectionText(){const w=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;if(!w||!k)return"";const N=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(w[0]===k[0])return"";const R=w[0]<k[0]?w[0]:k[0],M=w[0]<k[0]?k[0]:w[0];for(let D=w[1];D<=k[1];D++){const I=N.translateBufferLineToString(D,!0,R,M);L.push(I)}}else{const R=w[1]===k[1]?k[0]:void 0;L.push(N.translateBufferLineToString(w[1],!0,w[0],R));for(let M=w[1]+1;M<=k[1]-1;M++){const D=N.lines.get(M),I=N.translateBufferLineToString(M,!0);D?.isWrapped?L[L.length-1]+=I:L.push(I)}if(w[1]!==k[1]){const M=N.lines.get(k[1]),D=N.translateBufferLineToString(k[1],!0,0,k[0]);M&&M.isWrapped?L[L.length-1]+=D:L.push(D)}}return L.map((R=>R.replace(E," "))).join(h.isWindows?`\r
|
|
22
|
+
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")}}i.OscLinkProvider=b=c([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],b)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,c){this._parentWindow=n,this._renderCallback=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,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 n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=n(844);class f 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)}}i.ScreenDprMonitor=f},3236:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=n(3614),f=n(3656),l=n(6465),g=n(9042),b=n(3730),y=n(1680),_=n(3107),a=n(5744),h=n(2950),d=n(1296),u=n(428),x=n(4269),S=n(5114),k=n(8934),E=n(3230),w=n(9312),j=n(4725),T=n(6731),L=n(8055),N=n(8969),R=n(8460),D=n(844),I=n(6114),F=n(8437),z=n(2584),A=n(7399),P=n(5941),O=n(9074),B=n(2585),W=n(5435),V=n(4567),Q=typeof window<"u"?window.document:null;class Z extends N.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(M={}){super(M),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new D.MutableDisposable),this._onCursorMove=this.register(new R.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new R.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new R.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new R.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new R.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new R.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new R.EventEmitter),this._onBlur=this.register(new R.EventEmitter),this._onA11yCharEmitter=this.register(new R.EventEmitter),this._onA11yTabEmitter=this.register(new R.EventEmitter),this._onWillOpen=this.register(new R.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,U)=>this.refresh(H,U)))),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,R.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,R.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,D.toDisposable)((()=>{var H,U;this._customKeyEventHandler=void 0,(U=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||U===void 0||U.removeChild(this.element)})))}_handleColorEvent(M){if(this._themeService)for(const H of M){let U,$="";switch(H.index){case 256:U="foreground",$="10";break;case 257:U="background",$="11";break;case 258:U="cursor",$="12";break;default:U="ansi",$="4;"+H.index}switch(H.type){case 0:const se=L.color.toColorRGB(U==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[U]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${$};${(0,P.toRgbString)(se)}${z.C1_ESCAPED.ST}`);break;case 1:if(U==="ansi")this._themeService.modifyColors((K=>K.ansi[H.index]=L.rgba.toColor(...H.color)));else{const K=U;this._themeService.modifyColors((ce=>ce[K]=L.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(M){M?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(M){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(M),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var M;return(M=this.textarea)===null||M===void 0?void 0:M.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 M=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(M);if(!H)return;const U=Math.min(this.buffer.x,this.cols-1),$=this._renderService.dimensions.css.cell.height,se=H.getWidth(U),K=this._renderService.dimensions.css.cell.width*se,ce=this.buffer.y*this._renderService.dimensions.css.cell.height,pe=U*this._renderService.dimensions.css.cell.width;this.textarea.style.left=pe+"px",this.textarea.style.top=ce+"px",this.textarea.style.width=K+"px",this.textarea.style.height=$+"px",this.textarea.style.lineHeight=$+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const M=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",M)),this.register((0,f.addDisposableDomListener)(this.element,"paste",M)),I.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(M=>this._keyUp(M)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(M=>this._keyDown(M)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(M=>this._keyPress(M)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(M=>this._compositionHelper.compositionupdate(M)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(M=>this._inputEvent(M)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(M){var H;if(!M)throw new Error("Terminal requires a parent element.");M.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=M.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),M.appendChild(this.element);const U=Q.createDocumentFragment();this._viewportElement=Q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),U.appendChild(this._viewportElement),this._viewportScrollArea=Q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=Q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=Q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),U.appendChild(this.screenElement),this.textarea=Q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.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,f.addDisposableDomListener)(this.textarea,"focus",($=>this._handleTextAreaFocus($)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(T.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(x.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(($=>this._onRender.fire($)))),this.onResize(($=>this._renderService.resize($.cols,$.rows))),this._compositionView=Q.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(U);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(($=>this.scrollLines($.amount,$.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(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(($=>this.scrollLines($.amount,$.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw(($=>this._renderService.handleSelectionChanged($.start,$.end,$.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection(($=>{this.textarea.value=$,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event(($=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",($=>this._selectionService.handleMouseDown($)))),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(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",($=>this._handleScreenReaderModeOptionChange($)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",($=>{!this._overviewRulerRenderer&&$&&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 M=this,H=this.element;function U(K){const ce=M._mouseService.getMouseReportCoords(K,M.screenElement);if(!ce)return!1;let pe,xe;switch(K.overrideType||K.type){case"mousemove":xe=32,K.buttons===void 0?(pe=3,K.button!==void 0&&(pe=K.button<3?K.button:3)):pe=1&K.buttons?0:4&K.buttons?1:2&K.buttons?2:3;break;case"mouseup":xe=0,pe=K.button<3?K.button:3;break;case"mousedown":xe=1,pe=K.button<3?K.button:3;break;case"wheel":if(M.viewport.getLinesScrolled(K)===0)return!1;xe=K.deltaY<0?0:1,pe=4;break;default:return!1}return!(xe===void 0||pe===void 0||pe>4)&&M.coreMouseService.triggerMouseEvent({col:ce.col,row:ce.row,x:ce.x,y:ce.y,button:pe,action:xe,ctrl:K.ctrlKey,alt:K.altKey,shift:K.shiftKey})}const $={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:K=>(U(K),K.buttons||(this._document.removeEventListener("mouseup",$.mouseup),$.mousedrag&&this._document.removeEventListener("mousemove",$.mousedrag)),this.cancel(K)),wheel:K=>(U(K),this.cancel(K,!0)),mousedrag:K=>{K.buttons&&U(K)},mousemove:K=>{K.buttons||U(K)}};this.register(this.coreMouseService.onProtocolChange((K=>{K?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(K)),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&K?$.mousemove||(H.addEventListener("mousemove",se.mousemove),$.mousemove=se.mousemove):(H.removeEventListener("mousemove",$.mousemove),$.mousemove=null),16&K?$.wheel||(H.addEventListener("wheel",se.wheel,{passive:!1}),$.wheel=se.wheel):(H.removeEventListener("wheel",$.wheel),$.wheel=null),2&K?$.mouseup||(H.addEventListener("mouseup",se.mouseup),$.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",$.mouseup),H.removeEventListener("mouseup",$.mouseup),$.mouseup=null),4&K?$.mousedrag||($.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",$.mousedrag),$.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(H,"mousedown",(K=>{if(K.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(K))return U(K),$.mouseup&&this._document.addEventListener("mouseup",$.mouseup),$.mousedrag&&this._document.addEventListener("mousemove",$.mousedrag),this.cancel(K)}))),this.register((0,f.addDisposableDomListener)(H,"wheel",(K=>{if(!$.wheel){if(!this.buffer.hasScrollback){const ce=this.viewport.getLinesScrolled(K);if(ce===0)return;const pe=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(K.deltaY<0?"A":"B");let xe="";for(let De=0;De<Math.abs(ce);De++)xe+=pe;return this.coreService.triggerDataEvent(xe,!0),this.cancel(K,!0)}return this.viewport.handleWheel(K)?this.cancel(K):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(H,"touchstart",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(K),this.cancel(K)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(H,"touchmove",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(K)?void 0:this.cancel(K)}),{passive:!1}))}refresh(M,H){var U;(U=this._renderService)===null||U===void 0||U.refreshRows(M,H)}updateCursorStyle(M){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(M)?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(M,H,U=0){var $;U===1?(super.scrollLines(M,H,U),this.refresh(0,this.rows-1)):($=this.viewport)===null||$===void 0||$.scrollLines(M)}paste(M){(0,c.paste)(M,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(M){this._customKeyEventHandler=M}registerLinkProvider(M){return this.linkifier2.registerLinkProvider(M)}registerCharacterJoiner(M){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(M);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(M){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(M)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(M){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+M)}registerDecoration(M){return this._decorationService.registerDecoration(M)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(M,H,U){this._selectionService.setSelection(M,H,U)}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 M;(M=this._selectionService)===null||M===void 0||M.clearSelection()}selectAll(){var M;(M=this._selectionService)===null||M===void 0||M.selectAll()}selectLines(M,H){var U;(U=this._selectionService)===null||U===void 0||U.selectLines(M,H)}_keyDown(M){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(M)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&M.altKey;if(!H&&!this._compositionHelper.keydown(M))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||M.key!=="Dead"&&M.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const U=(0,A.evaluateKeyboardEvent)(M,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(M),U.type===3||U.type===2){const $=this.rows-1;return this.scrollLines(U.type===2?-$:$),this.cancel(M,!0)}return U.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,M)||(U.cancel&&this.cancel(M,!0),!U.key||!!(M.key&&!M.ctrlKey&&!M.altKey&&!M.metaKey&&M.key.length===1&&M.key.charCodeAt(0)>=65&&M.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(U.key!==z.C0.ETX&&U.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:U.key,domEvent:M}),this._showCursor(),this.coreService.triggerDataEvent(U.key,!0),!this.optionsService.rawOptions.screenReaderMode||M.altKey||M.ctrlKey?this.cancel(M,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(M,H){const U=M.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||M.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||M.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?U:U&&(!H.keyCode||H.keyCode>47)}_keyUp(M){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(M)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(M)||this.focus(),this.updateCursorStyle(M),this._keyPressHandled=!1)}_keyPress(M){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(M)===!1)return!1;if(this.cancel(M),M.charCode)H=M.charCode;else if(M.which===null||M.which===void 0)H=M.keyCode;else{if(M.which===0||M.charCode===0)return!1;H=M.which}return!(!H||(M.altKey||M.ctrlKey||M.metaKey)&&!this._isThirdLevelShift(this.browser,M)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:M}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(M){if(M.data&&M.inputType==="insertText"&&(!M.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=M.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(M),!0}return!1}resize(M,H){M!==this.cols||H!==this.rows?super.resize(M,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(M,H){var U,$;(U=this._charSizeService)===null||U===void 0||U.measure(),($=this.viewport)===null||$===void 0||$.syncScrollArea(!0)}clear(){var M;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}),(M=this.viewport)===null||M===void 0||M.reset(),this.refresh(0,this.rows-1)}}reset(){var M,H;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(M=this._selectionService)===null||M===void 0||M.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var M;(M=this._renderService)===null||M===void 0||M.clearTextureAtlas()}_reportFocus(){var M;!((M=this.element)===null||M===void 0)&&M.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(M){if(this._renderService)switch(M){case W.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),U=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${U};${H}t`);break;case W.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const $=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${se};${$}t`)}}cancel(M,H){if(this.options.cancelEvents||H)return M.preventDefault(),M.stopPropagation(),!1}}i.Terminal=Z},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,c=1e3){this._renderCallback=n,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,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,b=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),b)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c)}}},1680:function(v,i,n){var c=this&&this.__decorate||function(h,d,u,x){var S,k=arguments.length,E=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,x);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(E=(k<3?S(E):k>3?S(d,u,E):S(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,x){d(u,x,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const l=n(3656),g=n(4725),b=n(8460),y=n(844),_=n(2585);let a=i.Viewport=class extends y.Disposable{constructor(h,d,u,x,S,k,E,w){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=u,this._optionsService=x,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 b.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(w.colors),this.register(w.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 u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&u<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 u;let x,S="";const k=[],E=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const T=w.get(j);if(!T)continue;const L=(u=w.get(j+1))===null||u===void 0?void 0:u.isWrapped;if(S+=T.translateToString(!L),!L||j===w.length-1){const N=document.createElement("div");N.textContent=S,k.push(N),S.length>0&&(x=N),S=""}}return{bufferElements:k,cursorElement:x}}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 u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&d.altKey||u==="ctrl"&&d.ctrlKey||u==="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))}};i.Viewport=a=c([f(2,_.IBufferService),f(3,_.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],a)},3107:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(x=a[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const l=n(3656),g=n(4725),b=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends b.Disposable{constructor(a,h,d,u){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=u,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((x=>this._removeDecoration(x)))),this.register((0,b.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 u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),u.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const x=(d=a.options.x)!==null&&d!==void 0?d:0;return x&&x>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(a,u),u}_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 u=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=u?u*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()}};i.BufferDecorationRenderer=_=c([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,g.IRenderService)],_)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.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(n){if(n.options.overviewRulerOptions){for(const c of this._zones)if(c.color===n.options.overviewRulerOptions.color&&c.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,n.marker.line))return;if(this._lineAdjacentToZone(c,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(c,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,c){return c>=n.startBufferLine&&c<=n.endBufferLine}_lineAdjacentToZone(n,c,f){return c>=n.startBufferLine-this._linePadding[f||"full"]&&c<=n.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(n,c){n.startBufferLine=Math.min(n.startBufferLine,c),n.endBufferLine=Math.max(n.endBufferLine,c)}}},5744:function(v,i,n){var c=this&&this.__decorate||function(x,S,k,E){var w,j=arguments.length,T=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(x,S,k,E);else for(var L=x.length-1;L>=0;L--)(w=x[L])&&(T=(j<3?w(T):j>3?w(S,k,T):w(S,k))||T);return j>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(x,S){return function(k,E){S(k,E,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const l=n(5871),g=n(3656),b=n(4725),y=n(844),_=n(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 u=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,S,k,E,w,j,T){var L;super(),this._viewportElement=x,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=w,this._optionsService=j,this._coreBrowseService=T,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(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const N=this._canvas.getContext("2d");if(!N)throw new Error("Ctx cannot be null");this._ctx=N,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var R;(R=this._canvas)===null||R===void 0||R.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 x=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=x,h.center=S,h.right=x,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 x=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(x,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 x=this._colorZoneStore.zones;for(const S of x)S.position!=="full"&&this._renderColorZone(S);for(const S of x)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(d[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-a[x.position||"full"]/2),h[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[x.position||"full"]))}_queueRefresh(x,S){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=u=c([f(2,_.IBufferService),f(3,_.IDecorationService),f(4,b.IRenderService),f(5,_.IOptionsService),f(6,b.ICoreBrowserService)],u)},2950:function(v,i,n){var c=this&&this.__decorate||function(_,a,h,d){var u,x=arguments.length,S=x<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,a,h,d);else for(var k=_.length-1;k>=0;k--)(u=_[k])&&(S=(x<3?u(S):x>3?u(a,h,S):u(a,h))||S);return x>3&&S&&Object.defineProperty(a,h,S),S},f=this&&this.__param||function(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const l=n(4725),g=n(2585),b=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,a,h,d,u,x){this._textarea=_,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=u,this._renderService=x,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){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 _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(_,"");this._dataAlreadySent=h,a.length>_.length?this._coreService.triggerDataEvent(h,!0):a.length<_.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):a.length===_.length&&a!==_&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(_){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,u=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"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 x=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(x.width,1)+"px",this._textarea.style.height=Math.max(x.height,1)+"px",this._textarea.style.lineHeight=x.height+"px"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=c([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,l.IRenderService)],y)},9806:(v,i)=>{function n(c,f,l){const g=l.getBoundingClientRect(),b=c.getComputedStyle(l),y=parseInt(b.getPropertyValue("padding-left")),_=parseInt(b.getPropertyValue("padding-top"));return[f.clientX-g.left-y,f.clientY-g.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(c,f,l,g,b,y,_,a,h){if(!y)return;const d=n(c,f,l);return d?(d[0]=Math.ceil((d[0]+(h?_/2:0))/_),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),b),d):void 0}},9504:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=n(2584);function f(a,h,d,u){const x=a-l(a,d),S=h-l(h,d),k=Math.abs(x-S)-(function(E,w,j){let T=0;const L=E-l(E,j),N=w-l(w,j);for(let R=0;R<Math.abs(L-N);R++){const D=g(E,w)==="A"?-1:1,I=j.buffer.lines.get(L+D*R);I?.isWrapped&&T++}return T})(a,h,d);return _(k,y(g(a,h),u))}function l(a,h){let d=0,u=h.buffer.lines.get(a),x=u?.isWrapped;for(;x&&a>=0&&a<h.rows;)d++,u=h.buffer.lines.get(--a),x=u?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function b(a,h,d,u,x,S){let k=a,E=h,w="";for(;k!==d||E!==u;)k+=x?1:-1,x&&k>S.cols-1?(w+=S.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!x&&k<0&&(w+=S.buffer.translateBufferLineToString(E,!1,0,a+1),k=S.cols-1,a=k,E--);return w+S.buffer.translateBufferLineToString(E,!1,a,k)}function y(a,h){const d=h?"O":"[";return c.C0.ESC+d+a}function _(a,h){a=Math.floor(a);let d="";for(let u=0;u<a;u++)d+=h;return d}i.moveToCellSequence=function(a,h,d,u){const x=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,j,T,L,N,R){return f(j,L,N,R).length===0?"":_(b(w,j,w,j-l(j,N),!1,N).length,y("D",R))})(x,S,0,h,d,u)+f(S,h,d,u)+(function(w,j,T,L,N,R){let D;D=f(j,L,N,R).length>0?L-l(L,N):j;const I=L,F=(function(z,A,P,O,B,W){let V;return V=f(P,O,B,W).length>0?O-l(O,B):A,z<P&&V<=O||z>=P&&V<O?"C":"D"})(w,j,T,L,N,R);return _(b(w,D,T,I,F==="C",N).length,y(F,R))})(x,S,a,h,d,u);let k;if(S===h)return k=x>a?"D":"C",_(Math.abs(x-a),y(k,u));k=S>h?"D":"C";const E=Math.abs(S-h);return _((function(w,j){return j.cols-w})(S>h?a:x,d)+(E-1)*d.cols+1+((S>h?x:a)-1),y(k,u))}},1296:function(v,i,n){var c=this&&this.__decorate||function(N,R,D,I){var F,z=arguments.length,A=z<3?R:I===null?I=Object.getOwnPropertyDescriptor(R,D):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(N,R,D,I);else for(var P=N.length-1;P>=0;P--)(F=N[P])&&(A=(z<3?F(A):z>3?F(R,D,A):F(R,D))||A);return z>3&&A&&Object.defineProperty(R,D,A),A},f=this&&this.__param||function(N,R){return function(D,I){R(D,I,N)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const l=n(3787),g=n(2550),b=n(2223),y=n(6171),_=n(4725),a=n(8055),h=n(8460),d=n(844),u=n(2585),x="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",w="xterm-focus",j="xterm-selection";let T=1,L=i.DomRenderer=class extends d.Disposable{constructor(N,R,D,I,F,z,A,P,O,B){super(),this._element=N,this._screenElement=R,this._viewportElement=D,this._linkifier2=I,this._charSizeService=z,this._optionsService=A,this._bufferService=P,this._coreBrowserService=O,this._themeService=B,this._terminalClass=T++,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((W=>this._injectCss(W)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(x+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((W=>this._handleLinkHover(W)))),this.register(this._linkifier2.onHideLinkUnderline((W=>this._handleLinkLeave(W)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(x+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 N=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*N,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*N),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/N),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/N),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 D of this._rowElements)D.style.width=`${this.dimensions.css.canvas.width}px`,D.style.height=`${this.dimensions.css.cell.height}px`,D.style.lineHeight=`${this.dimensions.css.cell.height}px`,D.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const R=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=R,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(N){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let R=`${this._terminalSelector} .${S} { color: ${N.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;R+=`${this._terminalSelector} .${S} .xterm-dim { color: ${a.color.multiplyOpacity(N.foreground,.5).css};}`,R+=`${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;}`,R+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",R+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${N.cursor.css}; color: ${N.cursorAccent.css}; } 50% { background-color: inherit; color: ${N.cursor.css}; }}`,R+=`${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${w} .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: ${N.cursor.css}; color: ${N.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${N.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${N.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${N.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,R+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${N.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${N.selectionInactiveBackgroundOpaque.css};}`;for(const[D,I]of N.ansi.entries())R+=`${this._terminalSelector} .${k}${D} { color: ${I.css}; }${this._terminalSelector} .${k}${D}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${D} { background-color: ${I.css}; }`;R+=`${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(N.background).css}; }${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(N.background),.5).css}; }${this._terminalSelector} .${E}${b.INVERTED_DEFAULT_COLOR} { background-color: ${N.foreground.css}; }`,this._themeStyleElement.textContent=R}_setDefaultSpacing(){const N=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${N}px`,this._rowFactory.defaultSpacing=N}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(N,R){for(let D=this._rowElements.length;D<=R;D++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>R;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(N,R){this._refreshRowElements(N,R),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(N,R,D){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(N,R,D),this.renderRows(0,this._bufferService.rows-1),!N||!R)return;const I=N[1]-this._bufferService.buffer.ydisp,F=R[1]-this._bufferService.buffer.ydisp,z=Math.max(I,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(D){const O=N[0]>R[0];P.appendChild(this._createSelectionElement(z,O?R[0]:N[0],O?N[0]:R[0],A-z+1))}else{const O=I===z?N[0]:0,B=z===F?R[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,O,B));const W=A-z-1;if(P.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,W)),z!==A){const V=F===A?R[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,V))}}this._selectionContainer.appendChild(P)}_createSelectionElement(N,R,D,I=1){const F=document.createElement("div");return F.style.height=I*this.dimensions.css.cell.height+"px",F.style.top=N*this.dimensions.css.cell.height+"px",F.style.left=R*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(D-R)+"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 N of this._rowElements)N.replaceChildren()}renderRows(N,R){const D=this._bufferService.buffer,I=D.ybase+D.y,F=Math.min(D.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=N;O<=R;O++){const B=O+D.ydisp,W=this._rowElements[O],V=D.lines.get(B);if(!W||!V)break;W.replaceChildren(...this._rowFactory.createRow(V,B,B===I,A,P,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${x}${this._terminalClass}`}_handleLinkHover(N){this._setCellUnderline(N.x1,N.x2,N.y1,N.y2,N.cols,!0)}_handleLinkLeave(N){this._setCellUnderline(N.x1,N.x2,N.y1,N.y2,N.cols,!1)}_setCellUnderline(N,R,D,I,F,z){D<0&&(N=0),I<0&&(R=0);const A=this._bufferService.rows-1;D=Math.max(Math.min(D,A),0),I=Math.max(Math.min(I,A),0),F=Math.min(F,this._bufferService.cols);const P=this._bufferService.buffer,O=P.ybase+P.y,B=Math.min(P.x,F-1),W=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=D;Z<=I;++Z){const he=Z+P.ydisp,M=this._rowElements[Z],H=P.lines.get(he);if(!M||!H)break;M.replaceChildren(...this._rowFactory.createRow(H,he,he===O,V,Q,B,W,this.dimensions.css.cell.width,this._widthCache,z?Z===D?N:0:-1,z?(Z===I?R:F)-1:-1))}}};i.DomRenderer=L=c([f(4,u.IInstantiationService),f(5,_.ICharSizeService),f(6,u.IOptionsService),f(7,u.IBufferService),f(8,_.ICoreBrowserService),f(9,_.IThemeService)],L)},3787:function(v,i,n){var c=this&&this.__decorate||function(k,E,w,j){var T,L=arguments.length,N=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,w):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(k,E,w,j);else for(var R=k.length-1;R>=0;R--)(T=k[R])&&(N=(L<3?T(N):L>3?T(E,w,N):T(E,w))||N);return L>3&&N&&Object.defineProperty(E,w,N),N},f=this&&this.__param||function(k,E){return function(w,j){E(w,j,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const l=n(2223),g=n(643),b=n(511),y=n(2585),_=n(8055),a=n(4725),h=n(4269),d=n(6171),u=n(3734);let x=i.DomRendererRowFactory=class{constructor(k,E,w,j,T,L,N){this._document=k,this._characterJoinerService=E,this._optionsService=w,this._coreBrowserService=j,this._coreService=T,this._decorationService=L,this._themeService=N,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,w){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=w}createRow(k,E,w,j,T,L,N,R,D,I,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let O,B=k.getNoBgTrimmedLength();w&&B<L+1&&(B=L+1);let W=0,V="",Q=0,Z=0,he=0,M=!1,H=0,U=!1,$=0;const se=[],K=I!==-1&&F!==-1;for(let ce=0;ce<B;ce++){k.loadCell(ce,this._workCell);let pe=this._workCell.getWidth();if(pe===0)continue;let xe=!1,De=ce,ne=this._workCell;if(A.length>0&&ce===A[0][0]){xe=!0;const ee=A.shift();ne=new h.JoinedCellData(this._workCell,k.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),De=ee[1]-1,pe=ne.getWidth()}const _e=this._isCellInSelection(ce,E),He=w&&ce===L,we=K&&ce>=I&&ce<=F;let Le=!1;this._decorationService.forEachDecorationAtCell(ce,E,void 0,(ee=>{Le=!0}));let ke=ne.getChars()||g.WHITESPACE_CELL_CHAR;if(ke===" "&&(ne.isUnderline()||ne.isOverline())&&(ke=" "),$=pe*R-D.get(ke,ne.isBold(),ne.isItalic()),O){if(W&&(_e&&U||!_e&&!U&&ne.bg===Q)&&(_e&&U&&P.selectionForeground||ne.fg===Z)&&ne.extended.ext===he&&we===M&&$===H&&!He&&!xe&&!Le){V+=ke,W++;continue}W&&(O.textContent=V),O=this._document.createElement("span"),W=0,V=""}else O=this._document.createElement("span");if(Q=ne.bg,Z=ne.fg,he=ne.extended.ext,M=we,H=$,U=_e,xe&&L>=ce&&L<=De&&(L=ce),!this._coreService.isCursorHidden&&He){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)N&&se.push("xterm-cursor-blink"),se.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(T)switch(T){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(ne.isBold()&&se.push("xterm-bold"),ne.isItalic()&&se.push("xterm-italic"),ne.isDim()&&se.push("xterm-dim"),V=ne.isInvisible()?g.WHITESPACE_CELL_CHAR:ne.getChars()||g.WHITESPACE_CELL_CHAR,ne.isUnderline()&&(se.push(`xterm-underline-${ne.extended.underlineStyle}`),V===" "&&(V=" "),!ne.isUnderlineColorDefault()))if(ne.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(ne.getUnderlineColor()).join(",")})`;else{let ee=ne.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ne.isBold()&&ee<8&&(ee+=8),O.style.textDecorationColor=P.ansi[ee].css}ne.isOverline()&&(se.push("xterm-overline"),V===" "&&(V=" ")),ne.isStrikethrough()&&se.push("xterm-strikethrough"),we&&(O.style.textDecoration="underline");let Ee=ne.getFgColor(),Ue=ne.getFgColorMode(),be=ne.getBgColor(),Je=ne.getBgColorMode();const Ce=!!ne.isInverse();if(Ce){const ee=Ee;Ee=be,be=ee;const fe=Ue;Ue=Je,Je=fe}let Ne,tt,X,J=!1;switch(this._decorationService.forEachDecorationAtCell(ce,E,void 0,(ee=>{ee.options.layer!=="top"&&J||(ee.backgroundColorRGB&&(Je=50331648,be=ee.backgroundColorRGB.rgba>>8&16777215,Ne=ee.backgroundColorRGB),ee.foregroundColorRGB&&(Ue=50331648,Ee=ee.foregroundColorRGB.rgba>>8&16777215,tt=ee.foregroundColorRGB),J=ee.options.layer==="top")})),!J&&_e&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,be=Ne.rgba>>8&16777215,Je=50331648,J=!0,P.selectionForeground&&(Ue=50331648,Ee=P.selectionForeground.rgba>>8&16777215,tt=P.selectionForeground)),J&&se.push("xterm-decoration-top"),Je){case 16777216:case 33554432:X=P.ansi[be],se.push(`xterm-bg-${be}`);break;case 50331648:X=_.rgba.toColor(be>>16,be>>8&255,255&be),this._addStyle(O,`background-color:#${S((be>>>0).toString(16),"0",6)}`);break;default:Ce?(X=P.foreground,se.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):X=P.background}switch(Ne||ne.isDim()&&(Ne=_.color.multiplyOpacity(X,.5)),Ue){case 16777216:case 33554432:ne.isBold()&&Ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ee+=8),this._applyMinimumContrast(O,X,P.ansi[Ee],ne,Ne,void 0)||se.push(`xterm-fg-${Ee}`);break;case 50331648:const ee=_.rgba.toColor(Ee>>16&255,Ee>>8&255,255&Ee);this._applyMinimumContrast(O,X,ee,ne,Ne,tt)||this._addStyle(O,`color:#${S(Ee.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,X,P.foreground,ne,Ne,void 0)||Ce&&se.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}se.length&&(O.className=se.join(" "),se.length=0),He||xe||Le?O.textContent=V:W++,$!==this.defaultSpacing&&(O.style.letterSpacing=`${$}px`),z.push(O),ce=De}return O&&W&&(O.textContent=V),z}_applyMinimumContrast(k,E,w,j,T,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const N=this._getContrastCache(j);let R;if(T||L||(R=N.getColor(E.rgba,w.rgba)),R===void 0){const D=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);R=_.color.ensureContrastRatio(T||E,L||w,D),N.setColor((T||E).rgba,(L||w).rgba,R??null)}return!!R&&(this._addStyle(k,`color:${R.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 w=this._selectionStart,j=this._selectionEnd;return!(!w||!j)&&(this._columnSelectMode?w[0]<=j[0]?k>=w[0]&&E>=w[1]&&k<j[0]&&E<=j[1]:k<w[0]&&E>=w[1]&&k>=j[0]&&E<=j[1]:E>w[1]&&E<j[1]||w[1]===j[1]&&E===w[1]&&k>=w[0]&&k<j[0]||w[1]<j[1]&&E===j[1]&&k<j[0]||w[1]<j[1]&&E===w[1]&&k>=w[0])}};function S(k,E,w){for(;k.length<w;)k=E+k;return k}i.DomRendererRowFactory=x=c([f(1,a.ICharacterJoinerService),f(2,y.IOptionsService),f(3,a.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,a.IThemeService)],x)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.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=n.createElement("span"),f=n.createElement("span");f.style.fontWeight="bold";const l=n.createElement("span");l.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,f,l,g],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(l),this._container.appendChild(g),n.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(n,c,f,l){n===this._font&&c===this._fontSize&&f===this._weight&&l===this._weightBold||(this._font=n,this._fontSize=c,this._weight=f,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(n,c,f){let l=0;if(!c&&!f&&n.length===1&&(l=n.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(n,0);let g=n;c&&(g+="B"),f&&(g+="I");let b=this._holey.get(g);if(b===void 0){let y=0;c&&(y|=1),f&&(y|=2),b=this._measure(n,y),this._holey.set(g,b)}return b}_measure(n,c){const f=this._measureElements[c];return f.textContent=n.repeat(32),f.offsetWidth/32}}},2223:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function n(c){return 57508<=c&&c<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return n(c)||(function(f){return 9472<=f&&f<=9631})(c)},i.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,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,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 n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,c=this.selectionEnd;return!(!n||!c)&&(n[1]>c[1]||n[1]===c[1]&&n[0]>c[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(x=a[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const l=n(2585),g=n(8460),b=n(844);let y=i.CharSizeService=class extends b.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 _(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())}};i.CharSizeService=y=c([f(2,l.IOptionsService)],y);class _{constructor(h,d,u){this._document=h,this._parentElement=d,this._optionsService=u,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,i,n){var c=this&&this.__decorate||function(h,d,u,x){var S,k=arguments.length,E=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,x);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(E=(k<3?S(E):k>3?S(d,u,E):S(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,x){d(u,x,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const l=n(3734),g=n(643),b=n(511),y=n(2585);class _ extends l.AttributeData{constructor(d,u,x){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=u,this._width=x}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()]}}i.JoinedCellData=_;let a=i.CharacterJoinerService=class ha{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(d){const u={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(u),u.id}deregister(d){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===d)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(d);if(!u||u.length===0)return[];const x=[],S=u.translateToString(!0);let k=0,E=0,w=0,j=u.getFg(0),T=u.getBg(0);for(let L=0;L<u.getTrimmedLength();L++)if(u.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==T){if(L-k>1){const N=this._getJoinedRanges(S,w,E,u,k);for(let R=0;R<N.length;R++)x.push(N[R])}k=L,w=E,j=this._workCell.fg,T=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(S,w,E,u,k);for(let N=0;N<L.length;N++)x.push(L[N])}return x}_getJoinedRanges(d,u,x,S,k){const E=d.substring(u,x);let w=[];try{w=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const T=this._characterJoiners[j].handler(E);for(let L=0;L<T.length;L++)ha._mergeRanges(w,T[L])}catch(T){console.error(T)}return this._stringRangesToCellRanges(w,S,k),w}_stringRangesToCellRanges(d,u,x){let S=0,k=!1,E=0,w=d[S];if(w){for(let j=x;j<this._bufferService.cols;j++){const T=u.getWidth(j),L=u.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(T!==0){if(!k&&w[0]<=E&&(w[0]=j,k=!0),w[1]<=E){if(w[1]=j,w=d[++S],!w)break;w[0]<=E?(w[0]=j,k=!0):k=!1}E+=L}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,u){let x=!1;for(let S=0;S<d.length;S++){const k=d[S];if(x){if(u[1]<=k[0])return d[S-1][1]=u[1],d;if(u[1]<=k[1])return d[S-1][1]=Math.max(u[1],k[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(u[1]<=k[0])return d.splice(S,0,u),d;if(u[1]<=k[1])return k[0]=Math.min(u[0],k[0]),d;u[0]<k[1]&&(k[0]=Math.min(u[0],k[0]),x=!0)}}return x?d[d.length-1][1]=u[1]:d.push(u),d}};i.CharacterJoinerService=a=c([f(0,y.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,c){this._textarea=n,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,i,n){var c=this&&this.__decorate||function(y,_,a,h){var d,u=arguments.length,x=u<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(y,_,a,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(x=(u<3?d(x):u>3?d(_,a,x):d(_,a))||x);return u>3&&x&&Object.defineProperty(_,a,x),x},f=this&&this.__param||function(y,_){return function(a,h){_(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const l=n(4725),g=n(9806);let b=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,a,h,d){return(0,g.getCoords)(window,y,_,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,_){const a=(0,g.getCoordsRelativeToElement)(window,y,_);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])}}};i.MouseService=b=c([f(0,l.IRenderService),f(1,l.ICharSizeService)],b)},3230:function(v,i,n){var c=this&&this.__decorate||function(x,S,k,E){var w,j=arguments.length,T=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(x,S,k,E);else for(var L=x.length-1;L>=0;L--)(w=x[L])&&(T=(j<3?w(T):j>3?w(S,k,T):w(S,k))||T);return j>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(x,S){return function(k,E){S(k,E,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const l=n(3656),g=n(6193),b=n(5596),y=n(4725),_=n(8460),a=n(844),h=n(7226),d=n(2585);let u=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(x,S,k,E,w,j,T,L){if(super(),this._rowCount=x,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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(T.window,((N,R)=>this._renderRows(N,R))),this.register(this._renderDebouncer),this._screenDprMonitor=new b.ScreenDprMonitor(T.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var N;return(N=this._renderer.value)===null||N===void 0?void 0:N.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.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)(T.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in T.window){const N=new T.window.IntersectionObserver((R=>this._handleIntersectionChange(R[R.length-1])),{threshold:0});N.observe(S),this.register({dispose:()=>N.disconnect()})}}_handleIntersectionChange(x){this._isPaused=x.isIntersecting===void 0?x.intersectionRatio===0:!x.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(x,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(x,S,this._rowCount))}_renderRows(x,S){this._renderer.value&&(x=Math.min(x,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(x,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:x,end:S}),this._onRender.fire({start:x,end:S}),this._isNextRenderRedrawOnly=!0)}resize(x,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(x){this._renderer.value=x,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(x){return this._renderDebouncer.addRefreshCallback(x)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var x,S;this._renderer.value&&((S=(x=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(x),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(x,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(x,S))):this._renderer.value.handleResize(x,S),this._fullRefresh())}handleCharSizeChanged(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCharSizeChanged()}handleBlur(){var x;(x=this._renderer.value)===null||x===void 0||x.handleBlur()}handleFocus(){var x;(x=this._renderer.value)===null||x===void 0||x.handleFocus()}handleSelectionChanged(x,S,k){var E;this._selectionState.start=x,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(x,S,k)}handleCursorMove(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCursorMove()}clear(){var x;(x=this._renderer.value)===null||x===void 0||x.clear()}};i.RenderService=u=c([f(2,d.IOptionsService),f(3,y.ICharSizeService),f(4,d.IDecorationService),f(5,d.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],u)},9312:function(v,i,n){var c=this&&this.__decorate||function(w,j,T,L){var N,R=arguments.length,D=R<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,T):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(w,j,T,L);else for(var I=w.length-1;I>=0;I--)(N=w[I])&&(D=(R<3?N(D):R>3?N(j,T,D):N(j,T))||D);return R>3&&D&&Object.defineProperty(j,T,D),D},f=this&&this.__param||function(w,j){return function(T,L){j(T,L,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const l=n(9806),g=n(9504),b=n(456),y=n(4725),_=n(8460),a=n(844),h=n(6114),d=n(4841),u=n(511),x=n(2585),S=" ",k=new RegExp(S,"g");let E=i.SelectionService=class extends a.Disposable{constructor(w,j,T,L,N,R,D,I,F){super(),this._element=w,this._screenElement=j,this._linkifier=T,this._bufferService=L,this._coreService=N,this._mouseService=R,this._optionsService=D,this._renderService=I,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.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 b.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 w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!w||!j||w[0]===j[0]&&w[1]===j[1])}get selectionText(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!w||!j)return"";const T=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(w[0]===j[0])return"";const N=w[0]<j[0]?w[0]:j[0],R=w[0]<j[0]?j[0]:w[0];for(let D=w[1];D<=j[1];D++){const I=T.translateBufferLineToString(D,!0,N,R);L.push(I)}}else{const N=w[1]===j[1]?j[0]:void 0;L.push(T.translateBufferLineToString(w[1],!0,w[0],N));for(let R=w[1]+1;R<=j[1]-1;R++){const D=T.lines.get(R),I=T.translateBufferLineToString(R,!0);D?.isWrapped?L[L.length-1]+=I:L.push(I)}if(w[1]!==j[1]){const R=T.lines.get(j[1]),D=T.translateBufferLineToString(j[1],!0,0,j[0]);R&&R.isWrapped?L[L.length-1]+=D:L.push(D)}}return L.map((N=>N.replace(k," "))).join(h.isWindows?`\r
|
|
23
23
|
`:`
|
|
24
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&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(w){const k=this._getMouseBufferCoords(w),N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(N&&L&&k)&&this._areCoordsInSelection(k,N,L)}isCellInSelection(w,k){const N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!N||!L)&&this._areCoordsInSelection([w,k],N,L)}_areCoordsInSelection(w,k,N){return w[1]>k[1]&&w[1]<N[1]||k[1]===N[1]&&w[1]===k[1]&&w[0]>=k[0]&&w[0]<N[0]||k[1]<N[1]&&w[1]===N[1]&&w[0]<N[0]||k[1]<N[1]&&w[1]===k[1]&&w[0]>=k[0]}_selectWordAtCursor(w,k){var N,L;const R=(L=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||L===void 0?void 0:L.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(w);return!!M&&(this._selectWordAt(M,k),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,k){this._model.clearSelection(),w=Math.max(w,0),k=Math.min(k,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,k],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const k=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(k)return k[0]--,k[1]--,k[1]+=this._bufferService.buffer.ydisp,k}_getMouseEventScrollAmount(w){let k=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return k>=0&&k<=N?0:(k>N&&(k-=N),k=Math.min(Math.max(k,-50),50),k/=50,k/Math.abs(k)+Math.round(14*k))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),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(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const k=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);k&&k.length!==this._model.selectionStart[0]&&k.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const k=this._getMouseBufferCoords(w);k&&(this._activeSelectionMode=2,this._selectLineAt(k[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.stopImmediatePropagation(),!this._model.selectionStart)return;const k=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(w),!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(w),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 L=N.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}k&&k[0]===this._model.selectionEnd[0]&&k[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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const k=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&k<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const L=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,k=this._model.finalSelectionEnd,N=!(!w||!k||w[0]===k[0]&&w[1]===k[1]);N?w&&k&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&k[0]===this._oldSelectionEnd[0]&&k[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,k,N)):this._oldHasSelection&&this._fireOnSelectionChange(w,k,N)}_fireOnSelectionChange(w,k,N){this._oldSelectionStart=w,this._oldSelectionEnd=k,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((k=>this._handleTrim(k)))}_convertViewportColToCharacterIndex(w,k){let N=k;for(let L=0;k>=L;L++){const R=w.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:R>1&&k!==L&&(N+=R-1)}return N}setSelection(w,k,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,k],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,k,N=!0,L=!0){if(w[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,M=R.lines.get(w[1]);if(!M)return;const D=R.translateBufferLineToString(w[1],!1);let I=this._convertViewportColToCharacterIndex(M,w[0]),F=I;const z=w[0]-I;let A=0,P=0,O=0,B=0;if(D.charAt(I)===" "){for(;I>0&&D.charAt(I-1)===" ";)I--;for(;F<D.length&&D.charAt(F+1)===" ";)F++}else{let Q=w[0],Z=w[0];M.getWidth(Q)===0&&(A++,Q--),M.getWidth(Z)===2&&(P++,Z++);const he=M.getString(Z).length;for(he>1&&(B+=he-1,F+=he-1);Q>0&&I>0&&!this._isCharWordSeparator(M.loadCell(Q-1,this._workCell));){M.loadCell(Q-1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,Q--):T>1&&(O+=T-1,I-=T-1),I--,Q--}for(;Z<M.length&&F+1<D.length&&!this._isCharWordSeparator(M.loadCell(Z+1,this._workCell));){M.loadCell(Z+1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,Z++):T>1&&(B+=T-1,F+=T-1),F++,Z++}}F++;let $=I+z-A+O,Y=Math.min(this._bufferService.cols,F-I+A+P-O-B);if(k||D.slice(I,F).trim()!==""){if(N&&$===0&&M.getCodePoint(0)!==32){const Q=R.lines.get(w[1]-1);if(Q&&M.isWrapped&&Q.getCodePoint(this._bufferService.cols-1)!==32){const Z=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(Z){const he=this._bufferService.cols-Z.start;$-=he,Y+=he}}}if(L&&$+Y===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const Q=R.lines.get(w[1]+1);if(Q?.isWrapped&&Q.getCodePoint(0)!==32){const Z=this._getWordAt([0,w[1]+1],!1,!1,!0);Z&&(Y+=Z.length)}}return{start:$,length:Y}}}_selectWordAt(w,k){const N=this._getWordAt(w,k);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[N.start,w[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(w){const k=this._getWordAt(w,!0);if(k){let N=w[1];for(;k.start<0;)k.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;k.start+k.length>this._bufferService.cols;)k.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?k.start:k.start+k.length,N]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const k=this._bufferService.buffer.getWrappedRangeForLine(w),N={start:{x:0,y:k.first},end:{x:this._bufferService.cols-1,y:k.last}};this._model.selectionStart=[0,k.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(N,this._bufferService.cols)}};i.SelectionService=j=c([f(3,b.IBufferService),f(4,b.ICoreService),f(5,y.IMouseService),f(6,b.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],j)},4725:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const c=n(8343);i.ICharSizeService=(0,c.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),i.IMouseService=(0,c.createDecorator)("MouseService"),i.IRenderService=(0,c.createDecorator)("RenderService"),i.ISelectionService=(0,c.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(v,i,n){var c=this&&this.__decorate||function(j,w,k,N){var L,R=arguments.length,M=R<3?w:N===null?N=Object.getOwnPropertyDescriptor(w,k):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,w,k,N);else for(var D=j.length-1;D>=0;D--)(L=j[D])&&(M=(R<3?L(M):R>3?L(w,k,M):L(w,k))||M);return R>3&&M&&Object.defineProperty(w,k,M),M},f=this&&this.__param||function(j,w){return function(k,N){w(k,N,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const l=n(7239),g=n(8055),x=n(8460),y=n(844),_=n(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[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")],w=[0,95,135,175,215,255];for(let k=0;k<216;k++){const N=w[k/36%6|0],L=w[k/6%6|0],R=w[k%6];j.push({css:g.channels.toCss(N,L,R),rgba:g.channels.toRgba(N,L,R)})}for(let k=0;k<24;k++){const N=8+10*k;j.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return j})());let S=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),ansi:i.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(j={}){const w=this._colors;if(w.foreground=E(j.foreground,a),w.background=E(j.background,h),w.cursor=E(j.cursor,d),w.cursorAccent=E(j.cursorAccent,u),w.selectionBackgroundTransparent=E(j.selectionBackground,b),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=E(j.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=j.selectionForeground?E(j.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=E(j.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=E(j.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=E(j.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=E(j.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=E(j.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=E(j.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=E(j.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=E(j.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=E(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=E(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=E(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=E(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=E(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=E(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=E(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=E(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const k=Math.min(w.ansi.length-16,j.extendedAnsi.length);for(let N=0;N<k;N++)w.ansi[N+16]=E(j.extendedAnsi[N],i.DEFAULT_ANSI_COLORS[N+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){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[j]=this._restoreColors.ansi[j]}else for(let w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}modifyColors(j){j(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 E(j,w){if(j!==void 0)try{return g.css.toColor(j)}catch{}return w}i.ThemeService=S=c([f(0,_.IOptionsService)],S)},6349:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(x){super(),this._maxLength=x,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(x){if(this._maxLength===x)return;const y=new Array(x);for(let _=0;_<Math.min(x,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let y=this._length;y<x;y++)this._array[y]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,y){this._array[this._getCyclicIndex(x)]=y}push(x){this._array[this._getCyclicIndex(this._length)]=x,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(x,y,..._){if(y){for(let a=x;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:x,amount:y})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+_.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<_.length;a++)this._array[this._getCyclicIndex(x+a)]=_[a];if(_.length&&this.onInsertEmitter.fire({index:x,amount:_.length}),this._length+_.length>this._maxLength){const a=this._length+_.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=_.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,y,_){if(!(y<=0)){if(x<0||x>=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(_>0){for(let h=y-1;h>=0;h--)this.set(x+h+_,this.get(x+h));const a=x+y+_-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(x+a+_,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}i.CircularList=l},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(c,f=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=f<=1?c[g]:c[g]&&n(c[g],f-1);return l}},8055:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const c=n(6114);let f=0,l=0,g=0,x=0;var y,_,a,h,d;function u(S){const E=S.toString(16);return E.length<2?"0"+E:E}function b(S,E){return S<E?(E+.05)/(S+.05):(S+.05)/(E+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(E,j,w,k){return k!==void 0?`#${u(E)}${u(j)}${u(w)}${u(k)}`:`#${u(E)}${u(j)}${u(w)}`},S.toRgba=function(E,j,w,k=255){return(E<<24|j<<16|w<<8|k)>>>0}})(y||(i.channels=y={})),(function(S){function E(j,w){return x=Math.round(255*w),[f,l,g]=d.toChannels(j.rgba),{css:y.toCss(f,l,g,x),rgba:y.toRgba(f,l,g,x)}}S.blend=function(j,w){if(x=(255&w.rgba)/255,x===1)return{css:w.css,rgba:w.rgba};const k=w.rgba>>24&255,N=w.rgba>>16&255,L=w.rgba>>8&255,R=j.rgba>>24&255,M=j.rgba>>16&255,D=j.rgba>>8&255;return f=R+Math.round((k-R)*x),l=M+Math.round((N-M)*x),g=D+Math.round((L-D)*x),{css:y.toCss(f,l,g),rgba:y.toRgba(f,l,g)}},S.isOpaque=function(j){return(255&j.rgba)==255},S.ensureContrastRatio=function(j,w,k){const N=d.ensureContrastRatio(j.rgba,w.rgba,k);if(N)return d.toColor(N>>24&255,N>>16&255,N>>8&255)},S.opaque=function(j){const w=(255|j.rgba)>>>0;return[f,l,g]=d.toChannels(w),{css:y.toCss(f,l,g),rgba:w}},S.opacity=E,S.multiplyOpacity=function(j,w){return x=255&j.rgba,E(j,x*w/255)},S.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(_||(i.color=_={})),(function(S){let E,j;if(!c.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const k=w.getContext("2d",{willReadFrequently:!0});k&&(E=k,E.globalCompositeOperation="copy",j=E.createLinearGradient(0,0,1,1))}S.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(f,l,g);case 5:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),x=parseInt(w.slice(4,5).repeat(2),16),d.toColor(f,l,g,x);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const k=w.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(k)return f=parseInt(k[1]),l=parseInt(k[2]),g=parseInt(k[3]),x=Math.round(255*(k[5]===void 0?1:parseFloat(k[5]))),d.toColor(f,l,g,x);if(!E||!j)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=j,E.fillStyle=w,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[f,l,g,x]=E.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,l,g,x),css:w}}})(a||(i.css=a={})),(function(S){function E(j,w,k){const N=j/255,L=w/255,R=k/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}S.relativeLuminance=function(j){return E(j>>16&255,j>>8&255,255&j)},S.relativeLuminance2=E})(h||(i.rgb=h={})),(function(S){function E(w,k,N){const L=w>>24&255,R=w>>16&255,M=w>>8&255;let D=k>>24&255,I=k>>16&255,F=k>>8&255,z=b(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,R,M));for(;z<N&&(D>0||I>0||F>0);)D-=Math.max(0,Math.ceil(.1*D)),I-=Math.max(0,Math.ceil(.1*I)),F-=Math.max(0,Math.ceil(.1*F)),z=b(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,R,M));return(D<<24|I<<16|F<<8|255)>>>0}function j(w,k,N){const L=w>>24&255,R=w>>16&255,M=w>>8&255;let D=k>>24&255,I=k>>16&255,F=k>>8&255,z=b(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,R,M));for(;z<N&&(D<255||I<255||F<255);)D=Math.min(255,D+Math.ceil(.1*(255-D))),I=Math.min(255,I+Math.ceil(.1*(255-I))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=b(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,R,M));return(D<<24|I<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(w,k,N){const L=h.relativeLuminance(w>>8),R=h.relativeLuminance(k>>8);if(b(L,R)<N){if(R<L){const I=E(w,k,N),F=b(L,h.relativeLuminance(I>>8));if(F<N){const z=j(w,k,N);return F>b(L,h.relativeLuminance(z>>8))?I:z}return I}const M=j(w,k,N),D=b(L,h.relativeLuminance(M>>8));if(D<N){const I=E(w,k,N);return D>b(L,h.relativeLuminance(I>>8))?M:I}return M}},S.reduceLuminance=E,S.increaseLuminance=j,S.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},S.toColor=function(w,k,N,L){return{css:y.toCss(w,k,N,L),rgba:y.toRgba(w,k,N,L)}}})(d||(i.rgba=d={})),i.toPaddedHex=u,i.contrastRatio=b},8969:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=n(844),f=n(2585),l=n(4348),g=n(7866),x=n(744),y=n(7302),_=n(6975),a=n(8460),h=n(1753),d=n(1480),u=n(7994),b=n(9282),S=n(5435),E=n(5981),j=n(2660);let w=!1;class k extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((L=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(L.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(L){for(const R in L)this.optionsService.options[R]=L[R]}constructor(L){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(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(f.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((R=>{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((R=>{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 E.WriteBuffer(((R,M)=>this._inputHandler.parse(R,M)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,R){this._writeBuffer.write(L,R)}writeSync(L,R){this._logService.logLevel<=f.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(L,R)}resize(L,R){isNaN(L)||isNaN(R)||(L=Math.max(L,x.MINIMUM_COLS),R=Math.max(R,x.MINIMUM_ROWS),this._bufferService.resize(L,R))}scroll(L,R=!1){this._bufferService.scroll(L,R)}scrollLines(L,R,M){this._bufferService.scrollLines(L,R,M)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const R=L-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(L,R){return this._inputHandler.registerEscHandler(L,R)}registerDcsHandler(L,R){return this._inputHandler.registerDcsHandler(L,R)}registerCsiHandler(L,R){return this._inputHandler.registerCsiHandler(L,R)}registerOscHandler(L,R){return this._inputHandler.registerOscHandler(L,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?L=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const R of L)R.dispose()}))}}}i.CoreTerminal=k},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===n)return void this._listeners.splice(c,1)}}})),this._event}fire(n,c){const f=[];for(let l=0;l<this._listeners.length;l++)f.push(this._listeners[l]);for(let l=0;l<f.length;l++)f[l].call(void 0,n,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,c){return n((f=>c.fire(f)))}},5435:function(v,i,n){var c=this&&this.__decorate||function(z,A,P,O){var B,$=arguments.length,Y=$<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,P):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(z,A,P,O);else for(var Q=z.length-1;Q>=0;Q--)(B=z[Q])&&(Y=($<3?B(Y):$>3?B(A,P,Y):B(A,P))||Y);return $>3&&Y&&Object.defineProperty(A,P,Y),Y},f=this&&this.__param||function(z,A){return function(P,O){A(P,O,z)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const l=n(2584),g=n(7116),x=n(2015),y=n(844),_=n(482),a=n(8437),h=n(8460),d=n(643),u=n(511),b=n(3734),S=n(2585),E=n(6242),j=n(6351),w=n(5941),k={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function L(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 R;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(i.WindowsOptionsReportType=R={}));let M=0;class D extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,O,B,$,Y,Q,Z,he=new x.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=O,this._logService=B,this._optionsService=$,this._oscLinkService=Y,this._coreMouseService=Q,this._unicodeService=Z,this._parser=he,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new u.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 I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((T=>this._activeBuffer=T.activeBuffer))),this._parser.setCsiHandlerFallback(((T,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(T),params:H.toArray()})})),this._parser.setEscHandlerFallback((T=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(T)})})),this._parser.setExecuteHandlerFallback((T=>{this._logService.debug("Unknown EXECUTE code: ",{code:T})})),this._parser.setOscHandlerFallback(((T,H,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:T,action:H,data:U})})),this._parser.setDcsHandlerFallback(((T,H,U)=>{H==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(T),action:H,payload:U})})),this._parser.setPrintHandler(((T,H,U)=>this.print(T,H,U))),this._parser.registerCsiHandler({final:"@"},(T=>this.insertChars(T))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(T=>this.scrollLeft(T))),this._parser.registerCsiHandler({final:"A"},(T=>this.cursorUp(T))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(T=>this.scrollRight(T))),this._parser.registerCsiHandler({final:"B"},(T=>this.cursorDown(T))),this._parser.registerCsiHandler({final:"C"},(T=>this.cursorForward(T))),this._parser.registerCsiHandler({final:"D"},(T=>this.cursorBackward(T))),this._parser.registerCsiHandler({final:"E"},(T=>this.cursorNextLine(T))),this._parser.registerCsiHandler({final:"F"},(T=>this.cursorPrecedingLine(T))),this._parser.registerCsiHandler({final:"G"},(T=>this.cursorCharAbsolute(T))),this._parser.registerCsiHandler({final:"H"},(T=>this.cursorPosition(T))),this._parser.registerCsiHandler({final:"I"},(T=>this.cursorForwardTab(T))),this._parser.registerCsiHandler({final:"J"},(T=>this.eraseInDisplay(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(T=>this.eraseInDisplay(T,!0))),this._parser.registerCsiHandler({final:"K"},(T=>this.eraseInLine(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(T=>this.eraseInLine(T,!0))),this._parser.registerCsiHandler({final:"L"},(T=>this.insertLines(T))),this._parser.registerCsiHandler({final:"M"},(T=>this.deleteLines(T))),this._parser.registerCsiHandler({final:"P"},(T=>this.deleteChars(T))),this._parser.registerCsiHandler({final:"S"},(T=>this.scrollUp(T))),this._parser.registerCsiHandler({final:"T"},(T=>this.scrollDown(T))),this._parser.registerCsiHandler({final:"X"},(T=>this.eraseChars(T))),this._parser.registerCsiHandler({final:"Z"},(T=>this.cursorBackwardTab(T))),this._parser.registerCsiHandler({final:"`"},(T=>this.charPosAbsolute(T))),this._parser.registerCsiHandler({final:"a"},(T=>this.hPositionRelative(T))),this._parser.registerCsiHandler({final:"b"},(T=>this.repeatPrecedingCharacter(T))),this._parser.registerCsiHandler({final:"c"},(T=>this.sendDeviceAttributesPrimary(T))),this._parser.registerCsiHandler({prefix:">",final:"c"},(T=>this.sendDeviceAttributesSecondary(T))),this._parser.registerCsiHandler({final:"d"},(T=>this.linePosAbsolute(T))),this._parser.registerCsiHandler({final:"e"},(T=>this.vPositionRelative(T))),this._parser.registerCsiHandler({final:"f"},(T=>this.hVPosition(T))),this._parser.registerCsiHandler({final:"g"},(T=>this.tabClear(T))),this._parser.registerCsiHandler({final:"h"},(T=>this.setMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(T=>this.setModePrivate(T))),this._parser.registerCsiHandler({final:"l"},(T=>this.resetMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(T=>this.resetModePrivate(T))),this._parser.registerCsiHandler({final:"m"},(T=>this.charAttributes(T))),this._parser.registerCsiHandler({final:"n"},(T=>this.deviceStatus(T))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(T=>this.deviceStatusPrivate(T))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(T=>this.softReset(T))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(T=>this.setCursorStyle(T))),this._parser.registerCsiHandler({final:"r"},(T=>this.setScrollRegion(T))),this._parser.registerCsiHandler({final:"s"},(T=>this.saveCursor(T))),this._parser.registerCsiHandler({final:"t"},(T=>this.windowOptions(T))),this._parser.registerCsiHandler({final:"u"},(T=>this.restoreCursor(T))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(T=>this.insertColumns(T))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(T=>this.deleteColumns(T))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(T=>this.selectProtected(T))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(T=>this.requestMode(T,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(T=>this.requestMode(T,!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 E.OscHandler((T=>(this.setTitle(T),this.setIconName(T),!0)))),this._parser.registerOscHandler(1,new E.OscHandler((T=>this.setIconName(T)))),this._parser.registerOscHandler(2,new E.OscHandler((T=>this.setTitle(T)))),this._parser.registerOscHandler(4,new E.OscHandler((T=>this.setOrReportIndexedColor(T)))),this._parser.registerOscHandler(8,new E.OscHandler((T=>this.setHyperlink(T)))),this._parser.registerOscHandler(10,new E.OscHandler((T=>this.setOrReportFgColor(T)))),this._parser.registerOscHandler(11,new E.OscHandler((T=>this.setOrReportBgColor(T)))),this._parser.registerOscHandler(12,new E.OscHandler((T=>this.setOrReportCursorColor(T)))),this._parser.registerOscHandler(104,new E.OscHandler((T=>this.restoreIndexedColor(T)))),this._parser.registerOscHandler(110,new E.OscHandler((T=>this.restoreFgColor(T)))),this._parser.registerOscHandler(111,new E.OscHandler((T=>this.restoreBgColor(T)))),this._parser.registerOscHandler(112,new E.OscHandler((T=>this.restoreCursorColor(T)))),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 T in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:T},(()=>this.selectCharset("("+T))),this._parser.registerEscHandler({intermediates:")",final:T},(()=>this.selectCharset(")"+T))),this._parser.registerEscHandler({intermediates:"*",final:T},(()=>this.selectCharset("*"+T))),this._parser.registerEscHandler({intermediates:"+",final:T},(()=>this.selectCharset("+"+T))),this._parser.registerEscHandler({intermediates:"-",final:T},(()=>this.selectCharset("-"+T))),this._parser.registerEscHandler({intermediates:".",final:T},(()=>this.selectCharset("."+T))),this._parser.registerEscHandler({intermediates:"/",final:T},(()=>this.selectCharset("/"+T)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((T=>(this._logService.error("Parsing error: ",T),T))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((T,H)=>this.requestStatusString(T,H))))}_preserveStack(A,P,O,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=O,this._parseStack.position=B}_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,B=this._activeBuffer.x,$=this._activeBuffer.y,Y=0;const Q=this._parseStack.paused;if(Q){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(O),O;B=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>N&&(Y=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,(Z=>String.fromCharCode(Z))).join("")}"`),typeof A=="string"?A.split("").map((Z=>Z.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(A.length,N))),Q||this._dirtyRowTracker.clearRange(),A.length>N)for(let Z=Y;Z<A.length;Z+=N){const he=Z+N<A.length?Z+N:A.length,T=typeof A=="string"?this._stringDecoder.decode(A.substring(Z,he),this._parseBuffer):this._utf8Decoder.decode(A.subarray(Z,he),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,T))return this._preserveStack(B,$,T,Z),this._logSlowResolvingAsync(O),O}else if(!Q){const Z=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,Z))return this._preserveStack(B,$,Z,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===B&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,O){let B,$;const Y=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,he=this._coreService.decPrivateModes.wraparound,T=this._coreService.modes.insertMode,H=this._curAttrData;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-P>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=P;W<O;++W){if(B=A[W],$=this._unicodeService.wcwidth(B),B<127&&Y){const se=Y[String.fromCharCode(B)];se&&(B=se.charCodeAt(0))}if(Q&&this._onA11yChar.fire((0,_.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=Z){if(he){for(;this._activeBuffer.x<Z;)U.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),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Z-1,$===2)continue}if(T&&(U.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(H),H),U.getWidth(Z-1)===2&&U.setCellFromCodePoint(Z-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),U.setCellFromCodePoint(this._activeBuffer.x++,B,$,H.fg,H.bg,H.extended),$>0)for(;--$;)U.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else U.getWidth(this._activeBuffer.x-1)?U.addCodepointToCell(this._activeBuffer.x-1,B):U.addCodepointToCell(this._activeBuffer.x-2,B)}O-P>0&&(U.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<Z&&O-P>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.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=>!L(O.params[0],this._optionsService.rawOptions.windowOptions)||P(O)))}registerDcsHandler(A,P){return this._parser.registerDcsHandler(A,new j.DcsHandler(P))}registerEscHandler(A,P){return this._parser.registerEscHandler(A,P)}registerOscHandler(A,P){return this._parser.registerOscHandler(A,new E.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,B=!1,$=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);Y.replaceCells(P,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),B&&(Y.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 B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,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,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;P--;)this._activeBuffer.lines.splice($-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 B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;P--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(B,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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=0;B<P;++B)O[B]=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:B,activeEncoding:$}=this._coreMouseService,Y=this._coreService,{buffers:Q,cols:Z}=this._bufferService,{active:he,alt:T}=Q,H=this._optionsService.rawOptions,U=ce=>ce?1:2,W=A.params[0];return se=W,K=P?W===2?4:W===4?U(Y.modes.insertMode):W===12?3:W===20?U(H.convertEol):0:W===1?U(O.applicationCursorKeys):W===3?H.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:W===6?U(O.origin):W===7?U(O.wraparound):W===8?3:W===9?U(B==="X10"):W===12?U(H.cursorBlink):W===25?U(!Y.isCursorHidden):W===45?U(O.reverseWraparound):W===66?U(O.applicationKeypad):W===67?4:W===1e3?U(B==="VT200"):W===1002?U(B==="DRAG"):W===1003?U(B==="ANY"):W===1004?U(O.sendFocus):W===1005?4:W===1006?U($==="SGR"):W===1015?4:W===1016?U($==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?U(he===T):W===2004?U(O.bracketedPasteMode):0,Y.triggerDataEvent(`${l.C0.ESC}[${P?"":"?"}${se};${K}$y`),!0;var se,K}_updateAttrColor(A,P,O,B,$){return P===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([O,B,$])):P===5&&(A&=-50331904,A|=33554432|255&O),A}_extractColor(A,P,O){const B=[0,0,-1,0,0,0];let $=0,Y=0;do{if(B[Y+$]=A.params[P+Y],A.hasSubParams(P+Y)){const Q=A.getSubParams(P+Y);let Z=0;do B[1]===5&&($=1),B[Y+Z+1+$]=Q[Z];while(++Z<Q.length&&Z+Y+1+$<B.length);break}if(B[1]===5&&Y+$>=2||B[1]===2&&Y+$>=5)break;B[1]&&($=1)}while(++Y+P<A.length&&Y+$<B.length);for(let Q=2;Q<B.length;++Q)B[Q]===-1&&(B[Q]=0);switch(B[0]){case 38:O.fg=this._updateAttrColor(O.fg,B[1],B[3],B[4],B[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,B[1],B[3],B[4],B[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,B[1],B[3],B[4],B[5])}return Y}_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 B=this._curAttrData;for(let $=0;$<P;$++)O=A.params[$],O>=30&&O<=37?(B.fg&=-50331904,B.fg|=16777216|O-30):O>=40&&O<=47?(B.bg&=-50331904,B.bg|=16777216|O-40):O>=90&&O<=97?(B.fg&=-50331904,B.fg|=16777224|O-90):O>=100&&O<=107?(B.bg&=-50331904,B.bg|=16777224|O-100):O===0?this._processSGR0(B):O===1?B.fg|=134217728:O===3?B.bg|=67108864:O===4?(B.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,B)):O===5?B.fg|=536870912:O===7?B.fg|=67108864:O===8?B.fg|=1073741824:O===9?B.fg|=2147483648:O===2?B.bg|=134217728:O===21?this._processUnderline(2,B):O===22?(B.fg&=-134217729,B.bg&=-134217729):O===23?B.bg&=-67108865:O===24?(B.fg&=-268435457,this._processUnderline(0,B)):O===25?B.fg&=-536870913:O===27?B.fg&=-67108865:O===28?B.fg&=-1073741825:O===29?B.fg&=2147483647:O===39?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):O===49?(B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?$+=this._extractColor(A,$,B):O===53?B.bg|=1073741824:O===55?B.bg&=-1073741825:O===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):O===100?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.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(!L(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(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.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 B=O.shift(),$=O.shift();if(/^\d+$/.exec(B)){const Y=parseInt(B);if(F(Y))if($==="?")P.push({type:0,index:Y});else{const Q=(0,w.parseColor)($);Q&&P.push({type:1,index:Y,color:Q})}}}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 B;const $=O.findIndex((Y=>Y.startsWith("id=")));return $!==-1&&(B=O[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,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 B=0;B<O.length&&!(P>=this._specialColors.length);++B,++P)if(O[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,w.parseColor)(O[B]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}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 B=0;B<O.length;++B)if(/^\d+$/.exec(O[B])){const $=parseInt(O[B]);F($)&&P.push({type:2,index:$})}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(k[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 u.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,B=this._activeBuffer.lines.get(O);B&&(B.fill(A),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const O=this._bufferService.buffer,B=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${$}${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}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}i.InputHandler=D;let I=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&&(M=z,z=A,A=M),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}I=c([f(0,S.IBufferService)],I)},844:(v,i)=>{function n(c){for(const f of c)f.dispose();c.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.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 f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.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}},i.toDisposable=function(c){return{dispose:c}},i.disposeArray=n,i.getDisposeArrayDisposable=function(c){return{dispose:()=>n(c)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(f,l,g){this._data[f]||(this._data[f]={}),this._data[f][l]=g}get(f,l){return this._data[f]?this._data[f][l]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(c,f,l,g,x){this._data.get(c,f)||this._data.set(c,f,new n),this._data.get(c,f).set(l,g,x)}get(c,f,l,g){var x;return(x=this._data.get(c,f))===null||x===void 0?void 0:x.get(l,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,c=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const f=n.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),i.isIpad=c==="iPad",i.isIphone=c==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),i.isLinux=c.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(n=this._search(this._getKey(c)),this._array.splice(n,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(n=this._search(f),n===-1)||this._getKey(this._array[n])!==f)return!1;do if(this._array[n]===c)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===c)}forEachByKey(c,f){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do f(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===c)}values(){return[...this._array].values()}_search(c){let f=0,l=this._array.length-1;for(;l>=f;){let g=f+l>>1;const x=this._getKey(this._array[g]);if(x>c)l=g-1;else{if(!(x<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}f=g+1}}return f}}},7226:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=n(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),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(x){this._idleCallback=void 0;let y=0,_=0,a=x.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),_=Math.max(y,_),h=x.timeRemaining(),1.5*_>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 f{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const y=Date.now()+x;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=l,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=n(643);i.updateWindowsModeWrappedState=function(f){const l=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=l?.get(f.cols-1),x=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);x&&g&&(x.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{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 n;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}}i.AttributeData=n;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}}i.ExtendedAttrs=c},9092:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=n(6349),f=n(7226),l=n(3734),g=n(8437),x=n(4634),y=n(511),_=n(643),a=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,u,b){this._hasScrollback=d,this._optionsService=u,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,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.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,u){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),u)}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 u=d+this._optionsService.rawOptions.scrollback;return u>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:u}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)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,u){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const E=this._getCorrectBufferLength(u);if(E>this.lines.maxLength&&(this.lines.maxLength=E),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(d,b);let j=0;if(this._rows<u)for(let w=this._rows;w<u;w++)this.lines.length<u+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+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,b)));else for(let w=this._rows;w>u;w--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(E<this.lines.maxLength){const w=this.lines.length-E;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=E}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,u-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(d,u),this._cols>d))for(let j=0;j<this.lines.length;j++)S+=+this.lines.get(j).resize(d,b);this._cols=d,this._rows=u,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 u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>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,u){this._cols!==d&&(d>this._cols?this._reflowLarger(d,u):this._reflowSmaller(d,u))}_reflowLarger(d,u){const b=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const S=(0,x.reflowLargerCreateNewLayout)(this.lines,b);(0,x.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,u,S.countRemoved)}}_reflowLargerAdjustViewport(d,u,b){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let E=b;for(;E-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&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,u){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let E=0;for(let j=this.lines.length-1;j>=0;j--){let w=this.lines.get(j);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const k=[w];for(;w.isWrapped&&j>0;)w=this.lines.get(--j),k.unshift(w);const N=this.ybase+this.y;if(N>=j&&N<j+k.length)continue;const L=k[k.length-1].getTrimmedLength(),R=(0,x.reflowSmallerGetNewLineLengths)(k,this._cols,d),M=R.length-k.length;let D;D=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const I=[];for(let B=0;B<M;B++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push($)}I.length>0&&(S.push({start:j+k.length+E,newLines:I}),E+=I.length),k.push(...I);let F=R.length-1,z=R[F];z===0&&(F--,z=R[F]);let A=k.length-M-1,P=L;for(;A>=0;){const B=Math.min(P,z);if(k[F]===void 0)break;if(k[F].copyCellsFrom(k[A],P-B,z-B,B,!0),z-=B,z===0&&(F--,z=R[F]),P-=B,P===0){A--;const $=Math.max(A,0);P=(0,x.getWrappedLineTrimmedLength)(k,$,this._cols)}}for(let B=0;B<k.length;B++)R[B]<d&&k[B].setCell(R[B],b);let O=M-D;for(;O-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+E)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+u-1)}if(S.length>0){const j=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const k=this.lines.length;let N=k-1,L=0,R=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+E);let M=0;for(let F=Math.min(this.lines.maxLength-1,k+E-1);F>=0;F--)if(R&&R.start>N+M){for(let z=R.newLines.length-1;z>=0;z--)this.lines.set(F--,R.newLines[z]);F++,j.push({index:N+1,amount:R.newLines.length}),M+=R.newLines.length,R=S[++L]}else this.lines.set(F,w[N--]);let D=0;for(let F=j.length-1;F>=0;F--)j[F].index+=D,this.lines.onInsertEmitter.fire(j[F]),D+=j[F].amount;const I=Math.max(0,k+E-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,u,b=0,S){const E=this.lines.get(d);return E?E.translateToString(u,b,S):""}getWrappedRangeForLine(d){let u=d,b=d;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:u,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 u=0;u<this.markers.length;u++)this.markers[u].line===d&&(this.markers[u].dispose(),this.markers.splice(u--,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 u=new a.Marker(d);return this.markers.push(u),u.register(this.lines.onTrim((b=>{u.line-=b,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((b=>{u.line>=b.index&&(u.line+=b.amount)}))),u.register(this.lines.onDelete((b=>{u.line>=b.index&&u.line<b.index+b.amount&&u.dispose(),u.line>b.index&&(u.line-=b.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=n(3734),f=n(511),l=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let x=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const u=h||f.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,u);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 x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+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,u,b,S){268435456&b&&(this._extendedAttrs[a]=S),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=u,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,u){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length-a){const b=new f.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,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(a,h,d,u){if(a%=this.length,h<this.length-a){const b=new f.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,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(a,h,d,u,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.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,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.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 u=new Uint32Array(d);u.set(this._data),this._data=u}for(let u=this.length;u<a;++u)this.setCell(u,h)}else{this._data=this._data.subarray(0,d);const u=Object.keys(this._combined);for(let S=0;S<u.length;S++){const E=parseInt(u[S],10);E>=a&&delete this._combined[E]}const b=Object.keys(this._extendedAttrs);for(let S=0;S<b.length;S++){const E=parseInt(b[S],10);E>=a&&delete this._extendedAttrs[E]}}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,u,b){const S=a._data;if(b)for(let j=u-1;j>=0;j--){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}else for(let j=0;j<u;j++){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}const E=Object.keys(a._combined);for(let j=0;j<E.length;j++){const w=parseInt(E[j],10);w>=h&&(this._combined[w-h+d]=a._combined[w])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let u="";for(;h<d;){const b=this._data[3*h+0],S=2097151&b;u+=2097152&b?this._combined[h]:S?(0,g.stringFromCodePoint)(S):l.WHITESPACE_CELL_CHAR,h+=b>>22||1}return u}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,c){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return c*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(v,i)=>{function n(c,f,l){if(f===c.length-1)return c[f].getTrimmedLength();const g=!c[f].hasContent(l-1)&&c[f].getWidth(l-1)===1,x=c[f+1].getWidth(0)===2;return g&&x?l-1:l}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,f,l,g,x){const y=[];for(let _=0;_<c.length-1;_++){let a=_,h=c.get(++a);if(!h.isWrapped)continue;const d=[c.get(_)];for(;a<c.length&&h.isWrapped;)d.push(h),h=c.get(++a);if(g>=_&&g<a){_+=d.length-1;continue}let u=0,b=n(d,u,f),S=1,E=0;for(;S<d.length;){const w=n(d,S,f),k=w-E,N=l-b,L=Math.min(k,N);d[u].copyCellsFrom(d[S],E,b,L,!1),b+=L,b===l&&(u++,b=0),E+=L,E===w&&(S++,E=0),b===0&&u!==0&&d[u-1].getWidth(l-1)===2&&(d[u].copyCellsFrom(d[u-1],l-1,b++,1,!1),d[u-1].setCell(l-1,x))}d[u].replaceCells(b,l,x);let j=0;for(let w=d.length-1;w>0&&(w>u||d[w].getTrimmedLength()===0);w--)j++;j>0&&(y.push(_+d.length-j),y.push(j)),_+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(c,f){const l=[];let g=0,x=f[g],y=0;for(let _=0;_<c.length;_++)if(x===_){const a=f[++g];c.onDeleteEmitter.fire({index:_-y,amount:a}),_+=a-1,y+=a,x=f[++g]}else l.push(_);return{layout:l,countRemoved:y}},i.reflowLargerApplyNewLayout=function(c,f){const l=[];for(let g=0;g<f.length;g++)l.push(c.get(f[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=f.length},i.reflowSmallerGetNewLineLengths=function(c,f,l){const g=[],x=c.map(((h,d)=>n(c,d,f))).reduce(((h,d)=>h+d));let y=0,_=0,a=0;for(;a<x;){if(x-a<l){g.push(x-a);break}y+=l;const h=n(c,_,f);y>h&&(y-=h,_++);const d=c[_].getWidth(y-1)===2;d&&y--;const u=d?l-1:l;g.push(u),a+=u}return g},i.getWrappedLineTrimmedLength=n},5295:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=n(8460),f=n(844),l=n(9092);class g extends f.Disposable{constructor(y,_){super(),this._optionsService=y,this._bufferService=_,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,_){this._normal.resize(y,_),this._alt.resize(y,_),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=n(482),f=n(643),l=n(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 _=new g;return _.setFromCharData(y),_}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[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const a=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=n(8460),f=n(844);class l{get id(){return this._id}constructor(x){this.line=x,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,f.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}i.Marker=l,l._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.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:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var n,c,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.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=`
|
|
25
|
-
`,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=""})(n||(i.C0=n={})),(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||(i.C1=c={})),(function(l){l.ST=`${n.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=n(2584),f={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:["'",'"']};i.evaluateKeyboardEvent=function(l,g,x,y){const _={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"?_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){_.key=c.C0.ESC+c.C0.DEL;break}_.key=c.C0.DEL;break;case 9:if(l.shiftKey){_.key=c.C0.ESC+"[Z";break}_.key=c.C0.HT,_.cancel=!0;break;case 13:_.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,_.cancel=!0;break;case 27:_.key=c.C0.ESC,l.altKey&&(_.key=c.C0.ESC+c.C0.ESC),_.cancel=!0;break;case 37:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"D",_.key===c.C0.ESC+"[1;3D"&&(_.key=c.C0.ESC+(x?"b":"[1;5D"))):_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"C",_.key===c.C0.ESC+"[1;3C"&&(_.key=c.C0.ESC+(x?"f":"[1;5C"))):_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"A",x||_.key!==c.C0.ESC+"[1;3A"||(_.key=c.C0.ESC+"[1;5A")):_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"B",x||_.key!==c.C0.ESC+"[1;3B"||(_.key=c.C0.ESC+"[1;5B")):_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(_.key=c.C0.ESC+"[2~");break;case 46:_.key=a?c.C0.ESC+"[3;"+(a+1)+"~":c.C0.ESC+"[3~";break;case 36:_.key=a?c.C0.ESC+"[1;"+(a+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:_.key=a?c.C0.ESC+"[1;"+(a+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?_.type=2:l.ctrlKey?_.key=c.C0.ESC+"[5;"+(a+1)+"~":_.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?_.type=3:l.ctrlKey?_.key=c.C0.ESC+"[6;"+(a+1)+"~":_.key=c.C0.ESC+"[6~";break;case 112:_.key=a?c.C0.ESC+"[1;"+(a+1)+"P":c.C0.ESC+"OP";break;case 113:_.key=a?c.C0.ESC+"[1;"+(a+1)+"Q":c.C0.ESC+"OQ";break;case 114:_.key=a?c.C0.ESC+"[1;"+(a+1)+"R":c.C0.ESC+"OR";break;case 115:_.key=a?c.C0.ESC+"[1;"+(a+1)+"S":c.C0.ESC+"OS";break;case 116:_.key=a?c.C0.ESC+"[15;"+(a+1)+"~":c.C0.ESC+"[15~";break;case 117:_.key=a?c.C0.ESC+"[17;"+(a+1)+"~":c.C0.ESC+"[17~";break;case 118:_.key=a?c.C0.ESC+"[18;"+(a+1)+"~":c.C0.ESC+"[18~";break;case 119:_.key=a?c.C0.ESC+"[19;"+(a+1)+"~":c.C0.ESC+"[19~";break;case 120:_.key=a?c.C0.ESC+"[20;"+(a+1)+"~":c.C0.ESC+"[20~";break;case 121:_.key=a?c.C0.ESC+"[21;"+(a+1)+"~":c.C0.ESC+"[21~";break;case 122:_.key=a?c.C0.ESC+"[23;"+(a+1)+"~":c.C0.ESC+"[23~";break;case 123:_.key=a?c.C0.ESC+"[24;"+(a+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(x&&!y||!l.altKey||l.metaKey)!x||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?_.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(_.key=c.C0.US),l.key==="@"&&(_.key=c.C0.NUL)):l.keyCode===65&&(_.type=1);else{const h=f[l.keyCode],d=h?.[l.shiftKey?1:0];if(d)_.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const u=l.ctrlKey?l.keyCode-64:l.keyCode+32;let b=String.fromCharCode(u);l.shiftKey&&(b=b.toUpperCase()),_.key=c.C0.ESC+b}else if(l.keyCode===32)_.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let u=l.code.slice(3,4);l.shiftKey||(u=u.toLowerCase()),_.key=c.C0.ESC+u,_.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?_.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?_.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?_.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?_.key=c.C0.DEL:l.keyCode===219?_.key=c.C0.ESC:l.keyCode===220?_.key=c.C0.FS:l.keyCode===221&&(_.key=c.C0.GS)}return _}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,c=0,f=n.length){let l="";for(let g=c;g<f;++g){let x=n[g];x>65535?(x-=65536,l+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):l+=String.fromCharCode(x)}return l},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,c){const f=n.length;if(!f)return 0;let l=0,g=0;if(this._interim){const x=n.charCodeAt(g++);56320<=x&&x<=57343?c[l++]=1024*(this._interim-55296)+x-56320+65536:(c[l++]=this._interim,c[l++]=x),this._interim=0}for(let x=g;x<f;++x){const y=n.charCodeAt(x);if(55296<=y&&y<=56319){if(++x>=f)return this._interim=y,l;const _=n.charCodeAt(x);56320<=_&&_<=57343?c[l++]=1024*(y-55296)+_-56320+65536:(c[l++]=y,c[l++]=_)}else y!==65279&&(c[l++]=y)}return l}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,c){const f=n.length;if(!f)return 0;let l,g,x,y,_=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 E,j=0;for(;(E=63&this.interim[++j])&&j<4;)S<<=6,S|=E;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=w-j;for(;h<k;){if(h>=f)return 0;if(E=n[h++],(192&E)!=128){h--,b=!0;break}this.interim[j++]=E,S<<=6,S|=63&E}b||(w===2?S<128?h--:c[_++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(c[_++]=S):S<65536||S>1114111||(c[_++]=S)),this.interim.fill(0)}const d=f-4;let u=h;for(;u<f;){for(;!(!(u<d)||128&(l=n[u])||128&(g=n[u+1])||128&(x=n[u+2])||128&(y=n[u+3]));)c[_++]=l,c[_++]=g,c[_++]=x,c[_++]=y,u+=4;if(l=n[u++],l<128)c[_++]=l;else if((224&l)==192){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(a=(31&l)<<6|63&g,a<128){u--;continue}c[_++]=a}else if((240&l)==224){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(x=n[u++],(192&x)!=128){u--;continue}if(a=(15&l)<<12|(63&g)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;c[_++]=a}else if((248&l)==240){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(x=n[u++],(192&x)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=x,_;if(y=n[u++],(192&y)!=128){u--;continue}if(a=(7&l)<<18|(63&g)<<12|(63&x)<<6|63&y,a<65536||a>1114111)continue;c[_++]=a}}return _}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[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 f;i.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let l=0;l<n.length;++l)f.fill(0,n[l][0],n[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?f[l]:(function(g,x){let y,_=0,a=x.length-1;if(g<x[0][0]||g>x[a][1])return!1;for(;a>=_;)if(y=_+a>>1,g>x[y][1])_=y+1;else{if(!(g<x[y][0]))return!0;a=y-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(x){super(),this._action=x,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(x,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,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+=x.length,this._writeBuffer.push(x),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(y)}_innerWrite(x=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 u=b=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(_,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(u)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-_>=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()}}i.WriteBuffer=l},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\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 f(l,g){const x=l.toString(16),y=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=n.exec(g);if(x){const y=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/y*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/y*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,y=[0,0,0];for(let _=0;_<3;++_){const a=parseInt(g.slice(x*_,x*_+x),16);y[_]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return y}},i.toRgbString=function(l,g=16){const[x,y,_]=l;return`rgb:${f(x,g)}/${f(y,g)}/${f(_,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=n(482),f=n(8742),l=n(5770),g=[];i.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,_){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(_),{dispose:()=>{const h=a.indexOf(_);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,_){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(_);else this._handlerFb(this._ident,"HOOK",_)}put(y,_,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,_,a);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,_,a))}unhook(y,_=!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=_,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 x=new f.Params;x.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=x,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():x,this._data="",this._hitLimit=!1}put(y,_,a){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,_,a),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let _=!1;if(this._hitLimit)_=!1;else if(y&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,_}}},2015:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=n(844),f=n(8742),l=n(6242),g=n(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,u,b){this.table[d<<8|h]=u<<4|b}addMany(h,d,u,b){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=u<<4|b}}i.TransitionTable=x;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),h=Array.apply(null,Array(256)).map(((j,w)=>w)),d=(j,w)=>h.slice(j,w),u=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const S=d(0,14);let E;for(E in a.setDefault(1,0),a.addMany(u,0,2,0),S)a.addMany([24,26,153,154],E,3,0),a.addMany(d(128,144),E,3,0),a.addMany(d(144,152),E,3,0),a.add(156,E,0,0),a.add(27,E,11,1),a.add(157,E,4,8),a.addMany([152,158,159],E,0,7),a.add(155,E,11,3),a.add(144,E,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(u,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(u,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(u,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 _ extends c.Disposable{constructor(h=i.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 f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,u,b)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,u)=>{},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 u=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=h.prefix.charCodeAt(0),u&&60>u||u>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 E=h.intermediates.charCodeAt(S);if(32>E||E>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=E}}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 u<<=8,u|=b,u}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 u=this._identifier(h,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const b=this._escHandlers[u];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 u=this._identifier(h);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const b=this._csiHandlers[u];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,u,b,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=u,this._parseStack.transition=b,this._parseStack.chunkPos=S}parse(h,d,u){let b,S=0,E=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let k=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&k>-1){for(;k>=0&&(b=w[k](this._params),b!==!0);k--)if(b instanceof Promise)return this._parseStack.handlerPos=k,b}this._parseStack.handlers=[];break;case 4:if(u===!1&&k>-1){for(;k>=0&&(b=w[k](),b!==!0);k--)if(b instanceof Promise)return this._parseStack.handlerPos=k,b}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(S!==24&&S!==26,u),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,u),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let w=j;w<d;++w){switch(S=h[w],E=this._transitions.table[this.currentState<<8|(S<160?S:y)],E>>4){case 2:for(let M=w+1;;++M){if(M>=d||(S=h[M])<32||S>126&&S<y){this._printHandler(h,w,M),w=M-1;break}if(++M>=d||(S=h[M])<32||S>126&&S<y){this._printHandler(h,w,M),w=M-1;break}if(++M>=d||(S=h[M])<32||S>126&&S<y){this._printHandler(h,w,M),w=M-1;break}if(++M>=d||(S=h[M])<32||S>126&&S<y){this._printHandler(h,w,M),w=M-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:w,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const k=this._csiHandlers[this._collect<<8|S];let N=k?k.length-1:-1;for(;N>=0&&(b=k[N](this._params),b!==!0);N--)if(b instanceof Promise)return this._preserveStack(3,k,N,E,w),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(++w<d&&(S=h[w])>47&&S<60);w--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let R=L?L.length-1:-1;for(;R>=0&&(b=L[R](),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(4,L,R,E,w),b;R<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 M=w+1;;++M)if(M>=d||(S=h[M])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,w,M),w=M-1;break}break;case 14:if(b=this._dcsParser.unhook(S!==24&&S!==26),b)return this._preserveStack(6,[],0,E,w),b;S===27&&(E|=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 M=w+1;;M++)if(M>=d||(S=h[M])<32||S>127&&S<y){this._oscParser.put(h,w,M),w=M-1;break}break;case 6:if(b=this._oscParser.end(S!==24&&S!==26),b)return this._preserveStack(5,[],0,E,w),b;S===27&&(E|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&E}}}i.EscapeSequenceParser=_},6242:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=n(5770),f=n(482),l=[];i.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,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(x),{dispose:()=>{const _=y.indexOf(x);_!==-1&&y.splice(_,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,x,y){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(g,x,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,x,y))}start(){this.reset(),this._state=1}put(g,x,y){if(this._state!==3){if(this._state===1)for(;x<y;){const _=g[x++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&y-x>0&&this._put(g,x,y)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,_=this._active.length-1,a=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,y=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;_>=0&&(y=this._active[_].end(g),y!==!0);_--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,y;_--}for(;_>=0;_--)if(y=this._active[_].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=l,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,x,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,x}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let x=Array.isArray(l[0])?1:0;x<l.length;++x){const y=l[x];if(Array.isArray(y))for(let _=0;_<y.length;++_)g.addSubParam(y[_]);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 x=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-x>0&&l.push(Array.prototype.slice.call(this._subParams,x,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>n?n: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>n?n: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,x=255&this._subParamsIdx[l];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-x>0&&(l[g]=this._subParams.slice(x,y))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,y=x[g-1];x[g-1]=~y?Math.min(10*y+l,n):l}}i.Params=c},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===n){c=f;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(c,1)}}},8771:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=n(3785),f=n(511);i.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 f.CellData}}},3785:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=n(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,l){if(!(f<0||f>=this._line.length))return l?(this._line.loadCell(f,l),l):this._line.loadCell(f,new c.CellData)}translateToString(f,l,g){return this._line.translateToString(f,l,g)}}},8285:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=n(8771),f=n(8460),l=n(844);class g extends l.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.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)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,c){return this._core.registerCsiHandler(n,(f=>c(f.toArray())))}addCsiHandler(n,c){return this.registerCsiHandler(n,c)}registerDcsHandler(n,c){return this._core.registerDcsHandler(n,((f,l)=>c(f,l.toArray())))}addDcsHandler(n,c){return this.registerDcsHandler(n,c)}registerEscHandler(n,c){return this._core.registerEscHandler(n,c)}addEscHandler(n,c){return this.registerEscHandler(n,c)}registerOscHandler(n,c){return this._core.registerOscHandler(n,c)}addOscHandler(n,c){return this.registerOscHandler(n,c)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var b,S=arguments.length,E=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(a,h,d,u);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(E=(S<3?b(E):S>3?b(h,d,E):b(h,d))||E);return S>3&&E&&Object.defineProperty(h,d,E),E},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const l=n(8460),g=n(844),x=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let _=i.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,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new x.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 u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===a.fg&&u.getBg(0)===a.bg||(u=d.getBlankLine(a,h),this._cachedBlankLine=u),u.isWrapped=h;const b=d.ybase+d.scrollTop,S=d.ybase+d.scrollBottom;if(d.scrollTop===0){const E=d.lines.isFull;S===d.lines.length-1?E?d.lines.recycle().copyFrom(u):d.lines.push(u.clone()):d.lines.splice(S+1,0,u.clone()),E?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const E=S-b+1;d.lines.shiftElements(b+1,E-1,-1),d.lines.set(S,u.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const u=this.buffer;if(a<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else a+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const b=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+a,u.ybase),0),b!==u.ydisp&&(h||this._onScroll.fire(u.ydisp))}};i.BufferService=_=c([f(0,y.IOptionsService)],_)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,c){this._charsets[n]=c,this.glevel===n&&(this.charset=c)}}},1753:function(v,i,n){var c=this&&this.__decorate||function(u,b,S,E){var j,w=arguments.length,k=w<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,S):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(u,b,S,E);else for(var N=u.length-1;N>=0;N--)(j=u[N])&&(k=(w<3?j(k):w>3?j(b,S,k):j(b,S))||k);return w>3&&k&&Object.defineProperty(b,S,k),k},f=this&&this.__param||function(u,b){return function(S,E){b(S,E,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const l=n(2585),g=n(8460),x=n(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function _(u,b){let S=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(S|=64,S|=u.action):(S|=3&u.button,4&u.button&&(S|=64),8&u.button&&(S|=128),u.action===32?S|=32:u.action!==0||b||(S|=3)),S}const a=String.fromCharCode,h={DEFAULT:u=>{const b=[_(u,!1)+32,u.col+32,u.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:u=>{const b=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.col};${u.row}${b}`},SGR_PIXELS:u=>{const b=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.x};${u.y}${b}`}};let d=i.CoreMouseService=class extends x.Disposable{constructor(u,b){super(),this._bufferService=u,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(u,b){this._protocols[u]=b}addEncoding(u,b){this._encodings[u]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const b=this._encodings[this._activeEncoding](u);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,b,S){if(S){if(u.x!==b.x||u.y!==b.y)return!1}else if(u.col!==b.col||u.row!==b.row)return!1;return u.button===b.button&&u.action===b.action&&u.ctrl===b.ctrl&&u.alt===b.alt&&u.shift===b.shift}};i.CoreMouseService=d=c([f(0,l.IBufferService),f(1,l.ICoreService)],d)},6975:function(v,i,n){var c=this&&this.__decorate||function(d,u,b,S){var E,j=arguments.length,w=j<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,u,b,S);else for(var k=d.length-1;k>=0;k--)(E=d[k])&&(w=(j<3?E(w):j>3?E(u,b,w):E(u,b))||w);return j>3&&w&&Object.defineProperty(u,b,w),w},f=this&&this.__param||function(d,u){return function(b,S){u(b,S,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const l=n(1439),g=n(8460),x=n(844),y=n(2585),_=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends x.Disposable{constructor(d,u,b){super(),this._bufferService=d,this._logService=u,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)(_),this.decPrivateModes=(0,l.clone)(a)}reset(){this.modes=(0,l.clone)(_),this.decPrivateModes=(0,l.clone)(a)}triggerDataEvent(d,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),u&&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((u=>u.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=h=c([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],h)},9074:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=n(8055),f=n(8460),l=n(844),g=n(6106);let x=0,y=0;class _ 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 f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const u=new a(d);if(u){const b=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),b.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,u,b){var S,E,j;let w=0,k=0;for(const N of this._decorations.getKeyIterator(u))w=(S=N.options.x)!==null&&S!==void 0?S:0,k=w+((E=N.options.width)!==null&&E!==void 0?E:1),d>=w&&d<k&&(!b||((j=N.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&(yield N)}forEachDecorationAtCell(d,u,b,S){this._decorations.forEachByKey(u,(E=>{var j,w,k;x=(j=E.options.x)!==null&&j!==void 0?j:0,y=x+((w=E.options.width)!==null&&w!==void 0?w:1),d>=x&&d<y&&(!b||((k=E.options.layer)!==null&&k!==void 0?k:"bottom")===b)&&S(E)}))}}i.DecorationService=_;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 f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.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,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=n(2585),f=n(8343);class l{constructor(...x){this._entries=new Map;for(const[y,_]of x)this.set(y,_)}set(x,y){const _=this._entries.get(x);return this._entries.set(x,y),_}forEach(x){for(const[y,_]of this._entries.entries())x(y,_)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}i.ServiceCollection=l,i.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const y=(0,f.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),_=[];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}.`);_.push(d)}const a=y.length>0?y[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${x.length} static arguments`);return new g(...x,..._)}}},7866:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var b,S=arguments.length,E=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(a,h,d,u);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(E=(S<3?b(E):S>3?b(h,d,E):b(h,d))||E);return S>3&&E&&Object.defineProperty(h,d,E),E},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const l=n(844),g=n(2585),x={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,_=i.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=x[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,u;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}debug(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}info(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.INFO&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,a,h)}warn(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.WARN&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,a,h)}error(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,a,h)}};i.LogService=_=c([f(0,g.IOptionsService)],_),i.setTraceLogger=function(a){y=a},i.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const u=d.value;d.value=function(...b){if(y.logLevel!==g.LogLevelEnum.TRACE)return u.apply(this,b);y.trace(`GlyphRenderer#${u.name}(${b.map((E=>JSON.stringify(E))).join(", ")})`);const S=u.apply(this,b);return y.trace(`GlyphRenderer#${u.name} return`,S),S}}},7302:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=n(8460),f=n(844),l=n(6114);i.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 x extends f.Disposable{constructor(_){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in _)if(h in a)try{const d=_[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(_,a){return this.onOptionChange((h=>{h===_&&a(this.rawOptions[_])}))}onMultipleOptionChange(_,a){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&a()}))}_setupOptions(){const _=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in i.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:_.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(_,a){switch(_){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${_}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[_];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${_} 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(`${_} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${_} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=x},2660:function(v,i,n){var c=this&&this.__decorate||function(x,y,_,a){var h,d=arguments.length,u=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,_):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(x,y,_,a);else for(var b=x.length-1;b>=0;b--)(h=x[b])&&(u=(d<3?h(u):d>3?h(y,_,u):h(y,_))||u);return d>3&&u&&Object.defineProperty(y,_,u),u},f=this&&this.__param||function(x,y){return function(_,a){y(_,a,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const l=n(2585);let g=i.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const y=this._bufferService.buffer;if(x.id===void 0){const b=y.addMarker(y.ybase+y.y),S={data:x,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(_),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),u={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(u,d))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(x,y){const _=this._dataByLinkId.get(x);if(_&&_.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);_.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(_,a)))}}getLinkData(x){var y;return(y=this._dataByLinkId.get(x))===null||y===void 0?void 0:y.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,y){const _=x.lines.indexOf(y);_!==-1&&(x.lines.splice(_,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};i.OscLinkService=g=c([f(0,l.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[c]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const l=function(g,x,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,a,h){a[n]===a?a[c].push({id:_,index:h}):(a[c]=[{id:_,index:h}],a[n]=a)})(l,g,y)};return l.toString=()=>f,i.serviceRegistry.set(f,l),l}},2585:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const c=n(8343);var f;i.IBufferService=(0,c.createDecorator)("BufferService"),i.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),i.ICoreService=(0,c.createDecorator)("CoreService"),i.ICharsetService=(0,c.createDecorator)("CharsetService"),i.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"})(f||(i.LogLevelEnum=f={})),i.ILogService=(0,c.createDecorator)("LogService"),i.IOptionsService=(0,c.createDecorator)("OptionsService"),i.IOscLinkService=(0,c.createDecorator)("OscLinkService"),i.IUnicodeService=(0,c.createDecorator)("UnicodeService"),i.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=n(8460),f=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new f.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 x=l.length;for(let y=0;y<x;++y){let _=l.charCodeAt(y);if(55296<=_&&_<=56319){if(++y>=x)return g+this.wcwidth(_);const a=l.charCodeAt(y);56320<=a&&a<=57343?_=1024*(_-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(_)}return g}}}},o={};function m(v){var i=o[v];if(i!==void 0)return i.exports;var n=o[v]={exports:{}};return r[v].call(n.exports,n,n.exports,m),n.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=m(9042),n=m(3236),c=m(844),f=m(5741),l=m(8285),g=m(7975),x=m(7090),y=["cols","rows"];class _ extends c.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],u=(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:u.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 x.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,u,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(u=h.width)!==null&&u!==void 0?u:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,u){this._verifyIntegers(h,d,u),this._core.select(h,d,u)}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
|
|
26
|
-
`,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 i}_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=_})(),p})()))})(
|
|
24
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&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(w){const j=this._getMouseBufferCoords(w),T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(T&&L&&j)&&this._areCoordsInSelection(j,T,L)}isCellInSelection(w,j){const T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!T||!L)&&this._areCoordsInSelection([w,j],T,L)}_areCoordsInSelection(w,j,T){return w[1]>j[1]&&w[1]<T[1]||j[1]===T[1]&&w[1]===j[1]&&w[0]>=j[0]&&w[0]<T[0]||j[1]<T[1]&&w[1]===T[1]&&w[0]<T[0]||j[1]<T[1]&&w[1]===j[1]&&w[0]>=j[0]}_selectWordAtCursor(w,j){var T,L;const N=(L=(T=this._linkifier.currentLink)===null||T===void 0?void 0:T.link)===null||L===void 0?void 0:L.range;if(N)return this._model.selectionStart=[N.start.x-1,N.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(N,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const R=this._getMouseBufferCoords(w);return!!R&&(this._selectWordAt(R,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,j){this._model.clearSelection(),w=Math.max(w,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const j=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(w){let j=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const T=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=T?0:(j>T&&(j-=T),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),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(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!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(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const j=this._getMouseBufferCoords(w);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.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(w),!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(w),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const T=this._bufferService.buffer;if(this._model.selectionEnd[1]<T.lines.length){const L=T.lines.get(this._model.selectionEnd[1]);L&&L.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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const j=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const T=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(T&&T[0]!==void 0&&T[1]!==void 0){const L=(0,g.moveToCellSequence)(T[0]-1,T[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,T=!(!w||!j||w[0]===j[0]&&w[1]===j[1]);T?w&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,j,T)):this._oldHasSelection&&this._fireOnSelectionChange(w,j,T)}_fireOnSelectionChange(w,j,T){this._oldSelectionStart=w,this._oldSelectionEnd=j,this._oldHasSelection=T,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(w,j){let T=j;for(let L=0;j>=L;L++){const N=w.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?T--:N>1&&j!==L&&(T+=N-1)}return T}setSelection(w,j,T){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,j],this._model.selectionStartLength=T,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,j,T=!0,L=!0){if(w[0]>=this._bufferService.cols)return;const N=this._bufferService.buffer,R=N.lines.get(w[1]);if(!R)return;const D=N.translateBufferLineToString(w[1],!1);let I=this._convertViewportColToCharacterIndex(R,w[0]),F=I;const z=w[0]-I;let A=0,P=0,O=0,B=0;if(D.charAt(I)===" "){for(;I>0&&D.charAt(I-1)===" ";)I--;for(;F<D.length&&D.charAt(F+1)===" ";)F++}else{let Q=w[0],Z=w[0];R.getWidth(Q)===0&&(A++,Q--),R.getWidth(Z)===2&&(P++,Z++);const he=R.getString(Z).length;for(he>1&&(B+=he-1,F+=he-1);Q>0&&I>0&&!this._isCharWordSeparator(R.loadCell(Q-1,this._workCell));){R.loadCell(Q-1,this._workCell);const M=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,Q--):M>1&&(O+=M-1,I-=M-1),I--,Q--}for(;Z<R.length&&F+1<D.length&&!this._isCharWordSeparator(R.loadCell(Z+1,this._workCell));){R.loadCell(Z+1,this._workCell);const M=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,Z++):M>1&&(B+=M-1,F+=M-1),F++,Z++}}F++;let W=I+z-A+O,V=Math.min(this._bufferService.cols,F-I+A+P-O-B);if(j||D.slice(I,F).trim()!==""){if(T&&W===0&&R.getCodePoint(0)!==32){const Q=N.lines.get(w[1]-1);if(Q&&R.isWrapped&&Q.getCodePoint(this._bufferService.cols-1)!==32){const Z=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(Z){const he=this._bufferService.cols-Z.start;W-=he,V+=he}}}if(L&&W+V===this._bufferService.cols&&R.getCodePoint(this._bufferService.cols-1)!==32){const Q=N.lines.get(w[1]+1);if(Q?.isWrapped&&Q.getCodePoint(0)!==32){const Z=this._getWordAt([0,w[1]+1],!1,!1,!0);Z&&(V+=Z.length)}}return{start:W,length:V}}}_selectWordAt(w,j){const T=this._getWordAt(w,j);if(T){for(;T.start<0;)T.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[T.start,w[1]],this._model.selectionStartLength=T.length}}_selectToWordAt(w){const j=this._getWordAt(w,!0);if(j){let T=w[1];for(;j.start<0;)j.start+=this._bufferService.cols,T--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,T++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,T]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const j=this._bufferService.buffer.getWrappedRangeForLine(w),T={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)(T,this._bufferService.cols)}};i.SelectionService=E=c([f(3,x.IBufferService),f(4,x.ICoreService),f(5,y.IMouseService),f(6,x.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},4725:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const c=n(8343);i.ICharSizeService=(0,c.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),i.IMouseService=(0,c.createDecorator)("MouseService"),i.IRenderService=(0,c.createDecorator)("RenderService"),i.ISelectionService=(0,c.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(v,i,n){var c=this&&this.__decorate||function(E,w,j,T){var L,N=arguments.length,R=N<3?w:T===null?T=Object.getOwnPropertyDescriptor(w,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(E,w,j,T);else for(var D=E.length-1;D>=0;D--)(L=E[D])&&(R=(N<3?L(R):N>3?L(w,j,R):L(w,j))||R);return N>3&&R&&Object.defineProperty(w,j,R),R},f=this&&this.__param||function(E,w){return function(j,T){w(j,T,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const l=n(7239),g=n(8055),b=n(8460),y=n(844),_=n(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),x={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.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")],w=[0,95,135,175,215,255];for(let j=0;j<216;j++){const T=w[j/36%6|0],L=w[j/6%6|0],N=w[j%6];E.push({css:g.channels.toCss(T,L,N),rgba:g.channels.toRgba(T,L,N)})}for(let j=0;j<24;j++){const T=8+10*j;E.push({css:g.channels.toCss(T,T,T),rgba:g.channels.toRgba(T,T,T)})}return E})());let S=i.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 b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:x,selectionBackgroundOpaque:g.color.blend(h,x),selectionInactiveBackgroundTransparent:x,selectionInactiveBackgroundOpaque:g.color.blend(h,x),ansi:i.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 w=this._colors;if(w.foreground=k(E.foreground,a),w.background=k(E.background,h),w.cursor=k(E.cursor,d),w.cursorAccent=k(E.cursorAccent,u),w.selectionBackgroundTransparent=k(E.selectionBackground,x),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(E.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(w.ansi.length-16,E.extendedAnsi.length);for(let T=0;T<j;T++)w.ansi[T+16]=k(E.extendedAnsi[T],i.DEFAULT_ANSI_COLORS[T+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 w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}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,w){if(E!==void 0)try{return g.css.toColor(E)}catch{}return w}i.ThemeService=S=c([f(0,_.IOptionsService)],S)},6349:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(b){super(),this._maxLength=b,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(b){if(this._maxLength===b)return;const y=new Array(b);for(let _=0;_<Math.min(b,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=b,this._startIndex=0}get length(){return this._length}set length(b){if(b>this._length)for(let y=this._length;y<b;y++)this._array[y]=void 0;this._length=b}get(b){return this._array[this._getCyclicIndex(b)]}set(b,y){this._array[this._getCyclicIndex(b)]=y}push(b){this._array[this._getCyclicIndex(this._length)]=b,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(b,y,..._){if(y){for(let a=b;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:b,amount:y})}for(let a=this._length-1;a>=b;a--)this._array[this._getCyclicIndex(a+_.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<_.length;a++)this._array[this._getCyclicIndex(b+a)]=_[a];if(_.length&&this.onInsertEmitter.fire({index:b,amount:_.length}),this._length+_.length>this._maxLength){const a=this._length+_.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=_.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,y,_){if(!(y<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let h=y-1;h>=0;h--)this.set(b+h+_,this.get(b+h));const a=b+y+_-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(b+a+_,this.get(b+a))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}i.CircularList=l},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(c,f=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=f<=1?c[g]:c[g]&&n(c[g],f-1);return l}},8055:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const c=n(6114);let f=0,l=0,g=0,b=0;var y,_,a,h,d;function u(S){const k=S.toString(16);return k.length<2?"0"+k:k}function x(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,w,j){return j!==void 0?`#${u(k)}${u(E)}${u(w)}${u(j)}`:`#${u(k)}${u(E)}${u(w)}`},S.toRgba=function(k,E,w,j=255){return(k<<24|E<<16|w<<8|j)>>>0}})(y||(i.channels=y={})),(function(S){function k(E,w){return b=Math.round(255*w),[f,l,g]=d.toChannels(E.rgba),{css:y.toCss(f,l,g,b),rgba:y.toRgba(f,l,g,b)}}S.blend=function(E,w){if(b=(255&w.rgba)/255,b===1)return{css:w.css,rgba:w.rgba};const j=w.rgba>>24&255,T=w.rgba>>16&255,L=w.rgba>>8&255,N=E.rgba>>24&255,R=E.rgba>>16&255,D=E.rgba>>8&255;return f=N+Math.round((j-N)*b),l=R+Math.round((T-R)*b),g=D+Math.round((L-D)*b),{css:y.toCss(f,l,g),rgba:y.toRgba(f,l,g)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,w,j){const T=d.ensureContrastRatio(E.rgba,w.rgba,j);if(T)return d.toColor(T>>24&255,T>>16&255,T>>8&255)},S.opaque=function(E){const w=(255|E.rgba)>>>0;return[f,l,g]=d.toChannels(w),{css:y.toCss(f,l,g),rgba:w}},S.opacity=k,S.multiplyOpacity=function(E,w){return b=255&E.rgba,k(E,b*w/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(_||(i.color=_={})),(function(S){let k,E;if(!c.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const j=w.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(f,l,g);case 5:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),b=parseInt(w.slice(4,5).repeat(2),16),d.toColor(f,l,g,b);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const j=w.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 f=parseInt(j[1]),l=parseInt(j[2]),g=parseInt(j[3]),b=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(f,l,g,b);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,l,g,b]=k.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,l,g,b),css:w}}})(a||(i.css=a={})),(function(S){function k(E,w,j){const T=E/255,L=w/255,N=j/255;return .2126*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(h||(i.rgb=h={})),(function(S){function k(w,j,T){const L=w>>24&255,N=w>>16&255,R=w>>8&255;let D=j>>24&255,I=j>>16&255,F=j>>8&255,z=x(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,N,R));for(;z<T&&(D>0||I>0||F>0);)D-=Math.max(0,Math.ceil(.1*D)),I-=Math.max(0,Math.ceil(.1*I)),F-=Math.max(0,Math.ceil(.1*F)),z=x(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,N,R));return(D<<24|I<<16|F<<8|255)>>>0}function E(w,j,T){const L=w>>24&255,N=w>>16&255,R=w>>8&255;let D=j>>24&255,I=j>>16&255,F=j>>8&255,z=x(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,N,R));for(;z<T&&(D<255||I<255||F<255);)D=Math.min(255,D+Math.ceil(.1*(255-D))),I=Math.min(255,I+Math.ceil(.1*(255-I))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=x(h.relativeLuminance2(D,I,F),h.relativeLuminance2(L,N,R));return(D<<24|I<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(w,j,T){const L=h.relativeLuminance(w>>8),N=h.relativeLuminance(j>>8);if(x(L,N)<T){if(N<L){const I=k(w,j,T),F=x(L,h.relativeLuminance(I>>8));if(F<T){const z=E(w,j,T);return F>x(L,h.relativeLuminance(z>>8))?I:z}return I}const R=E(w,j,T),D=x(L,h.relativeLuminance(R>>8));if(D<T){const I=k(w,j,T);return D>x(L,h.relativeLuminance(I>>8))?R:I}return R}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},S.toColor=function(w,j,T,L){return{css:y.toCss(w,j,T,L),rgba:y.toRgba(w,j,T,L)}}})(d||(i.rgba=d={})),i.toPaddedHex=u,i.contrastRatio=x},8969:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=n(844),f=n(2585),l=n(4348),g=n(7866),b=n(744),y=n(7302),_=n(6975),a=n(8460),h=n(1753),d=n(1480),u=n(7994),x=n(9282),S=n(5435),k=n(5981),E=n(2660);let w=!1;class j extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((L=>{var N;(N=this._onScrollApi)===null||N===void 0||N.fire(L.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(L){for(const N in L)this.optionsService.options[N]=L[N]}constructor(L){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(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.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((N=>{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((N=>{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(((N,R)=>this._inputHandler.parse(N,R)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,N){this._writeBuffer.write(L,N)}writeSync(L,N){this._logService.logLevel<=f.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(L,N)}resize(L,N){isNaN(L)||isNaN(N)||(L=Math.max(L,b.MINIMUM_COLS),N=Math.max(N,b.MINIMUM_ROWS),this._bufferService.resize(L,N))}scroll(L,N=!1){this._bufferService.scroll(L,N)}scrollLines(L,N,R){this._bufferService.scrollLines(L,N,R)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const N=L-this._bufferService.buffer.ydisp;N!==0&&this.scrollLines(N)}registerEscHandler(L,N){return this._inputHandler.registerEscHandler(L,N)}registerDcsHandler(L,N){return this._inputHandler.registerDcsHandler(L,N)}registerCsiHandler(L,N){return this._inputHandler.registerCsiHandler(L,N)}registerOscHandler(L,N){return this._inputHandler.registerOscHandler(L,N)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const N=this.optionsService.rawOptions.windowsPty;N&&N.buildNumber!==void 0&&N.buildNumber!==void 0?L=N.backend==="conpty"&&N.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(x.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,x.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const N of L)N.dispose()}))}}}i.CoreTerminal=j},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===n)return void this._listeners.splice(c,1)}}})),this._event}fire(n,c){const f=[];for(let l=0;l<this._listeners.length;l++)f.push(this._listeners[l]);for(let l=0;l<f.length;l++)f[l].call(void 0,n,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,c){return n((f=>c.fire(f)))}},5435:function(v,i,n){var c=this&&this.__decorate||function(z,A,P,O){var B,W=arguments.length,V=W<3?A:O===null?O=Object.getOwnPropertyDescriptor(A,P):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(z,A,P,O);else for(var Q=z.length-1;Q>=0;Q--)(B=z[Q])&&(V=(W<3?B(V):W>3?B(A,P,V):B(A,P))||V);return W>3&&V&&Object.defineProperty(A,P,V),V},f=this&&this.__param||function(z,A){return function(P,O){A(P,O,z)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const l=n(2584),g=n(7116),b=n(2015),y=n(844),_=n(482),a=n(8437),h=n(8460),d=n(643),u=n(511),x=n(3734),S=n(2585),k=n(6242),E=n(6351),w=n(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function L(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 N;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(N||(i.WindowsOptionsReportType=N={}));let R=0;class D extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,O,B,W,V,Q,Z,he=new b.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=O,this._logService=B,this._optionsService=W,this._oscLinkService=V,this._coreMouseService=Q,this._unicodeService=Z,this._parser=he,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new u.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 I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((M=>this._activeBuffer=M.activeBuffer))),this._parser.setCsiHandlerFallback(((M,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(M),params:H.toArray()})})),this._parser.setEscHandlerFallback((M=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(M)})})),this._parser.setExecuteHandlerFallback((M=>{this._logService.debug("Unknown EXECUTE code: ",{code:M})})),this._parser.setOscHandlerFallback(((M,H,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:M,action:H,data:U})})),this._parser.setDcsHandlerFallback(((M,H,U)=>{H==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(M),action:H,payload:U})})),this._parser.setPrintHandler(((M,H,U)=>this.print(M,H,U))),this._parser.registerCsiHandler({final:"@"},(M=>this.insertChars(M))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(M=>this.scrollLeft(M))),this._parser.registerCsiHandler({final:"A"},(M=>this.cursorUp(M))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(M=>this.scrollRight(M))),this._parser.registerCsiHandler({final:"B"},(M=>this.cursorDown(M))),this._parser.registerCsiHandler({final:"C"},(M=>this.cursorForward(M))),this._parser.registerCsiHandler({final:"D"},(M=>this.cursorBackward(M))),this._parser.registerCsiHandler({final:"E"},(M=>this.cursorNextLine(M))),this._parser.registerCsiHandler({final:"F"},(M=>this.cursorPrecedingLine(M))),this._parser.registerCsiHandler({final:"G"},(M=>this.cursorCharAbsolute(M))),this._parser.registerCsiHandler({final:"H"},(M=>this.cursorPosition(M))),this._parser.registerCsiHandler({final:"I"},(M=>this.cursorForwardTab(M))),this._parser.registerCsiHandler({final:"J"},(M=>this.eraseInDisplay(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(M=>this.eraseInDisplay(M,!0))),this._parser.registerCsiHandler({final:"K"},(M=>this.eraseInLine(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(M=>this.eraseInLine(M,!0))),this._parser.registerCsiHandler({final:"L"},(M=>this.insertLines(M))),this._parser.registerCsiHandler({final:"M"},(M=>this.deleteLines(M))),this._parser.registerCsiHandler({final:"P"},(M=>this.deleteChars(M))),this._parser.registerCsiHandler({final:"S"},(M=>this.scrollUp(M))),this._parser.registerCsiHandler({final:"T"},(M=>this.scrollDown(M))),this._parser.registerCsiHandler({final:"X"},(M=>this.eraseChars(M))),this._parser.registerCsiHandler({final:"Z"},(M=>this.cursorBackwardTab(M))),this._parser.registerCsiHandler({final:"`"},(M=>this.charPosAbsolute(M))),this._parser.registerCsiHandler({final:"a"},(M=>this.hPositionRelative(M))),this._parser.registerCsiHandler({final:"b"},(M=>this.repeatPrecedingCharacter(M))),this._parser.registerCsiHandler({final:"c"},(M=>this.sendDeviceAttributesPrimary(M))),this._parser.registerCsiHandler({prefix:">",final:"c"},(M=>this.sendDeviceAttributesSecondary(M))),this._parser.registerCsiHandler({final:"d"},(M=>this.linePosAbsolute(M))),this._parser.registerCsiHandler({final:"e"},(M=>this.vPositionRelative(M))),this._parser.registerCsiHandler({final:"f"},(M=>this.hVPosition(M))),this._parser.registerCsiHandler({final:"g"},(M=>this.tabClear(M))),this._parser.registerCsiHandler({final:"h"},(M=>this.setMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(M=>this.setModePrivate(M))),this._parser.registerCsiHandler({final:"l"},(M=>this.resetMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(M=>this.resetModePrivate(M))),this._parser.registerCsiHandler({final:"m"},(M=>this.charAttributes(M))),this._parser.registerCsiHandler({final:"n"},(M=>this.deviceStatus(M))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(M=>this.deviceStatusPrivate(M))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(M=>this.softReset(M))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(M=>this.setCursorStyle(M))),this._parser.registerCsiHandler({final:"r"},(M=>this.setScrollRegion(M))),this._parser.registerCsiHandler({final:"s"},(M=>this.saveCursor(M))),this._parser.registerCsiHandler({final:"t"},(M=>this.windowOptions(M))),this._parser.registerCsiHandler({final:"u"},(M=>this.restoreCursor(M))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(M=>this.insertColumns(M))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(M=>this.deleteColumns(M))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(M=>this.selectProtected(M))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(M=>this.requestMode(M,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(M=>this.requestMode(M,!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((M=>(this.setTitle(M),this.setIconName(M),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((M=>this.setIconName(M)))),this._parser.registerOscHandler(2,new k.OscHandler((M=>this.setTitle(M)))),this._parser.registerOscHandler(4,new k.OscHandler((M=>this.setOrReportIndexedColor(M)))),this._parser.registerOscHandler(8,new k.OscHandler((M=>this.setHyperlink(M)))),this._parser.registerOscHandler(10,new k.OscHandler((M=>this.setOrReportFgColor(M)))),this._parser.registerOscHandler(11,new k.OscHandler((M=>this.setOrReportBgColor(M)))),this._parser.registerOscHandler(12,new k.OscHandler((M=>this.setOrReportCursorColor(M)))),this._parser.registerOscHandler(104,new k.OscHandler((M=>this.restoreIndexedColor(M)))),this._parser.registerOscHandler(110,new k.OscHandler((M=>this.restoreFgColor(M)))),this._parser.registerOscHandler(111,new k.OscHandler((M=>this.restoreBgColor(M)))),this._parser.registerOscHandler(112,new k.OscHandler((M=>this.restoreCursorColor(M)))),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 M in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:M},(()=>this.selectCharset("("+M))),this._parser.registerEscHandler({intermediates:")",final:M},(()=>this.selectCharset(")"+M))),this._parser.registerEscHandler({intermediates:"*",final:M},(()=>this.selectCharset("*"+M))),this._parser.registerEscHandler({intermediates:"+",final:M},(()=>this.selectCharset("+"+M))),this._parser.registerEscHandler({intermediates:"-",final:M},(()=>this.selectCharset("-"+M))),this._parser.registerEscHandler({intermediates:".",final:M},(()=>this.selectCharset("."+M))),this._parser.registerEscHandler({intermediates:"/",final:M},(()=>this.selectCharset("/"+M)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((M=>(this._logService.error("Parsing error: ",M),M))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((M,H)=>this.requestStatusString(M,H))))}_preserveStack(A,P,O,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=O,this._parseStack.position=B}_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,B=this._activeBuffer.x,W=this._activeBuffer.y,V=0;const Q=this._parseStack.paused;if(Q){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(O),O;B=this._parseStack.cursorStartX,W=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>T&&(V=this._parseStack.position+T)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(Z=>String.fromCharCode(Z))).join("")}"`),typeof A=="string"?A.split("").map((Z=>Z.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(A.length,T))),Q||this._dirtyRowTracker.clearRange(),A.length>T)for(let Z=V;Z<A.length;Z+=T){const he=Z+T<A.length?Z+T:A.length,M=typeof A=="string"?this._stringDecoder.decode(A.substring(Z,he),this._parseBuffer):this._utf8Decoder.decode(A.subarray(Z,he),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,M))return this._preserveStack(B,W,M,Z),this._logSlowResolvingAsync(O),O}else if(!Q){const Z=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,Z))return this._preserveStack(B,W,Z,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===B&&this._activeBuffer.y===W||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,O){let B,W;const V=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,he=this._coreService.decPrivateModes.wraparound,M=this._coreService.modes.insertMode,H=this._curAttrData;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-P>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let $=P;$<O;++$){if(B=A[$],W=this._unicodeService.wcwidth(B),B<127&&V){const se=V[String.fromCharCode(B)];se&&(B=se.charCodeAt(0))}if(Q&&this._onA11yChar.fire((0,_.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),W||!this._activeBuffer.x){if(this._activeBuffer.x+W-1>=Z){if(he){for(;this._activeBuffer.x<Z;)U.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),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=Z-1,W===2)continue}if(M&&(U.insertCells(this._activeBuffer.x,W,this._activeBuffer.getNullCell(H),H),U.getWidth(Z-1)===2&&U.setCellFromCodePoint(Z-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),U.setCellFromCodePoint(this._activeBuffer.x++,B,W,H.fg,H.bg,H.extended),W>0)for(;--W;)U.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else U.getWidth(this._activeBuffer.x-1)?U.addCodepointToCell(this._activeBuffer.x-1,B):U.addCodepointToCell(this._activeBuffer.x-2,B)}O-P>0&&(U.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<Z&&O-P>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.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=>!L(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,B=!1,W=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);V.replaceCells(P,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),W),B&&(V.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 B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,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,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,W=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;P--;)this._activeBuffer.lines.splice(W-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 B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;P--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(B,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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);B.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.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 B=0;B<P;++B)O[B]=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:B,activeEncoding:W}=this._coreMouseService,V=this._coreService,{buffers:Q,cols:Z}=this._bufferService,{active:he,alt:M}=Q,H=this._optionsService.rawOptions,U=ce=>ce?1:2,$=A.params[0];return se=$,K=P?$===2?4:$===4?U(V.modes.insertMode):$===12?3:$===20?U(H.convertEol):0:$===1?U(O.applicationCursorKeys):$===3?H.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:$===6?U(O.origin):$===7?U(O.wraparound):$===8?3:$===9?U(B==="X10"):$===12?U(H.cursorBlink):$===25?U(!V.isCursorHidden):$===45?U(O.reverseWraparound):$===66?U(O.applicationKeypad):$===67?4:$===1e3?U(B==="VT200"):$===1002?U(B==="DRAG"):$===1003?U(B==="ANY"):$===1004?U(O.sendFocus):$===1005?4:$===1006?U(W==="SGR"):$===1015?4:$===1016?U(W==="SGR_PIXELS"):$===1048?1:$===47||$===1047||$===1049?U(he===M):$===2004?U(O.bracketedPasteMode):0,V.triggerDataEvent(`${l.C0.ESC}[${P?"":"?"}${se};${K}$y`),!0;var se,K}_updateAttrColor(A,P,O,B,W){return P===2?(A|=50331648,A&=-16777216,A|=x.AttributeData.fromColorRGB([O,B,W])):P===5&&(A&=-50331904,A|=33554432|255&O),A}_extractColor(A,P,O){const B=[0,0,-1,0,0,0];let W=0,V=0;do{if(B[V+W]=A.params[P+V],A.hasSubParams(P+V)){const Q=A.getSubParams(P+V);let Z=0;do B[1]===5&&(W=1),B[V+Z+1+W]=Q[Z];while(++Z<Q.length&&Z+V+1+W<B.length);break}if(B[1]===5&&V+W>=2||B[1]===2&&V+W>=5)break;B[1]&&(W=1)}while(++V+P<A.length&&V+W<B.length);for(let Q=2;Q<B.length;++Q)B[Q]===-1&&(B[Q]=0);switch(B[0]){case 38:O.fg=this._updateAttrColor(O.fg,B[1],B[3],B[4],B[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,B[1],B[3],B[4],B[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,B[1],B[3],B[4],B[5])}return V}_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 B=this._curAttrData;for(let W=0;W<P;W++)O=A.params[W],O>=30&&O<=37?(B.fg&=-50331904,B.fg|=16777216|O-30):O>=40&&O<=47?(B.bg&=-50331904,B.bg|=16777216|O-40):O>=90&&O<=97?(B.fg&=-50331904,B.fg|=16777224|O-90):O>=100&&O<=107?(B.bg&=-50331904,B.bg|=16777224|O-100):O===0?this._processSGR0(B):O===1?B.fg|=134217728:O===3?B.bg|=67108864:O===4?(B.fg|=268435456,this._processUnderline(A.hasSubParams(W)?A.getSubParams(W)[0]:1,B)):O===5?B.fg|=536870912:O===7?B.fg|=67108864:O===8?B.fg|=1073741824:O===9?B.fg|=2147483648:O===2?B.bg|=134217728:O===21?this._processUnderline(2,B):O===22?(B.fg&=-134217729,B.bg&=-134217729):O===23?B.bg&=-67108865:O===24?(B.fg&=-268435457,this._processUnderline(0,B)):O===25?B.fg&=-536870913:O===27?B.fg&=-67108865:O===28?B.fg&=-1073741825:O===29?B.fg&=2147483647:O===39?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):O===49?(B.bg&=-67108864,B.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?W+=this._extractColor(A,W,B):O===53?B.bg|=1073741824:O===55?B.bg&=-1073741825:O===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):O===100?(B.fg&=-67108864,B.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.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(!L(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(N.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(N.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 B=O.shift(),W=O.shift();if(/^\d+$/.exec(B)){const V=parseInt(B);if(F(V))if(W==="?")P.push({type:0,index:V});else{const Q=(0,w.parseColor)(W);Q&&P.push({type:1,index:V,color:Q})}}}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 B;const W=O.findIndex((V=>V.startsWith("id=")));return W!==-1&&(B=O[W].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,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 B=0;B<O.length&&!(P>=this._specialColors.length);++B,++P)if(O[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const W=(0,w.parseColor)(O[B]);W&&this._onColor.fire([{type:1,index:this._specialColors[P],color:W}])}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 B=0;B<O.length;++B)if(/^\d+$/.exec(O[B])){const W=parseInt(O[B]);F(W)&&P.push({type:2,index:W})}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 u.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,B=this._activeBuffer.lines.get(O);B&&(B.fill(A),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const O=this._bufferService.buffer,B=this._optionsService.rawOptions;return(W=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${W}${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}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}i.InputHandler=D;let I=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&&(R=z,z=A,A=R),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}I=c([f(0,S.IBufferService)],I)},844:(v,i)=>{function n(c){for(const f of c)f.dispose();c.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.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 f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.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}},i.toDisposable=function(c){return{dispose:c}},i.disposeArray=n,i.getDisposeArrayDisposable=function(c){return{dispose:()=>n(c)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(f,l,g){this._data[f]||(this._data[f]={}),this._data[f][l]=g}get(f,l){return this._data[f]?this._data[f][l]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(c,f,l,g,b){this._data.get(c,f)||this._data.set(c,f,new n),this._data.get(c,f).set(l,g,b)}get(c,f,l,g){var b;return(b=this._data.get(c,f))===null||b===void 0?void 0:b.get(l,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,c=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const f=n.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),i.isIpad=c==="iPad",i.isIphone=c==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),i.isLinux=c.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(n=this._search(this._getKey(c)),this._array.splice(n,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(n=this._search(f),n===-1)||this._getKey(this._array[n])!==f)return!1;do if(this._array[n]===c)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===c)}forEachByKey(c,f){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do f(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===c)}values(){return[...this._array].values()}_search(c){let f=0,l=this._array.length-1;for(;l>=f;){let g=f+l>>1;const b=this._getKey(this._array[g]);if(b>c)l=g-1;else{if(!(b<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}f=g+1}}return f}}},7226:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=n(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(b){this._tasks.push(b),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(b){this._idleCallback=void 0;let y=0,_=0,a=b.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),_=Math.max(y,_),h=b.timeRemaining(),1.5*_>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 f{_requestCallback(b){return setTimeout((()=>b(this._createDeadline(16))))}_cancelCallback(b){clearTimeout(b)}_createDeadline(b){const y=Date.now()+b;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=l,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=n(643);i.updateWindowsModeWrappedState=function(f){const l=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=l?.get(f.cols-1),b=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);b&&g&&(b.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{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 n;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}}i.AttributeData=n;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}}i.ExtendedAttrs=c},9092:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=n(6349),f=n(7226),l=n(3734),g=n(8437),b=n(4634),y=n(511),_=n(643),a=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,u,x){this._hasScrollback=d,this._optionsService=u,this._bufferService=x,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,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.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,u){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),u)}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 u=d+this._optionsService.rawOptions.scrollback;return u>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:u}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)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,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(u);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(d,x);let E=0;if(this._rows<u)for(let w=this._rows;w<u;w++)this.lines.length<u+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,x)):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,x)));else for(let w=this._rows;w>u;w--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,u-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(d,u),this._cols>d))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(d,x);this._cols=d,this._rows=u,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 u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>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,u){this._cols!==d&&(d>this._cols?this._reflowLarger(d,u):this._reflowSmaller(d,u))}_reflowLarger(d,u){const x=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(x.length>0){const S=(0,b.reflowLargerCreateNewLayout)(this.lines,x);(0,b.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,u,S.countRemoved)}}_reflowLargerAdjustViewport(d,u,x){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=x;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new g.BufferLine(d,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-x,0)}_reflowSmaller(d,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let w=this.lines.get(E);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const j=[w];for(;w.isWrapped&&E>0;)w=this.lines.get(--E),j.unshift(w);const T=this.ybase+this.y;if(T>=E&&T<E+j.length)continue;const L=j[j.length-1].getTrimmedLength(),N=(0,b.reflowSmallerGetNewLineLengths)(j,this._cols,d),R=N.length-j.length;let D;D=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+R):Math.max(0,this.lines.length-this.lines.maxLength+R);const I=[];for(let B=0;B<R;B++){const W=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push(W)}I.length>0&&(S.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let F=N.length-1,z=N[F];z===0&&(F--,z=N[F]);let A=j.length-R-1,P=L;for(;A>=0;){const B=Math.min(P,z);if(j[F]===void 0)break;if(j[F].copyCellsFrom(j[A],P-B,z-B,B,!0),z-=B,z===0&&(F--,z=N[F]),P-=B,P===0){A--;const W=Math.max(A,0);P=(0,b.getWrappedLineTrimmedLength)(j,W,this._cols)}}for(let B=0;B<j.length;B++)N[B]<d&&j[B].setCell(N[B],x);let O=R-D;for(;O-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+R,this.ybase+u-1)}if(S.length>0){const E=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const j=this.lines.length;let T=j-1,L=0,N=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let R=0;for(let F=Math.min(this.lines.maxLength-1,j+k-1);F>=0;F--)if(N&&N.start>T+R){for(let z=N.newLines.length-1;z>=0;z--)this.lines.set(F--,N.newLines[z]);F++,E.push({index:T+1,amount:N.newLines.length}),R+=N.newLines.length,N=S[++L]}else this.lines.set(F,w[T--]);let D=0;for(let F=E.length-1;F>=0;F--)E[F].index+=D,this.lines.onInsertEmitter.fire(E[F]),D+=E[F].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,u,x=0,S){const k=this.lines.get(d);return k?k.translateToString(u,x,S):""}getWrappedRangeForLine(d){let u=d,x=d;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;x+1<this.lines.length&&this.lines.get(x+1).isWrapped;)x++;return{first:u,last:x}}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 u=0;u<this.markers.length;u++)this.markers[u].line===d&&(this.markers[u].dispose(),this.markers.splice(u--,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 u=new a.Marker(d);return this.markers.push(u),u.register(this.lines.onTrim((x=>{u.line-=x,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((x=>{u.line>=x.index&&(u.line+=x.amount)}))),u.register(this.lines.onDelete((x=>{u.line>=x.index&&u.line<x.index+x.amount&&u.dispose(),u.line>x.index&&(u.line-=x.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=n(3734),f=n(511),l=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let b=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const u=h||f.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let x=0;x<a;++x)this.setCell(x,u);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 b=3*a,h.content=this._data[b+0],h.fg=this._data[b+1],h.bg=this._data[b+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,u,x,S){268435456&x&&(this._extendedAttrs[a]=S),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=u,this._data[3*a+2]=x}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,u){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length-a){const x=new f.CellData;for(let S=this.length-a-h-1;S>=0;--S)this.setCell(a+h+S,this.loadCell(a+S,x));for(let S=0;S<h;++S)this.setCell(a+S,d)}else for(let x=a;x<this.length;++x)this.setCell(x,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(a,h,d,u){if(a%=this.length,h<this.length-a){const x=new f.CellData;for(let S=0;S<this.length-a-h;++S)this.setCell(a+S,this.loadCell(a+h+S,x));for(let S=this.length-h;S<this.length;++S)this.setCell(S,d)}else for(let x=a;x<this.length;++x)this.setCell(x,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(a,h,d,u,x=!1){if(x)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.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,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.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 u=new Uint32Array(d);u.set(this._data),this._data=u}for(let u=this.length;u<a;++u)this.setCell(u,h)}else{this._data=this._data.subarray(0,d);const u=Object.keys(this._combined);for(let S=0;S<u.length;S++){const k=parseInt(u[S],10);k>=a&&delete this._combined[k]}const x=Object.keys(this._extendedAttrs);for(let S=0;S<x.length;S++){const k=parseInt(x[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,u,x){const S=a._data;if(x)for(let E=u-1;E>=0;E--){for(let w=0;w<3;w++)this._data[3*(d+E)+w]=S[3*(h+E)+w];268435456&S[3*(h+E)+2]&&(this._extendedAttrs[d+E]=a._extendedAttrs[h+E])}else for(let E=0;E<u;E++){for(let w=0;w<3;w++)this._data[3*(d+E)+w]=S[3*(h+E)+w];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 w=parseInt(k[E],10);w>=h&&(this._combined[w-h+d]=a._combined[w])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let u="";for(;h<d;){const x=this._data[3*h+0],S=2097151&x;u+=2097152&x?this._combined[h]:S?(0,g.stringFromCodePoint)(S):l.WHITESPACE_CELL_CHAR,h+=x>>22||1}return u}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,c){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return c*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(v,i)=>{function n(c,f,l){if(f===c.length-1)return c[f].getTrimmedLength();const g=!c[f].hasContent(l-1)&&c[f].getWidth(l-1)===1,b=c[f+1].getWidth(0)===2;return g&&b?l-1:l}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,f,l,g,b){const y=[];for(let _=0;_<c.length-1;_++){let a=_,h=c.get(++a);if(!h.isWrapped)continue;const d=[c.get(_)];for(;a<c.length&&h.isWrapped;)d.push(h),h=c.get(++a);if(g>=_&&g<a){_+=d.length-1;continue}let u=0,x=n(d,u,f),S=1,k=0;for(;S<d.length;){const w=n(d,S,f),j=w-k,T=l-x,L=Math.min(j,T);d[u].copyCellsFrom(d[S],k,x,L,!1),x+=L,x===l&&(u++,x=0),k+=L,k===w&&(S++,k=0),x===0&&u!==0&&d[u-1].getWidth(l-1)===2&&(d[u].copyCellsFrom(d[u-1],l-1,x++,1,!1),d[u-1].setCell(l-1,b))}d[u].replaceCells(x,l,b);let E=0;for(let w=d.length-1;w>0&&(w>u||d[w].getTrimmedLength()===0);w--)E++;E>0&&(y.push(_+d.length-E),y.push(E)),_+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(c,f){const l=[];let g=0,b=f[g],y=0;for(let _=0;_<c.length;_++)if(b===_){const a=f[++g];c.onDeleteEmitter.fire({index:_-y,amount:a}),_+=a-1,y+=a,b=f[++g]}else l.push(_);return{layout:l,countRemoved:y}},i.reflowLargerApplyNewLayout=function(c,f){const l=[];for(let g=0;g<f.length;g++)l.push(c.get(f[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=f.length},i.reflowSmallerGetNewLineLengths=function(c,f,l){const g=[],b=c.map(((h,d)=>n(c,d,f))).reduce(((h,d)=>h+d));let y=0,_=0,a=0;for(;a<b;){if(b-a<l){g.push(b-a);break}y+=l;const h=n(c,_,f);y>h&&(y-=h,_++);const d=c[_].getWidth(y-1)===2;d&&y--;const u=d?l-1:l;g.push(u),a+=u}return g},i.getWrappedLineTrimmedLength=n},5295:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=n(8460),f=n(844),l=n(9092);class g extends f.Disposable{constructor(y,_){super(),this._optionsService=y,this._bufferService=_,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,_){this._normal.resize(y,_),this._alt.resize(y,_),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=n(482),f=n(643),l=n(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 _=new g;return _.setFromCharData(y),_}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[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const a=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=n(8460),f=n(844);class l{get id(){return this._id}constructor(b){this.line=b,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,f.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}i.Marker=l,l._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.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:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var n,c,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.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=`
|
|
25
|
+
`,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=""})(n||(i.C0=n={})),(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||(i.C1=c={})),(function(l){l.ST=`${n.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=n(2584),f={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:["'",'"']};i.evaluateKeyboardEvent=function(l,g,b,y){const _={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"?_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){_.key=c.C0.ESC+c.C0.DEL;break}_.key=c.C0.DEL;break;case 9:if(l.shiftKey){_.key=c.C0.ESC+"[Z";break}_.key=c.C0.HT,_.cancel=!0;break;case 13:_.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,_.cancel=!0;break;case 27:_.key=c.C0.ESC,l.altKey&&(_.key=c.C0.ESC+c.C0.ESC),_.cancel=!0;break;case 37:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"D",_.key===c.C0.ESC+"[1;3D"&&(_.key=c.C0.ESC+(b?"b":"[1;5D"))):_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"C",_.key===c.C0.ESC+"[1;3C"&&(_.key=c.C0.ESC+(b?"f":"[1;5C"))):_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"A",b||_.key!==c.C0.ESC+"[1;3A"||(_.key=c.C0.ESC+"[1;5A")):_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;a?(_.key=c.C0.ESC+"[1;"+(a+1)+"B",b||_.key!==c.C0.ESC+"[1;3B"||(_.key=c.C0.ESC+"[1;5B")):_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(_.key=c.C0.ESC+"[2~");break;case 46:_.key=a?c.C0.ESC+"[3;"+(a+1)+"~":c.C0.ESC+"[3~";break;case 36:_.key=a?c.C0.ESC+"[1;"+(a+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:_.key=a?c.C0.ESC+"[1;"+(a+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?_.type=2:l.ctrlKey?_.key=c.C0.ESC+"[5;"+(a+1)+"~":_.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?_.type=3:l.ctrlKey?_.key=c.C0.ESC+"[6;"+(a+1)+"~":_.key=c.C0.ESC+"[6~";break;case 112:_.key=a?c.C0.ESC+"[1;"+(a+1)+"P":c.C0.ESC+"OP";break;case 113:_.key=a?c.C0.ESC+"[1;"+(a+1)+"Q":c.C0.ESC+"OQ";break;case 114:_.key=a?c.C0.ESC+"[1;"+(a+1)+"R":c.C0.ESC+"OR";break;case 115:_.key=a?c.C0.ESC+"[1;"+(a+1)+"S":c.C0.ESC+"OS";break;case 116:_.key=a?c.C0.ESC+"[15;"+(a+1)+"~":c.C0.ESC+"[15~";break;case 117:_.key=a?c.C0.ESC+"[17;"+(a+1)+"~":c.C0.ESC+"[17~";break;case 118:_.key=a?c.C0.ESC+"[18;"+(a+1)+"~":c.C0.ESC+"[18~";break;case 119:_.key=a?c.C0.ESC+"[19;"+(a+1)+"~":c.C0.ESC+"[19~";break;case 120:_.key=a?c.C0.ESC+"[20;"+(a+1)+"~":c.C0.ESC+"[20~";break;case 121:_.key=a?c.C0.ESC+"[21;"+(a+1)+"~":c.C0.ESC+"[21~";break;case 122:_.key=a?c.C0.ESC+"[23;"+(a+1)+"~":c.C0.ESC+"[23~";break;case 123:_.key=a?c.C0.ESC+"[24;"+(a+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(b&&!y||!l.altKey||l.metaKey)!b||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?_.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(_.key=c.C0.US),l.key==="@"&&(_.key=c.C0.NUL)):l.keyCode===65&&(_.type=1);else{const h=f[l.keyCode],d=h?.[l.shiftKey?1:0];if(d)_.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const u=l.ctrlKey?l.keyCode-64:l.keyCode+32;let x=String.fromCharCode(u);l.shiftKey&&(x=x.toUpperCase()),_.key=c.C0.ESC+x}else if(l.keyCode===32)_.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let u=l.code.slice(3,4);l.shiftKey||(u=u.toLowerCase()),_.key=c.C0.ESC+u,_.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?_.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?_.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?_.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?_.key=c.C0.DEL:l.keyCode===219?_.key=c.C0.ESC:l.keyCode===220?_.key=c.C0.FS:l.keyCode===221&&(_.key=c.C0.GS)}return _}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,c=0,f=n.length){let l="";for(let g=c;g<f;++g){let b=n[g];b>65535?(b-=65536,l+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):l+=String.fromCharCode(b)}return l},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,c){const f=n.length;if(!f)return 0;let l=0,g=0;if(this._interim){const b=n.charCodeAt(g++);56320<=b&&b<=57343?c[l++]=1024*(this._interim-55296)+b-56320+65536:(c[l++]=this._interim,c[l++]=b),this._interim=0}for(let b=g;b<f;++b){const y=n.charCodeAt(b);if(55296<=y&&y<=56319){if(++b>=f)return this._interim=y,l;const _=n.charCodeAt(b);56320<=_&&_<=57343?c[l++]=1024*(y-55296)+_-56320+65536:(c[l++]=y,c[l++]=_)}else y!==65279&&(c[l++]=y)}return l}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,c){const f=n.length;if(!f)return 0;let l,g,b,y,_=0,a=0,h=0;if(this.interim[0]){let x=!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 w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=w-E;for(;h<j;){if(h>=f)return 0;if(k=n[h++],(192&k)!=128){h--,x=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}x||(w===2?S<128?h--:c[_++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(c[_++]=S):S<65536||S>1114111||(c[_++]=S)),this.interim.fill(0)}const d=f-4;let u=h;for(;u<f;){for(;!(!(u<d)||128&(l=n[u])||128&(g=n[u+1])||128&(b=n[u+2])||128&(y=n[u+3]));)c[_++]=l,c[_++]=g,c[_++]=b,c[_++]=y,u+=4;if(l=n[u++],l<128)c[_++]=l;else if((224&l)==192){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(a=(31&l)<<6|63&g,a<128){u--;continue}c[_++]=a}else if((240&l)==224){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(b=n[u++],(192&b)!=128){u--;continue}if(a=(15&l)<<12|(63&g)<<6|63&b,a<2048||a>=55296&&a<=57343||a===65279)continue;c[_++]=a}else if((248&l)==240){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(b=n[u++],(192&b)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=b,_;if(y=n[u++],(192&y)!=128){u--;continue}if(a=(7&l)<<18|(63&g)<<12|(63&b)<<6|63&y,a<65536||a>1114111)continue;c[_++]=a}}return _}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[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 f;i.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let l=0;l<n.length;++l)f.fill(0,n[l][0],n[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?f[l]:(function(g,b){let y,_=0,a=b.length-1;if(g<b[0][0]||g>b[a][1])return!1;for(;a>=_;)if(y=_+a>>1,g>b[y][1])_=y+1;else{if(!(g<b[y][0]))return!0;a=y-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(b){super(),this._action=b,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(b,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(b,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+=b.length,this._writeBuffer.push(b),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(y)}_innerWrite(b=0,y=!0){const _=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,y);if(h){const u=x=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,x))):this._innerWrite(_,x);return void h.catch((x=>(queueMicrotask((()=>{throw x})),Promise.resolve(!1)))).then(u)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-_>=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()}}i.WriteBuffer=l},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\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 f(l,g){const b=l.toString(16),y=b.length<2?"0"+b:b;switch(g){case 4:return b[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const b=n.exec(g);if(b){const y=b[1]?15:b[4]?255:b[7]?4095:65535;return[Math.round(parseInt(b[1]||b[4]||b[7]||b[10],16)/y*255),Math.round(parseInt(b[2]||b[5]||b[8]||b[11],16)/y*255),Math.round(parseInt(b[3]||b[6]||b[9]||b[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const b=g.length/3,y=[0,0,0];for(let _=0;_<3;++_){const a=parseInt(g.slice(b*_,b*_+b),16);y[_]=b===1?a<<4:b===2?a:b===3?a>>4:a>>8}return y}},i.toRgbString=function(l,g=16){const[b,y,_]=l;return`rgb:${f(b,g)}/${f(y,g)}/${f(_,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=n(482),f=n(8742),l=n(5770),g=[];i.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,_){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(_),{dispose:()=>{const h=a.indexOf(_);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,_){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(_);else this._handlerFb(this._ident,"HOOK",_)}put(y,_,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,_,a);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,_,a))}unhook(y,_=!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=_,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 b=new f.Params;b.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=b,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():b,this._data="",this._hitLimit=!1}put(y,_,a){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,_,a),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let _=!1;if(this._hitLimit)_=!1;else if(y&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((a=>(this._params=b,this._data="",this._hitLimit=!1,a)));return this._params=b,this._data="",this._hitLimit=!1,_}}},2015:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=n(844),f=n(8742),l=n(6242),g=n(6351);class b{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,u,x){this.table[d<<8|h]=u<<4|x}addMany(h,d,u,x){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=u<<4|x}}i.TransitionTable=b;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new b(4095),h=Array.apply(null,Array(256)).map(((E,w)=>w)),d=(E,w)=>h.slice(E,w),u=d(32,127),x=d(0,24);x.push(25),x.push.apply(x,d(28,32));const S=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(u,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(x,0,3,0),a.addMany(x,1,3,1),a.add(127,1,0,1),a.addMany(x,8,0,8),a.addMany(x,3,3,3),a.add(127,3,0,3),a.addMany(x,4,3,4),a.add(127,4,0,4),a.addMany(x,6,3,6),a.addMany(x,5,3,5),a.add(127,5,0,5),a.addMany(x,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(u,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(u,7,0,7),a.addMany(x,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(x,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(x,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(x,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(x,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(x,13,13,13),a.addMany(u,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 _ extends c.Disposable{constructor(h=i.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 f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,u,x)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,u)=>{},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 u=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=h.prefix.charCodeAt(0),u&&60>u||u>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");u<<=8,u|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const x=h.final.charCodeAt(0);if(d[0]>x||x>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return u<<=8,u|=x,u}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 u=this._identifier(h,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const x=this._escHandlers[u];return x.push(d),{dispose:()=>{const S=x.indexOf(d);S!==-1&&x.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 u=this._identifier(h);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const x=this._csiHandlers[u];return x.push(d),{dispose:()=>{const S=x.indexOf(d);S!==-1&&x.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,u,x,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=u,this._parseStack.transition=x,this._parseStack.chunkPos=S}parse(h,d,u){let x,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(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&j>-1){for(;j>=0&&(x=w[j](this._params),x!==!0);j--)if(x instanceof Promise)return this._parseStack.handlerPos=j,x}this._parseStack.handlers=[];break;case 4:if(u===!1&&j>-1){for(;j>=0&&(x=w[j](),x!==!0);j--)if(x instanceof Promise)return this._parseStack.handlerPos=j,x}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],x=this._dcsParser.unhook(S!==24&&S!==26,u),x)return x;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],x=this._oscParser.end(S!==24&&S!==26,u),x)return x;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 w=E;w<d;++w){switch(S=h[w],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let R=w+1;;++R){if(R>=d||(S=h[R])<32||S>126&&S<y){this._printHandler(h,w,R),w=R-1;break}if(++R>=d||(S=h[R])<32||S>126&&S<y){this._printHandler(h,w,R),w=R-1;break}if(++R>=d||(S=h[R])<32||S>126&&S<y){this._printHandler(h,w,R),w=R-1;break}if(++R>=d||(S=h[R])<32||S>126&&S<y){this._printHandler(h,w,R),w=R-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:w,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 T=j?j.length-1:-1;for(;T>=0&&(x=j[T](this._params),x!==!0);T--)if(x instanceof Promise)return this._preserveStack(3,j,T,k,w),x;T<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(++w<d&&(S=h[w])>47&&S<60);w--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let N=L?L.length-1:-1;for(;N>=0&&(x=L[N](),x!==!0);N--)if(x instanceof Promise)return this._preserveStack(4,L,N,k,w),x;N<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 R=w+1;;++R)if(R>=d||(S=h[R])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,w,R),w=R-1;break}break;case 14:if(x=this._dcsParser.unhook(S!==24&&S!==26),x)return this._preserveStack(6,[],0,k,w),x;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 R=w+1;;R++)if(R>=d||(S=h[R])<32||S>127&&S<y){this._oscParser.put(h,w,R),w=R-1;break}break;case 6:if(x=this._oscParser.end(S!==24&&S!==26),x)return this._preserveStack(5,[],0,k,w),x;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=_},6242:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=n(5770),f=n(482),l=[];i.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,b){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(b),{dispose:()=>{const _=y.indexOf(b);_!==-1&&y.splice(_,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,b,y){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(g,b,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,b,y))}start(){this.reset(),this._state=1}put(g,b,y){if(this._state!==3){if(this._state===1)for(;b<y;){const _=g[b++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&y-b>0&&this._put(g,b,y)}}end(g,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,_=this._active.length-1,a=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,y=b,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;_>=0&&(y=this._active[_].end(g),y!==!0);_--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,y;_--}for(;_>=0;_--)if(y=this._active[_].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=l,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,b,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,b,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let b=!1;if(this._hitLimit)b=!1;else if(g&&(b=this._handler(this._data),b instanceof Promise))return b.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,b}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let b=Array.isArray(l[0])?1:0;b<l.length;++b){const y=l[b];if(Array.isArray(y))for(let _=0;_<y.length;++_)g.addSubParam(y[_]);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 b=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-b>0&&l.push(Array.prototype.slice.call(this._subParams,b,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>n?n: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>n?n: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,b=255&this._subParamsIdx[l];return b-g>0?this._subParams.subarray(g,b):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const b=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-b>0&&(l[g]=this._subParams.slice(b,y))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,y=b[g-1];b[g-1]=~y?Math.min(10*y+l,n):l}}i.Params=c},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===n){c=f;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(c,1)}}},8771:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=n(3785),f=n(511);i.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 f.CellData}}},3785:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=n(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,l){if(!(f<0||f>=this._line.length))return l?(this._line.loadCell(f,l),l):this._line.loadCell(f,new c.CellData)}translateToString(f,l,g){return this._line.translateToString(f,l,g)}}},8285:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=n(8771),f=n(8460),l=n(844);class g extends l.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.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)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,c){return this._core.registerCsiHandler(n,(f=>c(f.toArray())))}addCsiHandler(n,c){return this.registerCsiHandler(n,c)}registerDcsHandler(n,c){return this._core.registerDcsHandler(n,((f,l)=>c(f,l.toArray())))}addDcsHandler(n,c){return this.registerDcsHandler(n,c)}registerEscHandler(n,c){return this._core.registerEscHandler(n,c)}addEscHandler(n,c){return this.registerEscHandler(n,c)}registerOscHandler(n,c){return this._core.registerOscHandler(n,c)}addOscHandler(n,c){return this.registerOscHandler(n,c)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(x=a[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const l=n(8460),g=n(844),b=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let _=i.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,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new b.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 u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===a.fg&&u.getBg(0)===a.bg||(u=d.getBlankLine(a,h),this._cachedBlankLine=u),u.isWrapped=h;const x=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(u):d.lines.push(u.clone()):d.lines.splice(S+1,0,u.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=S-x+1;d.lines.shiftElements(x+1,k-1,-1),d.lines.set(S,u.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const u=this.buffer;if(a<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else a+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const x=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+a,u.ybase),0),x!==u.ydisp&&(h||this._onScroll.fire(u.ydisp))}};i.BufferService=_=c([f(0,y.IOptionsService)],_)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,c){this._charsets[n]=c,this.glevel===n&&(this.charset=c)}}},1753:function(v,i,n){var c=this&&this.__decorate||function(u,x,S,k){var E,w=arguments.length,j=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,x,S,k);else for(var T=u.length-1;T>=0;T--)(E=u[T])&&(j=(w<3?E(j):w>3?E(x,S,j):E(x,S))||j);return w>3&&j&&Object.defineProperty(x,S,j),j},f=this&&this.__param||function(u,x){return function(S,k){x(S,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const l=n(2585),g=n(8460),b=n(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function _(u,x){let S=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(S|=64,S|=u.action):(S|=3&u.button,4&u.button&&(S|=64),8&u.button&&(S|=128),u.action===32?S|=32:u.action!==0||x||(S|=3)),S}const a=String.fromCharCode,h={DEFAULT:u=>{const x=[_(u,!1)+32,u.col+32,u.row+32];return x[0]>255||x[1]>255||x[2]>255?"":`\x1B[M${a(x[0])}${a(x[1])}${a(x[2])}`},SGR:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.col};${u.row}${x}`},SGR_PIXELS:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.x};${u.y}${x}`}};let d=i.CoreMouseService=class extends b.Disposable{constructor(u,x){super(),this._bufferService=u,this._coreService=x,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(u,x){this._protocols[u]=x}addEncoding(u,x){this._encodings[u]=x}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const x=this._encodings[this._activeEncoding](u);return x&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(x):this._coreService.triggerDataEvent(x,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,x,S){if(S){if(u.x!==x.x||u.y!==x.y)return!1}else if(u.col!==x.col||u.row!==x.row)return!1;return u.button===x.button&&u.action===x.action&&u.ctrl===x.ctrl&&u.alt===x.alt&&u.shift===x.shift}};i.CoreMouseService=d=c([f(0,l.IBufferService),f(1,l.ICoreService)],d)},6975:function(v,i,n){var c=this&&this.__decorate||function(d,u,x,S){var k,E=arguments.length,w=E<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,x):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,u,x,S);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(w=(E<3?k(w):E>3?k(u,x,w):k(u,x))||w);return E>3&&w&&Object.defineProperty(u,x,w),w},f=this&&this.__param||function(d,u){return function(x,S){u(x,S,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const l=n(1439),g=n(8460),b=n(844),y=n(2585),_=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends b.Disposable{constructor(d,u,x){super(),this._bufferService=d,this._logService=u,this._optionsService=x,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)(_),this.decPrivateModes=(0,l.clone)(a)}reset(){this.modes=(0,l.clone)(_),this.decPrivateModes=(0,l.clone)(a)}triggerDataEvent(d,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const x=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&x.ybase!==x.ydisp&&this._onRequestScrollToBottom.fire(),u&&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((u=>u.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=h=c([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],h)},9074:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=n(8055),f=n(8460),l=n(844),g=n(6106);let b=0,y=0;class _ 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 f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const u=new a(d);if(u){const x=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),x.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,u,x){var S,k,E;let w=0,j=0;for(const T of this._decorations.getKeyIterator(u))w=(S=T.options.x)!==null&&S!==void 0?S:0,j=w+((k=T.options.width)!==null&&k!==void 0?k:1),d>=w&&d<j&&(!x||((E=T.options.layer)!==null&&E!==void 0?E:"bottom")===x)&&(yield T)}forEachDecorationAtCell(d,u,x,S){this._decorations.forEachByKey(u,(k=>{var E,w,j;b=(E=k.options.x)!==null&&E!==void 0?E:0,y=b+((w=k.options.width)!==null&&w!==void 0?w:1),d>=b&&d<y&&(!x||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===x)&&S(k)}))}}i.DecorationService=_;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 f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.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,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=n(2585),f=n(8343);class l{constructor(...b){this._entries=new Map;for(const[y,_]of b)this.set(y,_)}set(b,y){const _=this._entries.get(b);return this._entries.set(b,y),_}forEach(b){for(const[y,_]of this._entries.entries())b(y,_)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}i.ServiceCollection=l,i.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,b){this._services.set(g,b)}getService(g){return this._services.get(g)}createInstance(g,...b){const y=(0,f.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),_=[];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}.`);_.push(d)}const a=y.length>0?y[0].index:b.length;if(b.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${b.length} static arguments`);return new g(...b,..._)}}},7866:function(v,i,n){var c=this&&this.__decorate||function(a,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,u);else for(var E=a.length-1;E>=0;E--)(x=a[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(a,h){return function(d,u){h(d,u,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const l=n(844),g=n(2585),b={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,_=i.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=b[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,u;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}debug(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,a,h)}info(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.INFO&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,a,h)}warn(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.WARN&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,a,h)}error(a,...h){var d,u;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,a,h)}};i.LogService=_=c([f(0,g.IOptionsService)],_),i.setTraceLogger=function(a){y=a},i.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const u=d.value;d.value=function(...x){if(y.logLevel!==g.LogLevelEnum.TRACE)return u.apply(this,x);y.trace(`GlyphRenderer#${u.name}(${x.map((k=>JSON.stringify(k))).join(", ")})`);const S=u.apply(this,x);return y.trace(`GlyphRenderer#${u.name} return`,S),S}}},7302:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=n(8460),f=n(844),l=n(6114);i.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 b extends f.Disposable{constructor(_){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in _)if(h in a)try{const d=_[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(_,a){return this.onOptionChange((h=>{h===_&&a(this.rawOptions[_])}))}onMultipleOptionChange(_,a){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&a()}))}_setupOptions(){const _=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in i.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:_.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(_,a){switch(_){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${_}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[_];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${_} 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(`${_} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${_} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=b},2660:function(v,i,n){var c=this&&this.__decorate||function(b,y,_,a){var h,d=arguments.length,u=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,_):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(b,y,_,a);else for(var x=b.length-1;x>=0;x--)(h=b[x])&&(u=(d<3?h(u):d>3?h(y,_,u):h(y,_))||u);return d>3&&u&&Object.defineProperty(y,_,u),u},f=this&&this.__param||function(b,y){return function(_,a){y(_,a,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const l=n(2585);let g=i.OscLinkService=class{constructor(b){this._bufferService=b,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(b){const y=this._bufferService.buffer;if(b.id===void 0){const x=y.addMarker(y.ybase+y.y),S={data:b,id:this._nextId++,lines:[x]};return x.onDispose((()=>this._removeMarkerFromLink(S,x))),this._dataByLinkId.set(S.id,S),S.id}const _=b,a=this._getEntryIdKey(_),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),u={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(u,d))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(b,y){const _=this._dataByLinkId.get(b);if(_&&_.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);_.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(_,a)))}}getLinkData(b){var y;return(y=this._dataByLinkId.get(b))===null||y===void 0?void 0:y.data}_getEntryIdKey(b){return`${b.id};;${b.uri}`}_removeMarkerFromLink(b,y){const _=b.lines.indexOf(y);_!==-1&&(b.lines.splice(_,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};i.OscLinkService=g=c([f(0,l.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[c]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const l=function(g,b,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,a,h){a[n]===a?a[c].push({id:_,index:h}):(a[c]=[{id:_,index:h}],a[n]=a)})(l,g,y)};return l.toString=()=>f,i.serviceRegistry.set(f,l),l}},2585:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const c=n(8343);var f;i.IBufferService=(0,c.createDecorator)("BufferService"),i.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),i.ICoreService=(0,c.createDecorator)("CoreService"),i.ICharsetService=(0,c.createDecorator)("CharsetService"),i.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"})(f||(i.LogLevelEnum=f={})),i.ILogService=(0,c.createDecorator)("LogService"),i.IOptionsService=(0,c.createDecorator)("OptionsService"),i.IOscLinkService=(0,c.createDecorator)("OscLinkService"),i.IUnicodeService=(0,c.createDecorator)("UnicodeService"),i.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=n(8460),f=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new f.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 b=l.length;for(let y=0;y<b;++y){let _=l.charCodeAt(y);if(55296<=_&&_<=56319){if(++y>=b)return g+this.wcwidth(_);const a=l.charCodeAt(y);56320<=a&&a<=57343?_=1024*(_-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(_)}return g}}}},o={};function m(v){var i=o[v];if(i!==void 0)return i.exports;var n=o[v]={exports:{}};return r[v].call(n.exports,n,n.exports,m),n.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=m(9042),n=m(3236),c=m(844),f=m(5741),l=m(8285),g=m(7975),b=m(7090),y=["cols","rows"];class _ extends c.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=x=>this._core.options[x],u=(x,S)=>{this._checkReadonlyOptions(x),this._core.options[x]=S};for(const x in this._core.options){const S={get:d.bind(this,x),set:u.bind(this,x)};Object.defineProperty(this._publicOptions,x,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 b.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,u,x;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(u=h.width)!==null&&u!==void 0?u:0,(x=h.height)!==null&&x!==void 0?x:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,u){this._verifyIntegers(h,d,u),this._core.select(h,d,u)}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
|
|
26
|
+
`,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 i}_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=_})(),p})()))})(zr)),zr.exports}var uf=df();var hf=2,ff=1,mf=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._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 t=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"))},i=v.top+v.bottom,n=v.right+v.left,c=o-i,f=m-n-t;return{cols:Math.max(hf,Math.floor(f/e.css.cell.width)),rows:Math.max(ff,Math.floor(c/e.css.cell.height))}}};function pf(e={}){const{cwd:t,cols:r,rows:o,onOutput:m,onExit:p}=e,[v,i]=C.useState(null),[n,c]=C.useState(()=>It.isConnected()),[f,l]=C.useState(!1),[g,b]=C.useState(!1),[y,_]=C.useState(!1),a=C.useRef({onOutput:m,onExit:p});a.current={onOutput:m,onExit:p};const h=C.useRef(null);h.current=v,C.useEffect(()=>{if(!v)return;const k=It.getSocket(),E=()=>{c(!0),l(!1),i(null),_(!0)},w=()=>{c(!1),l(!1)},j=R=>{R.terminalId===v&&a.current.onOutput?.(R.data)},T=R=>{R.terminalId===v&&(l(!1),a.current.onExit?.(R.exitCode),i(null))},L=R=>{R.terminalId===v&&l(!0)},N=R=>{R.terminalId===v&&l(!1)};return k.on("connect",E),k.on("disconnect",w),k.on(dt.TERMINAL_STDOUT,j),k.on(dt.TERMINAL_EXIT,T),k.on(dt.TERMINAL_SUBSCRIBED,L),k.on(dt.TERMINAL_UNSUBSCRIBED,N),c(k.connected),k.connected&&k.emit(Jt.SUBSCRIBE,{topic:"terminal",id:v},R=>{R.success&&l(!0)}),()=>{k.off("connect",E),k.off("disconnect",w),k.off(dt.TERMINAL_STDOUT,j),k.off(dt.TERMINAL_EXIT,T),k.off(dt.TERMINAL_SUBSCRIBED,L),k.off(dt.TERMINAL_UNSUBSCRIBED,N),k.emit(Jt.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=C.useCallback(async()=>{const k=It.getSocket();if(!k.connected)return null;b(!0);try{const E=await ge.post("/terminals",{socketId:k.id,cwd:t,cols:r,rows:o});return i(E.terminalId),_(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{b(!1)}},[t,r,o]),u=C.useCallback(async()=>{const k=h.current;if(k){try{await ge.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),l(!1)}},[]),x=C.useCallback(k=>{const E=h.current;if(!E)return;It.getSocket().emit(Jt.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=C.useCallback((k,E)=>{const w=h.current;if(!w)return;It.getSocket().emit(Jt.TERMINAL_RESIZE,{terminalId:w,cols:k,rows:E})},[]);return C.useEffect(()=>()=>{const k=h.current;k&&ge.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:n,isAttached:f,isCreating:g,needsRecreate:y,create:d,destroy:u,sendInput:x,resize:S}}const gf={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"},vf=ie.memo(function({cwd:t,onExit:r,onReady:o}){const m=C.useRef(null),p=C.useRef(null),v=C.useRef(null),i=C.useRef(!1),{terminalId:n,isAttached:c,needsRecreate:f,create:l,sendInput:g,resize:b}=pf({cwd:t,onOutput:C.useCallback(y=>{p.current?.write(y)},[]),onExit:C.useCallback(y=>{p.current?.writeln(`\r
|
|
27
27
|
\x1B[90m[Process exited with code ${y}]\x1B[0m`),r?.(y)},[r])});return C.useEffect(()=>{if(!f)return;const y=p.current;y&&y.writeln(`\r
|
|
28
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),l()},[f,l]),C.useLayoutEffect(()=>{if(!m.current)return;const y=new
|
|
29
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Wn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Hn(Object(r),!0).forEach(function(o){
|
|
28
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),l()},[f,l]),C.useLayoutEffect(()=>{if(!m.current)return;const y=new uf.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:gf,scrollback:5e3,convertEol:!0}),_=new mf;y.loadAddon(_),y.open(m.current);const a=(h=0)=>{if(!(h>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>a(h+1),50);return}_.fit(),b(y.cols,y.rows)}catch{setTimeout(()=>a(h+1),50)}};return a(0),setTimeout(()=>a(1),100),p.current=y,v.current=_,()=>{y.dispose(),p.current=null,v.current=null}},[b]),C.useEffect(()=>{i.current||(i.current=!0,l())},[l]),C.useEffect(()=>{const y=p.current;if(!y||!c)return;const _=y.onData(a=>{g(a)});return()=>_.dispose()},[g,c]),C.useEffect(()=>{c&&o?.({sendInput:g})},[c,g,o]),C.useEffect(()=>{if(!m.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const _=v.current,a=p.current,h=m.current;_&&a&&h&&h.clientWidth>0&&h.clientHeight>0&&(_.fit(),b(a.cols,a.rows))}catch{}})});return y.observe(m.current),()=>y.disconnect()},[b]),s.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!n&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),s.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),_f=ie.memo(function({commands:t,onSelect:r}){const{t:o}=ae(),[m,p]=C.useState(!1),v=C.useRef(null),i=C.useRef(null);return C.useEffect(()=>{if(!m)return;const n=c=>{v.current&&!v.current.contains(c.target)&&i.current&&!i.current.contains(c.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[m]),t.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{ref:i,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:[s.jsx(ld,{size:12}),s.jsx("span",{children:o("快捷命令")}),s.jsx(vt,{size:10,className:`transition-transform ${m?"rotate-180":""}`})]}),m&&s.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:s.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((n,c)=>s.jsxs("button",{onClick:()=>{r(n.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:[s.jsx(Kt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),s.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},c))})})]})]})});let Hr=0;function Fn(){return Hr+=1,{id:`shell-${Hr}`,order:Hr}}const xf=ie.memo(function({cwd:t,quickCommands:r=[]}){const{t:o}=ae(),[m,p]=C.useState(()=>[Fn()]),[v,i]=C.useState(()=>m[0].id),n=C.useRef(new Map),c=C.useCallback(()=>{const y=Fn();p(_=>[..._,y]),i(y.id)},[]),f=C.useCallback((y,_)=>{_.stopPropagation(),n.current.delete(y),p(a=>{const h=a.filter(d=>d.id!==y);return y===v&&h.length>0&&i(h[h.length-1].id),h})},[v]),l=C.useCallback(y=>{n.current.delete(y),p(_=>{const a=_.filter(h=>h.id!==y);return y===v&&a.length>0&&i(a[a.length-1].id),a})},[v]),g=C.useCallback((y,_)=>{n.current.set(y,_.sendInput)},[]),b=C.useCallback(y=>{const _=n.current.get(v);_&&_(y+"\r")},[v]);return s.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[s.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[s.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:m.map(y=>s.jsxs("button",{onClick:()=>i(y.id),className:te("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",y.id===v?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[s.jsx(Js,{size:11,className:"shrink-0"}),s.jsx("span",{children:o("Shell {count}",{count:y.order})}),m.length>1&&s.jsx("span",{onClick:_=>f(y.id,_),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:s.jsx(Wt,{size:10})})]},y.id))}),s.jsx("button",{onClick:c,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:o("New Terminal"),children:s.jsx(os,{size:14})}),r.length>0&&s.jsx(_f,{commands:r,onSelect:b})]}),s.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Js,{size:28}),s.jsx("span",{className:"text-xs",children:o("No terminals open")}),s.jsx("button",{onClick:c,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:o("New Terminal")})]})}):m.map(y=>s.jsx("div",{className:"absolute inset-0",style:{display:y.id===v?"block":"none"},children:s.jsx(vf,{cwd:t,onExit:()=>l(y.id),onReady:_=>g(y.id,_)})},y.id))})]})});function zn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function bf(e){if(Array.isArray(e))return e}function yf(e,t,r){return(t=Nf(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Sf(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,m,p,v,i=[],n=!0,c=!1;try{if(p=(r=r.call(e)).next,t!==0)for(;!(n=(o=p.call(r)).done)&&(i.push(o.value),i.length!==t);n=!0);}catch(f){c=!0,m=f}finally{try{if(!n&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(c)throw m}}return i}}function wf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
29
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Wn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Hn(Object(r),!0).forEach(function(o){yf(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hn(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Cf(e,t){if(e==null)return{};var r,o,m=kf(e,t);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(m[r]=e[r])}return m}function kf(e,t){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Ef(e,t){return bf(e)||Sf(e,t)||Af(e,t)||wf()}function jf(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Nf(e){var t=jf(e,"string");return typeof t=="symbol"?t:t+""}function Af(e,t){if(e){if(typeof e=="string")return zn(e,t);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)?zn(e,t):void 0}}function Rf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),r.push.apply(r,o)}return r}function Un(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$n(Object(r),!0).forEach(function(o){Rf(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$n(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Tf(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(o){return t.reduceRight(function(m,p){return p(m)},o)}}function vs(e){return function t(){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,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return t.apply(r,[].concat(m,i))}}}function ar(e){return{}.toString.call(e).includes("Object")}function Mf(e){return!Object.keys(e).length}function As(e){return typeof e=="function"}function Df(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Lf(e,t){return ar(t)||Ft("changeType"),Object.keys(t).some(function(r){return!Df(e,r)})&&Ft("changeField"),t}function Pf(e){As(e)||Ft("selectorType")}function Of(e){As(e)||ar(e)||Ft("handlerType"),ar(e)&&Object.values(e).some(function(t){return!As(t)})&&Ft("handlersType")}function If(e){e||Ft("initialIsRequired"),ar(e)||Ft("initialType"),Mf(e)&&Ft("initialContent")}function Bf(e,t){throw new Error(e[t]||e.default)}var Ff={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"},Ft=vs(Bf)(Ff),$s={changes:Lf,selector:Pf,handler:Of,initial:If};function zf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};$s.initial(e),$s.handler(t);var r={current:e},o=vs($f)(r,t),m=vs(Wf)(r),p=vs($s.changes)(e),v=vs(Hf)(r);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return $s.selector(c),c(r.current)}function n(c){Tf(o,m,p,v)(c)}return[i,n]}function Hf(e,t){return As(t)?t(e.current):t}function Wf(e,t){return e.current=Un(Un({},e.current),t),t}function $f(e,t,r){return As(t)?t(e.current):Object.keys(r).forEach(function(o){var m;return(m=t[o])===null||m===void 0?void 0:m.call(t,e.current[o])}),r}var Uf={create:zf},qf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Kf(e){return function t(){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,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return t.apply(r,[].concat(m,i))}}}function Xf(e){return{}.toString.call(e).includes("Object")}function Vf(e){return e||qn("configIsRequired"),Xf(e)||qn("configType"),e.urls?(Yf(),{paths:{vs:e.urls.monacoBase}}):e}function Yf(){console.warn(fa.deprecation)}function Gf(e,t){throw new Error(e[t]||e.default)}var fa={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!
|
|
30
30
|
You are using deprecated way of configuration.
|
|
31
31
|
|
|
32
32
|
Instead of using
|
|
@@ -35,7 +35,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
35
35
|
monaco.config({ paths: { vs: '...' } })
|
|
36
36
|
|
|
37
37
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
38
|
-
`},qn=Vf(Zf)(fa),Jf={config:Gf},em=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return function(m){return r.reduceRight(function(p,v){return v(p)},m)}};function ma(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],ma(e[r],t[r]))}),Wn(Wn({},e),t)}var tm={type:"cancelation",msg:"operation is manually canceled"};function Ur(e){var t=!1,r=new Promise(function(o,m){e.then(function(p){return t?m(tm):o(p)}),e.catch(m)});return r.cancel=function(){return t=!0},r}var sm=["monaco"],rm=Kf.create({config:Xf,isInitialized:!1,resolve:null,reject:null,monaco:null}),pa=Nf(rm,2),Fs=pa[0],Cr=pa[1];function im(e){var t=Jf.config(e),r=t.monaco,o=Ef(t,sm);Cr(function(m){return{config:ma(m.config,o),monaco:r}})}function nm(){var e=Fs(function(t){var r=t.monaco,o=t.isInitialized,m=t.resolve;return{monaco:r,isInitialized:o,resolve:m}});if(!e.isInitialized){if(Cr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ur(qr);if(window.monaco&&window.monaco.editor)return ga(window.monaco),e.resolve(window.monaco),Ur(qr);em(om,lm)(cm)}return Ur(qr)}function om(e){return document.body.appendChild(e)}function am(e){var t=document.createElement("script");return e&&(t.src=e),t}function lm(e){var t=Fs(function(o){var m=o.config,p=o.reject;return{config:m,reject:p}}),r=am("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function cm(){var e=Fs(function(r){var o=r.config,m=r.resolve,p=r.reject;return{config:o,resolve:m,reject:p}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var o=r.m||r;ga(o),e.resolve(o)},function(r){e.reject(r)})}function ga(e){Fs().monaco||Cr({monaco:e})}function dm(){return Fs(function(e){var t=e.monaco;return t})}var qr=new Promise(function(e,t){return Cr({resolve:e,reject:t})}),va={config:im,init:nm,__getMonacoInstance:dm},um={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Kr=um,hm={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},fm=hm;function mm({children:e}){return ie.createElement("div",{style:fm.container},e)}var pm=mm,gm=pm;function vm({width:e,height:t,isEditorReady:r,loading:o,_ref:m,className:p,wrapperProps:v}){return ie.createElement("section",{style:{...Kr.wrapper,width:e,height:t},...v},!r&&ie.createElement(gm,null,o),ie.createElement("div",{ref:m,style:{...Kr.fullWidth,...!r&&Kr.hide},className:p}))}var _m=vm,_a=C.memo(_m);function xm(e){C.useEffect(e,[])}var xa=xm;function bm(e,t,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,t)}var St=bm;function Ss(){}function ss(e,t,r,o){return ym(e,o)||Sm(e,t,r,o)}function ym(e,t){return e.editor.getModel(ba(e,t))}function Sm(e,t,r,o){return e.editor.createModel(t,r,o?ba(e,o):void 0)}function ba(e,t){return e.Uri.parse(t)}function wm({original:e,modified:t,language:r,originalLanguage:o,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:c="light",loading:f="Loading...",options:l={},height:g="100%",width:x="100%",className:y,wrapperProps:_={},beforeMount:a=Ss,onMount:h=Ss}){let[d,u]=C.useState(!1),[b,S]=C.useState(!0),E=C.useRef(null),j=C.useRef(null),w=C.useRef(null),k=C.useRef(h),N=C.useRef(a),L=C.useRef(!1);xa(()=>{let I=va.init();return I.then(F=>(j.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>E.current?D():I.cancel()}),St(()=>{if(E.current&&j.current){let I=E.current.getOriginalEditor(),F=ss(j.current,e||"",o||r||"text",p||"");F!==I.getModel()&&I.setModel(F)}},[p],d),St(()=>{if(E.current&&j.current){let I=E.current.getModifiedEditor(),F=ss(j.current,t||"",m||r||"text",v||"");F!==I.getModel()&&I.setModel(F)}},[v],d),St(()=>{let I=E.current.getModifiedEditor();I.getOption(j.current.editor.EditorOption.readOnly)?I.setValue(t||""):t!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[t],d),St(()=>{E.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:I,modified:F}=E.current.getModel();j.current.editor.setModelLanguage(I,o||r||"text"),j.current.editor.setModelLanguage(F,m||r||"text")},[r,o,m],d),St(()=>{j.current?.editor.setTheme(c)},[c],d),St(()=>{E.current?.updateOptions(l)},[l],d);let R=C.useCallback(()=>{if(!j.current)return;N.current(j.current);let I=ss(j.current,e||"",o||r||"text",p||""),F=ss(j.current,t||"",m||r||"text",v||"");E.current?.setModel({original:I,modified:F})},[r,t,m,e,o,p,v]),M=C.useCallback(()=>{!L.current&&w.current&&(E.current=j.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...l}),R(),j.current?.editor.setTheme(c),u(!0),L.current=!0)},[l,c,R]);C.useEffect(()=>{d&&k.current(E.current,j.current)},[d]),C.useEffect(()=>{!b&&!d&&M()},[b,d,M]);function D(){let I=E.current?.getModel();i||I?.original?.dispose(),n||I?.modified?.dispose(),E.current?.dispose()}return ie.createElement(_a,{width:x,height:g,isEditorReady:d,loading:f,_ref:w,className:y,wrapperProps:_})}var Cm=wm;C.memo(Cm);function km(e){let t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}var Em=km,Ks=new Map;function jm({defaultValue:e,defaultLanguage:t,defaultPath:r,value:o,language:m,path:p,theme:v="light",line:i,loading:n="Loading...",options:c={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:g=!1,width:x="100%",height:y="100%",className:_,wrapperProps:a={},beforeMount:h=Ss,onMount:d=Ss,onChange:u,onValidate:b=Ss}){let[S,E]=C.useState(!1),[j,w]=C.useState(!0),k=C.useRef(null),N=C.useRef(null),L=C.useRef(null),R=C.useRef(d),M=C.useRef(h),D=C.useRef(),I=C.useRef(o),F=Em(p),z=C.useRef(!1),A=C.useRef(!1);xa(()=>{let B=va.init();return B.then($=>(k.current=$)&&w(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>N.current?O():B.cancel()}),St(()=>{let B=ss(k.current,e||o||"",t||m||"",p||r||"");B!==N.current?.getModel()&&(l&&Ks.set(F,N.current?.saveViewState()),N.current?.setModel(B),l&&N.current?.restoreViewState(Ks.get(p)))},[p],S),St(()=>{N.current?.updateOptions(c)},[c],S),St(()=>{!N.current||o===void 0||(N.current.getOption(k.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 B=N.current?.getModel();B&&m&&k.current?.editor.setModelLanguage(B,m)},[m],S),St(()=>{i!==void 0&&N.current?.revealLine(i)},[i],S),St(()=>{k.current?.editor.setTheme(v)},[v],S);let P=C.useCallback(()=>{if(!(!L.current||!k.current)&&!z.current){M.current(k.current);let B=p||r,$=ss(k.current,o||e||"",t||m||"",B||"");N.current=k.current?.editor.create(L.current,{model:$,automaticLayout:!0,...c},f),l&&N.current.restoreViewState(Ks.get(B)),k.current.editor.setTheme(v),i!==void 0&&N.current.revealLine(i),E(!0),z.current=!0}},[e,t,r,o,m,p,c,f,l,v,i]);C.useEffect(()=>{S&&R.current(N.current,k.current)},[S]),C.useEffect(()=>{!j&&!S&&P()},[j,S,P]),I.current=o,C.useEffect(()=>{S&&u&&(D.current?.dispose(),D.current=N.current?.onDidChangeModelContent(B=>{A.current||u(N.current.getValue(),B)}))},[S,u]),C.useEffect(()=>{if(S){let B=k.current.editor.onDidChangeMarkers($=>{let Y=N.current.getModel()?.uri;if(Y&&$.find(Q=>Q.path===Y.path)){let Q=k.current.editor.getModelMarkers({resource:Y});b?.(Q)}});return()=>{B?.dispose()}}return()=>{}},[S,b]);function O(){D.current?.dispose(),g?l&&Ks.set(p,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return ie.createElement(_a,{width:x,height:y,isEditorReady:S,loading:n,_ref:L,className:_,wrapperProps:a})}var Nm=jm,Am=C.memo(Nm),Tm=Am,Ct=function(e,t){return Number(e.toFixed(t))},Rm=function(e,t){return typeof e=="number"?e:t},Ke=function(e,t,r){r&&typeof r=="function"&&r(e,t)},Mm=function(e){return-Math.cos(e*Math.PI)/2+.5},Dm=function(e){return e},Lm=function(e){return e*e},Pm=function(e){return e*(2-e)},Om=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Im=function(e){return e*e*e},Bm=function(e){return--e*e*e+1},Fm=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},zm=function(e){return e*e*e*e},Hm=function(e){return 1- --e*e*e*e},Wm=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},$m=function(e){return e*e*e*e*e},Um=function(e){return 1+--e*e*e*e*e},qm=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},ya={easeOut:Mm,linear:Dm,easeInQuad:Lm,easeOutQuad:Pm,easeInOutQuad:Om,easeInCubic:Im,easeOutCubic:Bm,easeInOutCubic:Fm,easeInQuart:zm,easeOutQuart:Hm,easeInOutQuart:Wm,easeInQuint:$m,easeOutQuint:Um,easeInOutQuint:qm},Sa=function(e){typeof e=="number"&&cancelAnimationFrame(e)},kt=function(e){e.mounted&&(Sa(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function wa(e,t,r,o){if(e.mounted){var m=new Date().getTime(),p=1;kt(e),e.animation=function(){if(!e.mounted)return Sa(e.animation);var v=new Date().getTime()-m,i=v/r,n=ya[t],c=n(i);v>=r?(o(p),e.animation=null):e.animation&&(o(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Km(e){var t=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(o))}function Wt(e,t,r,o){var m=Km(t);if(!(!e.mounted||!m)){var p=e.setTransformState,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=t.scale-i,l=t.positionX-n,g=t.positionY-c;r===0?p(t.scale,t.positionX,t.positionY):wa(e,o,r,function(x){var y=i+f*x,_=n+l*x,a=c+g*x;p(y,_,a)})}}function Xm(e,t,r){var o=e.offsetWidth,m=e.offsetHeight,p=t.offsetWidth,v=t.offsetHeight,i=p*r,n=v*r,c=o-i,f=m-n;return{wrapperWidth:o,wrapperHeight:m,newContentWidth:i,newDiffWidth:c,newContentHeight:n,newDiffHeight:f}}var Vm=function(e,t,r,o,m,p,v){var i=e>t?r*(v?1:.5):0,n=o>m?p*(v?1:.5):0,c=e-t-i,f=i,l=o-m-n,g=n;return{minPositionX:c,maxPositionX:f,minPositionY:l,maxPositionY:g}},Wi=function(e,t){var r=e.wrapperComponent,o=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=Xm(r,o,t),v=p.wrapperWidth,i=p.wrapperHeight,n=p.newContentWidth,c=p.newDiffWidth,f=p.newContentHeight,l=p.newDiffHeight,g=Vm(v,n,c,i,f,l,!!m);return g},oi=function(e,t,r,o){return o?e<t?Ct(t,2):e>r?Ct(r,2):Ct(e,2):Ct(e,2)},Kt=function(e,t){var r=Wi(e,t);return e.bounds=r,r};function zs(e,t,r,o,m,p,v){var i=r.minPositionX,n=r.minPositionY,c=r.maxPositionX,f=r.maxPositionY,l=0,g=0;v&&(l=m,g=p);var x=oi(e,i-l,c+l,o),y=oi(t,n-g,f+g,o);return{x,y}}function kr(e,t,r,o,m,p){var v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=o-i;if(typeof t!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:c};var l=n-t*f,g=c-r*f,x=zs(l,g,m,p,0,0,null);return x}function Hs(e,t,r,o,m){var p=m?o:0,v=t-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(t)&&e<=v?v:e}var Kn=function(e,t){var r=e.setup.panning.excluded,o=e.isInitialized,m=e.wrapperComponent,p=t.target,v="shadowRoot"in p&&"composedPath"in t,i=v?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(p),n=o&&p&&i;if(!n)return!1;var c=Er(p,r);return!c},Xn=function(e){var t=e.isInitialized,r=e.isPanning,o=e.setup,m=o.panning.disabled,p=t&&r&&!m;return!!p},Ym=function(e,t){var r=e.transformState,o=r.positionX,m=r.positionY;e.isPanning=!0;var p=t.clientX,v=t.clientY;e.startCoords={x:p-o,y:v-m}},Gm=function(e,t){var r=t.touches,o=e.transformState,m=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-m,y:n-p}}};function Qm(e){var t=e.transformState,r=t.positionX,o=t.positionY,m=t.scale,p=e.setup,v=p.disabled,i=p.limitToBounds,n=p.centerZoomedOut,c=e.wrapperComponent;if(!(v||!c||!e.bounds)){var f=e.bounds,l=f.maxPositionX,g=f.minPositionX,x=f.maxPositionY,y=f.minPositionY,_=r>l||r<g,a=o>x||o<y,h=r>l?c.offsetWidth:e.setup.minPositionX||0,d=o>x?c.offsetHeight:e.setup.minPositionY||0,u=kr(e,h,d,m,e.bounds,i||n),b=u.x,S=u.y;return{scale:m,positionX:_?b:r,positionY:a?S:o}}}function Ca(e,t,r,o,m){var p=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(!(v===null||i===null||t===f&&r===l)){var g=zs(t,r,i,p,o,m,v),x=g.x,y=g.y;e.setTransformState(c,x,y)}}var Zm=function(e,t,r){var o=e.startCoords,m=e.transformState,p=e.setup.panning,v=p.lockAxisX,i=p.lockAxisY,n=m.positionX,c=m.positionY;if(!o)return{x:n,y:c};var f=t-o.x,l=r-o.y,g=v?n:f,x=i?c:l;return{x:g,y:x}},zt=function(e,t){var r=e.setup,o=e.transformState,m=o.scale,p=r.minScale,v=r.disablePadding;return t>0&&m>=p&&!v?t:0},Jm=function(e){var t=e.mounted,r=e.setup,o=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,v=m.disabled,i=!v||p>1||!o||t;return!!i},ep=function(e){var t=e.mounted,r=e.velocity,o=e.bounds,m=e.setup,p=m.disabled,v=m.velocityAnimation,i=e.transformState.scale,n=v.disabled,c=!n||i>1||!p||t;return!(!c||!r||!o)};function tp(e,t){var r=e.setup.velocityAnimation,o=r.equalToMove,m=r.animationTime,p=r.sensitivity;return o?m*t*p:m}function Vn(e,t,r,o,m,p,v,i,n,c){if(m){if(t>v&&r>v){var f=v+(e-v)*c;return f>n?n:f<v?v:f}if(t<p&&r<p){var f=p+(e-p)*c;return f<i?i:f>p?p:f}}return o?t:oi(e,p,v,m)}function sp(e,t){var r=1;return t?Math.min(r,e.offsetWidth/window.innerWidth):r}function rp(e,t){var r=Jm(e);if(r){var o=e.lastMousePosition,m=e.velocityTime,p=e.setup,v=e.wrapperComponent,i=p.velocityAnimation.equalToMove,n=Date.now();if(o&&m&&v){var c=sp(v,i),f=t.x-o.x,l=t.y-o.y,g=f/c,x=l/c,y=n-m,_=f*f+l*l,a=Math.sqrt(_)/y;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=t,e.velocityTime=n}}function ip(e){var t=e.velocity,r=e.bounds,o=e.setup,m=e.wrapperComponent,p=ep(e);if(!(!p||!t||!r||!m)){var v=t.velocityX,i=t.velocityY,n=t.total,c=r.maxPositionX,f=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,x=o.limitToBounds,y=o.alignmentAnimation,_=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,u=_.animationType,b=y.sizeX,S=y.sizeY,E=y.velocityAlignmentTime,j=E,w=tp(e,n),k=Math.max(w,j),N=zt(e,b),L=zt(e,S),R=N*m.offsetWidth/100,M=L*m.offsetHeight/100,D=c+R,I=f-R,F=l+M,z=g-M,A=e.transformState,P=new Date().getTime();wa(e,u,k,function(O){var B=e.transformState,$=B.scale,Y=B.positionX,Q=B.positionY,Z=new Date().getTime()-P,he=Z/j,T=ya[y.animationType],H=1-T(Math.min(1,he)),U=1-O,W=Y+v*U,se=Q+i*U,K=Vn(W,A.positionX,Y,d,x,f,c,I,D,H),ce=Vn(se,A.positionY,Q,h,x,g,l,z,F,H);(Y!==W||Q!==se)&&e.setTransformState($,K,ce)})}}function Yn(e,t){var r=e.transformState.scale;kt(e),Kt(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?Gm(e,t):Ym(e,t)}function $i(e,t){var r=e.transformState.scale,o=e.setup,m=o.minScale,p=o.alignmentAnimation,v=p.disabled,i=p.sizeX,n=p.sizeY,c=p.animationTime,f=p.animationType,l=v||r<m||!i&&!n;if(!l){var g=Qm(e);g&&Wt(e,g,t??c,f)}}function Gn(e,t,r){var o=e.startCoords,m=e.setup,p=m.alignmentAnimation,v=p.sizeX,i=p.sizeY;if(o){var n=Zm(e,t,r),c=n.x,f=n.y,l=zt(e,v),g=zt(e,i);rp(e,{x:c,y:f}),Ca(e,c,f,l,g)}}function np(e){if(e.isPanning){var t=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(),i=p?.width||0,n=p?.height||0,c=v?.width||0,f=v?.height||0,l=i<c||n<f,g=!t&&r&&r?.total>.1&&l;g?ip(e):$i(e)}}function Ui(e,t,r,o){var m=e.setup,p=m.minScale,v=m.maxScale,i=m.limitToBounds,n=Hs(Ct(t,2),p,v,0,!1),c=Kt(e,n),f=kr(e,r,o,n,c,i),l=f.x,g=f.y;return{scale:n,positionX:l,positionY:g}}function ka(e,t,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.minScale,i=p.limitToBounds,n=p.zoomAnimation,c=n.disabled,f=n.animationTime,l=n.animationType,g=c||o>=v;if((o>=1||i)&&$i(e),!(g||!m||!e.mounted)){var x=t||m.offsetWidth/2,y=r||m.offsetHeight/2,_=Ui(e,v,x,y);_&&Wt(e,_,f,l)}}var Ft=function(){return Ft=Object.assign||function(t){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)&&(t[p]=r[p])}return t},Ft.apply(this,arguments)};function Qn(e,t,r){for(var o=0,m=t.length,p;o<m;o++)(p||!(o in t))&&(p||(p=Array.prototype.slice.call(t,0,o)),p[o]=t[o]);return e.concat(p||Array.prototype.slice.call(t))}var Xs={scale:1,positionX:0,positionY:0},gs={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}},ai={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ea=function(e){var t,r,o,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:Xs.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Xs.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Xs.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:Xs.positionY}},Zn=function(e){var t=Ft({},gs);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",m=typeof gs[r]<"u";if(m&&o){var p=Object.prototype.toString.call(gs[r]),v=p==="[object Object]",i=p==="[object Array]";v?t[r]=Ft(Ft({},gs[r]),e[r]):i?t[r]=Qn(Qn([],gs[r],!0),e[r]):t[r]=e[r]}}),t},ja=function(e,t,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.maxScale,i=p.minScale,n=p.zoomAnimation,c=p.smooth,f=n.size;if(!m)throw new Error("Wrapper is not mounted");var l=c?o*Math.exp(t*r):o+t*r,g=Hs(Ct(l,3),i,v,f,!1);return g};function Na(e,t,r,o,m){var p=e.wrapperComponent,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY;if(!p)return console.error("No WrapperComponent found");var f=p.offsetWidth,l=p.offsetHeight,g=(f/2-n)/i,x=(l/2-c)/i,y=ja(e,t,r),_=Ui(e,y,g,x);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");Wt(e,_,o,m)}function Aa(e,t,r,o){var m=e.setup,p=e.wrapperComponent,v=m.limitToBounds,i=Ea(e.props),n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(p){var g=Wi(e,i.scale),x=zs(i.positionX,i.positionY,g,v,0,0,p),y={scale:i.scale,positionX:x.x,positionY:x.y};c===i.scale&&f===i.positionX&&l===i.positionY||(o?.(),Wt(e,y,t,r))}}function op(e,t,r,o){var m=e.getBoundingClientRect(),p=t.getBoundingClientRect(),v=r.getBoundingClientRect(),i=p.x*o.scale,n=p.y*o.scale;return{x:(m.x-v.x+i)/o.scale,y:(m.y-v.y+n)/o.scale}}function ap(e,t,r){var o=e.wrapperComponent,m=e.contentComponent,p=e.transformState,v=e.setup,i=v.limitToBounds,n=v.minScale,c=v.maxScale;if(!o||!m)return p;var f=o.getBoundingClientRect(),l=t.getBoundingClientRect(),g=op(t,o,m,p),x=g.x,y=g.y,_=l.width/p.scale,a=l.height/p.scale,h=o.offsetWidth/_,d=o.offsetHeight/a,u=Hs(r||Math.min(h,d),n,c,0,!1),b=(f.width-_*u)/2,S=(f.height-a*u)/2,E=(f.left-x)*u+b,j=(f.top-y)*u+S,w=Wi(e,u),k=zs(E,j,w,i,0,0,o),N=k.x,L=k.y;return{positionX:N,positionY:L,scale:u}}var lp=function(e){return function(t,r,o){t===void 0&&(t=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Na(e,1,t,r,o)}},cp=function(e){return function(t,r,o){t===void 0&&(t=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Na(e,-1,t,r,o)}},dp=function(e){return function(t,r,o,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var v=e.transformState,i=v.positionX,n=v.positionY,c=v.scale,f=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!f||!l)){var x={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?c:o};Wt(e,x,m,p)}}},up=function(e){return function(t,r){t===void 0&&(t=200),r===void 0&&(r="easeOut"),Aa(e,t,r)}},hp=function(e){return function(t,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 i=Ta(t||m.scale,p,v);Wt(e,i,r,o)}}},fp=function(e){return function(t,r,o,m){o===void 0&&(o=600),m===void 0&&(m="easeOut"),kt(e);var p=e.wrapperComponent,v=typeof t=="string"?document.getElementById(t):t;if(p&&v&&p.contains(v)){var i=ap(e,v,r);Wt(e,i,o,m)}}},dr=function(e){return{instance:e,zoomIn:lp(e),zoomOut:cp(e),setTransform:dp(e),resetTransform:up(e),centerView:hp(e),zoomToElement:fp(e)}},li=function(e){return{instance:e,state:e.transformState}},We=function(e){var t={};return Object.assign(t,li(e)),Object.assign(t,dr(e)),t},Xr=!1;function Vr(){try{var e={get passive(){return Xr=!0,!1}};return e}catch{return Xr=!1,Xr}}var Vs=".".concat(ai.wrapperClass),Er=function(e,t){return t.some(function(r){return e.matches("".concat(Vs," ").concat(r,", ").concat(Vs," .").concat(r,", ").concat(Vs," ").concat(r," *, ").concat(Vs," .").concat(r," *"))})},ci=function(e){e&&clearTimeout(e)},mp=function(e,t,r){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},Ta=function(e,t,r){var o=r.offsetWidth*e,m=r.offsetHeight*e,p=(t.offsetWidth-o)/2,v=(t.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:v}};function pp(e){return function(t){e.forEach(function(r){typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var gp=function(e,t){var r=e.setup.wheel,o=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,n=e.isPanning,c=t.target,f=i&&!n&&!o&&c;if(!f||m&&!t.ctrlKey||p&&t.ctrlKey)return!1;var l=Er(c,v);return!l},vp=function(e){return e?e.deltaY<0?1:-1:0};function _p(e,t){var r=vp(e),o=Rm(t,r);return o}function Ra(e,t,r){var o=t.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 xp=function(e,t,r,o,m){var p=e.transformState.scale,v=e.wrapperComponent,i=e.setup,n=i.maxScale,c=i.minScale,f=i.zoomAnimation,l=i.disablePadding,g=f.size,x=f.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=p+t*r,_=o?!1:!x,a=Hs(Ct(y,3),c,n,g,_&&!l);return a},bp=function(e,t){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(t.deltaY)||r.deltaY>0&&r.deltaY<t.deltaY||r.deltaY<0&&r.deltaY>t.deltaY||Math.sign(r.deltaY)!==Math.sign(t.deltaY):!1},yp=function(e,t){var r=e.setup.pinch,o=r.disabled,m=r.excluded,p=e.isInitialized,v=t.target,i=p&&!o&&v;if(!i)return!1;var n=Er(v,m);return!n},Sp=function(e){var t=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,m=r&&!t&&o;return!!m},wp=function(e,t,r){var o=r.getBoundingClientRect(),m=e.touches,p=Ct(m[0].clientX-o.left,5),v=Ct(m[0].clientY-o.top,5),i=Ct(m[1].clientX-o.left,5),n=Ct(m[1].clientY-o.top,5);return{x:(p+i)/2/t,y:(v+n)/2/t}},Ma=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))},Cp=function(e,t){var r=e.pinchStartScale,o=e.pinchStartDistance,m=e.setup,p=m.maxScale,v=m.minScale,i=m.zoomAnimation,n=m.disablePadding,c=i.size,f=i.disabled;if(!r||o===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var l=t/o,g=l*r;return Hs(Ct(g,2),v,p,c,!f&&!n)},kp=160,Ep=100,jp=function(e,t){var r=e.props,o=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(kt(e),Ke(We(e),t,o),Ke(We(e),t,m))},Np=function(e,t){var r=e.props,o=r.onWheel,m=r.onZoom,p=e.contentComponent,v=e.setup,i=e.transformState,n=i.scale,c=v.limitToBounds,f=v.centerZoomedOut,l=v.zoomAnimation,g=v.wheel,x=v.disablePadding,y=v.smooth,_=l.size,a=l.disabled,h=g.step,d=g.smoothStep;if(!p)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=_p(t,null),b=y?d*Math.abs(t.deltaY):h,S=xp(e,u,b,!t.ctrlKey);if(n!==S){var E=Kt(e,S),j=Ra(t,p,n),w=a||_===0||f||x,k=c&&w,N=kr(e,j.x,j.y,S,E,k),L=N.x,R=N.y;e.previousWheelEvent=t,e.setTransformState(S,L,R),Ke(We(e),t,o),Ke(We(e),t,m)}},Ap=function(e,t){var r=e.props,o=r.onWheelStop,m=r.onZoomStop;ci(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ka(e,t.x,t.y),e.wheelAnimationTimer=null)},Ep);var p=bp(e,t);p&&(ci(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ke(We(e),t,o),Ke(We(e),t,m))},kp))},Da=function(e){for(var t=0,r=0,o=0;o<2;o+=1)t+=e.touches[o].clientX,r+=e.touches[o].clientY;var m=t/2,p=r/2;return{x:m,y:p}},Tp=function(e,t){var r=Ma(t);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Da(t);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,kt(e)},Rp=function(e,t){var r=e.contentComponent,o=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,v=e.setup,i=v.limitToBounds,n=v.centerZoomedOut,c=v.zoomAnimation,f=v.alignmentAnimation,l=c.disabled,g=c.size;if(!(o===null||!r)){var x=wp(t,p,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var y=Ma(t),_=Cp(e,y),a=Da(t),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(_===p&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var u=Kt(e,_),b=l||g===0||n,S=i&&b,E=kr(e,x.x,x.y,_,u,S),j=E.x,w=E.y;e.pinchMidpoint=x,e.lastDistance=y;var k=f.sizeX,N=f.sizeY,L=zt(e,k),R=zt(e,N),M=j+h,D=w+d,I=zs(M,D,u,i,L,R,m),F=I.x,z=I.y;e.setTransformState(_,F,z)}}}},Mp=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ka(e,t?.x,t?.y)},La=function(e,t){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;ci(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ke(We(e),t,r)},o)},Dp=function(e,t){var r=e.props,o=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,i=p.animationType;Ke(We(e),t,o),Aa(e,v,i,function(){return Ke(We(e),t,m)}),La(e,t)};function Lp(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Pp(e,t){var r=e.setup,o=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,v=m.scale,i=e.props,n=i.onZoomStart,c=i.onZoom,f=r.doubleClick,l=f.disabled,g=f.mode,x=f.step,y=f.animationTime,_=f.animationType;if(!l&&!o){if(g==="reset")return Dp(e,t);if(!p)return console.error("No ContentComponent found");var a=Lp(g,e.transformState.scale),h=ja(e,a,x);if(v!==h){Ke(We(e),t,n);var d=Ra(t,p,v),u=Ui(e,h,d.x,d.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");Ke(We(e),t,c),Wt(e,u,y,_),La(e,t)}}}var Op=function(e,t){var r=e.isInitialized,o=e.setup,m=e.wrapperComponent,p=o.doubleClick,v=p.disabled,i=p.excluded,n=t.target,c=m?.contains(n),f=r&&n&&c&&!v;if(!f)return!1;var l=Er(n,i);return!l},Ip=(function(){function e(t){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,Kt(r,r.transformState.scale),r.setup=Zn(o)},this.initializeWindowEvents=function(){var o,m,p=Vr(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),i?.addEventListener("mousedown",r.onPanningStart,p),i?.addEventListener("mousemove",r.onPanning,p),i?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),i?.addEventListener("keyup",r.setKeyUnPressed,p),i?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,m,p=Vr(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,p),i?.removeEventListener("mousemove",r.onPanning,p),i?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),i?.removeEventListener("keyup",r.setKeyUnPressed,p),i?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),kt(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(o){var m=Vr();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,i=function(n,c){for(var f=0,l=n;f<l.length;f++){var g=l[f];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(We(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,m))if(v&&!p){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(p=!0,r.setCenter())}else kt(r),Kt(r,r.transformState.scale),$i(r,0)}),r.observer.observe(o),r.observer.observe(m)},this.onWheelZoom=function(o){var m=r.setup.disabled;if(!m){var p=gp(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(jp(r,o),Np(r,o),Ap(r,o))}}},this.onWheelPanning=function(o){var m=r.setup,p=m.disabled,v=m.wheel,i=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,c=n.positionX,f=n.positionY,l=c-o.deltaX,g=f-o.deltaY,x=i.lockAxisX?c:l,y=i.lockAxisY?f:g,_=r.setup.alignmentAnimation,a=_.sizeX,h=_.sizeY,d=zt(r,a),u=zt(r,h);x===c&&y===f||Ca(r,x,y,d,u)}},this.onPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Kn(r,o);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(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(),kt(r),Yn(r,o),Ke(We(r),o,p)))}}},this.onPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var v=Xn(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),Gn(r,o.clientX,o.clientY),Ke(We(r),o,p))}}},this.onPanningStop=function(o){var m=r.props.onPanningStop;r.isPanning&&(np(r),Ke(We(r),o,m))},this.onPinchStart=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinchingStart,i=p.onZoomStart;if(!m){var n=yp(r,o);n&&(Tp(r,o),kt(r),Ke(We(r),o,v),Ke(We(r),o,i))}},this.onPinch=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinching,i=p.onZoom;if(!m){var n=Sp(r);n&&(o.preventDefault(),o.stopPropagation(),Rp(r,o),Ke(We(r),o,v),Ke(We(r),o,i))}},this.onPinchStop=function(o){var m=r.props,p=m.onPinchingStop,v=m.onZoomStop;r.pinchStartScale&&(Mp(r),Ke(We(r),o,p),Ke(We(r),o,v))},this.onTouchPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Kn(r,o);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,kt(r);var n=o.touches,c=n.length===1,f=n.length===2;c&&(kt(r),Yn(r,o),Ke(We(r),o,p)),f&&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=Xn(r);if(!v)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];Gn(r,i.clientX,i.clientY),Ke(We(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=Op(r,o);p&&Pp(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 i=We(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ke(i,{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=Ta(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):mp(o,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,m=o.scale,p=o.positionX,v=o.positionY,i=r.handleTransformStyles(p,v,m);r.contentComponent.style.transform=i}},this.getContext=function(){return We(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,Kt(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=We(r);Ke(p,void 0,r.props.onInit)},this.props=t,this.setup=Zn(this.props),this.transformState=Ea(this.props)}return e})(),jr=ie.createContext(null),Bp=function(e,t){return typeof e=="function"?e(t):e},Fp=ie.forwardRef(function(e,t){var r=C.useRef(new Ip(e)).current,o=Bp(e.children,dr(r));return C.useImperativeHandle(t,function(){return dr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ie.createElement(jr.Provider,{value:r},o)});ie.forwardRef(function(e,t){var r=C.useRef(null),o=C.useContext(jr);return C.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]),ie.createElement("div",Ft({},e,{ref:pp([r,t])}))});function zp(e,t){t===void 0&&(t={});var r=t.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 Hp=`.transform-component-module_wrapper__SPB86 {
|
|
38
|
+
`},qn=Kf(Gf)(fa),Qf={config:Vf},Zf=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return function(m){return r.reduceRight(function(p,v){return v(p)},m)}};function ma(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],ma(e[r],t[r]))}),Wn(Wn({},e),t)}var Jf={type:"cancelation",msg:"operation is manually canceled"};function Wr(e){var t=!1,r=new Promise(function(o,m){e.then(function(p){return t?m(Jf):o(p)}),e.catch(m)});return r.cancel=function(){return t=!0},r}var em=["monaco"],tm=Uf.create({config:qf,isInitialized:!1,resolve:null,reject:null,monaco:null}),pa=Ef(tm,2),Is=pa[0],Sr=pa[1];function sm(e){var t=Qf.config(e),r=t.monaco,o=Cf(t,em);Sr(function(m){return{config:ma(m.config,o),monaco:r}})}function rm(){var e=Is(function(t){var r=t.monaco,o=t.isInitialized,m=t.resolve;return{monaco:r,isInitialized:o,resolve:m}});if(!e.isInitialized){if(Sr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Wr($r);if(window.monaco&&window.monaco.editor)return ga(window.monaco),e.resolve(window.monaco),Wr($r);Zf(im,om)(am)}return Wr($r)}function im(e){return document.body.appendChild(e)}function nm(e){var t=document.createElement("script");return e&&(t.src=e),t}function om(e){var t=Is(function(o){var m=o.config,p=o.reject;return{config:m,reject:p}}),r=nm("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function am(){var e=Is(function(r){var o=r.config,m=r.resolve,p=r.reject;return{config:o,resolve:m,reject:p}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var o=r.m||r;ga(o),e.resolve(o)},function(r){e.reject(r)})}function ga(e){Is().monaco||Sr({monaco:e})}function lm(){return Is(function(e){var t=e.monaco;return t})}var $r=new Promise(function(e,t){return Sr({resolve:e,reject:t})}),va={config:sm,init:rm,__getMonacoInstance:lm},cm={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ur=cm,dm={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},um=dm;function hm({children:e}){return ie.createElement("div",{style:um.container},e)}var fm=hm,mm=fm;function pm({width:e,height:t,isEditorReady:r,loading:o,_ref:m,className:p,wrapperProps:v}){return ie.createElement("section",{style:{...Ur.wrapper,width:e,height:t},...v},!r&&ie.createElement(mm,null,o),ie.createElement("div",{ref:m,style:{...Ur.fullWidth,...!r&&Ur.hide},className:p}))}var gm=pm,_a=C.memo(gm);function vm(e){C.useEffect(e,[])}var xa=vm;function _m(e,t,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,t)}var St=_m;function ys(){}function ts(e,t,r,o){return xm(e,o)||bm(e,t,r,o)}function xm(e,t){return e.editor.getModel(ba(e,t))}function bm(e,t,r,o){return e.editor.createModel(t,r,o?ba(e,o):void 0)}function ba(e,t){return e.Uri.parse(t)}function ym({original:e,modified:t,language:r,originalLanguage:o,modifiedLanguage:m,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:c="light",loading:f="Loading...",options:l={},height:g="100%",width:b="100%",className:y,wrapperProps:_={},beforeMount:a=ys,onMount:h=ys}){let[d,u]=C.useState(!1),[x,S]=C.useState(!0),k=C.useRef(null),E=C.useRef(null),w=C.useRef(null),j=C.useRef(h),T=C.useRef(a),L=C.useRef(!1);xa(()=>{let I=va.init();return I.then(F=>(E.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?D():I.cancel()}),St(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),F=ts(E.current,e||"",o||r||"text",p||"");F!==I.getModel()&&I.setModel(F)}},[p],d),St(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),F=ts(E.current,t||"",m||r||"text",v||"");F!==I.getModel()&&I.setModel(F)}},[v],d),St(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(t||""):t!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[t],d),St(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:I,modified:F}=k.current.getModel();E.current.editor.setModelLanguage(I,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 N=C.useCallback(()=>{if(!E.current)return;T.current(E.current);let I=ts(E.current,e||"",o||r||"text",p||""),F=ts(E.current,t||"",m||r||"text",v||"");k.current?.setModel({original:I,modified:F})},[r,t,m,e,o,p,v]),R=C.useCallback(()=>{!L.current&&w.current&&(k.current=E.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...l}),N(),E.current?.editor.setTheme(c),u(!0),L.current=!0)},[l,c,N]);C.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),C.useEffect(()=>{!x&&!d&&R()},[x,d,R]);function D(){let I=k.current?.getModel();i||I?.original?.dispose(),n||I?.modified?.dispose(),k.current?.dispose()}return ie.createElement(_a,{width:b,height:g,isEditorReady:d,loading:f,_ref:w,className:y,wrapperProps:_})}var Sm=ym;C.memo(Sm);function wm(e){let t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}var Cm=wm,Us=new Map;function km({defaultValue:e,defaultLanguage:t,defaultPath:r,value:o,language:m,path:p,theme:v="light",line:i,loading:n="Loading...",options:c={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:g=!1,width:b="100%",height:y="100%",className:_,wrapperProps:a={},beforeMount:h=ys,onMount:d=ys,onChange:u,onValidate:x=ys}){let[S,k]=C.useState(!1),[E,w]=C.useState(!0),j=C.useRef(null),T=C.useRef(null),L=C.useRef(null),N=C.useRef(d),R=C.useRef(h),D=C.useRef(),I=C.useRef(o),F=Cm(p),z=C.useRef(!1),A=C.useRef(!1);xa(()=>{let B=va.init();return B.then(W=>(j.current=W)&&w(!1)).catch(W=>W?.type!=="cancelation"&&console.error("Monaco initialization: error:",W)),()=>T.current?O():B.cancel()}),St(()=>{let B=ts(j.current,e||o||"",t||m||"",p||r||"");B!==T.current?.getModel()&&(l&&Us.set(F,T.current?.saveViewState()),T.current?.setModel(B),l&&T.current?.restoreViewState(Us.get(p)))},[p],S),St(()=>{T.current?.updateOptions(c)},[c],S),St(()=>{!T.current||o===void 0||(T.current.getOption(j.current.editor.EditorOption.readOnly)?T.current.setValue(o):o!==T.current.getValue()&&(A.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),T.current.pushUndoStop(),A.current=!1))},[o],S),St(()=>{let B=T.current?.getModel();B&&m&&j.current?.editor.setModelLanguage(B,m)},[m],S),St(()=>{i!==void 0&&T.current?.revealLine(i)},[i],S),St(()=>{j.current?.editor.setTheme(v)},[v],S);let P=C.useCallback(()=>{if(!(!L.current||!j.current)&&!z.current){R.current(j.current);let B=p||r,W=ts(j.current,o||e||"",t||m||"",B||"");T.current=j.current?.editor.create(L.current,{model:W,automaticLayout:!0,...c},f),l&&T.current.restoreViewState(Us.get(B)),j.current.editor.setTheme(v),i!==void 0&&T.current.revealLine(i),k(!0),z.current=!0}},[e,t,r,o,m,p,c,f,l,v,i]);C.useEffect(()=>{S&&N.current(T.current,j.current)},[S]),C.useEffect(()=>{!E&&!S&&P()},[E,S,P]),I.current=o,C.useEffect(()=>{S&&u&&(D.current?.dispose(),D.current=T.current?.onDidChangeModelContent(B=>{A.current||u(T.current.getValue(),B)}))},[S,u]),C.useEffect(()=>{if(S){let B=j.current.editor.onDidChangeMarkers(W=>{let V=T.current.getModel()?.uri;if(V&&W.find(Q=>Q.path===V.path)){let Q=j.current.editor.getModelMarkers({resource:V});x?.(Q)}});return()=>{B?.dispose()}}return()=>{}},[S,x]);function O(){D.current?.dispose(),g?l&&Us.set(p,T.current.saveViewState()):T.current.getModel()?.dispose(),T.current.dispose()}return ie.createElement(_a,{width:b,height:y,isEditorReady:S,loading:n,_ref:L,className:_,wrapperProps:a})}var Em=km,jm=C.memo(Em),Nm=jm,Ct=function(e,t){return Number(e.toFixed(t))},Am=function(e,t){return typeof e=="number"?e:t},Ke=function(e,t,r){r&&typeof r=="function"&&r(e,t)},Rm=function(e){return-Math.cos(e*Math.PI)/2+.5},Tm=function(e){return e},Mm=function(e){return e*e},Dm=function(e){return e*(2-e)},Lm=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Pm=function(e){return e*e*e},Om=function(e){return--e*e*e+1},Im=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Bm=function(e){return e*e*e*e},Fm=function(e){return 1- --e*e*e*e},zm=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Hm=function(e){return e*e*e*e*e},Wm=function(e){return 1+--e*e*e*e*e},$m=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},ya={easeOut:Rm,linear:Tm,easeInQuad:Mm,easeOutQuad:Dm,easeInOutQuad:Lm,easeInCubic:Pm,easeOutCubic:Om,easeInOutCubic:Im,easeInQuart:Bm,easeOutQuart:Fm,easeInOutQuart:zm,easeInQuint:Hm,easeOutQuint:Wm,easeInOutQuint:$m},Sa=function(e){typeof e=="number"&&cancelAnimationFrame(e)},kt=function(e){e.mounted&&(Sa(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function wa(e,t,r,o){if(e.mounted){var m=new Date().getTime(),p=1;kt(e),e.animation=function(){if(!e.mounted)return Sa(e.animation);var v=new Date().getTime()-m,i=v/r,n=ya[t],c=n(i);v>=r?(o(p),e.animation=null):e.animation&&(o(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Um(e){var t=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(o))}function $t(e,t,r,o){var m=Um(t);if(!(!e.mounted||!m)){var p=e.setTransformState,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=t.scale-i,l=t.positionX-n,g=t.positionY-c;r===0?p(t.scale,t.positionX,t.positionY):wa(e,o,r,function(b){var y=i+f*b,_=n+l*b,a=c+g*b;p(y,_,a)})}}function qm(e,t,r){var o=e.offsetWidth,m=e.offsetHeight,p=t.offsetWidth,v=t.offsetHeight,i=p*r,n=v*r,c=o-i,f=m-n;return{wrapperWidth:o,wrapperHeight:m,newContentWidth:i,newDiffWidth:c,newContentHeight:n,newDiffHeight:f}}var Km=function(e,t,r,o,m,p,v){var i=e>t?r*(v?1:.5):0,n=o>m?p*(v?1:.5):0,c=e-t-i,f=i,l=o-m-n,g=n;return{minPositionX:c,maxPositionX:f,minPositionY:l,maxPositionY:g}},Hi=function(e,t){var r=e.wrapperComponent,o=e.contentComponent,m=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=qm(r,o,t),v=p.wrapperWidth,i=p.wrapperHeight,n=p.newContentWidth,c=p.newDiffWidth,f=p.newContentHeight,l=p.newDiffHeight,g=Km(v,n,c,i,f,l,!!m);return g},ii=function(e,t,r,o){return o?e<t?Ct(t,2):e>r?Ct(r,2):Ct(e,2):Ct(e,2)},Xt=function(e,t){var r=Hi(e,t);return e.bounds=r,r};function Bs(e,t,r,o,m,p,v){var i=r.minPositionX,n=r.minPositionY,c=r.maxPositionX,f=r.maxPositionY,l=0,g=0;v&&(l=m,g=p);var b=ii(e,i-l,c+l,o),y=ii(t,n-g,f+g,o);return{x:b,y}}function wr(e,t,r,o,m,p){var v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=o-i;if(typeof t!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:c};var l=n-t*f,g=c-r*f,b=Bs(l,g,m,p,0,0,null);return b}function Fs(e,t,r,o,m){var p=m?o:0,v=t-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(t)&&e<=v?v:e}var Kn=function(e,t){var r=e.setup.panning.excluded,o=e.isInitialized,m=e.wrapperComponent,p=t.target,v="shadowRoot"in p&&"composedPath"in t,i=v?t.composedPath().some(function(f){return f instanceof Element?m?.contains(f):!1}):m?.contains(p),n=o&&p&&i;if(!n)return!1;var c=Cr(p,r);return!c},Xn=function(e){var t=e.isInitialized,r=e.isPanning,o=e.setup,m=o.panning.disabled,p=t&&r&&!m;return!!p},Xm=function(e,t){var r=e.transformState,o=r.positionX,m=r.positionY;e.isPanning=!0;var p=t.clientX,v=t.clientY;e.startCoords={x:p-o,y:v-m}},Vm=function(e,t){var r=t.touches,o=e.transformState,m=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-m,y:n-p}}};function Ym(e){var t=e.transformState,r=t.positionX,o=t.positionY,m=t.scale,p=e.setup,v=p.disabled,i=p.limitToBounds,n=p.centerZoomedOut,c=e.wrapperComponent;if(!(v||!c||!e.bounds)){var f=e.bounds,l=f.maxPositionX,g=f.minPositionX,b=f.maxPositionY,y=f.minPositionY,_=r>l||r<g,a=o>b||o<y,h=r>l?c.offsetWidth:e.setup.minPositionX||0,d=o>b?c.offsetHeight:e.setup.minPositionY||0,u=wr(e,h,d,m,e.bounds,i||n),x=u.x,S=u.y;return{scale:m,positionX:_?x:r,positionY:a?S:o}}}function Ca(e,t,r,o,m){var p=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(!(v===null||i===null||t===f&&r===l)){var g=Bs(t,r,i,p,o,m,v),b=g.x,y=g.y;e.setTransformState(c,b,y)}}var Gm=function(e,t,r){var o=e.startCoords,m=e.transformState,p=e.setup.panning,v=p.lockAxisX,i=p.lockAxisY,n=m.positionX,c=m.positionY;if(!o)return{x:n,y:c};var f=t-o.x,l=r-o.y,g=v?n:f,b=i?c:l;return{x:g,y:b}},Ht=function(e,t){var r=e.setup,o=e.transformState,m=o.scale,p=r.minScale,v=r.disablePadding;return t>0&&m>=p&&!v?t:0},Qm=function(e){var t=e.mounted,r=e.setup,o=r.disabled,m=r.velocityAnimation,p=e.transformState.scale,v=m.disabled,i=!v||p>1||!o||t;return!!i},Zm=function(e){var t=e.mounted,r=e.velocity,o=e.bounds,m=e.setup,p=m.disabled,v=m.velocityAnimation,i=e.transformState.scale,n=v.disabled,c=!n||i>1||!p||t;return!(!c||!r||!o)};function Jm(e,t){var r=e.setup.velocityAnimation,o=r.equalToMove,m=r.animationTime,p=r.sensitivity;return o?m*t*p:m}function Vn(e,t,r,o,m,p,v,i,n,c){if(m){if(t>v&&r>v){var f=v+(e-v)*c;return f>n?n:f<v?v:f}if(t<p&&r<p){var f=p+(e-p)*c;return f<i?i:f>p?p:f}}return o?t:ii(e,p,v,m)}function ep(e,t){var r=1;return t?Math.min(r,e.offsetWidth/window.innerWidth):r}function tp(e,t){var r=Qm(e);if(r){var o=e.lastMousePosition,m=e.velocityTime,p=e.setup,v=e.wrapperComponent,i=p.velocityAnimation.equalToMove,n=Date.now();if(o&&m&&v){var c=ep(v,i),f=t.x-o.x,l=t.y-o.y,g=f/c,b=l/c,y=n-m,_=f*f+l*l,a=Math.sqrt(_)/y;e.velocity={velocityX:g,velocityY:b,total:a}}e.lastMousePosition=t,e.velocityTime=n}}function sp(e){var t=e.velocity,r=e.bounds,o=e.setup,m=e.wrapperComponent,p=Zm(e);if(!(!p||!t||!r||!m)){var v=t.velocityX,i=t.velocityY,n=t.total,c=r.maxPositionX,f=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,b=o.limitToBounds,y=o.alignmentAnimation,_=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,u=_.animationType,x=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,w=Jm(e,n),j=Math.max(w,E),T=Ht(e,x),L=Ht(e,S),N=T*m.offsetWidth/100,R=L*m.offsetHeight/100,D=c+N,I=f-N,F=l+R,z=g-R,A=e.transformState,P=new Date().getTime();wa(e,u,j,function(O){var B=e.transformState,W=B.scale,V=B.positionX,Q=B.positionY,Z=new Date().getTime()-P,he=Z/E,M=ya[y.animationType],H=1-M(Math.min(1,he)),U=1-O,$=V+v*U,se=Q+i*U,K=Vn($,A.positionX,V,d,b,f,c,I,D,H),ce=Vn(se,A.positionY,Q,h,b,g,l,z,F,H);(V!==$||Q!==se)&&e.setTransformState(W,K,ce)})}}function Yn(e,t){var r=e.transformState.scale;kt(e),Xt(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?Vm(e,t):Xm(e,t)}function Wi(e,t){var r=e.transformState.scale,o=e.setup,m=o.minScale,p=o.alignmentAnimation,v=p.disabled,i=p.sizeX,n=p.sizeY,c=p.animationTime,f=p.animationType,l=v||r<m||!i&&!n;if(!l){var g=Ym(e);g&&$t(e,g,t??c,f)}}function Gn(e,t,r){var o=e.startCoords,m=e.setup,p=m.alignmentAnimation,v=p.sizeX,i=p.sizeY;if(o){var n=Gm(e,t,r),c=n.x,f=n.y,l=Ht(e,v),g=Ht(e,i);tp(e,{x:c,y:f}),Ca(e,c,f,l,g)}}function rp(e){if(e.isPanning){var t=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(),i=p?.width||0,n=p?.height||0,c=v?.width||0,f=v?.height||0,l=i<c||n<f,g=!t&&r&&r?.total>.1&&l;g?sp(e):Wi(e)}}function $i(e,t,r,o){var m=e.setup,p=m.minScale,v=m.maxScale,i=m.limitToBounds,n=Fs(Ct(t,2),p,v,0,!1),c=Xt(e,n),f=wr(e,r,o,n,c,i),l=f.x,g=f.y;return{scale:n,positionX:l,positionY:g}}function ka(e,t,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.minScale,i=p.limitToBounds,n=p.zoomAnimation,c=n.disabled,f=n.animationTime,l=n.animationType,g=c||o>=v;if((o>=1||i)&&Wi(e),!(g||!m||!e.mounted)){var b=t||m.offsetWidth/2,y=r||m.offsetHeight/2,_=$i(e,v,b,y);_&&$t(e,_,f,l)}}var zt=function(){return zt=Object.assign||function(t){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)&&(t[p]=r[p])}return t},zt.apply(this,arguments)};function Qn(e,t,r){for(var o=0,m=t.length,p;o<m;o++)(p||!(o in t))&&(p||(p=Array.prototype.slice.call(t,0,o)),p[o]=t[o]);return e.concat(p||Array.prototype.slice.call(t))}var qs={scale:1,positionX:0,positionY:0},ps={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}},ni={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ea=function(e){var t,r,o,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:qs.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:qs.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:qs.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:qs.positionY}},Zn=function(e){var t=zt({},ps);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",m=typeof ps[r]<"u";if(m&&o){var p=Object.prototype.toString.call(ps[r]),v=p==="[object Object]",i=p==="[object Array]";v?t[r]=zt(zt({},ps[r]),e[r]):i?t[r]=Qn(Qn([],ps[r],!0),e[r]):t[r]=e[r]}}),t},ja=function(e,t,r){var o=e.transformState.scale,m=e.wrapperComponent,p=e.setup,v=p.maxScale,i=p.minScale,n=p.zoomAnimation,c=p.smooth,f=n.size;if(!m)throw new Error("Wrapper is not mounted");var l=c?o*Math.exp(t*r):o+t*r,g=Fs(Ct(l,3),i,v,f,!1);return g};function Na(e,t,r,o,m){var p=e.wrapperComponent,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY;if(!p)return console.error("No WrapperComponent found");var f=p.offsetWidth,l=p.offsetHeight,g=(f/2-n)/i,b=(l/2-c)/i,y=ja(e,t,r),_=$i(e,y,g,b);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");$t(e,_,o,m)}function Aa(e,t,r,o){var m=e.setup,p=e.wrapperComponent,v=m.limitToBounds,i=Ea(e.props),n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(p){var g=Hi(e,i.scale),b=Bs(i.positionX,i.positionY,g,v,0,0,p),y={scale:i.scale,positionX:b.x,positionY:b.y};c===i.scale&&f===i.positionX&&l===i.positionY||(o?.(),$t(e,y,t,r))}}function ip(e,t,r,o){var m=e.getBoundingClientRect(),p=t.getBoundingClientRect(),v=r.getBoundingClientRect(),i=p.x*o.scale,n=p.y*o.scale;return{x:(m.x-v.x+i)/o.scale,y:(m.y-v.y+n)/o.scale}}function np(e,t,r){var o=e.wrapperComponent,m=e.contentComponent,p=e.transformState,v=e.setup,i=v.limitToBounds,n=v.minScale,c=v.maxScale;if(!o||!m)return p;var f=o.getBoundingClientRect(),l=t.getBoundingClientRect(),g=ip(t,o,m,p),b=g.x,y=g.y,_=l.width/p.scale,a=l.height/p.scale,h=o.offsetWidth/_,d=o.offsetHeight/a,u=Fs(r||Math.min(h,d),n,c,0,!1),x=(f.width-_*u)/2,S=(f.height-a*u)/2,k=(f.left-b)*u+x,E=(f.top-y)*u+S,w=Hi(e,u),j=Bs(k,E,w,i,0,0,o),T=j.x,L=j.y;return{positionX:T,positionY:L,scale:u}}var op=function(e){return function(t,r,o){t===void 0&&(t=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Na(e,1,t,r,o)}},ap=function(e){return function(t,r,o){t===void 0&&(t=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Na(e,-1,t,r,o)}},lp=function(e){return function(t,r,o,m,p){m===void 0&&(m=300),p===void 0&&(p="easeOut");var v=e.transformState,i=v.positionX,n=v.positionY,c=v.scale,f=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!f||!l)){var b={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?c:o};$t(e,b,m,p)}}},cp=function(e){return function(t,r){t===void 0&&(t=200),r===void 0&&(r="easeOut"),Aa(e,t,r)}},dp=function(e){return function(t,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 i=Ra(t||m.scale,p,v);$t(e,i,r,o)}}},up=function(e){return function(t,r,o,m){o===void 0&&(o=600),m===void 0&&(m="easeOut"),kt(e);var p=e.wrapperComponent,v=typeof t=="string"?document.getElementById(t):t;if(p&&v&&p.contains(v)){var i=np(e,v,r);$t(e,i,o,m)}}},lr=function(e){return{instance:e,zoomIn:op(e),zoomOut:ap(e),setTransform:lp(e),resetTransform:cp(e),centerView:dp(e),zoomToElement:up(e)}},oi=function(e){return{instance:e,state:e.transformState}},We=function(e){var t={};return Object.assign(t,oi(e)),Object.assign(t,lr(e)),t},qr=!1;function Kr(){try{var e={get passive(){return qr=!0,!1}};return e}catch{return qr=!1,qr}}var Ks=".".concat(ni.wrapperClass),Cr=function(e,t){return t.some(function(r){return e.matches("".concat(Ks," ").concat(r,", ").concat(Ks," .").concat(r,", ").concat(Ks," ").concat(r," *, ").concat(Ks," .").concat(r," *"))})},ai=function(e){e&&clearTimeout(e)},hp=function(e,t,r){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},Ra=function(e,t,r){var o=r.offsetWidth*e,m=r.offsetHeight*e,p=(t.offsetWidth-o)/2,v=(t.offsetHeight-m)/2;return{scale:e,positionX:p,positionY:v}};function fp(e){return function(t){e.forEach(function(r){typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var mp=function(e,t){var r=e.setup.wheel,o=r.disabled,m=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,n=e.isPanning,c=t.target,f=i&&!n&&!o&&c;if(!f||m&&!t.ctrlKey||p&&t.ctrlKey)return!1;var l=Cr(c,v);return!l},pp=function(e){return e?e.deltaY<0?1:-1:0};function gp(e,t){var r=pp(e),o=Am(t,r);return o}function Ta(e,t,r){var o=t.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 vp=function(e,t,r,o,m){var p=e.transformState.scale,v=e.wrapperComponent,i=e.setup,n=i.maxScale,c=i.minScale,f=i.zoomAnimation,l=i.disablePadding,g=f.size,b=f.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=p+t*r,_=o?!1:!b,a=Fs(Ct(y,3),c,n,g,_&&!l);return a},_p=function(e,t){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(t.deltaY)||r.deltaY>0&&r.deltaY<t.deltaY||r.deltaY<0&&r.deltaY>t.deltaY||Math.sign(r.deltaY)!==Math.sign(t.deltaY):!1},xp=function(e,t){var r=e.setup.pinch,o=r.disabled,m=r.excluded,p=e.isInitialized,v=t.target,i=p&&!o&&v;if(!i)return!1;var n=Cr(v,m);return!n},bp=function(e){var t=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,m=r&&!t&&o;return!!m},yp=function(e,t,r){var o=r.getBoundingClientRect(),m=e.touches,p=Ct(m[0].clientX-o.left,5),v=Ct(m[0].clientY-o.top,5),i=Ct(m[1].clientX-o.left,5),n=Ct(m[1].clientY-o.top,5);return{x:(p+i)/2/t,y:(v+n)/2/t}},Ma=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))},Sp=function(e,t){var r=e.pinchStartScale,o=e.pinchStartDistance,m=e.setup,p=m.maxScale,v=m.minScale,i=m.zoomAnimation,n=m.disablePadding,c=i.size,f=i.disabled;if(!r||o===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var l=t/o,g=l*r;return Fs(Ct(g,2),v,p,c,!f&&!n)},wp=160,Cp=100,kp=function(e,t){var r=e.props,o=r.onWheelStart,m=r.onZoomStart;e.wheelStopEventTimer||(kt(e),Ke(We(e),t,o),Ke(We(e),t,m))},Ep=function(e,t){var r=e.props,o=r.onWheel,m=r.onZoom,p=e.contentComponent,v=e.setup,i=e.transformState,n=i.scale,c=v.limitToBounds,f=v.centerZoomedOut,l=v.zoomAnimation,g=v.wheel,b=v.disablePadding,y=v.smooth,_=l.size,a=l.disabled,h=g.step,d=g.smoothStep;if(!p)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=gp(t,null),x=y?d*Math.abs(t.deltaY):h,S=vp(e,u,x,!t.ctrlKey);if(n!==S){var k=Xt(e,S),E=Ta(t,p,n),w=a||_===0||f||b,j=c&&w,T=wr(e,E.x,E.y,S,k,j),L=T.x,N=T.y;e.previousWheelEvent=t,e.setTransformState(S,L,N),Ke(We(e),t,o),Ke(We(e),t,m)}},jp=function(e,t){var r=e.props,o=r.onWheelStop,m=r.onZoomStop;ai(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ka(e,t.x,t.y),e.wheelAnimationTimer=null)},Cp);var p=_p(e,t);p&&(ai(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ke(We(e),t,o),Ke(We(e),t,m))},wp))},Da=function(e){for(var t=0,r=0,o=0;o<2;o+=1)t+=e.touches[o].clientX,r+=e.touches[o].clientY;var m=t/2,p=r/2;return{x:m,y:p}},Np=function(e,t){var r=Ma(t);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Da(t);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,kt(e)},Ap=function(e,t){var r=e.contentComponent,o=e.pinchStartDistance,m=e.wrapperComponent,p=e.transformState.scale,v=e.setup,i=v.limitToBounds,n=v.centerZoomedOut,c=v.zoomAnimation,f=v.alignmentAnimation,l=c.disabled,g=c.size;if(!(o===null||!r)){var b=yp(t,p,r);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var y=Ma(t),_=Sp(e,y),a=Da(t),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(_===p&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var u=Xt(e,_),x=l||g===0||n,S=i&&x,k=wr(e,b.x,b.y,_,u,S),E=k.x,w=k.y;e.pinchMidpoint=b,e.lastDistance=y;var j=f.sizeX,T=f.sizeY,L=Ht(e,j),N=Ht(e,T),R=E+h,D=w+d,I=Bs(R,D,u,i,L,N,m),F=I.x,z=I.y;e.setTransformState(_,F,z)}}}},Rp=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ka(e,t?.x,t?.y)},La=function(e,t){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;ai(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ke(We(e),t,r)},o)},Tp=function(e,t){var r=e.props,o=r.onZoomStart,m=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,i=p.animationType;Ke(We(e),t,o),Aa(e,v,i,function(){return Ke(We(e),t,m)}),La(e,t)};function Mp(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Dp(e,t){var r=e.setup,o=e.doubleClickStopEventTimer,m=e.transformState,p=e.contentComponent,v=m.scale,i=e.props,n=i.onZoomStart,c=i.onZoom,f=r.doubleClick,l=f.disabled,g=f.mode,b=f.step,y=f.animationTime,_=f.animationType;if(!l&&!o){if(g==="reset")return Tp(e,t);if(!p)return console.error("No ContentComponent found");var a=Mp(g,e.transformState.scale),h=ja(e,a,b);if(v!==h){Ke(We(e),t,n);var d=Ta(t,p,v),u=$i(e,h,d.x,d.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");Ke(We(e),t,c),$t(e,u,y,_),La(e,t)}}}var Lp=function(e,t){var r=e.isInitialized,o=e.setup,m=e.wrapperComponent,p=o.doubleClick,v=p.disabled,i=p.excluded,n=t.target,c=m?.contains(n),f=r&&n&&c&&!v;if(!f)return!1;var l=Cr(n,i);return!l},Pp=(function(){function e(t){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,Xt(r,r.transformState.scale),r.setup=Zn(o)},this.initializeWindowEvents=function(){var o,m,p=Kr(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;(m=r.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",r.onWheelPanning,p),i?.addEventListener("mousedown",r.onPanningStart,p),i?.addEventListener("mousemove",r.onPanning,p),i?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),i?.addEventListener("keyup",r.setKeyUnPressed,p),i?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,m,p=Kr(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,p),i?.removeEventListener("mousemove",r.onPanning,p),i?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),i?.removeEventListener("keyup",r.setKeyUnPressed,p),i?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),kt(r),(m=r.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(o){var m=Kr();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,i=function(n,c){for(var f=0,l=n;f<l.length;f++){var g=l[f];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(We(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,m))if(v&&!p){var c=m.offsetWidth,f=m.offsetHeight;(c>0||f>0)&&(p=!0,r.setCenter())}else kt(r),Xt(r,r.transformState.scale),Wi(r,0)}),r.observer.observe(o),r.observer.observe(m)},this.onWheelZoom=function(o){var m=r.setup.disabled;if(!m){var p=mp(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(kp(r,o),Ep(r,o),jp(r,o))}}},this.onWheelPanning=function(o){var m=r.setup,p=m.disabled,v=m.wheel,i=m.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,c=n.positionX,f=n.positionY,l=c-o.deltaX,g=f-o.deltaY,b=i.lockAxisX?c:l,y=i.lockAxisY?f:g,_=r.setup.alignmentAnimation,a=_.sizeX,h=_.sizeY,d=Ht(r,a),u=Ht(r,h);b===c&&y===f||Ca(r,b,y,d,u)}},this.onPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Kn(r,o);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(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(),kt(r),Yn(r,o),Ke(We(r),o,p)))}}},this.onPanning=function(o){var m=r.setup.disabled,p=r.props.onPanning;if(!m){var v=Xn(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),Gn(r,o.clientX,o.clientY),Ke(We(r),o,p))}}},this.onPanningStop=function(o){var m=r.props.onPanningStop;r.isPanning&&(rp(r),Ke(We(r),o,m))},this.onPinchStart=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinchingStart,i=p.onZoomStart;if(!m){var n=xp(r,o);n&&(Np(r,o),kt(r),Ke(We(r),o,v),Ke(We(r),o,i))}},this.onPinch=function(o){var m=r.setup.disabled,p=r.props,v=p.onPinching,i=p.onZoom;if(!m){var n=bp(r);n&&(o.preventDefault(),o.stopPropagation(),Ap(r,o),Ke(We(r),o,v),Ke(We(r),o,i))}},this.onPinchStop=function(o){var m=r.props,p=m.onPinchingStop,v=m.onZoomStop;r.pinchStartScale&&(Rp(r),Ke(We(r),o,p),Ke(We(r),o,v))},this.onTouchPanningStart=function(o){var m=r.setup.disabled,p=r.props.onPanningStart;if(!m){var v=Kn(r,o);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,kt(r);var n=o.touches,c=n.length===1,f=n.length===2;c&&(kt(r),Yn(r,o),Ke(We(r),o,p)),f&&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=Xn(r);if(!v)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];Gn(r,i.clientX,i.clientY),Ke(We(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=Lp(r,o);p&&Dp(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 i=We(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ke(i,{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=Ra(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):hp(o,m,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,m=o.scale,p=o.positionX,v=o.positionY,i=r.handleTransformStyles(p,v,m);r.contentComponent.style.transform=i}},this.getContext=function(){return We(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,Xt(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,m),r.initializeWindowEvents(),r.isInitialized=!0;var p=We(r);Ke(p,void 0,r.props.onInit)},this.props=t,this.setup=Zn(this.props),this.transformState=Ea(this.props)}return e})(),kr=ie.createContext(null),Op=function(e,t){return typeof e=="function"?e(t):e},Ip=ie.forwardRef(function(e,t){var r=C.useRef(new Pp(e)).current,o=Op(e.children,lr(r));return C.useImperativeHandle(t,function(){return lr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ie.createElement(kr.Provider,{value:r},o)});ie.forwardRef(function(e,t){var r=C.useRef(null),o=C.useContext(kr);return C.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]),ie.createElement("div",zt({},e,{ref:fp([r,t])}))});function Bp(e,t){t===void 0&&(t={});var r=t.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 Fp=`.transform-component-module_wrapper__SPB86 {
|
|
39
39
|
position: relative;
|
|
40
40
|
width: -moz-fit-content;
|
|
41
41
|
width: fit-content;
|
|
@@ -66,25 +66,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
66
66
|
.transform-component-module_content__FBWxo img {
|
|
67
67
|
pointer-events: none;
|
|
68
68
|
}
|
|
69
|
-
`,Jn={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};zp(Hp);var Wp=function(e){var t=e.children,r=e.wrapperClass,o=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,v=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,c=n===void 0?{}:n,f=e.contentProps,l=f===void 0?{}:f,g=C.useContext(jr),x=g.init,y=g.cleanupWindowEvents,_=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=_.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){y?.()}},[]),ie.createElement("div",Ft({},c,{ref:_,className:"".concat(ai.wrapperClass," ").concat(Jn.wrapper," ").concat(o),style:v}),ie.createElement("div",Ft({},l,{ref:a,className:"".concat(ai.contentClass," ").concat(Jn.content," ").concat(p),style:i}),t))},Pa=function(){var e=C.useContext(jr);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},$p=function(){var e=Pa();return dr(e)};function Up(e){var t=Pa(),r=C.useState(e(li(t))),o=r[0],m=r[1];return C.useEffect(function(){var p=!0,v=t.onChange(function(i){p&&m(e(li(i.instance)))});return function(){v(),p=!1}},[e,t]),o}function qp(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 Kp(e,t){return xt({queryKey:de.files.tree(e||"",t),queryFn:()=>ge.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function Xp(e,t){return xt({queryKey:de.files.content(e||"",t||""),queryFn:()=>ge.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Vp(e){const t=Ge();return C.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Yp(){const e=Ge();return ht({mutationFn:t=>ge.post("/files/write",t),onSuccess:(t,r)=>{const o=de.files.content(r.workingDir,r.path),m=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:m?.language||qp(r.path)})}})}function Gp(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Qp(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Zp=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Jp(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Zp.has(t)?Ti:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?ks:t==="json"?Nc:t==="md"||t==="mdx"||t==="txt"?ji:rc}const eo=({depth:e,active:t,onClick:r,leftIcon:o,rightIcon:m,label:p})=>s.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",t&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[s.jsx("span",{className:"shrink-0",children:m}),s.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),s.jsx("span",{className:"truncate text-neutral-700",children:p})]}),Oa=({workingDir:e,path:t,depth:r,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})=>{const{t:i}=ae(),{data:n,isLoading:c,isError:f}=Kp(e,t),l=C.useMemo(()=>n?.items??[],[n?.items]);return c?s.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):f?s.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):s.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const h=Gp(t,g.name),d=o.has(h);return s.jsxs("div",{children:[s.jsx(eo,{depth:r,onClick:()=>m(h),rightIcon:d?s.jsx(bt,{size:14,className:"text-neutral-400"}):s.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?s.jsx(Ni,{size:14,className:"text-amber-500"}):s.jsx(sc,{size:14,className:"text-amber-500"}),label:g.name}),d&&s.jsx(Oa,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})]},h)}const x=Qp(t,g.name),y=Jp(g),_=v===x,a=y===Ti;return s.jsx(eo,{depth:r,active:_,onClick:()=>p(x),rightIcon:s.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?s.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},e0=({workingDir:e,className:t,onFileSelect:r,selectedFilePath:o,onCollapse:m})=>{const{t:p}=ae(),[v,i]=C.useState(()=>new Set),n=Vp(e),c=C.useCallback(f=>{i(l=>{const g=new Set(l);return g.has(f)?g.delete(f):g.add(f),g})},[]);return s.jsxs("div",{className:te("h-full flex flex-col",t),children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),s.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&s.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:s.jsx(Es,{size:13})}),m&&s.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:s.jsx(Gc,{size:13})})]})]}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?s.jsx(Oa,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:c,onFileSelect:r,selectedFilePath:o}):s.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},t0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function s0(e){const t=e.split(".").pop()?.toLowerCase();return t?t0.has(t):!1}function r0(e,t){const r="/api",o=new URLSearchParams({workingDir:e,path:t});return`${r}/files/image?${o.toString()}`}const i0=({filePath:e})=>{const{t}=ae(),{zoomIn:r,zoomOut:o,centerView:m}=$p(),p=Up(i=>i.state.scale),v=Math.round(p*100);return s.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:[s.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:t("Zoom out"),children:s.jsx(md,{size:14})}),s.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:t("Reset zoom"),children:[v,"%"]}),s.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:t("Zoom in"),children:s.jsx(hd,{size:14})}),s.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:t("Fit to view"),children:s.jsx(Xc,{size:13})}),s.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},n0=({workingDir:e,filePath:t})=>{const{t:r}=ae(),[o,m]=C.useState(!1),p=r0(e,t);return o?s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):s.jsx(Fp,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx(i0,{filePath:t}),s.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:s.jsx(Wp,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:s.jsx("img",{src:p,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function o0(e){const t=e.split("/");return t[t.length-1]||e}function a0(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 l0=({active:e,name:t,isDirty:r,onClick:o,onClose:m})=>{const{t:p}=ae();return s.jsxs("button",{type:"button",onClick:o,className:te("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:[s.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),s.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),s.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:s.jsx(Ht,{size:12})})]})},c0=({workingDir:e,className:t,readOnly:r=!1})=>{const{t:o}=ae(),[m,p]=C.useState([]),[v,i]=C.useState(null),n=Yp(),[c,f]=C.useState(280),[l,g]=C.useState(!1),[x,y]=C.useState(!1),_=C.useRef(280),a=C.useCallback(()=>{g(M=>(M?f(_.current):_.current=c,!M))},[c]),h=C.useCallback(M=>{M.preventDefault(),y(!0);const D=M.clientX,I=c,F=A=>{const P=A.clientX-D,O=Math.min(480,Math.max(160,I+P));f(O)},z=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);C.useEffect(()=>{p([]),i(null)},[e]);const d=C.useMemo(()=>m.find(M=>M.path===v)||null,[m,v]),{data:u,isFetching:b,isError:S,error:E}=Xp(e,d?.isImage?null:v);C.useEffect(()=>{!v||!u||p(M=>M.map(D=>D.path!==v||D.isDirty||D.loaded?D:{...D,language:u.language||D.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[v,u]);const j=C.useCallback(M=>{p(D=>{if(D.find(z=>z.path===M))return D;const F=s0(M);return[...D,{path:M,name:o0(M),language:a0(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(M)},[]),w=C.useCallback(M=>{p(D=>{const I=D.filter(F=>F.path!==M);return i(F=>F!==M?F:I.length?I[I.length-1].path:null),I})},[]),k=C.useCallback(M=>{p(D=>D.map(I=>{if(I.path!==v)return I;const F=M!==I.savedContent;return{...I,content:M,isDirty:F}}))},[v]),N=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(M=>M.map(D=>D.path===d.path?{...D,savedContent:D.content,isDirty:!1,loaded:!0}:D)))},[d,r,n,e]),L=C.useRef(()=>{});C.useEffect(()=>{L.current=()=>{N().catch(()=>{})}},[N]),C.useEffect(()=>{const M=D=>{r||(D.metaKey||D.ctrlKey)&&D.key.toLowerCase()==="s"&&(D.preventDefault(),L.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const R=C.useCallback((M,D)=>{M.addCommand(D.KeyMod.CtrlCmd|D.KeyCode.KeyS,()=>{L.current()})},[]);return s.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",t),style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:c,transition:x?"none":"width 0.15s ease"},children:l?s.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:s.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:s.jsx(Zc,{size:16})})}):s.jsx(s.Fragment,{children:s.jsx(e0,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!l&&s.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.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?s.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):m.map(M=>s.jsx(l0,{active:M.path===v,name:M.name,isDirty:M.isDirty,onClick:()=>i(M.path),onClose:D=>{D.stopPropagation(),w(M.path)}},M.path)),s.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&s.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),n.isPending&&s.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[s.jsx($e,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!n.isPending&&s.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),s.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?s.jsx(n0,{workingDir:e,filePath:d.path}):s.jsxs(s.Fragment,{children:[s.jsx(Tm,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>k(M??""),onMount:R,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!d.loaded&&s.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:s.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[s.jsx($e,{size:14,className:"animate-spin"}),o("Loading file...")]})}),S&&s.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"),E instanceof Error?`: ${E.message}`:""]})]}):s.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.")}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("No workspace selected.")})})]})]})};function Ia(e){return xt({queryKey:de.git.changes(e||""),queryFn:()=>ge.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function Ba(e,t,r){return xt({queryKey:de.git.diff(e||"",t||"",r),queryFn:()=>ge.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:r}}),enabled:!!e&&!!t})}function Fa(e,t){return xt({queryKey:de.git.commitFiles(e||"",t||""),queryFn:()=>ge.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function za(e,t,r){return xt({queryKey:de.git.commitDiff(e||"",t||"",r||""),queryFn:()=>ge.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:r||""}}),enabled:!!e&&!!t&&!!r})}const to={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"},d0={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function u0(e){const t=e.split("/");return t[t.length-1]||e}function h0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const f0=({entry:e,selected:t,onClick:r})=>{const{t:o}=ae(),m=to[e.status]||to.M,p=d0[e.status]||e.status,v=h0(e.path);return s.jsxs("button",{type:"button",onClick:r,className:te("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",t?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:o(p),children:e.status}),s.jsx("span",{className:"text-xs text-neutral-900 truncate",children:u0(e.path)}),v&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:v})]})},so=({title:e,entries:t,type:r,selectedKey:o,onSelect:m})=>{const{t:p}=ae();return t.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),s.jsx("div",{className:"space-y-0.5",children:t.map(v=>{const i=`${r}:${v.path}`;return s.jsx(f0,{entry:v,selected:o===i,onClick:()=>m(v.path,r)},i)})})]})},m0=({line:e,lineNum:t})=>{let r="",o="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",o="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",o="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",o="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-neutral-400"),s.jsxs("div",{className:te("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},p0=({workingDir:e,filePath:t,type:r})=>{const{t:o}=ae(),{data:m,isLoading:p,isError:v}=Ba(e,t,r);if(p)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
70
|
-
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(
|
|
71
|
-
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(b0,{line:c,lineNum:f+1},f))})},S0=({workingDir:e,hash:t,selectedPath:r,onSelectFile:o})=>{const{t:m}=ae(),{data:p,isLoading:v}=Fa(e,t);if(v)return s.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[s.jsx($e,{size:12,className:"animate-spin"}),s.jsx("span",{children:m("Loading...")})]});const i=p?.files||[];return i.length===0?s.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):s.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const c=ro[n.status]||ro.M,f=x0(n.path);return s.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),o(n.path)},className:te("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",r===n.path?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:te("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:n.status}),s.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:_0(n.path)}),f&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},n.path)})})},w0=({workingDir:e})=>{const{t}=ae(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:i}=Lo({queryKey:de.git.log(e||""),queryFn:({pageParam:S=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(Yr),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,E)=>S.commits.length<Yr?void 0:E.length*Yr,enabled:!!e}),n=r?.pages.flatMap(S=>S.commits)||[],[c,f]=C.useState(null),[l,g]=C.useState(null),[x,y]=C.useState(280),[_,a]=C.useState(!1),h=C.useCallback(S=>{S.preventDefault(),a(!0);const E=S.clientX,j=x,w=N=>{const L=Math.min(480,Math.max(180,j+(N.clientX-E)));y(L)},k=()=>{a(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k)},[x]),d=S=>{c===S?(f(null),g(null)):(f(S),g(null))},u=C.useRef(null);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(o)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(n.length===0)return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[s.jsx(cs,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No commit history")})]});const b=n.find(S=>S.hash===c);return s.jsxs("div",{className:"flex h-full bg-white",style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:x},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cs,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n.length})]})}),s.jsxs("div",{ref:u,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(S=>{const E=c===S.hash;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:te("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",E?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:s.jsx("div",{className:te("w-2 h-2 rounded-full shrink-0 transition-colors",E?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:S.shortHash}),s.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:S.message}),s.jsx(Mt,{size:12,className:te("shrink-0 text-neutral-400 transition-transform",E&&"rotate-90")})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:S.author}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:v0(S.timestamp)})]})]})]}),E&&s.jsxs(s.Fragment,{children:[S.body&&s.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-neutral-600 whitespace-pre-wrap leading-4 border-l-2 border-blue-100 ml-3",children:S.body}),s.jsx(S0,{workingDir:e,hash:S.hash,selectedPath:l,onSelectFile:g})]})]},S.hash)}),v&&s.jsx("button",{type:"button",onClick:()=>p(),disabled:i,className:"w-full py-2 text-xs text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded transition-colors flex items-center justify-center gap-1.5",children:i?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),s.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(ks,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:l}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",b?.shortHash,")"]})]}),s.jsx(y0,{workingDir:e,hash:c,filePath:l})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(ks,{size:28}),s.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function C0(e){return xt({queryKey:de.previews.status(e??""),queryFn:async()=>{const t=await ge.get(`/previews/${e}/status`);return{...t,viewUrl:t.viewUrl?t.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function k0(e){const t=Ge();return ht({mutationFn:r=>ge.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(t.invalidateQueries({queryKey:de.previews.status(e)}),t.invalidateQueries({queryKey:de.workspaces.all}))}})}function E0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function j0({workspaceId:e,readOnly:t}){const{t:r}=ae(),{data:o,isLoading:m,refetch:p,isFetching:v}=C0(e),i=k0(e),[n,c]=C.useState(""),[f,l]=C.useState(0);C.useEffect(()=>{c(o?.target??"")},[o?.target]);const g=C.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${f}`,[f,o?.ready,o?.viewUrl]),x=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),l(_=>_+1),ns.success(r("Preview target saved"))}catch(_){const a=_ instanceof Error?_.message:r("Failed to save preview target");ns.error(a)}},y=async()=>{await p(),l(_=>_+1)};return e?s.jsxs("div",{className:"h-full flex flex-col bg-white",children:[s.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:n,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&(_.preventDefault(),x())},disabled:t||i.isPending,placeholder:E0(),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"}),s.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:x,disabled:t||i.isPending,title:r("Save preview target"),children:[i.isPending?s.jsx($e,{className:"animate-spin"}):s.jsx(nd,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),s.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?s.jsx($e,{className:"animate-spin"}):s.jsx(Es,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&s.jsx(Ie,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:s.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:s.jsx(Ei,{})})})]}),s.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[s.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.")}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),s.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?s.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):s.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.")})})]}):s.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}const N0=[{key:"changes",label:"Changes",icon:s.jsx(ls,{size:14})},{key:"history",label:"History",icon:s.jsx(cs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ls,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(tr,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(yi,{size:14})}],A0=[{key:"history",label:"History",icon:s.jsx(cs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ls,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(tr,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(yi,{size:14})}],T0=({active:e,onClick:t,icon:r,label:o})=>s.jsxs("button",{onClick:t,className:te("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,s.jsx("span",{children:o})]}),Ha=ie.memo(function({className:t,sessionId:r,workspaceId:o,workingDir:m,projectId:p,hideChanges:v,readOnly:i,repoDeleted:n,teamRun:c,teamStatus:f}){const{t:l}=ae(),g=C.useMemo(()=>{const b=v?A0:N0,S=i?b.filter(E=>E.key!=="terminal"):b;return c?[{key:"team-status",label:"Team Status",icon:s.jsx(mr,{size:14})},...S]:S},[v,i,c]),[x,y]=C.useState(v?"history":"changes"),{data:_}=ic(p??""),a=C.useMemo(()=>{if(!_?.quickCommands)return[];try{return JSON.parse(_.quickCommands)}catch{return[]}},[_?.quickCommands]),[h,d]=C.useState([]),u=C.useRef(void 0);return C.useEffect(()=>{m&&m!==u.current&&(u.current=m,d(b=>b.includes(m)?b:[...b,m]))},[m]),C.useEffect(()=>{i&&x==="terminal"&&y(v?"history":"changes")},[x,v,i]),C.useEffect(()=>{c||x!=="team-status"||y(v?"history":"changes")},[x,v,c]),s.jsxs("div",{className:te("flex flex-col h-full bg-white",t),children:[i&&s.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:l(n?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),s.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:g.map(b=>s.jsx(T0,{active:x===b.key,onClick:()=>y(b.key),icon:b.icon,label:l(b.label)},b.key))}),s.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[x==="team-status"&&c&&f,x==="editor"&&s.jsx(c0,{workingDir:m,readOnly:i}),h.map(b=>s.jsx("div",{className:"h-full absolute inset-0",style:{display:x==="terminal"&&m===b?"block":"none"},children:s.jsx(yf,{cwd:b,quickCommands:a})},b)),x==="preview"&&s.jsx(j0,{workspaceId:o,readOnly:i}),x==="changes"&&s.jsx(g0,{workingDir:m}),x==="history"&&s.jsx(w0,{workingDir:m})]})]})});function R0(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function io(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 M0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Wa({workspaces:e,teamRun:t,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:m,className:p,buttonClassName:v}){const{t:i}=ae(),[n,c]=C.useState(!1),f=C.useRef(null),l=C.useMemo(()=>ca(e,t),[e,t]),g=l.find(x=>x.workspace.id===r)??l[0];return C.useEffect(()=>{if(!n)return;const x=y=>{f.current&&!f.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),l.length===0?s.jsxs("div",{className:te("inline-flex h-8 items-center gap-2 rounded-md border border-neutral-200 bg-neutral-50 px-2.5 text-xs text-neutral-400",p),children:[s.jsx(ds,{size:14}),s.jsx("span",{children:i("No workspace")})]}):s.jsxs("div",{ref:f,className:te("relative",p),children:[s.jsxs("button",{type:"button",onClick:()=>c(x=>!x),disabled:m,className:te("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:i("Workspace"),children:[s.jsx(ds,{size:14,className:"shrink-0 text-neutral-500"}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",io(g.roleLabel)),children:i(g.roleLabel)}),s.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),s.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:M0(g.workspace.branchName)}),s.jsx(bt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&s.jsx("div",{className:"absolute right-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(x=>{const y=x.workspace.id===g.workspace.id;return s.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),c(!1)},className:te("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[s.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?s.jsx(Tt,{size:13}):s.jsx(Ai,{size:13})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(x.displayName)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",io(x.roleLabel)),children:i(x.roleLabel)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",R0(x.workspace.status)),children:x.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:x.workspace.branchName}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&s.jsxs("span",{children:[i("Owner"),": ",x.ownerName]}),x.parentBranchName&&s.jsxs("span",{children:[i("Parent"),": ",x.parentBranchName]}),s.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}function $a(e){return xt({queryKey:de.workspaces.list(e),queryFn:()=>ge.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Ua(e){const t=Ge();return ht({mutationFn:r=>ge.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{t.invalidateQueries({queryKey:de.workspaces.list(e)}),t.invalidateQueries({queryKey:de.tasks.all})}})}function D0(){const e=Ge();return ht({mutationFn:({id:t,commitMessage:r})=>ge.post(`/workspaces/${t}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function L0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function qi(){return ht({mutationFn:({workspaceId:e,editorType:t})=>ge.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function qa(e){return xt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>ge.get(`/workspaces/${e}/git-status`),enabled:!!e})}function P0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/rebase`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})},onError:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})}})}function O0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})}})}const no=1500,I0=3e3;function B0(e){const[t,r]=C.useState(null),o=C.useRef(0),m=C.useRef(null),p=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},i=Ot.connect(),n=f=>{r(f),p.current=setTimeout(()=>r(null),I0)},c=f=>{if(f.taskId!==e)return;const l={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.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,x=no-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=l,p.current=setTimeout(()=>n(l),no)):x>0?(m.current=l,v(),p.current=setTimeout(()=>n(l),x)):n(l)};return i.on(dt.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(dt.WORKSPACE_SETUP_PROGRESS,c),v(),o.current=0,m.current=null}},[e]),t}function Ki(){const e=Ge();return ht({mutationFn:t=>ge.post(`/sessions/${t}/start`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Ka(){const e=Ge();return ht({mutationFn:t=>ge.post(`/sessions/${t}/stop`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)})}})}function Xi(){const e=Ge();return ht({mutationFn:({id:t,message:r,providerId:o})=>ge.post(`/sessions/${t}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function F0(e,t){const r={};return t?.status!=null&&(r.status=t.status),t?.page!=null&&(r.page=String(t.page)),t?.limit!=null&&(r.limit=String(t.limit)),xt({queryKey:de.tasks.list(e,t),queryFn:()=>ge.get(`/projects/${e}/tasks`,{params:r}),enabled:!!e})}function z0(e){const t=Ge();return ht({mutationFn:r=>ge.post(`/projects/${e}/tasks`,r),onSuccess:()=>{t.invalidateQueries({queryKey:de.tasks.list(e)}),t.invalidateQueries({queryKey:de.tasks.stats(e)})}})}function H0(){const e=Ge();return ht({mutationFn:({id:t,status:r})=>ge.patch(`/tasks/${t}/status`,{status:r}),onSuccess:t=>{e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.tasks.detail(t.id)})}})}function W0(){const e=Ge();return ht({mutationFn:t=>ge.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:de.tasks.all})}})}function $0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.detail(t.id)})}})}function Xa(e,t){return C.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 t??null},[e,t])}function Va({isOpen:e,onClose:t,taskId:r,taskTitle:o,taskDescription:m}){const{t:p}=ae(),[v,i]=C.useState(""),[n,c]=C.useState(""),[f,l]=C.useState("idle"),[g,x]=C.useState(null),y=Ge(),_=Ua(r),a=Ki(),{data:h,isLoading:d}=Ds();C.useEffect(()=>{if(!e||!h)return;const E=h.find(j=>j.availability.type!=="NOT_FOUND");E&&i(E.provider.id)},[e,h]),C.useEffect(()=>{if(e){const E=[o];m&&E.push(m),c(E.join(`
|
|
69
|
+
`,Jn={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Bp(Fp);var zp=function(e){var t=e.children,r=e.wrapperClass,o=r===void 0?"":r,m=e.contentClass,p=m===void 0?"":m,v=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,c=n===void 0?{}:n,f=e.contentProps,l=f===void 0?{}:f,g=C.useContext(kr),b=g.init,y=g.cleanupWindowEvents,_=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=_.current,d=a.current;return h!==null&&d!==null&&b&&b?.(h,d),function(){y?.()}},[]),ie.createElement("div",zt({},c,{ref:_,className:"".concat(ni.wrapperClass," ").concat(Jn.wrapper," ").concat(o),style:v}),ie.createElement("div",zt({},l,{ref:a,className:"".concat(ni.contentClass," ").concat(Jn.content," ").concat(p),style:i}),t))},Pa=function(){var e=C.useContext(kr);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Hp=function(){var e=Pa();return lr(e)};function Wp(e){var t=Pa(),r=C.useState(e(oi(t))),o=r[0],m=r[1];return C.useEffect(function(){var p=!0,v=t.onChange(function(i){p&&m(e(oi(i.instance)))});return function(){v(),p=!1}},[e,t]),o}function $p(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 Up(e,t){return bt({queryKey:de.files.tree(e||"",t),queryFn:()=>ge.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function qp(e,t){return bt({queryKey:de.files.content(e||"",t||""),queryFn:()=>ge.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Kp(e){const t=Ge();return C.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Xp(){const e=Ge();return ht({mutationFn:t=>ge.post("/files/write",t),onSuccess:(t,r)=>{const o=de.files.content(r.workingDir,r.path),m=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:m?.language||$p(r.path)})}})}function Vp(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Yp(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const Gp=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Qp(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&Gp.has(t)?Ni:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?ks:t==="json"?Ec:t==="md"||t==="mdx"||t==="txt"?ki:rc}const eo=({depth:e,active:t,onClick:r,leftIcon:o,rightIcon:m,label:p})=>s.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",t&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[s.jsx("span",{className:"shrink-0",children:m}),s.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),s.jsx("span",{className:"truncate text-neutral-700",children:p})]}),Oa=({workingDir:e,path:t,depth:r,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})=>{const{t:i}=ae(),{data:n,isLoading:c,isError:f}=Up(e,t),l=C.useMemo(()=>n?.items??[],[n?.items]);return c?s.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):f?s.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):s.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const h=Vp(t,g.name),d=o.has(h);return s.jsxs("div",{children:[s.jsx(eo,{depth:r,onClick:()=>m(h),rightIcon:d?s.jsx(vt,{size:14,className:"text-neutral-400"}):s.jsx(Tt,{size:14,className:"text-neutral-400"}),leftIcon:d?s.jsx(Ei,{size:14,className:"text-amber-500"}):s.jsx(sc,{size:14,className:"text-amber-500"}),label:g.name}),d&&s.jsx(Oa,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:m,onFileSelect:p,selectedFilePath:v})]},h)}const b=Yp(t,g.name),y=Qp(g),_=v===b,a=y===Ni;return s.jsx(eo,{depth:r,active:_,onClick:()=>p(b),rightIcon:s.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?s.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},b)})})},Zp=({workingDir:e,className:t,onFileSelect:r,selectedFilePath:o,onCollapse:m})=>{const{t:p}=ae(),[v,i]=C.useState(()=>new Set),n=Kp(e),c=C.useCallback(f=>{i(l=>{const g=new Set(l);return g.has(f)?g.delete(f):g.add(f),g})},[]);return s.jsxs("div",{className:te("h-full flex flex-col",t),children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),s.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&s.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:s.jsx(Ri,{size:13})}),m&&s.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:s.jsx(Vc,{size:13})})]})]}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?s.jsx(Oa,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:c,onFileSelect:r,selectedFilePath:o}):s.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},Jp=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function e0(e){const t=e.split(".").pop()?.toLowerCase();return t?Jp.has(t):!1}function t0(e,t){const r="/api",o=new URLSearchParams({workingDir:e,path:t});return`${r}/files/image?${o.toString()}`}const s0=({filePath:e})=>{const{t}=ae(),{zoomIn:r,zoomOut:o,centerView:m}=Hp(),p=Wp(i=>i.state.scale),v=Math.round(p*100);return s.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:[s.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:t("Zoom out"),children:s.jsx(hd,{size:14})}),s.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:t("Reset zoom"),children:[v,"%"]}),s.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:t("Zoom in"),children:s.jsx(dd,{size:14})}),s.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:t("Fit to view"),children:s.jsx(qc,{size:13})}),s.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},r0=({workingDir:e,filePath:t})=>{const{t:r}=ae(),[o,m]=C.useState(!1),p=t0(e,t);return o?s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):s.jsx(Ip,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx(s0,{filePath:t}),s.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:s.jsx(zp,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:s.jsx("img",{src:p,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>m(!0)})})})]})})};function i0(e){const t=e.split("/");return t[t.length-1]||e}function n0(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 o0=({active:e,name:t,isDirty:r,onClick:o,onClose:m})=>{const{t:p}=ae();return s.jsxs("button",{type:"button",onClick:o,className:te("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:[s.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),s.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),s.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:s.jsx(Wt,{size:12})})]})},a0=({workingDir:e,className:t,readOnly:r=!1})=>{const{t:o}=ae(),[m,p]=C.useState([]),[v,i]=C.useState(null),n=Xp(),[c,f]=C.useState(280),[l,g]=C.useState(!1),[b,y]=C.useState(!1),_=C.useRef(280),a=C.useCallback(()=>{g(R=>(R?f(_.current):_.current=c,!R))},[c]),h=C.useCallback(R=>{R.preventDefault(),y(!0);const D=R.clientX,I=c,F=A=>{const P=A.clientX-D,O=Math.min(480,Math.max(160,I+P));f(O)},z=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);C.useEffect(()=>{p([]),i(null)},[e]);const d=C.useMemo(()=>m.find(R=>R.path===v)||null,[m,v]),{data:u,isFetching:x,isError:S,error:k}=qp(e,d?.isImage?null:v);C.useEffect(()=>{!v||!u||p(R=>R.map(D=>D.path!==v||D.isDirty||D.loaded?D:{...D,language:u.language||D.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[v,u]);const E=C.useCallback(R=>{p(D=>{if(D.find(z=>z.path===R))return D;const F=e0(R);return[...D,{path:R,name:i0(R),language:n0(R),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(R)},[]),w=C.useCallback(R=>{p(D=>{const I=D.filter(F=>F.path!==R);return i(F=>F!==R?F:I.length?I[I.length-1].path:null),I})},[]),j=C.useCallback(R=>{p(D=>D.map(I=>{if(I.path!==v)return I;const F=R!==I.savedContent;return{...I,content:R,isDirty:F}}))},[v]),T=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),p(R=>R.map(D=>D.path===d.path?{...D,savedContent:D.content,isDirty:!1,loaded:!0}:D)))},[d,r,n,e]),L=C.useRef(()=>{});C.useEffect(()=>{L.current=()=>{T().catch(()=>{})}},[T]),C.useEffect(()=>{const R=D=>{r||(D.metaKey||D.ctrlKey)&&D.key.toLowerCase()==="s"&&(D.preventDefault(),L.current())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r]);const N=C.useCallback((R,D)=>{R.addCommand(D.KeyMod.CtrlCmd|D.KeyCode.KeyS,()=>{L.current()})},[]);return s.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",t),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:c,transition:b?"none":"width 0.15s ease"},children:l?s.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:s.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:s.jsx(Gc,{size:16})})}):s.jsx(s.Fragment,{children:s.jsx(Zp,{workingDir:e,onFileSelect:E,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!l&&s.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.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?s.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):m.map(R=>s.jsx(o0,{active:R.path===v,name:R.name,isDirty:R.isDirty,onClick:()=>i(R.path),onClose:D=>{D.stopPropagation(),w(R.path)}},R.path)),s.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&s.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),n.isPending&&s.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[s.jsx($e,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!n.isPending&&s.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),s.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?s.jsx(r0,{workingDir:e,filePath:d.path}):s.jsxs(s.Fragment,{children:[s.jsx(Nm,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:R=>j(R??""),onMount:N,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),x&&!d.loaded&&s.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:s.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[s.jsx($e,{size:14,className:"animate-spin"}),o("Loading file...")]})}),S&&s.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}`:""]})]}):s.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.")}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("No workspace selected.")})})]})]})};function Ia(e){return bt({queryKey:de.git.changes(e||""),queryFn:()=>ge.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function Ba(e,t,r){return bt({queryKey:de.git.diff(e||"",t||"",r),queryFn:()=>ge.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:r}}),enabled:!!e&&!!t})}function Fa(e,t){return bt({queryKey:de.git.commitFiles(e||"",t||""),queryFn:()=>ge.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function za(e,t,r){return bt({queryKey:de.git.commitDiff(e||"",t||"",r||""),queryFn:()=>ge.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:r||""}}),enabled:!!e&&!!t&&!!r})}const to={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"},l0={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function c0(e){const t=e.split("/");return t[t.length-1]||e}function d0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const u0=({entry:e,selected:t,onClick:r})=>{const{t:o}=ae(),m=to[e.status]||to.M,p=l0[e.status]||e.status,v=d0(e.path);return s.jsxs("button",{type:"button",onClick:r,className:te("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",t?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",m),title:o(p),children:e.status}),s.jsx("span",{className:"text-xs text-neutral-900 truncate",children:c0(e.path)}),v&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:v})]})},so=({title:e,entries:t,type:r,selectedKey:o,onSelect:m})=>{const{t:p}=ae();return t.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),s.jsx("div",{className:"space-y-0.5",children:t.map(v=>{const i=`${r}:${v.path}`;return s.jsx(u0,{entry:v,selected:o===i,onClick:()=>m(v.path,r)},i)})})]})},h0=({line:e,lineNum:t})=>{let r="",o="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",o="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",o="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",o="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-neutral-400"),s.jsxs("div",{className:te("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},f0=({workingDir:e,filePath:t,type:r})=>{const{t:o}=ae(),{data:m,isLoading:p,isError:v}=Ba(e,t,r);if(p)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
70
|
+
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(h0,{line:c,lineNum:f+1},f))})},m0=({workingDir:e})=>{const{t}=ae(),{data:r,isLoading:o,isError:m}=Ia(e),[p,v]=C.useState(null),[i,n]=C.useState(260),[c,f]=C.useState(!1),l=C.useCallback(h=>{h.preventDefault(),f(!0);const d=h.clientX,u=i,x=k=>{const E=k.clientX-d,w=Math.min(480,Math.max(160,u+E));n(w)},S=()=>{f(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",S)},[i]),g=p?`${p.type}:${p.path}`:null,b=(h,d)=>{v({path:h,type:d})};if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(o)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load changes.")});const y=r?.uncommitted||[],_=r?.committed||[],a=y.length+_.length;return s.jsxs("div",{className:"flex h-full bg-white",style:c?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:i},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(as,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("Changes")}),a>0&&s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:a})]})}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:a===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[s.jsx(as,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No pending changes")})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(so,{title:"Uncommitted",entries:y,type:"uncommitted",selectedKey:g,onSelect:b}),s.jsx(so,{title:"Committed",entries:_,type:"committed",selectedKey:g,onSelect:b})]})})]}),s.jsx("div",{onMouseDown:l,className:te("w-1 shrink-0 cursor-col-resize transition-colors",c?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:p?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(ks,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:p.path}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",t(p.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),s.jsx(f0,{workingDir:e,filePath:p.path,type:p.type})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(ks,{size:28}),s.jsx("span",{className:"text-xs",children:t("Select a file to view diff")})]})})})]})},Xr=50,ro={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 p0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Bt("{count}s ago",{count:r}):r<3600?Bt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Bt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Bt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function g0(e){const t=e.split("/");return t[t.length-1]||e}function v0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const _0=({line:e,lineNum:t})=>{let r="",o="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",o="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",o="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",o="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-neutral-400"),s.jsxs("div",{className:te("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},x0=({workingDir:e,hash:t,filePath:r})=>{const{t:o}=ae(),{data:m,isLoading:p,isError:v}=za(e,t,r);if(p)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
71
|
+
`);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(_0,{line:c,lineNum:f+1},f))})},b0=({workingDir:e,hash:t,selectedPath:r,onSelectFile:o})=>{const{t:m}=ae(),{data:p,isLoading:v}=Fa(e,t);if(v)return s.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[s.jsx($e,{size:12,className:"animate-spin"}),s.jsx("span",{children:m("Loading...")})]});const i=p?.files||[];return i.length===0?s.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:m("No files changed")}):s.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const c=ro[n.status]||ro.M,f=v0(n.path);return s.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),o(n.path)},className:te("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",r===n.path?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:te("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:n.status}),s.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:g0(n.path)}),f&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},n.path)})})},y0=({workingDir:e})=>{const{t}=ae(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:i}=Lo({queryKey:de.git.log(e||""),queryFn:({pageParam:S=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(Xr),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,k)=>S.commits.length<Xr?void 0:k.length*Xr,enabled:!!e}),n=r?.pages.flatMap(S=>S.commits)||[],[c,f]=C.useState(null),[l,g]=C.useState(null),[b,y]=C.useState(280),[_,a]=C.useState(!1),h=C.useCallback(S=>{S.preventDefault(),a(!0);const k=S.clientX,E=b,w=T=>{const L=Math.min(480,Math.max(180,E+(T.clientX-k)));y(L)},j=()=>{a(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",j)},[b]),d=S=>{c===S?(f(null),g(null)):(f(S),g(null))},u=C.useRef(null);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(o)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(n.length===0)return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[s.jsx(ls,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No commit history")})]});const x=n.find(S=>S.hash===c);return s.jsxs("div",{className:"flex h-full bg-white",style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:b},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ls,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n.length})]})}),s.jsxs("div",{ref:u,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(S=>{const k=c===S.hash;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:te("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",k?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:s.jsx("div",{className:te("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:S.shortHash}),s.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:S.message}),s.jsx(Tt,{size:12,className:te("shrink-0 text-neutral-400 transition-transform",k&&"rotate-90")})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:S.author}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:p0(S.timestamp)})]})]})]}),k&&s.jsxs(s.Fragment,{children:[S.body&&s.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-neutral-600 whitespace-pre-wrap leading-4 border-l-2 border-blue-100 ml-3",children:S.body}),s.jsx(b0,{workingDir:e,hash:S.hash,selectedPath:l,onSelectFile:g})]})]},S.hash)}),v&&s.jsx("button",{type:"button",onClick:()=>p(),disabled:i,className:"w-full py-2 text-xs text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded transition-colors flex items-center justify-center gap-1.5",children:i?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),s.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(ks,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:l}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",x?.shortHash,")"]})]}),s.jsx(x0,{workingDir:e,hash:c,filePath:l})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(ks,{size:28}),s.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function S0(e){return bt({queryKey:de.previews.status(e??""),queryFn:async()=>{const t=await ge.get(`/previews/${e}/status`);return{...t,viewUrl:t.viewUrl?t.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function w0(e){const t=Ge();return ht({mutationFn:r=>ge.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(t.invalidateQueries({queryKey:de.previews.status(e)}),t.invalidateQueries({queryKey:de.workspaces.all}))}})}function C0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function k0({workspaceId:e,readOnly:t}){const{t:r}=ae(),{data:o,isLoading:m,refetch:p,isFetching:v}=S0(e),i=w0(e),[n,c]=C.useState(""),[f,l]=C.useState(0);C.useEffect(()=>{c(o?.target??"")},[o?.target]);const g=C.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${f}`,[f,o?.ready,o?.viewUrl]),b=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),l(_=>_+1),is.success(r("Preview target saved"))}catch(_){const a=_ instanceof Error?_.message:r("Failed to save preview target");is.error(a)}},y=async()=>{await p(),l(_=>_+1)};return e?s.jsxs("div",{className:"h-full flex flex-col bg-white",children:[s.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:n,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&(_.preventDefault(),b())},disabled:t||i.isPending,placeholder:C0(),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"}),s.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:t||i.isPending,title:r("Save preview target"),children:[i.isPending?s.jsx($e,{className:"animate-spin"}):s.jsx(rd,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),s.jsxs(Ie,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?s.jsx($e,{className:"animate-spin"}):s.jsx(Ri,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&s.jsx(Ie,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:s.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:s.jsx(Ci,{})})})]}),s.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[s.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.")}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),s.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?s.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):s.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.")})})]}):s.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}const E0=[{key:"changes",label:"Changes",icon:s.jsx(as,{size:14})},{key:"history",label:"History",icon:s.jsx(ls,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ms,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(Js,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(xi,{size:14})}],j0=[{key:"history",label:"History",icon:s.jsx(ls,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(Ms,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(Js,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(xi,{size:14})}],N0=({active:e,onClick:t,icon:r,label:o})=>s.jsxs("button",{onClick:t,className:te("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,s.jsx("span",{children:o})]}),Ha=ie.memo(function({className:t,sessionId:r,workspaceId:o,workingDir:m,projectId:p,hideChanges:v,readOnly:i,repoDeleted:n,teamRun:c,teamStatus:f}){const{t:l}=ae(),g=C.useMemo(()=>{const x=v?j0:E0,S=i?x.filter(k=>k.key!=="terminal"):x;return c?[{key:"team-status",label:"Team Status",icon:s.jsx(Ss,{size:14})},...S]:S},[v,i,c]),[b,y]=C.useState(v?"history":"changes"),{data:_}=ic(p??""),a=C.useMemo(()=>{if(!_?.quickCommands)return[];try{return JSON.parse(_.quickCommands)}catch{return[]}},[_?.quickCommands]),[h,d]=C.useState([]),u=C.useRef(void 0);return C.useEffect(()=>{m&&m!==u.current&&(u.current=m,d(x=>x.includes(m)?x:[...x,m]))},[m]),C.useEffect(()=>{i&&b==="terminal"&&y(v?"history":"changes")},[b,v,i]),C.useEffect(()=>{c||b!=="team-status"||y(v?"history":"changes")},[b,v,c]),s.jsxs("div",{className:te("flex flex-col h-full bg-white",t),children:[i&&s.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:l(n?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),s.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:g.map(x=>s.jsx(N0,{active:b===x.key,onClick:()=>y(x.key),icon:x.icon,label:l(x.label)},x.key))}),s.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[b==="team-status"&&c&&f,b==="editor"&&s.jsx(a0,{workingDir:m,readOnly:i}),h.map(x=>s.jsx("div",{className:"h-full absolute inset-0",style:{display:b==="terminal"&&m===x?"block":"none"},children:s.jsx(xf,{cwd:x,quickCommands:a})},x)),b==="preview"&&s.jsx(k0,{workspaceId:o,readOnly:i}),b==="changes"&&s.jsx(m0,{workingDir:m}),b==="history"&&s.jsx(y0,{workingDir:m})]})]})});function A0(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function io(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 R0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Wa({workspaces:e,teamRun:t,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:m,className:p,buttonClassName:v}){const{t:i}=ae(),[n,c]=C.useState(!1),f=C.useRef(null),l=C.useMemo(()=>ca(e,t),[e,t]),g=l.find(b=>b.workspace.id===r)??l[0];return C.useEffect(()=>{if(!n)return;const b=y=>{f.current&&!f.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]),l.length===0?s.jsxs("div",{className:te("inline-flex h-8 items-center gap-2 rounded-md border border-neutral-200 bg-neutral-50 px-2.5 text-xs text-neutral-400",p),children:[s.jsx(cs,{size:14}),s.jsx("span",{children:i("No workspace")})]}):s.jsxs("div",{ref:f,className:te("relative",p),children:[s.jsxs("button",{type:"button",onClick:()=>c(b=>!b),disabled:m,className:te("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:i("Workspace"),children:[s.jsx(cs,{size:14,className:"shrink-0 text-neutral-500"}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",io(g.roleLabel)),children:i(g.roleLabel)}),s.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),s.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:R0(g.workspace.branchName)}),s.jsx(vt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&s.jsx("div",{className:"absolute right-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(b=>{const y=b.workspace.id===g.workspace.id;return s.jsxs("button",{type:"button",onClick:()=>{o(b.workspace.id),c(!1)},className:te("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[s.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?s.jsx(Rt,{size:13}):s.jsx(ji,{size:13})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(b.displayName)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",io(b.roleLabel)),children:i(b.roleLabel)}),s.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",A0(b.workspace.status)),children:b.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:b.workspace.branchName}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[b.ownerName&&s.jsxs("span",{children:[i("Owner"),": ",b.ownerName]}),b.parentBranchName&&s.jsxs("span",{children:[i("Parent"),": ",b.parentBranchName]}),s.jsx("span",{children:b.workspace.id.slice(0,8)})]})]})]},b.workspace.id)})})]})}function $a(e){return bt({queryKey:de.workspaces.list(e),queryFn:()=>ge.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Ua(e){const t=Ge();return ht({mutationFn:r=>ge.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{t.invalidateQueries({queryKey:de.workspaces.list(e)}),t.invalidateQueries({queryKey:de.tasks.all})}})}function T0(){const e=Ge();return ht({mutationFn:({id:t,commitMessage:r})=>ge.post(`/workspaces/${t}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function M0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Ui(){return ht({mutationFn:({workspaceId:e,editorType:t})=>ge.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function qa(e){return bt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>ge.get(`/workspaces/${e}/git-status`),enabled:!!e})}function D0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/rebase`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})},onError:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})}})}function L0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)})}})}const no=1500,P0=3e3;function O0(e){const[t,r]=C.useState(null),o=C.useRef(0),m=C.useRef(null),p=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},i=It.connect(),n=f=>{r(f),p.current=setTimeout(()=>r(null),P0)},c=f=>{if(f.taskId!==e)return;const l={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.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,b=no-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),m.current=l,p.current=setTimeout(()=>n(l),no)):b>0?(m.current=l,v(),p.current=setTimeout(()=>n(l),b)):n(l)};return i.on(dt.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(dt.WORKSPACE_SETUP_PROGRESS,c),v(),o.current=0,m.current=null}},[e]),t}function qi(){const e=Ge();return ht({mutationFn:t=>ge.post(`/sessions/${t}/start`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Ka(){const e=Ge();return ht({mutationFn:t=>ge.post(`/sessions/${t}/stop`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:de.sessions.detail(r)})}})}function Ki(){const e=Ge();return ht({mutationFn:({id:t,message:r,providerId:o})=>ge.post(`/sessions/${t}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function I0(e,t){const r={};return t?.status!=null&&(r.status=t.status),t?.page!=null&&(r.page=String(t.page)),t?.limit!=null&&(r.limit=String(t.limit)),bt({queryKey:de.tasks.list(e,t),queryFn:()=>ge.get(`/projects/${e}/tasks`,{params:r}),enabled:!!e})}function B0(e){const t=Ge();return ht({mutationFn:r=>ge.post(`/projects/${e}/tasks`,r),onSuccess:()=>{t.invalidateQueries({queryKey:de.tasks.list(e)}),t.invalidateQueries({queryKey:de.tasks.stats(e)})}})}function F0(){const e=Ge();return ht({mutationFn:({id:t,status:r})=>ge.patch(`/tasks/${t}/status`,{status:r}),onSuccess:t=>{e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.tasks.detail(t.id)})}})}function z0(){const e=Ge();return ht({mutationFn:t=>ge.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:de.tasks.all})}})}function H0(){const e=Ge();return ht({mutationFn:t=>ge.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.detail(t.id)})}})}function Xa(e,t){return C.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 t??null},[e,t])}function Va({isOpen:e,onClose:t,taskId:r,taskTitle:o,taskDescription:m}){const{t:p}=ae(),[v,i]=C.useState(""),[n,c]=C.useState(""),[f,l]=C.useState("idle"),[g,b]=C.useState(null),y=Ge(),_=Ua(r),a=qi(),{data:h,isLoading:d}=Ts();C.useEffect(()=>{if(!e||!h)return;const k=h.find(E=>E.availability.type!=="NOT_FOUND");k&&i(k.provider.id)},[e,h]),C.useEffect(()=>{if(e){const k=[o];m&&k.push(m),c(k.join(`
|
|
72
72
|
|
|
73
|
-
`)),l("idle"),x(null)}},[e,o,m]);const u=f!=="idle",b=async()=>{if(!(!v||!n.trim())){x(null);try{l("creating-workspace");const E=await _.mutateAsync({});l("creating-session");const j=await ge.post(`/workspaces/${E.id}/sessions`,{providerId:v,prompt:n.trim()});l("starting-session"),await a.mutateAsync(j.id),await y.invalidateQueries({queryKey:de.workspaces.list(r)}),l("idle"),t()}catch(E){l("idle"),x(E instanceof Error?E.message:p("启动失败,请重试"))}}},S={idle:p("启动"),"creating-workspace":p("创建工作空间..."),"creating-session":p("创建会话..."),"starting-session":p("启动 Agent...")};return s.jsx(Ms,{isOpen:e,onClose:u?()=>{}:t,title:p("启动 Agent"),action:s.jsxs(s.Fragment,{children:[s.jsx(Ie,{variant:"outline",onClick:t,disabled:u,children:p("取消")}),s.jsx(Ie,{onClick:b,disabled:u||!v||!n.trim(),children:S[f]})]}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("选择 Provider")}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d&&s.jsx("span",{className:"text-sm text-neutral-400",children:p("加载中...")}),h?.map(({provider:E,availability:j})=>{const w=j.type!=="NOT_FOUND";return s.jsxs(Ie,{variant:v===E.id?"default":"outline",size:"sm",disabled:!w||u,onClick:()=>i(E.id),children:[E.name,!w&&p(" (不可用)")]},E.id)})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("任务描述")}),s.jsx("textarea",{value:n,onChange:E=>c(E.target.value),rows:5,disabled:u,placeholder:p("描述你想让 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"})]}),g&&s.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:g})]})})}function Ya(e){const t=e?.tokenUsage;if(!(!t||typeof t.totalTokens!="number"))return t}function U0(e,t,r){const o=e?.providerId??r?.providerId??null,m=o?t?.find(i=>i.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 Ga({session:e,providers:t,usage:r,compact:o=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:v="top"}){const{t:i}=ae(),n=U0(e,t,{providerId:m,agentType:p});return!n&&!r?null:s.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&s.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:`${i("Provider")}: ${n.title}`,children:[s.jsx(Ls,{size:o?12:14,className:"shrink-0 text-neutral-400"}),s.jsx("span",{className:"min-w-0 truncate",children:si(n.label,o?12:18)})]}),s.jsx(Hi,{usage:r,tooltipSide:v})]})}function q0(e,t){return e instanceof Error?e.message:t}function K0(e){return Object.values(e).filter(Boolean).length}function oo(e,t,r,o){if(r.filter(v=>v===o).length<=1)return e;const p=r.slice(0,t+1).filter(v=>v===o).length;return`${e} #${p}`}function ao({title:e,error:t,isFetching:r,onRetry:o,disabled:m}){const{t:p}=ae();return s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium",children:e}),s.jsx("div",{className:"mt-1 text-xs text-red-600",children:q0(t,p("请稍后重试。"))})]}),s.jsx(Ie,{type:"button",size:"sm",variant:"outline",onClick:o,disabled:m||r,children:r?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:14,className:"animate-spin"}),p("加载中...")]}):p("重试")})]})})}function Qa({mode:e,setMode:t,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:v=!1}){const{t:i}=ae(),{data:n}=Ds(),{data:c,error:f,isError:l,isFetching:g,isLoading:x,refetch:y}=Zl(),{data:_,error:a,isError:h,isFetching:d,isLoading:u,refetch:b}=Jl(),S=C.useMemo(()=>new Map((n??[]).map(({provider:D,availability:I})=>[D.id,D.name+(I.type==="NOT_FOUND"?i(" (不可用)"):"")])),[n,i]),E=C.useMemo(()=>new Map((c??[]).map(D=>[D.id,D])),[c]),j=C.useMemo(()=>new Map((_??[]).map(D=>[D.id,D])),[_]),w=r?j.get(r)??null:null,k=C.useMemo(()=>m.map(D=>E.get(D)).filter(D=>!!D),[E,m]);C.useEffect(()=>{c!==void 0&&p(D=>{const I=D.filter(F=>E.has(F));return I.length===D.length&&I.every((F,z)=>F===D[z])?D:I})},[c,E,p]),C.useEffect(()=>{_!==void 0&&o(D=>!D||j.has(D)?D:null)},[o,j,_]);const N=D=>{v||o(I=>I===D?null:D)},L=D=>{v||p(I=>[...I,D])},R=D=>{v||p(I=>I.filter((F,z)=>z!==D))},M=(D,I)=>{v||p(F=>{const z=D+I;if(z<0||z>=F.length)return F;const A=[...F],[P]=A.splice(D,1);return A.splice(z,0,P),A})};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i("TeamRun 模式")}),s.jsx("div",{className:"text-xs text-neutral-500",children:i("默认使用自动模式,团队消息会直接排队执行。")})]}),s.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[s.jsx("button",{type:"button",onClick:()=>!v&&t("CONFIRM"),disabled:v,className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("确认模式")}),s.jsx("button",{type:"button",onClick:()=>!v&&t("AUTO"),disabled:v,className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("自动模式")})]})]}),s.jsx("div",{className:"pr-1",children:s.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("团队模板")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("模板成员会先加入,随后按顺序追加所选成员。")})]}),h?s.jsx(ao,{title:i("团队模板加载失败"),error:a,isFetching:d,onRetry:()=>{b()},disabled:v}):u?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),i("加载中...")]}):(_??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有团队模板")}),s.jsx(Ie,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Qs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(_??[]).map(D=>{const I=D.id===r,F=D.members?.length??0,z=D.members?.map(P=>P.memberPresetId)??[],A=D.members?.slice(0,3).map((P,O)=>oo(P.memberPreset?.name??P.memberPresetId,O,z,P.memberPresetId)).join(" · ");return s.jsx("button",{type:"button",onClick:()=>N(D.id),disabled:v,className:te("w-full rounded-lg border px-3 py-2 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60",I?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:D.name}),s.jsx("div",{className:"mt-1 truncate text-xs text-neutral-500",children:i("{count} 个成员",{count:F})}),A&&s.jsx("div",{className:"mt-2 truncate text-[11px] text-neutral-400",children:A})]}),I&&s.jsx(Tt,{size:14,className:"mt-0.5 shrink-0 text-neutral-900"})]})},D.id)})})]}),s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("成员预设")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("选择顺序即保存顺序。")})]}),l?s.jsx(ao,{title:i("成员预设加载失败"),error:f,isFetching:g,onRetry:()=>{y()},disabled:v}):x?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),i("加载中...")]}):(c??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有成员预设")}),s.jsx(Ie,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Qs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(c??[]).map(D=>{const I=m.filter(A=>A===D.id).length,F=S.get(D.providerId)??D.providerId,z=K0(D.capabilities);return s.jsxs("button",{type:"button",onClick:()=>L(D.id),disabled:v,className:te("flex w-full items-start gap-3 rounded-lg border px-3 py-2 text-left transition-colors",v&&"cursor-not-allowed opacity-60",I>0?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[s.jsx(Xt,{name:D.name,avatar:D.avatar,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:D.name}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs("span",{className:"text-[11px] text-neutral-400",children:[z,"/10"]}),I>0&&s.jsxs("span",{className:"rounded-full bg-neutral-900 px-2 py-0.5 text-[11px] font-medium text-white",children:["x",I]}),s.jsx(as,{size:15,className:"text-neutral-500"})]})]},D.id)})})]})]}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("已选成员")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("上移下移后即为保存顺序。")})]}),k.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:i("尚未选择成员预设")}):s.jsx("div",{className:"space-y-2",children:k.map((D,I)=>{const F=S.get(D.providerId)??D.providerId,z=oo(D.name,I,m,D.id);return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Xt,{name:D.name,avatar:D.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:z}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(I,-1),disabled:v||I===0,title:i("上移"),children:s.jsx(wi,{size:14})}),s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>M(I,1),disabled:v||I===k.length-1,title:i("下移"),children:s.jsx(bt,{size:14})}),s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>R(I),disabled:v,title:i("移除"),children:s.jsx(Si,{size:14})})]})]},`${D.id}-${I}`)})})]}),s.jsxs("section",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-4",children:[s.jsx("div",{className:"text-xs font-medium text-neutral-700",children:i("模板成员会先加入,随后按顺序追加所选成员。")}),s.jsx("div",{className:"mt-2 text-xs text-neutral-500",children:w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium text-neutral-700",children:w.name}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:i("{count} 个成员",{count:w.members?.length??0})})]}):s.jsx("span",{children:i("请选择至少一个团队模板或成员预设。")})})]})]})]})})]})}function X0({isOpen:e,onClose:t,taskId:r}){const{t:o}=ae(),[m,p]=C.useState("AUTO"),[v,i]=C.useState(null),[n,c]=C.useState([]),[f,l]=C.useState(null),g=jo();C.useEffect(()=>{e&&(p("AUTO"),i(null),c([]),l(null))},[e]);const x=g.isPending,y=!!v||n.length>0,_=async()=>{if(!x){if(!v&&n.length===0){l(o("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:m,...v?{teamTemplateId:v}:{},...n.length>0?{memberPresetIds:n}:{}}),t()}catch(h){if(h instanceof No&&h.status===409){l(o("该任务已经存在 TeamRun。请刷新后再试。"));return}l(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!y;return s.jsxs(Ms,{isOpen:e,onClose:x?()=>{}:t,title:o("创建 TeamRun"),className:"max-w-5xl",action:s.jsxs(s.Fragment,{children:[s.jsx(Ie,{type:"button",variant:"outline",onClick:t,disabled:x,children:o("取消")}),s.jsx(Ie,{type:"button",onClick:_,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[s.jsx(Qa,{mode:m,setMode:p,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:c,disabled:x}),f&&s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f})]})}function Za({providers:e,currentProviderId:t,agentType:r,onSelect:o}){const{t:m}=ae(),[p,v]=C.useState(!1),i=C.useRef(null),n=e.filter(f=>String(f.provider.agentType)===r),c=e.find(f=>f.provider.id===t);return C.useEffect(()=>{function f(l){i.current&&!i.current.contains(l.target)&&v(!1)}if(p)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[p]),n.length<=1?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[s.jsx(un,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?si(c.provider.name,12):r})]}):s.jsxs("div",{className:"relative",ref:i,children:[s.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:[s.jsx(un,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?si(c.provider.name,12):r}),s.jsx(bt,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&s.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:[s.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),n.map(f=>s.jsxs("button",{onClick:()=>{o(f.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 ${f.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&s.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===t&&s.jsx(Tt,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function V0({commands:e,selectedIndex:t,query:r,hasCatalog:o,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:c=!1,onSelect:f}){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",x=c?"max-h-36":"max-h-48";return s.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[s.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[s.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?s.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?i??`No matches for ${p}${r}`:v}):s.jsx("div",{className:`${l} ${x} overflow-y-auto`,children:e.map((y,_)=>s.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>f(y),className:`w-full rounded-lg border text-left transition-colors ${_===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?s.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]}),s.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Lt=12,Ys=8;function ur({open:e,anchorRef:t,commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l=!1,onSelect:g}){const x=C.useRef(null),[y,_]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){_(null);return}const a=t.current;if(!a)return;let h=0;const d=()=>{const S=t.current;if(!S)return;const E=S.getBoundingClientRect(),j=window.innerWidth,w=window.innerHeight,k=l?260:320,N=l?j-Lt*2:560,L=Math.min(Math.max(E.width,k),Math.max(k,N)),R=Math.min(Math.max(Lt,E.left),Math.max(Lt,j-Lt-L)),M=w-E.bottom-Ys-Lt,D=E.top-Ys-Lt,I=x.current?.offsetHeight??(l?220:280),F=l?240:320,z=M<180&&D>M,P=Math.max(120,Math.min(F,z?D:M)),O=z?Math.max(Lt,E.top-Ys-Math.min(I,P)):Math.min(w-Lt-Math.min(I,P),E.bottom+Ys);_({top:O,left:R,width:L,maxHeight:P})},u=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};u();const b=new ResizeObserver(u);return b.observe(a),x.current&&b.observe(x.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,r.length,l,e,m,o]),!e||!y||typeof document>"u"?null:Ut.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:s.jsx("div",{ref:x,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:s.jsx(V0,{commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l,onSelect:g})})}),document.body)}function Y0({workspaceId:e,gitStatus:t,onResolve:r}){const{t:o}=ae(),m=O0();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const p=t.operation==="rebase"?"Rebase":"Merge";return s.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:[s.jsx(Ci,{size:18,className:"text-amber-600 shrink-0"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-amber-900",children:o("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:t.conflictedFiles.length})})}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:o("中止操作")}),s.jsx(Ie,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Ja(e){return e.length>0?e.map(t=>`- ${t}`).join(`
|
|
74
|
-
`):"- 未获取到冲突文件列表"}function el(e){if(!e)return[];const t=[];return e.workspaceId&&t.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&t.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&t.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&t.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&t.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&t.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&t.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&t.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&t.push("- Merge state: conflict detected and already aborted by Agent Tower"),t}function
|
|
75
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...
|
|
76
|
-
`)}function
|
|
77
|
-
`)}function eg(e){if(e.teamRunId)return{type:"team_room",message:J0(e)};const t=e.currentSessionId||e.selectedSessionId;return t?{type:"session",sessionId:t,message:Z0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function tg({open:e,onOpenChange:t,workspaceId:r,conflictOp:o,conflictedFiles:m,sourceBranch:p,targetBranch:v,operation:i,worktreePath:n,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sessions:_,currentSessionId:a,teamRunId:h}){const{t:d}=ae(),[u,b]=C.useState(""),S=Xi(),E=fi(h??""),j=qi(),w=!!h,k=a||u,N=w?E.isPending:S.isPending,L=()=>{const F=eg({workspaceId:r,worktreePath:n,operation:i,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sourceBranch:p,targetBranch:v,conflictedFiles:m,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:u});if(F.type==="team_room"){E.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ns.success(d("已发送到 Team Room")),t(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>t(!1)})},R=()=>{j.mutate({workspaceId:r},{onSuccess:()=>t(!1)})},M=o==="REBASE"?"Rebase":"Merge",D=!w&&!a&&_.length>0,I=w||!!k;return s.jsx(Ms,{isOpen:e,onClose:()=>t(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ie,{variant:"outline",onClick:R,children:d("在 IDE 中打开")}),s.jsx(Ie,{onClick:L,disabled:!I||N,children:d(N?"发送中...":"AI 辅助解决")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:m.length})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>s.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))})]}),w&&s.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,由团队调度处理。")}),D&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),s.jsxs("select",{value:u,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:[s.jsx("option",{value:"",children:d("选择一个 Session...")}),_.map(F=>s.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!k&&_.length===0&&s.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Jt(e,t){const r=e[t];return typeof r=="string"&&r.length>0?r:void 0}function sg(e){if(!(e instanceof No)||e.status!==409)return;const t=e.details;if(t.code!=="MERGE_CONFLICT"||t.conflictOp!==ws.REBASE&&t.conflictOp!==ws.MERGE||!Array.isArray(t.conflictedFiles)||!t.conflictedFiles.every(o=>typeof o=="string"))return;const r=t.mergeStrategy==="squash"||t.mergeStrategy==="no_ff"?t.mergeStrategy:void 0;return{conflictOp:t.conflictOp,conflictedFiles:t.conflictedFiles,mergeAborted:typeof t.mergeAborted=="boolean"?t.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Jt(t,"sourceBranch"),targetBranch:Jt(t,"targetBranch"),sourceWorktreePath:Jt(t,"sourceWorktreePath"),targetWorktreePath:Jt(t,"targetWorktreePath"),sourceWorkspaceId:Jt(t,"sourceWorkspaceId"),targetWorkspaceId:Jt(t,"targetWorkspaceId")}}function lo(e,t,r,o){const m=sg(e);if(m){r(m);return}o(e instanceof Error?e.message:t)}function $t({children:e,variant:t}){const r={success:"bg-emerald-50 text-emerald-700 border-emerald-200",warning:"bg-amber-50 text-amber-700 border-amber-200",info:"bg-blue-50 text-blue-700 border-blue-200",neutral:"bg-neutral-50 text-neutral-600 border-neutral-200",danger:"bg-red-50 text-red-700 border-red-200"};return s.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r[t]}`,children:e})}function rg({gitStatus:e,branchName:t,targetBranch:r}){const{t:o}=ae();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),s.jsx(Po,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&s.jsxs($t,{variant:"danger",children:[s.jsx(Rc,{size:12}),o("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&s.jsxs($t,{variant:"warning",children:[s.jsx(Ci,{size:12}),o("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&s.jsxs($t,{variant:"warning",children:[s.jsx($e,{size:12,className:"animate-spin"}),o("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&s.jsxs($t,{variant:"warning",children:[s.jsx($e,{size:12,className:"animate-spin"}),o("合并进行中")]}),e.ahead>0&&s.jsxs($t,{variant:"success",children:[s.jsx(vn,{size:12}),o("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&s.jsx($t,{variant:"warning",children:o("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&s.jsxs($t,{variant:"neutral",children:[s.jsx(vn,{size:12}),o("已是最新")]})]}),e.hasUncommittedChanges&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:o("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function ig({open:e,onOpenChange:t,workspaceId:r,branchName:o,targetBranch:m,commitMessage:p,onRefreshCommitMessage:v,onConflict:i}){const{t:n}=ae(),{data:c,isLoading:f}=qa(r),l=P0(),g=D0(),[x,y]=C.useState(null),[_,a]=C.useState("select"),[h,d]=C.useState(""),[u,b]=C.useState(!1),S=c?c.conflictedFiles.length>0:!1,E=c?c.operation!=="idle":!1,j=c?.hasUncommittedChanges??!1;C.useEffect(()=>{e&&(a("select"),y(null),b(!1),v?.())},[e,v]),C.useEffect(()=>{!e||u||d(p??"")},[e,p,u]);const w=M=>{b(!0),d(D=>typeof M=="function"?M(D):M)},k=()=>{y(null),l.mutate(r,{onSuccess:()=>t(!1),onError:M=>{lo(M,n("变基失败"),D=>{t(!1),i(D)},y)}})},N=()=>{y(null),a("confirm")},L=()=>{y(null);const M=h.trim()||void 0;g.mutate({id:r,commitMessage:M},{onSuccess:()=>t(!1),onError:D=>{lo(D,n("合并失败"),I=>{t(!1),i(I)},y)}})},R=n(_==="confirm"?"确认合并":"Git 操作");return s.jsx(Ms,{isOpen:e,onClose:()=>t(!1),title:R,children:f||!c?s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[s.jsx($e,{size:18,className:"animate-spin"}),s.jsx("span",{className:"text-sm",children:n("加载分支状态...")})]}):_==="confirm"?s.jsx(og,{editableMessage:h,setEditableMessage:w,error:x,isPending:g.isPending,onConfirm:L,onBack:()=>a("select"),branchName:o,targetBranch:m}):s.jsx(ng,{gitStatus:c,branchName:o,targetBranch:m,error:x,isDirty:j,hasConflicts:S,isOperationInProgress:E,rebasePending:l.isPending,mergePending:g.isPending,onRebase:k,onMerge:N})})}function ng({gitStatus:e,branchName:t,targetBranch:r,error:o,isDirty:m,hasConflicts:p,isOperationInProgress:v,rebasePending:i,mergePending:n,onRebase:c,onMerge:f}){const{t:l}=ae();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(rg,{gitStatus:e,branchName:t,targetBranch:r}),o&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:o}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:c,disabled:i||p||v||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:s.jsx(Ai,{size:16,className:"text-blue-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(i?"变基中...":"变基 (Rebase)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("将当前分支变基到最新的 {targetBranch}",{targetBranch:r})})]})]}),s.jsxs("button",{onClick:f,disabled:n||p||v||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:s.jsx(Bo,{size:16,className:"text-emerald-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(n?"合并中...":"合并 (Merge)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("合并到 {targetBranch}",{targetBranch:r})})]})]})]})]})}function og({editableMessage:e,setEditableMessage:t,error:r,isPending:o,onConfirm:m,onBack:p,branchName:v,targetBranch:i}){const{t:n}=ae();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:v}),s.jsx(Po,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:i})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:n("提交消息")}),s.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:n("输入提交消息..."),rows:4,className:"w-full px-3 py-2 rounded-md border border-neutral-200 text-sm font-mono text-neutral-800 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-300 resize-none"}),!e.trim()&&s.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:n("留空将使用默认消息")})]}),r&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:r}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:p,disabled:o,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:n("返回")}),s.jsx("button",{onClick:m,disabled:o,className:"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:o?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:14,className:"animate-spin"}),n("合并中...")]}):s.jsxs(s.Fragment,{children:[s.jsx(Bo,{size:14}),n("确认合并")]})})]})]})}function ag({agentType:e,workingDir:t}){return xt({queryKey:de.system.slashCommandCatalog(e,t),queryFn:async()=>(await ge.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function lg(e,t){const r=new Set,o=[];for(const m of[...e,...t]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),o.push(m.kind?m:{...m,kind:"builtin"}))}return o}function Nr(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function cg(e){return Nr(e.command)}function dg(e,t){if(!t)return 1e3;const r=cg(e),o=e.aliases?.map(Nr)??[],m=[r,...o];let p=0;for(const i of m)i===t?p=Math.max(p,500):i.startsWith(t)?p=Math.max(p,400-(i.length-t.length)):i.includes(t)&&(p=Math.max(p,250-i.indexOf(t)));return p>0?p:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function co(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const r=t.index+t[1].length;return{query:Nr(t[2]),replaceStart:r}}function tl(e,t){const r=Nr(t);return r?e.map((o,m)=>({command:o,index:m,score:dg(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 ug=[{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"}],hg=[{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"}],fg=[{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"}],mg=[{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"}],pg={[At.CODEX]:ug,[At.CLAUDE_CODE]:hg,[At.GEMINI_CLI]:fg,[At.CURSOR_AGENT]:mg};function sl(e){return e.trim().toLowerCase().replace(/^\//,"")}function gg(e){return e?(pg[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function vg(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?sl(t[1]):null}function _g(e,t){return tl(e,sl(t))}function xg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function rl({agentType:e,workingDir:t,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=ag({agentType:e,workingDir:t}),f=C.useMemo(()=>lg(gg(e),c),[e,c]),l=C.useMemo(()=>vg(r),[r]),g=C.useMemo(()=>l===null?[]:_g(f,l),[f,l]),x=C.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]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,x,o,m]),_=C.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):xg(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allCommands:f,query:l,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:_}}function bg({agentType:e,workingDir:t}){return xt({queryKey:de.system.skillCatalog(e,t),queryFn:async()=>(await ge.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===At.CODEX,staleTime:3e4})}function yg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function il({agentType:e,workingDir:t,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=bg({agentType:e,workingDir:t}),l=C.useMemo(()=>e===At.CODEX?co(r):null,[e,r])?.query??null,g=C.useMemo(()=>l===null?[]:tl(c,l),[l,c]),x=C.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]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const h=co(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(x(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,x,o,m]),_=C.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):yg(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:_}}const Sg="/api",wg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Sg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Cg=675,uo=320,ho=1200;function kg(){const{t:e}=ae();return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[s.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-300",children:[s.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),s.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),s.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const fo=[{status:ve.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:s.jsx(mi,{className:"w-3 h-3"})},{status:ve.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:s.jsx(pi,{className:"w-3 h-3"})},{status:ve.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:s.jsx(gi,{className:"w-3 h-3"})},{status:ve.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:s.jsx(vi,{className:"w-3 h-3"})},{status:ve.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:s.jsx(_i,{className:"w-3 h-3"})}];function Eg({status:e,onChangeStatus:t}){const{t:r}=ae(),[o,m]=C.useState(!1),p=C.useRef(null);C.useEffect(()=>{if(!o)return;const i=n=>{p.current&&!p.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const v=fo.find(i=>i.status===e);return s.jsxs("div",{className:"relative",ref:p,children:[s.jsxs("button",{onClick:()=>t&&m(i=>!i),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${v.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,s.jsx("span",{children:r(e)}),t&&s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:s.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&s.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:fo.filter(i=>i.status!==e).map(i=>s.jsxs("button",{onClick:()=>{t?.(i.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[s.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),s.jsx("span",{className:"text-neutral-700",children:r(i.status)})]},i.status))})]})}function jg({task:e,onDeleteTask:t,isDeleting:r,onTaskStatusChange:o}){const{t:m}=ae(),[p,v]=C.useState(""),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[x,y]=C.useState(!1),[_,a]=C.useState(!1),[h,d]=C.useState(!1),[u,b]=C.useState(null),[S,E]=C.useState(!1),[j,w]=C.useState(!1),[k,N]=C.useState(null),[L,R]=C.useState(void 0),[M,D]=C.useState(!1),I=C.useRef(null),F=C.useRef(null),z=C.useRef(null),A=C.useRef(null),{scrollRef:P,contentRef:O,isAtBottom:B,scrollToBottom:$}=zi({resize:"smooth",initial:"instant"}),[Y,Q]=C.useState(Cg),[Z,he]=C.useState(!0),[T,H]=C.useState(!1),U=C.useRef(0),W=C.useRef(0),se=C.useRef(null),{data:K,isLoading:ce}=$a(e?.id??""),pe=B0(e?.id),{data:be}=Ao(e?.id??""),{data:De}=To(be?.id??""),ne=fi(be?.id??""),_e=be??null,He=!!_e,we=be===null;C.useEffect(()=>{D(!1),N(null),R(void 0)},[e?.id]);const Le=C.useMemo(()=>da(K,_e,L),[L,_e,K]);C.useEffect(()=>{L&&!K?.some(G=>G.id===L)&&R(void 0)},[L,K]);const ke=C.useMemo(()=>K?.find(G=>G.id===Le),[Le,K]),Ee=ke?.status===Et.ACTIVE?ke.id:void 0,Ue=Gh(ke,_e);C.useEffect(()=>{if(!M||!K)return;K.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&D(!1)},[K,M]);const ye=C.useMemo(()=>{if(M||!K)return null;const G=it=>{const Lr=it.createdAt,ps=it.endedAt??it.startedAt??Lr;if(!ps)return 0;const Qt=Date.parse(ps);return Number.isNaN(Qt)?0:Qt},oe=(it,Lr)=>{const ps=it.filter(Qt=>Lr.includes(Qt.status));return ps.length===0?null:ps.sort((Qt,Il)=>G(Il)-G(Qt))[0]??null},Re=K.filter(it=>it.status==="ACTIVE"&&Array.isArray(it.sessions)).flatMap(it=>it.sessions??[]),gt=oe(Re,[Xe.RUNNING])??oe(Re,[Xe.PENDING])??oe(Re,[Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED]);if(gt)return gt;const at=K.filter(it=>(it.status==="MERGED"||it.status==="ABANDONED"||it.status==="HIBERNATED")&&Array.isArray(it.sessions)).flatMap(it=>it.sessions??[]);return oe(at,[Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED])},[K,M]),Je=ye?.id??"",Ce=He?k??"":Je,Ne=C.useMemo(()=>{if(!k||!K)return null;for(const G of K){const oe=G.sessions?.find(Re=>Re.id===k);if(oe)return oe}return null},[k,K]),tt=C.useMemo(()=>{if(!k||!_e?.invocations)return null;const G=_e.invocations.filter(oe=>oe.sessionId===k);return G.length===0?null:G.sort((oe,Re)=>{const gt=Date.parse(oe.updatedAt??oe.createdAt??""),at=Date.parse(Re.updatedAt??Re.createdAt??"");return(Number.isNaN(at)?0:at)-(Number.isNaN(gt)?0:gt)})[0]??null},[k,_e?.invocations]),X=C.useMemo(()=>!tt?.memberId||!_e?.members?null:_e.members.find(G=>G.id===tt.memberId)??null,[tt?.memberId,_e?.members]),J=k?Ne:ye??null,ee=J?.status===Xe.RUNNING||J?.status===Xe.PENDING,fe=!!e?.projectArchivedAt,qe=!!e?.projectRepoDeletedAt,Ae=m(qe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Ve}=Ds(),[nt,Fe]=C.useState(null);C.useEffect(()=>{Fe(ye?.providerId??null)},[ye?.providerId]);const yt=C.useMemo(()=>!ye||!K?!1:!K.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Re=>Re.id===ye.id)),[ye,K]),Qe=C.useMemo(()=>{if(!(!K||M)){if(ke)return ke.worktreePath||void 0;for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[M,ke,K]),ct=rl({agentType:ye?.agentType,workingDir:Qe,input:p,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),Me=il({agentType:ye?.agentType,workingDir:Qe,input:p,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),{data:Pe}=qa(Ue?Ee??"":""),et=ke?.sessions??[],ft=ke?.branchName??"",ot=ke?.commitMessage,st=C.useMemo(()=>Qh(ke,K,e?.mainBranch??""),[ke,e?.mainBranch,K]),Oe=C.useMemo(()=>Pe?.conflictOp&&Pe.conflictedFiles.length>0?{conflictOp:Pe.conflictOp,conflictedFiles:Pe.conflictedFiles}:u,[Pe?.conflictOp,Pe?.conflictedFiles,u]),_t=Oe?.targetWorkspaceId??Ee,Ye=Oe?.targetWorktreePath??ke?.worktreePath,mt=Oe?.sourceBranch??ft,rt=Oe?.targetBranch??st,V=Ge(),le=C.useCallback(()=>e?.id?V.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,V]);C.useEffect(()=>{if(!j)return;const G=oe=>{F.current&&!F.current.contains(oe.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[j]);const je=Xi(),q=qi(),re=$0(),me=Ua(e?.id??""),ue=Ki(),Be=L0(),Te=C.useMemo(()=>!K||K.some(oe=>oe.status==="ACTIVE")?null:K.find(oe=>oe.status==="HIBERNATED")??null,[K]),pt=C.useRef(null);C.useEffect(()=>{Te&&pt.current!==Te.id&&(Be.isPending||(pt.current=Te.id,Be.mutate(Te.id,{onSettled:()=>{pt.current=null}})))},[Te,Be]);const Dt=C.useCallback(async()=>{if(!e?.id)return;const G=ye?.providerId??Ve?.find(Re=>Re.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const oe=[e.title,e.description].filter(Boolean).join(`
|
|
73
|
+
`)),l("idle"),b(null)}},[e,o,m]);const u=f!=="idle",x=async()=>{if(!(!v||!n.trim())){b(null);try{l("creating-workspace");const k=await _.mutateAsync({});l("creating-session");const E=await ge.post(`/workspaces/${k.id}/sessions`,{providerId:v,prompt:n.trim()});l("starting-session"),await a.mutateAsync(E.id),await y.invalidateQueries({queryKey:de.workspaces.list(r)}),l("idle"),t()}catch(k){l("idle"),b(k instanceof Error?k.message:p("启动失败,请重试"))}}},S={idle:p("启动"),"creating-workspace":p("创建工作空间..."),"creating-session":p("创建会话..."),"starting-session":p("启动 Agent...")};return s.jsx(Rs,{isOpen:e,onClose:u?()=>{}:t,title:p("启动 Agent"),action:s.jsxs(s.Fragment,{children:[s.jsx(Ie,{variant:"outline",onClick:t,disabled:u,children:p("取消")}),s.jsx(Ie,{onClick:x,disabled:u||!v||!n.trim(),children:S[f]})]}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("选择 Provider")}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d&&s.jsx("span",{className:"text-sm text-neutral-400",children:p("加载中...")}),h?.map(({provider:k,availability:E})=>{const w=E.type!=="NOT_FOUND";return s.jsxs(Ie,{variant:v===k.id?"default":"outline",size:"sm",disabled:!w||u,onClick:()=>i(k.id),children:[k.name,!w&&p(" (不可用)")]},k.id)})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:p("任务描述")}),s.jsx("textarea",{value:n,onChange:k=>c(k.target.value),rows:5,disabled:u,placeholder:p("描述你想让 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"})]}),g&&s.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:g})]})})}function Ya(e){const t=e?.tokenUsage;if(!(!t||typeof t.totalTokens!="number"))return t}function W0(e,t,r){const o=e?.providerId??r?.providerId??null,m=o?t?.find(i=>i.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 Ga({session:e,providers:t,usage:r,compact:o=!1,providerIdFallback:m,agentTypeFallback:p,tokenTooltipSide:v="top"}){const{t:i}=ae(),n=W0(e,t,{providerId:m,agentType:p});return!n&&!r?null:s.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&s.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:`${i("Provider")}: ${n.title}`,children:[s.jsx(Ms,{size:o?12:14,className:"shrink-0 text-neutral-400"}),s.jsx("span",{className:"min-w-0 truncate",children:ei(n.label,o?12:18)})]}),s.jsx(zi,{usage:r,tooltipSide:v})]})}function $0(e,t){return e instanceof Error?e.message:t}function U0(e){return Object.values(e).filter(Boolean).length}function oo(e,t,r,o){if(r.filter(v=>v===o).length<=1)return e;const p=r.slice(0,t+1).filter(v=>v===o).length;return`${e} #${p}`}function ao({title:e,error:t,isFetching:r,onRetry:o,disabled:m}){const{t:p}=ae();return s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium",children:e}),s.jsx("div",{className:"mt-1 text-xs text-red-600",children:$0(t,p("请稍后重试。"))})]}),s.jsx(Ie,{type:"button",size:"sm",variant:"outline",onClick:o,disabled:m||r,children:r?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:14,className:"animate-spin"}),p("加载中...")]}):p("重试")})]})})}function Qa({mode:e,setMode:t,selectedTemplateId:r,setSelectedTemplateId:o,selectedMemberPresetIds:m,setSelectedMemberPresetIds:p,disabled:v=!1}){const{t:i}=ae(),{data:n}=Ts(),{data:c,error:f,isError:l,isFetching:g,isLoading:b,refetch:y}=Zl(),{data:_,error:a,isError:h,isFetching:d,isLoading:u,refetch:x}=Jl(),S=C.useMemo(()=>new Map((n??[]).map(({provider:D,availability:I})=>[D.id,D.name+(I.type==="NOT_FOUND"?i(" (不可用)"):"")])),[n,i]),k=C.useMemo(()=>new Map((c??[]).map(D=>[D.id,D])),[c]),E=C.useMemo(()=>new Map((_??[]).map(D=>[D.id,D])),[_]),w=r?E.get(r)??null:null,j=C.useMemo(()=>m.map(D=>k.get(D)).filter(D=>!!D),[k,m]);C.useEffect(()=>{c!==void 0&&p(D=>{const I=D.filter(F=>k.has(F));return I.length===D.length&&I.every((F,z)=>F===D[z])?D:I})},[c,k,p]),C.useEffect(()=>{_!==void 0&&o(D=>!D||E.has(D)?D:null)},[o,E,_]);const T=D=>{v||o(I=>I===D?null:D)},L=D=>{v||p(I=>[...I,D])},N=D=>{v||p(I=>I.filter((F,z)=>z!==D))},R=(D,I)=>{v||p(F=>{const z=D+I;if(z<0||z>=F.length)return F;const A=[...F],[P]=A.splice(D,1);return A.splice(z,0,P),A})};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i("TeamRun 模式")}),s.jsx("div",{className:"text-xs text-neutral-500",children:i("默认使用自动模式,团队消息会直接排队执行。")})]}),s.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[s.jsx("button",{type:"button",onClick:()=>!v&&t("CONFIRM"),disabled:v,className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("确认模式")}),s.jsx("button",{type:"button",onClick:()=>!v&&t("AUTO"),disabled:v,className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("自动模式")})]})]}),s.jsx("div",{className:"pr-1",children:s.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("团队模板")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("模板成员会先加入,随后按顺序追加所选成员。")})]}),h?s.jsx(ao,{title:i("团队模板加载失败"),error:a,isFetching:d,onRetry:()=>{x()},disabled:v}):u?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),i("加载中...")]}):(_??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有团队模板")}),s.jsx(Ie,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Ys,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(_??[]).map(D=>{const I=D.id===r,F=D.members?.length??0,z=D.members?.map(P=>P.memberPresetId)??[],A=D.members?.slice(0,3).map((P,O)=>oo(P.memberPreset?.name??P.memberPresetId,O,z,P.memberPresetId)).join(" · ");return s.jsx("button",{type:"button",onClick:()=>T(D.id),disabled:v,className:te("w-full rounded-lg border px-3 py-2 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60",I?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:D.name}),s.jsx("div",{className:"mt-1 truncate text-xs text-neutral-500",children:i("{count} 个成员",{count:F})}),A&&s.jsx("div",{className:"mt-2 truncate text-[11px] text-neutral-400",children:A})]}),I&&s.jsx(Rt,{size:14,className:"mt-0.5 shrink-0 text-neutral-900"})]})},D.id)})})]}),s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("成员预设")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("选择顺序即保存顺序。")})]}),l?s.jsx(ao,{title:i("成员预设加载失败"),error:f,isFetching:g,onRetry:()=>{y()},disabled:v}):b?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),i("加载中...")]}):(c??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有成员预设")}),s.jsx(Ie,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Ys,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(c??[]).map(D=>{const I=m.filter(A=>A===D.id).length,F=S.get(D.providerId)??D.providerId,z=U0(D.capabilities);return s.jsxs("button",{type:"button",onClick:()=>L(D.id),disabled:v,className:te("flex w-full items-start gap-3 rounded-lg border px-3 py-2 text-left transition-colors",v&&"cursor-not-allowed opacity-60",I>0?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[s.jsx(Mt,{name:D.name,avatar:D.avatar,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:D.name}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs("span",{className:"text-[11px] text-neutral-400",children:[z,"/10"]}),I>0&&s.jsxs("span",{className:"rounded-full bg-neutral-900 px-2 py-0.5 text-[11px] font-medium text-white",children:["x",I]}),s.jsx(os,{size:15,className:"text-neutral-500"})]})]},D.id)})})]})]}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("已选成员")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("上移下移后即为保存顺序。")})]}),j.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:i("尚未选择成员预设")}):s.jsx("div",{className:"space-y-2",children:j.map((D,I)=>{const F=S.get(D.providerId)??D.providerId,z=oo(D.name,I,m,D.id);return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Mt,{name:D.name,avatar:D.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:z}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>R(I,-1),disabled:v||I===0,title:i("上移"),children:s.jsx(yi,{size:14})}),s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>R(I,1),disabled:v||I===j.length-1,title:i("下移"),children:s.jsx(vt,{size:14})}),s.jsx(Ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>N(I),disabled:v,title:i("移除"),children:s.jsx(bi,{size:14})})]})]},`${D.id}-${I}`)})})]}),s.jsxs("section",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-4",children:[s.jsx("div",{className:"text-xs font-medium text-neutral-700",children:i("模板成员会先加入,随后按顺序追加所选成员。")}),s.jsx("div",{className:"mt-2 text-xs text-neutral-500",children:w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium text-neutral-700",children:w.name}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:i("{count} 个成员",{count:w.members?.length??0})})]}):s.jsx("span",{children:i("请选择至少一个团队模板或成员预设。")})})]})]})]})})]})}function q0({isOpen:e,onClose:t,taskId:r}){const{t:o}=ae(),[m,p]=C.useState("AUTO"),[v,i]=C.useState(null),[n,c]=C.useState([]),[f,l]=C.useState(null),g=jo();C.useEffect(()=>{e&&(p("AUTO"),i(null),c([]),l(null))},[e]);const b=g.isPending,y=!!v||n.length>0,_=async()=>{if(!b){if(!v&&n.length===0){l(o("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:m,...v?{teamTemplateId:v}:{},...n.length>0?{memberPresetIds:n}:{}}),t()}catch(h){if(h instanceof No&&h.status===409){l(o("该任务已经存在 TeamRun。请刷新后再试。"));return}l(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=b||!y;return s.jsxs(Rs,{isOpen:e,onClose:b?()=>{}:t,title:o("创建 TeamRun"),className:"max-w-5xl",action:s.jsxs(s.Fragment,{children:[s.jsx(Ie,{type:"button",variant:"outline",onClick:t,disabled:b,children:o("取消")}),s.jsx(Ie,{type:"button",onClick:_,disabled:a,children:o(b?"处理中...":"创建 TeamRun")})]}),children:[s.jsx(Qa,{mode:m,setMode:p,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:c,disabled:b}),f&&s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f})]})}function Za({providers:e,currentProviderId:t,agentType:r,onSelect:o}){const{t:m}=ae(),[p,v]=C.useState(!1),i=C.useRef(null),n=e.filter(f=>String(f.provider.agentType)===r),c=e.find(f=>f.provider.id===t);return C.useEffect(()=>{function f(l){i.current&&!i.current.contains(l.target)&&v(!1)}if(p)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[p]),n.length<=1?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[s.jsx(dn,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?ei(c.provider.name,12):r})]}):s.jsxs("div",{className:"relative",ref:i,children:[s.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:[s.jsx(dn,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?ei(c.provider.name,12):r}),s.jsx(vt,{size:12,className:`shrink-0 transition-transform ${p?"rotate-180":""}`})]}),p&&s.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:[s.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:m("切换渠道")}),n.map(f=>s.jsxs("button",{onClick:()=>{o(f.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 ${f.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&s.jsx("span",{className:"text-xs text-neutral-400",children:m("(默认)")})]}),f.provider.id===t&&s.jsx(Rt,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function K0({commands:e,selectedIndex:t,query:r,hasCatalog:o,title:m="Slash Commands",queryPrefix:p="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:c=!1,onSelect:f}){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",b=c?"max-h-36":"max-h-48";return s.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[s.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[s.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:m}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?s.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?i??`No matches for ${p}${r}`:v}):s.jsx("div",{className:`${l} ${b} overflow-y-auto`,children:e.map((y,_)=>s.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>f(y),className:`w-full rounded-lg border text-left transition-colors ${_===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?s.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]}),s.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Pt=12,Xs=8;function cr({open:e,anchorRef:t,commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l=!1,onSelect:g}){const b=C.useRef(null),[y,_]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){_(null);return}const a=t.current;if(!a)return;let h=0;const d=()=>{const S=t.current;if(!S)return;const k=S.getBoundingClientRect(),E=window.innerWidth,w=window.innerHeight,j=l?260:320,T=l?E-Pt*2:560,L=Math.min(Math.max(k.width,j),Math.max(j,T)),N=Math.min(Math.max(Pt,k.left),Math.max(Pt,E-Pt-L)),R=w-k.bottom-Xs-Pt,D=k.top-Xs-Pt,I=b.current?.offsetHeight??(l?220:280),F=l?240:320,z=R<180&&D>R,P=Math.max(120,Math.min(F,z?D:R)),O=z?Math.max(Pt,k.top-Xs-Math.min(I,P)):Math.min(w-Pt-Math.min(I,P),k.bottom+Xs);_({top:O,left:N,width:L,maxHeight:P})},u=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};u();const x=new ResizeObserver(u);return x.observe(a),b.current&&x.observe(b.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(h),x.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,r.length,l,e,m,o]),!e||!y||typeof document>"u"?null:qt.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:s.jsx("div",{ref:b,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:s.jsx(K0,{commands:r,selectedIndex:o,query:m,hasCatalog:p,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l,onSelect:g})})}),document.body)}function X0({workspaceId:e,gitStatus:t,onResolve:r}){const{t:o}=ae(),m=L0();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const p=t.operation==="rebase"?"Rebase":"Merge";return s.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:[s.jsx(Si,{size:18,className:"text-amber-600 shrink-0"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-amber-900",children:o("{opLabel} 冲突 — {count} 个文件",{opLabel:p,count:t.conflictedFiles.length})})}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Ie,{variant:"outline",size:"sm",onClick:()=>m.mutate(e),disabled:m.isPending,children:o("中止操作")}),s.jsx(Ie,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Ja(e){return e.length>0?e.map(t=>`- ${t}`).join(`
|
|
74
|
+
`):"- 未获取到冲突文件列表"}function el(e){if(!e)return[];const t=[];return e.workspaceId&&t.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&t.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&t.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&t.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&t.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&t.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&t.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&t.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&t.push("- Merge state: conflict detected and already aborted by Agent Tower"),t}function V0(e,t){if(!t?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=t.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=t.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 Y0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const t=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;请在${t}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function G0(e,t,r,o,m){const p=Ja(r),v=el(m);return o===ws.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
75
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...V0(e,m)].join(`
|
|
76
|
+
`)}function Q0(e){const t=e.conflictOp===ws.REBASE?"Rebase":"Merge",r=Ja(e.conflictedFiles),o=[...el(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${t} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${t} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===ws.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Y0(e)].join(`
|
|
77
|
+
`)}function Z0(e){if(e.teamRunId)return{type:"team_room",message:Q0(e)};const t=e.currentSessionId||e.selectedSessionId;return t?{type:"session",sessionId:t,message:G0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function J0({open:e,onOpenChange:t,workspaceId:r,conflictOp:o,conflictedFiles:m,sourceBranch:p,targetBranch:v,operation:i,worktreePath:n,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:y,sessions:_,currentSessionId:a,teamRunId:h}){const{t:d}=ae(),[u,x]=C.useState(""),S=Ki(),k=ui(h??""),E=Ui(),w=!!h,j=a||u,T=w?k.isPending:S.isPending,L=()=>{const F=Z0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:y,sourceBranch:p,targetBranch:v,conflictedFiles:m,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:u});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{is.success(d("已发送到 Team Room")),t(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>t(!1)})},N=()=>{E.mutate({workspaceId:r},{onSuccess:()=>t(!1)})},R=o==="REBASE"?"Rebase":"Merge",D=!w&&!a&&_.length>0,I=w||!!j;return s.jsx(Rs,{isOpen:e,onClose:()=>t(!1),title:d("解决 {opLabel} 冲突",{opLabel:R}),action:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ie,{variant:"outline",onClick:N,children:d("在 IDE 中打开")}),s.jsx(Ie,{onClick:L,disabled:!I||T,children:d(T?"发送中...":"AI 辅助解决")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:m.length})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(F=>s.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))})]}),w&&s.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,由团队调度处理。")}),D&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),s.jsxs("select",{value:u,onChange:F=>x(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:[s.jsx("option",{value:"",children:d("选择一个 Session...")}),_.map(F=>s.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!j&&_.length===0&&s.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Zt(e,t){const r=e[t];return typeof r=="string"&&r.length>0?r:void 0}function eg(e){if(!(e instanceof No)||e.status!==409)return;const t=e.details;if(t.code!=="MERGE_CONFLICT"||t.conflictOp!==ws.REBASE&&t.conflictOp!==ws.MERGE||!Array.isArray(t.conflictedFiles)||!t.conflictedFiles.every(o=>typeof o=="string"))return;const r=t.mergeStrategy==="squash"||t.mergeStrategy==="no_ff"?t.mergeStrategy:void 0;return{conflictOp:t.conflictOp,conflictedFiles:t.conflictedFiles,mergeAborted:typeof t.mergeAborted=="boolean"?t.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Zt(t,"sourceBranch"),targetBranch:Zt(t,"targetBranch"),sourceWorktreePath:Zt(t,"sourceWorktreePath"),targetWorktreePath:Zt(t,"targetWorktreePath"),sourceWorkspaceId:Zt(t,"sourceWorkspaceId"),targetWorkspaceId:Zt(t,"targetWorkspaceId")}}function lo(e,t,r,o){const m=eg(e);if(m){r(m);return}o(e instanceof Error?e.message:t)}function Ut({children:e,variant:t}){const r={success:"bg-emerald-50 text-emerald-700 border-emerald-200",warning:"bg-amber-50 text-amber-700 border-amber-200",info:"bg-blue-50 text-blue-700 border-blue-200",neutral:"bg-neutral-50 text-neutral-600 border-neutral-200",danger:"bg-red-50 text-red-700 border-red-200"};return s.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r[t]}`,children:e})}function tg({gitStatus:e,branchName:t,targetBranch:r}){const{t:o}=ae();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),s.jsx(Po,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&s.jsxs(Ut,{variant:"danger",children:[s.jsx(Ac,{size:12}),o("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&s.jsxs(Ut,{variant:"warning",children:[s.jsx(Si,{size:12}),o("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&s.jsxs(Ut,{variant:"warning",children:[s.jsx($e,{size:12,className:"animate-spin"}),o("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&s.jsxs(Ut,{variant:"warning",children:[s.jsx($e,{size:12,className:"animate-spin"}),o("合并进行中")]}),e.ahead>0&&s.jsxs(Ut,{variant:"success",children:[s.jsx(gn,{size:12}),o("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&s.jsx(Ut,{variant:"warning",children:o("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&s.jsxs(Ut,{variant:"neutral",children:[s.jsx(gn,{size:12}),o("已是最新")]})]}),e.hasUncommittedChanges&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:o("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function sg({open:e,onOpenChange:t,workspaceId:r,branchName:o,targetBranch:m,commitMessage:p,onRefreshCommitMessage:v,onConflict:i}){const{t:n}=ae(),{data:c,isLoading:f}=qa(r),l=D0(),g=T0(),[b,y]=C.useState(null),[_,a]=C.useState("select"),[h,d]=C.useState(""),[u,x]=C.useState(!1),S=c?c.conflictedFiles.length>0:!1,k=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;C.useEffect(()=>{e&&(a("select"),y(null),x(!1),v?.())},[e,v]),C.useEffect(()=>{!e||u||d(p??"")},[e,p,u]);const w=R=>{x(!0),d(D=>typeof R=="function"?R(D):R)},j=()=>{y(null),l.mutate(r,{onSuccess:()=>t(!1),onError:R=>{lo(R,n("变基失败"),D=>{t(!1),i(D)},y)}})},T=()=>{y(null),a("confirm")},L=()=>{y(null);const R=h.trim()||void 0;g.mutate({id:r,commitMessage:R},{onSuccess:()=>t(!1),onError:D=>{lo(D,n("合并失败"),I=>{t(!1),i(I)},y)}})},N=n(_==="confirm"?"确认合并":"Git 操作");return s.jsx(Rs,{isOpen:e,onClose:()=>t(!1),title:N,children:f||!c?s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[s.jsx($e,{size:18,className:"animate-spin"}),s.jsx("span",{className:"text-sm",children:n("加载分支状态...")})]}):_==="confirm"?s.jsx(ig,{editableMessage:h,setEditableMessage:w,error:b,isPending:g.isPending,onConfirm:L,onBack:()=>a("select"),branchName:o,targetBranch:m}):s.jsx(rg,{gitStatus:c,branchName:o,targetBranch:m,error:b,isDirty:E,hasConflicts:S,isOperationInProgress:k,rebasePending:l.isPending,mergePending:g.isPending,onRebase:j,onMerge:T})})}function rg({gitStatus:e,branchName:t,targetBranch:r,error:o,isDirty:m,hasConflicts:p,isOperationInProgress:v,rebasePending:i,mergePending:n,onRebase:c,onMerge:f}){const{t:l}=ae();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(tg,{gitStatus:e,branchName:t,targetBranch:r}),o&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:o}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:c,disabled:i||p||v||m,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:s.jsx(ji,{size:16,className:"text-blue-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(i?"变基中...":"变基 (Rebase)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("将当前分支变基到最新的 {targetBranch}",{targetBranch:r})})]})]}),s.jsxs("button",{onClick:f,disabled:n||p||v||m||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:s.jsx(Bo,{size:16,className:"text-emerald-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(n?"合并中...":"合并 (Merge)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("合并到 {targetBranch}",{targetBranch:r})})]})]})]})]})}function ig({editableMessage:e,setEditableMessage:t,error:r,isPending:o,onConfirm:m,onBack:p,branchName:v,targetBranch:i}){const{t:n}=ae();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:v}),s.jsx(Po,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:i})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:n("提交消息")}),s.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:n("输入提交消息..."),rows:4,className:"w-full px-3 py-2 rounded-md border border-neutral-200 text-sm font-mono text-neutral-800 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-300 resize-none"}),!e.trim()&&s.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:n("留空将使用默认消息")})]}),r&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:r}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:p,disabled:o,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:n("返回")}),s.jsx("button",{onClick:m,disabled:o,className:"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:o?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:14,className:"animate-spin"}),n("合并中...")]}):s.jsxs(s.Fragment,{children:[s.jsx(Bo,{size:14}),n("确认合并")]})})]})]})}function ng({agentType:e,workingDir:t}){return bt({queryKey:de.system.slashCommandCatalog(e,t),queryFn:async()=>(await ge.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function og(e,t){const r=new Set,o=[];for(const m of[...e,...t]){const p=m.command.trim().toLowerCase();!p||r.has(p)||(r.add(p),o.push(m.kind?m:{...m,kind:"builtin"}))}return o}function Er(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function ag(e){return Er(e.command)}function lg(e,t){if(!t)return 1e3;const r=ag(e),o=e.aliases?.map(Er)??[],m=[r,...o];let p=0;for(const i of m)i===t?p=Math.max(p,500):i.startsWith(t)?p=Math.max(p,400-(i.length-t.length)):i.includes(t)&&(p=Math.max(p,250-i.indexOf(t)));return p>0?p:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function co(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const r=t.index+t[1].length;return{query:Er(t[2]),replaceStart:r}}function tl(e,t){const r=Er(t);return r?e.map((o,m)=>({command:o,index:m,score:lg(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 cg=[{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"}],dg=[{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"}],ug=[{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"}],hg=[{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"}],fg={[At.CODEX]:cg,[At.CLAUDE_CODE]:dg,[At.GEMINI_CLI]:ug,[At.CURSOR_AGENT]:hg};function sl(e){return e.trim().toLowerCase().replace(/^\//,"")}function mg(e){return e?(fg[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function pg(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?sl(t[1]):null}function gg(e,t){return tl(e,sl(t))}function vg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function rl({agentType:e,workingDir:t,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=ng({agentType:e,workingDir:t}),f=C.useMemo(()=>og(mg(e),c),[e,c]),l=C.useMemo(()=>pg(r),[r]),g=C.useMemo(()=>l===null?[]:gg(f,l),[f,l]),b=C.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]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,o,m]),_=C.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):vg(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allCommands:f,query:l,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:_}}function _g({agentType:e,workingDir:t}){return bt({queryKey:de.system.skillCatalog(e,t),queryFn:async()=>(await ge.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===At.CODEX,staleTime:3e4})}function xg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function il({agentType:e,workingDir:t,input:r,setInput:o,textareaRef:m,minHeight:p,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=_g({agentType:e,workingDir:t}),l=C.useMemo(()=>e===At.CODEX?co(r):null,[e,r])?.query??null,g=C.useMemo(()=>l===null?[]:tl(c,l),[l,c]),b=C.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]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const h=co(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const u=m.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,o,m]),_=C.useCallback(a=>l===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):xg(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:_}}const bg="/api",yg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${bg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Sg=675,uo=320,ho=1200;function wg(){const{t:e}=ae();return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[s.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-300",children:[s.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),s.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),s.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const fo=[{status:ve.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:s.jsx(hi,{className:"w-3 h-3"})},{status:ve.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:s.jsx(fi,{className:"w-3 h-3"})},{status:ve.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:s.jsx(mi,{className:"w-3 h-3"})},{status:ve.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:s.jsx(pi,{className:"w-3 h-3"})},{status:ve.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:s.jsx(gi,{className:"w-3 h-3"})}];function Cg({status:e,onChangeStatus:t}){const{t:r}=ae(),[o,m]=C.useState(!1),p=C.useRef(null);C.useEffect(()=>{if(!o)return;const i=n=>{p.current&&!p.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const v=fo.find(i=>i.status===e);return s.jsxs("div",{className:"relative",ref:p,children:[s.jsxs("button",{onClick:()=>t&&m(i=>!i),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${v.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,s.jsx("span",{children:r(e)}),t&&s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:s.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&s.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:fo.filter(i=>i.status!==e).map(i=>s.jsxs("button",{onClick:()=>{t?.(i.status),m(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[s.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),s.jsx("span",{className:"text-neutral-700",children:r(i.status)})]},i.status))})]})}function kg({task:e,onDeleteTask:t,isDeleting:r,onTaskStatusChange:o}){const{t:m}=ae(),[p,v]=C.useState(""),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[b,y]=C.useState(!1),[_,a]=C.useState(!1),[h,d]=C.useState(!1),[u,x]=C.useState(null),[S,k]=C.useState(!1),[E,w]=C.useState(!1),[j,T]=C.useState(null),[L,N]=C.useState(void 0),[R,D]=C.useState(!1),I=C.useRef(null),F=C.useRef(null),z=C.useRef(null),A=C.useRef(null),{scrollRef:P,contentRef:O,isAtBottom:B,scrollToBottom:W}=Fi({resize:"smooth",initial:"instant"}),[V,Q]=C.useState(Sg),[Z,he]=C.useState(!0),[M,H]=C.useState(!1),U=C.useRef(0),$=C.useRef(0),se=C.useRef(null),{data:K,isLoading:ce}=$a(e?.id??""),pe=O0(e?.id),{data:xe}=Ao(e?.id??""),{data:De}=Ro(xe?.id??""),ne=ui(xe?.id??""),_e=xe??null,He=!!_e,we=xe===null;C.useEffect(()=>{D(!1),T(null),N(void 0)},[e?.id]);const Le=C.useMemo(()=>da(K,_e,L),[L,_e,K]);C.useEffect(()=>{L&&!K?.some(G=>G.id===L)&&N(void 0)},[L,K]);const ke=C.useMemo(()=>K?.find(G=>G.id===Le),[Le,K]),Ee=ke?.status===Et.ACTIVE?ke.id:void 0,Ue=Vh(ke,_e);C.useEffect(()=>{if(!R||!K)return;K.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&D(!1)},[K,R]);const be=C.useMemo(()=>{if(R||!K)return null;const G=it=>{const Mr=it.createdAt,ms=it.endedAt??it.startedAt??Mr;if(!ms)return 0;const Qt=Date.parse(ms);return Number.isNaN(Qt)?0:Qt},oe=(it,Mr)=>{const ms=it.filter(Qt=>Mr.includes(Qt.status));return ms.length===0?null:ms.sort((Qt,Il)=>G(Il)-G(Qt))[0]??null},Te=K.filter(it=>it.status==="ACTIVE"&&Array.isArray(it.sessions)).flatMap(it=>it.sessions??[]),gt=oe(Te,[Xe.RUNNING])??oe(Te,[Xe.PENDING])??oe(Te,[Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED]);if(gt)return gt;const at=K.filter(it=>(it.status==="MERGED"||it.status==="ABANDONED"||it.status==="HIBERNATED")&&Array.isArray(it.sessions)).flatMap(it=>it.sessions??[]);return oe(at,[Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED])},[K,R]),Je=be?.id??"",Ce=He?j??"":Je,Ne=C.useMemo(()=>{if(!j||!K)return null;for(const G of K){const oe=G.sessions?.find(Te=>Te.id===j);if(oe)return oe}return null},[j,K]),tt=C.useMemo(()=>{if(!j||!_e?.invocations)return null;const G=_e.invocations.filter(oe=>oe.sessionId===j);return G.length===0?null:G.sort((oe,Te)=>{const gt=Date.parse(oe.updatedAt??oe.createdAt??""),at=Date.parse(Te.updatedAt??Te.createdAt??"");return(Number.isNaN(at)?0:at)-(Number.isNaN(gt)?0:gt)})[0]??null},[j,_e?.invocations]),X=C.useMemo(()=>!tt?.memberId||!_e?.members?null:_e.members.find(G=>G.id===tt.memberId)??null,[tt?.memberId,_e?.members]),J=j?Ne:be??null,ee=J?.status===Xe.RUNNING||J?.status===Xe.PENDING,fe=!!e?.projectArchivedAt,qe=!!e?.projectRepoDeletedAt,Ae=m(qe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Ve}=Ts(),[nt,Fe]=C.useState(null);C.useEffect(()=>{Fe(be?.providerId??null)},[be?.providerId]);const yt=C.useMemo(()=>!be||!K?!1:!K.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Te=>Te.id===be.id)),[be,K]),Qe=C.useMemo(()=>{if(!(!K||R)){if(ke)return ke.worktreePath||void 0;for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[R,ke,K]),ct=rl({agentType:be?.agentType,workingDir:Qe,input:p,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),Me=il({agentType:be?.agentType,workingDir:Qe,input:p,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),{data:Pe}=qa(Ue?Ee??"":""),et=ke?.sessions??[],ft=ke?.branchName??"",ot=ke?.commitMessage,st=C.useMemo(()=>Yh(ke,K,e?.mainBranch??""),[ke,e?.mainBranch,K]),Oe=C.useMemo(()=>Pe?.conflictOp&&Pe.conflictedFiles.length>0?{conflictOp:Pe.conflictOp,conflictedFiles:Pe.conflictedFiles}:u,[Pe?.conflictOp,Pe?.conflictedFiles,u]),xt=Oe?.targetWorkspaceId??Ee,Ye=Oe?.targetWorktreePath??ke?.worktreePath,mt=Oe?.sourceBranch??ft,rt=Oe?.targetBranch??st,Y=Ge(),le=C.useCallback(()=>e?.id?Y.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Y]);C.useEffect(()=>{if(!E)return;const G=oe=>{F.current&&!F.current.contains(oe.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[E]);const je=Ki(),q=Ui(),re=H0(),me=Ua(e?.id??""),ue=qi(),Be=M0(),Re=C.useMemo(()=>!K||K.some(oe=>oe.status==="ACTIVE")?null:K.find(oe=>oe.status==="HIBERNATED")??null,[K]),pt=C.useRef(null);C.useEffect(()=>{Re&&pt.current!==Re.id&&(Be.isPending||(pt.current=Re.id,Be.mutate(Re.id,{onSettled:()=>{pt.current=null}})))},[Re,Be]);const Lt=C.useCallback(async()=>{if(!e?.id)return;const G=be?.providerId??Ve?.find(Te=>Te.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const oe=[e.title,e.description].filter(Boolean).join(`
|
|
78
78
|
|
|
79
|
-
`);y(!1),a(!0);try{await re.mutateAsync(e.id),D(!0);const
|
|
79
|
+
`);y(!1),a(!0);try{await re.mutateAsync(e.id),D(!0);const Te=await me.mutateAsync({}),gt=await ge.post(`/workspaces/${Te.id}/sessions`,{providerId:G,prompt:oe});await ue.mutateAsync(gt.id),await Y.invalidateQueries({queryKey:de.workspaces.list(e.id)})}catch(Te){console.error("[retry] failed:",Te),D(!1)}finally{a(!1)}},[e?.id,e?.title,e?.description,be?.providerId,Ve,re,me,ue,Y]),bl=C.useCallback(()=>{ke?.id&&q.mutate({workspaceId:ke.id})},[q,ke?.id]),yl=C.useCallback(()=>{!e?.id||!t||(t(e.id),g(!1))},[e?.id,t]),Vi=C.useCallback(G=>{T(G),requestAnimationFrame(()=>{W()})},[W]),Sl=C.useCallback(()=>{T(null)},[]),Yi=C.useCallback(G=>{x(G??null),d(!0)},[]),wl=C.useCallback(G=>ne.mutateAsync(G),[ne]),Yt=C.useCallback(()=>{Y.invalidateQueries({queryKey:ec.all})},[Y]),{isConnected:Gi,isLoadingSnapshot:Qi,logs:hs,entries:Cl,attach:zs}=To({sessionId:Ce,sessionStatus:J?.status,onExit:C.useCallback(()=>{Y.invalidateQueries({queryKey:["workspaces"]})},[Y])});C.useEffect(()=>{if(!e?.id)return;const G=It.connect();G.emit(Jt.SUBSCRIBE,{topic:"task",id:e.id});const oe=at=>{at.taskId===e.id&&(Y.invalidateQueries({queryKey:["tasks"]}),Yt())},Te=at=>{at.taskId===e.id&&(Y.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Yt())},gt=at=>{at.taskId===e.id&&(Y.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Yt())};return G.on(dt.TASK_UPDATED,oe),G.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Te),G.on(dt.WORKSPACE_HIBERNATED,gt),()=>{G.off(dt.TASK_UPDATED,oe),G.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Te),G.off(dt.WORKSPACE_HIBERNATED,gt),G.emit(Jt.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Y,Yt]),C.useEffect(()=>{if(!Ce)return;const G=It.connect(),oe=Te=>{Te.sessionId===Ce&&(Y.invalidateQueries({queryKey:["workspaces"]}),Yt())};return G.on(dt.SESSION_COMPLETED,oe),()=>{G.off(dt.SESSION_COMPLETED,oe)}},[Ce,Y,Yt]);const{todos:Zi}=Mo(Cl),{files:kl,addFiles:Gt,removeFile:El,clear:Ji,buildMarkdownLinks:en,hasFiles:fs,isUploading:Hs}=xr(),jl=C.useMemo(()=>Ya(J),[J?.tokenUsage]),tn=Xa(hs,jl);C.useEffect(()=>{Ce&&Gi&&zs()},[Ce,Gi,zs]);const sn=C.useRef(e?.id);C.useEffect(()=>{if(sn.current!==e?.id&&P.current){const G=P.current;requestAnimationFrame(()=>{G.scrollTop=G.scrollHeight})}sn.current=e?.id},[e?.id,P]);const jr=Ka(),Nr=C.useRef(!1),rn=C.useCallback(async()=>{if(!p.trim()&&!fs||!Ce||Nr.current||Hs)return;Nr.current=!0;const G=en(),oe=[p.trim(),G].filter(Boolean).join(`
|
|
80
80
|
|
|
81
|
-
`);v(""),en(),z.current&&(z.current.style.height="60px"),je.mutate({id:Ce,message:oe,providerId:nt??void 0},{onSuccess:()=>{Ws()},onSettled:()=>{Tr.current=!1}})},[p,Ce,je,Ws,ms,$s,tn,en,nt]),Nl=C.useCallback(async()=>{Ce&&(await Ar.mutateAsync(Ce),V.invalidateQueries({queryKey:["workspaces"]}))},[Ce,Ar,V]),Al=C.useCallback(G=>{const oe=G.target.files;oe&&oe.length>0&&Gt(Array.from(oe)),G.target.value=""},[Gt]),Tl=C.useCallback(G=>{const oe=G.clipboardData.items,Re=[];for(const gt of oe)if(gt.kind==="file"){const at=gt.getAsFile();at&&Re.push(at)}Re.length>0&&(G.preventDefault(),Gt(Re))},[Gt]),[on,Rr]=C.useState(!1),Rl=C.useCallback(G=>{G.preventDefault(),Rr(!0)},[]),Ml=C.useCallback(G=>{G.preventDefault(),Rr(!1)},[]),Dl=C.useCallback(G=>{G.preventDefault(),Rr(!1);const oe=G.dataTransfer.files;oe.length>0&&Gt(Array.from(oe))},[Gt]),Mr=C.useCallback(G=>{const oe=G.clientX-U.current,Re=Math.max(uo,Math.min(W.current+oe,ho));se.current&&(se.current.style.width=`${Re}px`)},[]),Dr=C.useCallback(()=>{if(H(!1),se.current){const G=se.current.getBoundingClientRect().width;Q(Math.max(uo,Math.min(Math.round(G),ho)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(T)return document.addEventListener("mousemove",Mr),document.addEventListener("mouseup",Dr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Mr),document.removeEventListener("mouseup",Dr),document.body.style.cursor="",document.body.style.userSelect=""}},[T,Mr,Dr]);const Ll=C.useCallback(G=>{G.preventDefault(),U.current=G.clientX,W.current=Y,H(!0)},[Y]),Pl=C.useCallback(()=>{he(G=>!G)},[]),Ol=C.useCallback(G=>{v(G.target.value);const oe=G.target;oe.style.height="auto";const Re=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Re,300))}px`},[]),an=C.useMemo(()=>{const G=[];if(K&&K.length>0){const oe=K.some(at=>at.status==="ACTIVE"),Re=K.some(at=>at.sessions?.some(it=>it.status===Xe.RUNNING||it.status===Xe.PENDING)),gt=K.some(at=>at.status==="ACTIVE");Re&&G.push(m("正在运行的 Agent 将被停止")),gt&&G.push(m("分支上未合并的变更将丢失")),oe&&G.push(m("关联的工作目录(worktree)将被清理"))}return G},[K,m]);return e?s.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[s.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-neutral-100 bg-white/80 backdrop-blur-sm z-20 flex-shrink-0",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[s.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),s.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),s.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),s.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Eg,{status:e.status,onChangeStatus:!fe&&o?G=>o(e.id,G):void 0}),s.jsx(Wa,{workspaces:K,teamRun:_e,selectedWorkspaceId:Le,onSelectWorkspace:R}),ke&&!fe&&s.jsx("button",{onClick:()=>E(!0),disabled:!Ue,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Git 操作"),children:s.jsx(Bc,{size:18})}),s.jsx("button",{onClick:bl,disabled:!ke?.worktreePath||fe,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:s.jsx(Ls,{size:18})}),s.jsx("button",{onClick:Pl,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:Z?s.jsx(ed,{size:18}):s.jsx(Ri,{size:18})}),we&&!fe&&s.jsxs("button",{onClick:()=>f(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:m("创建 TeamRun"),children:[s.jsx(as,{size:14}),s.jsx("span",{children:m("创建 TeamRun")})]}),t&&!fe&&s.jsxs("div",{className:"relative",ref:F,children:[s.jsx("button",{onClick:()=>w(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:s.jsx(Io,{size:18})}),j&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[s.jsxs("button",{onClick:()=>{y(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[s.jsx(nc,{size:15}),s.jsx("span",{children:m("重新开始")})]}),s.jsxs("button",{onClick:()=>{g(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[s.jsx(Si,{size:15}),s.jsx("span",{children:m("删除任务")})]})]})]})]})]}),Ue&&Ee&&Pe&&s.jsx(Y0,{workspaceId:Ee,gitStatus:Pe,onResolve:()=>Gi()}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsx("div",{ref:se,className:`flex flex-col bg-white relative ${Z?"flex-shrink-0":"flex-1"}`,style:{width:Z?Y:"100%"},children:He&&_e?k?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:k})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Ga,{session:J,providers:Ve,usage:sn,providerIdFallback:X?.providerId,agentTypeFallback:J?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ie,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-2 text-xs font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900",onClick:Sl,children:[s.jsx(ti,{size:13}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsx("div",{ref:O,className:"w-full",children:Zi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):fs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(ee?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Zs,{logs:fs})})}),!B&&s.jsxs("button",{onClick:()=>$(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:m("回到底部")})]})]})]}):s.jsx(la,{teamRun:_e,messages:De??_e.messages??[],readOnly:fe,readOnlyMessage:Ae,onSendMessage:wl,onViewInvocationSession:Yi}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsxs("div",{ref:O,className:"w-full",children:[s.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(xi,{urlTransform:wg,components:bi,children:e.description})}):s.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),pe&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[pe.status==="running"&&s.jsxs(s.Fragment,{children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:pe.currentIndex,total:pe.totalCommands,command:pe.currentCommand})})]}),pe.status==="completed"&&s.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),pe.status==="failed"&&s.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:pe.error})})]}),ce?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading...")})]}):Je?Zi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):fs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(ee?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Zs,{logs:fs}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:s.jsx(qt,{size:24,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(fe?"项目为只读历史":"尚未启动 Agent")}),s.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:fe?Ae:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!fe&&s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[s.jsxs(Ie,{onClick:()=>n(!0),children:[s.jsx(qt,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),we&&s.jsxs(Ie,{variant:"outline",onClick:()=>f(!0),children:[s.jsx(as,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!B&&s.jsxs("button",{onClick:()=>$(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:m("回到底部")})]})]}),Ji.length>0&&s.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:s.jsx(Do,{todos:Ji})}),fe?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:Ae})}):yt?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[s.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ie,{size:"sm",onClick:()=>n(!0),children:[s.jsx(qt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):s.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Rl,onDragLeave:Ml,onDrop:Dl,children:[s.jsxs("div",{ref:I,className:`relative bg-white rounded-xl border shadow-sm hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300 transition-all duration-200 ${on?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[s.jsx(wr,{files:kl,onRemove:El}),s.jsx("textarea",{ref:z,value:p,onChange:Ol,onPaste:Tl,onKeyDown:G=>{Me.handleKeyDown(G)||ct.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),nn())},rows:1,placeholder:m(on?"Drop files here...":Je&&!ee?"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-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),s.jsx("input",{ref:A,type:"file",multiple:!0,className:"hidden",onChange:Al}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[s.jsx("div",{className:"flex items-center gap-1",children:s.jsx("button",{onClick:()=>A.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:s.jsx(pr,{size:18})})}),s.jsxs("div",{className:"flex items-center gap-2",children:[ye&&Ve&&s.jsx(Za,{providers:Ve,currentProviderId:nt,agentType:ye.agentType,onSelect:Fe}),s.jsx(Hi,{usage:sn}),ee&&!p.trim()&&!ms?s.jsx("button",{onClick:Nl,disabled:Ar.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-red-500 text-white hover:bg-red-600 shadow-md disabled:opacity-50",children:s.jsx(os,{size:14})}):s.jsx("button",{onClick:nn,disabled:!p.trim()&&!ms||$s,className:`p-2 rounded-lg transition-all duration-200 ${(p.trim()||ms)&&!$s?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:s.jsx(ki,{size:18})})]})]})]}),s.jsx(ur,{open:ct.query!==null,anchorRef:I,commands:ct.filteredCommands,selectedIndex:ct.selectedIndex,query:ct.query??"",hasCatalog:ct.allCommands.length>0,onSelect:ct.applyCommand}),s.jsx(ur,{open:Me.query!==null,anchorRef:I,commands:Me.filteredSkills,selectedIndex:Me.selectedIndex,query:Me.query??"",hasCatalog:Me.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Me.applySkill})]})]})}),Z&&s.jsx("div",{className:"w-1 cursor-col-resize hover:bg-neutral-200 active:bg-blue-400 transition-colors z-30 flex-shrink-0 border-l border-neutral-200",onMouseDown:Ll}),Z&&s.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:s.jsx(Ha,{sessionId:Je||void 0,workspaceId:Le,workingDir:Qe,projectId:e.projectId,readOnly:fe,repoDeleted:qe,teamRun:_e,teamStatus:_e?s.jsx(ua,{teamRun:_e,workspaces:K,selectedWorkspaceId:Le,onSelectWorkspace:R,onViewInvocationSession:Yi}):void 0})})]}),!fe&&s.jsx(Va,{isOpen:i,onClose:()=>n(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),we&&!fe&&s.jsx(X0,{isOpen:c,onClose:()=>f(!1),taskId:e.id}),Ue&&Ee&&!fe&&s.jsx(ig,{open:S,onOpenChange:E,workspaceId:Ee,branchName:ft,targetBranch:st,commitMessage:ot,onRefreshCommitMessage:le,onConflict:Gi}),Ue&&_t&&Oe&&s.jsx(tg,{open:h,onOpenChange:G=>{d(G),G||b(null)},workspaceId:_t,conflictOp:Oe.conflictOp,conflictedFiles:Oe.conflictedFiles,sourceBranch:mt,targetBranch:rt,operation:Pe?.operation,worktreePath:Ye,mergeAborted:Oe.mergeAborted,mergeStrategy:Oe.mergeStrategy,sourceWorkspaceId:Oe.sourceWorkspaceId,targetWorkspaceId:Oe.targetWorkspaceId,sourceWorktreePath:Oe.sourceWorktreePath,targetWorktreePath:Oe.targetWorktreePath,sessions:et,currentSessionId:He?void 0:Je,teamRunId:_e?.id}),s.jsx(Js,{isOpen:x,onClose:()=>y(!1),onConfirm:Dt,title:m("重新开始任务"),description:s.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:_}),s.jsx(Js,{isOpen:l,onClose:()=>g(!1),onConfirm:yl,title:m("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),an.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:an.map((G,oe)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:G})]},oe))})]}),confirmText:m("删除"),variant:"danger",isLoading:r})]}):s.jsx(kg,{})}function Vi(e){switch(e){case Nt.TODO:return ve.Pending;case Nt.IN_PROGRESS:return ve.Running;case Nt.IN_REVIEW:return ve.Review;case Nt.DONE:return ve.Done;case Nt.CANCELLED:return ve.Cancelled}}function Ng(e){switch(e){case ve.Pending:return Nt.TODO;case ve.Running:return Nt.IN_PROGRESS;case ve.Review:return Nt.IN_REVIEW;case ve.Done:return Nt.DONE;case ve.Cancelled:return Nt.CANCELLED}}function Ag(e){switch(e){case At.CLAUDE_CODE:return"Claude Code";case At.GEMINI_CLI:return"Gemini CLI";case At.CURSOR_AGENT:return"Cursor Agent";case At.CODEX:return"Codex"}}const hr=["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 nl(e,t){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%t}function ol(e,t){return t??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Tg(e){return{id:e.id,name:e.name,color:e.color||hr[nl(e.name,hr.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Rg(e){const t=ol(e);if(!t)return{agent:"—",branch:"—"};const r=t.branchName,o=t.sessions;if(o&&o.length>0){const m=o[o.length-1];return{agent:Ag(m.agentType),branch:r}}return{agent:"—",branch:r}}function Mg(e){const{agent:t,branch:r}=Rg(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Vi(e.status),agent:t,branch:r,description:e.description??"",projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function Dg(e,t,r){const o=ol(e.workspaces,r),m=o?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||hr[nl(t.name,hr.length)],title:e.title,status:Vi(e.status),branch:m,mainBranch:o?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const mo={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 Lg(e){const t=e.split("/");return t[t.length-1]||e}function Pg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Og({workingDir:e,filePath:t,type:r}){const{t:o}=ae(),{data:m,isLoading:p,isError:v}=Ba(e,t,r);if(p)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
82
|
-
`);return s.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:n.map((c,f)=>{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"),s.jsx("div",{className:te("px-3 whitespace-pre",l,g),children:c},f)})})}function
|
|
83
|
-
`);return s.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:n.map((c,f)=>{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"),s.jsx("div",{className:te("px-3 whitespace-pre",l,g),children:c},f)})})}function
|
|
81
|
+
`);v(""),Ji(),z.current&&(z.current.style.height="60px"),je.mutate({id:Ce,message:oe,providerId:nt??void 0},{onSuccess:()=>{zs()},onSettled:()=>{Nr.current=!1}})},[p,Ce,je,zs,fs,Hs,en,Ji,nt]),Nl=C.useCallback(async()=>{Ce&&(await jr.mutateAsync(Ce),Y.invalidateQueries({queryKey:["workspaces"]}))},[Ce,jr,Y]),Al=C.useCallback(G=>{const oe=G.target.files;oe&&oe.length>0&&Gt(Array.from(oe)),G.target.value=""},[Gt]),Rl=C.useCallback(G=>{const oe=G.clipboardData.items,Te=[];for(const gt of oe)if(gt.kind==="file"){const at=gt.getAsFile();at&&Te.push(at)}Te.length>0&&(G.preventDefault(),Gt(Te))},[Gt]),[nn,Ar]=C.useState(!1),Tl=C.useCallback(G=>{G.preventDefault(),Ar(!0)},[]),Ml=C.useCallback(G=>{G.preventDefault(),Ar(!1)},[]),Dl=C.useCallback(G=>{G.preventDefault(),Ar(!1);const oe=G.dataTransfer.files;oe.length>0&&Gt(Array.from(oe))},[Gt]),Rr=C.useCallback(G=>{const oe=G.clientX-U.current,Te=Math.max(uo,Math.min($.current+oe,ho));se.current&&(se.current.style.width=`${Te}px`)},[]),Tr=C.useCallback(()=>{if(H(!1),se.current){const G=se.current.getBoundingClientRect().width;Q(Math.max(uo,Math.min(Math.round(G),ho)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(M)return document.addEventListener("mousemove",Rr),document.addEventListener("mouseup",Tr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Rr),document.removeEventListener("mouseup",Tr),document.body.style.cursor="",document.body.style.userSelect=""}},[M,Rr,Tr]);const Ll=C.useCallback(G=>{G.preventDefault(),U.current=G.clientX,$.current=V,H(!0)},[V]),Pl=C.useCallback(()=>{he(G=>!G)},[]),Ol=C.useCallback(G=>{v(G.target.value);const oe=G.target;oe.style.height="auto";const Te=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Te,300))}px`},[]),on=C.useMemo(()=>{const G=[];if(K&&K.length>0){const oe=K.some(at=>at.status==="ACTIVE"),Te=K.some(at=>at.sessions?.some(it=>it.status===Xe.RUNNING||it.status===Xe.PENDING)),gt=K.some(at=>at.status==="ACTIVE");Te&&G.push(m("正在运行的 Agent 将被停止")),gt&&G.push(m("分支上未合并的变更将丢失")),oe&&G.push(m("关联的工作目录(worktree)将被清理"))}return G},[K,m]);return e?s.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[s.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-neutral-100 bg-white/80 backdrop-blur-sm z-20 flex-shrink-0",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[s.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?m("源码已删除"):m("已删除")}),s.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),s.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),s.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Cg,{status:e.status,onChangeStatus:!fe&&o?G=>o(e.id,G):void 0}),s.jsx(Wa,{workspaces:K,teamRun:_e,selectedWorkspaceId:Le,onSelectWorkspace:N}),ke&&!fe&&s.jsx("button",{onClick:()=>k(!0),disabled:!Ue,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Git 操作"),children:s.jsx(Oc,{size:18})}),s.jsx("button",{onClick:bl,disabled:!ke?.worktreePath||fe,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:m("Open in IDE"),children:s.jsx(Ms,{size:18})}),s.jsx("button",{onClick:Pl,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("Toggle Workspace"),children:Z?s.jsx(Zc,{size:18}):s.jsx(Zs,{size:18})}),we&&!fe&&s.jsxs("button",{onClick:()=>f(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:m("创建 TeamRun"),children:[s.jsx(os,{size:14}),s.jsx("span",{children:m("创建 TeamRun")})]}),t&&!fe&&s.jsxs("div",{className:"relative",ref:F,children:[s.jsx("button",{onClick:()=>w(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:m("More actions"),children:s.jsx(Io,{size:18})}),E&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[s.jsxs("button",{onClick:()=>{y(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[s.jsx(nc,{size:15}),s.jsx("span",{children:m("重新开始")})]}),s.jsxs("button",{onClick:()=>{g(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[s.jsx(bi,{size:15}),s.jsx("span",{children:m("删除任务")})]})]})]})]})]}),Ue&&Ee&&Pe&&s.jsx(X0,{workspaceId:Ee,gitStatus:Pe,onResolve:()=>Yi()}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsx("div",{ref:se,className:`flex flex-col bg-white relative ${Z?"flex-shrink-0":"flex-1"}`,style:{width:Z?V:"100%"},children:He&&_e?j?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:j})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Ga,{session:J,providers:Ve,usage:tn,providerIdFallback:X?.providerId,agentTypeFallback:J?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ie,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-2 text-xs font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900",onClick:Sl,children:[s.jsx(Jr,{size:13}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsx("div",{ref:O,className:"w-full",children:Qi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):hs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(ee?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Gs,{logs:hs})})}),!B&&s.jsxs("button",{onClick:()=>W(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:m("回到底部")})]})]})]}):s.jsx(la,{teamRun:_e,messages:De??_e.messages??[],readOnly:fe,readOnlyMessage:Ae,onSendMessage:wl,onViewInvocationSession:Vi}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsxs("div",{ref:O,className:"w-full",children:[s.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(vi,{urlTransform:yg,components:_i,children:e.description})}):s.jsx("p",{className:"text-sm text-neutral-400 italic",children:m("No description")})}),pe&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[pe.status==="running"&&s.jsxs(s.Fragment,{children:[s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{children:m("Setup ({current}/{total}): {command}",{current:pe.currentIndex,total:pe.totalCommands,command:pe.currentCommand})})]}),pe.status==="completed"&&s.jsx("span",{className:"text-emerald-600",children:m("Setup 完成")}),pe.status==="failed"&&s.jsx("span",{className:"text-red-500",children:m("Setup 失败: {error}",{error:pe.error})})]}),ce?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading...")})]}):Je?Qi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:m("Loading logs...")})]}):hs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:m(ee?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Gs,{logs:hs}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:s.jsx(Kt,{size:24,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:m(fe?"项目为只读历史":"尚未启动 Agent")}),s.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:fe?Ae:m("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!fe&&s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[s.jsxs(Ie,{onClick:()=>n(!0),children:[s.jsx(Kt,{size:16,className:"mr-1.5"}),m("启动 Agent")]}),we&&s.jsxs(Ie,{variant:"outline",onClick:()=>f(!0),children:[s.jsx(os,{size:16,className:"mr-1.5"}),m("创建 TeamRun")]})]})]})]})}),!B&&s.jsxs("button",{onClick:()=>W(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":m("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:m("回到底部")})]})]}),Zi.length>0&&s.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:s.jsx(Do,{todos:Zi})}),fe?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:Ae})}):yt?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[s.jsx("span",{className:"text-sm text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ie,{size:"sm",onClick:()=>n(!0),children:[s.jsx(Kt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):s.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Tl,onDragLeave:Ml,onDrop:Dl,children:[s.jsxs("div",{ref:I,className:`relative bg-white rounded-xl border shadow-sm hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300 transition-all duration-200 ${nn?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[s.jsx(br,{files:kl,onRemove:El}),s.jsx("textarea",{ref:z,value:p,onChange:Ol,onPaste:Rl,onKeyDown:G=>{Me.handleKeyDown(G)||ct.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),rn())},rows:1,placeholder:m(nn?"Drop files here...":Je&&!ee?"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-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),s.jsx("input",{ref:A,type:"file",multiple:!0,className:"hidden",onChange:Al}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[s.jsx("div",{className:"flex items-center gap-1",children:s.jsx("button",{onClick:()=>A.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:m("Upload file"),children:s.jsx(hr,{size:18})})}),s.jsxs("div",{className:"flex items-center gap-2",children:[be&&Ve&&s.jsx(Za,{providers:Ve,currentProviderId:nt,agentType:be.agentType,onSelect:Fe}),s.jsx(zi,{usage:tn}),ee&&!p.trim()&&!fs?s.jsx("button",{onClick:Nl,disabled:jr.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-red-500 text-white hover:bg-red-600 shadow-md disabled:opacity-50",children:s.jsx(ns,{size:14})}):s.jsx("button",{onClick:rn,disabled:!p.trim()&&!fs||Hs,className:`p-2 rounded-lg transition-all duration-200 ${(p.trim()||fs)&&!Hs?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:s.jsx(wi,{size:18})})]})]})]}),s.jsx(cr,{open:ct.query!==null,anchorRef:I,commands:ct.filteredCommands,selectedIndex:ct.selectedIndex,query:ct.query??"",hasCatalog:ct.allCommands.length>0,onSelect:ct.applyCommand}),s.jsx(cr,{open:Me.query!==null,anchorRef:I,commands:Me.filteredSkills,selectedIndex:Me.selectedIndex,query:Me.query??"",hasCatalog:Me.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Me.applySkill})]})]})}),Z&&s.jsx("div",{className:"w-1 cursor-col-resize hover:bg-neutral-200 active:bg-blue-400 transition-colors z-30 flex-shrink-0 border-l border-neutral-200",onMouseDown:Ll}),Z&&s.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:s.jsx(Ha,{sessionId:Je||void 0,workspaceId:Le,workingDir:Qe,projectId:e.projectId,readOnly:fe,repoDeleted:qe,teamRun:_e,teamStatus:_e?s.jsx(ua,{teamRun:_e,workspaces:K,selectedWorkspaceId:Le,onSelectWorkspace:N,onViewInvocationSession:Vi}):void 0})})]}),!fe&&s.jsx(Va,{isOpen:i,onClose:()=>n(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),we&&!fe&&s.jsx(q0,{isOpen:c,onClose:()=>f(!1),taskId:e.id}),Ue&&Ee&&!fe&&s.jsx(sg,{open:S,onOpenChange:k,workspaceId:Ee,branchName:ft,targetBranch:st,commitMessage:ot,onRefreshCommitMessage:le,onConflict:Yi}),Ue&&xt&&Oe&&s.jsx(J0,{open:h,onOpenChange:G=>{d(G),G||x(null)},workspaceId:xt,conflictOp:Oe.conflictOp,conflictedFiles:Oe.conflictedFiles,sourceBranch:mt,targetBranch:rt,operation:Pe?.operation,worktreePath:Ye,mergeAborted:Oe.mergeAborted,mergeStrategy:Oe.mergeStrategy,sourceWorkspaceId:Oe.sourceWorkspaceId,targetWorkspaceId:Oe.targetWorkspaceId,sourceWorktreePath:Oe.sourceWorktreePath,targetWorktreePath:Oe.targetWorktreePath,sessions:et,currentSessionId:He?void 0:Je,teamRunId:_e?.id}),s.jsx(Qs,{isOpen:b,onClose:()=>y(!1),onConfirm:Lt,title:m("重新开始任务"),description:s.jsx("p",{children:m("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:m("确认重试"),variant:"default",isLoading:_}),s.jsx(Qs,{isOpen:l,onClose:()=>g(!1),onConfirm:yl,title:m("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),on.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:on.map((G,oe)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:G})]},oe))})]}),confirmText:m("删除"),variant:"danger",isLoading:r})]}):s.jsx(wg,{})}function Xi(e){switch(e){case Nt.TODO:return ve.Pending;case Nt.IN_PROGRESS:return ve.Running;case Nt.IN_REVIEW:return ve.Review;case Nt.DONE:return ve.Done;case Nt.CANCELLED:return ve.Cancelled}}function Eg(e){switch(e){case ve.Pending:return Nt.TODO;case ve.Running:return Nt.IN_PROGRESS;case ve.Review:return Nt.IN_REVIEW;case ve.Done:return Nt.DONE;case ve.Cancelled:return Nt.CANCELLED}}function jg(e){switch(e){case At.CLAUDE_CODE:return"Claude Code";case At.GEMINI_CLI:return"Gemini CLI";case At.CURSOR_AGENT:return"Cursor Agent";case At.CODEX:return"Codex"}}const dr=["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 nl(e,t){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%t}function ol(e,t){return t??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Ng(e){return{id:e.id,name:e.name,color:e.color||dr[nl(e.name,dr.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Ag(e){const t=ol(e);if(!t)return{agent:"—",branch:"—"};const r=t.branchName,o=t.sessions;if(o&&o.length>0){const m=o[o.length-1];return{agent:jg(m.agentType),branch:r}}return{agent:"—",branch:r}}function Rg(e){const{agent:t,branch:r}=Ag(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:Xi(e.status),agent:t,branch:r,description:e.description??"",projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function Tg(e,t,r){const o=ol(e.workspaces,r),m=o?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||dr[nl(t.name,dr.length)],title:e.title,status:Xi(e.status),branch:m,mainBranch:o?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const mo={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 Mg(e){const t=e.split("/");return t[t.length-1]||e}function Dg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Lg({workingDir:e,filePath:t,type:r}){const{t:o}=ae(),{data:m,isLoading:p,isError:v}=Ba(e,t,r);if(p)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
82
|
+
`);return s.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:n.map((c,f)=>{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"),s.jsx("div",{className:te("px-3 whitespace-pre",l,g),children:c},f)})})}function Pg({entry:e,type:t,workingDir:r}){const[o,m]=C.useState(!1),p=mo[e.status]||mo.M,v=Dg(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(i=>!i),className:te("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[s.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Mg(e.path)}),v&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:o?s.jsx(vt,{size:14}):s.jsx(Tt,{size:14})})]}),o&&s.jsx(Lg,{workingDir:r,filePath:e.path,type:t})]})}function po({title:e,entries:t,type:r,workingDir:o,defaultOpen:m}){const{t:p}=ae(),[v,i]=C.useState(m);return t.length===0?null:s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[s.jsx("span",{className:"text-neutral-400",children:v?s.jsx(vt,{size:14}):s.jsx(Tt,{size:14})}),s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),v&&s.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(n=>s.jsx(Pg,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function Og({workingDir:e}){const{t}=ae(),{data:r,isLoading:o,isError:m}=Ia(e);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(o)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(m)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const p=r?.uncommitted||[],v=r?.committed||[];return p.length+v.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(as,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx(po,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),s.jsx(po,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Vr=50,go={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 Ig(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Bt("{count}s ago",{count:r}):r<3600?Bt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Bt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Bt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Bg(e){const t=e.split("/");return t[t.length-1]||e}function Fg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function zg({workingDir:e,hash:t,filePath:r}){const{t:o}=ae(),{data:m,isLoading:p,isError:v}=za(e,t,r);if(p)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=m?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
83
|
+
`);return s.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:n.map((c,f)=>{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"),s.jsx("div",{className:te("px-3 whitespace-pre",l,g),children:c},f)})})}function Hg({entry:e,workingDir:t,hash:r}){const[o,m]=C.useState(!1),p=go[e.status]||go.M,v=Fg(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(i=>!i),className:te("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[s.jsx("span",{className:te("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Bg(e.path)}),v&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:o?s.jsx(vt,{size:14}):s.jsx(Tt,{size:14})})]}),o&&s.jsx(zg,{workingDir:t,hash:r,filePath:e.path})]})}function Wg({commit:e,workingDir:t}){const{t:r}=ae(),[o,m]=C.useState(!1),{data:p,isLoading:v}=Fa(t,o?e.hash:null),i=p?.files||[];return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>m(n=>!n),className:te("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:s.jsx("div",{className:te("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),s.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),s.jsx("span",{className:"text-[11px] text-neutral-400",children:Ig(e.timestamp)})]})]}),s.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?s.jsx(vt,{size:14}):s.jsx(Tt,{size:14})})]}),o&&s.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&s.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[s.jsx($e,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):s.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>s.jsx(Hg,{entry:n,workingDir:t,hash:e.hash},n.path))})]})]})}function $g({workingDir:e}){const{t}=ae(),{data:r,isLoading:o,isError:m,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:i}=Lo({queryKey:de.git.log(e||""),queryFn:({pageParam:c=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(Vr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<Vr?void 0:f.length*Vr,enabled:!!e}),n=r?.pages.flatMap(c=>c.commits)||[];return e?o?s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx($e,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):m?s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):n.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(ls,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No commit history")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(c=>s.jsx(Wg,{commit:c,workingDir:e},c.hash))}),v&&s.jsx("button",{type:"button",onClick:()=>p(),disabled:i,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:i?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const Ug="/api",qg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Ug}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Kg({status:e}){const t={[ve.Running]:"bg-blue-500",[ve.Review]:"bg-amber-500",[ve.Pending]:"bg-neutral-400",[ve.Done]:"bg-emerald-500",[ve.Cancelled]:"bg-neutral-400"};return s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Xg=[{key:"chat",label:"Chat",icon:Ai},{key:"changes",label:"Changes",icon:as},{key:"history",label:"History",icon:ls},{key:"workspace",label:"Workspace",icon:Ei}],Vg=[{key:"chat",label:"Team room",icon:Ai},{key:"team-status",label:"Team Status",icon:Ss},{key:"changes",label:"Changes",icon:as},{key:"workspace",label:"Workspace",icon:Ei}];function Yg({task:e,onBack:t,onDeleteTask:r,isDeleting:o}){const{t:m}=ae(),[p,v]=C.useState("chat"),[i,n]=C.useState(""),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[b,y]=C.useState(!1),[_,a]=C.useState(null),[h,d]=C.useState(void 0),u=C.useRef(null),x=C.useRef(null),S=C.useRef(null),k=C.useRef(null),{scrollRef:E,contentRef:w,isAtBottom:j,scrollToBottom:T}=Fi({resize:"smooth",initial:"instant"}),L=Ge();C.useEffect(()=>{if(!b)return;const Y=le=>{x.current&&!x.current.contains(le.target)&&y(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[b]);const{data:N,isLoading:R}=$a(e.id),{data:D}=Ao(e.id),{data:I}=Ro(D?.id??""),F=ui(D?.id??""),z=D??null,A=z?Vg:Xg;C.useEffect(()=>{d(void 0),a(null)},[e.id]),C.useEffect(()=>{z&&p==="history"&&v("chat"),!z&&p==="team-status"&&v("chat")},[p,z]);const P=C.useMemo(()=>da(N,z,h),[h,z,N]);C.useEffect(()=>{h&&!N?.some(Y=>Y.id===h)&&d(void 0)},[h,N]);const O=C.useMemo(()=>N?.find(Y=>Y.id===P),[P,N]),B=C.useMemo(()=>{if(!N)return null;const Y=N.filter(ue=>ue.status==="ACTIVE"&&Array.isArray(ue.sessions)).flatMap(ue=>ue.sessions??[]),le=ue=>{const Be=ue.createdAt,Re=ue.endedAt??ue.startedAt??Be;if(!Re)return 0;const pt=Date.parse(Re);return Number.isNaN(pt)?0:pt},je=ue=>{const Be=Y.filter(Re=>ue.includes(Re.status));return Be.length===0?null:Be.sort((Re,pt)=>le(pt)-le(Re))[0]??null},q=je([Xe.RUNNING])??je([Xe.PENDING])??je([Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED]);if(q)return q;const me=N.filter(ue=>(ue.status==="ABANDONED"||ue.status==="MERGED"||ue.status==="HIBERNATED")&&Array.isArray(ue.sessions)).flatMap(ue=>ue.sessions??[]).filter(ue=>[Xe.COMPLETED,Xe.FAILED,Xe.CANCELLED].includes(ue.status));return me.length===0?null:me.sort((ue,Be)=>le(Be)-le(ue))[0]??null},[N]),W=B?.id??"",V=z?_??"":W,Q=C.useMemo(()=>{if(!_||!N)return null;for(const Y of N){const le=Y.sessions?.find(je=>je.id===_);if(le)return le}return null},[_,N]),Z=C.useMemo(()=>{if(!_||!z?.invocations)return null;const Y=z.invocations.filter(le=>le.sessionId===_);return Y.length===0?null:Y.sort((le,je)=>{const q=Date.parse(le.updatedAt??le.createdAt??""),re=Date.parse(je.updatedAt??je.createdAt??"");return(Number.isNaN(re)?0:re)-(Number.isNaN(q)?0:q)})[0]??null},[_,z?.invocations]),he=C.useMemo(()=>!Z?.memberId||!z?.members?null:z.members.find(Y=>Y.id===Z.memberId)??null,[Z?.memberId,z?.members]),M=_?Q:B??null,H=M?.status===Xe.RUNNING||M?.status===Xe.PENDING,U=!!e.projectArchivedAt,$=!!e.projectRepoDeletedAt,se=m($?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),K=C.useMemo(()=>!B||!N?!1:!N.some(le=>le.status==="ACTIVE"&&le.sessions?.some(je=>je.id===B.id)),[B,N]),{data:ce}=Ts(),[pe,xe]=C.useState(null),De=pe?.sessionId===W?pe.providerId:B?.providerId??null,ne=C.useCallback(Y=>{xe({sessionId:W,providerId:Y})},[W]),_e=C.useMemo(()=>{if(N){if(O)return O.worktreePath||void 0;for(const Y of N)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return N[0]?.worktreePath}},[O,N]),He=rl({agentType:B?.agentType,workingDir:_e,input:i,setInput:n,textareaRef:S,minHeight:40,maxHeight:140}),we=il({agentType:B?.agentType,workingDir:_e,input:i,setInput:n,textareaRef:S,minHeight:40,maxHeight:140}),Le=O?.worktreePath?O.id:void 0,ke=C.useMemo(()=>{const Y=[];if(N&&N.length>0){const le=N.some(q=>q.status==="ACTIVE");N.some(q=>q.sessions?.some(re=>re.status===Xe.RUNNING||re.status===Xe.PENDING))&&Y.push(m("正在运行的 Agent 将被停止")),le&&(Y.push(m("分支上未合并的变更将丢失")),Y.push(m("关联的工作目录(worktree)将被清理")))}return Y},[N,m]),Ee=Ki(),Ue=Ui(),be=Ka(),{isConnected:Je,isLoadingSnapshot:Ce,logs:Ne,entries:tt,attach:X}=To({sessionId:V,sessionStatus:M?.status,onExit:C.useCallback(()=>{L.invalidateQueries({queryKey:["workspaces"]})},[L])}),{todos:J}=Mo(tt),{files:ee,addFiles:fe,removeFile:qe,clear:Ae,buildMarkdownLinks:Ve,hasFiles:nt,isUploading:Fe}=xr(),yt=C.useMemo(()=>Ya(M),[M?.tokenUsage]),Qe=Xa(Ne,yt);C.useEffect(()=>{V&&Je&&X()},[V,Je,X]);const ct=C.useRef(null);C.useEffect(()=>{if(ct.current!==e.id&&E.current){const Y=E.current;requestAnimationFrame(()=>{Y.scrollTop=Y.scrollHeight})}ct.current=e.id},[e.id,E]);const Me=C.useRef(!1),Pe=C.useCallback(async()=>{if(!i.trim()&&!nt||!W||Me.current||Fe)return;Me.current=!0;const Y=Ve(),le=[i.trim(),Y].filter(Boolean).join(`
|
|
84
84
|
|
|
85
|
-
`);n(""),Ae(),S.current&&(S.current.style.height="40px"),Ee.mutate({id:$,message:le,providerId:De??void 0},{onSuccess:()=>X(),onSettled:()=>{Me.current=!1}})},[i,$,Ee,X,nt,Fe,Ve,Ae,De]),et=C.useCallback(async()=>{$&&(await ye.mutateAsync($),L.invalidateQueries({queryKey:["workspaces"]}))},[$,ye,L]),ft=C.useCallback(V=>F.mutateAsync(V),[F]),ot=C.useCallback(V=>{a(V),v("chat"),requestAnimationFrame(()=>{N()})},[N]),st=C.useCallback(()=>{a(null)},[]),Oe=C.useCallback(V=>{const le=V.target.files;le&&le.length>0&&fe(Array.from(le)),V.target.value=""},[fe]),_t=C.useCallback(V=>{const le=V.clipboardData.items,je=[];for(const q of le)if(q.kind==="file"){const re=q.getAsFile();re&&je.push(re)}je.length>0&&(V.preventDefault(),fe(je))},[fe]),Ye=C.useCallback(V=>{n(V.target.value);const le=V.target;le.style.height="auto",le.style.height=`${Math.max(40,Math.min(le.scrollHeight,140))}px`},[]),mt=C.useCallback(()=>{Le&&Ue.mutate({workspaceId:Le})},[Ue,Le]),rt=C.useRef(null);return C.useEffect(()=>{const V=window.visualViewport;if(!V)return;let le=!1;const je=()=>{rt.current&&(rt.current.style.height=`${V.height}px`,rt.current.style.top=`${V.offsetTop}px`)},q=()=>je(),re=()=>{le||je()},me=()=>{le=!0},ue=()=>{le=!1,requestAnimationFrame(je)};return V.addEventListener("resize",q),V.addEventListener("scroll",re),document.addEventListener("touchstart",me,{passive:!0}),document.addEventListener("touchend",ue,{passive:!0}),document.addEventListener("touchcancel",ue,{passive:!0}),()=>{V.removeEventListener("resize",q),V.removeEventListener("scroll",re),document.removeEventListener("touchstart",me),document.removeEventListener("touchend",ue),document.removeEventListener("touchcancel",ue)}},[]),C.useEffect(()=>{const V=rt.current;if(!V)return;const le=je=>{let q=je.target;for(;q&&q!==V;){if(q.tagName==="TEXTAREA"){if(q.scrollHeight>q.clientHeight)return;q=q.parentElement;continue}const me=window.getComputedStyle(q).overflowY;if((me==="auto"||me==="scroll")&&q.scrollHeight>q.clientHeight)return;q=q.parentElement}je.preventDefault()};return V.addEventListener("touchmove",le,{passive:!1}),()=>V.removeEventListener("touchmove",le)},[]),s.jsxs("div",{ref:rt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[s.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[s.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[s.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:s.jsx(ti,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),s.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[s.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.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("已删除")}),s.jsx("span",{className:"text-neutral-300",children:"/"}),s.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),s.jsx(Vg,{status:e.status}),s.jsx("button",{onClick:mt,disabled:!Le||U,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:s.jsx(Ls,{size:16})}),r&&!U&&s.jsxs("div",{className:"relative",ref:b,children:[s.jsx("button",{onClick:()=>y(V=>!V),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:s.jsx(Io,{size:16})}),x&&s.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:s.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:[s.jsx(Si,{size:15}),s.jsx("span",{children:m("删除任务")})]})})]})]}),s.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:V,label:le,icon:je})=>s.jsxs("button",{onClick:()=>v(V),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${p===V?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[s.jsx(je,{size:13,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:m(le)})]},V))})]}),p==="chat"&&(z?s.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:_?s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:_})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(Ga,{session:T,providers:ce,usage:Qe,compact:!0,providerIdFallback:he?.providerId,agentTypeFallback:T?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ie,{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:st,children:[s.jsx(ti,{size:12}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:j,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsx("div",{ref:w,children:Ce?s.jsx(Qr,{label:m("Loading logs...")}):Ne.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:m(H?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Zs,{logs:Ne})})}),!k&&s.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:[s.jsx(Cs,{size:12}),s.jsx("span",{children:m("回到底部")})]})]})]}):s.jsx(la,{teamRun:z,messages:I??z.messages??[],readOnly:U,readOnlyMessage:se,onSendMessage:ft,onViewInvocationSession:ot,compactComposer:!0})}):s.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:j,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsxs("div",{ref:w,children:[s.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(xi,{urlTransform:Xg,components:bi,children:e.description})}):s.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),M?s.jsx(Qr,{label:"Loading..."}):$?Ce?s.jsx(Qr,{label:"Loading logs..."}):Ne.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:H?"Waiting for agent output...":"No logs recorded."}):s.jsx(Zs,{logs:Ne}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:s.jsx(qt,{size:20,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),s.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:U?se:m("选择一个 Agent 来执行此任务")}),!U&&s.jsxs(Ie,{onClick:()=>f(!0),children:[s.jsx(qt,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!k&&s.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:[s.jsx(Cs,{size:12}),s.jsx("span",{children:m("回到底部")})]})]}),J.length>0&&s.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:s.jsx(Do,{todos:J,compact:!0})}),U?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:se})}):K?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ie,{size:"sm",onClick:()=>f(!0),children:[s.jsx(qt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):$&&s.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[s.jsxs("div",{ref:u,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[s.jsx(wr,{files:ee,onRemove:qe}),s.jsx("textarea",{ref:S,value:i,onChange:Ye,onPaste:_t,onKeyDown:V=>{we.handleKeyDown(V)||He.handleKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),Pe())},rows:1,placeholder:H?"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}}),s.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:Oe}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:s.jsx("button",{onClick:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:s.jsx(pr,{size:15})})}),s.jsxs("div",{className:"flex items-center gap-1",children:[B&&ce&&s.jsx(Za,{providers:ce,currentProviderId:De,agentType:B.agentType,onSelect:ne}),s.jsx(Hi,{usage:Qe}),H&&!i.trim()&&!nt?s.jsx("button",{onClick:et,disabled:ye.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:s.jsx(os,{size:12})}):s.jsx("button",{onClick:Pe,disabled:!i.trim()&&!nt||Fe,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||nt)&&!Fe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:s.jsx(ki,{size:15})})]})]})]}),s.jsx(ur,{open:He.query!==null,anchorRef:u,commands:He.filteredCommands,selectedIndex:He.selectedIndex,query:He.query??"",hasCatalog:He.allCommands.length>0,compact:!0,onSelect:He.applyCommand}),s.jsx(ur,{open:we.query!==null,anchorRef:u,commands:we.filteredSkills,selectedIndex:we.selectedIndex,query:we.query??"",hasCatalog:we.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:we.applySkill})]})]})),p==="team-status"&&z&&s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:s.jsx(ua,{teamRun:z,workspaces:R,selectedWorkspaceId:P,onSelectWorkspace:d,onViewInvocationSession:ot})}),p==="changes"&&s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[R&&R.length>1&&s.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:s.jsx(Wa,{workspaces:R,teamRun:z,selectedWorkspaceId:P,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),s.jsx(Bg,{workingDir:_e})]}),p==="history"&&s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:s.jsx(qg,{workingDir:_e})}),p==="workspace"&&s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(Ha,{sessionId:$||void 0,workspaceId:P,workingDir:_e,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:U,repoDeleted:W})}),!U&&s.jsx(Va,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),s.jsx(Js,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},title:m("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),ke.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:ke.map((V,le)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:V})]},le))})]}),confirmText:m("删除"),variant:"danger",isLoading:o})]})}function Qr({label:e}){return s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:e})]})}var Zg=Object.defineProperty,fr=Object.getOwnPropertySymbols,al=Object.prototype.hasOwnProperty,ll=Object.prototype.propertyIsEnumerable,vo=(e,t,r)=>t in e?Zg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,di=(e,t)=>{for(var r in t||(t={}))al.call(t,r)&&vo(e,r,t[r]);if(fr)for(var r of fr(t))ll.call(t,r)&&vo(e,r,t[r]);return e},ui=(e,t)=>{var r={};for(var o in e)al.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&fr)for(var o of fr(e))t.indexOf(o)<0&&ll.call(e,o)&&(r[o]=e[o]);return r};var Vt;(e=>{const t=class Se{constructor(n,c,f,l){if(this.version=n,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],n<Se.MIN_VERSION||n>Se.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=n*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 x=this.addEccAndInterleave(f);if(this.drawCodewords(x),l==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const a=this.getPenaltyScore();a<y&&(l=_,y=a),this.applyMask(_)}}m(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(n,c){const f=e.QrSegment.makeSegments(n);return Se.encodeSegments(f,c)}static encodeBinary(n,c){const f=e.QrSegment.makeBytes(n);return Se.encodeSegments([f],c)}static encodeSegments(n,c,f=1,l=40,g=-1,x=!0){if(!(Se.MIN_VERSION<=f&&f<=l&&l<=Se.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,_;for(y=f;;y++){const u=Se.getNumDataCodewords(y,c)*8,b=v.getTotalBits(n,y);if(b<=u){_=b;break}if(y>=l)throw new RangeError("Data too long")}for(const u of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])x&&_<=Se.getNumDataCodewords(y,u)*8&&(c=u);let a=[];for(const u of n){r(u.mode.modeBits,4,a),r(u.numChars,u.mode.numCharCountBits(y),a);for(const b of u.getData())a.push(b)}m(a.length==_);const h=Se.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 u=236;a.length<h;u^=253)r(u,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((u,b)=>d[b>>>3]|=u<<7-(b&7)),new Se(y,c,d,g)}getModule(n,c){return 0<=n&&n<this.size&&0<=c&&c<this.size&&this.modules[c][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),c=n.length;for(let f=0;f<c;f++)for(let l=0;l<c;l++)f==0&&l==0||f==0&&l==c-1||f==c-1&&l==0||this.drawAlignmentPattern(n[f],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const c=this.errorCorrectionLevel.formatBits<<3|n;let f=c;for(let g=0;g<10;g++)f=f<<1^(f>>>9)*1335;const l=(c<<10|f)^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 n=this.version;for(let f=0;f<12;f++)n=n<<1^(n>>>11)*7973;const c=this.version<<12|n;m(c>>>18==0);for(let f=0;f<18;f++){const l=o(c,f),g=this.size-11+f%3,x=Math.floor(f/3);this.setFunctionModule(g,x,l),this.setFunctionModule(x,g,l)}}drawFinderPattern(n,c){for(let f=-4;f<=4;f++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(f)),x=n+l,y=c+f;0<=x&&x<this.size&&0<=y&&y<this.size&&this.setFunctionModule(x,y,g!=2&&g!=4)}}drawAlignmentPattern(n,c){for(let f=-2;f<=2;f++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,c+f,Math.max(Math.abs(l),Math.abs(f))!=1)}setFunctionModule(n,c,f){this.modules[c][n]=f,this.isFunction[c][n]=!0}addEccAndInterleave(n){const c=this.version,f=this.errorCorrectionLevel;if(n.length!=Se.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const l=Se.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],g=Se.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],x=Math.floor(Se.getNumRawDataModules(c)/8),y=l-x%l,_=Math.floor(x/l);let a=[];const h=Se.reedSolomonComputeDivisor(g);for(let u=0,b=0;u<l;u++){let S=n.slice(b,b+_-g+(u<y?0:1));b+=S.length;const E=Se.reedSolomonComputeRemainder(S,h);u<y&&S.push(0),a.push(S.concat(E))}let d=[];for(let u=0;u<a[0].length;u++)a.forEach((b,S)=>{(u!=_-g||S>=y)&&d.push(b[u])});return m(d.length==x),d}drawCodewords(n){if(n.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const x=f-g,_=(f+1&2)==0?this.size-1-l:l;!this.isFunction[_][x]&&c<n.length*8&&(this.modules[_][x]=o(n[c>>>3],7-(c&7)),c++)}}m(c==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let l;switch(n){case 0:l=(f+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=f%3==0;break;case 3:l=(f+c)%3==0;break;case 4:l=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:l=f*c%2+f*c%3==0;break;case 6:l=(f*c%2+f*c%3)%2==0;break;case 7:l=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&l&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),x=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),x=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const y=this.modules[g][x];y==this.modules[g][x+1]&&y==this.modules[g+1][x]&&y==this.modules[g+1][x+1]&&(n+=Se.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((x,y)=>x+(y?1:0),c);const f=this.size*this.size,l=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=l&&l<=9),n+=l*Se.PENALTY_N4,m(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let f=[6];for(let l=this.size-7;f.length<n;l-=c)f.splice(1,0,l);return f}}static getNumRawDataModules(n){if(n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*n+128)*n+64;if(n>=2){const f=Math.floor(n/7)+2;c-=(25*f-10)*f-55,n>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(n,c){return Math.floor(Se.getNumRawDataModules(n)/8)-Se.ECC_CODEWORDS_PER_BLOCK[c.ordinal][n]*Se.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let c=[];for(let l=0;l<n-1;l++)c.push(0);c.push(1);let f=1;for(let l=0;l<n;l++){for(let g=0;g<c.length;g++)c[g]=Se.reedSolomonMultiply(c[g],f),g+1<c.length&&(c[g]^=c[g+1]);f=Se.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(n,c){let f=c.map(l=>0);for(const l of n){const g=l^f.shift();f.push(0),c.forEach((x,y)=>f[y]^=Se.reedSolomonMultiply(x,g))}return f}static reedSolomonMultiply(n,c){if(n>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let l=7;l>=0;l--)f=f<<1^(f>>>7)*285,f^=(c>>>l&1)*n;return m(f>>>8==0),f}finderPenaltyCountPatterns(n){const c=n[1];m(c<=this.size*3);const f=c>0&&n[2]==c&&n[3]==c*3&&n[4]==c&&n[5]==c;return(f&&n[0]>=c*4&&n[6]>=c?1:0)+(f&&n[6]>=c*4&&n[0]>=c?1:0)}finderPenaltyTerminateAndCount(n,c,f){return n&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(n,c){c[0]==0&&(n+=this.size),c.pop(),c.unshift(n)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function r(i,n,c){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let f=n-1;f>=0;f--)c.push(i>>>f&1)}function o(i,n){return(i>>>n&1)!=0}function m(i){if(!i)throw new Error("Assertion error")}const p=class Ze{constructor(n,c,f){if(this.mode=n,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(n){let c=[];for(const f of n)r(f,8,c);return new Ze(Ze.Mode.BYTE,n.length,c)}static makeNumeric(n){if(!Ze.isNumeric(n))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<n.length;){const l=Math.min(n.length-f,3);r(parseInt(n.substring(f,f+l),10),l*3+1,c),f+=l}return new Ze(Ze.Mode.NUMERIC,n.length,c)}static makeAlphanumeric(n){if(!Ze.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=n.length;f+=2){let l=Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f))*45;l+=Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f+1)),r(l,11,c)}return f<n.length&&r(Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f)),6,c),new Ze(Ze.Mode.ALPHANUMERIC,n.length,c)}static makeSegments(n){return n==""?[]:Ze.isNumeric(n)?[Ze.makeNumeric(n)]:Ze.isAlphanumeric(n)?[Ze.makeAlphanumeric(n)]:[Ze.makeBytes(Ze.toUtf8ByteArray(n))]}static makeEci(n){let c=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,c);else if(n<16384)r(2,2,c),r(n,14,c);else if(n<1e6)r(6,3,c),r(n,21,c);else throw new RangeError("ECI assignment value out of range");return new Ze(Ze.Mode.ECI,0,c)}static isNumeric(n){return Ze.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return Ze.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,c){let f=0;for(const l of n){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;f+=4+g+l.bitData.length}return f}static toUtf8ByteArray(n){n=encodeURI(n);let c=[];for(let f=0;f<n.length;f++)n.charAt(f)!="%"?c.push(n.charCodeAt(f)):(c.push(parseInt(n.substring(f+1,f+3),16)),f+=2);return c}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(Vt||(Vt={}));(e=>{(t=>{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),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(Vt||(Vt={}));(e=>{(t=>{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]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(Vt||(Vt={}));var rs=Vt;var Jg={L:rs.QrCode.Ecc.LOW,M:rs.QrCode.Ecc.MEDIUM,Q:rs.QrCode.Ecc.QUARTILE,H:rs.QrCode.Ecc.HIGH},cl=128,dl="L",ul="#FFFFFF",hl="#000000",fl=!1,ml=1,ev=4,tv=0,sv=.1;function pl(e,t=0){const r=[];return e.forEach(function(o,m){let p=null;o.forEach(function(v,i){if(!v&&p!==null){r.push(`M${p+t} ${m+t}h${i-p}v1H${p+t}z`),p=null;return}if(i===o.length-1){if(!v)return;p===null?r.push(`M${i+t},${m+t} h1v1H${i+t}z`):r.push(`M${p+t},${m+t} h${i+1-p}v1H${p+t}z`);return}v&&p===null&&(p=i)})}),r.join("")}function gl(e,t){return e.slice().map((r,o)=>o<t.y||o>=t.y+t.h?r:r.map((m,p)=>p<t.x||p>=t.x+t.w?m:!1))}function rv(e,t,r,o){if(o==null)return null;const m=e.length+r*2,p=Math.floor(t*sv),v=m/t,i=(o.width||p)*v,n=(o.height||p)*v,c=o.x==null?e.length/2-i/2:o.x*v,f=o.y==null?e.length/2-n/2:o.y*v,l=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let y=Math.floor(c),_=Math.floor(f),a=Math.ceil(i+c-y),h=Math.ceil(n+f-_);g={x:y,y:_,w:a,h}}const x=o.crossOrigin;return{x:c,y:f,h:n,w:i,excavation:g,opacity:l,crossOrigin:x}}function iv(e,t){return t!=null?Math.max(Math.floor(t),0):e?ev:tv}function vl({value:e,level:t,minVersion:r,includeMargin:o,marginSize:m,imageSettings:p,size:v,boostLevel:i}){let n=ie.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,a)=>(_.push(...rs.QrSegment.makeSegments(a)),_),[]);return rs.QrCode.encodeSegments(y,Jg[t],r,void 0,void 0,i)},[e,t,r,i]);const{cells:c,margin:f,numCells:l,calculatedImageSettings:g}=ie.useMemo(()=>{let x=n.getModules();const y=iv(o,m),_=x.length+y*2,a=rv(x,v,y,p);return{cells:x,margin:y,numCells:_,calculatedImageSettings:a}},[n,v,p,o,m]);return{qrcode:n,margin:f,cells:c,numCells:l,calculatedImageSettings:g}}var nv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ov=ie.forwardRef(function(t,r){const o=t,{value:m,size:p=cl,level:v=dl,bgColor:i=ul,fgColor:n=hl,includeMargin:c=fl,minVersion:f=ml,boostLevel:l,marginSize:g,imageSettings:x}=o,_=ui(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=_,h=ui(_,["style"]),d=x?.src,u=ie.useRef(null),b=ie.useRef(null),S=ie.useCallback(D=>{u.current=D,typeof r=="function"?r(D):r&&(r.current=D)},[r]),[E,j]=ie.useState(!1),{margin:w,cells:k,numCells:N,calculatedImageSettings:L}=vl({value:m,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:x,size:p});ie.useEffect(()=>{if(u.current!=null){const D=u.current,I=D.getContext("2d");if(!I)return;let F=k;const z=b.current,A=L!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&L.excavation!=null&&(F=gl(k,L.excavation));const P=window.devicePixelRatio||1;D.height=D.width=p*P;const O=p/N*P;I.scale(O,O),I.fillStyle=i,I.fillRect(0,0,N,N),I.fillStyle=n,nv?I.fill(new Path2D(pl(F,w))):k.forEach(function(B,$){B.forEach(function(Y,Q){Y&&I.fillRect(Q+w,$+w,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(z,L.x+w,L.y+w,L.w,L.h)}}),ie.useEffect(()=>{j(!1)},[d]);const R=di({height:p,width:p},a);let M=null;return d!=null&&(M=ie.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:L?.crossOrigin})),ie.createElement(ie.Fragment,null,ie.createElement("canvas",di({style:R,height:p,width:p,ref:S,role:"img"},h)),M)});ov.displayName="QRCodeCanvas";var _l=ie.forwardRef(function(t,r){const o=t,{value:m,size:p=cl,level:v=dl,bgColor:i=ul,fgColor:n=hl,includeMargin:c=fl,minVersion:f=ml,boostLevel:l,title:g,marginSize:x,imageSettings:y}=o,_=ui(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:u}=vl({value:m,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:x,imageSettings:y,size:p});let b=h,S=null;y!=null&&u!=null&&(u.excavation!=null&&(b=gl(h,u.excavation)),S=ie.createElement("image",{href:y.src,height:u.h,width:u.w,x:u.x+a,y:u.y+a,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const E=pl(b,a);return ie.createElement("svg",di({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},_),!!g&&ie.createElement("title",null,g),ie.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ie.createElement("path",{fill:n,d:E,shapeRendering:"crispEdges"}),S)});_l.displayName="QRCodeSVG";function xl(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function av(){return xt({queryKey:de.tunnel.status,queryFn:()=>ge.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function lv(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/start",{port:xl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function cv(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/regenerate",{port:xl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function dv(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function uv(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Share via tunnel",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 hv(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 fv(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 _o(e){if(!e)return"Never";const t=new Date(e).getTime();if(!Number.isFinite(t))return e;const r=Math.max(0,Math.round((Date.now()-t)/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 vs(e){const t=e?.trim();return t||null}function mv(e){if(!e)return"";const t=[vs(e.lastLocalError),vs(e.lastRemoteError),vs(e.lastError)].filter(m=>m!==null),r=vs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!vs(e.lastError));return r&&o&&t.push(r),t.join(`
|
|
86
|
-
`)}function xo(){const{t:e}=ae(),{data:t}=av(),r=lv(),o=dv(),m=cv(),[p,v]=C.useState(!1),[i,n]=C.useState(null),c=C.useRef(null),[f,l]=C.useState({top:0,right:0}),[g,x]=C.useState(!1),[y,_]=C.useState(!1),a=t?.status!==void 0&&t.status!=="stopped",h=r.isPending||t?.status==="starting",d=m.isPending,u=t?.shareableUrl,b=t?.token,S=uv(t),E=hv(t),j=mv(t);C.useEffect(()=>{if(p&&c.current){const M=c.current.getBoundingClientRect();l({top:M.bottom+8,right:window.innerWidth-M.right})}},[p]);const w=C.useCallback(()=>{a?v(!0):r.mutate(void 0,{onSuccess:()=>v(!0)})},[a,r]),k=C.useCallback(()=>{u&&(navigator.clipboard.writeText(u),n("url"),setTimeout(()=>n(null),2e3))},[u]),N=C.useCallback(()=>{b&&(navigator.clipboard.writeText(b),n("token"),setTimeout(()=>n(null),2e3))},[b]),L=C.useCallback(()=>{o.mutate(),v(!1),x(!1),_(!1)},[o]),R=C.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{_(!1),v(!0)}})},[m]);return s.jsxs("div",{className:"relative",children:[s.jsx("button",{ref:c,onClick:w,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?s.jsx($e,{size:16,className:"animate-spin"}):S.icon==="warn"?s.jsx(Ci,{size:16}):s.jsx(yi,{size:16})}),a&&!h&&s.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),p&&a&&Ut.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),s.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:f.top,right:f.right},children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{children:[s.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${t?.status==="healthy"||t?.status==="checking"?"text-emerald-600":t?.status==="exited"||t?.status==="error"?"text-red-600":"text-amber-600"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(E)]}),s.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(fv(t))})]}),s.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:s.jsx(Ht,{size:14})})]}),b&&s.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:[s.jsx(ad,{size:12}),s.jsx("span",{children:e("Token protected")})]}),u&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(_l,{value:u,size:160})}),u||t?.url?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{readOnly:!0,value:u??t?.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:M=>M.target.select()}),s.jsx("button",{onClick:k,disabled:!u,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:i==="url"?s.jsx(Tt,{size:14,className:"text-emerald-500"}):s.jsx(_n,{size:14})})]}):s.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")}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:_o(t?.lastCheckedAt)})]}),s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:_o(t?.lastHealthyAt)})]})]}),j&&s.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:j}),t?.status==="degraded"&&s.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.")}),t?.status==="linkReplaced"&&s.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&&s.jsxs("div",{className:"mt-2",children:[s.jsx("button",{onClick:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.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}),s.jsx("button",{onClick:N,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:i==="token"?s.jsx(Tt,{size:14,className:"text-emerald-500"}):s.jsx(_n,{size:14})})]})]}),y&&s.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[s.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx("button",{onClick:()=>_(!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")}),s.jsx("button",{onClick:R,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&&s.jsxs("button",{onClick:()=>_(!0),disabled:d||t?.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:[s.jsx(Es,{size:13}),e("Regenerate link")]}),s.jsx("button",{onClick:L,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 Zr({isOpen:e,onClose:t}){const{t:r}=ae(),o=oc(),[m,p]=C.useState(""),[v,i]=C.useState(""),[n,c]=C.useState(null),[f,l]=C.useState(!1),[g,x]=C.useState(!1),y=m.trim(),_=v.trim(),a=f||o.isPending,h=C.useMemo(()=>!!(y&&_&&!a),[y,_,a]),d=C.useCallback(()=>{p(""),i(""),c(null),x(!1)},[]),u=C.useCallback(()=>{a||(d(),t())},[a,t,d]);C.useEffect(()=>{e||d()},[e,d]);const b=C.useCallback(async j=>{try{await o.mutateAsync({name:y,repoPath:_,initEmptyRepo:j}),d(),t()}catch(w){const k=w instanceof Error?w.message:r("Failed to create project");c(k),ns.error(k)}},[o,t,d,r,y,_]),S=C.useCallback(async()=>{if(!(!y||!_||a)){c(null),l(!0);try{const j=await ge.get("/filesystem/validate",{params:{path:_}});if(j.valid){await b(!1);return}if(j.reason==="no_git"&&j.isEmpty){x(!0);return}if(j.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(j.error??r("Selected path is not a valid directory"))}catch(j){c(j instanceof Error?j.message:r("Could not check repository path"))}finally{l(!1)}}},[b,a,r,y,_]),E=C.useCallback(()=>{x(!1),b(!0)},[b]);return s.jsxs(s.Fragment,{children:[s.jsx(Ms,{isOpen:e,onClose:u,title:r("Create New Project"),action:s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:u,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),s.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:f?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),s.jsx("input",{type:"text",value:m,onChange:j=>p(j.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),s.jsx(ac,{value:v,onChange:i,validationMode:"directory"})]}),n&&s.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),s.jsx(Js,{isOpen:g,onClose:()=>{o.isPending||x(!1)},onConfirm:E,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 bo={idle:"Create & Start","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},yo=C.lazy(()=>tc(()=>import("./modal-wCjKEnyL.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),So=s.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),pv=260,gv=600,wo=400,vv=100,Jr=1e3;function Pv(){const{t:e}=ae(),[t,r]=C.useState(null),[o,m]=C.useState(null),[p,v]=C.useState(wo),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(""),[x,y]=C.useState(""),[_,a]=C.useState(""),[h,d]=C.useState(""),[u,b]=C.useState("SOLO"),[S,E]=C.useState("AUTO"),[j,w]=C.useState(null),[k,N]=C.useState([]),[L,R]=C.useState(null),[M,D]=C.useState(null),[I,F]=C.useState("idle"),{files:z,addFiles:A,removeFile:P,clear:O,buildMarkdownLinks:B,isUploading:$}=Sr(),Y=C.useRef(null),Q=C.useRef(!1),Z=C.useRef(0),he=C.useRef(wo),T=C.useRef(null),H=Ge(),{data:U,isLoading:W}=Ds(),{data:se,isLoading:K}=lc({limit:vv}),ce=C.useMemo(()=>se?.data??[],[se?.data]),pe=C.useMemo(()=>ce.map(Tg),[ce]),be=o&&ce.some(q=>q.id===o)?o:null,{data:De,isLoading:ne}=F0(be??"",{limit:Jr}),_e=hc({queries:be?[]:ce.map(q=>({queryKey:de.tasks.list(q.id,{limit:Jr}),queryFn:()=>ge.get(`/projects/${q.id}/tasks`,{params:{limit:String(Jr)}})}))}),He=!be&&_e.some(q=>q.isLoading),we=C.useMemo(()=>{if(be)return De?.data??[];const q=[];for(const re of _e)re.data?.data&&q.push(...re.data.data);return q},[be,De,_e]),Le=t&&we.some(q=>q.id===t)?t:null,ke=C.useMemo(()=>{const q=new Map;for(const re of we){const me=re.createdAt?new Date(re.createdAt).getTime():0,ue=q.get(re.projectId)??0;me>ue&&q.set(re.projectId,me)}return[...ce].sort((re,me)=>{const ue=q.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(q.get(me.id)??(me.createdAt?new Date(me.createdAt).getTime():0))-ue})},[ce,we]),Ee=C.useMemo(()=>ke.filter(q=>!q.archivedAt),[ke]),Ue=C.useMemo(()=>{if(!U)return[];const q=localStorage.getItem("providerUsageCount"),re=q?JSON.parse(q):{};return[...U].sort((me,ue)=>{const Be=me.availability.type!=="NOT_FOUND",Te=ue.availability.type!=="NOT_FOUND";if(Be!==Te)return Be?-1:1;const pt=re[me.provider.id]??0;return(re[ue.provider.id]??0)-pt})},[U]),ye=C.useMemo(()=>we.map(Mg),[we]),Je=C.useMemo(()=>new Set,[]),Ce=C.useMemo(()=>{if(!Le)return null;const q=we.find(me=>me.id===Le);if(!q)return null;const re=ce.find(me=>me.id===q.projectId);if(!re){const me=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Vi(q.status),branch:me,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Dg(q,re)},[Le,we,ce]),Ne=z0(_),tt=jo(),X=W0(),J=H0(),ee=C.useCallback(q=>{X.mutate(q,{onSuccess:()=>{Le===q&&r(null),H.invalidateQueries({queryKey:de.tasks.all})}})},[X,Le,H]),fe=C.useCallback((q,re)=>{J.mutate({id:q,status:Ng(re)},{onError:()=>{ns.error(e("状态变更失败,该操作不被允许"))}})},[J,e]),qe=C.useCallback(q=>{q.preventDefault(),Q.current=!0,Z.current=q.clientX,he.current=p,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[p]);C.useEffect(()=>{const q=me=>{if(!Q.current)return;const ue=me.clientX-Z.current,Be=Math.max(pv,Math.min(gv,he.current+ue));v(Be)},re=()=>{Q.current&&(Q.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)}},[]);const Ae=C.useCallback(()=>{n(!0)},[]),Ve=C.useCallback(()=>{if(Ee.length===0){ns.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),re=localStorage.getItem("lastSelectedProviderId"),me=q&&Ee.find(Te=>Te.id===q)?q:(be&&Ee.find(Te=>Te.id===be)?.id)??Ee[0]?.id??"";a(me);const ue=Ue?.find(Te=>Te.availability.type!=="NOT_FOUND"),Be=re&&Ue?.find(Te=>Te.provider.id===re&&Te.availability.type!=="NOT_FOUND")?re:ue?.provider.id??"";d(Be),b("SOLO"),E("AUTO"),w(null),N([]),R(null),D(null),F("idle"),f(!0)},[Ee,be,Ue,e]),nt=C.useCallback(()=>{n(!1)},[]),Fe=C.useCallback(()=>{I==="idle"&&(f(!1),g(""),y(""),a(""),d(""),b("SOLO"),E("AUTO"),w(null),N([]),R(null),D(null),F("idle"),O())},[I,O]),yt=Ki(),Qe=C.useCallback(async()=>{const q=!!l.trim()&&!!_,re=u==="TEAM"&&L!==null;if(u==="TEAM"&&!j&&k.length===0){D(e("请选择至少一个团队模板或成员预设。"));return}if(u==="TEAM"){if(!re&&!q)return}else if(!q)return;try{D(null);const me=B(),ue=[x.trim(),me].filter(Boolean).join(`
|
|
85
|
+
`);n(""),Ae(),S.current&&(S.current.style.height="40px"),Ee.mutate({id:W,message:le,providerId:De??void 0},{onSuccess:()=>X(),onSettled:()=>{Me.current=!1}})},[i,W,Ee,X,nt,Fe,Ve,Ae,De]),et=C.useCallback(async()=>{W&&(await be.mutateAsync(W),L.invalidateQueries({queryKey:["workspaces"]}))},[W,be,L]),ft=C.useCallback(Y=>F.mutateAsync(Y),[F]),ot=C.useCallback(Y=>{a(Y),v("chat"),requestAnimationFrame(()=>{T()})},[T]),st=C.useCallback(()=>{a(null)},[]),Oe=C.useCallback(Y=>{const le=Y.target.files;le&&le.length>0&&fe(Array.from(le)),Y.target.value=""},[fe]),xt=C.useCallback(Y=>{const le=Y.clipboardData.items,je=[];for(const q of le)if(q.kind==="file"){const re=q.getAsFile();re&&je.push(re)}je.length>0&&(Y.preventDefault(),fe(je))},[fe]),Ye=C.useCallback(Y=>{n(Y.target.value);const le=Y.target;le.style.height="auto",le.style.height=`${Math.max(40,Math.min(le.scrollHeight,140))}px`},[]),mt=C.useCallback(()=>{Le&&Ue.mutate({workspaceId:Le})},[Ue,Le]),rt=C.useRef(null);return C.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let le=!1;const je=()=>{rt.current&&(rt.current.style.height=`${Y.height}px`,rt.current.style.top=`${Y.offsetTop}px`)},q=()=>je(),re=()=>{le||je()},me=()=>{le=!0},ue=()=>{le=!1,requestAnimationFrame(je)};return Y.addEventListener("resize",q),Y.addEventListener("scroll",re),document.addEventListener("touchstart",me,{passive:!0}),document.addEventListener("touchend",ue,{passive:!0}),document.addEventListener("touchcancel",ue,{passive:!0}),()=>{Y.removeEventListener("resize",q),Y.removeEventListener("scroll",re),document.removeEventListener("touchstart",me),document.removeEventListener("touchend",ue),document.removeEventListener("touchcancel",ue)}},[]),C.useEffect(()=>{const Y=rt.current;if(!Y)return;const le=je=>{let q=je.target;for(;q&&q!==Y;){if(q.tagName==="TEXTAREA"){if(q.scrollHeight>q.clientHeight)return;q=q.parentElement;continue}const me=window.getComputedStyle(q).overflowY;if((me==="auto"||me==="scroll")&&q.scrollHeight>q.clientHeight)return;q=q.parentElement}je.preventDefault()};return Y.addEventListener("touchmove",le,{passive:!1}),()=>Y.removeEventListener("touchmove",le)},[]),s.jsxs("div",{ref:rt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[s.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[s.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[s.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:s.jsx(Jr,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),s.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[s.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.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("已删除")}),s.jsx("span",{className:"text-neutral-300",children:"/"}),s.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),s.jsx(Kg,{status:e.status}),s.jsx("button",{onClick:mt,disabled:!Le||U,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:s.jsx(Ms,{size:16})}),r&&!U&&s.jsxs("div",{className:"relative",ref:x,children:[s.jsx("button",{onClick:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:s.jsx(Io,{size:16})}),b&&s.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:s.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:[s.jsx(bi,{size:15}),s.jsx("span",{children:m("删除任务")})]})})]})]}),s.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:Y,label:le,icon:je})=>s.jsxs("button",{onClick:()=>v(Y),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${p===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[s.jsx(je,{size:13,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:m(le)})]},Y))})]}),p==="chat"&&(z?s.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:_?s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:m("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:_})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(Ga,{session:M,providers:ce,usage:Qe,compact:!0,providerIdFallback:he?.providerId,agentTypeFallback:M?.agentType,tokenTooltipSide:"bottom"}),s.jsxs(Ie,{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:st,children:[s.jsx(Jr,{size:12}),s.jsx("span",{children:m("Team room")})]})]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.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:s.jsx("div",{ref:w,children:Ce?s.jsx(Yr,{label:m("Loading logs...")}):Ne.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:m(H?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Gs,{logs:Ne})})}),!j&&s.jsxs("button",{onClick:()=>T(),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:[s.jsx(Cs,{size:12}),s.jsx("span",{children:m("回到底部")})]})]})]}):s.jsx(la,{teamRun:z,messages:I??z.messages??[],readOnly:U,readOnlyMessage:se,onSendMessage:ft,onViewInvocationSession:ot,compactComposer:!0})}):s.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.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:s.jsxs("div",{ref:w,children:[s.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(vi,{urlTransform:qg,components:_i,children:e.description})}):s.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),R?s.jsx(Yr,{label:"Loading..."}):W?Ce?s.jsx(Yr,{label:"Loading logs..."}):Ne.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:H?"Waiting for agent output...":"No logs recorded."}):s.jsx(Gs,{logs:Ne}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:s.jsx(Kt,{size:20,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:m("尚未启动 Agent")}),s.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:U?se:m("选择一个 Agent 来执行此任务")}),!U&&s.jsxs(Ie,{onClick:()=>f(!0),children:[s.jsx(Kt,{size:16,className:"mr-1.5"}),m("启动 Agent")]})]})]})}),!j&&s.jsxs("button",{onClick:()=>T(),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:[s.jsx(Cs,{size:12}),s.jsx("span",{children:m("回到底部")})]})]}),J.length>0&&s.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:s.jsx(Do,{todos:J,compact:!0})}),U?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:se})}):K?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-neutral-500",children:m("代码已合并,以上为历史沟通记录")}),s.jsxs(Ie,{size:"sm",onClick:()=>f(!0),children:[s.jsx(Kt,{size:14,className:"mr-1.5"}),m("启动新 Agent")]})]})}):W&&s.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[s.jsxs("div",{ref:u,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[s.jsx(br,{files:ee,onRemove:qe}),s.jsx("textarea",{ref:S,value:i,onChange:Ye,onPaste:xt,onKeyDown:Y=>{we.handleKeyDown(Y)||He.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),Pe())},rows:1,placeholder:H?"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}}),s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:Oe}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:s.jsx("button",{onClick:()=>k.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:s.jsx(hr,{size:15})})}),s.jsxs("div",{className:"flex items-center gap-1",children:[B&&ce&&s.jsx(Za,{providers:ce,currentProviderId:De,agentType:B.agentType,onSelect:ne}),s.jsx(zi,{usage:Qe}),H&&!i.trim()&&!nt?s.jsx("button",{onClick:et,disabled:be.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:s.jsx(ns,{size:12})}):s.jsx("button",{onClick:Pe,disabled:!i.trim()&&!nt||Fe,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||nt)&&!Fe?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:s.jsx(wi,{size:15})})]})]})]}),s.jsx(cr,{open:He.query!==null,anchorRef:u,commands:He.filteredCommands,selectedIndex:He.selectedIndex,query:He.query??"",hasCatalog:He.allCommands.length>0,compact:!0,onSelect:He.applyCommand}),s.jsx(cr,{open:we.query!==null,anchorRef:u,commands:we.filteredSkills,selectedIndex:we.selectedIndex,query:we.query??"",hasCatalog:we.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:we.applySkill})]})]})),p==="team-status"&&z&&s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:s.jsx(ua,{teamRun:z,workspaces:N,selectedWorkspaceId:P,onSelectWorkspace:d,onViewInvocationSession:ot})}),p==="changes"&&s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[N&&N.length>1&&s.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:s.jsx(Wa,{workspaces:N,teamRun:z,selectedWorkspaceId:P,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),s.jsx(Og,{workingDir:_e})]}),p==="history"&&s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:s.jsx($g,{workingDir:_e})}),p==="workspace"&&s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(Ha,{sessionId:W||void 0,workspaceId:P,workingDir:_e,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:U,repoDeleted:$})}),!U&&s.jsx(Va,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),s.jsx(Qs,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},title:m("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:m("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),ke.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:ke.map((Y,le)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:Y})]},le))})]}),confirmText:m("删除"),variant:"danger",isLoading:o})]})}function Yr({label:e}){return s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:e})]})}var Gg=Object.defineProperty,ur=Object.getOwnPropertySymbols,al=Object.prototype.hasOwnProperty,ll=Object.prototype.propertyIsEnumerable,vo=(e,t,r)=>t in e?Gg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,li=(e,t)=>{for(var r in t||(t={}))al.call(t,r)&&vo(e,r,t[r]);if(ur)for(var r of ur(t))ll.call(t,r)&&vo(e,r,t[r]);return e},ci=(e,t)=>{var r={};for(var o in e)al.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ur)for(var o of ur(e))t.indexOf(o)<0&&ll.call(e,o)&&(r[o]=e[o]);return r};var Vt;(e=>{const t=class Se{constructor(n,c,f,l){if(this.version=n,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],n<Se.MIN_VERSION||n>Se.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=n*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 b=this.addEccAndInterleave(f);if(this.drawCodewords(b),l==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const a=this.getPenaltyScore();a<y&&(l=_,y=a),this.applyMask(_)}}m(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(n,c){const f=e.QrSegment.makeSegments(n);return Se.encodeSegments(f,c)}static encodeBinary(n,c){const f=e.QrSegment.makeBytes(n);return Se.encodeSegments([f],c)}static encodeSegments(n,c,f=1,l=40,g=-1,b=!0){if(!(Se.MIN_VERSION<=f&&f<=l&&l<=Se.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,_;for(y=f;;y++){const u=Se.getNumDataCodewords(y,c)*8,x=v.getTotalBits(n,y);if(x<=u){_=x;break}if(y>=l)throw new RangeError("Data too long")}for(const u of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])b&&_<=Se.getNumDataCodewords(y,u)*8&&(c=u);let a=[];for(const u of n){r(u.mode.modeBits,4,a),r(u.numChars,u.mode.numCharCountBits(y),a);for(const x of u.getData())a.push(x)}m(a.length==_);const h=Se.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 u=236;a.length<h;u^=253)r(u,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((u,x)=>d[x>>>3]|=u<<7-(x&7)),new Se(y,c,d,g)}getModule(n,c){return 0<=n&&n<this.size&&0<=c&&c<this.size&&this.modules[c][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),c=n.length;for(let f=0;f<c;f++)for(let l=0;l<c;l++)f==0&&l==0||f==0&&l==c-1||f==c-1&&l==0||this.drawAlignmentPattern(n[f],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const c=this.errorCorrectionLevel.formatBits<<3|n;let f=c;for(let g=0;g<10;g++)f=f<<1^(f>>>9)*1335;const l=(c<<10|f)^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 n=this.version;for(let f=0;f<12;f++)n=n<<1^(n>>>11)*7973;const c=this.version<<12|n;m(c>>>18==0);for(let f=0;f<18;f++){const l=o(c,f),g=this.size-11+f%3,b=Math.floor(f/3);this.setFunctionModule(g,b,l),this.setFunctionModule(b,g,l)}}drawFinderPattern(n,c){for(let f=-4;f<=4;f++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(f)),b=n+l,y=c+f;0<=b&&b<this.size&&0<=y&&y<this.size&&this.setFunctionModule(b,y,g!=2&&g!=4)}}drawAlignmentPattern(n,c){for(let f=-2;f<=2;f++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,c+f,Math.max(Math.abs(l),Math.abs(f))!=1)}setFunctionModule(n,c,f){this.modules[c][n]=f,this.isFunction[c][n]=!0}addEccAndInterleave(n){const c=this.version,f=this.errorCorrectionLevel;if(n.length!=Se.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const l=Se.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],g=Se.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],b=Math.floor(Se.getNumRawDataModules(c)/8),y=l-b%l,_=Math.floor(b/l);let a=[];const h=Se.reedSolomonComputeDivisor(g);for(let u=0,x=0;u<l;u++){let S=n.slice(x,x+_-g+(u<y?0:1));x+=S.length;const k=Se.reedSolomonComputeRemainder(S,h);u<y&&S.push(0),a.push(S.concat(k))}let d=[];for(let u=0;u<a[0].length;u++)a.forEach((x,S)=>{(u!=_-g||S>=y)&&d.push(x[u])});return m(d.length==b),d}drawCodewords(n){if(n.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const b=f-g,_=(f+1&2)==0?this.size-1-l:l;!this.isFunction[_][b]&&c<n.length*8&&(this.modules[_][b]=o(n[c>>>3],7-(c&7)),c++)}}m(c==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let l;switch(n){case 0:l=(f+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=f%3==0;break;case 3:l=(f+c)%3==0;break;case 4:l=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:l=f*c%2+f*c%3==0;break;case 6:l=(f*c%2+f*c%3)%2==0;break;case 7:l=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&l&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let b=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==b?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),b||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),b=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(b,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size;g++){let b=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==b?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),b||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),b=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(b,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let b=0;b<this.size-1;b++){const y=this.modules[g][b];y==this.modules[g][b+1]&&y==this.modules[g+1][b]&&y==this.modules[g+1][b+1]&&(n+=Se.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((b,y)=>b+(y?1:0),c);const f=this.size*this.size,l=Math.ceil(Math.abs(c*20-f*10)/f)-1;return m(0<=l&&l<=9),n+=l*Se.PENALTY_N4,m(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let f=[6];for(let l=this.size-7;f.length<n;l-=c)f.splice(1,0,l);return f}}static getNumRawDataModules(n){if(n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*n+128)*n+64;if(n>=2){const f=Math.floor(n/7)+2;c-=(25*f-10)*f-55,n>=7&&(c-=36)}return m(208<=c&&c<=29648),c}static getNumDataCodewords(n,c){return Math.floor(Se.getNumRawDataModules(n)/8)-Se.ECC_CODEWORDS_PER_BLOCK[c.ordinal][n]*Se.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let c=[];for(let l=0;l<n-1;l++)c.push(0);c.push(1);let f=1;for(let l=0;l<n;l++){for(let g=0;g<c.length;g++)c[g]=Se.reedSolomonMultiply(c[g],f),g+1<c.length&&(c[g]^=c[g+1]);f=Se.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(n,c){let f=c.map(l=>0);for(const l of n){const g=l^f.shift();f.push(0),c.forEach((b,y)=>f[y]^=Se.reedSolomonMultiply(b,g))}return f}static reedSolomonMultiply(n,c){if(n>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let l=7;l>=0;l--)f=f<<1^(f>>>7)*285,f^=(c>>>l&1)*n;return m(f>>>8==0),f}finderPenaltyCountPatterns(n){const c=n[1];m(c<=this.size*3);const f=c>0&&n[2]==c&&n[3]==c*3&&n[4]==c&&n[5]==c;return(f&&n[0]>=c*4&&n[6]>=c?1:0)+(f&&n[6]>=c*4&&n[0]>=c?1:0)}finderPenaltyTerminateAndCount(n,c,f){return n&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(n,c){c[0]==0&&(n+=this.size),c.pop(),c.unshift(n)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function r(i,n,c){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let f=n-1;f>=0;f--)c.push(i>>>f&1)}function o(i,n){return(i>>>n&1)!=0}function m(i){if(!i)throw new Error("Assertion error")}const p=class Ze{constructor(n,c,f){if(this.mode=n,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(n){let c=[];for(const f of n)r(f,8,c);return new Ze(Ze.Mode.BYTE,n.length,c)}static makeNumeric(n){if(!Ze.isNumeric(n))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<n.length;){const l=Math.min(n.length-f,3);r(parseInt(n.substring(f,f+l),10),l*3+1,c),f+=l}return new Ze(Ze.Mode.NUMERIC,n.length,c)}static makeAlphanumeric(n){if(!Ze.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=n.length;f+=2){let l=Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f))*45;l+=Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f+1)),r(l,11,c)}return f<n.length&&r(Ze.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f)),6,c),new Ze(Ze.Mode.ALPHANUMERIC,n.length,c)}static makeSegments(n){return n==""?[]:Ze.isNumeric(n)?[Ze.makeNumeric(n)]:Ze.isAlphanumeric(n)?[Ze.makeAlphanumeric(n)]:[Ze.makeBytes(Ze.toUtf8ByteArray(n))]}static makeEci(n){let c=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,c);else if(n<16384)r(2,2,c),r(n,14,c);else if(n<1e6)r(6,3,c),r(n,21,c);else throw new RangeError("ECI assignment value out of range");return new Ze(Ze.Mode.ECI,0,c)}static isNumeric(n){return Ze.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return Ze.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,c){let f=0;for(const l of n){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;f+=4+g+l.bitData.length}return f}static toUtf8ByteArray(n){n=encodeURI(n);let c=[];for(let f=0;f<n.length;f++)n.charAt(f)!="%"?c.push(n.charCodeAt(f)):(c.push(parseInt(n.substring(f+1,f+3),16)),f+=2);return c}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(Vt||(Vt={}));(e=>{(t=>{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),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(Vt||(Vt={}));(e=>{(t=>{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]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(Vt||(Vt={}));var ss=Vt;var Qg={L:ss.QrCode.Ecc.LOW,M:ss.QrCode.Ecc.MEDIUM,Q:ss.QrCode.Ecc.QUARTILE,H:ss.QrCode.Ecc.HIGH},cl=128,dl="L",ul="#FFFFFF",hl="#000000",fl=!1,ml=1,Zg=4,Jg=0,ev=.1;function pl(e,t=0){const r=[];return e.forEach(function(o,m){let p=null;o.forEach(function(v,i){if(!v&&p!==null){r.push(`M${p+t} ${m+t}h${i-p}v1H${p+t}z`),p=null;return}if(i===o.length-1){if(!v)return;p===null?r.push(`M${i+t},${m+t} h1v1H${i+t}z`):r.push(`M${p+t},${m+t} h${i+1-p}v1H${p+t}z`);return}v&&p===null&&(p=i)})}),r.join("")}function gl(e,t){return e.slice().map((r,o)=>o<t.y||o>=t.y+t.h?r:r.map((m,p)=>p<t.x||p>=t.x+t.w?m:!1))}function tv(e,t,r,o){if(o==null)return null;const m=e.length+r*2,p=Math.floor(t*ev),v=m/t,i=(o.width||p)*v,n=(o.height||p)*v,c=o.x==null?e.length/2-i/2:o.x*v,f=o.y==null?e.length/2-n/2:o.y*v,l=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let y=Math.floor(c),_=Math.floor(f),a=Math.ceil(i+c-y),h=Math.ceil(n+f-_);g={x:y,y:_,w:a,h}}const b=o.crossOrigin;return{x:c,y:f,h:n,w:i,excavation:g,opacity:l,crossOrigin:b}}function sv(e,t){return t!=null?Math.max(Math.floor(t),0):e?Zg:Jg}function vl({value:e,level:t,minVersion:r,includeMargin:o,marginSize:m,imageSettings:p,size:v,boostLevel:i}){let n=ie.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,a)=>(_.push(...ss.QrSegment.makeSegments(a)),_),[]);return ss.QrCode.encodeSegments(y,Qg[t],r,void 0,void 0,i)},[e,t,r,i]);const{cells:c,margin:f,numCells:l,calculatedImageSettings:g}=ie.useMemo(()=>{let b=n.getModules();const y=sv(o,m),_=b.length+y*2,a=tv(b,v,y,p);return{cells:b,margin:y,numCells:_,calculatedImageSettings:a}},[n,v,p,o,m]);return{qrcode:n,margin:f,cells:c,numCells:l,calculatedImageSettings:g}}var rv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),iv=ie.forwardRef(function(t,r){const o=t,{value:m,size:p=cl,level:v=dl,bgColor:i=ul,fgColor:n=hl,includeMargin:c=fl,minVersion:f=ml,boostLevel:l,marginSize:g,imageSettings:b}=o,_=ci(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=_,h=ci(_,["style"]),d=b?.src,u=ie.useRef(null),x=ie.useRef(null),S=ie.useCallback(D=>{u.current=D,typeof r=="function"?r(D):r&&(r.current=D)},[r]),[k,E]=ie.useState(!1),{margin:w,cells:j,numCells:T,calculatedImageSettings:L}=vl({value:m,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:b,size:p});ie.useEffect(()=>{if(u.current!=null){const D=u.current,I=D.getContext("2d");if(!I)return;let F=j;const z=x.current,A=L!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&L.excavation!=null&&(F=gl(j,L.excavation));const P=window.devicePixelRatio||1;D.height=D.width=p*P;const O=p/T*P;I.scale(O,O),I.fillStyle=i,I.fillRect(0,0,T,T),I.fillStyle=n,rv?I.fill(new Path2D(pl(F,w))):j.forEach(function(B,W){B.forEach(function(V,Q){V&&I.fillRect(Q+w,W+w,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(z,L.x+w,L.y+w,L.w,L.h)}}),ie.useEffect(()=>{E(!1)},[d]);const N=li({height:p,width:p},a);let R=null;return d!=null&&(R=ie.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:x,crossOrigin:L?.crossOrigin})),ie.createElement(ie.Fragment,null,ie.createElement("canvas",li({style:N,height:p,width:p,ref:S,role:"img"},h)),R)});iv.displayName="QRCodeCanvas";var _l=ie.forwardRef(function(t,r){const o=t,{value:m,size:p=cl,level:v=dl,bgColor:i=ul,fgColor:n=hl,includeMargin:c=fl,minVersion:f=ml,boostLevel:l,title:g,marginSize:b,imageSettings:y}=o,_=ci(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:u}=vl({value:m,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:b,imageSettings:y,size:p});let x=h,S=null;y!=null&&u!=null&&(u.excavation!=null&&(x=gl(h,u.excavation)),S=ie.createElement("image",{href:y.src,height:u.h,width:u.w,x:u.x+a,y:u.y+a,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const k=pl(x,a);return ie.createElement("svg",li({height:p,width:p,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},_),!!g&&ie.createElement("title",null,g),ie.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ie.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),S)});_l.displayName="QRCodeSVG";function xl(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function nv(){return bt({queryKey:de.tunnel.status,queryFn:()=>ge.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function ov(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/start",{port:xl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function av(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/regenerate",{port:xl()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function lv(){const e=Ge();return ht({mutationFn:()=>ge.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function cv(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Share via tunnel",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 dv(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 uv(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 _o(e){if(!e)return"Never";const t=new Date(e).getTime();if(!Number.isFinite(t))return e;const r=Math.max(0,Math.round((Date.now()-t)/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 gs(e){const t=e?.trim();return t||null}function hv(e){if(!e)return"";const t=[gs(e.lastLocalError),gs(e.lastRemoteError),gs(e.lastError)].filter(m=>m!==null),r=gs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!gs(e.lastError));return r&&o&&t.push(r),t.join(`
|
|
86
|
+
`)}function xo(){const{t:e}=ae(),{data:t}=nv(),r=ov(),o=lv(),m=av(),[p,v]=C.useState(!1),[i,n]=C.useState(null),c=C.useRef(null),[f,l]=C.useState({top:0,right:0}),[g,b]=C.useState(!1),[y,_]=C.useState(!1),a=t?.status!==void 0&&t.status!=="stopped",h=r.isPending||t?.status==="starting",d=m.isPending,u=t?.shareableUrl,x=t?.token,S=cv(t),k=dv(t),E=hv(t);C.useEffect(()=>{if(p&&c.current){const R=c.current.getBoundingClientRect();l({top:R.bottom+8,right:window.innerWidth-R.right})}},[p]);const w=C.useCallback(()=>{a?v(!0):r.mutate(void 0,{onSuccess:()=>v(!0)})},[a,r]),j=C.useCallback(()=>{u&&(navigator.clipboard.writeText(u),n("url"),setTimeout(()=>n(null),2e3))},[u]),T=C.useCallback(()=>{x&&(navigator.clipboard.writeText(x),n("token"),setTimeout(()=>n(null),2e3))},[x]),L=C.useCallback(()=>{o.mutate(),v(!1),b(!1),_(!1)},[o]),N=C.useCallback(()=>{m.mutate(void 0,{onSuccess:()=>{_(!1),v(!0)}})},[m]);return s.jsxs("div",{className:"relative",children:[s.jsx("button",{ref:c,onClick:w,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?s.jsx($e,{size:16,className:"animate-spin"}):S.icon==="warn"?s.jsx(Si,{size:16}):s.jsx(xi,{size:16})}),a&&!h&&s.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),p&&a&&qt.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),s.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:f.top,right:f.right},children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{children:[s.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${t?.status==="healthy"||t?.status==="checking"?"text-emerald-600":t?.status==="exited"||t?.status==="error"?"text-red-600":"text-amber-600"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(k)]}),s.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(uv(t))})]}),s.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:s.jsx(Wt,{size:14})})]}),x&&s.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:[s.jsx(nd,{size:12}),s.jsx("span",{children:e("Token protected")})]}),u&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(_l,{value:u,size:160})}),u||t?.url?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{readOnly:!0,value:u??t?.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:R=>R.target.select()}),s.jsx("button",{onClick:j,disabled:!u,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:i==="url"?s.jsx(Rt,{size:14,className:"text-emerald-500"}):s.jsx(vn,{size:14})})]}):s.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")}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:_o(t?.lastCheckedAt)})]}),s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:_o(t?.lastHealthyAt)})]})]}),E&&s.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}),t?.status==="degraded"&&s.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.")}),t?.status==="linkReplaced"&&s.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.")}),x&&s.jsxs("div",{className:"mt-2",children:[s.jsx("button",{onClick:()=>b(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.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:x}),s.jsx("button",{onClick:T,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:i==="token"?s.jsx(Rt,{size:14,className:"text-emerald-500"}):s.jsx(vn,{size:14})})]})]}),y&&s.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[s.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx("button",{onClick:()=>_(!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")}),s.jsx("button",{onClick:N,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&&s.jsxs("button",{onClick:()=>_(!0),disabled:d||t?.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:[s.jsx(Ri,{size:13}),e("Regenerate link")]}),s.jsx("button",{onClick:L,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 Gr({isOpen:e,onClose:t}){const{t:r}=ae(),o=oc(),[m,p]=C.useState(""),[v,i]=C.useState(""),[n,c]=C.useState(null),[f,l]=C.useState(!1),[g,b]=C.useState(!1),y=m.trim(),_=v.trim(),a=f||o.isPending,h=C.useMemo(()=>!!(y&&_&&!a),[y,_,a]),d=C.useCallback(()=>{p(""),i(""),c(null),b(!1)},[]),u=C.useCallback(()=>{a||(d(),t())},[a,t,d]);C.useEffect(()=>{e||d()},[e,d]);const x=C.useCallback(async E=>{try{await o.mutateAsync({name:y,repoPath:_,initEmptyRepo:E}),d(),t()}catch(w){const j=w instanceof Error?w.message:r("Failed to create project");c(j),is.error(j)}},[o,t,d,r,y,_]),S=C.useCallback(async()=>{if(!(!y||!_||a)){c(null),l(!0);try{const E=await ge.get("/filesystem/validate",{params:{path:_}});if(E.valid){await x(!1);return}if(E.reason==="no_git"&&E.isEmpty){b(!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)}}},[x,a,r,y,_]),k=C.useCallback(()=>{b(!1),x(!0)},[x]);return s.jsxs(s.Fragment,{children:[s.jsx(Rs,{isOpen:e,onClose:u,title:r("Create New Project"),action:s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:u,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),s.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:f?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),s.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),s.jsx(ac,{value:v,onChange:i,validationMode:"directory"})]}),n&&s.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),s.jsx(Qs,{isOpen:g,onClose:()=>{o.isPending||b(!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 bo={idle:"Create & Start","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},yo=C.lazy(()=>tc(()=>import("./modal-kzH1vcBa.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),So=s.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),fv=260,mv=600,wo=400,pv=100,Qr=1e3;function Dv(){const{t:e}=ae(),[t,r]=C.useState(null),[o,m]=C.useState(null),[p,v]=C.useState(wo),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(""),[b,y]=C.useState(""),[_,a]=C.useState(""),[h,d]=C.useState(""),[u,x]=C.useState("SOLO"),[S,k]=C.useState("AUTO"),[E,w]=C.useState(null),[j,T]=C.useState([]),[L,N]=C.useState(null),[R,D]=C.useState(null),[I,F]=C.useState("idle"),{files:z,addFiles:A,removeFile:P,clear:O,buildMarkdownLinks:B,isUploading:W}=xr(),V=C.useRef(null),Q=C.useRef(!1),Z=C.useRef(0),he=C.useRef(wo),M=C.useRef(null),H=Ge(),{data:U,isLoading:$}=Ts(),{data:se,isLoading:K}=lc({limit:pv}),ce=C.useMemo(()=>se?.data??[],[se?.data]),pe=C.useMemo(()=>ce.map(Ng),[ce]),xe=o&&ce.some(q=>q.id===o)?o:null,{data:De,isLoading:ne}=I0(xe??"",{limit:Qr}),_e=hc({queries:xe?[]:ce.map(q=>({queryKey:de.tasks.list(q.id,{limit:Qr}),queryFn:()=>ge.get(`/projects/${q.id}/tasks`,{params:{limit:String(Qr)}})}))}),He=!xe&&_e.some(q=>q.isLoading),we=C.useMemo(()=>{if(xe)return De?.data??[];const q=[];for(const re of _e)re.data?.data&&q.push(...re.data.data);return q},[xe,De,_e]),Le=t&&we.some(q=>q.id===t)?t:null,ke=C.useMemo(()=>{const q=new Map;for(const re of we){const me=re.createdAt?new Date(re.createdAt).getTime():0,ue=q.get(re.projectId)??0;me>ue&&q.set(re.projectId,me)}return[...ce].sort((re,me)=>{const ue=q.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(q.get(me.id)??(me.createdAt?new Date(me.createdAt).getTime():0))-ue})},[ce,we]),Ee=C.useMemo(()=>ke.filter(q=>!q.archivedAt),[ke]),Ue=C.useMemo(()=>{if(!U)return[];const q=localStorage.getItem("providerUsageCount"),re=q?JSON.parse(q):{};return[...U].sort((me,ue)=>{const Be=me.availability.type!=="NOT_FOUND",Re=ue.availability.type!=="NOT_FOUND";if(Be!==Re)return Be?-1:1;const pt=re[me.provider.id]??0;return(re[ue.provider.id]??0)-pt})},[U]),be=C.useMemo(()=>we.map(Rg),[we]),Je=C.useMemo(()=>new Set,[]),Ce=C.useMemo(()=>{if(!Le)return null;const q=we.find(me=>me.id===Le);if(!q)return null;const re=ce.find(me=>me.id===q.projectId);if(!re){const me=q.workspaces?.find(ue=>ue.status==="ACTIVE")?.branchName??q.workspaces?.[0]?.branchName??"—";return{id:q.id,projectId:q.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:q.title,status:Xi(q.status),branch:me,mainBranch:"main",description:q.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return Tg(q,re)},[Le,we,ce]),Ne=B0(_),tt=jo(),X=z0(),J=F0(),ee=C.useCallback(q=>{X.mutate(q,{onSuccess:()=>{Le===q&&r(null),H.invalidateQueries({queryKey:de.tasks.all})}})},[X,Le,H]),fe=C.useCallback((q,re)=>{J.mutate({id:q,status:Eg(re)},{onError:()=>{is.error(e("状态变更失败,该操作不被允许"))}})},[J,e]),qe=C.useCallback(q=>{q.preventDefault(),Q.current=!0,Z.current=q.clientX,he.current=p,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[p]);C.useEffect(()=>{const q=me=>{if(!Q.current)return;const ue=me.clientX-Z.current,Be=Math.max(fv,Math.min(mv,he.current+ue));v(Be)},re=()=>{Q.current&&(Q.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",re)}},[]);const Ae=C.useCallback(()=>{n(!0)},[]),Ve=C.useCallback(()=>{if(Ee.length===0){is.error(e("没有可用项目,请先创建或恢复项目"));return}const q=localStorage.getItem("lastSelectedProjectId"),re=localStorage.getItem("lastSelectedProviderId"),me=q&&Ee.find(Re=>Re.id===q)?q:(xe&&Ee.find(Re=>Re.id===xe)?.id)??Ee[0]?.id??"";a(me);const ue=Ue?.find(Re=>Re.availability.type!=="NOT_FOUND"),Be=re&&Ue?.find(Re=>Re.provider.id===re&&Re.availability.type!=="NOT_FOUND")?re:ue?.provider.id??"";d(Be),x("SOLO"),k("AUTO"),w(null),T([]),N(null),D(null),F("idle"),f(!0)},[Ee,xe,Ue,e]),nt=C.useCallback(()=>{n(!1)},[]),Fe=C.useCallback(()=>{I==="idle"&&(f(!1),g(""),y(""),a(""),d(""),x("SOLO"),k("AUTO"),w(null),T([]),N(null),D(null),F("idle"),O())},[I,O]),yt=qi(),Qe=C.useCallback(async()=>{const q=!!l.trim()&&!!_,re=u==="TEAM"&&L!==null;if(u==="TEAM"&&!E&&j.length===0){D(e("请选择至少一个团队模板或成员预设。"));return}if(u==="TEAM"){if(!re&&!q)return}else if(!q)return;try{D(null);const me=B(),ue=[b.trim(),me].filter(Boolean).join(`
|
|
87
87
|
|
|
88
|
-
`);let Be=L;if(!Be){F("creating-task");const
|
|
88
|
+
`);let Be=L;if(!Be){F("creating-task");const Re=await Ne.mutateAsync({title:l.trim(),description:ue||void 0});if(Be=Re.id,N(Re.id),localStorage.setItem("lastSelectedProjectId",_),u==="SOLO"&&h){localStorage.setItem("lastSelectedProviderId",h);const pt=localStorage.getItem("providerUsageCount"),Lt=pt?JSON.parse(pt):{};Lt[h]=(Lt[h]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Lt))}}if(u==="TEAM"){const Re=j;F("creating-teamrun"),await tt.mutateAsync({taskId:Be,mode:S,...E?{teamTemplateId:E}:{},...Re.length>0?{memberPresetIds:Re}:{}}),N(null)}else if(h){const Re=[l.trim(),ue].filter(Boolean).join(`
|
|
89
89
|
|
|
90
|
-
`);F("creating-workspace");const pt=await ge.post(`/tasks/${Be}/workspaces`,{});F("creating-session");const
|
|
90
|
+
`);F("creating-workspace");const pt=await ge.post(`/tasks/${Be}/workspaces`,{});F("creating-session");const Lt=await ge.post(`/workspaces/${pt.id}/sessions`,{providerId:h,prompt:Re});F("starting-session"),await yt.mutateAsync(Lt.id),await H.invalidateQueries({queryKey:de.workspaces.list(Be)})}r(Be),F("idle"),f(!1),g(""),y(""),a(""),d(""),x("SOLO"),k("AUTO"),w(null),T([]),N(null),D(null),O()}catch(me){u==="TEAM"&&D(me instanceof Error?me.message:e("创建 TeamRun 失败")),F("idle")}},[l,b,_,h,u,S,E,j,L,Ne,tt,yt,H,B,O,e]),ct=C.useCallback(q=>{const re=q.target.files;re&&re.length>0&&A(Array.from(re)),q.target.value=""},[A]),Me=C.useCallback(q=>{const re=q.clipboardData.items,me=[];for(const ue of re)if(ue.kind==="file"){const Be=ue.getAsFile();Be&&me.push(Be)}me.length>0&&(q.preventDefault(),A(me))},[A]),[Pe,et]=C.useState(!1),ft=C.useCallback(q=>{q.preventDefault(),et(!0)},[]),ot=C.useCallback(q=>{q.preventDefault(),et(!1)},[]),st=C.useCallback(q=>{q.preventDefault(),et(!1);const re=q.dataTransfer.files;re.length>0&&A(Array.from(re))},[A]),Oe=K||ne||He,xt=!!l.trim()&&!!_,Ye=u!=="TEAM"||!!E||j.length>0,mt=I==="idle"&&Ye&&(u==="TEAM"&&L!==null||xt),rt=e(u==="TEAM"&&I==="idle"?"Create TeamRun":bo[I]),Y=s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:Fe,disabled:I!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),s.jsx("button",{onClick:Qe,disabled:!mt,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${mt?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:rt})]}),le=s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-700",children:e("Execution")}),s.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[s.jsx("button",{type:"button",onClick:()=>{I==="idle"&&(x("SOLO"),D(null))},disabled:I!=="idle",className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="SOLO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("Solo Agent")}),s.jsx("button",{type:"button",onClick:()=>{I==="idle"&&(x("TEAM"),D(null))},disabled:I!=="idle",className:te("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="TEAM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("TeamRun")})]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),s.jsx(mn,{value:_,onChange:a,options:Ee.map(q=>({value:q.id,label:q.name})),placeholder:e("Select project..."),disabled:I!=="idle"})]}),u==="SOLO"?s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),s.jsx(mn,{value:h,onChange:d,options:Ue.map(({provider:q,availability:re})=>({value:q.id,label:q.name+(re.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:re.type==="NOT_FOUND"})),placeholder:e($?"Loading...":"Select provider..."),disabled:I!=="idle"})]}):s.jsx("div",{className:"flex-1 min-w-0"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),s.jsx("input",{type:"text",value:l,onChange:q=>g(q.target.value),placeholder:e("e.g., Implement login flow"),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:I!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&Qe()}})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),s.jsxs("div",{className:`relative border rounded-lg transition-colors ${Pe?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:ft,onDragLeave:ot,onDrop:st,children:[s.jsx("textarea",{rows:3,value:b,onChange:q=>y(q.target.value),onPaste:Me,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:I!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&Qe()}}),Pe&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:s.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>V.current?.click(),disabled:I!=="idle"||W,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(hr,{size:14}),e("Attach files")]}),s.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),s.jsx("input",{ref:V,type:"file",multiple:!0,onChange:ct,className:"hidden"}),s.jsx(br,{files:z,onRemove:P})]}),u==="TEAM"&&s.jsxs("div",{className:"space-y-3 border-t border-neutral-100 pt-4",children:[s.jsx(Qa,{mode:S,setMode:k,selectedTemplateId:E,setSelectedTemplateId:w,selectedMemberPresetIds:j,setSelectedMemberPresetIds:T,disabled:I!=="idle"}),R&&s.jsx("p",{className:"text-xs text-red-500",children:R})]}),Ne.isError&&s.jsx("p",{className:"text-xs text-red-500",children:Ne.error instanceof Error?Ne.error.message:e("Failed to create task")})]});return na()?Le&&Ce?s.jsxs(s.Fragment,{children:[s.jsx(Yg,{task:Ce,onBack:()=>r(null),onDeleteTask:Ce.projectArchivedAt?void 0:ee,isDeleting:X.isPending}),s.jsx(Gr,{isOpen:i,onClose:nt})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(un,{}),So]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(xo,{}),s.jsx(Ys,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:s.jsx(fn,{size:16})})]})]}),Oe&&be.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):s.jsx(Rn,{tasks:be,projects:pe,selectedTaskId:null,onSelectTask:r,filterProjectId:xe,setFilterProjectId:m,width:"100%",onCreateProject:Ae,onCreateTask:Ve,activeTaskIds:Je,onTaskStatusChange:fe})]}),s.jsxs(C.Suspense,{fallback:null,children:[s.jsx(Gr,{isOpen:i,onClose:nt}),s.jsx(yo,{isOpen:c,onClose:Fe,title:e("Create New Task"),className:u==="TEAM"?"max-w-5xl":void 0,action:Y,children:le})]})]}):s.jsxs("div",{ref:M,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(un,{}),So]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(xo,{}),s.jsx(Ys,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:s.jsx(fn,{size:16})})]})]}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Oe&&be.length===0?s.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:p},children:e("Loading...")}):s.jsx(Rn,{tasks:be,projects:pe,selectedTaskId:Le,onSelectTask:r,filterProjectId:xe,setFilterProjectId:m,width:p,onCreateProject:Ae,onCreateTask:Ve,activeTaskIds:Je,onTaskStatusChange:fe,onDeleteTask:ee}),s.jsx("div",{onMouseDown:qe,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),s.jsx(kg,{task:Ce,onDeleteTask:Ce?.projectArchivedAt?void 0:ee,isDeleting:X.isPending,onTaskStatusChange:Ce?.projectArchivedAt?void 0:fe})]}),s.jsxs(C.Suspense,{fallback:null,children:[s.jsx(Gr,{isOpen:i,onClose:nt}),s.jsx(yo,{isOpen:c,onClose:Fe,title:e("Create New Task"),className:u==="TEAM"?"max-w-5xl":void 0,action:Y,children:le})]})]})}export{Dv as ProjectKanbanPage};
|