agent-tower 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/web/assets/{AgentDemoPage-CRvlbWcT.js → AgentDemoPage-JOhI4e6I.js} +1 -1
  2. package/dist/web/assets/{DemoPage-6R4b4Gon.js → DemoPage-D8aqJqYC.js} +1 -1
  3. package/dist/web/assets/{NotificationSettingsPage-CZrEncBT.js → NotificationSettingsPage-Cy6OfcgA.js} +1 -1
  4. package/dist/web/assets/{ProfileSettingsPage-B0NeNKi9.js → ProfileSettingsPage-BdK5AEmX.js} +1 -1
  5. package/dist/web/assets/ProjectKanbanPage-CCNjhk3N.js +85 -0
  6. package/dist/web/assets/{ProjectSettingsPage-Ctv5BWdf.js → ProjectSettingsPage-DHRBIna-.js} +1 -1
  7. package/dist/web/assets/{api-client-JWeNZKcl.js → api-client-BNFthYT3.js} +1 -1
  8. package/dist/web/assets/{chevron-down-DVussag2.js → chevron-down-D4rsLJz9.js} +1 -1
  9. package/dist/web/assets/{circle-alert-CvcZV0Gx.js → circle-alert-omLrIhad.js} +1 -1
  10. package/dist/web/assets/{code-block-OCS4YCEC-ZmRyZGvD.js → code-block-OCS4YCEC-Bg1AT3rl.js} +1 -1
  11. package/dist/web/assets/{folder-picker-B7s6TEGt.js → folder-picker-CGYYkKNV.js} +1 -1
  12. package/dist/web/assets/index-CY7Dhqkb.css +1 -0
  13. package/dist/web/assets/{index-BtJ21Bn6.js → index-avirVIbA.js} +2 -2
  14. package/dist/web/assets/{loader-circle-CZN73-Yt.js → loader-circle-dpFaJTtP.js} +1 -1
  15. package/dist/web/assets/{mermaid-NOHMQCX5-C13e8gYV.js → mermaid-NOHMQCX5-Bg6BeR-E.js} +4 -4
  16. package/dist/web/assets/{modal-D7xekFRe.js → modal-CSGNm99V.js} +1 -1
  17. package/dist/web/assets/{query-keys-C9CBerVg.js → query-keys-CyJt79Op.js} +1 -1
  18. package/dist/web/assets/{select-Dwk13G3M.js → select-BLzIwgqs.js} +1 -1
  19. package/dist/web/assets/{use-profiles-CtLrX0dV.js → use-profiles-BoldotQi.js} +1 -1
  20. package/dist/web/assets/{use-projects-CVQDuqNr.js → use-projects-DDzxS25T.js} +1 -1
  21. package/dist/web/assets/{x-4BBJo9pY.js → x-CVtKmQkK.js} +1 -1
  22. package/dist/web/index.html +2 -2
  23. package/package.json +1 -1
  24. package/dist/web/assets/ProjectKanbanPage-BM6rclOk.js +0 -83
  25. package/dist/web/assets/index-uPUZpEZk.css +0 -1
@@ -1,83 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-D7xekFRe.js","assets/index-BtJ21Bn6.js","assets/index-uPUZpEZk.css","assets/api-client-JWeNZKcl.js","assets/x-4BBJo9pY.js","assets/folder-picker-B7s6TEGt.js","assets/mermaid-NOHMQCX5-C13e8gYV.js","assets/chevron-down-DVussag2.js","assets/mermaid-NOHMQCX5-lI9o3AWT.css","assets/loader-circle-CZN73-Yt.js","assets/circle-alert-CvcZV0Gx.js","assets/use-projects-CVQDuqNr.js","assets/query-keys-C9CBerVg.js"])))=>i.map(i=>d[i]);
2
- import{y as jr,z as So,A as yo,a as Co,q as Qs,d as wo,B as Eo,u as Te,r as R,n as ko,c as ue,R as Z,D as _t,j as c,s as ot,S as Oe,C as rt,i as cr,g as hr,E as Ro,G as Do,L as Mr,_ as Ii}from"./index-BtJ21Bn6.js";import{Q as ur,b as Lo,c as Ao,e as To,d as jo,f as Mo,s as Nr,g as Pr,w as No,h as Po,i as Oo,a as Ue,q as le,u as nt}from"./query-keys-C9CBerVg.js";import{C as gt,h as dr,b as fr,d as pr,c as mr,i as vr,G as _s,u as Fi,a as Hi,e as zi,T as Wi,P as $i,f as Ui,S as Or}from"./mermaid-NOHMQCX5-C13e8gYV.js";import{C as dt,a as as}from"./chevron-down-DVussag2.js";import{P as Zs,X as bs}from"./x-4BBJo9pY.js";import{a as he,c as me,B as it}from"./api-client-JWeNZKcl.js";import{F as Bo,a as Io,c as Fo,u as Ho,d as zo}from"./use-projects-CVQDuqNr.js";import{L as Ae}from"./loader-circle-CZN73-Yt.js";import{M as xs,T as qi}from"./modal-D7xekFRe.js";import{S as es}from"./select-Dwk13G3M.js";var Wo=class extends ur{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:jr()})}getOptimisticResult(e){return e.behavior=jr(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,a=super.createResult(e,t),{isFetching:m,isRefetching:b,isError:C,isRefetchError:r}=a,i=s.fetchMeta?.fetchMore?.direction,l=C&&i==="forward",d=m&&i==="forward",o=C&&i==="backward",p=m&&i==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yo(t,s.data),hasPreviousPage:So(t,s.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:o,isFetchingPreviousPage:p,isRefetchError:r&&!l&&!o,isRefetching:b&&!d&&!p}}};function Br(e,t){const s=new Set(t);return e.filter(a=>!s.has(a))}function $o(e,t,s){const a=e.slice(0);return a[t]=s,a}var Uo=class extends Co{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,s){super(),this.#r=e,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,Qs.batch(()=>{const s=this.#t,a=this.#d(this.#i);a.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const m=a.map(d=>d.observer),b=m.map(d=>d.getCurrentResult()),C=s.length!==m.length,r=m.some((d,o)=>d!==s[o]),i=C||r,l=i?!0:b.some((d,o)=>{const p=this.#e[o];return!p||!wo(d,p)});!i&&!l||(i&&(this.#c=a,this.#t=m),this.#e=b,this.hasListeners()&&(i&&(Br(s,m).forEach(d=>{d.destroy()}),Br(m,s).forEach(d=>{d.subscribe(o=>{this.#f(d,o)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#d(e),a=s.map(b=>b.observer.getOptimisticResult(b.defaultedQueryOptions)),m=s.map(b=>b.defaultedQueryOptions.queryHash);return[a,b=>this.#u(b??a,t,m),()=>this.#h(a,s)]}#h(e,t){return t.map((s,a)=>{const m=e[a];return s.defaultedQueryOptions.notifyOnChangeProps?m:s.observer.trackResult(m,b=>{t.forEach(C=>{C.observer.trackProp(b)})})})}#u(e,t,s){if(t){const a=this.#l,m=s!==void 0&&a!==void 0&&(a.length!==s.length||s.some((b,C)=>b!==a[C]));return(!this.#s||this.#e!==this.#a||m||t!==this.#o)&&(this.#o=t,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Eo(this.#s,t(e))),this.#s}return e}#d(e){const t=new Map;this.#t.forEach(a=>{const m=a.options.queryHash;if(!m)return;const b=t.get(m);b?b.push(a):t.set(m,[a])});const s=[];return e.forEach(a=>{const m=this.#r.defaultQueryOptions(a),C=t.get(m.queryHash)?.shift()??new ur(this.#r,m);s.push({defaultedQueryOptions:m,observer:C})}),s}#f(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=$o(this.#e,s,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#s,t=this.#h(this.#e,this.#c),s=this.#u(t,this.#n?.combine);e!==s&&Qs.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function qo({queries:e,...t},s){const a=Te(),m=Lo(),b=Ao(),C=R.useMemo(()=>e.map(g=>{const n=a.defaultQueryOptions(g);return n._optimisticResults=m?"isRestoring":"optimistic",n}),[e,a,m]);C.forEach(g=>{To(g);const n=a.getQueryCache().get(g.queryHash);jo(g,b,n)}),Mo(b);const[r]=R.useState(()=>new Uo(a,C,t)),[i,l,d]=r.getOptimisticResult(C,t.combine),o=!m&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(g=>o?r.subscribe(Qs.batchCalls(g)):ko,[r,o]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),R.useEffect(()=>{r.setQueries(C,t)},[C,t,r]);const _=i.some((g,n)=>Nr(C[n],g))?i.flatMap((g,n)=>{const f=C[n];if(f){const h=new ur(a,f);if(Nr(f,g))return Pr(f,h,b);No(g,m)&&Pr(f,h,b)}return[]}):[];if(_.length>0)throw Promise.all(_);const y=i.find((g,n)=>{const f=C[n];return f&&Po({result:g,errorResetBoundary:b,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(y?.error)throw y.error;return l(d())}function Ki(e,t){return Oo(e,Wo)}const Ko=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Xi=ue("arrow-down",Ko);const Xo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Yi=ue("arrow-right",Xo);const Yo=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Vi=ue("arrow-up",Yo);const Vo=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ir=ue("circle-check-big",Vo);const Go=[["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"}]],Ss=ue("code-xml",Go);const Qo=[["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"}]],Fr=ue("copy",Qo);const Zo=[["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"}]],Gi=ue("ellipsis-vertical",Zo);const Jo=[["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"}]],ea=ue("file-braces-corner",Jo);const ta=[["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"}]],Ht=ue("file-code-corner",ta);const sa=[["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"}]],ra=ue("file-exclamation-point",sa);const ia=[["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"}]],Qi=ue("file-text",ia);const na=[["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"}]],Zi=ue("folder-open",na);const oa=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],aa=ue("gauge",oa);const la=[["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"}]],ca=ue("git-branch",la);const ha=[["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"}]],ua=ue("git-fork",ha);const da=[["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"}]],zt=ue("git-graph",da);const fa=[["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"}]],Ji=ue("git-merge",fa);const pa=[["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"}]],Ct=ue("history",pa);const ma=[["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"}]],gr=ue("image",ma);const va=[["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"}]],Hr=ue("layers",va);const ga=[["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"}]],_a=ue("maximize",ga);const ba=[["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"}]],xa=ue("message-square",ba);const Sa=[["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"}]],ya=ue("panel-left-close",Sa);const Ca=[["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"}]],wa=ue("panel-left-open",Ca);const Ea=[["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"}]],ka=ue("panel-right-close",Ea);const Ra=[["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"}]],Da=ue("panel-right-open",Ra);const La=[["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"}]],St=ue("play",La);const Aa=[["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"}]],Ta=ue("refresh-cw",Aa);const ja=[["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"}]],Ma=ue("shield",ja);const Na=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ls=ue("terminal",Na);const Pa=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],_r=ue("triangle-alert",Pa);const Oa=[["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"}]],Ba=ue("zap",Oa);const Ia=[["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"}]],Fa=ue("zoom-in",Ia);const Ha=[["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"}]],za=ue("zoom-out",Ha),ys=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function wt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function br(e){return"nodeType"in e}function $e(e){var t,s;return e?wt(e)?e:br(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function xr(e){const{Document:t}=$e(e);return e instanceof t}function Kt(e){return wt(e)?!1:e instanceof $e(e).HTMLElement}function en(e){return e instanceof $e(e).SVGElement}function Et(e){return e?wt(e)?e.document:br(e)?xr(e)?e:Kt(e)||en(e)?e.ownerDocument:document:document:document}const at=ys?R.useLayoutEffect:R.useEffect;function Cs(e){const t=R.useRef(e);return at(()=>{t.current=e}),R.useCallback(function(){for(var s=arguments.length,a=new Array(s),m=0;m<s;m++)a[m]=arguments[m];return t.current==null?void 0:t.current(...a)},[])}function Wa(){const e=R.useRef(null),t=R.useCallback((a,m)=>{e.current=setInterval(a,m)},[]),s=R.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Wt(e,t){t===void 0&&(t=[e]);const s=R.useRef(e);return at(()=>{s.current!==e&&(s.current=e)},t),s}function Xt(e,t){const s=R.useRef();return R.useMemo(()=>{const a=e(s.current);return s.current=a,a},[...t])}function cs(e){const t=Cs(e),s=R.useRef(null),a=R.useCallback(m=>{m!==s.current&&t?.(m,s.current),s.current=m},[]);return[s,a]}function hs(e){const t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}let Os={};function ws(e,t){return R.useMemo(()=>{if(t)return t;const s=Os[e]==null?0:Os[e]+1;return Os[e]=s,e+"-"+s},[e,t])}function tn(e){return function(t){for(var s=arguments.length,a=new Array(s>1?s-1:0),m=1;m<s;m++)a[m-1]=arguments[m];return a.reduce((b,C)=>{const r=Object.entries(C);for(const[i,l]of r){const d=b[i];d!=null&&(b[i]=d+e*l)}return b},{...t})}}const yt=tn(1),us=tn(-1);function $a(e){return"clientX"in e&&"clientY"in e}function Sr(e){if(!e)return!1;const{KeyboardEvent:t}=$e(e.target);return t&&e instanceof t}function Ua(e){if(!e)return!1;const{TouchEvent:t}=$e(e.target);return t&&e instanceof t}function ds(e){if(Ua(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return $a(e)?{x:e.clientX,y:e.clientY}:null}const $t=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[$t.Translate.toString(e),$t.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:a}=e;return t+" "+s+"ms "+a}}}),zr="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function qa(e){return e.matches(zr)?e:e.querySelector(zr)}const Ka={display:"none"};function Xa(e){let{id:t,value:s}=e;return Z.createElement("div",{id:t,style:Ka},s)}function Ya(e){let{id:t,announcement:s,ariaLiveType:a="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 Z.createElement("div",{id:t,style:m,role:"status","aria-live":a,"aria-atomic":!0},s)}function Va(){const[e,t]=R.useState("");return{announce:R.useCallback(a=>{a!=null&&t(a)},[]),announcement:e}}const sn=R.createContext(null);function Ga(e){const t=R.useContext(sn);R.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Qa(){const[e]=R.useState(()=>new Set),t=R.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]);return[R.useCallback(a=>{let{type:m,event:b}=a;e.forEach(C=>{var r;return(r=C[m])==null?void 0:r.call(C,b)})},[e]),t]}const Za={draggable:`
3
- To pick up a draggable item, press the space bar.
4
- While dragging, use the arrow keys to move the item.
5
- Press space again to drop the item in its new position, or press escape to cancel.
6
- `},Ja={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function el(e){let{announcements:t=Ja,container:s,hiddenTextDescribedById:a,screenReaderInstructions:m=Za}=e;const{announce:b,announcement:C}=Va(),r=ws("DndLiveRegion"),[i,l]=R.useState(!1);if(R.useEffect(()=>{l(!0)},[]),Ga(R.useMemo(()=>({onDragStart(o){let{active:p}=o;b(t.onDragStart({active:p}))},onDragMove(o){let{active:p,over:_}=o;t.onDragMove&&b(t.onDragMove({active:p,over:_}))},onDragOver(o){let{active:p,over:_}=o;b(t.onDragOver({active:p,over:_}))},onDragEnd(o){let{active:p,over:_}=o;b(t.onDragEnd({active:p,over:_}))},onDragCancel(o){let{active:p,over:_}=o;b(t.onDragCancel({active:p,over:_}))}}),[b,t])),!i)return null;const d=Z.createElement(Z.Fragment,null,Z.createElement(Xa,{id:a,value:m.draggable}),Z.createElement(Ya,{id:r,announcement:C}));return s?_t.createPortal(d,s):d}var Ne;(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"})(Ne||(Ne={}));function fs(){}function tl(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function sl(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return R.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const et=Object.freeze({x:0,y:0});function rl(e,t){const s=ds(e);if(!s)return"0 0";const a={x:(s.x-t.left)/t.width*100,y:(s.y-t.top)/t.height*100};return a.x+"% "+a.y+"%"}function il(e,t){let{data:{value:s}}=e,{data:{value:a}}=t;return a-s}function nl(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function ol(e,t){const s=Math.max(t.top,e.top),a=Math.max(t.left,e.left),m=Math.min(t.left+t.width,e.left+e.width),b=Math.min(t.top+t.height,e.top+e.height),C=m-a,r=b-s;if(a<m&&s<b){const i=t.width*t.height,l=e.width*e.height,d=C*r,o=d/(i+l-d);return Number(o.toFixed(4))}return 0}const al=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:a}=e;const m=[];for(const b of a){const{id:C}=b,r=s.get(C);if(r){const i=ol(r,t);i>0&&m.push({id:C,data:{droppableContainer:b,value:i}})}}return m.sort(il)};function ll(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function rn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:et}function cl(e){return function(s){for(var a=arguments.length,m=new Array(a>1?a-1:0),b=1;b<a;b++)m[b-1]=arguments[b];return m.reduce((C,r)=>({...C,top:C.top+e*r.y,bottom:C.bottom+e*r.y,left:C.left+e*r.x,right:C.right+e*r.x}),{...s})}}const hl=cl(1);function nn(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 ul(e,t,s){const a=nn(t);if(!a)return e;const{scaleX:m,scaleY:b,x:C,y:r}=a,i=e.left-C-(1-m)*parseFloat(s),l=e.top-r-(1-b)*parseFloat(s.slice(s.indexOf(" ")+1)),d=m?e.width/m:e.width,o=b?e.height/b:e.height;return{width:d,height:o,top:l,right:i+d,bottom:l+o,left:i}}const dl={ignoreTransform:!1};function Yt(e,t){t===void 0&&(t=dl);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:l,transformOrigin:d}=$e(e).getComputedStyle(e);l&&(s=ul(s,l,d))}const{top:a,left:m,width:b,height:C,bottom:r,right:i}=s;return{top:a,left:m,width:b,height:C,bottom:r,right:i}}function Wr(e){return Yt(e,{ignoreTransform:!0})}function fl(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function pl(e,t){return t===void 0&&(t=$e(e).getComputedStyle(e)),t.position==="fixed"}function ml(e,t){t===void 0&&(t=$e(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(m=>{const b=t[m];return typeof b=="string"?s.test(b):!1})}function yr(e,t){const s=[];function a(m){if(t!=null&&s.length>=t||!m)return s;if(xr(m)&&m.scrollingElement!=null&&!s.includes(m.scrollingElement))return s.push(m.scrollingElement),s;if(!Kt(m)||en(m)||s.includes(m))return s;const b=$e(e).getComputedStyle(m);return m!==e&&ml(m,b)&&s.push(m),pl(m,b)?s:a(m.parentNode)}return e?a(e):s}function on(e){const[t]=yr(e,1);return t??null}function Bs(e){return!ys||!e?null:wt(e)?e:br(e)?xr(e)||e===Et(e).scrollingElement?window:Kt(e)?e:null:null}function an(e){return wt(e)?e.scrollX:e.scrollLeft}function ln(e){return wt(e)?e.scrollY:e.scrollTop}function Js(e){return{x:an(e),y:ln(e)}}var Be;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Be||(Be={}));function cn(e){return!ys||!e?!1:e===document.scrollingElement}function hn(e){const t={x:0,y:0},s=cn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},m=e.scrollTop<=t.y,b=e.scrollLeft<=t.x,C=e.scrollTop>=a.y,r=e.scrollLeft>=a.x;return{isTop:m,isLeft:b,isBottom:C,isRight:r,maxScroll:a,minScroll:t}}const vl={x:.2,y:.2};function gl(e,t,s,a,m){let{top:b,left:C,right:r,bottom:i}=s;a===void 0&&(a=10),m===void 0&&(m=vl);const{isTop:l,isBottom:d,isLeft:o,isRight:p}=hn(e),_={x:0,y:0},y={x:0,y:0},g={height:t.height*m.y,width:t.width*m.x};return!l&&b<=t.top+g.height?(_.y=Be.Backward,y.y=a*Math.abs((t.top+g.height-b)/g.height)):!d&&i>=t.bottom-g.height&&(_.y=Be.Forward,y.y=a*Math.abs((t.bottom-g.height-i)/g.height)),!p&&r>=t.right-g.width?(_.x=Be.Forward,y.x=a*Math.abs((t.right-g.width-r)/g.width)):!o&&C<=t.left+g.width&&(_.x=Be.Backward,y.x=a*Math.abs((t.left+g.width-C)/g.width)),{direction:_,speed:y}}function _l(e){if(e===document.scrollingElement){const{innerWidth:b,innerHeight:C}=window;return{top:0,left:0,right:b,bottom:C,width:b,height:C}}const{top:t,left:s,right:a,bottom:m}=e.getBoundingClientRect();return{top:t,left:s,right:a,bottom:m,width:e.clientWidth,height:e.clientHeight}}function un(e){return e.reduce((t,s)=>yt(t,Js(s)),et)}function bl(e){return e.reduce((t,s)=>t+an(s),0)}function xl(e){return e.reduce((t,s)=>t+ln(s),0)}function dn(e,t){if(t===void 0&&(t=Yt),!e)return;const{top:s,left:a,bottom:m,right:b}=t(e);on(e)&&(m<=0||b<=0||s>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Sl=[["x",["left","right"],bl],["y",["top","bottom"],xl]];class Cr{constructor(t,s){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 a=yr(s),m=un(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[b,C,r]of Sl)for(const i of C)Object.defineProperty(this,i,{get:()=>{const l=r(a),d=m[b]-l;return this.rect[i]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Pt{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...s)})},this.target=t}add(t,s,a){var m;(m=this.target)==null||m.addEventListener(t,s,a),this.listeners.push([t,s,a])}}function yl(e){const{EventTarget:t}=$e(e);return e instanceof t?e:Et(e)}function Is(e,t){const s=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+a**2)>t:"x"in t&&"y"in t?s>t.x&&a>t.y:"x"in t?s>t.x:"y"in t?a>t.y:!1}var Ve;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Ve||(Ve={}));function $r(e){e.preventDefault()}function Cl(e){e.stopPropagation()}var _e;(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"})(_e||(_e={}));const fn={start:[_e.Space,_e.Enter],cancel:[_e.Esc],end:[_e.Space,_e.Enter,_e.Tab]},wl=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case _e.Right:return{...s,x:s.x+25};case _e.Left:return{...s,x:s.x-25};case _e.Down:return{...s,y:s.y+25};case _e.Up:return{...s,y:s.y-25}}};class pn{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:s}}=t;this.props=t,this.listeners=new Pt(Et(s)),this.windowListeners=new Pt($e(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ve.Resize,this.handleCancel),this.windowListeners.add(Ve.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ve.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,a=t.node.current;a&&dn(a),s(et)}handleKeyDown(t){if(Sr(t)){const{active:s,context:a,options:m}=this.props,{keyboardCodes:b=fn,coordinateGetter:C=wl,scrollBehavior:r="smooth"}=m,{code:i}=t;if(b.end.includes(i)){this.handleEnd(t);return}if(b.cancel.includes(i)){this.handleCancel(t);return}const{collisionRect:l}=a.current,d=l?{x:l.left,y:l.top}:et;this.referenceCoordinates||(this.referenceCoordinates=d);const o=C(t,{active:s,context:a.current,currentCoordinates:d});if(o){const p=us(o,d),_={x:0,y:0},{scrollableAncestors:y}=a.current;for(const g of y){const n=t.code,{isTop:f,isRight:h,isLeft:u,isBottom:v,maxScroll:S,minScroll:w}=hn(g),k=_l(g),x={x:Math.min(n===_e.Right?k.right-k.width/2:k.right,Math.max(n===_e.Right?k.left:k.left+k.width/2,o.x)),y:Math.min(n===_e.Down?k.bottom-k.height/2:k.bottom,Math.max(n===_e.Down?k.top:k.top+k.height/2,o.y))},E=n===_e.Right&&!h||n===_e.Left&&!u,A=n===_e.Down&&!v||n===_e.Up&&!f;if(E&&x.x!==o.x){const j=g.scrollLeft+p.x,T=n===_e.Right&&j<=S.x||n===_e.Left&&j>=w.x;if(T&&!p.y){g.scrollTo({left:j,behavior:r});return}T?_.x=g.scrollLeft-j:_.x=n===_e.Right?g.scrollLeft-S.x:g.scrollLeft-w.x,_.x&&g.scrollBy({left:-_.x,behavior:r});break}else if(A&&x.y!==o.y){const j=g.scrollTop+p.y,T=n===_e.Down&&j<=S.y||n===_e.Up&&j>=w.y;if(T&&!p.x){g.scrollTo({top:j,behavior:r});return}T?_.y=g.scrollTop-j:_.y=n===_e.Down?g.scrollTop-S.y:g.scrollTop-w.y,_.y&&g.scrollBy({top:-_.y,behavior:r});break}}this.handleMove(t,yt(us(o,this.referenceCoordinates),_))}}}handleMove(t,s){const{onMove:a}=this.props;t.preventDefault(),a(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}pn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:a=fn,onActivation:m}=t,{active:b}=s;const{code:C}=e.nativeEvent;if(a.start.includes(C)){const r=b.activatorNode.current;return r&&e.target!==r?!1:(e.preventDefault(),m?.({event:e.nativeEvent}),!0)}return!1}}];function Ur(e){return!!(e&&"distance"in e)}function qr(e){return!!(e&&"delay"in e)}class wr{constructor(t,s,a){var m;a===void 0&&(a=yl(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=s;const{event:b}=t,{target:C}=b;this.props=t,this.events=s,this.document=Et(C),this.documentListeners=new Pt(this.document),this.listeners=new Pt(a),this.windowListeners=new Pt($e(C)),this.initialCoordinates=(m=ds(b))!=null?m:et,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:s,bypassActivationConstraint:a}}}=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(Ve.Resize,this.handleCancel),this.windowListeners.add(Ve.DragStart,$r),this.windowListeners.add(Ve.VisibilityChange,this.handleCancel),this.windowListeners.add(Ve.ContextMenu,$r),this.documentListeners.add(Ve.Keydown,this.handleKeydown),s){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qr(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Ur(s)){this.handlePending(s);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,s){const{active:a,onPending:m}=this.props;m(a,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(Ve.Click,Cl,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ve.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:a,initialCoordinates:m,props:b}=this,{onMove:C,options:{activationConstraint:r}}=b;if(!m)return;const i=(s=ds(t))!=null?s:et,l=us(m,i);if(!a&&r){if(Ur(r)){if(r.tolerance!=null&&Is(l,r.tolerance))return this.handleCancel();if(Is(l,r.distance))return this.handleStart()}if(qr(r)&&Is(l,r.tolerance))return this.handleCancel();this.handlePending(r,l);return}t.cancelable&&t.preventDefault(),C(i)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===_e.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const El={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Er extends wr{constructor(t){const{event:s}=t,a=Et(s.target);super(t,El,a)}}Er.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;return!s.isPrimary||s.button!==0?!1:(a?.({event:s}),!0)}}];const kl={move:{name:"mousemove"},end:{name:"mouseup"}};var er;(function(e){e[e.RightClick=2]="RightClick"})(er||(er={}));class Rl extends wr{constructor(t){super(t,kl,Et(t.event.target))}}Rl.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;return s.button===er.RightClick?!1:(a?.({event:s}),!0)}}];const Fs={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Dl extends wr{constructor(t){super(t,Fs)}static setup(){return window.addEventListener(Fs.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Fs.move.name,t)};function t(){}}}Dl.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:a}=t;const{touches:m}=s;return m.length>1?!1:(a?.({event:s}),!0)}}];var Ot;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ot||(Ot={}));var ps;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ps||(ps={}));function Ll(e){let{acceleration:t,activator:s=Ot.Pointer,canScroll:a,draggingRect:m,enabled:b,interval:C=5,order:r=ps.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:d,delta:o,threshold:p}=e;const _=Tl({delta:o,disabled:!b}),[y,g]=Wa(),n=R.useRef({x:0,y:0}),f=R.useRef({x:0,y:0}),h=R.useMemo(()=>{switch(s){case Ot.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case Ot.DraggableRect:return m}},[s,m,i]),u=R.useRef(null),v=R.useCallback(()=>{const w=u.current;if(!w)return;const k=n.current.x*f.current.x,x=n.current.y*f.current.y;w.scrollBy(k,x)},[]),S=R.useMemo(()=>r===ps.TreeOrder?[...l].reverse():l,[r,l]);R.useEffect(()=>{if(!b||!l.length||!h){g();return}for(const w of S){if(a?.(w)===!1)continue;const k=l.indexOf(w),x=d[k];if(!x)continue;const{direction:E,speed:A}=gl(w,x,h,t,p);for(const j of["x","y"])_[j][E[j]]||(A[j]=0,E[j]=0);if(A.x>0||A.y>0){g(),u.current=w,y(v,C),n.current=A,f.current=E;return}}n.current={x:0,y:0},f.current={x:0,y:0},g()},[t,v,a,g,b,C,JSON.stringify(h),JSON.stringify(_),y,l,S,d,JSON.stringify(p)])}const Al={x:{[Be.Backward]:!1,[Be.Forward]:!1},y:{[Be.Backward]:!1,[Be.Forward]:!1}};function Tl(e){let{delta:t,disabled:s}=e;const a=hs(t);return Xt(m=>{if(s||!a||!m)return Al;const b={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[Be.Backward]:m.x[Be.Backward]||b.x===-1,[Be.Forward]:m.x[Be.Forward]||b.x===1},y:{[Be.Backward]:m.y[Be.Backward]||b.y===-1,[Be.Forward]:m.y[Be.Forward]||b.y===1}}},[s,t,a])}function jl(e,t){const s=t!=null?e.get(t):void 0,a=s?s.node.current:null;return Xt(m=>{var b;return t==null?null:(b=a??m)!=null?b:null},[a,t])}function Ml(e,t){return R.useMemo(()=>e.reduce((s,a)=>{const{sensor:m}=a,b=m.activators.map(C=>({eventName:C.eventName,handler:t(C.handler,a)}));return[...s,...b]},[]),[e,t])}var Ut;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ut||(Ut={}));var tr;(function(e){e.Optimized="optimized"})(tr||(tr={}));const Kr=new Map;function Nl(e,t){let{dragging:s,dependencies:a,config:m}=t;const[b,C]=R.useState(null),{frequency:r,measure:i,strategy:l}=m,d=R.useRef(e),o=n(),p=Wt(o),_=R.useCallback(function(f){f===void 0&&(f=[]),!p.current&&C(h=>h===null?f:h.concat(f.filter(u=>!h.includes(u))))},[p]),y=R.useRef(null),g=Xt(f=>{if(o&&!s)return Kr;if(!f||f===Kr||d.current!==e||b!=null){const h=new Map;for(let u of e){if(!u)continue;if(b&&b.length>0&&!b.includes(u.id)&&u.rect.current){h.set(u.id,u.rect.current);continue}const v=u.node.current,S=v?new Cr(i(v),v):null;u.rect.current=S,S&&h.set(u.id,S)}return h}return f},[e,b,s,o,i]);return R.useEffect(()=>{d.current=e},[e]),R.useEffect(()=>{o||_()},[s,o]),R.useEffect(()=>{b&&b.length>0&&C(null)},[JSON.stringify(b)]),R.useEffect(()=>{o||typeof r!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},r))},[r,o,_,...a]),{droppableRects:g,measureDroppableContainers:_,measuringScheduled:b!=null};function n(){switch(l){case Ut.Always:return!1;case Ut.BeforeDragging:return s;default:return!s}}}function kr(e,t){return Xt(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function Pl(e,t){return kr(e,t)}function Ol(e){let{callback:t,disabled:s}=e;const a=Cs(t),m=R.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:b}=window;return new b(a)},[a,s]);return R.useEffect(()=>()=>m?.disconnect(),[m]),m}function Es(e){let{callback:t,disabled:s}=e;const a=Cs(t),m=R.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:b}=window;return new b(a)},[s]);return R.useEffect(()=>()=>m?.disconnect(),[m]),m}function Bl(e){return new Cr(Yt(e),e)}function Xr(e,t,s){t===void 0&&(t=Bl);const[a,m]=R.useState(null);function b(){m(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??s)!=null?l:null}const d=t(e);return JSON.stringify(i)===JSON.stringify(d)?i:d})}const C=Ol({callback(i){if(e)for(const l of i){const{type:d,target:o}=l;if(d==="childList"&&o instanceof HTMLElement&&o.contains(e)){b();break}}}}),r=Es({callback:b});return at(()=>{b(),e?(r?.observe(e),C?.observe(document.body,{childList:!0,subtree:!0})):(r?.disconnect(),C?.disconnect())},[e]),a}function Il(e){const t=kr(e);return rn(e,t)}const Yr=[];function Fl(e){const t=R.useRef(e),s=Xt(a=>e?a&&a!==Yr&&e&&t.current&&e.parentNode===t.current.parentNode?a:yr(e):Yr,[e]);return R.useEffect(()=>{t.current=e},[e]),s}function Hl(e){const[t,s]=R.useState(null),a=R.useRef(e),m=R.useCallback(b=>{const C=Bs(b.target);C&&s(r=>r?(r.set(C,Js(C)),new Map(r)):null)},[]);return R.useEffect(()=>{const b=a.current;if(e!==b){C(b);const r=e.map(i=>{const l=Bs(i);return l?(l.addEventListener("scroll",m,{passive:!0}),[l,Js(l)]):null}).filter(i=>i!=null);s(r.length?new Map(r):null),a.current=e}return()=>{C(e),C(b)};function C(r){r.forEach(i=>{const l=Bs(i);l?.removeEventListener("scroll",m)})}},[m,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((b,C)=>yt(b,C),et):un(e):et,[e,t])}function Vr(e,t){t===void 0&&(t=[]);const s=R.useRef(null);return R.useEffect(()=>{s.current=null},t),R.useEffect(()=>{const a=e!==et;a&&!s.current&&(s.current=e),!a&&s.current&&(s.current=null)},[e]),s.current?us(e,s.current):et}function zl(e){R.useEffect(()=>{if(!ys)return;const t=e.map(s=>{let{sensor:a}=s;return a.setup==null?void 0:a.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function Wl(e,t){return R.useMemo(()=>e.reduce((s,a)=>{let{eventName:m,handler:b}=a;return s[m]=C=>{b(C,t)},s},{}),[e,t])}function mn(e){return R.useMemo(()=>e?fl(e):null,[e])}const Gr=[];function $l(e,t){t===void 0&&(t=Yt);const[s]=e,a=mn(s?$e(s):null),[m,b]=R.useState(Gr);function C(){b(()=>e.length?e.map(i=>cn(i)?a:new Cr(t(i),i)):Gr)}const r=Es({callback:C});return at(()=>{r?.disconnect(),C(),e.forEach(i=>r?.observe(i))},[e]),m}function vn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Kt(t)?t:e}function Ul(e){let{measure:t}=e;const[s,a]=R.useState(null),m=R.useCallback(l=>{for(const{target:d}of l)if(Kt(d)){a(o=>{const p=t(d);return o?{...o,width:p.width,height:p.height}:p});break}},[t]),b=Es({callback:m}),C=R.useCallback(l=>{const d=vn(l);b?.disconnect(),d&&b?.observe(d),a(d?t(d):null)},[t,b]),[r,i]=cs(C);return R.useMemo(()=>({nodeRef:r,rect:s,setRef:i}),[s,r,i])}const ql=[{sensor:Er,options:{}},{sensor:pn,options:{}}],Kl={current:{}},os={draggable:{measure:Wr},droppable:{measure:Wr,strategy:Ut.WhileDragging,frequency:tr.Optimized},dragOverlay:{measure:Yt}};class Bt extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,a;return(s=(a=this.get(t))==null?void 0:a.node.current)!=null?s:void 0}}const Xl={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:fs},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:os,measureDroppableContainers:fs,windowRect:null,measuringScheduled:!1},gn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:fs,draggableNodes:new Map,over:null,measureDroppableContainers:fs},Vt=R.createContext(gn),_n=R.createContext(Xl);function Yl(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bt}}}function Vl(e,t){switch(t.type){case Ne.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ne.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 Ne.DragEnd:case Ne.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ne.RegisterDroppable:{const{element:s}=t,{id:a}=s,m=new Bt(e.droppable.containers);return m.set(a,s),{...e,droppable:{...e.droppable,containers:m}}}case Ne.SetDroppableDisabled:{const{id:s,key:a,disabled:m}=t,b=e.droppable.containers.get(s);if(!b||a!==b.key)return e;const C=new Bt(e.droppable.containers);return C.set(s,{...b,disabled:m}),{...e,droppable:{...e.droppable,containers:C}}}case Ne.UnregisterDroppable:{const{id:s,key:a}=t,m=e.droppable.containers.get(s);if(!m||a!==m.key)return e;const b=new Bt(e.droppable.containers);return b.delete(s),{...e,droppable:{...e.droppable,containers:b}}}default:return e}}function Gl(e){let{disabled:t}=e;const{active:s,activatorEvent:a,draggableNodes:m}=R.useContext(Vt),b=hs(a),C=hs(s?.id);return R.useEffect(()=>{if(!t&&!a&&b&&C!=null){if(!Sr(b)||document.activeElement===b.target)return;const r=m.get(C);if(!r)return;const{activatorNode:i,node:l}=r;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const d of[i.current,l.current]){if(!d)continue;const o=qa(d);if(o){o.focus();break}}})}},[a,t,m,C,b]),null}function bn(e,t){let{transform:s,...a}=t;return e!=null&&e.length?e.reduce((m,b)=>b({transform:m,...a}),s):s}function Ql(e){return R.useMemo(()=>({draggable:{...os.draggable,...e?.draggable},droppable:{...os.droppable,...e?.droppable},dragOverlay:{...os.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Zl(e){let{activeNode:t,measure:s,initialRect:a,config:m=!0}=e;const b=R.useRef(!1),{x:C,y:r}=typeof m=="boolean"?{x:m,y:m}:m;at(()=>{if(!C&&!r||!t){b.current=!1;return}if(b.current||!a)return;const l=t?.node.current;if(!l||l.isConnected===!1)return;const d=s(l),o=rn(d,a);if(C||(o.x=0),r||(o.y=0),b.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const p=on(l);p&&p.scrollBy({top:o.y,left:o.x})}},[t,C,r,a,s])}const ks=R.createContext({...et,scaleX:1,scaleY:1});var lt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(lt||(lt={}));const Jl=R.memo(function(t){var s,a,m,b;let{id:C,accessibility:r,autoScroll:i=!0,children:l,sensors:d=ql,collisionDetection:o=al,measuring:p,modifiers:_,...y}=t;const g=R.useReducer(Vl,void 0,Yl),[n,f]=g,[h,u]=Qa(),[v,S]=R.useState(lt.Uninitialized),w=v===lt.Initialized,{draggable:{active:k,nodes:x,translate:E},droppable:{containers:A}}=n,j=k!=null?x.get(k):null,T=R.useRef({initial:null,translated:null}),N=R.useMemo(()=>{var Le;return k!=null?{id:k,data:(Le=j?.data)!=null?Le:Kl,rect:T}:null},[k,j]),I=R.useRef(null),[F,H]=R.useState(null),[z,D]=R.useState(null),M=Wt(y,Object.values(y)),P=ws("DndDescribedBy",C),O=R.useMemo(()=>A.getEnabled(),[A]),U=Ql(p),{droppableRects:K,measureDroppableContainers:X,measuringScheduled:G}=Nl(O,{dragging:w,dependencies:[E.x,E.y],config:U.droppable}),ne=jl(x,k),L=R.useMemo(()=>z?ds(z):null,[z]),B=At(),$=Pl(ne,U.draggable.measure);Zl({activeNode:k!=null?x.get(k):null,config:B.layoutShiftCompensation,initialRect:$,measure:U.draggable.measure});const W=Xr(ne,U.draggable.measure,$),J=Xr(ne?ne.parentElement:null),Y=R.useRef({activatorEvent:null,active:null,activeNode:ne,collisionRect:null,collisions:null,droppableRects:K,draggableNodes:x,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=A.getNodeFor((s=Y.current.over)==null?void 0:s.id),de=Ul({measure:U.dragOverlay.measure}),be=(a=de.nodeRef.current)!=null?a:ne,Ee=w?(m=de.rect)!=null?m:W:null,te=!!(de.nodeRef.current&&de.rect),Re=Il(te?null:W),De=mn(be?$e(be):null),Q=Fl(w?oe??ne:null),re=$l(Q),fe=bn(_,{transform:{x:E.x-Re.x,y:E.y-Re.y,scaleX:1,scaleY:1},activatorEvent:z,active:N,activeNodeRect:W,containerNodeRect:J,draggingNodeRect:Ee,over:Y.current.over,overlayNodeRect:de.rect,scrollableAncestors:Q,scrollableAncestorRects:re,windowRect:De}),se=L?yt(L,E):null,q=Hl(Q),ie=Vr(q),pe=Vr(q,[W]),Ie=yt(fe,ie),je=Ee?hl(Ee,fe):null,Xe=N&&je?o({active:N,collisionRect:je,droppableRects:K,droppableContainers:O,pointerCoordinates:se}):null,Fe=nl(Xe,"id"),[Pe,ve]=R.useState(null),kt=te?fe:yt(fe,pe),js=ll(kt,(b=Pe?.rect)!=null?b:null,W),Rt=R.useRef(null),Dt=R.useCallback((Le,He)=>{let{sensor:ze,options:tt}=He;if(I.current==null)return;const We=x.get(I.current);if(!We)return;const V=Le.nativeEvent,ee=new ze({active:I.current,activeNode:We,event:V,options:tt,context:Y,onAbort(ye){if(!x.get(ye))return;const{onDragAbort:ge}=M.current,qe={id:ye};ge?.(qe),h({type:"onDragAbort",event:qe})},onPending(ye,Me,ge,qe){if(!x.get(ye))return;const{onDragPending:Ye}=M.current,st={id:ye,constraint:Me,initialCoordinates:ge,offset:qe};Ye?.(st),h({type:"onDragPending",event:st})},onStart(ye){const Me=I.current;if(Me==null)return;const ge=x.get(Me);if(!ge)return;const{onDragStart:qe}=M.current,Ze={activatorEvent:V,active:{id:Me,data:ge.data,rect:T}};_t.unstable_batchedUpdates(()=>{qe?.(Ze),S(lt.Initializing),f({type:Ne.DragStart,initialCoordinates:ye,active:Me}),h({type:"onDragStart",event:Ze}),H(Rt.current),D(V)})},onMove(ye){f({type:Ne.DragMove,coordinates:ye})},onEnd:xe(Ne.DragEnd),onCancel:xe(Ne.DragCancel)});Rt.current=ee;function xe(ye){return async function(){const{active:ge,collisions:qe,over:Ze,scrollAdjustedTranslate:Ye}=Y.current;let st=null;if(ge&&Ye){const{cancelDrop:Tt}=M.current;st={activatorEvent:V,active:ge,collisions:qe,delta:Ye,over:Ze},ye===Ne.DragEnd&&typeof Tt=="function"&&await Promise.resolve(Tt(st))&&(ye=Ne.DragCancel)}I.current=null,_t.unstable_batchedUpdates(()=>{f({type:ye}),S(lt.Uninitialized),ve(null),H(null),D(null),Rt.current=null;const Tt=ye===Ne.DragEnd?"onDragEnd":"onDragCancel";if(st){const Ps=M.current[Tt];Ps?.(st),h({type:Tt,event:st})}})}}},[x]),Lt=R.useCallback((Le,He)=>(ze,tt)=>{const We=ze.nativeEvent,V=x.get(tt);if(I.current!==null||!V||We.dndKit||We.defaultPrevented)return;const ee={active:V};Le(ze,He.options,ee)===!0&&(We.dndKit={capturedBy:He.sensor},I.current=tt,Dt(ze,He))},[x,Dt]),Jt=Ml(d,Lt);zl(d),at(()=>{W&&v===lt.Initializing&&S(lt.Initialized)},[W,v]),R.useEffect(()=>{const{onDragMove:Le}=M.current,{active:He,activatorEvent:ze,collisions:tt,over:We}=Y.current;if(!He||!ze)return;const V={active:He,activatorEvent:ze,collisions:tt,delta:{x:Ie.x,y:Ie.y},over:We};_t.unstable_batchedUpdates(()=>{Le?.(V),h({type:"onDragMove",event:V})})},[Ie.x,Ie.y]),R.useEffect(()=>{const{active:Le,activatorEvent:He,collisions:ze,droppableContainers:tt,scrollAdjustedTranslate:We}=Y.current;if(!Le||I.current==null||!He||!We)return;const{onDragOver:V}=M.current,ee=tt.get(Fe),xe=ee&&ee.rect.current?{id:ee.id,rect:ee.rect.current,data:ee.data,disabled:ee.disabled}:null,ye={active:Le,activatorEvent:He,collisions:ze,delta:{x:We.x,y:We.y},over:xe};_t.unstable_batchedUpdates(()=>{ve(xe),V?.(ye),h({type:"onDragOver",event:ye})})},[Fe]),at(()=>{Y.current={activatorEvent:z,active:N,activeNode:ne,collisionRect:je,collisions:Xe,droppableRects:K,draggableNodes:x,draggingNode:be,draggingNodeRect:Ee,droppableContainers:A,over:Pe,scrollableAncestors:Q,scrollAdjustedTranslate:Ie},T.current={initial:Ee,translated:je}},[N,ne,Xe,je,x,be,Ee,K,A,Pe,Q,Ie]),Ll({...B,delta:E,draggingRect:je,pointerCoordinates:se,scrollableAncestors:Q,scrollableAncestorRects:re});const Ms=R.useMemo(()=>({active:N,activeNode:ne,activeNodeRect:W,activatorEvent:z,collisions:Xe,containerNodeRect:J,dragOverlay:de,draggableNodes:x,droppableContainers:A,droppableRects:K,over:Pe,measureDroppableContainers:X,scrollableAncestors:Q,scrollableAncestorRects:re,measuringConfiguration:U,measuringScheduled:G,windowRect:De}),[N,ne,W,z,Xe,J,de,x,A,K,Pe,X,Q,re,U,G,De]),Ns=R.useMemo(()=>({activatorEvent:z,activators:Jt,active:N,activeNodeRect:W,ariaDescribedById:{draggable:P},dispatch:f,draggableNodes:x,over:Pe,measureDroppableContainers:X}),[z,Jt,N,W,f,P,x,Pe,X]);return Z.createElement(sn.Provider,{value:u},Z.createElement(Vt.Provider,{value:Ns},Z.createElement(_n.Provider,{value:Ms},Z.createElement(ks.Provider,{value:js},l)),Z.createElement(Gl,{disabled:r?.restoreFocus===!1})),Z.createElement(el,{...r,hiddenTextDescribedById:P}));function At(){const Le=F?.autoScrollEnabled===!1,He=typeof i=="object"?i.enabled===!1:i===!1,ze=w&&!Le&&!He;return typeof i=="object"?{...i,enabled:ze}:{enabled:ze}}}),ec=R.createContext(null),Qr="button",tc="Draggable";function sc(e){let{id:t,data:s,disabled:a=!1,attributes:m}=e;const b=ws(tc),{activators:C,activatorEvent:r,active:i,activeNodeRect:l,ariaDescribedById:d,draggableNodes:o,over:p}=R.useContext(Vt),{role:_=Qr,roleDescription:y="draggable",tabIndex:g=0}=m??{},n=i?.id===t,f=R.useContext(n?ks:ec),[h,u]=cs(),[v,S]=cs(),w=Wl(C,t),k=Wt(s);at(()=>(o.set(t,{id:t,key:b,node:h,activatorNode:v,data:k}),()=>{const E=o.get(t);E&&E.key===b&&o.delete(t)}),[o,t]);const x=R.useMemo(()=>({role:_,tabIndex:g,"aria-disabled":a,"aria-pressed":n&&_===Qr?!0:void 0,"aria-roledescription":y,"aria-describedby":d.draggable}),[a,_,g,n,y,d.draggable]);return{active:i,activatorEvent:r,activeNodeRect:l,attributes:x,isDragging:n,listeners:a?void 0:w,node:h,over:p,setNodeRef:u,setActivatorNodeRef:S,transform:f}}function rc(){return R.useContext(_n)}const ic="Droppable",nc={timeout:25};function oc(e){let{data:t,disabled:s=!1,id:a,resizeObserverConfig:m}=e;const b=ws(ic),{active:C,dispatch:r,over:i,measureDroppableContainers:l}=R.useContext(Vt),d=R.useRef({disabled:s}),o=R.useRef(!1),p=R.useRef(null),_=R.useRef(null),{disabled:y,updateMeasurementsFor:g,timeout:n}={...nc,...m},f=Wt(g??a),h=R.useCallback(()=>{if(!o.current){o.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{l(Array.isArray(f.current)?f.current:[f.current]),_.current=null},n)},[n]),u=Es({callback:h,disabled:y||!C}),v=R.useCallback((x,E)=>{u&&(E&&(u.unobserve(E),o.current=!1),x&&u.observe(x))},[u]),[S,w]=cs(v),k=Wt(t);return R.useEffect(()=>{!u||!S.current||(u.disconnect(),o.current=!1,u.observe(S.current))},[S,u]),R.useEffect(()=>(r({type:Ne.RegisterDroppable,element:{id:a,key:b,disabled:s,node:S,rect:p,data:k}}),()=>r({type:Ne.UnregisterDroppable,key:b,id:a})),[a]),R.useEffect(()=>{s!==d.current.disabled&&(r({type:Ne.SetDroppableDisabled,id:a,key:b,disabled:s}),d.current.disabled=s)},[a,b,s,r]),{active:C,rect:p,isOver:i?.id===a,node:S,over:i,setNodeRef:w}}function ac(e){let{animation:t,children:s}=e;const[a,m]=R.useState(null),[b,C]=R.useState(null),r=hs(s);return!s&&!a&&r&&m(r),at(()=>{if(!b)return;const i=a?.key,l=a?.props.id;if(i==null||l==null){m(null);return}Promise.resolve(t(l,b)).then(()=>{m(null)})},[t,a,b]),Z.createElement(Z.Fragment,null,s,a?R.cloneElement(a,{ref:C}):null)}const lc={x:0,y:0,scaleX:1,scaleY:1};function cc(e){let{children:t}=e;return Z.createElement(Vt.Provider,{value:gn},Z.createElement(ks.Provider,{value:lc},t))}const hc={position:"fixed",touchAction:"none"},uc=e=>Sr(e)?"transform 250ms ease":void 0,dc=R.forwardRef((e,t)=>{let{as:s,activatorEvent:a,adjustScale:m,children:b,className:C,rect:r,style:i,transform:l,transition:d=uc}=e;if(!r)return null;const o=m?l:{...l,scaleX:1,scaleY:1},p={...hc,width:r.width,height:r.height,top:r.top,left:r.left,transform:$t.Transform.toString(o),transformOrigin:m&&a?rl(a,r):void 0,transition:typeof d=="function"?d(a):d,...i};return Z.createElement(s,{className:C,style:p,ref:t},b)}),fc=e=>t=>{let{active:s,dragOverlay:a}=t;const m={},{styles:b,className:C}=e;if(b!=null&&b.active)for(const[r,i]of Object.entries(b.active))i!==void 0&&(m[r]=s.node.style.getPropertyValue(r),s.node.style.setProperty(r,i));if(b!=null&&b.dragOverlay)for(const[r,i]of Object.entries(b.dragOverlay))i!==void 0&&a.node.style.setProperty(r,i);return C!=null&&C.active&&s.node.classList.add(C.active),C!=null&&C.dragOverlay&&a.node.classList.add(C.dragOverlay),function(){for(const[i,l]of Object.entries(m))s.node.style.setProperty(i,l);C!=null&&C.active&&s.node.classList.remove(C.active)}},pc=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:$t.Transform.toString(t)},{transform:$t.Transform.toString(s)}]},mc={duration:250,easing:"ease",keyframes:pc,sideEffects:fc({styles:{active:{opacity:"0"}}})};function vc(e){let{config:t,draggableNodes:s,droppableContainers:a,measuringConfiguration:m}=e;return Cs((b,C)=>{if(t===null)return;const r=s.get(b);if(!r)return;const i=r.node.current;if(!i)return;const l=vn(C);if(!l)return;const{transform:d}=$e(C).getComputedStyle(C),o=nn(d);if(!o)return;const p=typeof t=="function"?t:gc(t);return dn(i,m.draggable.measure),p({active:{id:b,data:r.data,node:i,rect:m.draggable.measure(i)},draggableNodes:s,dragOverlay:{node:C,rect:m.dragOverlay.measure(l)},droppableContainers:a,measuringConfiguration:m,transform:o})})}function gc(e){const{duration:t,easing:s,sideEffects:a,keyframes:m}={...mc,...e};return b=>{let{active:C,dragOverlay:r,transform:i,...l}=b;if(!t)return;const d={x:r.rect.left-C.rect.left,y:r.rect.top-C.rect.top},o={scaleX:i.scaleX!==1?C.rect.width*i.scaleX/r.rect.width:1,scaleY:i.scaleY!==1?C.rect.height*i.scaleY/r.rect.height:1},p={x:i.x-d.x,y:i.y-d.y,...o},_=m({...l,active:C,dragOverlay:r,transform:{initial:i,final:p}}),[y]=_,g=_[_.length-1];if(JSON.stringify(y)===JSON.stringify(g))return;const n=a?.({active:C,dragOverlay:r,...l}),f=r.node.animate(_,{duration:t,easing:s,fill:"forwards"});return new Promise(h=>{f.onfinish=()=>{n?.(),h()}})}}let Zr=0;function _c(e){return R.useMemo(()=>{if(e!=null)return Zr++,Zr},[e])}const bc=Z.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:a,style:m,transition:b,modifiers:C,wrapperElement:r="div",className:i,zIndex:l=999}=e;const{activatorEvent:d,active:o,activeNodeRect:p,containerNodeRect:_,draggableNodes:y,droppableContainers:g,dragOverlay:n,over:f,measuringConfiguration:h,scrollableAncestors:u,scrollableAncestorRects:v,windowRect:S}=rc(),w=R.useContext(ks),k=_c(o?.id),x=bn(C,{activatorEvent:d,active:o,activeNodeRect:p,containerNodeRect:_,draggingNodeRect:n.rect,over:f,overlayNodeRect:n.rect,scrollableAncestors:u,scrollableAncestorRects:v,transform:w,windowRect:S}),E=kr(p),A=vc({config:a,draggableNodes:y,droppableContainers:g,measuringConfiguration:h}),j=E?n.setRef:void 0;return Z.createElement(cc,null,Z.createElement(ac,{animation:A},o&&k?Z.createElement(dc,{key:k,id:o.id,ref:j,as:r,activatorEvent:d,adjustScale:t,className:i,transition:b,rect:E,style:{zIndex:l,...m},transform:x},s):null))}),ae={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},xc=[{status:ae.Review,label:"Review",icon:dr,color:"text-amber-600"},{status:ae.Running,label:"Running",icon:fr,color:"text-blue-600"},{status:ae.Pending,label:"Pending",icon:pr,color:"text-neutral-600"},{status:ae.Done,label:"Done",icon:mr,color:"text-emerald-600"},{status:ae.Cancelled,label:"Cancelled",icon:vr,color:"text-neutral-500"}];function Sc({task:e,status:t,isSelected:s,isAgentActive:a,project:m,onSelectTask:b,onTaskStatusChange:C,onDeleteTask:r}){const{attributes:i,listeners:l,setNodeRef:d,isDragging:o}=sc({id:e.id,data:{task:e,fromStatus:t}}),[p,_]=R.useState(null),y=R.useRef(null),g=R.useCallback(n=>{!C&&!r||(n.preventDefault(),_({x:n.clientX,y:n.clientY}))},[C,r]);return R.useEffect(()=>{if(!p)return;const n=f=>{y.current&&!y.current.contains(f.target)&&_(null)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),c.jsxs(c.Fragment,{children:[c.jsxs("button",{ref:d,onClick:()=>b(e.id),onContextMenu:g,className:`flex items-start pl-8 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
7
- ${o?"opacity-30":""}
8
- ${s?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l,...i,children:[c.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ae.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ae.Review&&c.jsx(dr,{className:s?"text-amber-600":"text-neutral-500"}),t===ae.Running&&c.jsx(fr,{className:"animate-pulse"}),t===ae.Pending&&c.jsx(pr,{}),t===ae.Done&&c.jsx(mr,{className:"text-neutral-400"}),t===ae.Cancelled&&c.jsx(vr,{className:"text-neutral-400"})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"mb-0.5",children:[c.jsx("span",{className:`font-medium mr-1 ${m?.color||"text-neutral-500"}`,children:m?.name}),c.jsx("span",{className:"text-neutral-400",children:"/"}),c.jsx("span",{className:`ml-1 ${s?"text-neutral-900":"text-neutral-700"}`,children:e.title}),a&&c.jsxs("span",{className:"relative inline-flex h-2 w-2 ml-1.5 align-middle",children:[c.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),c.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),c.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${s?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),p&&c.jsxs("div",{ref:y,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:p.x,top:p.y},children:[C&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:"移动到"}),xc.filter(n=>n.status!==t).map(n=>{const f=n.icon;return c.jsxs("button",{onClick:()=>{C(e.id,n.status),_(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[c.jsx(f,{className:`w-3.5 h-3.5 ${n.color}`}),c.jsx("span",{className:"text-neutral-700",children:n.label})]},n.status)})]}),r&&c.jsxs(c.Fragment,{children:[C&&c.jsx("div",{className:"my-1 border-t border-neutral-100"}),c.jsxs("button",{onClick:()=>{r(e.id),_(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:[c.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:[c.jsx("path",{d:"M3 6h18"}),c.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),c.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),c.jsx("span",{children:"删除任务"})]})]})]})]})}const yc=R.memo(function({title:t,tasks:s,status:a,defaultOpen:m,selectedTaskId:b,onSelectTask:C,projects:r,activeTaskIds:i,isDragging:l,dragFromStatus:d,onTaskStatusChange:o,onDeleteTask:p}){const[_,y]=R.useState(m),g=s.length===0,n=l&&d===a,f=l&&d!==a,{setNodeRef:h,isOver:u}=oc({id:`group-${a}`,data:{status:a}}),v=a===ae.Review,S=l?n&&(_||!0):_;return c.jsxs("div",{className:"mb-2",children:[c.jsxs("button",{onClick:()=>!l&&y(w=>!w),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:[c.jsx("span",{className:"mr-2 text-neutral-400",children:S?c.jsx(dt,{size:14}):c.jsx(gt,{size:14})}),c.jsx("span",{className:"flex-1 text-left",children:t}),v&&!g?c.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:s.length}):c.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",s.length,")"]})]}),f&&c.jsx("div",{ref:h,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
- ${u?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:c.jsx("span",{className:"text-xs font-medium",children:u?`放入 ${t}`:"拖到此处"})}),S&&!f&&c.jsx("div",{ref:n?void 0:h,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
10
- ${u&&!n?"bg-blue-50 ring-1 ring-blue-200":""}
11
- ${g&&l?"border border-dashed border-neutral-300":""}`,children:g?c.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-8",children:"No tasks"}):s.map(w=>{const k=r.find(A=>A.id===w.projectId),x=b===w.id,E=i?.has(w.id)??!1;return c.jsx(Sc,{task:w,status:a,isSelected:x,isAgentActive:E,project:k,onSelectTask:C,onTaskStatusChange:o,onDeleteTask:p},w.id)})})]})}),Cc=c.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:c.jsx("span",{children:"0 tasks"})});function wc(e){const t={[ae.Review]:[],[ae.Running]:[],[ae.Pending]:[],[ae.Done]:[],[ae.Cancelled]:[]};for(const s of e)t[s.status].push(s);return t}const Ec=[{status:ae.Review,title:"Review",defaultOpen:!0},{status:ae.Running,title:"Running",defaultOpen:!0},{status:ae.Pending,title:"Pending",defaultOpen:!1},{status:ae.Done,title:"Done",defaultOpen:!1},{status:ae.Cancelled,title:"Cancelled",defaultOpen:!1}];function Jr({tasks:e=[],projects:t=[],selectedTaskId:s,onSelectTask:a,filterProjectId:m,setFilterProjectId:b,width:C=320,onCreateProject:r,onCreateTask:i,activeTaskIds:l,onTaskStatusChange:d,onDeleteTask:o}){const[p,_]=R.useState(!1),[y,g]=R.useState(null),[n,f]=R.useState(null),h=sl(tl(Er,{activationConstraint:{distance:8}})),u=R.useCallback(E=>{const A=E.active.data.current?.task,j=E.active.data.current?.fromStatus;A&&g(A),j&&f(j)},[]),v=R.useCallback(E=>{g(null),f(null);const{active:A,over:j}=E;if(!j)return;const T=A.data.current?.task,N=A.data.current?.fromStatus,I=j.data.current?.status;!T||!N||!I||N!==I&&d?.(T.id,I)},[d]),S=m?e.filter(E=>E.projectId===m):e,w=m?t.find(E=>E.id===m)??null:null,k=wc(S),x=C==="100%";return c.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${x?"":"border-r border-neutral-200"}`,style:{width:C},children:[c.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[c.jsxs("div",{className:"relative flex-1 mr-2",children:[c.jsxs("button",{onClick:()=>_(E=>!E),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?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),c.jsx("span",{className:"truncate",children:w.name})]}):c.jsxs(c.Fragment,{children:[c.jsx(Hr,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),c.jsx("span",{children:"All Projects"})]}),c.jsx(dt,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${p?"rotate-180":""}`})]}),p?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>_(!1)}),c.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:[c.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:"Select View"}),c.jsxs("button",{onClick:()=>{b(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:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:c.jsx(Hr,{size:12})}),c.jsx("span",{className:m===null?"text-neutral-900 font-medium":"text-neutral-600",children:"All Projects"})]}),m===null?c.jsx(as,{size:14,className:"text-neutral-900"}):null]}),c.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),t.map(E=>{const A=m===E.id,j=E.color.replace("text-","bg-");return c.jsxs("button",{onClick:()=>{b(E.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:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${j}`}),c.jsx("span",{className:A?"text-neutral-900 font-medium":"text-neutral-600",children:E.name})]}),A?c.jsx(as,{size:14,className:"text-neutral-900"}):null]},E.id)}),c.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),c.jsxs("button",{onClick:()=>{_(!1),r?.()},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:[c.jsx(Zs,{size:14}),c.jsx("span",{children:"Create New Project..."})]})]})]}):null]}),c.jsx("button",{onClick:i,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0",title:"New Task",children:c.jsx(Zs,{size:18})})]}),c.jsxs(Jl,{sensors:h,onDragStart:u,onDragEnd:v,children:[c.jsx("div",{className:"flex-1 overflow-y-auto py-4 relative",children:Ec.map(({status:E,title:A,defaultOpen:j})=>c.jsx(yc,{title:A,tasks:k[E],status:E,defaultOpen:j,selectedTaskId:s,onSelectTask:a,projects:t,activeTaskIds:l,isDragging:y!==null,dragFromStatus:n,onTaskStatusChange:d,onDeleteTask:o},E))}),c.jsx(bc,{dropAnimation:null,children:y?c.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:c.jsx("span",{className:"text-neutral-700 font-medium",children:y.title})}):null})]}),S.length>0?c.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[c.jsxs("span",{children:[S.length," tasks"]}),m?c.jsx("button",{onClick:()=>b(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:"Clear filter"}):null]}):Cc]})}const kc={damping:.7,stiffness:.05,mass:1.25},Rc=70,Dc=1e3/60,Lc=350;let Rs=!1;globalThis.document?.addEventListener("mousedown",()=>{Rs=!0});globalThis.document?.addEventListener("mouseup",()=>{Rs=!1});globalThis.document?.addEventListener("click",()=>{Rs=!1});const xn=(e={})=>{const[t,s]=R.useState(!1),[a,m]=R.useState(e.initial!==!1),[b,C]=R.useState(!1),r=R.useRef(null);r.current=e;const i=R.useCallback(()=>{if(!Rs)return!1;const h=window.getSelection();if(!h||!h.rangeCount)return!1;const u=h.getRangeAt(0);return u.commonAncestorContainer.contains(n.current)||n.current?.contains(u.commonAncestorContainer)},[]),l=R.useCallback(h=>{o.isAtBottom=h,m(h)},[]),d=R.useCallback(h=>{o.escapedFromLock=h,s(h)},[]),o=R.useMemo(()=>{let h;return{escapedFromLock:t,isAtBottom:a,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return n.current?.scrollTop??0},set scrollTop(u){n.current&&(n.current.scrollTop=u,o.ignoreScrollToTop=n.current.scrollTop)},get targetScrollTop(){return!n.current||!f.current?0:n.current.scrollHeight-1-n.current.clientHeight},get calculatedTargetScrollTop(){if(!n.current||!f.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(h?.targetScrollTop===u)return h.calculatedScrollTop;const v=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:n.current,contentElement:f.current}),u),0);return h={targetScrollTop:u,calculatedScrollTop:v},requestAnimationFrame(()=>{h=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Rc}}},[]),p=R.useCallback((h={})=>{typeof h=="string"&&(h={animation:h}),h.preserveScrollPosition||l(!0);const u=Date.now()+(Number(h.wait)||0),v=zs(r.current,h.animation),{ignoreEscapes:S=!1}=h;let w,k=o.calculatedTargetScrollTop;h.duration instanceof Promise?h.duration.finally(()=>{w=Date.now()}):w=u+(h.duration??0);const x=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!o.isAtBottom)return o.animation=void 0,!1;const{scrollTop:A}=o,j=performance.now(),T=(j-(o.lastTick??j))/Dc;if(o.animation||(o.animation={behavior:v,promise:E,ignoreEscapes:S}),o.animation.behavior===v&&(o.lastTick=j),i()||u>Date.now())return x();if(A<Math.min(k,o.calculatedTargetScrollTop)){if(o.animation?.behavior===v){if(v==="instant")return o.scrollTop=o.calculatedTargetScrollTop,x();o.velocity=(v.damping*o.velocity+v.stiffness*o.scrollDifference)/v.mass,o.accumulated+=o.velocity*T,o.scrollTop+=o.accumulated,o.scrollTop!==A&&(o.accumulated=0)}return x()}return w>Date.now()?(k=o.calculatedTargetScrollTop,x()):(o.animation=void 0,o.scrollTop<o.calculatedTargetScrollTop?p({animation:zs(r.current,r.current.resize),ignoreEscapes:S,duration:Math.max(0,w-Date.now())||void 0}):o.isAtBottom)});return E.then(A=>(requestAnimationFrame(()=>{o.animation||(o.lastTick=void 0,o.velocity=0)}),A))};return h.wait!==!0&&(o.animation=void 0),o.animation?.behavior===v?o.animation.promise:x()},[l,i,o]),_=R.useCallback(()=>{d(!0),l(!1)},[d,l]),y=R.useCallback(({target:h})=>{if(h!==n.current)return;const{scrollTop:u,ignoreScrollToTop:v}=o;let{lastScrollTop:S=u}=o;o.lastScrollTop=u,o.ignoreScrollToTop=void 0,v&&v>u&&(S=v),C(o.isNearBottom),setTimeout(()=>{if(o.resizeDifference||u===v)return;if(i()){d(!0),l(!1);return}const w=u>S,k=u<S;if(o.animation?.ignoreEscapes){o.scrollTop=S;return}k&&(d(!0),l(!1)),w&&d(!1),!o.escapedFromLock&&o.isNearBottom&&l(!0)},1)},[d,l,i,o]),g=R.useCallback(({target:h,deltaY:u})=>{let v=h;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===n.current&&u<0&&n.current.scrollHeight>n.current.clientHeight&&!o.animation?.ignoreEscapes&&(d(!0),l(!1))},[d,l,o]),n=ei(h=>{n.current?.removeEventListener("scroll",y),n.current?.removeEventListener("wheel",g),h?.addEventListener("scroll",y,{passive:!0}),h?.addEventListener("wheel",g,{passive:!0})},[]),f=ei(h=>{if(o.resizeObserver?.disconnect(),!h)return;let u;o.resizeObserver=new ResizeObserver(([v])=>{const{height:S}=v.contentRect,w=S-(u??S);if(o.resizeDifference=w,o.scrollTop>o.targetScrollTop&&(o.scrollTop=o.targetScrollTop),C(o.isNearBottom),w>=0){const k=zs(r.current,u?r.current.resize:r.current.initial);p({animation:k,wait:!0,preserveScrollPosition:!0,duration:k==="instant"?void 0:Lc})}else o.isNearBottom&&(d(!1),l(!0));u=S,requestAnimationFrame(()=>{setTimeout(()=>{o.resizeDifference===w&&(o.resizeDifference=0)},1)})}),o.resizeObserver?.observe(h)},[]);return{contentRef:f,scrollRef:n,scrollToBottom:p,stopScroll:_,isAtBottom:a||b,isNearBottom:b,escapedFromLock:t,state:o}};function ei(e,t){const s=R.useCallback(a=>(s.current=a,e(a)),t);return s}const Hs=new Map;function zs(...e){const t={...kc};let s=!1;for(const m of e){if(m==="instant"){s=!0;continue}typeof m=="object"&&(s=!1,t.damping=m.damping??t.damping,t.stiffness=m.stiffness??t.stiffness,t.mass=m.mass??t.mass)}const a=JSON.stringify(t);return Hs.has(a)||Hs.set(a,Object.freeze(t)),s?"instant":Hs.get(a)}var Ge;(function(e){e.TODO="TODO",e.IN_PROGRESS="IN_PROGRESS",e.IN_REVIEW="IN_REVIEW",e.DONE="DONE",e.CANCELLED="CANCELLED"})(Ge||(Ge={}));var ti;(function(e){e.ACTIVE="ACTIVE",e.MERGED="MERGED",e.ABANDONED="ABANDONED"})(ti||(ti={}));var It;(function(e){e.CLAUDE_CODE="CLAUDE_CODE",e.GEMINI_CLI="GEMINI_CLI",e.CURSOR_AGENT="CURSOR_AGENT"})(It||(It={}));var we;(function(e){e.PENDING="PENDING",e.RUNNING="RUNNING",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.CANCELLED="CANCELLED"})(we||(we={}));var si;(function(e){e.CHAT="CHAT",e.COMMIT_MSG="COMMIT_MSG"})(si||(si={}));var sr;(function(e){e.REBASE="REBASE",e.MERGE="MERGE"})(sr||(sr={}));function ts(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ac(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function Sn({usage:e}){if(!e)return null;const t=e.modelContextWindow,s=t?e.totalTokens/t:0,a=t?Math.min(Math.round(s*100),100):null,m=t?Ac(s):"text-neutral-400";return c.jsxs("div",{className:"group relative 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:[c.jsx(aa,{size:14,className:m}),c.jsxs("span",{className:`tabular-nums ${m}`,children:[ts(e.totalTokens),a!==null&&c.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",a,"%"]})]}),c.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg",children:[t?c.jsxs("span",{children:["上下文: ",ts(e.totalTokens)," / ",ts(t)," tokens"]}):c.jsxs("span",{children:["已使用: ",ts(e.totalTokens)," tokens"]}),c.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-neutral-900"})]})]})}var Ws={exports:{}},ri;function Tc(){return ri||(ri=1,(function(e,t){(function(s,a){e.exports=a()})(self,(()=>(()=>{var s={4567:function(C,r,i){var l=this&&this.__decorate||function(u,v,S,w){var k,x=arguments.length,E=x<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,S):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,v,S,w);else for(var A=u.length-1;A>=0;A--)(k=u[A])&&(E=(x<3?k(E):x>3?k(v,S,E):k(v,S))||E);return x>3&&E&&Object.defineProperty(v,S,E),E},d=this&&this.__param||function(u,v){return function(S,w){v(S,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const o=i(9042),p=i(6114),_=i(9924),y=i(844),g=i(5596),n=i(4725),f=i(3656);let h=r.AccessibilityManager=class extends y.Disposable{constructor(u,v){super(),this._terminal=u,this._renderService=v,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
12
- `)))),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 g.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,f.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let v=0;v<u;v++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
13
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=o.tooMuchOutput)),p.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,p.isMac&&this._liveRegion.remove()}_handleKey(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,v){this._liveRegionDebouncer.refresh(u,v,this._terminal.rows)}_renderRows(u,v){const S=this._terminal.buffer,w=S.lines.length.toString();for(let k=u;k<=v;k++){const x=S.translateBufferLineToString(S.ydisp+k,!0),E=(S.ydisp+k+1).toString(),A=this._rowElements[k];A&&(x.length===0?A.innerText=" ":A.textContent=x,A.setAttribute("aria-posinset",E),A.setAttribute("aria-setsize",w))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,v){const S=u.target,w=this._rowElements[v===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(v===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==w)return;let k,x;if(v===0?(k=S,x=this._rowElements.pop(),this._rowContainer.removeChild(x)):(k=this._rowElements.shift(),x=S,this._rowContainer.removeChild(k)),k.removeEventListener("focus",this._topBoundaryFocusListener),x.removeEventListener("focus",this._bottomBoundaryFocusListener),v===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(v===0?-1:1),this._rowElements[v===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 v=this._rowContainer.children.length;v<this._terminal.rows;v++)this._rowElements[v]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[v]);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`}};r.AccessibilityManager=h=l([d(1,n.IRenderService)],h)},3614:(C,r)=>{function i(p){return p.replace(/\r?\n/g,"\r")}function l(p,_){return _?"\x1B[200~"+p+"\x1B[201~":p}function d(p,_,y,g){p=l(p=i(p),y.decPrivateModes.bracketedPasteMode&&g.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),_.value=""}function o(p,_,y){const g=y.getBoundingClientRect(),n=p.clientX-g.left-10,f=p.clientY-g.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${n}px`,_.style.top=`${f}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=i,r.bracketTextForPaste=l,r.copyHandler=function(p,_){p.clipboardData&&p.clipboardData.setData("text/plain",_.selectionText),p.preventDefault()},r.handlePasteEvent=function(p,_,y,g){p.stopPropagation(),p.clipboardData&&d(p.clipboardData.getData("text/plain"),_,y,g)},r.paste=d,r.moveTextAreaUnderMouseCursor=o,r.rightClickHandler=function(p,_,y,g,n){o(p,_,y),n&&g.rightClickSelect(p),_.value=g.selectionText,_.select()}},7239:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const l=i(1505);r.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(d,o,p){this._css.set(d,o,p)}getCss(d,o){return this._css.get(d,o)}setColor(d,o,p){this._color.set(d,o,p)}getColor(d,o){return this._color.get(d,o)}clear(){this._color.clear(),this._css.clear()}}},3656:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(i,l,d,o){i.addEventListener(l,d,o);let p=!1;return{dispose:()=>{p||(p=!0,i.removeEventListener(l,d,o))}}}},6465:function(C,r,i){var l=this&&this.__decorate||function(n,f,h,u){var v,S=arguments.length,w=S<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(S<3?v(w):S>3?v(f,h,w):v(f,h))||w);return S>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const o=i(3656),p=i(8460),_=i(844),y=i(2585);let g=r.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const f=this._linkProviders.indexOf(n);f!==-1&&this._linkProviders.splice(f,1)}}}attachToDom(n,f,h){this._element=n,this._mouseService=f,this._renderService=h,this.register((0,o.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,o.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,o.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const f=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const h=n.composedPath();for(let u=0;u<h.length;u++){const v=h[u];if(v.classList.contains("xterm"))break;if(v.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,f){var h,u;this._activeProviderReplies&&f||((h=this._activeProviderReplies)===null||h===void 0||h.forEach((S=>{S?.forEach((w=>{w.link.dispose&&w.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let v=!1;for(const[S,w]of this._linkProviders.entries())f?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(S)&&(v=this._checkLinkProviderResult(S,n,v)):w.provideLinks(n.y,(k=>{var x,E;if(this._isMouseOut)return;const A=k?.map((j=>({link:j})));(x=this._activeProviderReplies)===null||x===void 0||x.set(S,A),v=this._checkLinkProviderResult(S,n,v),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,f){const h=new Set;for(let u=0;u<f.size;u++){const v=f.get(u);if(v)for(let S=0;S<v.length;S++){const w=v[S],k=w.link.range.start.y<n?0:w.link.range.start.x,x=w.link.range.end.y>n?this._bufferService.cols:w.link.range.end.x;for(let E=k;E<=x;E++){if(h.has(E)){v.splice(S--,1);break}h.add(E)}}}}_checkLinkProviderResult(n,f,h){var u;if(!this._activeProviderReplies)return h;const v=this._activeProviderReplies.get(n);let S=!1;for(let w=0;w<n;w++)this._activeProviderReplies.has(w)&&!this._activeProviderReplies.get(w)||(S=!0);if(!S&&v){const w=v.find((k=>this._linkAtPosition(k.link,f)));w&&(h=!0,this._handleNewLink(w))}if(this._activeProviderReplies.size===this._linkProviders.length&&!h)for(let w=0;w<this._activeProviderReplies.size;w++){const k=(u=this._activeProviderReplies.get(w))===null||u===void 0?void 0:u.find((x=>this._linkAtPosition(x.link,f)));if(k){h=!0,this._handleNewLink(k);break}}return h}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const f=this._positionFromMouseEvent(n,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,f){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!f||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(n.link,f)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:h=>{var u,v;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==h&&(this._currentLink.state.decorations.pointerCursor=h,this._currentLink.state.isHovered&&((v=this._element)===null||v===void 0||v.classList.toggle("xterm-cursor-pointer",h)))}},underline:{get:()=>{var h,u;return(u=(h=this._currentLink)===null||h===void 0?void 0:h.state)===null||u===void 0?void 0:u.decorations.underline},set:h=>{var u,v,S;!((u=this._currentLink)===null||u===void 0)&&u.state&&((S=(v=this._currentLink)===null||v===void 0?void 0:v.state)===null||S===void 0?void 0:S.decorations.underline)!==h&&(this._currentLink.state.decorations.underline=h,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,h))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((h=>{if(!this._currentLink)return;const u=h.start===0?0:h.start+1+this._bufferService.buffer.ydisp,v=this._bufferService.buffer.ydisp+1+h.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=v&&(this._clearCurrentLink(u,v),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(n,f,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(h,f.text)}_fireUnderlineEvent(n,f){const h=n.range,u=this._bufferService.buffer.ydisp,v=this._createLinkUnderlineEvent(h.start.x-1,h.start.y-u-1,h.end.x,h.end.y-u-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(v)}_linkLeave(n,f,h){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(h,f.text)}_linkAtPosition(n,f){const h=n.range.start.y*this._bufferService.cols+n.range.start.x,u=n.range.end.y*this._bufferService.cols+n.range.end.x,v=f.y*this._bufferService.cols+f.x;return h<=v&&v<=u}_positionFromMouseEvent(n,f,h){const u=h.getCoords(n,f,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,f,h,u,v){return{x1:n,y1:f,x2:h,y2:u,cols:this._bufferService.cols,fg:v}}};r.Linkifier2=g=l([d(0,y.IBufferService)],g)},9042:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(C,r,i){var l=this&&this.__decorate||function(g,n,f,h){var u,v=arguments.length,S=v<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,f):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(g,n,f,h);else for(var w=g.length-1;w>=0;w--)(u=g[w])&&(S=(v<3?u(S):v>3?u(n,f,S):u(n,f))||S);return v>3&&S&&Object.defineProperty(n,f,S),S},d=this&&this.__param||function(g,n){return function(f,h){n(f,h,g)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const o=i(511),p=i(2585);let _=r.OscLinkProvider=class{constructor(g,n,f){this._bufferService=g,this._optionsService=n,this._oscLinkService=f}provideLinks(g,n){var f;const h=this._bufferService.buffer.lines.get(g-1);if(!h)return void n(void 0);const u=[],v=this._optionsService.rawOptions.linkHandler,S=new o.CellData,w=h.getTrimmedLength();let k=-1,x=-1,E=!1;for(let A=0;A<w;A++)if(x!==-1||h.hasContent(A)){if(h.loadCell(A,S),S.hasExtendedAttrs()&&S.extended.urlId){if(x===-1){x=A,k=S.extended.urlId;continue}E=S.extended.urlId!==k}else x!==-1&&(E=!0);if(E||x!==-1&&A===w-1){const j=(f=this._oscLinkService.getLinkData(k))===null||f===void 0?void 0:f.uri;if(j){const T={start:{x:x+1,y:g},end:{x:A+(E||A!==w-1?0:1),y:g}};let N=!1;if(!v?.allowNonHttpProtocols)try{const I=new URL(j);["http:","https:"].includes(I.protocol)||(N=!0)}catch{N=!0}N||u.push({text:j,range:T,activate:(I,F)=>v?v.activate(I,F,T):y(0,F),hover:(I,F)=>{var H;return(H=v?.hover)===null||H===void 0?void 0:H.call(v,I,F,T)},leave:(I,F)=>{var H;return(H=v?.leave)===null||H===void 0?void 0:H.call(v,I,F,T)}})}E=!1,S.hasExtendedAttrs()&&S.extended.urlId?(x=A,k=S.extended.urlId):(x=-1,k=-1)}}n(u)}};function y(g,n){if(confirm(`Do you want to navigate to ${n}?
14
-
15
- WARNING: This link could potentially be dangerous`)){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=_=l([d(0,p.IBufferService),d(1,p.IOptionsService),d(2,p.IOscLinkService)],_)},6193:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const l=i(844);class d extends l.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.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)}}r.ScreenDprMonitor=d},3236:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const l=i(3614),d=i(3656),o=i(6465),p=i(9042),_=i(3730),y=i(1680),g=i(3107),n=i(5744),f=i(2950),h=i(1296),u=i(428),v=i(4269),S=i(5114),w=i(8934),k=i(3230),x=i(9312),E=i(4725),A=i(6731),j=i(8055),T=i(8969),N=i(8460),I=i(844),F=i(6114),H=i(8437),z=i(2584),D=i(7399),M=i(5941),P=i(9074),O=i(2585),U=i(5435),K=i(4567),X=typeof window<"u"?window.document:null;class G extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(L={}){super(L),this.browser=F,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new N.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new N.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new N.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new N.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new N.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new N.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new N.EventEmitter),this._onBlur=this.register(new N.EventEmitter),this._onA11yCharEmitter=this.register(new N.EventEmitter),this._onA11yTabEmitter=this.register(new N.EventEmitter),this._onWillOpen=this.register(new N.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(o.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((B,$)=>this.refresh(B,$)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((B=>this._reportWindowsOptions(B)))),this.register(this._inputHandler.onColor((B=>this._handleColorEvent(B)))),this.register((0,N.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,N.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((B=>this._afterResize(B.cols,B.rows)))),this.register((0,I.toDisposable)((()=>{var B,$;this._customKeyEventHandler=void 0,($=(B=this.element)===null||B===void 0?void 0:B.parentNode)===null||$===void 0||$.removeChild(this.element)})))}_handleColorEvent(L){if(this._themeService)for(const B of L){let $,W="";switch(B.index){case 256:$="foreground",W="10";break;case 257:$="background",W="11";break;case 258:$="cursor",W="12";break;default:$="ansi",W="4;"+B.index}switch(B.type){case 0:const J=j.color.toColorRGB($==="ansi"?this._themeService.colors.ansi[B.index]:this._themeService.colors[$]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,M.toRgbString)(J)}${z.C1_ESCAPED.ST}`);break;case 1:if($==="ansi")this._themeService.modifyColors((Y=>Y.ansi[B.index]=j.rgba.toColor(...B.color)));else{const Y=$;this._themeService.modifyColors((oe=>oe[Y]=j.rgba.toColor(...B.color)))}break;case 2:this._themeService.restoreColor(B.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(L){L?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(L){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(L),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var L;return(L=this.textarea)===null||L===void 0?void 0:L.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 L=this.buffer.ybase+this.buffer.y,B=this.buffer.lines.get(L);if(!B)return;const $=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,J=B.getWidth($),Y=this._renderService.dimensions.css.cell.width*J,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,de=$*this._renderService.dimensions.css.cell.width;this.textarea.style.left=de+"px",this.textarea.style.top=oe+"px",this.textarea.style.width=Y+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(B=>{this.hasSelection()&&(0,l.copyHandler)(B,this._selectionService)})));const L=B=>(0,l.handlePasteEvent)(B,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",L)),this.register((0,d.addDisposableDomListener)(this.element,"paste",L)),F.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(B=>{B.button===2&&(0,l.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(B=>{(0,l.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),F.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(B=>{B.button===1&&(0,l.moveTextAreaUnderMouseCursor)(B,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(L=>this._keyUp(L)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(L=>this._keyDown(L)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(L=>this._keyPress(L)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(L=>this._compositionHelper.compositionupdate(L)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(L=>this._inputEvent(L)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(L){var B;if(!L)throw new Error("Terminal requires a parent element.");L.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=L.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),L.appendChild(this.element);const $=X.createDocumentFragment();this._viewportElement=X.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),$.appendChild(this._viewportElement),this._viewportScrollArea=X.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=X.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=X.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),$.appendChild(this.screenElement),this.textarea=X.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),F.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,(B=this._document.defaultView)!==null&&B!==void 0?B:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,d.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(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(v.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(k.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.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=X.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(f.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild($);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(w.MouseService),this._instantiationService.setService(E.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(x.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.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,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(g.BufferDecorationRenderer,this.screenElement)),this.register((0,d.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(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(h.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const L=this,B=this.element;function $(Y){const oe=L._mouseService.getMouseReportCoords(Y,L.screenElement);if(!oe)return!1;let de,be;switch(Y.overrideType||Y.type){case"mousemove":be=32,Y.buttons===void 0?(de=3,Y.button!==void 0&&(de=Y.button<3?Y.button:3)):de=1&Y.buttons?0:4&Y.buttons?1:2&Y.buttons?2:3;break;case"mouseup":be=0,de=Y.button<3?Y.button:3;break;case"mousedown":be=1,de=Y.button<3?Y.button:3;break;case"wheel":if(L.viewport.getLinesScrolled(Y)===0)return!1;be=Y.deltaY<0?0:1,de=4;break;default:return!1}return!(be===void 0||de===void 0||de>4)&&L.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:de,action:be,ctrl:Y.ctrlKey,alt:Y.altKey,shift:Y.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},J={mouseup:Y=>($(Y),Y.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(Y)),wheel:Y=>($(Y),this.cancel(Y,!0)),mousedrag:Y=>{Y.buttons&&$(Y)},mousemove:Y=>{Y.buttons||$(Y)}};this.register(this.coreMouseService.onProtocolChange((Y=>{Y?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Y)),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&Y?W.mousemove||(B.addEventListener("mousemove",J.mousemove),W.mousemove=J.mousemove):(B.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&Y?W.wheel||(B.addEventListener("wheel",J.wheel,{passive:!1}),W.wheel=J.wheel):(B.removeEventListener("wheel",W.wheel),W.wheel=null),2&Y?W.mouseup||(B.addEventListener("mouseup",J.mouseup),W.mouseup=J.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),B.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&Y?W.mousedrag||(W.mousedrag=J.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(B,"mousedown",(Y=>{if(Y.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Y))return $(Y),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(Y)}))),this.register((0,d.addDisposableDomListener)(B,"wheel",(Y=>{if(!W.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(Y);if(oe===0)return;const de=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Y.deltaY<0?"A":"B");let be="";for(let Ee=0;Ee<Math.abs(oe);Ee++)be+=de;return this.coreService.triggerDataEvent(be,!0),this.cancel(Y,!0)}return this.viewport.handleWheel(Y)?this.cancel(Y):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(B,"touchstart",(Y=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Y),this.cancel(Y)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(B,"touchmove",(Y=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Y)?void 0:this.cancel(Y)}),{passive:!1}))}refresh(L,B){var $;($=this._renderService)===null||$===void 0||$.refreshRows(L,B)}updateCursorStyle(L){var B;!((B=this._selectionService)===null||B===void 0)&&B.shouldColumnSelect(L)?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(L,B,$=0){var W;$===1?(super.scrollLines(L,B,$),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(L)}paste(L){(0,l.paste)(L,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(L){this._customKeyEventHandler=L}registerLinkProvider(L){return this.linkifier2.registerLinkProvider(L)}registerCharacterJoiner(L){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const B=this._characterJoinerService.register(L);return this.refresh(0,this.rows-1),B}deregisterCharacterJoiner(L){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(L)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(L){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+L)}registerDecoration(L){return this._decorationService.registerDecoration(L)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(L,B,$){this._selectionService.setSelection(L,B,$)}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 L;(L=this._selectionService)===null||L===void 0||L.clearSelection()}selectAll(){var L;(L=this._selectionService)===null||L===void 0||L.selectAll()}selectLines(L,B){var $;($=this._selectionService)===null||$===void 0||$.selectLines(L,B)}_keyDown(L){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1)return!1;const B=this.browser.isMac&&this.options.macOptionIsMeta&&L.altKey;if(!B&&!this._compositionHelper.keydown(L))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;B||L.key!=="Dead"&&L.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const $=(0,D.evaluateKeyboardEvent)(L,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(L),$.type===3||$.type===2){const W=this.rows-1;return this.scrollLines($.type===2?-W:W),this.cancel(L,!0)}return $.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,L)||($.cancel&&this.cancel(L,!0),!$.key||!!(L.key&&!L.ctrlKey&&!L.altKey&&!L.metaKey&&L.key.length===1&&L.key.charCodeAt(0)>=65&&L.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):($.key!==z.C0.ETX&&$.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:$.key,domEvent:L}),this._showCursor(),this.coreService.triggerDataEvent($.key,!0),!this.optionsService.rawOptions.screenReaderMode||L.altKey||L.ctrlKey?this.cancel(L,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(L,B){const $=L.isMac&&!this.options.macOptionIsMeta&&B.altKey&&!B.ctrlKey&&!B.metaKey||L.isWindows&&B.altKey&&B.ctrlKey&&!B.metaKey||L.isWindows&&B.getModifierState("AltGraph");return B.type==="keypress"?$:$&&(!B.keyCode||B.keyCode>47)}_keyUp(L){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1||((function(B){return B.keyCode===16||B.keyCode===17||B.keyCode===18})(L)||this.focus(),this.updateCursorStyle(L),this._keyPressHandled=!1)}_keyPress(L){let B;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(L)===!1)return!1;if(this.cancel(L),L.charCode)B=L.charCode;else if(L.which===null||L.which===void 0)B=L.keyCode;else{if(L.which===0||L.charCode===0)return!1;B=L.which}return!(!B||(L.altKey||L.ctrlKey||L.metaKey)&&!this._isThirdLevelShift(this.browser,L)||(B=String.fromCharCode(B),this._onKey.fire({key:B,domEvent:L}),this._showCursor(),this.coreService.triggerDataEvent(B,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(L){if(L.data&&L.inputType==="insertText"&&(!L.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const B=L.data;return this.coreService.triggerDataEvent(B,!0),this.cancel(L),!0}return!1}resize(L,B){L!==this.cols||B!==this.rows?super.resize(L,B):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(L,B){var $,W;($=this._charSizeService)===null||$===void 0||$.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var L;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 B=1;B<this.rows;B++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(L=this.viewport)===null||L===void 0||L.reset(),this.refresh(0,this.rows-1)}}reset(){var L,B;this.options.rows=this.rows,this.options.cols=this.cols;const $=this._customKeyEventHandler;this._setup(),super.reset(),(L=this._selectionService)===null||L===void 0||L.reset(),this._decorationService.reset(),(B=this.viewport)===null||B===void 0||B.reset(),this._customKeyEventHandler=$,this.refresh(0,this.rows-1)}clearTextureAtlas(){var L;(L=this._renderService)===null||L===void 0||L.clearTextureAtlas()}_reportFocus(){var L;!((L=this.element)===null||L===void 0)&&L.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(L){if(this._renderService)switch(L){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const B=this._renderService.dimensions.css.canvas.width.toFixed(0),$=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${$};${B}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),J=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${J};${W}t`)}}cancel(L,B){if(this.options.cancelEvents||B)return L.preventDefault(),L.stopPropagation(),!1}}r.Terminal=G},9924:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const o=Date.now();if(o-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=o,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=o-this._lastRefreshMs,_=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(C,r,i){var l=this&&this.__decorate||function(f,h,u,v){var S,w=arguments.length,k=w<3?h:v===null?v=Object.getOwnPropertyDescriptor(h,u):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(f,h,u,v);else for(var x=f.length-1;x>=0;x--)(S=f[x])&&(k=(w<3?S(k):w>3?S(h,u,k):S(h,u))||k);return w>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(f,h){return function(u,v){h(u,v,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const o=i(3656),p=i(4725),_=i(8460),y=i(844),g=i(2585);let n=r.Viewport=class extends y.Disposable{constructor(f,h,u,v,S,w,k,x){super(),this._viewportElement=f,this._scrollArea=h,this._bufferService=u,this._optionsService=v,this._charSizeService=S,this._renderService=w,this._coreBrowserService=k,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,o.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(x.colors),this.register(x.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(f){this._viewportElement.style.backgroundColor=f.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(f){if(f)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 h=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==h&&(this._lastRecordedBufferHeight=h,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const f=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==f&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=f),this._refreshAnimationFrame=null}syncScrollArea(f=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(f);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(f)}_handleScroll(f){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 h=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const f=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(f*(this._smoothScrollState.target-this._smoothScrollState.origin)),f<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(f,h){const u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(h<0&&this._viewportElement.scrollTop!==0||h>0&&u<this._lastRecordedBufferHeight)||(f.cancelable&&f.preventDefault(),!1)}handleWheel(f){const h=this._getPixelsScrolled(f);return h!==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+h:this._smoothScrollState.target+=h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=h,this._bubbleScroll(f,h))}scrollLines(f){if(f!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const h=f*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+h,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:f,suppressScrollEvent:!1})}_getPixelsScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let h=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_LINE?h*=this._currentRowHeight:f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._currentRowHeight*this._bufferService.rows),h}getBufferElements(f,h){var u;let v,S="";const w=[],k=h??this._bufferService.buffer.lines.length,x=this._bufferService.buffer.lines;for(let E=f;E<k;E++){const A=x.get(E);if(!A)continue;const j=(u=x.get(E+1))===null||u===void 0?void 0:u.isWrapped;if(S+=A.translateToString(!j),!j||E===x.length-1){const T=document.createElement("div");T.textContent=S,w.push(T),S.length>0&&(v=T),S=""}}return{bufferElements:w,cursorElement:v}}getLinesScrolled(f){if(f.deltaY===0||f.shiftKey)return 0;let h=this._applyScrollModifier(f.deltaY,f);return f.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(h/=this._currentRowHeight+0,this._wheelPartialScroll+=h,h=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):f.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._bufferService.rows),h}_applyScrollModifier(f,h){const u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&h.altKey||u==="ctrl"&&h.ctrlKey||u==="shift"&&h.shiftKey?f*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:f*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(f){this._lastTouchY=f.touches[0].pageY}handleTouchMove(f){const h=this._lastTouchY-f.touches[0].pageY;return this._lastTouchY=f.touches[0].pageY,h!==0&&(this._viewportElement.scrollTop+=h,this._bubbleScroll(f,h))}};r.Viewport=n=l([d(2,g.IBufferService),d(3,g.IOptionsService),d(4,p.ICharSizeService),d(5,p.IRenderService),d(6,p.ICoreBrowserService),d(7,p.IThemeService)],n)},3107:function(C,r,i){var l=this&&this.__decorate||function(n,f,h,u){var v,S=arguments.length,w=S<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(S<3?v(w):S>3?v(f,h,w):v(f,h))||w);return S>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const o=i(3656),p=i(4725),_=i(844),y=i(2585);let g=r.BufferDecorationRenderer=class extends _.Disposable{constructor(n,f,h,u){super(),this._screenElement=n,this._bufferService=f,this._decorationService=h,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,o.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((v=>this._removeDecoration(v)))),this.register((0,_.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var f,h;const u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((f=n?.options)===null||f===void 0?void 0:f.layer)==="top"),u.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(n.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 v=(h=n.options.x)!==null&&h!==void 0?h:0;return v&&v>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(n,u),u}_refreshStyle(n){const f=n.marker.line-this._bufferService.buffers.active.ydisp;if(f<0||f>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let h=this._decorationElements.get(n);h||(h=this._createElement(n),n.element=h,this._decorationElements.set(n,h),this._container.appendChild(h),n.onDispose((()=>{this._decorationElements.delete(n),h.remove()}))),h.style.top=f*this._renderService.dimensions.css.cell.height+"px",h.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(h)}}_refreshXPosition(n,f=n.element){var h;if(!f)return;const u=(h=n.options.x)!==null&&h!==void 0?h:0;(n.options.anchor||"left")==="right"?f.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":f.style.left=u?u*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var f;(f=this._decorationElements.get(n))===null||f===void 0||f.remove(),this._decorationElements.delete(n),n.dispose()}};r.BufferDecorationRenderer=g=l([d(1,y.IBufferService),d(2,y.IDecorationService),d(3,p.IRenderService)],g)},5871:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,d){return l>=i.startBufferLine-this._linePadding[d||"full"]&&l<=i.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(C,r,i){var l=this&&this.__decorate||function(v,S,w,k){var x,E=arguments.length,A=E<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,S,w,k);else for(var j=v.length-1;j>=0;j--)(x=v[j])&&(A=(E<3?x(A):E>3?x(S,w,A):x(S,w))||A);return E>3&&A&&Object.defineProperty(S,w,A),A},d=this&&this.__param||function(v,S){return function(w,k){S(w,k,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const o=i(5871),p=i(3656),_=i(4725),y=i(844),g=i(2585),n={full:0,left:0,center:0,right:0},f={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0};let u=r.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(v,S,w,k,x,E,A){var j;super(),this._viewportElement=v,this._screenElement=S,this._bufferService=w,this._decorationService=k,this._renderService=x,this._optionsService=E,this._coreBrowseService=A,this._colorZoneStore=new o.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(),(j=this._viewportElement.parentElement)===null||j===void 0||j.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var N;(N=this._canvas)===null||N===void 0||N.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,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const v=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);f.full=this._canvas.width,f.left=v,f.center=S,f.right=v,this._refreshDrawHeightConstants(),h.full=0,h.left=0,h.center=f.left,h.right=f.left+f.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const v=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(v,12),6)*this._coreBrowseService.dpr);n.left=S,n.center=S,n.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.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 v=this._colorZoneStore.zones;for(const S of v)S.position!=="full"&&this._renderColorZone(S);for(const S of v)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(v){this._ctx.fillStyle=v.color,this._ctx.fillRect(h[v.position||"full"],Math.round((this._canvas.height-1)*(v.startBufferLine/this._bufferService.buffers.active.lines.length)-n[v.position||"full"]/2),f[v.position||"full"],Math.round((this._canvas.height-1)*((v.endBufferLine-v.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[v.position||"full"]))}_queueRefresh(v,S){this._shouldUpdateDimensions=v||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=u=l([d(2,g.IBufferService),d(3,g.IDecorationService),d(4,_.IRenderService),d(5,g.IOptionsService),d(6,_.ICoreBrowserService)],u)},2950:function(C,r,i){var l=this&&this.__decorate||function(g,n,f,h){var u,v=arguments.length,S=v<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,f):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(g,n,f,h);else for(var w=g.length-1;w>=0;w--)(u=g[w])&&(S=(v<3?u(S):v>3?u(n,f,S):u(n,f))||S);return v>3&&S&&Object.defineProperty(n,f,S),S},d=this&&this.__param||function(g,n){return function(f,h){n(f,h,g)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const o=i(4725),p=i(2585),_=i(2584);let y=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(g,n,f,h,u,v){this._textarea=g,this._compositionView=n,this._bufferService=f,this._optionsService=h,this._coreService=u,this._renderService=v,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(g){this._compositionView.textContent=g.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(g){if(this._isComposing||this._isSendingComposition){if(g.keyCode===229||g.keyCode===16||g.keyCode===17||g.keyCode===18)return!1;this._finalizeComposition(!1)}return g.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(g){if(this._compositionView.classList.remove("active"),this._isComposing=!1,g){const n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let f;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,f=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),f.length>0&&this._coreService.triggerDataEvent(f,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const g=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,f=n.replace(g,"");this._dataAlreadySent=f,n.length>g.length?this._coreService.triggerDataEvent(f,!0):n.length<g.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):n.length===g.length&&n!==g&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(g){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),f=this._renderService.dimensions.css.cell.height,h=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,u=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"px",this._compositionView.style.top=h+"px",this._compositionView.style.height=f+"px",this._compositionView.style.lineHeight=f+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const v=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=h+"px",this._textarea.style.width=Math.max(v.width,1)+"px",this._textarea.style.height=Math.max(v.height,1)+"px",this._textarea.style.lineHeight=v.height+"px"}g||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=y=l([d(2,p.IBufferService),d(3,p.IOptionsService),d(4,p.ICoreService),d(5,o.IRenderService)],y)},9806:(C,r)=>{function i(l,d,o){const p=o.getBoundingClientRect(),_=l.getComputedStyle(o),y=parseInt(_.getPropertyValue("padding-left")),g=parseInt(_.getPropertyValue("padding-top"));return[d.clientX-p.left-y,d.clientY-p.top-g]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=i,r.getCoords=function(l,d,o,p,_,y,g,n,f){if(!y)return;const h=i(l,d,o);return h?(h[0]=Math.ceil((h[0]+(f?g/2:0))/g),h[1]=Math.ceil(h[1]/n),h[0]=Math.min(Math.max(h[0],1),p+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),_),h):void 0}},9504:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const l=i(2584);function d(n,f,h,u){const v=n-o(n,h),S=f-o(f,h),w=Math.abs(v-S)-(function(k,x,E){let A=0;const j=k-o(k,E),T=x-o(x,E);for(let N=0;N<Math.abs(j-T);N++){const I=p(k,x)==="A"?-1:1,F=E.buffer.lines.get(j+I*N);F?.isWrapped&&A++}return A})(n,f,h);return g(w,y(p(n,f),u))}function o(n,f){let h=0,u=f.buffer.lines.get(n),v=u?.isWrapped;for(;v&&n>=0&&n<f.rows;)h++,u=f.buffer.lines.get(--n),v=u?.isWrapped;return h}function p(n,f){return n>f?"A":"B"}function _(n,f,h,u,v,S){let w=n,k=f,x="";for(;w!==h||k!==u;)w+=v?1:-1,v&&w>S.cols-1?(x+=S.buffer.translateBufferLineToString(k,!1,n,w),w=0,n=0,k++):!v&&w<0&&(x+=S.buffer.translateBufferLineToString(k,!1,0,n+1),w=S.cols-1,n=w,k--);return x+S.buffer.translateBufferLineToString(k,!1,n,w)}function y(n,f){const h=f?"O":"[";return l.C0.ESC+h+n}function g(n,f){n=Math.floor(n);let h="";for(let u=0;u<n;u++)h+=f;return h}r.moveToCellSequence=function(n,f,h,u){const v=h.buffer.x,S=h.buffer.y;if(!h.buffer.hasScrollback)return(function(x,E,A,j,T,N){return d(E,j,T,N).length===0?"":g(_(x,E,x,E-o(E,T),!1,T).length,y("D",N))})(v,S,0,f,h,u)+d(S,f,h,u)+(function(x,E,A,j,T,N){let I;I=d(E,j,T,N).length>0?j-o(j,T):E;const F=j,H=(function(z,D,M,P,O,U){let K;return K=d(M,P,O,U).length>0?P-o(P,O):D,z<M&&K<=P||z>=M&&K<P?"C":"D"})(x,E,A,j,T,N);return g(_(x,I,A,F,H==="C",T).length,y(H,N))})(v,S,n,f,h,u);let w;if(S===f)return w=v>n?"D":"C",g(Math.abs(v-n),y(w,u));w=S>f?"D":"C";const k=Math.abs(S-f);return g((function(x,E){return E.cols-x})(S>f?n:v,h)+(k-1)*h.cols+1+((S>f?v:n)-1),y(w,u))}},1296:function(C,r,i){var l=this&&this.__decorate||function(T,N,I,F){var H,z=arguments.length,D=z<3?N:F===null?F=Object.getOwnPropertyDescriptor(N,I):F;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(T,N,I,F);else for(var M=T.length-1;M>=0;M--)(H=T[M])&&(D=(z<3?H(D):z>3?H(N,I,D):H(N,I))||D);return z>3&&D&&Object.defineProperty(N,I,D),D},d=this&&this.__param||function(T,N){return function(I,F){N(I,F,T)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const o=i(3787),p=i(2550),_=i(2223),y=i(6171),g=i(4725),n=i(8055),f=i(8460),h=i(844),u=i(2585),v="xterm-dom-renderer-owner-",S="xterm-rows",w="xterm-fg-",k="xterm-bg-",x="xterm-focus",E="xterm-selection";let A=1,j=r.DomRenderer=class extends h.Disposable{constructor(T,N,I,F,H,z,D,M,P,O){super(),this._element=T,this._screenElement=N,this._viewportElement=I,this._linkifier2=F,this._charSizeService=z,this._optionsService=D,this._bufferService=M,this._coreBrowserService=P,this._themeService=O,this._terminalClass=A++,this._rowElements=[],this.onRequestRedraw=this.register(new f.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(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(o.DomRendererRowFactory,document),this._element.classList.add(v+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,h.toDisposable)((()=>{this._element.classList.remove(v+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new p.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const N=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=N,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let N=`${this._terminalSelector} .${S} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;N+=`${this._terminalSelector} .${S} .xterm-dim { color: ${n.color.multiplyOpacity(T.foreground,.5).css};}`,N+=`${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;}`,N+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",N+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,N+=`${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,N+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[I,F]of T.ansi.entries())N+=`${this._terminalSelector} .${w}${I} { color: ${F.css}; }${this._terminalSelector} .${w}${I}.xterm-dim { color: ${n.color.multiplyOpacity(F,.5).css}; }${this._terminalSelector} .${k}${I} { background-color: ${F.css}; }`;N+=`${this._terminalSelector} .${w}${_.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(T.background).css}; }${this._terminalSelector} .${w}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=N}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,N){for(let I=this._rowElements.length;I<=N;I++){const F=document.createElement("div");this._rowContainer.appendChild(F),this._rowElements.push(F)}for(;this._rowElements.length>N;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,N){this._refreshRowElements(T,N),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(x)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,N,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,N,I),this.renderRows(0,this._bufferService.rows-1),!T||!N)return;const F=T[1]-this._bufferService.buffer.ydisp,H=N[1]-this._bufferService.buffer.ydisp,z=Math.max(F,0),D=Math.min(H,this._bufferService.rows-1);if(z>=this._bufferService.rows||D<0)return;const M=document.createDocumentFragment();if(I){const P=T[0]>N[0];M.appendChild(this._createSelectionElement(z,P?N[0]:T[0],P?T[0]:N[0],D-z+1))}else{const P=F===z?T[0]:0,O=z===H?N[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(z,P,O));const U=D-z-1;if(M.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,U)),z!==D){const K=H===D?N[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(D,0,K))}}this._selectionContainer.appendChild(M)}_createSelectionElement(T,N,I,F=1){const H=document.createElement("div");return H.style.height=F*this.dimensions.css.cell.height+"px",H.style.top=T*this.dimensions.css.cell.height+"px",H.style.left=N*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(I-N)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,N){const I=this._bufferService.buffer,F=I.ybase+I.y,H=Math.min(I.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,D=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=T;P<=N;P++){const O=P+I.ydisp,U=this._rowElements[P],K=I.lines.get(O);if(!U||!K)break;U.replaceChildren(...this._rowFactory.createRow(K,O,O===F,D,M,H,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${v}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,N,I,F,H,z){I<0&&(T=0),F<0&&(N=0);const D=this._bufferService.rows-1;I=Math.max(Math.min(I,D),0),F=Math.max(Math.min(F,D),0),H=Math.min(H,this._bufferService.cols);const M=this._bufferService.buffer,P=M.ybase+M.y,O=Math.min(M.x,H-1),U=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let G=I;G<=F;++G){const ne=G+M.ydisp,L=this._rowElements[G],B=M.lines.get(ne);if(!L||!B)break;L.replaceChildren(...this._rowFactory.createRow(B,ne,ne===P,K,X,O,U,this.dimensions.css.cell.width,this._widthCache,z?G===I?T:0:-1,z?(G===F?N:H)-1:-1))}}};r.DomRenderer=j=l([d(4,u.IInstantiationService),d(5,g.ICharSizeService),d(6,u.IOptionsService),d(7,u.IBufferService),d(8,g.ICoreBrowserService),d(9,g.IThemeService)],j)},3787:function(C,r,i){var l=this&&this.__decorate||function(w,k,x,E){var A,j=arguments.length,T=j<3?k:E===null?E=Object.getOwnPropertyDescriptor(k,x):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(w,k,x,E);else for(var N=w.length-1;N>=0;N--)(A=w[N])&&(T=(j<3?A(T):j>3?A(k,x,T):A(k,x))||T);return j>3&&T&&Object.defineProperty(k,x,T),T},d=this&&this.__param||function(w,k){return function(x,E){k(x,E,w)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const o=i(2223),p=i(643),_=i(511),y=i(2585),g=i(8055),n=i(4725),f=i(4269),h=i(6171),u=i(3734);let v=r.DomRendererRowFactory=class{constructor(w,k,x,E,A,j,T){this._document=w,this._characterJoinerService=k,this._optionsService=x,this._coreBrowserService=E,this._coreService=A,this._decorationService=j,this._themeService=T,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(w,k,x){this._selectionStart=w,this._selectionEnd=k,this._columnSelectMode=x}createRow(w,k,x,E,A,j,T,N,I,F,H){const z=[],D=this._characterJoinerService.getJoinedCharacters(k),M=this._themeService.colors;let P,O=w.getNoBgTrimmedLength();x&&O<j+1&&(O=j+1);let U=0,K="",X=0,G=0,ne=0,L=!1,B=0,$=!1,W=0;const J=[],Y=F!==-1&&H!==-1;for(let oe=0;oe<O;oe++){w.loadCell(oe,this._workCell);let de=this._workCell.getWidth();if(de===0)continue;let be=!1,Ee=oe,te=this._workCell;if(D.length>0&&oe===D[0][0]){be=!0;const ve=D.shift();te=new f.JoinedCellData(this._workCell,w.translateToString(!0,ve[0],ve[1]),ve[1]-ve[0]),Ee=ve[1]-1,de=te.getWidth()}const Re=this._isCellInSelection(oe,k),De=x&&oe===j,Q=Y&&oe>=F&&oe<=H;let re=!1;this._decorationService.forEachDecorationAtCell(oe,k,void 0,(ve=>{re=!0}));let fe=te.getChars()||p.WHITESPACE_CELL_CHAR;if(fe===" "&&(te.isUnderline()||te.isOverline())&&(fe=" "),W=de*N-I.get(fe,te.isBold(),te.isItalic()),P){if(U&&(Re&&$||!Re&&!$&&te.bg===X)&&(Re&&$&&M.selectionForeground||te.fg===G)&&te.extended.ext===ne&&Q===L&&W===B&&!De&&!be&&!re){K+=fe,U++;continue}U&&(P.textContent=K),P=this._document.createElement("span"),U=0,K=""}else P=this._document.createElement("span");if(X=te.bg,G=te.fg,ne=te.extended.ext,L=Q,B=W,$=Re,be&&j>=oe&&j<=Ee&&(j=oe),!this._coreService.isCursorHidden&&De){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&J.push("xterm-cursor-blink"),J.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline")}}if(te.isBold()&&J.push("xterm-bold"),te.isItalic()&&J.push("xterm-italic"),te.isDim()&&J.push("xterm-dim"),K=te.isInvisible()?p.WHITESPACE_CELL_CHAR:te.getChars()||p.WHITESPACE_CELL_CHAR,te.isUnderline()&&(J.push(`xterm-underline-${te.extended.underlineStyle}`),K===" "&&(K=" "),!te.isUnderlineColorDefault()))if(te.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(te.getUnderlineColor()).join(",")})`;else{let ve=te.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&te.isBold()&&ve<8&&(ve+=8),P.style.textDecorationColor=M.ansi[ve].css}te.isOverline()&&(J.push("xterm-overline"),K===" "&&(K=" ")),te.isStrikethrough()&&J.push("xterm-strikethrough"),Q&&(P.style.textDecoration="underline");let se=te.getFgColor(),q=te.getFgColorMode(),ie=te.getBgColor(),pe=te.getBgColorMode();const Ie=!!te.isInverse();if(Ie){const ve=se;se=ie,ie=ve;const kt=q;q=pe,pe=kt}let je,Xe,Fe,Pe=!1;switch(this._decorationService.forEachDecorationAtCell(oe,k,void 0,(ve=>{ve.options.layer!=="top"&&Pe||(ve.backgroundColorRGB&&(pe=50331648,ie=ve.backgroundColorRGB.rgba>>8&16777215,je=ve.backgroundColorRGB),ve.foregroundColorRGB&&(q=50331648,se=ve.foregroundColorRGB.rgba>>8&16777215,Xe=ve.foregroundColorRGB),Pe=ve.options.layer==="top")})),!Pe&&Re&&(je=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,ie=je.rgba>>8&16777215,pe=50331648,Pe=!0,M.selectionForeground&&(q=50331648,se=M.selectionForeground.rgba>>8&16777215,Xe=M.selectionForeground)),Pe&&J.push("xterm-decoration-top"),pe){case 16777216:case 33554432:Fe=M.ansi[ie],J.push(`xterm-bg-${ie}`);break;case 50331648:Fe=g.rgba.toColor(ie>>16,ie>>8&255,255&ie),this._addStyle(P,`background-color:#${S((ie>>>0).toString(16),"0",6)}`);break;default:Ie?(Fe=M.foreground,J.push(`xterm-bg-${o.INVERTED_DEFAULT_COLOR}`)):Fe=M.background}switch(je||te.isDim()&&(je=g.color.multiplyOpacity(Fe,.5)),q){case 16777216:case 33554432:te.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(P,Fe,M.ansi[se],te,je,void 0)||J.push(`xterm-fg-${se}`);break;case 50331648:const ve=g.rgba.toColor(se>>16&255,se>>8&255,255&se);this._applyMinimumContrast(P,Fe,ve,te,je,Xe)||this._addStyle(P,`color:#${S(se.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Fe,M.foreground,te,je,void 0)||Ie&&J.push(`xterm-fg-${o.INVERTED_DEFAULT_COLOR}`)}J.length&&(P.className=J.join(" "),J.length=0),De||be||re?P.textContent=K:U++,W!==this.defaultSpacing&&(P.style.letterSpacing=`${W}px`),z.push(P),oe=Ee}return P&&U&&(P.textContent=K),z}_applyMinimumContrast(w,k,x,E,A,j){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,h.excludeFromContrastRatioDemands)(E.getCode()))return!1;const T=this._getContrastCache(E);let N;if(A||j||(N=T.getColor(k.rgba,x.rgba)),N===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);N=g.color.ensureContrastRatio(A||k,j||x,I),T.setColor((A||k).rgba,(j||x).rgba,N??null)}return!!N&&(this._addStyle(w,`color:${N.css}`),!0)}_getContrastCache(w){return w.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(w,k){w.setAttribute("style",`${w.getAttribute("style")||""}${k};`)}_isCellInSelection(w,k){const x=this._selectionStart,E=this._selectionEnd;return!(!x||!E)&&(this._columnSelectMode?x[0]<=E[0]?w>=x[0]&&k>=x[1]&&w<E[0]&&k<=E[1]:w<x[0]&&k>=x[1]&&w>=E[0]&&k<=E[1]:k>x[1]&&k<E[1]||x[1]===E[1]&&k===x[1]&&w>=x[0]&&w<E[0]||x[1]<E[1]&&k===E[1]&&w<E[0]||x[1]<E[1]&&k===x[1]&&w>=x[0])}};function S(w,k,x){for(;w.length<x;)w=k+w;return w}r.DomRendererRowFactory=v=l([d(1,n.ICharacterJoinerService),d(2,y.IOptionsService),d(3,n.ICoreBrowserService),d(4,y.ICoreService),d(5,y.IDecorationService),d(6,n.IThemeService)],v)},2550:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),d=i.createElement("span");d.style.fontWeight="bold";const o=i.createElement("span");o.style.fontStyle="italic";const p=i.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[l,d,o,p],this._container.appendChild(l),this._container.appendChild(d),this._container.appendChild(o),this._container.appendChild(p),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,d,o){i===this._font&&l===this._fontSize&&d===this._weight&&o===this._weightBold||(this._font=i,this._fontSize=l,this._weight=d,this._weightBold=o,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${o}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${o}`,this.clear())}get(i,l,d){let o=0;if(!l&&!d&&i.length===1&&(o=i.charCodeAt(0))<256)return this._flat[o]!==-9999?this._flat[o]:this._flat[o]=this._measure(i,0);let p=i;l&&(p+="B"),d&&(p+="I");let _=this._holey.get(p);if(_===void 0){let y=0;l&&(y|=1),d&&(y|=2),_=this._measure(i,y),this._holey.set(p,_)}return _}_measure(i,l){const d=this._measureElements[l];return d.textContent=i.repeat(32),d.offsetWidth/32}}},2223:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(C,r)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(r,"__esModule",{value:!0}),r.createRenderDimensions=r.excludeFromContrastRatioDemands=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},r.isPowerlineGlyph=i,r.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},r.excludeFromContrastRatioDemands=function(l){return i(l)||(function(d){return 9472<=d&&d<=9631})(l)},r.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:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(C,r,i){var l=this&&this.__decorate||function(n,f,h,u){var v,S=arguments.length,w=S<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(S<3?v(w):S>3?v(f,h,w):v(f,h))||w);return S>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const o=i(2585),p=i(8460),_=i(844);let y=r.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,f,h){super(),this._optionsService=h,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new g(n,f,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};r.CharSizeService=y=l([d(2,o.IOptionsService)],y);class g{constructor(f,h,u){this._document=f,this._parentElement=h,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 f={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return f.width!==0&&f.height!==0&&(this._result.width=f.width/32,this._result.height=Math.ceil(f.height)),this._result}}},4269:function(C,r,i){var l=this&&this.__decorate||function(f,h,u,v){var S,w=arguments.length,k=w<3?h:v===null?v=Object.getOwnPropertyDescriptor(h,u):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(f,h,u,v);else for(var x=f.length-1;x>=0;x--)(S=f[x])&&(k=(w<3?S(k):w>3?S(h,u,k):S(h,u))||k);return w>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(f,h){return function(u,v){h(u,v,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const o=i(3734),p=i(643),_=i(511),y=i(2585);class g extends o.AttributeData{constructor(h,u,v){super(),this.content=0,this.combinedData="",this.fg=h.fg,this.bg=h.bg,this.combinedData=u,this._width=v}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(h){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.JoinedCellData=g;let n=r.CharacterJoinerService=class yn{constructor(h){this._bufferService=h,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(h){const u={id:this._nextCharacterJoinerId++,handler:h};return this._characterJoiners.push(u),u.id}deregister(h){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===h)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(h){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(h);if(!u||u.length===0)return[];const v=[],S=u.translateToString(!0);let w=0,k=0,x=0,E=u.getFg(0),A=u.getBg(0);for(let j=0;j<u.getTrimmedLength();j++)if(u.loadCell(j,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==A){if(j-w>1){const T=this._getJoinedRanges(S,x,k,u,w);for(let N=0;N<T.length;N++)v.push(T[N])}w=j,x=k,E=this._workCell.fg,A=this._workCell.bg}k+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-w>1){const j=this._getJoinedRanges(S,x,k,u,w);for(let T=0;T<j.length;T++)v.push(j[T])}return v}_getJoinedRanges(h,u,v,S,w){const k=h.substring(u,v);let x=[];try{x=this._characterJoiners[0].handler(k)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const A=this._characterJoiners[E].handler(k);for(let j=0;j<A.length;j++)yn._mergeRanges(x,A[j])}catch(A){console.error(A)}return this._stringRangesToCellRanges(x,S,w),x}_stringRangesToCellRanges(h,u,v){let S=0,w=!1,k=0,x=h[S];if(x){for(let E=v;E<this._bufferService.cols;E++){const A=u.getWidth(E),j=u.getString(E).length||p.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!w&&x[0]<=k&&(x[0]=E,w=!0),x[1]<=k){if(x[1]=E,x=h[++S],!x)break;x[0]<=k?(x[0]=E,w=!0):w=!1}k+=j}}x&&(x[1]=this._bufferService.cols)}}static _mergeRanges(h,u){let v=!1;for(let S=0;S<h.length;S++){const w=h[S];if(v){if(u[1]<=w[0])return h[S-1][1]=u[1],h;if(u[1]<=w[1])return h[S-1][1]=Math.max(u[1],w[1]),h.splice(S,1),h;h.splice(S,1),S--}else{if(u[1]<=w[0])return h.splice(S,0,u),h;if(u[1]<=w[1])return w[0]=Math.min(u[0],w[0]),h;u[0]<w[1]&&(w[0]=Math.min(u[0],w[0]),v=!0)}}return v?h[h.length-1][1]=u[1]:h.push(u),h}};r.CharacterJoinerService=n=l([d(0,y.IBufferService)],n)},5114:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,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(C,r,i){var l=this&&this.__decorate||function(y,g,n,f){var h,u=arguments.length,v=u<3?g:f===null?f=Object.getOwnPropertyDescriptor(g,n):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(y,g,n,f);else for(var S=y.length-1;S>=0;S--)(h=y[S])&&(v=(u<3?h(v):u>3?h(g,n,v):h(g,n))||v);return u>3&&v&&Object.defineProperty(g,n,v),v},d=this&&this.__param||function(y,g){return function(n,f){g(n,f,y)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const o=i(4725),p=i(9806);let _=r.MouseService=class{constructor(y,g){this._renderService=y,this._charSizeService=g}getCoords(y,g,n,f,h){return(0,p.getCoords)(window,y,g,n,f,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,h)}getMouseReportCoords(y,g){const n=(0,p.getCoordsRelativeToElement)(window,y,g);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};r.MouseService=_=l([d(0,o.IRenderService),d(1,o.ICharSizeService)],_)},3230:function(C,r,i){var l=this&&this.__decorate||function(v,S,w,k){var x,E=arguments.length,A=E<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,S,w,k);else for(var j=v.length-1;j>=0;j--)(x=v[j])&&(A=(E<3?x(A):E>3?x(S,w,A):x(S,w))||A);return E>3&&A&&Object.defineProperty(S,w,A),A},d=this&&this.__param||function(v,S){return function(w,k){S(w,k,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const o=i(3656),p=i(6193),_=i(5596),y=i(4725),g=i(8460),n=i(844),f=i(7226),h=i(2585);let u=r.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,S,w,k,x,E,A,j){if(super(),this._rowCount=v,this._charSizeService=k,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new f.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 g.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new g.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new g.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new g.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(A.window,((T,N)=>this._renderRows(T,N))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(w.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(x.onDecorationRegistered((()=>this._fullRefresh()))),this.register(x.onDecorationRemoved((()=>this._fullRefresh()))),this.register(w.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(w.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,o.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(j.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const T=new A.window.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});T.observe(S),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.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(v,S,w=!1){this._isPaused?this._needsFullRefresh=!0:(w||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,S,this._rowCount))}_renderRows(v,S){this._renderer.value&&(v=Math.min(v,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(v,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:v,end:S}),this._onRender.fire({start:v,end:S}),this._isNextRenderRedrawOnly=!0)}resize(v,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(v){this._renderer.value=v,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var v,S;this._renderer.value&&((S=(v=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(v),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(v,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(v,S))):this._renderer.value.handleResize(v,S),this._fullRefresh())}handleCharSizeChanged(){var v;(v=this._renderer.value)===null||v===void 0||v.handleCharSizeChanged()}handleBlur(){var v;(v=this._renderer.value)===null||v===void 0||v.handleBlur()}handleFocus(){var v;(v=this._renderer.value)===null||v===void 0||v.handleFocus()}handleSelectionChanged(v,S,w){var k;this._selectionState.start=v,this._selectionState.end=S,this._selectionState.columnSelectMode=w,(k=this._renderer.value)===null||k===void 0||k.handleSelectionChanged(v,S,w)}handleCursorMove(){var v;(v=this._renderer.value)===null||v===void 0||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)===null||v===void 0||v.clear()}};r.RenderService=u=l([d(2,h.IOptionsService),d(3,y.ICharSizeService),d(4,h.IDecorationService),d(5,h.IBufferService),d(6,y.ICoreBrowserService),d(7,y.IThemeService)],u)},9312:function(C,r,i){var l=this&&this.__decorate||function(x,E,A,j){var T,N=arguments.length,I=N<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,A):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(x,E,A,j);else for(var F=x.length-1;F>=0;F--)(T=x[F])&&(I=(N<3?T(I):N>3?T(E,A,I):T(E,A))||I);return N>3&&I&&Object.defineProperty(E,A,I),I},d=this&&this.__param||function(x,E){return function(A,j){E(A,j,x)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const o=i(9806),p=i(9504),_=i(456),y=i(4725),g=i(8460),n=i(844),f=i(6114),h=i(4841),u=i(511),v=i(2585),S=" ",w=new RegExp(S,"g");let k=r.SelectionService=class extends n.Disposable{constructor(x,E,A,j,T,N,I,F,H){super(),this._element=x,this._screenElement=E,this._linkifier=A,this._bufferService=j,this._coreService=T,this._mouseService=N,this._optionsService=I,this._renderService=F,this._coreBrowserService=H,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 g.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new g.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new g.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new g.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((z=>this._handleTrim(z))),this.register(this._bufferService.buffers.onBufferActivate((z=>this._handleBufferActivate(z)))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,n.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 x=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!x||!E||x[0]===E[0]&&x[1]===E[1])}get selectionText(){const x=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!x||!E)return"";const A=this._bufferService.buffer,j=[];if(this._activeSelectionMode===3){if(x[0]===E[0])return"";const T=x[0]<E[0]?x[0]:E[0],N=x[0]<E[0]?E[0]:x[0];for(let I=x[1];I<=E[1];I++){const F=A.translateBufferLineToString(I,!0,T,N);j.push(F)}}else{const T=x[1]===E[1]?E[0]:void 0;j.push(A.translateBufferLineToString(x[1],!0,x[0],T));for(let N=x[1]+1;N<=E[1]-1;N++){const I=A.lines.get(N),F=A.translateBufferLineToString(N,!0);I?.isWrapped?j[j.length-1]+=F:j.push(F)}if(x[1]!==E[1]){const N=A.lines.get(E[1]),I=A.translateBufferLineToString(E[1],!0,0,E[0]);N&&N.isWrapped?j[j.length-1]+=I:j.push(I)}}return j.map((T=>T.replace(w," "))).join(f.isWindows?`\r
16
- `:`
17
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(x){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),f.isLinux&&x&&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(x){const E=this._getMouseBufferCoords(x),A=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!!(A&&j&&E)&&this._areCoordsInSelection(E,A,j)}isCellInSelection(x,E){const A=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!A||!j)&&this._areCoordsInSelection([x,E],A,j)}_areCoordsInSelection(x,E,A){return x[1]>E[1]&&x[1]<A[1]||E[1]===A[1]&&x[1]===E[1]&&x[0]>=E[0]&&x[0]<A[0]||E[1]<A[1]&&x[1]===A[1]&&x[0]<A[0]||E[1]<A[1]&&x[1]===E[1]&&x[0]>=E[0]}_selectWordAtCursor(x,E){var A,j;const T=(j=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||j===void 0?void 0:j.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,h.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const N=this._getMouseBufferCoords(x);return!!N&&(this._selectWordAt(N,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(x,E){this._model.clearSelection(),x=Math.max(x,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,x],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(x){this._model.handleTrim(x)&&this.refresh()}_getMouseBufferCoords(x){const E=this._mouseService.getCoords(x,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(x){let E=(0,o.getCoordsRelativeToElement)(this._coreBrowserService.window,x,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=A?0:(E>A&&(E-=A),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(x){return f.isMac?x.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:x.shiftKey}handleMouseDown(x){if(this._mouseDownTimeStamp=x.timeStamp,(x.button!==2||!this.hasSelection)&&x.button===0){if(!this._enabled){if(!this.shouldForceSelection(x))return;x.stopPropagation()}x.preventDefault(),this._dragScrollAmount=0,this._enabled&&x.shiftKey?this._handleIncrementalClick(x):x.detail===1?this._handleSingleClick(x):x.detail===2?this._handleDoubleClick(x):x.detail===3&&this._handleTripleClick(x),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(x){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(x))}_handleSingleClick(x){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(x)?3:0,this._model.selectionStart=this._getMouseBufferCoords(x),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(x){this._selectWordAtCursor(x,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(x){const E=this._getMouseBufferCoords(x);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(x){return x.altKey&&!(f.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(x){if(x.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(x),!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(x),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const j=A.lines.get(this._model.selectionEnd[1]);j&&j.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}E&&E[0]===this._model.selectionEnd[0]&&E[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 x=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(x.ydisp+this._bufferService.rows,x.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=x.ydisp),this.refresh()}}_handleMouseUp(x){const E=x.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&x.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(x,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const j=(0,p.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(j,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const x=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,A=!(!x||!E||x[0]===E[0]&&x[1]===E[1]);A?x&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&x[0]===this._oldSelectionStart[0]&&x[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(x,E,A)):this._oldHasSelection&&this._fireOnSelectionChange(x,E,A)}_fireOnSelectionChange(x,E,A){this._oldSelectionStart=x,this._oldSelectionEnd=E,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(x){this.clearSelection(),this._trimListener.dispose(),this._trimListener=x.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(x,E){let A=E;for(let j=0;E>=j;j++){const T=x.loadCell(j,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:T>1&&E!==j&&(A+=T-1)}return A}setSelection(x,E,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[x,E],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(x){this._isClickInSelection(x)||(this._selectWordAtCursor(x,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(x,E,A=!0,j=!0){if(x[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,N=T.lines.get(x[1]);if(!N)return;const I=T.translateBufferLineToString(x[1],!1);let F=this._convertViewportColToCharacterIndex(N,x[0]),H=F;const z=x[0]-F;let D=0,M=0,P=0,O=0;if(I.charAt(F)===" "){for(;F>0&&I.charAt(F-1)===" ";)F--;for(;H<I.length&&I.charAt(H+1)===" ";)H++}else{let X=x[0],G=x[0];N.getWidth(X)===0&&(D++,X--),N.getWidth(G)===2&&(M++,G++);const ne=N.getString(G).length;for(ne>1&&(O+=ne-1,H+=ne-1);X>0&&F>0&&!this._isCharWordSeparator(N.loadCell(X-1,this._workCell));){N.loadCell(X-1,this._workCell);const L=this._workCell.getChars().length;this._workCell.getWidth()===0?(D++,X--):L>1&&(P+=L-1,F-=L-1),F--,X--}for(;G<N.length&&H+1<I.length&&!this._isCharWordSeparator(N.loadCell(G+1,this._workCell));){N.loadCell(G+1,this._workCell);const L=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,G++):L>1&&(O+=L-1,H+=L-1),H++,G++}}H++;let U=F+z-D+P,K=Math.min(this._bufferService.cols,H-F+D+M-P-O);if(E||I.slice(F,H).trim()!==""){if(A&&U===0&&N.getCodePoint(0)!==32){const X=T.lines.get(x[1]-1);if(X&&N.isWrapped&&X.getCodePoint(this._bufferService.cols-1)!==32){const G=this._getWordAt([this._bufferService.cols-1,x[1]-1],!1,!0,!1);if(G){const ne=this._bufferService.cols-G.start;U-=ne,K+=ne}}}if(j&&U+K===this._bufferService.cols&&N.getCodePoint(this._bufferService.cols-1)!==32){const X=T.lines.get(x[1]+1);if(X?.isWrapped&&X.getCodePoint(0)!==32){const G=this._getWordAt([0,x[1]+1],!1,!1,!0);G&&(K+=G.length)}}return{start:U,length:K}}}_selectWordAt(x,E){const A=this._getWordAt(x,E);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,x[1]--;this._model.selectionStart=[A.start,x[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(x){const E=this._getWordAt(x,!0);if(E){let A=x[1];for(;E.start<0;)E.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,A]}}_isCharWordSeparator(x){return x.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(x.getChars())>=0}_selectLineAt(x){const E=this._bufferService.buffer.getWrappedRangeForLine(x),A={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,h.getRangeLength)(A,this._bufferService.cols)}};r.SelectionService=k=l([d(3,v.IBufferService),d(4,v.ICoreService),d(5,y.IMouseService),d(6,v.IOptionsService),d(7,y.IRenderService),d(8,y.ICoreBrowserService)],k)},4725:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const l=i(8343);r.ICharSizeService=(0,l.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),r.IMouseService=(0,l.createDecorator)("MouseService"),r.IRenderService=(0,l.createDecorator)("RenderService"),r.ISelectionService=(0,l.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(C,r,i){var l=this&&this.__decorate||function(k,x,E,A){var j,T=arguments.length,N=T<3?x:A===null?A=Object.getOwnPropertyDescriptor(x,E):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(k,x,E,A);else for(var I=k.length-1;I>=0;I--)(j=k[I])&&(N=(T<3?j(N):T>3?j(x,E,N):j(x,E))||N);return T>3&&N&&Object.defineProperty(x,E,N),N},d=this&&this.__param||function(k,x){return function(E,A){x(E,A,k)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const o=i(7239),p=i(8055),_=i(8460),y=i(844),g=i(2585),n=p.css.toColor("#ffffff"),f=p.css.toColor("#000000"),h=p.css.toColor("#ffffff"),u=p.css.toColor("#000000"),v={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const k=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],x=[0,95,135,175,215,255];for(let E=0;E<216;E++){const A=x[E/36%6|0],j=x[E/6%6|0],T=x[E%6];k.push({css:p.channels.toCss(A,j,T),rgba:p.channels.toRgba(A,j,T)})}for(let E=0;E<24;E++){const A=8+10*E;k.push({css:p.channels.toCss(A,A,A),rgba:p.channels.toRgba(A,A,A)})}return k})());let S=r.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(k){super(),this._optionsService=k,this._contrastCache=new o.ColorContrastCache,this._halfContrastCache=new o.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:f,cursor:h,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:v,selectionBackgroundOpaque:p.color.blend(f,v),selectionInactiveBackgroundTransparent:v,selectionInactiveBackgroundOpaque:p.color.blend(f,v),ansi:r.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(k={}){const x=this._colors;if(x.foreground=w(k.foreground,n),x.background=w(k.background,f),x.cursor=w(k.cursor,h),x.cursorAccent=w(k.cursorAccent,u),x.selectionBackgroundTransparent=w(k.selectionBackground,v),x.selectionBackgroundOpaque=p.color.blend(x.background,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundTransparent=w(k.selectionInactiveBackground,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundOpaque=p.color.blend(x.background,x.selectionInactiveBackgroundTransparent),x.selectionForeground=k.selectionForeground?w(k.selectionForeground,p.NULL_COLOR):void 0,x.selectionForeground===p.NULL_COLOR&&(x.selectionForeground=void 0),p.color.isOpaque(x.selectionBackgroundTransparent)&&(x.selectionBackgroundTransparent=p.color.opacity(x.selectionBackgroundTransparent,.3)),p.color.isOpaque(x.selectionInactiveBackgroundTransparent)&&(x.selectionInactiveBackgroundTransparent=p.color.opacity(x.selectionInactiveBackgroundTransparent,.3)),x.ansi=r.DEFAULT_ANSI_COLORS.slice(),x.ansi[0]=w(k.black,r.DEFAULT_ANSI_COLORS[0]),x.ansi[1]=w(k.red,r.DEFAULT_ANSI_COLORS[1]),x.ansi[2]=w(k.green,r.DEFAULT_ANSI_COLORS[2]),x.ansi[3]=w(k.yellow,r.DEFAULT_ANSI_COLORS[3]),x.ansi[4]=w(k.blue,r.DEFAULT_ANSI_COLORS[4]),x.ansi[5]=w(k.magenta,r.DEFAULT_ANSI_COLORS[5]),x.ansi[6]=w(k.cyan,r.DEFAULT_ANSI_COLORS[6]),x.ansi[7]=w(k.white,r.DEFAULT_ANSI_COLORS[7]),x.ansi[8]=w(k.brightBlack,r.DEFAULT_ANSI_COLORS[8]),x.ansi[9]=w(k.brightRed,r.DEFAULT_ANSI_COLORS[9]),x.ansi[10]=w(k.brightGreen,r.DEFAULT_ANSI_COLORS[10]),x.ansi[11]=w(k.brightYellow,r.DEFAULT_ANSI_COLORS[11]),x.ansi[12]=w(k.brightBlue,r.DEFAULT_ANSI_COLORS[12]),x.ansi[13]=w(k.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),x.ansi[14]=w(k.brightCyan,r.DEFAULT_ANSI_COLORS[14]),x.ansi[15]=w(k.brightWhite,r.DEFAULT_ANSI_COLORS[15]),k.extendedAnsi){const E=Math.min(x.ansi.length-16,k.extendedAnsi.length);for(let A=0;A<E;A++)x.ansi[A+16]=w(k.extendedAnsi[A],r.DEFAULT_ANSI_COLORS[A+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(k){this._restoreColor(k),this._onChangeColors.fire(this.colors)}_restoreColor(k){if(k!==void 0)switch(k){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[k]=this._restoreColors.ansi[k]}else for(let x=0;x<this._restoreColors.ansi.length;++x)this._colors.ansi[x]=this._restoreColors.ansi[x]}modifyColors(k){k(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 w(k,x){if(k!==void 0)try{return p.css.toColor(k)}catch{}return x}r.ThemeService=S=l([d(0,g.IOptionsService)],S)},6349:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const l=i(8460),d=i(844);class o extends d.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(_){if(this._maxLength===_)return;const y=new Array(_);for(let g=0;g<Math.min(_,this.length);g++)y[g]=this._array[this._getCyclicIndex(g)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,y,...g){if(y){for(let n=_;n<this._length-y;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let n=this._length-1;n>=_;n--)this._array[this._getCyclicIndex(n+g.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<g.length;n++)this._array[this._getCyclicIndex(_+n)]=g[n];if(g.length&&this.onInsertEmitter.fire({index:_,amount:g.length}),this._length+g.length>this._maxLength){const n=this._length+g.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=g.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,g){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+g<0)throw new Error("Cannot shift elements in list beyond index 0");if(g>0){for(let f=y-1;f>=0;f--)this.set(_+f+g,this.get(_+f));const n=_+y+g-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<y;n++)this.set(_+n+g,this.get(_+n))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}r.CircularList=o},1439:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function i(l,d=5){if(typeof l!="object")return l;const o=Array.isArray(l)?[]:{};for(const p in l)o[p]=d<=1?l[p]:l[p]&&i(l[p],d-1);return o}},8055:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;const l=i(6114);let d=0,o=0,p=0,_=0;var y,g,n,f,h;function u(S){const w=S.toString(16);return w.length<2?"0"+w:w}function v(S,w){return S<w?(w+.05)/(S+.05):(S+.05)/(w+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(w,k,x,E){return E!==void 0?`#${u(w)}${u(k)}${u(x)}${u(E)}`:`#${u(w)}${u(k)}${u(x)}`},S.toRgba=function(w,k,x,E=255){return(w<<24|k<<16|x<<8|E)>>>0}})(y||(r.channels=y={})),(function(S){function w(k,x){return _=Math.round(255*x),[d,o,p]=h.toChannels(k.rgba),{css:y.toCss(d,o,p,_),rgba:y.toRgba(d,o,p,_)}}S.blend=function(k,x){if(_=(255&x.rgba)/255,_===1)return{css:x.css,rgba:x.rgba};const E=x.rgba>>24&255,A=x.rgba>>16&255,j=x.rgba>>8&255,T=k.rgba>>24&255,N=k.rgba>>16&255,I=k.rgba>>8&255;return d=T+Math.round((E-T)*_),o=N+Math.round((A-N)*_),p=I+Math.round((j-I)*_),{css:y.toCss(d,o,p),rgba:y.toRgba(d,o,p)}},S.isOpaque=function(k){return(255&k.rgba)==255},S.ensureContrastRatio=function(k,x,E){const A=h.ensureContrastRatio(k.rgba,x.rgba,E);if(A)return h.toColor(A>>24&255,A>>16&255,A>>8&255)},S.opaque=function(k){const x=(255|k.rgba)>>>0;return[d,o,p]=h.toChannels(x),{css:y.toCss(d,o,p),rgba:x}},S.opacity=w,S.multiplyOpacity=function(k,x){return _=255&k.rgba,w(k,_*x/255)},S.toColorRGB=function(k){return[k.rgba>>24&255,k.rgba>>16&255,k.rgba>>8&255]}})(g||(r.color=g={})),(function(S){let w,k;if(!l.isNode){const x=document.createElement("canvas");x.width=1,x.height=1;const E=x.getContext("2d",{willReadFrequently:!0});E&&(w=E,w.globalCompositeOperation="copy",k=w.createLinearGradient(0,0,1,1))}S.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return d=parseInt(x.slice(1,2).repeat(2),16),o=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),h.toColor(d,o,p);case 5:return d=parseInt(x.slice(1,2).repeat(2),16),o=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),_=parseInt(x.slice(4,5).repeat(2),16),h.toColor(d,o,p,_);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const E=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return d=parseInt(E[1]),o=parseInt(E[2]),p=parseInt(E[3]),_=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),h.toColor(d,o,p,_);if(!w||!k)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=k,w.fillStyle=x,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[d,o,p,_]=w.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(d,o,p,_),css:x}}})(n||(r.css=n={})),(function(S){function w(k,x,E){const A=k/255,j=x/255,T=E/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(j<=.03928?j/12.92:Math.pow((j+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}S.relativeLuminance=function(k){return w(k>>16&255,k>>8&255,255&k)},S.relativeLuminance2=w})(f||(r.rgb=f={})),(function(S){function w(x,E,A){const j=x>>24&255,T=x>>16&255,N=x>>8&255;let I=E>>24&255,F=E>>16&255,H=E>>8&255,z=v(f.relativeLuminance2(I,F,H),f.relativeLuminance2(j,T,N));for(;z<A&&(I>0||F>0||H>0);)I-=Math.max(0,Math.ceil(.1*I)),F-=Math.max(0,Math.ceil(.1*F)),H-=Math.max(0,Math.ceil(.1*H)),z=v(f.relativeLuminance2(I,F,H),f.relativeLuminance2(j,T,N));return(I<<24|F<<16|H<<8|255)>>>0}function k(x,E,A){const j=x>>24&255,T=x>>16&255,N=x>>8&255;let I=E>>24&255,F=E>>16&255,H=E>>8&255,z=v(f.relativeLuminance2(I,F,H),f.relativeLuminance2(j,T,N));for(;z<A&&(I<255||F<255||H<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),F=Math.min(255,F+Math.ceil(.1*(255-F))),H=Math.min(255,H+Math.ceil(.1*(255-H))),z=v(f.relativeLuminance2(I,F,H),f.relativeLuminance2(j,T,N));return(I<<24|F<<16|H<<8|255)>>>0}S.ensureContrastRatio=function(x,E,A){const j=f.relativeLuminance(x>>8),T=f.relativeLuminance(E>>8);if(v(j,T)<A){if(T<j){const F=w(x,E,A),H=v(j,f.relativeLuminance(F>>8));if(H<A){const z=k(x,E,A);return H>v(j,f.relativeLuminance(z>>8))?F:z}return F}const N=k(x,E,A),I=v(j,f.relativeLuminance(N>>8));if(I<A){const F=w(x,E,A);return I>v(j,f.relativeLuminance(F>>8))?N:F}return N}},S.reduceLuminance=w,S.increaseLuminance=k,S.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]},S.toColor=function(x,E,A,j){return{css:y.toCss(x,E,A,j),rgba:y.toRgba(x,E,A,j)}}})(h||(r.rgba=h={})),r.toPaddedHex=u,r.contrastRatio=v},8969:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const l=i(844),d=i(2585),o=i(4348),p=i(7866),_=i(744),y=i(7302),g=i(6975),n=i(8460),f=i(1753),h=i(1480),u=i(7994),v=i(9282),S=i(5435),w=i(5981),k=i(2660);let x=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((j=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(j.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(j){for(const T in j)this.optionsService.options[T]=j[T]}constructor(j){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new o.InstantiationService,this.optionsService=this.register(new y.OptionsService(j)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(g.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(f.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(h.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(k.OscLinkService),this._instantiationService.setService(d.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,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new w.WriteBuffer(((T,N)=>this._inputHandler.parse(T,N)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(j,T){this._writeBuffer.write(j,T)}writeSync(j,T){this._logService.logLevel<=d.LogLevelEnum.WARN&&!x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),x=!0),this._writeBuffer.writeSync(j,T)}resize(j,T){isNaN(j)||isNaN(T)||(j=Math.max(j,_.MINIMUM_COLS),T=Math.max(T,_.MINIMUM_ROWS),this._bufferService.resize(j,T))}scroll(j,T=!1){this._bufferService.scroll(j,T)}scrollLines(j,T,N){this._bufferService.scrollLines(j,T,N)}scrollPages(j){this.scrollLines(j*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(j){const T=j-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(j,T){return this._inputHandler.registerEscHandler(j,T)}registerDcsHandler(j,T){return this._inputHandler.registerDcsHandler(j,T)}registerCsiHandler(j,T){return this._inputHandler.registerCsiHandler(j,T)}registerOscHandler(j,T){return this._inputHandler.registerOscHandler(j,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let j=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?j=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(j=!0),j?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const j=[];j.push(this.onLineFeed(v.updateWindowsModeWrappedState.bind(null,this._bufferService))),j.push(this.registerCsiHandler({final:"H"},(()=>((0,v.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of j)T.dispose()}))}}}r.CoreTerminal=E},8460:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const d=[];for(let o=0;o<this._listeners.length;o++)d.push(this._listeners[o]);for(let o=0;o<d.length;o++)d[o].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(i,l){return i((d=>l.fire(d)))}},5435:function(C,r,i){var l=this&&this.__decorate||function(z,D,M,P){var O,U=arguments.length,K=U<3?D:P===null?P=Object.getOwnPropertyDescriptor(D,M):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(z,D,M,P);else for(var X=z.length-1;X>=0;X--)(O=z[X])&&(K=(U<3?O(K):U>3?O(D,M,K):O(D,M))||K);return U>3&&K&&Object.defineProperty(D,M,K),K},d=this&&this.__param||function(z,D){return function(M,P){D(M,P,z)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const o=i(2584),p=i(7116),_=i(2015),y=i(844),g=i(482),n=i(8437),f=i(8460),h=i(643),u=i(511),v=i(3734),S=i(2585),w=i(6242),k=i(6351),x=i(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function j(z,D){if(z>24)return D.setWinLines||!1;switch(z){case 1:return!!D.restoreWin;case 2:return!!D.minimizeWin;case 3:return!!D.setWinPosition;case 4:return!!D.setWinSizePixels;case 5:return!!D.raiseWin;case 6:return!!D.lowerWin;case 7:return!!D.refreshWin;case 8:return!!D.setWinSizeChars;case 9:return!!D.maximizeWin;case 10:return!!D.fullscreenWin;case 11:return!!D.getWinState;case 13:return!!D.getWinPosition;case 14:return!!D.getWinSizePixels;case 15:return!!D.getScreenSizePixels;case 16:return!!D.getCellSizePixels;case 18:return!!D.getWinSizeChars;case 19:return!!D.getScreenSizeChars;case 20:return!!D.getIconTitle;case 21:return!!D.getWinTitle;case 22:return!!D.pushTitle;case 23:return!!D.popTitle;case 24:return!!D.setWinLines}return!1}var T;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(r.WindowsOptionsReportType=T={}));let N=0;class I extends y.Disposable{getAttrData(){return this._curAttrData}constructor(D,M,P,O,U,K,X,G,ne=new _.EscapeSequenceParser){super(),this._bufferService=D,this._charsetService=M,this._coreService=P,this._logService=O,this._optionsService=U,this._oscLinkService=K,this._coreMouseService=X,this._unicodeService=G,this._parser=ne,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new g.StringToUtf32,this._utf8Decoder=new g.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new f.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new f.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new f.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new f.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new f.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new f.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new f.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new f.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new f.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new f.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new f.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new f.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 F(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((L=>this._activeBuffer=L.activeBuffer))),this._parser.setCsiHandlerFallback(((L,B)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(L),params:B.toArray()})})),this._parser.setEscHandlerFallback((L=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(L)})})),this._parser.setExecuteHandlerFallback((L=>{this._logService.debug("Unknown EXECUTE code: ",{code:L})})),this._parser.setOscHandlerFallback(((L,B,$)=>{this._logService.debug("Unknown OSC code: ",{identifier:L,action:B,data:$})})),this._parser.setDcsHandlerFallback(((L,B,$)=>{B==="HOOK"&&($=$.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(L),action:B,payload:$})})),this._parser.setPrintHandler(((L,B,$)=>this.print(L,B,$))),this._parser.registerCsiHandler({final:"@"},(L=>this.insertChars(L))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(L=>this.scrollLeft(L))),this._parser.registerCsiHandler({final:"A"},(L=>this.cursorUp(L))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(L=>this.scrollRight(L))),this._parser.registerCsiHandler({final:"B"},(L=>this.cursorDown(L))),this._parser.registerCsiHandler({final:"C"},(L=>this.cursorForward(L))),this._parser.registerCsiHandler({final:"D"},(L=>this.cursorBackward(L))),this._parser.registerCsiHandler({final:"E"},(L=>this.cursorNextLine(L))),this._parser.registerCsiHandler({final:"F"},(L=>this.cursorPrecedingLine(L))),this._parser.registerCsiHandler({final:"G"},(L=>this.cursorCharAbsolute(L))),this._parser.registerCsiHandler({final:"H"},(L=>this.cursorPosition(L))),this._parser.registerCsiHandler({final:"I"},(L=>this.cursorForwardTab(L))),this._parser.registerCsiHandler({final:"J"},(L=>this.eraseInDisplay(L,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(L=>this.eraseInDisplay(L,!0))),this._parser.registerCsiHandler({final:"K"},(L=>this.eraseInLine(L,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(L=>this.eraseInLine(L,!0))),this._parser.registerCsiHandler({final:"L"},(L=>this.insertLines(L))),this._parser.registerCsiHandler({final:"M"},(L=>this.deleteLines(L))),this._parser.registerCsiHandler({final:"P"},(L=>this.deleteChars(L))),this._parser.registerCsiHandler({final:"S"},(L=>this.scrollUp(L))),this._parser.registerCsiHandler({final:"T"},(L=>this.scrollDown(L))),this._parser.registerCsiHandler({final:"X"},(L=>this.eraseChars(L))),this._parser.registerCsiHandler({final:"Z"},(L=>this.cursorBackwardTab(L))),this._parser.registerCsiHandler({final:"`"},(L=>this.charPosAbsolute(L))),this._parser.registerCsiHandler({final:"a"},(L=>this.hPositionRelative(L))),this._parser.registerCsiHandler({final:"b"},(L=>this.repeatPrecedingCharacter(L))),this._parser.registerCsiHandler({final:"c"},(L=>this.sendDeviceAttributesPrimary(L))),this._parser.registerCsiHandler({prefix:">",final:"c"},(L=>this.sendDeviceAttributesSecondary(L))),this._parser.registerCsiHandler({final:"d"},(L=>this.linePosAbsolute(L))),this._parser.registerCsiHandler({final:"e"},(L=>this.vPositionRelative(L))),this._parser.registerCsiHandler({final:"f"},(L=>this.hVPosition(L))),this._parser.registerCsiHandler({final:"g"},(L=>this.tabClear(L))),this._parser.registerCsiHandler({final:"h"},(L=>this.setMode(L))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(L=>this.setModePrivate(L))),this._parser.registerCsiHandler({final:"l"},(L=>this.resetMode(L))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(L=>this.resetModePrivate(L))),this._parser.registerCsiHandler({final:"m"},(L=>this.charAttributes(L))),this._parser.registerCsiHandler({final:"n"},(L=>this.deviceStatus(L))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(L=>this.deviceStatusPrivate(L))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(L=>this.softReset(L))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(L=>this.setCursorStyle(L))),this._parser.registerCsiHandler({final:"r"},(L=>this.setScrollRegion(L))),this._parser.registerCsiHandler({final:"s"},(L=>this.saveCursor(L))),this._parser.registerCsiHandler({final:"t"},(L=>this.windowOptions(L))),this._parser.registerCsiHandler({final:"u"},(L=>this.restoreCursor(L))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(L=>this.insertColumns(L))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(L=>this.deleteColumns(L))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(L=>this.selectProtected(L))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(L=>this.requestMode(L,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(L=>this.requestMode(L,!1))),this._parser.setExecuteHandler(o.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(o.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(o.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(o.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(o.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(o.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(o.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(o.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(o.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(o.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new w.OscHandler((L=>(this.setTitle(L),this.setIconName(L),!0)))),this._parser.registerOscHandler(1,new w.OscHandler((L=>this.setIconName(L)))),this._parser.registerOscHandler(2,new w.OscHandler((L=>this.setTitle(L)))),this._parser.registerOscHandler(4,new w.OscHandler((L=>this.setOrReportIndexedColor(L)))),this._parser.registerOscHandler(8,new w.OscHandler((L=>this.setHyperlink(L)))),this._parser.registerOscHandler(10,new w.OscHandler((L=>this.setOrReportFgColor(L)))),this._parser.registerOscHandler(11,new w.OscHandler((L=>this.setOrReportBgColor(L)))),this._parser.registerOscHandler(12,new w.OscHandler((L=>this.setOrReportCursorColor(L)))),this._parser.registerOscHandler(104,new w.OscHandler((L=>this.restoreIndexedColor(L)))),this._parser.registerOscHandler(110,new w.OscHandler((L=>this.restoreFgColor(L)))),this._parser.registerOscHandler(111,new w.OscHandler((L=>this.restoreBgColor(L)))),this._parser.registerOscHandler(112,new w.OscHandler((L=>this.restoreCursorColor(L)))),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 L in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:L},(()=>this.selectCharset("("+L))),this._parser.registerEscHandler({intermediates:")",final:L},(()=>this.selectCharset(")"+L))),this._parser.registerEscHandler({intermediates:"*",final:L},(()=>this.selectCharset("*"+L))),this._parser.registerEscHandler({intermediates:"+",final:L},(()=>this.selectCharset("+"+L))),this._parser.registerEscHandler({intermediates:"-",final:L},(()=>this.selectCharset("-"+L))),this._parser.registerEscHandler({intermediates:".",final:L},(()=>this.selectCharset("."+L))),this._parser.registerEscHandler({intermediates:"/",final:L},(()=>this.selectCharset("/"+L)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((L=>(this._logService.error("Parsing error: ",L),L))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new k.DcsHandler(((L,B)=>this.requestStatusString(L,B))))}_preserveStack(D,M,P,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=D,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=P,this._parseStack.position=O}_logSlowResolvingAsync(D){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([D,new Promise(((M,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(D,M){let P,O=this._activeBuffer.x,U=this._activeBuffer.y,K=0;const X=this._parseStack.paused;if(X){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(P),P;O=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,D.length>A&&(K=this._parseStack.position+A)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof D=="string"?` "${D}"`:` "${Array.prototype.map.call(D,(G=>String.fromCharCode(G))).join("")}"`),typeof D=="string"?D.split("").map((G=>G.charCodeAt(0))):D),this._parseBuffer.length<D.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(D.length,A))),X||this._dirtyRowTracker.clearRange(),D.length>A)for(let G=K;G<D.length;G+=A){const ne=G+A<D.length?G+A:D.length,L=typeof D=="string"?this._stringDecoder.decode(D.substring(G,ne),this._parseBuffer):this._utf8Decoder.decode(D.subarray(G,ne),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,L))return this._preserveStack(O,U,L,G),this._logSlowResolvingAsync(P),P}else if(!X){const G=typeof D=="string"?this._stringDecoder.decode(D,this._parseBuffer):this._utf8Decoder.decode(D,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,G))return this._preserveStack(O,U,G,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===O&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(D,M,P){let O,U;const K=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,G=this._bufferService.cols,ne=this._coreService.decPrivateModes.wraparound,L=this._coreService.modes.insertMode,B=this._curAttrData;let $=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-M>0&&$.getWidth(this._activeBuffer.x-1)===2&&$.setCellFromCodePoint(this._activeBuffer.x-1,0,1,B.fg,B.bg,B.extended);for(let W=M;W<P;++W){if(O=D[W],U=this._unicodeService.wcwidth(O),O<127&&K){const J=K[String.fromCharCode(O)];J&&(O=J.charCodeAt(0))}if(X&&this._onA11yChar.fire((0,g.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=G){if(ne){for(;this._activeBuffer.x<G;)$.setCellFromCodePoint(this._activeBuffer.x++,0,1,B.fg,B.bg,B.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),$=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=G-1,U===2)continue}if(L&&($.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(B),B),$.getWidth(G-1)===2&&$.setCellFromCodePoint(G-1,h.NULL_CELL_CODE,h.NULL_CELL_WIDTH,B.fg,B.bg,B.extended)),$.setCellFromCodePoint(this._activeBuffer.x++,O,U,B.fg,B.bg,B.extended),U>0)for(;--U;)$.setCellFromCodePoint(this._activeBuffer.x++,0,0,B.fg,B.bg,B.extended)}else $.getWidth(this._activeBuffer.x-1)?$.addCodepointToCell(this._activeBuffer.x-1,O):$.addCodepointToCell(this._activeBuffer.x-2,O)}P-M>0&&($.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<G&&P-M>0&&$.getWidth(this._activeBuffer.x)===0&&!$.hasContent(this._activeBuffer.x)&&$.setCellFromCodePoint(this._activeBuffer.x,0,1,B.fg,B.bg,B.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(D,M){return D.final!=="t"||D.prefix||D.intermediates?this._parser.registerCsiHandler(D,M):this._parser.registerCsiHandler(D,(P=>!j(P.params[0],this._optionsService.rawOptions.windowOptions)||M(P)))}registerDcsHandler(D,M){return this._parser.registerDcsHandler(D,new k.DcsHandler(M))}registerEscHandler(D,M){return this._parser.registerEscHandler(D,M)}registerOscHandler(D,M){return this._parser.registerOscHandler(D,new w.OscHandler(M))}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 D;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&&(!((D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||D===void 0)&&D.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const D=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-D),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(D=this._bufferService.cols-1){this._activeBuffer.x=Math.min(D,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(D,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=D,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=D,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(D,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+D,this._activeBuffer.y+M)}cursorUp(D){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,D.params[0]||1)):this._moveCursor(0,-(D.params[0]||1)),!0}cursorDown(D){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,D.params[0]||1)):this._moveCursor(0,D.params[0]||1),!0}cursorForward(D){return this._moveCursor(D.params[0]||1,0),!0}cursorBackward(D){return this._moveCursor(-(D.params[0]||1),0),!0}cursorNextLine(D){return this.cursorDown(D),this._activeBuffer.x=0,!0}cursorPrecedingLine(D){return this.cursorUp(D),this._activeBuffer.x=0,!0}cursorCharAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(D){return this._setCursor(D.length>=2?(D.params[1]||1)-1:0,(D.params[0]||1)-1),!0}charPosAbsolute(D){return this._setCursor((D.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(D){return this._moveCursor(D.params[0]||1,0),!0}linePosAbsolute(D){return this._setCursor(this._activeBuffer.x,(D.params[0]||1)-1),!0}vPositionRelative(D){return this._moveCursor(0,D.params[0]||1),!0}hVPosition(D){return this.cursorPosition(D),!0}tabClear(D){const M=D.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=D.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(D){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=D.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(D){const M=D.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(D,M,P,O=!1,U=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);K.replaceCells(M,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),O&&(K.isWrapped=!1)}_resetBufferLine(D,M=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+D),P.isWrapped=!1)}eraseInDisplay(D,M=!1){let P;switch(this._restrictCursor(this._bufferService.cols),D.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);P<this._bufferService.rows;P++)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,M);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(D,M=!1){switch(this._restrictCursor(this._bufferService.cols),D.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(D){this._restrictCursor();let M=D.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(D){this._restrictCursor();let M=D.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;M--;)this._activeBuffer.lines.splice(P,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}insertChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,D.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(D){let M=D.params[0]||1;for(;M--;)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(D){let M=D.params[0]||1;for(;M--;)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(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(D){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=D.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(D){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(D.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(D){if(!this._parser.precedingCodepoint)return!0;const M=D.params[0]||1,P=new Uint32Array(M);for(let O=0;O<M;++O)P[O]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(D){return D.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(D){return D.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(D.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c")),!0}_is(D){return(this._optionsService.rawOptions.termName+"").indexOf(D)===0}setMode(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.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(D){for(let M=0;M<D.length;M++)switch(D.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(D){for(let M=0;M<D.length;M++)switch(D.params[M]){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(),D.params[M]===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(D,M){const P=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:U}=this._coreMouseService,K=this._coreService,{buffers:X,cols:G}=this._bufferService,{active:ne,alt:L}=X,B=this._optionsService.rawOptions,$=oe=>oe?1:2,W=D.params[0];return J=W,Y=M?W===2?4:W===4?$(K.modes.insertMode):W===12?3:W===20?$(B.convertEol):0:W===1?$(P.applicationCursorKeys):W===3?B.windowOptions.setWinLines?G===80?2:G===132?1:0:0:W===6?$(P.origin):W===7?$(P.wraparound):W===8?3:W===9?$(O==="X10"):W===12?$(B.cursorBlink):W===25?$(!K.isCursorHidden):W===45?$(P.reverseWraparound):W===66?$(P.applicationKeypad):W===67?4:W===1e3?$(O==="VT200"):W===1002?$(O==="DRAG"):W===1003?$(O==="ANY"):W===1004?$(P.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?$(ne===L):W===2004?$(P.bracketedPasteMode):0,K.triggerDataEvent(`${o.C0.ESC}[${M?"":"?"}${J};${Y}$y`),!0;var J,Y}_updateAttrColor(D,M,P,O,U){return M===2?(D|=50331648,D&=-16777216,D|=v.AttributeData.fromColorRGB([P,O,U])):M===5&&(D&=-50331904,D|=33554432|255&P),D}_extractColor(D,M,P){const O=[0,0,-1,0,0,0];let U=0,K=0;do{if(O[K+U]=D.params[M+K],D.hasSubParams(M+K)){const X=D.getSubParams(M+K);let G=0;do O[1]===5&&(U=1),O[K+G+1+U]=X[G];while(++G<X.length&&G+K+1+U<O.length);break}if(O[1]===5&&K+U>=2||O[1]===2&&K+U>=5)break;O[1]&&(U=1)}while(++K+M<D.length&&K+U<O.length);for(let X=2;X<O.length;++X)O[X]===-1&&(O[X]=0);switch(O[0]){case 38:P.fg=this._updateAttrColor(P.fg,O[1],O[3],O[4],O[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,O[1],O[3],O[4],O[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,O[1],O[3],O[4],O[5])}return K}_processUnderline(D,M){M.extended=M.extended.clone(),(!~D||D>5)&&(D=1),M.extended.underlineStyle=D,M.fg|=268435456,D===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(D){D.fg=n.DEFAULT_ATTR_DATA.fg,D.bg=n.DEFAULT_ATTR_DATA.bg,D.extended=D.extended.clone(),D.extended.underlineStyle=0,D.extended.underlineColor&=-67108864,D.updateExtended()}charAttributes(D){if(D.length===1&&D.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=D.length;let P;const O=this._curAttrData;for(let U=0;U<M;U++)P=D.params[U],P>=30&&P<=37?(O.fg&=-50331904,O.fg|=16777216|P-30):P>=40&&P<=47?(O.bg&=-50331904,O.bg|=16777216|P-40):P>=90&&P<=97?(O.fg&=-50331904,O.fg|=16777224|P-90):P>=100&&P<=107?(O.bg&=-50331904,O.bg|=16777224|P-100):P===0?this._processSGR0(O):P===1?O.fg|=134217728:P===3?O.bg|=67108864:P===4?(O.fg|=268435456,this._processUnderline(D.hasSubParams(U)?D.getSubParams(U)[0]:1,O)):P===5?O.fg|=536870912:P===7?O.fg|=67108864:P===8?O.fg|=1073741824:P===9?O.fg|=2147483648:P===2?O.bg|=134217728:P===21?this._processUnderline(2,O):P===22?(O.fg&=-134217729,O.bg&=-134217729):P===23?O.bg&=-67108865:P===24?(O.fg&=-268435457,this._processUnderline(0,O)):P===25?O.fg&=-536870913:P===27?O.fg&=-67108865:P===28?O.fg&=-1073741825:P===29?O.fg&=2147483647:P===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):P===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?U+=this._extractColor(D,U,O):P===53?O.bg|=1073741824:P===55?O.bg&=-1073741825:P===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):P===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(D){switch(D.params[0]){case 5:this._coreService.triggerDataEvent(`${o.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[${M};${P}R`)}return!0}deviceStatusPrivate(D){if(D.params[0]===6){const M=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${o.C0.ESC}[?${M};${P}R`)}return!0}softReset(D){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=n.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(D){const M=D.params[0]||1;switch(M){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 P=M%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(D){const M=D.params[0]||1;let P;return(D.length<2||(P=D.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(D){if(!j(D.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=D.length>1?D.params[1]:0;switch(D.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${o.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(D){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(D){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(D){return this._windowTitle=D,this._onTitleChange.fire(D),!0}setIconName(D){return this._iconName=D,!0}setOrReportIndexedColor(D){const M=[],P=D.split(";");for(;P.length>1;){const O=P.shift(),U=P.shift();if(/^\d+$/.exec(O)){const K=parseInt(O);if(H(K))if(U==="?")M.push({type:0,index:K});else{const X=(0,x.parseColor)(U);X&&M.push({type:1,index:K,color:X})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(D){const M=D.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(D,M){this._getCurrentLinkId()&&this._finishHyperlink();const P=D.split(":");let O;const U=P.findIndex((K=>K.startsWith("id=")));return U!==-1&&(O=P[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(D,M){const P=D.split(";");for(let O=0;O<P.length&&!(M>=this._specialColors.length);++O,++M)if(P[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,x.parseColor)(P[O]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(D){return this._setOrReportSpecialColor(D,0)}setOrReportBgColor(D){return this._setOrReportSpecialColor(D,1)}setOrReportCursorColor(D){return this._setOrReportSpecialColor(D,2)}restoreIndexedColor(D){if(!D)return this._onColor.fire([{type:2}]),!0;const M=[],P=D.split(";");for(let O=0;O<P.length;++O)if(/^\d+$/.exec(P[O])){const U=parseInt(P[O]);H(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(D){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(D){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(D){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,p.DEFAULT_CHARSET),!0}selectCharset(D){return D.length!==2?(this.selectDefaultCharset(),!0):(D[0]==="/"||this._charsetService.setgCharset(E[D[0]],p.CHARSETS[D[1]]||p.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 D=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,D,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=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(D){return this._charsetService.setgLevel(D),!0}screenAlignmentPattern(){const D=new u.CellData;D.content=4194373,D.fg=this._curAttrData.fg,D.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const P=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(P);O&&(O.fill(D),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(D,M){const P=this._bufferService.buffer,O=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${o.C0.ESC}${U}${o.C0.ESC}\\`),!0))(D==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:D==='"p'?'P1$r61;1"p':D==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:D==="m"?"P1$r0m":D===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(D,M){this._dirtyRowTracker.markRangeDirty(D,M)}}r.InputHandler=I;let F=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,D){z>D&&(N=z,z=D,D=N),z<this.start&&(this.start=z),D>this.end&&(this.end=D)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(z){return 0<=z&&z<256}F=l([d(0,S.IBufferService)],F)},844:(C,r)=>{function i(l){for(const d of l)d.dispose();l.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const d=this._disposables.indexOf(l);d!==-1&&this._disposables.splice(d,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var d;this._isDisposed||l===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},r.toDisposable=function(l){return{dispose:l}},r.disposeArray=i,r.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(d,o,p){this._data[d]||(this._data[d]={}),this._data[d][o]=p}get(d,o){return this._data[d]?this._data[d][o]:void 0}clear(){this._data={}}}r.TwoKeyMap=i,r.FourKeyMap=class{constructor(){this._data=new i}set(l,d,o,p,_){this._data.get(l,d)||this._data.set(l,d,new i),this._data.get(l,d).set(o,p,_)}get(l,d,o,p){var _;return(_=this._data.get(l,d))===null||_===void 0?void 0:_.get(o,p)}clear(){this._data.clear()}}},6114:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof navigator>"u";const i=r.isNode?"node":navigator.userAgent,l=r.isNode?"node":navigator.platform;r.isFirefox=i.includes("Firefox"),r.isLegacyEdge=i.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(i),r.getSafariVersion=function(){if(!r.isSafari)return 0;const d=i.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),r.isIpad=l==="iPad",r.isIphone=l==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),r.isLinux=l.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(i)},6106:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let i=0;r.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const d=this._getKey(l);if(d===void 0||(i=this._search(d),i===-1)||this._getKey(this._array[i])!==d)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===d);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,d){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do d(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let d=0,o=this._array.length-1;for(;o>=d;){let p=d+o>>1;const _=this._getKey(this._array[p]);if(_>l)o=p-1;else{if(!(_<l)){for(;p>0&&this._getKey(this._array[p-1])===l;)p--;return p}d=p+1}}return d}}},7226:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const l=i(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,g=0,n=_.timeRemaining(),f=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),g=Math.max(y,g),f=_.timeRemaining(),1.5*g>f)return n-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-y))}ms`),void this._start();n=f}this.clear()}}class o extends d{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}r.PriorityTaskQueue=o,r.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:o,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const l=i(643);r.updateWindowsModeWrappedState=function(d){const o=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),p=o?.get(d.cols-1),_=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);_&&p&&(_.isWrapped=p[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&p[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(o){return[o>>>16&255,o>>>8&255,255&o]}static fromColorRGB(o){return(255&o[0])<<16|(255&o[1])<<8|255&o[2]}clone(){const o=new i;return o.fg=this.fg,o.bg=this.bg,o.extended=this.extended.clone(),o}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}}r.AttributeData=i;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(o){this._ext=o}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(o){this._ext&=-469762049,this._ext|=o<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(o){this._ext&=-67108864,this._ext|=67108863&o}get urlId(){return this._urlId}set urlId(o){this._urlId=o}constructor(o=0,p=0){this._ext=0,this._urlId=0,this._ext=o,this._urlId=p}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=l},9092:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const l=i(6349),d=i(7226),o=i(3734),p=i(8437),_=i(4634),y=i(511),g=i(643),n=i(4863),f=i(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(h,u,v){this._hasScrollback=h,this._optionsService=u,this._bufferService=v,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=f.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,g.WHITESPACE_CELL_CHAR,g.WHITESPACE_CELL_WIDTH,g.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new o.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new o.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,u){return new p.BufferLine(this._bufferService.cols,this.getNullCell(h),u)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;const u=h+this._optionsService.rawOptions.scrollback;return u>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:u}fillViewportRows(h){if(this.lines.length===0){h===void 0&&(h=p.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(h))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(h,u){const v=this.getNullCell(p.DEFAULT_ATTR_DATA);let S=0;const w=this._getCorrectBufferLength(u);if(w>this.lines.maxLength&&(this.lines.maxLength=w),this.lines.length>0){if(this._cols<h)for(let x=0;x<this.lines.length;x++)S+=+this.lines.get(x).resize(h,v);let k=0;if(this._rows<u)for(let x=this._rows;x<u;x++)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 p.BufferLine(h,v)):this.ybase>0&&this.lines.length<=this.ybase+this.y+k+1?(this.ybase--,k++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(h,v)));else for(let x=this._rows;x>u;x--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(w<this.lines.maxLength){const x=this.lines.length-w;x>0&&(this.lines.trimStart(x),this.ybase=Math.max(this.ybase-x,0),this.ydisp=Math.max(this.ydisp-x,0),this.savedY=Math.max(this.savedY-x,0)),this.lines.maxLength=w}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,u-1),k&&(this.y+=k),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(h,u),this._cols>h))for(let k=0;k<this.lines.length;k++)S+=+this.lines.get(k).resize(h,v);this._cols=h,this._rows=u,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let h=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,h=!1);let u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>100)return!0;return h}get _isReflowEnabled(){const h=this._optionsService.rawOptions.windowsPty;return h&&h.buildNumber?this._hasScrollback&&h.backend==="conpty"&&h.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(h,u){this._cols!==h&&(h>this._cols?this._reflowLarger(h,u):this._reflowSmaller(h,u))}_reflowLarger(h,u){const v=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(v.length>0){const S=(0,_.reflowLargerCreateNewLayout)(this.lines,v);(0,_.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(h,u,S.countRemoved)}}_reflowLargerAdjustViewport(h,u,v){const S=this.getNullCell(p.DEFAULT_ATTR_DATA);let w=v;for(;w-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new p.BufferLine(h,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-v,0)}_reflowSmaller(h,u){const v=this.getNullCell(p.DEFAULT_ATTR_DATA),S=[];let w=0;for(let k=this.lines.length-1;k>=0;k--){let x=this.lines.get(k);if(!x||!x.isWrapped&&x.getTrimmedLength()<=h)continue;const E=[x];for(;x.isWrapped&&k>0;)x=this.lines.get(--k),E.unshift(x);const A=this.ybase+this.y;if(A>=k&&A<k+E.length)continue;const j=E[E.length-1].getTrimmedLength(),T=(0,_.reflowSmallerGetNewLineLengths)(E,this._cols,h),N=T.length-E.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+N):Math.max(0,this.lines.length-this.lines.maxLength+N);const F=[];for(let O=0;O<N;O++){const U=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);F.push(U)}F.length>0&&(S.push({start:k+E.length+w,newLines:F}),w+=F.length),E.push(...F);let H=T.length-1,z=T[H];z===0&&(H--,z=T[H]);let D=E.length-N-1,M=j;for(;D>=0;){const O=Math.min(M,z);if(E[H]===void 0)break;if(E[H].copyCellsFrom(E[D],M-O,z-O,O,!0),z-=O,z===0&&(H--,z=T[H]),M-=O,M===0){D--;const U=Math.max(D,0);M=(0,_.getWrappedLineTrimmedLength)(E,U,this._cols)}}for(let O=0;O<E.length;O++)T[O]<h&&E[O].setCell(T[O],v);let P=N-I;for(;P-- >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+w)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+N,this.ybase+u-1)}if(S.length>0){const k=[],x=[];for(let H=0;H<this.lines.length;H++)x.push(this.lines.get(H));const E=this.lines.length;let A=E-1,j=0,T=S[j];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+w);let N=0;for(let H=Math.min(this.lines.maxLength-1,E+w-1);H>=0;H--)if(T&&T.start>A+N){for(let z=T.newLines.length-1;z>=0;z--)this.lines.set(H--,T.newLines[z]);H++,k.push({index:A+1,amount:T.newLines.length}),N+=T.newLines.length,T=S[++j]}else this.lines.set(H,x[A--]);let I=0;for(let H=k.length-1;H>=0;H--)k[H].index+=I,this.lines.onInsertEmitter.fire(k[H]),I+=k[H].amount;const F=Math.max(0,E+w-this.lines.maxLength);F>0&&this.lines.onTrimEmitter.fire(F)}}translateBufferLineToString(h,u,v=0,S){const w=this.lines.get(h);return w?w.translateToString(u,v,S):""}getWrappedRangeForLine(h){let u=h,v=h;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;v+1<this.lines.length&&this.lines.get(v+1).isWrapped;)v++;return{first:u,last:v}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].line===h&&(this.markers[u].dispose(),this.markers.splice(u--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose(),this.markers.splice(h--,1);this._isClearing=!1}addMarker(h){const u=new n.Marker(h);return this.markers.push(u),u.register(this.lines.onTrim((v=>{u.line-=v,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((v=>{u.line>=v.index&&(u.line+=v.amount)}))),u.register(this.lines.onDelete((v=>{u.line>=v.index&&u.line<v.index+v.amount&&u.dispose(),u.line>v.index&&(u.line-=v.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},8437:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const l=i(3734),d=i(511),o=i(643),p=i(482);r.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class y{constructor(n,f,h=!1){this.isWrapped=h,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const u=f||d.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]);for(let v=0;v<n;++v)this.setCell(v,u);this.length=n}get(n){const f=this._data[3*n+0],h=2097151&f;return[this._data[3*n+1],2097152&f?this._combined[n]:h?(0,p.stringFromCodePoint)(h):"",f>>22,2097152&f?this._combined[n].charCodeAt(this._combined[n].length-1):h]}set(n,f){this._data[3*n+1]=f[o.CHAR_DATA_ATTR_INDEX],f[o.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=f[1],this._data[3*n+0]=2097152|n|f[o.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=f[o.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[o.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const f=this._data[3*n+0];return 2097152&f?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&f}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const f=this._data[3*n+0];return 2097152&f?this._combined[n]:2097151&f?(0,p.stringFromCodePoint)(2097151&f):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,f){return _=3*n,f.content=this._data[_+0],f.fg=this._data[_+1],f.bg=this._data[_+2],2097152&f.content&&(f.combinedData=this._combined[n]),268435456&f.bg&&(f.extended=this._extendedAttrs[n]),f}setCell(n,f){2097152&f.content&&(this._combined[n]=f.combinedData),268435456&f.bg&&(this._extendedAttrs[n]=f.extended),this._data[3*n+0]=f.content,this._data[3*n+1]=f.fg,this._data[3*n+2]=f.bg}setCellFromCodePoint(n,f,h,u,v,S){268435456&v&&(this._extendedAttrs[n]=S),this._data[3*n+0]=f|h<<22,this._data[3*n+1]=u,this._data[3*n+2]=v}addCodepointToCell(n,f){let h=this._data[3*n+0];2097152&h?this._combined[n]+=(0,p.stringFromCodePoint)(f):(2097151&h?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&h)+(0,p.stringFromCodePoint)(f),h&=-2097152,h|=2097152):h=f|4194304,this._data[3*n+0]=h)}insertCells(n,f,h,u){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs),f<this.length-n){const v=new d.CellData;for(let S=this.length-n-f-1;S>=0;--S)this.setCell(n+f+S,this.loadCell(n+S,v));for(let S=0;S<f;++S)this.setCell(n+S,h)}else for(let v=n;v<this.length;++v)this.setCell(v,h);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs)}deleteCells(n,f,h,u){if(n%=this.length,f<this.length-n){const v=new d.CellData;for(let S=0;S<this.length-n-f;++S)this.setCell(n+S,this.loadCell(n+f+S,v));for(let S=this.length-f;S<this.length;++S)this.setCell(S,h)}else for(let v=n;v<this.length;++v)this.setCell(v,h);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs)}replaceCells(n,f,h,u,v=!1){if(v)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&!this.isProtected(f)&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs);n<f&&n<this.length;)this.isProtected(n)||this.setCell(n,h),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs),f<this.length&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f,0,1,u?.fg||0,u?.bg||0,u?.extended||new l.ExtendedAttrs);n<f&&n<this.length;)this.setCell(n++,h)}resize(n,f){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const h=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*h)this._data=new Uint32Array(this._data.buffer,0,h);else{const u=new Uint32Array(h);u.set(this._data),this._data=u}for(let u=this.length;u<n;++u)this.setCell(u,f)}else{this._data=this._data.subarray(0,h);const u=Object.keys(this._combined);for(let S=0;S<u.length;S++){const w=parseInt(u[S],10);w>=n&&delete this._combined[w]}const v=Object.keys(this._extendedAttrs);for(let S=0;S<v.length;S++){const w=parseInt(v[S],10);w>=n&&delete this._extendedAttrs[w]}}return this.length=n,4*h*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,f=!1){if(f)for(let h=0;h<this.length;++h)this.isProtected(h)||this.setCell(h,n);else{this._combined={},this._extendedAttrs={};for(let h=0;h<this.length;++h)this.setCell(h,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const f in n._combined)this._combined[f]=n._combined[f];this._extendedAttrs={};for(const f in n._extendedAttrs)this._extendedAttrs[f]=n._extendedAttrs[f];this.isWrapped=n.isWrapped}clone(){const n=new y(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const f in this._combined)n._combined[f]=this._combined[f];for(const f in this._extendedAttrs)n._extendedAttrs[f]=this._extendedAttrs[f];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,f,h,u,v){const S=n._data;if(v)for(let k=u-1;k>=0;k--){for(let x=0;x<3;x++)this._data[3*(h+k)+x]=S[3*(f+k)+x];268435456&S[3*(f+k)+2]&&(this._extendedAttrs[h+k]=n._extendedAttrs[f+k])}else for(let k=0;k<u;k++){for(let x=0;x<3;x++)this._data[3*(h+k)+x]=S[3*(f+k)+x];268435456&S[3*(f+k)+2]&&(this._extendedAttrs[h+k]=n._extendedAttrs[f+k])}const w=Object.keys(n._combined);for(let k=0;k<w.length;k++){const x=parseInt(w[k],10);x>=f&&(this._combined[x-f+h]=n._combined[x])}}translateToString(n=!1,f=0,h=this.length){n&&(h=Math.min(h,this.getTrimmedLength()));let u="";for(;f<h;){const v=this._data[3*f+0],S=2097151&v;u+=2097152&v?this._combined[f]:S?(0,p.stringFromCodePoint)(S):o.WHITESPACE_CELL_CHAR,f+=v>>22||1}return u}}r.BufferLine=y},4841:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(C,r)=>{function i(l,d,o){if(d===l.length-1)return l[d].getTrimmedLength();const p=!l[d].hasContent(o-1)&&l[d].getWidth(o-1)===1,_=l[d+1].getWidth(0)===2;return p&&_?o-1:o}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(l,d,o,p,_){const y=[];for(let g=0;g<l.length-1;g++){let n=g,f=l.get(++n);if(!f.isWrapped)continue;const h=[l.get(g)];for(;n<l.length&&f.isWrapped;)h.push(f),f=l.get(++n);if(p>=g&&p<n){g+=h.length-1;continue}let u=0,v=i(h,u,d),S=1,w=0;for(;S<h.length;){const x=i(h,S,d),E=x-w,A=o-v,j=Math.min(E,A);h[u].copyCellsFrom(h[S],w,v,j,!1),v+=j,v===o&&(u++,v=0),w+=j,w===x&&(S++,w=0),v===0&&u!==0&&h[u-1].getWidth(o-1)===2&&(h[u].copyCellsFrom(h[u-1],o-1,v++,1,!1),h[u-1].setCell(o-1,_))}h[u].replaceCells(v,o,_);let k=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)k++;k>0&&(y.push(g+h.length-k),y.push(k)),g+=h.length-1}return y},r.reflowLargerCreateNewLayout=function(l,d){const o=[];let p=0,_=d[p],y=0;for(let g=0;g<l.length;g++)if(_===g){const n=d[++p];l.onDeleteEmitter.fire({index:g-y,amount:n}),g+=n-1,y+=n,_=d[++p]}else o.push(g);return{layout:o,countRemoved:y}},r.reflowLargerApplyNewLayout=function(l,d){const o=[];for(let p=0;p<d.length;p++)o.push(l.get(d[p]));for(let p=0;p<o.length;p++)l.set(p,o[p]);l.length=d.length},r.reflowSmallerGetNewLineLengths=function(l,d,o){const p=[],_=l.map(((f,h)=>i(l,h,d))).reduce(((f,h)=>f+h));let y=0,g=0,n=0;for(;n<_;){if(_-n<o){p.push(_-n);break}y+=o;const f=i(l,g,d);y>f&&(y-=f,g++);const h=l[g].getWidth(y-1)===2;h&&y--;const u=h?o-1:o;p.push(u),n+=u}return p},r.getWrappedLineTrimmedLength=i},5295:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const l=i(8460),d=i(844),o=i(9092);class p extends d.Disposable{constructor(y,g){super(),this._optionsService=y,this._bufferService=g,this._onBufferActivate=this.register(new l.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 o.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.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,g){this._normal.resize(y,g),this._alt.resize(y,g),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}r.BufferSet=p},511:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const l=i(482),d=i(643),o=i(3734);class p extends o.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new o.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const g=new p;return g.setFromCharData(y),g}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let g=!1;if(y[d.CHAR_DATA_CHAR_INDEX].length>2)g=!0;else if(y[d.CHAR_DATA_CHAR_INDEX].length===2){const n=y[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const f=y[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=f&&f<=57343?this.content=1024*(n-55296)+f-56320+65536|y[d.CHAR_DATA_WIDTH_INDEX]<<22:g=!0}else g=!0}else this.content=y[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[d.CHAR_DATA_WIDTH_INDEX]<<22;g&&(this.combinedData=y[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=p},643:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const l=i(8460),d=i(844);class o{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=o._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}r.Marker=o,o._nextId=1},7116:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.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:"≥","{":"π","|":"≠","}":"£","~":"·"},r.CHARSETS.A={"#":"£"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},r.CHARSETS.C=r.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},r.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},r.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},r.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},r.CHARSETS.E=r.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},r.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},r.CHARSETS.H=r.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(C,r)=>{var i,l,d;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(o){o.NUL="\0",o.SOH="",o.STX="",o.ETX="",o.EOT="",o.ENQ="",o.ACK="",o.BEL="\x07",o.BS="\b",o.HT=" ",o.LF=`
18
- `,o.VT="\v",o.FF="\f",o.CR="\r",o.SO="",o.SI="",o.DLE="",o.DC1="",o.DC2="",o.DC3="",o.DC4="",o.NAK="",o.SYN="",o.ETB="",o.CAN="",o.EM="",o.SUB="",o.ESC="\x1B",o.FS="",o.GS="",o.RS="",o.US="",o.SP=" ",o.DEL=""})(i||(r.C0=i={})),(function(o){o.PAD="€",o.HOP="",o.BPH="‚",o.NBH="ƒ",o.IND="„",o.NEL="…",o.SSA="†",o.ESA="‡",o.HTS="ˆ",o.HTJ="‰",o.VTS="Š",o.PLD="‹",o.PLU="Œ",o.RI="",o.SS2="Ž",o.SS3="",o.DCS="",o.PU1="‘",o.PU2="’",o.STS="“",o.CCH="”",o.MW="•",o.SPA="–",o.EPA="—",o.SOS="˜",o.SGCI="™",o.SCI="š",o.CSI="›",o.ST="œ",o.OSC="",o.PM="ž",o.APC="Ÿ"})(l||(r.C1=l={})),(function(o){o.ST=`${i.ESC}\\`})(d||(r.C1_ESCAPED=d={}))},7399:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const l=i(2584),d={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:["'",'"']};r.evaluateKeyboardEvent=function(o,p,_,y){const g={type:0,cancel:!1,key:void 0},n=(o.shiftKey?1:0)|(o.altKey?2:0)|(o.ctrlKey?4:0)|(o.metaKey?8:0);switch(o.keyCode){case 0:o.key==="UIKeyInputUpArrow"?g.key=p?l.C0.ESC+"OA":l.C0.ESC+"[A":o.key==="UIKeyInputLeftArrow"?g.key=p?l.C0.ESC+"OD":l.C0.ESC+"[D":o.key==="UIKeyInputRightArrow"?g.key=p?l.C0.ESC+"OC":l.C0.ESC+"[C":o.key==="UIKeyInputDownArrow"&&(g.key=p?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(o.altKey){g.key=l.C0.ESC+l.C0.DEL;break}g.key=l.C0.DEL;break;case 9:if(o.shiftKey){g.key=l.C0.ESC+"[Z";break}g.key=l.C0.HT,g.cancel=!0;break;case 13:g.key=o.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,g.cancel=!0;break;case 27:g.key=l.C0.ESC,o.altKey&&(g.key=l.C0.ESC+l.C0.ESC),g.cancel=!0;break;case 37:if(o.metaKey)break;n?(g.key=l.C0.ESC+"[1;"+(n+1)+"D",g.key===l.C0.ESC+"[1;3D"&&(g.key=l.C0.ESC+(_?"b":"[1;5D"))):g.key=p?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(o.metaKey)break;n?(g.key=l.C0.ESC+"[1;"+(n+1)+"C",g.key===l.C0.ESC+"[1;3C"&&(g.key=l.C0.ESC+(_?"f":"[1;5C"))):g.key=p?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(o.metaKey)break;n?(g.key=l.C0.ESC+"[1;"+(n+1)+"A",_||g.key!==l.C0.ESC+"[1;3A"||(g.key=l.C0.ESC+"[1;5A")):g.key=p?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(o.metaKey)break;n?(g.key=l.C0.ESC+"[1;"+(n+1)+"B",_||g.key!==l.C0.ESC+"[1;3B"||(g.key=l.C0.ESC+"[1;5B")):g.key=p?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:o.shiftKey||o.ctrlKey||(g.key=l.C0.ESC+"[2~");break;case 46:g.key=n?l.C0.ESC+"[3;"+(n+1)+"~":l.C0.ESC+"[3~";break;case 36:g.key=n?l.C0.ESC+"[1;"+(n+1)+"H":p?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:g.key=n?l.C0.ESC+"[1;"+(n+1)+"F":p?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:o.shiftKey?g.type=2:o.ctrlKey?g.key=l.C0.ESC+"[5;"+(n+1)+"~":g.key=l.C0.ESC+"[5~";break;case 34:o.shiftKey?g.type=3:o.ctrlKey?g.key=l.C0.ESC+"[6;"+(n+1)+"~":g.key=l.C0.ESC+"[6~";break;case 112:g.key=n?l.C0.ESC+"[1;"+(n+1)+"P":l.C0.ESC+"OP";break;case 113:g.key=n?l.C0.ESC+"[1;"+(n+1)+"Q":l.C0.ESC+"OQ";break;case 114:g.key=n?l.C0.ESC+"[1;"+(n+1)+"R":l.C0.ESC+"OR";break;case 115:g.key=n?l.C0.ESC+"[1;"+(n+1)+"S":l.C0.ESC+"OS";break;case 116:g.key=n?l.C0.ESC+"[15;"+(n+1)+"~":l.C0.ESC+"[15~";break;case 117:g.key=n?l.C0.ESC+"[17;"+(n+1)+"~":l.C0.ESC+"[17~";break;case 118:g.key=n?l.C0.ESC+"[18;"+(n+1)+"~":l.C0.ESC+"[18~";break;case 119:g.key=n?l.C0.ESC+"[19;"+(n+1)+"~":l.C0.ESC+"[19~";break;case 120:g.key=n?l.C0.ESC+"[20;"+(n+1)+"~":l.C0.ESC+"[20~";break;case 121:g.key=n?l.C0.ESC+"[21;"+(n+1)+"~":l.C0.ESC+"[21~";break;case 122:g.key=n?l.C0.ESC+"[23;"+(n+1)+"~":l.C0.ESC+"[23~";break;case 123:g.key=n?l.C0.ESC+"[24;"+(n+1)+"~":l.C0.ESC+"[24~";break;default:if(!o.ctrlKey||o.shiftKey||o.altKey||o.metaKey)if(_&&!y||!o.altKey||o.metaKey)!_||o.altKey||o.ctrlKey||o.shiftKey||!o.metaKey?o.key&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&o.keyCode>=48&&o.key.length===1?g.key=o.key:o.key&&o.ctrlKey&&(o.key==="_"&&(g.key=l.C0.US),o.key==="@"&&(g.key=l.C0.NUL)):o.keyCode===65&&(g.type=1);else{const f=d[o.keyCode],h=f?.[o.shiftKey?1:0];if(h)g.key=l.C0.ESC+h;else if(o.keyCode>=65&&o.keyCode<=90){const u=o.ctrlKey?o.keyCode-64:o.keyCode+32;let v=String.fromCharCode(u);o.shiftKey&&(v=v.toUpperCase()),g.key=l.C0.ESC+v}else if(o.keyCode===32)g.key=l.C0.ESC+(o.ctrlKey?l.C0.NUL:" ");else if(o.key==="Dead"&&o.code.startsWith("Key")){let u=o.code.slice(3,4);o.shiftKey||(u=u.toLowerCase()),g.key=l.C0.ESC+u,g.cancel=!0}}else o.keyCode>=65&&o.keyCode<=90?g.key=String.fromCharCode(o.keyCode-64):o.keyCode===32?g.key=l.C0.NUL:o.keyCode>=51&&o.keyCode<=55?g.key=String.fromCharCode(o.keyCode-51+27):o.keyCode===56?g.key=l.C0.DEL:o.keyCode===219?g.key=l.C0.ESC:o.keyCode===220?g.key=l.C0.FS:o.keyCode===221&&(g.key=l.C0.GS)}return g}},482:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},r.utf32ToString=function(i,l=0,d=i.length){let o="";for(let p=l;p<d;++p){let _=i[p];_>65535?(_-=65536,o+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):o+=String.fromCharCode(_)}return o},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const d=i.length;if(!d)return 0;let o=0,p=0;if(this._interim){const _=i.charCodeAt(p++);56320<=_&&_<=57343?l[o++]=1024*(this._interim-55296)+_-56320+65536:(l[o++]=this._interim,l[o++]=_),this._interim=0}for(let _=p;_<d;++_){const y=i.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=d)return this._interim=y,o;const g=i.charCodeAt(_);56320<=g&&g<=57343?l[o++]=1024*(y-55296)+g-56320+65536:(l[o++]=y,l[o++]=g)}else y!==65279&&(l[o++]=y)}return o}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const d=i.length;if(!d)return 0;let o,p,_,y,g=0,n=0,f=0;if(this.interim[0]){let v=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let w,k=0;for(;(w=63&this.interim[++k])&&k<4;)S<<=6,S|=w;const x=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=x-k;for(;f<E;){if(f>=d)return 0;if(w=i[f++],(192&w)!=128){f--,v=!0;break}this.interim[k++]=w,S<<=6,S|=63&w}v||(x===2?S<128?f--:l[g++]=S:x===3?S<2048||S>=55296&&S<=57343||S===65279||(l[g++]=S):S<65536||S>1114111||(l[g++]=S)),this.interim.fill(0)}const h=d-4;let u=f;for(;u<d;){for(;!(!(u<h)||128&(o=i[u])||128&(p=i[u+1])||128&(_=i[u+2])||128&(y=i[u+3]));)l[g++]=o,l[g++]=p,l[g++]=_,l[g++]=y,u+=4;if(o=i[u++],o<128)l[g++]=o;else if((224&o)==192){if(u>=d)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(n=(31&o)<<6|63&p,n<128){u--;continue}l[g++]=n}else if((240&o)==224){if(u>=d)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,g;if(_=i[u++],(192&_)!=128){u--;continue}if(n=(15&o)<<12|(63&p)<<6|63&_,n<2048||n>=55296&&n<=57343||n===65279)continue;l[g++]=n}else if((248&o)==240){if(u>=d)return this.interim[0]=o,g;if(p=i[u++],(192&p)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,g;if(_=i[u++],(192&_)!=128){u--;continue}if(u>=d)return this.interim[0]=o,this.interim[1]=p,this.interim[2]=_,g;if(y=i[u++],(192&y)!=128){u--;continue}if(n=(7&o)<<18|(63&p)<<12|(63&_)<<6|63&y,n<65536||n>1114111)continue;l[g++]=n}}return g}}},225:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[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 d;r.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let o=0;o<i.length;++o)d.fill(0,i[o][0],i[o][1]+1)}}wcwidth(o){return o<32?0:o<127?1:o<65536?d[o]:(function(p,_){let y,g=0,n=_.length-1;if(p<_[0][0]||p>_[n][1])return!1;for(;n>=g;)if(y=g+n>>1,p>_[y][1])g=y+1;else{if(!(p<_[y][0]))return!0;n=y-1}return!1})(o,l)?0:o>=131072&&o<=196605||o>=196608&&o<=262141?2:1}}},5981:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const l=i(8460),d=i(844);class o extends d.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let g;for(this._isSyncWriting=!0;g=this._writeBuffer.shift();){this._action(g);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const g=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],f=this._action(n,y);if(f){const u=v=>Date.now()-g>=12?setTimeout((()=>this._innerWrite(0,v))):this._innerWrite(g,v);return void f.catch((v=>(queueMicrotask((()=>{throw v})),Promise.resolve(!1)))).then(u)}const h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-g>=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()}}r.WriteBuffer=o},5941:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function d(o,p){const _=o.toString(16),y=_.length<2?"0"+_:_;switch(p){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}r.parseColor=function(o){if(!o)return;let p=o.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const _=i.exec(p);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),l.exec(p)&&[3,6,9,12].includes(p.length))){const _=p.length/3,y=[0,0,0];for(let g=0;g<3;++g){const n=parseInt(p.slice(_*g,_*g+_),16);y[g]=_===1?n<<4:_===2?n:_===3?n>>4:n>>8}return y}},r.toRgbString=function(o,p=16){const[_,y,g]=o;return`rgb:${d(_,p)}/${d(y,p)}/${d(g,p)}`}},5770:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const l=i(482),d=i(8742),o=i(5770),p=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(y,g){this._handlers[y]===void 0&&(this._handlers[y]=[]);const n=this._handlers[y];return n.push(g),{dispose:()=>{const f=n.indexOf(g);f!==-1&&n.splice(f,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=p,this._ident=0}hook(y,g){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(g);else this._handlerFb(this._ident,"HOOK",g)}put(y,g,n){if(this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].put(y,g,n);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,g,n))}unhook(y,g=!0){if(this._active.length){let n=!1,f=this._active.length-1,h=!1;if(this._stack.paused&&(f=this._stack.loopPosition-1,n=g,h=this._stack.fallThrough,this._stack.paused=!1),!h&&n===!1){for(;f>=0&&(n=this._active[f].unhook(y),n!==!0);f--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!1,n;f--}for(;f>=0;f--)if(n=this._active[f].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=f,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const _=new d.Params;_.addParam(0),r.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,g,n){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,g,n),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let g=!1;if(this._hitLimit)g=!1;else if(y&&(g=this._handler(this._data,this._params),g instanceof Promise))return g.then((n=>(this._params=_,this._data="",this._hitLimit=!1,n)));return this._params=_,this._data="",this._hitLimit=!1,g}}},2015:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const l=i(844),d=i(8742),o=i(6242),p=i(6351);class _{constructor(f){this.table=new Uint8Array(f)}setDefault(f,h){this.table.fill(f<<4|h)}add(f,h,u,v){this.table[h<<8|f]=u<<4|v}addMany(f,h,u,v){for(let S=0;S<f.length;S++)this.table[h<<8|f[S]]=u<<4|v}}r.TransitionTable=_;const y=160;r.VT500_TRANSITION_TABLE=(function(){const n=new _(4095),f=Array.apply(null,Array(256)).map(((k,x)=>x)),h=(k,x)=>f.slice(k,x),u=h(32,127),v=h(0,24);v.push(25),v.push.apply(v,h(28,32));const S=h(0,14);let w;for(w in n.setDefault(1,0),n.addMany(u,0,2,0),S)n.addMany([24,26,153,154],w,3,0),n.addMany(h(128,144),w,3,0),n.addMany(h(144,152),w,3,0),n.add(156,w,0,0),n.add(27,w,11,1),n.add(157,w,4,8),n.addMany([152,158,159],w,0,7),n.add(155,w,11,3),n.add(144,w,11,9);return n.addMany(v,0,3,0),n.addMany(v,1,3,1),n.add(127,1,0,1),n.addMany(v,8,0,8),n.addMany(v,3,3,3),n.add(127,3,0,3),n.addMany(v,4,3,4),n.add(127,4,0,4),n.addMany(v,6,3,6),n.addMany(v,5,3,5),n.add(127,5,0,5),n.addMany(v,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(u,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(h(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(u,7,0,7),n.addMany(v,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(h(64,127),3,7,0),n.addMany(h(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(h(48,60),4,8,4),n.addMany(h(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(h(32,64),6,0,6),n.add(127,6,0,6),n.addMany(h(64,127),6,0,0),n.addMany(h(32,48),3,9,5),n.addMany(h(32,48),5,9,5),n.addMany(h(48,64),5,0,6),n.addMany(h(64,127),5,7,0),n.addMany(h(32,48),4,9,5),n.addMany(h(32,48),1,9,2),n.addMany(h(32,48),2,9,2),n.addMany(h(48,127),2,10,0),n.addMany(h(48,80),1,10,0),n.addMany(h(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(h(96,127),1,10,0),n.add(80,1,11,9),n.addMany(v,9,0,9),n.add(127,9,0,9),n.addMany(h(28,32),9,0,9),n.addMany(h(32,48),9,9,12),n.addMany(h(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(v,11,0,11),n.addMany(h(32,128),11,0,11),n.addMany(h(28,32),11,0,11),n.addMany(v,10,0,10),n.add(127,10,0,10),n.addMany(h(28,32),10,0,10),n.addMany(h(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(h(32,48),10,9,12),n.addMany(v,12,0,12),n.add(127,12,0,12),n.addMany(h(28,32),12,0,12),n.addMany(h(32,48),12,9,12),n.addMany(h(48,64),12,0,11),n.addMany(h(64,127),12,12,13),n.addMany(h(64,127),10,12,13),n.addMany(h(64,127),9,12,13),n.addMany(v,13,13,13),n.addMany(u,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(y,0,2,0),n.add(y,8,5,8),n.add(y,6,0,6),n.add(y,11,0,11),n.add(y,13,13,13),n})();class g extends l.Disposable{constructor(f=r.VT500_TRANSITION_TABLE){super(),this._transitions=f,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(h,u,v)=>{},this._executeHandlerFb=h=>{},this._csiHandlerFb=(h,u)=>{},this._escHandlerFb=h=>{},this._errorHandlerFb=h=>h,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new o.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(f,h=[64,126]){let u=0;if(f.prefix){if(f.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=f.prefix.charCodeAt(0),u&&60>u||u>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(f.intermediates){if(f.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<f.intermediates.length;++S){const w=f.intermediates.charCodeAt(S);if(32>w||w>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=w}}if(f.final.length!==1)throw new Error("final must be a single byte");const v=f.final.charCodeAt(0);if(h[0]>v||v>h[1])throw new Error(`final must be in range ${h[0]} .. ${h[1]}`);return u<<=8,u|=v,u}identToString(f){const h=[];for(;f;)h.push(String.fromCharCode(255&f)),f>>=8;return h.reverse().join("")}setPrintHandler(f){this._printHandler=f}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(f,h){const u=this._identifier(f,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const v=this._escHandlers[u];return v.push(h),{dispose:()=>{const S=v.indexOf(h);S!==-1&&v.splice(S,1)}}}clearEscHandler(f){this._escHandlers[this._identifier(f,[48,126])]&&delete this._escHandlers[this._identifier(f,[48,126])]}setEscHandlerFallback(f){this._escHandlerFb=f}setExecuteHandler(f,h){this._executeHandlers[f.charCodeAt(0)]=h}clearExecuteHandler(f){this._executeHandlers[f.charCodeAt(0)]&&delete this._executeHandlers[f.charCodeAt(0)]}setExecuteHandlerFallback(f){this._executeHandlerFb=f}registerCsiHandler(f,h){const u=this._identifier(f);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const v=this._csiHandlers[u];return v.push(h),{dispose:()=>{const S=v.indexOf(h);S!==-1&&v.splice(S,1)}}}clearCsiHandler(f){this._csiHandlers[this._identifier(f)]&&delete this._csiHandlers[this._identifier(f)]}setCsiHandlerFallback(f){this._csiHandlerFb=f}registerDcsHandler(f,h){return this._dcsParser.registerHandler(this._identifier(f),h)}clearDcsHandler(f){this._dcsParser.clearHandler(this._identifier(f))}setDcsHandlerFallback(f){this._dcsParser.setHandlerFallback(f)}registerOscHandler(f,h){return this._oscParser.registerHandler(f,h)}clearOscHandler(f){this._oscParser.clearHandler(f)}setOscHandlerFallback(f){this._oscParser.setHandlerFallback(f)}setErrorHandler(f){this._errorHandler=f}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(f,h,u,v,S){this._parseStack.state=f,this._parseStack.handlers=h,this._parseStack.handlerPos=u,this._parseStack.transition=v,this._parseStack.chunkPos=S}parse(f,h,u){let v,S=0,w=0,k=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,k=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 x=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&E>-1){for(;E>=0&&(v=x[E](this._params),v!==!0);E--)if(v instanceof Promise)return this._parseStack.handlerPos=E,v}this._parseStack.handlers=[];break;case 4:if(u===!1&&E>-1){for(;E>=0&&(v=x[E](),v!==!0);E--)if(v instanceof Promise)return this._parseStack.handlerPos=E,v}this._parseStack.handlers=[];break;case 6:if(S=f[this._parseStack.chunkPos],v=this._dcsParser.unhook(S!==24&&S!==26,u),v)return v;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=f[this._parseStack.chunkPos],v=this._oscParser.end(S!==24&&S!==26,u),v)return v;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,k=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let x=k;x<h;++x){switch(S=f[x],w=this._transitions.table[this.currentState<<8|(S<160?S:y)],w>>4){case 2:for(let N=x+1;;++N){if(N>=h||(S=f[N])<32||S>126&&S<y){this._printHandler(f,x,N),x=N-1;break}if(++N>=h||(S=f[N])<32||S>126&&S<y){this._printHandler(f,x,N),x=N-1;break}if(++N>=h||(S=f[N])<32||S>126&&S<y){this._printHandler(f,x,N),x=N-1;break}if(++N>=h||(S=f[N])<32||S>126&&S<y){this._printHandler(f,x,N),x=N-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:x,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|S];let A=E?E.length-1:-1;for(;A>=0&&(v=E[A](this._params),v!==!0);A--)if(v instanceof Promise)return this._preserveStack(3,E,A,w,x),v;A<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(++x<h&&(S=f[x])>47&&S<60);x--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const j=this._escHandlers[this._collect<<8|S];let T=j?j.length-1:-1;for(;T>=0&&(v=j[T](),v!==!0);T--)if(v instanceof Promise)return this._preserveStack(4,j,T,w,x),v;T<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let N=x+1;;++N)if(N>=h||(S=f[N])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(f,x,N),x=N-1;break}break;case 14:if(v=this._dcsParser.unhook(S!==24&&S!==26),v)return this._preserveStack(6,[],0,w,x),v;S===27&&(w|=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 N=x+1;;N++)if(N>=h||(S=f[N])<32||S>127&&S<y){this._oscParser.put(f,x,N),x=N-1;break}break;case 6:if(v=this._oscParser.end(S!==24&&S!==26),v)return this._preserveStack(5,[],0,w,x),v;S===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&w}}}r.EscapeSequenceParser=g},6242:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const l=i(5770),d=i(482),o=[];r.OscParser=class{constructor(){this._state=0,this._active=o,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,_){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(_),{dispose:()=>{const g=y.indexOf(_);g!==-1&&y.splice(g,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=o}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||o,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,_,y){if(this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].put(p,_,y);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(p,_,y))}start(){this.reset(),this._state=1}put(p,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const g=p[_++];if(g===59){this._state=2,this._start();break}if(g<48||57<g)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+g-48}this._state===2&&y-_>0&&this._put(p,_,y)}}end(p,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,g=this._active.length-1,n=!1;if(this._stack.paused&&(g=this._stack.loopPosition-1,y=_,n=this._stack.fallThrough,this._stack.paused=!1),!n&&y===!1){for(;g>=0&&(y=this._active[g].end(p),y!==!0);g--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!1,y;g--}for(;g>=0;g--)if(y=this._active[g].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",p);this._active=o,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,_,y){this._hitLimit||(this._data+=(0,d.utf32ToString)(p,_,y),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let _=!1;if(this._hitLimit)_=!1;else if(p&&(_=this._handler(this._data),_ instanceof Promise))return _.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,_}}},8742:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const i=2147483647;class l{static fromArray(o){const p=new l;if(!o.length)return p;for(let _=Array.isArray(o[0])?1:0;_<o.length;++_){const y=o[_];if(Array.isArray(y))for(let g=0;g<y.length;++g)p.addSubParam(y[g]);else p.addParam(y)}return p}constructor(o=32,p=32){if(this.maxLength=o,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(o),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(o),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const o=new l(this.maxLength,this.maxSubParamsLength);return o.params.set(this.params),o.length=this.length,o._subParams.set(this._subParams),o._subParamsLength=this._subParamsLength,o._subParamsIdx.set(this._subParamsIdx),o._rejectDigits=this._rejectDigits,o._rejectSubDigits=this._rejectSubDigits,o._digitIsSub=this._digitIsSub,o}toArray(){const o=[];for(let p=0;p<this.length;++p){o.push(this.params[p]);const _=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-_>0&&o.push(Array.prototype.slice.call(this._subParams,_,y))}return o}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(o){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=o>i?i:o}}addSubParam(o){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(o<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=o>i?i:o,this._subParamsIdx[this.length-1]++}}hasSubParams(o){return(255&this._subParamsIdx[o])-(this._subParamsIdx[o]>>8)>0}getSubParams(o){const p=this._subParamsIdx[o]>>8,_=255&this._subParamsIdx[o];return _-p>0?this._subParams.subarray(p,_):null}getSubParamsAll(){const o={};for(let p=0;p<this.length;++p){const _=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-_>0&&(o[p]=this._subParams.slice(_,y))}return o}addDigit(o){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[p-1];_[p-1]=~y?Math.min(10*y+o,i):o}}r.Params=l},5741:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const d={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(d),l.dispose=()=>this._wrappedAddonDispose(d),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===i){l=d;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const l=i(3785),d=i(511);r.BufferApiView=class{constructor(o,p){this._buffer=o,this.type=p}init(o){return this._buffer=o,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(o){const p=this._buffer.lines.get(o);if(p)return new l.BufferLineApiView(p)}getNullCell(){return new d.CellData}}},3785:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const l=i(511);r.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,o){if(!(d<0||d>=this._line.length))return o?(this._line.loadCell(d,o),o):this._line.loadCell(d,new l.CellData)}translateToString(d,o,p){return this._line.translateToString(d,o,p)}}},8285:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const l=i(8771),d=i(8460),o=i(844);class p extends o.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.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)}}r.BufferNamespaceApi=p},7975:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(d=>l(d.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((d,o)=>l(d,o.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(C,r,i){var l=this&&this.__decorate||function(n,f,h,u){var v,S=arguments.length,w=S<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(S<3?v(w):S>3?v(f,h,w):v(f,h))||w);return S>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const o=i(8460),p=i(844),_=i(5295),y=i(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let g=r.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new o.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(n,this))}resize(n,f){this.cols=n,this.rows=f,this.buffers.resize(n,f),this._onResize.fire({cols:n,rows:f})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,f=!1){const h=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===n.fg&&u.getBg(0)===n.bg||(u=h.getBlankLine(n,f),this._cachedBlankLine=u),u.isWrapped=f;const v=h.ybase+h.scrollTop,S=h.ybase+h.scrollBottom;if(h.scrollTop===0){const w=h.lines.isFull;S===h.lines.length-1?w?h.lines.recycle().copyFrom(u):h.lines.push(u.clone()):h.lines.splice(S+1,0,u.clone()),w?this.isUserScrolling&&(h.ydisp=Math.max(h.ydisp-1,0)):(h.ybase++,this.isUserScrolling||h.ydisp++)}else{const w=S-v+1;h.lines.shiftElements(v+1,w-1,-1),h.lines.set(S,u.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(n,f,h){const u=this.buffer;if(n<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else n+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const v=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+n,u.ybase),0),v!==u.ydisp&&(f||this._onScroll.fire(u.ydisp))}};r.BufferService=g=l([d(0,y.IOptionsService)],g)},7994:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(C,r,i){var l=this&&this.__decorate||function(u,v,S,w){var k,x=arguments.length,E=x<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,S):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,v,S,w);else for(var A=u.length-1;A>=0;A--)(k=u[A])&&(E=(x<3?k(E):x>3?k(v,S,E):k(v,S))||E);return x>3&&E&&Object.defineProperty(v,S,E),E},d=this&&this.__param||function(u,v){return function(S,w){v(S,w,u)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const o=i(2585),p=i(8460),_=i(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 g(u,v){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||v||(S|=3)),S}const n=String.fromCharCode,f={DEFAULT:u=>{const v=[g(u,!1)+32,u.col+32,u.row+32];return v[0]>255||v[1]>255||v[2]>255?"":`\x1B[M${n(v[0])}${n(v[1])}${n(v[2])}`},SGR:u=>{const v=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.col};${u.row}${v}`},SGR_PIXELS:u=>{const v=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${g(u,!0)};${u.x};${u.y}${v}`}};let h=r.CoreMouseService=class extends _.Disposable{constructor(u,v){super(),this._bufferService=u,this._coreService=v,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(f))this.addEncoding(S,f[S]);this.reset()}addProtocol(u,v){this._protocols[u]=v}addEncoding(u,v){this._encodings[u]=v}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 v=this._encodings[this._activeEncoding](u);return v&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(v):this._coreService.triggerDataEvent(v,!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,v,S){if(S){if(u.x!==v.x||u.y!==v.y)return!1}else if(u.col!==v.col||u.row!==v.row)return!1;return u.button===v.button&&u.action===v.action&&u.ctrl===v.ctrl&&u.alt===v.alt&&u.shift===v.shift}};r.CoreMouseService=h=l([d(0,o.IBufferService),d(1,o.ICoreService)],h)},6975:function(C,r,i){var l=this&&this.__decorate||function(h,u,v,S){var w,k=arguments.length,x=k<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,v):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,u,v,S);else for(var E=h.length-1;E>=0;E--)(w=h[E])&&(x=(k<3?w(x):k>3?w(u,v,x):w(u,v))||x);return k>3&&x&&Object.defineProperty(u,v,x),x},d=this&&this.__param||function(h,u){return function(v,S){u(v,S,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const o=i(1439),p=i(8460),_=i(844),y=i(2585),g=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let f=r.CoreService=class extends _.Disposable{constructor(h,u,v){super(),this._bufferService=h,this._logService=u,this._optionsService=v,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}reset(){this.modes=(0,o.clone)(g),this.decPrivateModes=(0,o.clone)(n)}triggerDataEvent(h,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const v=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&v.ybase!==v.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`,(()=>h.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(h)}triggerBinaryEvent(h){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${h}"`,(()=>h.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(h))}};r.CoreService=f=l([d(0,y.IBufferService),d(1,y.ILogService),d(2,y.IOptionsService)],f)},9074:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const l=i(8055),d=i(8460),o=i(844),p=i(6106);let _=0,y=0;class g extends o.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((h=>h?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,o.toDisposable)((()=>this.reset())))}registerDecoration(h){if(h.marker.isDisposed)return;const u=new n(h);if(u){const v=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),v.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const h of this._decorations.values())h.dispose();this._decorations.clear()}*getDecorationsAtCell(h,u,v){var S,w,k;let x=0,E=0;for(const A of this._decorations.getKeyIterator(u))x=(S=A.options.x)!==null&&S!==void 0?S:0,E=x+((w=A.options.width)!==null&&w!==void 0?w:1),h>=x&&h<E&&(!v||((k=A.options.layer)!==null&&k!==void 0?k:"bottom")===v)&&(yield A)}forEachDecorationAtCell(h,u,v,S){this._decorations.forEachByKey(u,(w=>{var k,x,E;_=(k=w.options.x)!==null&&k!==void 0?k:0,y=_+((x=w.options.width)!==null&&x!==void 0?x:1),h>=_&&h<y&&(!v||((E=w.options.layer)!==null&&E!==void 0?E:"bottom")===v)&&S(w)}))}}r.DecorationService=g;class n extends o.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(h){super(),this.options=h,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=h.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const l=i(2585),d=i(8343);class o{constructor(..._){this._entries=new Map;for(const[y,g]of _)this.set(y,g)}set(_,y){const g=this._entries.get(_);return this._entries.set(_,y),g}forEach(_){for(const[y,g]of this._entries.entries())_(y,g)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}r.ServiceCollection=o,r.InstantiationService=class{constructor(){this._services=new o,this._services.set(l.IInstantiationService,this)}setService(p,_){this._services.set(p,_)}getService(p){return this._services.get(p)}createInstance(p,..._){const y=(0,d.getServiceDependencies)(p).sort(((f,h)=>f.index-h.index)),g=[];for(const f of y){const h=this._services.get(f.id);if(!h)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${f.id}.`);g.push(h)}const n=y.length>0?y[0].index:_.length;if(_.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${_.length} static arguments`);return new p(..._,...g)}}},7866:function(C,r,i){var l=this&&this.__decorate||function(n,f,h,u){var v,S=arguments.length,w=S<3?f:u===null?u=Object.getOwnPropertyDescriptor(f,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(n,f,h,u);else for(var k=n.length-1;k>=0;k--)(v=n[k])&&(w=(S<3?v(w):S>3?v(f,h,w):v(f,h))||w);return S>3&&w&&Object.defineProperty(f,h,w),w},d=this&&this.__param||function(n,f){return function(h,u){f(h,u,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const o=i(844),p=i(2585),_={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,g=r.LogService=class extends o.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let f=0;f<n.length;f++)typeof n[f]=="function"&&(n[f]=n[f]())}_log(n,f,h){this._evalLazyOptionalParams(h),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+f,...h)}trace(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,f)}debug(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,n,f)}info(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.INFO&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,n,f)}warn(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.WARN&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,n,f)}error(n,...f){var h,u;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((u=(h=this._optionsService.options.logger)===null||h===void 0?void 0:h.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,n,f)}};r.LogService=g=l([d(0,p.IOptionsService)],g),r.setTraceLogger=function(n){y=n},r.traceCall=function(n,f,h){if(typeof h.value!="function")throw new Error("not supported");const u=h.value;h.value=function(...v){if(y.logLevel!==p.LogLevelEnum.TRACE)return u.apply(this,v);y.trace(`GlyphRenderer#${u.name}(${v.map((w=>JSON.stringify(w))).join(", ")})`);const S=u.apply(this,v);return y.trace(`GlyphRenderer#${u.name} return`,S),S}}},7302:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const l=i(8460),d=i(844),o=i(6114);r.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:o.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends d.Disposable{constructor(g){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},r.DEFAULT_OPTIONS);for(const f in g)if(f in n)try{const h=g[f];n[f]=this._sanitizeAndValidateOption(f,h)}catch(h){console.error(h)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(g,n){return this.onOptionChange((f=>{f===g&&n(this.rawOptions[g])}))}onMultipleOptionChange(g,n){return this.onOptionChange((f=>{g.indexOf(f)!==-1&&n()}))}_setupOptions(){const g=f=>{if(!(f in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);return this.rawOptions[f]},n=(f,h)=>{if(!(f in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${f}"`);h=this._sanitizeAndValidateOption(f,h),this.rawOptions[f]!==h&&(this.rawOptions[f]=h,this._onOptionChange.fire(f))};for(const f in this.rawOptions){const h={get:g.bind(this,f),set:n.bind(this,f)};Object.defineProperty(this.options,f,h)}}_sanitizeAndValidateOption(g,n){switch(g){case"cursorStyle":if(n||(n=r.DEFAULT_OPTIONS[g]),!(function(f){return f==="block"||f==="underline"||f==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${g}`);break;case"wordSeparator":n||(n=r.DEFAULT_OPTIONS[g]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:r.DEFAULT_OPTIONS[g];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${g} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${g} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${g} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${g} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}r.OptionsService=_},2660:function(C,r,i){var l=this&&this.__decorate||function(_,y,g,n){var f,h=arguments.length,u=h<3?y:n===null?n=Object.getOwnPropertyDescriptor(y,g):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(_,y,g,n);else for(var v=_.length-1;v>=0;v--)(f=_[v])&&(u=(h<3?f(u):h>3?f(y,g,u):f(y,g))||u);return h>3&&u&&Object.defineProperty(y,g,u),u},d=this&&this.__param||function(_,y){return function(g,n){y(g,n,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const o=i(2585);let p=r.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const v=y.addMarker(y.ybase+y.y),S={data:_,id:this._nextId++,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(S,v))),this._dataByLinkId.set(S.id,S),S.id}const g=_,n=this._getEntryIdKey(g),f=this._entriesWithId.get(n);if(f)return this.addLineToLink(f.id,y.ybase+y.y),f.id;const h=y.addMarker(y.ybase+y.y),u={id:this._nextId++,key:this._getEntryIdKey(g),data:g,lines:[h]};return h.onDispose((()=>this._removeMarkerFromLink(u,h))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(_,y){const g=this._dataByLinkId.get(_);if(g&&g.lines.every((n=>n.line!==y))){const n=this._bufferService.buffer.addMarker(y);g.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(g,n)))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const g=_.lines.indexOf(y);g!==-1&&(_.lines.splice(g,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};r.OscLinkService=p=l([d(0,o.IBufferService)],p)},8343:(C,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const i="di$target",l="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(d){return d[l]||[]},r.createDecorator=function(d){if(r.serviceRegistry.has(d))return r.serviceRegistry.get(d);const o=function(p,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(g,n,f){n[i]===n?n[l].push({id:g,index:f}):(n[l]=[{id:g,index:f}],n[i]=n)})(o,p,y)};return o.toString=()=>d,r.serviceRegistry.set(d,o),o}},2585:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;const l=i(8343);var d;r.IBufferService=(0,l.createDecorator)("BufferService"),r.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),r.ICoreService=(0,l.createDecorator)("CoreService"),r.ICharsetService=(0,l.createDecorator)("CharsetService"),r.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(o){o[o.TRACE=0]="TRACE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.ERROR=4]="ERROR",o[o.OFF=5]="OFF"})(d||(r.LogLevelEnum=d={})),r.ILogService=(0,l.createDecorator)("LogService"),r.IOptionsService=(0,l.createDecorator)("OptionsService"),r.IOscLinkService=(0,l.createDecorator)("OscLinkService"),r.IUnicodeService=(0,l.createDecorator)("UnicodeService"),r.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(C,r,i)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const l=i(8460),d=i(225);r.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const o=new d.UnicodeV6;this.register(o),this._active=o.version,this._activeProvider=o}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(o){if(!this._providers[o])throw new Error(`unknown Unicode version "${o}"`);this._active=o,this._activeProvider=this._providers[o],this._onChange.fire(o)}register(o){this._providers[o.version]=o}wcwidth(o){return this._activeProvider.wcwidth(o)}getStringCellWidth(o){let p=0;const _=o.length;for(let y=0;y<_;++y){let g=o.charCodeAt(y);if(55296<=g&&g<=56319){if(++y>=_)return p+this.wcwidth(g);const n=o.charCodeAt(y);56320<=n&&n<=57343?g=1024*(g-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(g)}return p}}}},a={};function m(C){var r=a[C];if(r!==void 0)return r.exports;var i=a[C]={exports:{}};return s[C].call(i.exports,i,i.exports,m),i.exports}var b={};return(()=>{var C=b;Object.defineProperty(C,"__esModule",{value:!0}),C.Terminal=void 0;const r=m(9042),i=m(3236),l=m(844),d=m(5741),o=m(8285),p=m(7975),_=m(7090),y=["cols","rows"];class g extends l.Disposable{constructor(f){super(),this._core=this.register(new i.Terminal(f)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const h=v=>this._core.options[v],u=(v,S)=>{this._checkReadonlyOptions(v),this._core.options[v]=S};for(const v in this._core.options){const S={get:h.bind(this,v),set:u.bind(this,v)};Object.defineProperty(this._publicOptions,v,S)}}_checkReadonlyOptions(f){if(y.includes(f))throw new Error(`Option "${f}" 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 p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new o.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const f=this._core.coreService.decPrivateModes;let h="none";switch(this._core.coreMouseService.activeProtocol){case"X10":h="x10";break;case"VT200":h="vt200";break;case"DRAG":h="drag";break;case"ANY":h="any"}return{applicationCursorKeysMode:f.applicationCursorKeys,applicationKeypadMode:f.applicationKeypad,bracketedPasteMode:f.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:h,originMode:f.origin,reverseWraparoundMode:f.reverseWraparound,sendFocusMode:f.sendFocus,wraparoundMode:f.wraparound}}get options(){return this._publicOptions}set options(f){for(const h in f)this._publicOptions[h]=f[h]}blur(){this._core.blur()}focus(){this._core.focus()}resize(f,h){this._verifyIntegers(f,h),this._core.resize(f,h)}open(f){this._core.open(f)}attachCustomKeyEventHandler(f){this._core.attachCustomKeyEventHandler(f)}registerLinkProvider(f){return this._core.registerLinkProvider(f)}registerCharacterJoiner(f){return this._checkProposedApi(),this._core.registerCharacterJoiner(f)}deregisterCharacterJoiner(f){this._checkProposedApi(),this._core.deregisterCharacterJoiner(f)}registerMarker(f=0){return this._verifyIntegers(f),this._core.registerMarker(f)}registerDecoration(f){var h,u,v;return this._checkProposedApi(),this._verifyPositiveIntegers((h=f.x)!==null&&h!==void 0?h:0,(u=f.width)!==null&&u!==void 0?u:0,(v=f.height)!==null&&v!==void 0?v:0),this._core.registerDecoration(f)}hasSelection(){return this._core.hasSelection()}select(f,h,u){this._verifyIntegers(f,h,u),this._core.select(f,h,u)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(f,h){this._verifyIntegers(f,h),this._core.selectLines(f,h)}dispose(){super.dispose()}scrollLines(f){this._verifyIntegers(f),this._core.scrollLines(f)}scrollPages(f){this._verifyIntegers(f),this._core.scrollPages(f)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(f){this._verifyIntegers(f),this._core.scrollToLine(f)}clear(){this._core.clear()}write(f,h){this._core.write(f,h)}writeln(f,h){this._core.write(f),this._core.write(`\r
19
- `,h)}paste(f){this._core.paste(f)}refresh(f,h){this._verifyIntegers(f,h),this._core.refresh(f,h)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(f){this._addonManager.loadAddon(this,f)}static get strings(){return r}_verifyIntegers(...f){for(const h of f)if(h===1/0||isNaN(h)||h%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...f){for(const h of f)if(h&&(h===1/0||isNaN(h)||h%1!=0||h<0))throw new Error("This API only accepts positive integers")}}C.Terminal=g})(),b})()))})(Ws)),Ws.exports}var jc=Tc();var Mc=2,Nc=1,Pc=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,s=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(s.getPropertyValue("height")),m=Math.max(0,parseInt(s.getPropertyValue("width"))),b=window.getComputedStyle(this._terminal.element),C={top:parseInt(b.getPropertyValue("padding-top")),bottom:parseInt(b.getPropertyValue("padding-bottom")),right:parseInt(b.getPropertyValue("padding-right")),left:parseInt(b.getPropertyValue("padding-left"))},r=C.top+C.bottom,i=C.right+C.left,l=a-r,d=m-i-t;return{cols:Math.max(Mc,Math.floor(d/e.css.cell.width)),rows:Math.max(Nc,Math.floor(l/e.css.cell.height))}}};function Oc(e={}){const{cwd:t,cols:s,rows:a,onOutput:m,onExit:b}=e,[C,r]=R.useState(null),[i,l]=R.useState(()=>ot.isConnected()),[d,o]=R.useState(!1),[p,_]=R.useState(!1),[y,g]=R.useState(!1),n=R.useRef({onOutput:m,onExit:b});n.current={onOutput:m,onExit:b};const f=R.useRef(null);f.current=C,R.useEffect(()=>{if(!C)return;const w=ot.getSocket(),k=()=>{l(!0),o(!1),r(null),g(!0)},x=()=>{l(!1),o(!1)},E=N=>{N.terminalId===C&&n.current.onOutput?.(N.data)},A=N=>{N.terminalId===C&&(o(!1),n.current.onExit?.(N.exitCode),r(null))},j=N=>{N.terminalId===C&&o(!0)},T=N=>{N.terminalId===C&&o(!1)};return w.on("connect",k),w.on("disconnect",x),w.on(Oe.TERMINAL_STDOUT,E),w.on(Oe.TERMINAL_EXIT,A),w.on(Oe.TERMINAL_SUBSCRIBED,j),w.on(Oe.TERMINAL_UNSUBSCRIBED,T),l(w.connected),w.connected&&w.emit(rt.SUBSCRIBE,{topic:"terminal",id:C},N=>{N.success&&o(!0)}),()=>{w.off("connect",k),w.off("disconnect",x),w.off(Oe.TERMINAL_STDOUT,E),w.off(Oe.TERMINAL_EXIT,A),w.off(Oe.TERMINAL_SUBSCRIBED,j),w.off(Oe.TERMINAL_UNSUBSCRIBED,T),w.emit(rt.UNSUBSCRIBE,{topic:"terminal",id:C})}},[C]);const h=R.useCallback(async()=>{const w=ot.getSocket();if(!w.connected)return null;_(!0);try{const k=await he.post("/terminals",{socketId:w.id,cwd:t,cols:s,rows:a});return r(k.terminalId),g(!1),k.terminalId}catch(k){return console.error("[useStandaloneTerminal] Failed to create terminal:",k),null}finally{_(!1)}},[t,s,a]),u=R.useCallback(async()=>{const w=f.current;if(w){try{await he.delete(`/terminals/${w}`)}catch(k){console.error("[useStandaloneTerminal] Failed to destroy terminal:",k)}r(null),o(!1)}},[]),v=R.useCallback(w=>{const k=f.current;if(!k)return;ot.getSocket().emit(rt.TERMINAL_INPUT,{terminalId:k,data:w})},[]),S=R.useCallback((w,k)=>{const x=f.current;if(!x)return;ot.getSocket().emit(rt.TERMINAL_RESIZE,{terminalId:x,cols:w,rows:k})},[]);return R.useEffect(()=>()=>{const w=f.current;w&&he.delete(`/terminals/${w}`).catch(()=>{})},[]),{terminalId:C,isConnected:i,isAttached:d,isCreating:p,needsRecreate:y,create:h,destroy:u,sendInput:v,resize:S}}const Bc={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"},Ic=Z.memo(function({cwd:t,onExit:s,onReady:a}){const m=R.useRef(null),b=R.useRef(null),C=R.useRef(null),r=R.useRef(!1),{terminalId:i,isAttached:l,needsRecreate:d,create:o,sendInput:p,resize:_}=Oc({cwd:t,onOutput:R.useCallback(y=>{b.current?.write(y)},[]),onExit:R.useCallback(y=>{b.current?.writeln(`\r
20
- \x1B[90m[Process exited with code ${y}]\x1B[0m`),s?.(y)},[s])});return R.useEffect(()=>{if(!d)return;const y=b.current;y&&y.writeln(`\r
21
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),o()},[d,o]),R.useLayoutEffect(()=>{if(!m.current)return;const y=new jc.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Bc,scrollback:5e3,convertEol:!0}),g=new Pc;y.loadAddon(g),y.open(m.current);const n=(f=0)=>{if(!(f>=5))try{const u=m.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>n(f+1),50);return}g.fit(),_(y.cols,y.rows)}catch{setTimeout(()=>n(f+1),50)}};return n(0),setTimeout(()=>n(1),100),b.current=y,C.current=g,()=>{y.dispose(),b.current=null,C.current=null}},[_]),R.useEffect(()=>{r.current||(r.current=!0,o())},[o]),R.useEffect(()=>{const y=b.current;if(!y||!l)return;const g=y.onData(n=>{p(n)});return()=>g.dispose()},[p,l]),R.useEffect(()=>{l&&a?.({sendInput:p})},[l,p,a]),R.useEffect(()=>{if(!m.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const g=C.current,n=b.current,f=m.current;g&&n&&f&&f.clientWidth>0&&f.clientHeight>0&&(g.fit(),_(n.cols,n.rows))}catch{}})});return y.observe(m.current),()=>y.disconnect()},[_]),c.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!i&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),c.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Fc=Z.memo(function({commands:t,onSelect:s}){const[a,m]=R.useState(!1),b=R.useRef(null),C=R.useRef(null);return R.useEffect(()=>{if(!a)return;const r=i=>{b.current&&!b.current.contains(i.target)&&C.current&&!C.current.contains(i.target)&&m(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[a]),t.length===0?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),c.jsxs("div",{className:"relative",children:[c.jsxs("button",{ref:C,onClick:()=>m(!a),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${a?"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:[c.jsx(Ba,{size:12}),c.jsx("span",{children:"快捷命令"}),c.jsx(dt,{size:10,className:`transition-transform ${a?"rotate-180":""}`})]}),a&&c.jsx("div",{ref:b,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:c.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((r,i)=>c.jsxs("button",{onClick:()=>{s(r.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[c.jsx(St,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:r.name}),c.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:r.command})]})]},i))})})]})]})});let Hc=0;function ii(){return`shell-${++Hc}`}const zc=Z.memo(function({cwd:t,quickCommands:s=[]}){const[a,m]=R.useState(()=>[{id:ii(),label:"Shell 1"}]),[b,C]=R.useState(()=>a[0].id),r=R.useRef(new Map),i=R.useCallback(()=>{const _=ii(),y={id:_,label:`Shell ${a.length+1}`};m(g=>[...g,y]),C(_)},[a.length]),l=R.useCallback((_,y)=>{y.stopPropagation(),r.current.delete(_),m(g=>{const n=g.filter(f=>f.id!==_);return _===b&&n.length>0&&C(n[n.length-1].id),n})},[b]),d=R.useCallback(_=>{r.current.delete(_),m(y=>{const g=y.filter(n=>n.id!==_);return _===b&&g.length>0&&C(g[g.length-1].id),g})},[b]),o=R.useCallback((_,y)=>{r.current.set(_,y.sendInput)},[]),p=R.useCallback(_=>{const y=r.current.get(b);y&&y(_+"\r")},[b]);return c.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[c.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[c.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:a.map(_=>c.jsxs("button",{onClick:()=>C(_.id),className:me("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",_.id===b?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[c.jsx(ls,{size:11,className:"shrink-0"}),c.jsx("span",{children:_.label}),a.length>1&&c.jsx("span",{onClick:y=>l(_.id,y),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:c.jsx(bs,{size:10})})]},_.id))}),c.jsx("button",{onClick:i,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:"New Terminal",children:c.jsx(Zs,{size:14})}),s.length>0&&c.jsx(Fc,{commands:s,onSelect:p})]}),c.jsx("div",{className:"flex-1 overflow-hidden relative",children:a.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx(ls,{size:28}),c.jsx("span",{className:"text-xs",children:"No terminals open"}),c.jsx("button",{onClick:i,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:"New Terminal"})]})}):a.map(_=>c.jsx("div",{className:"absolute inset-0",style:{display:_.id===b?"block":"none"},children:c.jsx(Ic,{cwd:t,onExit:()=>d(_.id),onReady:y=>o(_.id,y)})},_.id))})]})});function ni(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,a=Array(t);s<t;s++)a[s]=e[s];return a}function Wc(e){if(Array.isArray(e))return e}function $c(e,t,s){return(t=Gc(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Uc(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var a,m,b,C,r=[],i=!0,l=!1;try{if(b=(s=s.call(e)).next,t!==0)for(;!(i=(a=b.call(s)).done)&&(r.push(a.value),r.length!==t);i=!0);}catch(d){l=!0,m=d}finally{try{if(!i&&s.return!=null&&(C=s.return(),Object(C)!==C))return}finally{if(l)throw m}}return r}}function qc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
22
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oi(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,a)}return s}function ai(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?oi(Object(s),!0).forEach(function(a){$c(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):oi(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function Kc(e,t){if(e==null)return{};var s,a,m=Xc(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(a=0;a<b.length;a++)s=b[a],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(m[s]=e[s])}return m}function Xc(e,t){if(e==null)return{};var s={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;s[a]=e[a]}return s}function Yc(e,t){return Wc(e)||Uc(e,t)||Qc(e,t)||qc()}function Vc(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var a=s.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Gc(e){var t=Vc(e,"string");return typeof t=="symbol"?t:t+""}function Qc(e,t){if(e){if(typeof e=="string")return ni(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?ni(e,t):void 0}}function Zc(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function li(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(m){return Object.getOwnPropertyDescriptor(e,m).enumerable})),s.push.apply(s,a)}return s}function ci(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?li(Object(s),!0).forEach(function(a){Zc(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):li(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function Jc(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(a){return t.reduceRight(function(m,b){return b(m)},a)}}function Nt(e){return function t(){for(var s=this,a=arguments.length,m=new Array(a),b=0;b<a;b++)m[b]=arguments[b];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function ms(e){return{}.toString.call(e).includes("Object")}function eh(e){return!Object.keys(e).length}function qt(e){return typeof e=="function"}function th(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sh(e,t){return ms(t)||ct("changeType"),Object.keys(t).some(function(s){return!th(e,s)})&&ct("changeField"),t}function rh(e){qt(e)||ct("selectorType")}function ih(e){qt(e)||ms(e)||ct("handlerType"),ms(e)&&Object.values(e).some(function(t){return!qt(t)})&&ct("handlersType")}function nh(e){e||ct("initialIsRequired"),ms(e)||ct("initialType"),eh(e)&&ct("initialContent")}function oh(e,t){throw new Error(e[t]||e.default)}var ah={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"},ct=Nt(oh)(ah),ss={changes:sh,selector:rh,handler:ih,initial:nh};function lh(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ss.initial(e),ss.handler(t);var s={current:e},a=Nt(uh)(s,t),m=Nt(hh)(s),b=Nt(ss.changes)(e),C=Nt(ch)(s);function r(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return ss.selector(l),l(s.current)}function i(l){Jc(a,m,b,C)(l)}return[r,i]}function ch(e,t){return qt(t)?t(e.current):t}function hh(e,t){return e.current=ci(ci({},e.current),t),t}function uh(e,t,s){return qt(t)?t(e.current):Object.keys(s).forEach(function(a){var m;return(m=t[a])===null||m===void 0?void 0:m.call(t,e.current[a])}),s}var dh={create:lh},fh={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function ph(e){return function t(){for(var s=this,a=arguments.length,m=new Array(a),b=0;b<a;b++)m[b]=arguments[b];return m.length>=e.length?e.apply(this,m):function(){for(var C=arguments.length,r=new Array(C),i=0;i<C;i++)r[i]=arguments[i];return t.apply(s,[].concat(m,r))}}}function mh(e){return{}.toString.call(e).includes("Object")}function vh(e){return e||hi("configIsRequired"),mh(e)||hi("configType"),e.urls?(gh(),{paths:{vs:e.urls.monacoBase}}):e}function gh(){console.warn(Cn.deprecation)}function _h(e,t){throw new Error(e[t]||e.default)}var Cn={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!
23
- You are using deprecated way of configuration.
24
-
25
- Instead of using
26
- monaco.config({ urls: { monacoBase: '...' } })
27
- use
28
- monaco.config({ paths: { vs: '...' } })
29
-
30
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
31
- `},hi=ph(_h)(Cn),bh={config:vh},xh=function(){for(var t=arguments.length,s=new Array(t),a=0;a<t;a++)s[a]=arguments[a];return function(m){return s.reduceRight(function(b,C){return C(b)},m)}};function wn(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],wn(e[s],t[s]))}),ai(ai({},e),t)}var Sh={type:"cancelation",msg:"operation is manually canceled"};function $s(e){var t=!1,s=new Promise(function(a,m){e.then(function(b){return t?m(Sh):a(b)}),e.catch(m)});return s.cancel=function(){return t=!0},s}var yh=["monaco"],Ch=dh.create({config:fh,isInitialized:!1,resolve:null,reject:null,monaco:null}),En=Yc(Ch,2),Gt=En[0],Ds=En[1];function wh(e){var t=bh.config(e),s=t.monaco,a=Kc(t,yh);Ds(function(m){return{config:wn(m.config,a),monaco:s}})}function Eh(){var e=Gt(function(t){var s=t.monaco,a=t.isInitialized,m=t.resolve;return{monaco:s,isInitialized:a,resolve:m}});if(!e.isInitialized){if(Ds({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),$s(Us);if(window.monaco&&window.monaco.editor)return kn(window.monaco),e.resolve(window.monaco),$s(Us);xh(kh,Dh)(Lh)}return $s(Us)}function kh(e){return document.body.appendChild(e)}function Rh(e){var t=document.createElement("script");return e&&(t.src=e),t}function Dh(e){var t=Gt(function(a){var m=a.config,b=a.reject;return{config:m,reject:b}}),s=Rh("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Lh(){var e=Gt(function(s){var a=s.config,m=s.resolve,b=s.reject;return{config:a,resolve:m,reject:b}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var a=s.m||s;kn(a),e.resolve(a)},function(s){e.reject(s)})}function kn(e){Gt().monaco||Ds({monaco:e})}function Ah(){return Gt(function(e){var t=e.monaco;return t})}var Us=new Promise(function(e,t){return Ds({resolve:e,reject:t})}),Rn={config:wh,init:Eh,__getMonacoInstance:Ah},Th={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},qs=Th,jh={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Mh=jh;function Nh({children:e}){return Z.createElement("div",{style:Mh.container},e)}var Ph=Nh,Oh=Ph;function Bh({width:e,height:t,isEditorReady:s,loading:a,_ref:m,className:b,wrapperProps:C}){return Z.createElement("section",{style:{...qs.wrapper,width:e,height:t},...C},!s&&Z.createElement(Oh,null,a),Z.createElement("div",{ref:m,style:{...qs.fullWidth,...!s&&qs.hide},className:b}))}var Ih=Bh,Dn=R.memo(Ih);function Fh(e){R.useEffect(e,[])}var Ln=Fh;function Hh(e,t,s=!0){let a=R.useRef(!0);R.useEffect(a.current||!s?()=>{a.current=!1}:e,t)}var Ke=Hh;function Ft(){}function bt(e,t,s,a){return zh(e,a)||Wh(e,t,s,a)}function zh(e,t){return e.editor.getModel(An(e,t))}function Wh(e,t,s,a){return e.editor.createModel(t,s,a?An(e,a):void 0)}function An(e,t){return e.Uri.parse(t)}function $h({original:e,modified:t,language:s,originalLanguage:a,modifiedLanguage:m,originalModelPath:b,modifiedModelPath:C,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:d="Loading...",options:o={},height:p="100%",width:_="100%",className:y,wrapperProps:g={},beforeMount:n=Ft,onMount:f=Ft}){let[h,u]=R.useState(!1),[v,S]=R.useState(!0),w=R.useRef(null),k=R.useRef(null),x=R.useRef(null),E=R.useRef(f),A=R.useRef(n),j=R.useRef(!1);Ln(()=>{let F=Rn.init();return F.then(H=>(k.current=H)&&S(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>w.current?I():F.cancel()}),Ke(()=>{if(w.current&&k.current){let F=w.current.getOriginalEditor(),H=bt(k.current,e||"",a||s||"text",b||"");H!==F.getModel()&&F.setModel(H)}},[b],h),Ke(()=>{if(w.current&&k.current){let F=w.current.getModifiedEditor(),H=bt(k.current,t||"",m||s||"text",C||"");H!==F.getModel()&&F.setModel(H)}},[C],h),Ke(()=>{let F=w.current.getModifiedEditor();F.getOption(k.current.editor.EditorOption.readOnly)?F.setValue(t||""):t!==F.getValue()&&(F.executeEdits("",[{range:F.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),F.pushUndoStop())},[t],h),Ke(()=>{w.current?.getModel()?.original.setValue(e||"")},[e],h),Ke(()=>{let{original:F,modified:H}=w.current.getModel();k.current.editor.setModelLanguage(F,a||s||"text"),k.current.editor.setModelLanguage(H,m||s||"text")},[s,a,m],h),Ke(()=>{k.current?.editor.setTheme(l)},[l],h),Ke(()=>{w.current?.updateOptions(o)},[o],h);let T=R.useCallback(()=>{if(!k.current)return;A.current(k.current);let F=bt(k.current,e||"",a||s||"text",b||""),H=bt(k.current,t||"",m||s||"text",C||"");w.current?.setModel({original:F,modified:H})},[s,t,m,e,a,b,C]),N=R.useCallback(()=>{!j.current&&x.current&&(w.current=k.current.editor.createDiffEditor(x.current,{automaticLayout:!0,...o}),T(),k.current?.editor.setTheme(l),u(!0),j.current=!0)},[o,l,T]);R.useEffect(()=>{h&&E.current(w.current,k.current)},[h]),R.useEffect(()=>{!v&&!h&&N()},[v,h,N]);function I(){let F=w.current?.getModel();r||F?.original?.dispose(),i||F?.modified?.dispose(),w.current?.dispose()}return Z.createElement(Dn,{width:_,height:p,isEditorReady:h,loading:d,_ref:x,className:y,wrapperProps:g})}var Uh=$h;R.memo(Uh);function qh(e){let t=R.useRef();return R.useEffect(()=>{t.current=e},[e]),t.current}var Kh=qh,rs=new Map;function Xh({defaultValue:e,defaultLanguage:t,defaultPath:s,value:a,language:m,path:b,theme:C="light",line:r,loading:i="Loading...",options:l={},overrideServices:d={},saveViewState:o=!0,keepCurrentModel:p=!1,width:_="100%",height:y="100%",className:g,wrapperProps:n={},beforeMount:f=Ft,onMount:h=Ft,onChange:u,onValidate:v=Ft}){let[S,w]=R.useState(!1),[k,x]=R.useState(!0),E=R.useRef(null),A=R.useRef(null),j=R.useRef(null),T=R.useRef(h),N=R.useRef(f),I=R.useRef(),F=R.useRef(a),H=Kh(b),z=R.useRef(!1),D=R.useRef(!1);Ln(()=>{let O=Rn.init();return O.then(U=>(E.current=U)&&x(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>A.current?P():O.cancel()}),Ke(()=>{let O=bt(E.current,e||a||"",t||m||"",b||s||"");O!==A.current?.getModel()&&(o&&rs.set(H,A.current?.saveViewState()),A.current?.setModel(O),o&&A.current?.restoreViewState(rs.get(b)))},[b],S),Ke(()=>{A.current?.updateOptions(l)},[l],S),Ke(()=>{!A.current||a===void 0||(A.current.getOption(E.current.editor.EditorOption.readOnly)?A.current.setValue(a):a!==A.current.getValue()&&(D.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),A.current.pushUndoStop(),D.current=!1))},[a],S),Ke(()=>{let O=A.current?.getModel();O&&m&&E.current?.editor.setModelLanguage(O,m)},[m],S),Ke(()=>{r!==void 0&&A.current?.revealLine(r)},[r],S),Ke(()=>{E.current?.editor.setTheme(C)},[C],S);let M=R.useCallback(()=>{if(!(!j.current||!E.current)&&!z.current){N.current(E.current);let O=b||s,U=bt(E.current,a||e||"",t||m||"",O||"");A.current=E.current?.editor.create(j.current,{model:U,automaticLayout:!0,...l},d),o&&A.current.restoreViewState(rs.get(O)),E.current.editor.setTheme(C),r!==void 0&&A.current.revealLine(r),w(!0),z.current=!0}},[e,t,s,a,m,b,l,d,o,C,r]);R.useEffect(()=>{S&&T.current(A.current,E.current)},[S]),R.useEffect(()=>{!k&&!S&&M()},[k,S,M]),F.current=a,R.useEffect(()=>{S&&u&&(I.current?.dispose(),I.current=A.current?.onDidChangeModelContent(O=>{D.current||u(A.current.getValue(),O)}))},[S,u]),R.useEffect(()=>{if(S){let O=E.current.editor.onDidChangeMarkers(U=>{let K=A.current.getModel()?.uri;if(K&&U.find(X=>X.path===K.path)){let X=E.current.editor.getModelMarkers({resource:K});v?.(X)}});return()=>{O?.dispose()}}return()=>{}},[S,v]);function P(){I.current?.dispose(),p?o&&rs.set(b,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return Z.createElement(Dn,{width:_,height:y,isEditorReady:S,loading:i,_ref:j,className:g,wrapperProps:n})}var Yh=Xh,Vh=R.memo(Yh),Gh=Vh,Qe=function(e,t){return Number(e.toFixed(t))},Qh=function(e,t){return typeof e=="number"?e:t},Ce=function(e,t,s){s&&typeof s=="function"&&s(e,t)},Zh=function(e){return-Math.cos(e*Math.PI)/2+.5},Jh=function(e){return e},eu=function(e){return e*e},tu=function(e){return e*(2-e)},su=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},ru=function(e){return e*e*e},iu=function(e){return--e*e*e+1},nu=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},ou=function(e){return e*e*e*e},au=function(e){return 1- --e*e*e*e},lu=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},cu=function(e){return e*e*e*e*e},hu=function(e){return 1+--e*e*e*e*e},uu=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Tn={easeOut:Zh,linear:Jh,easeInQuad:eu,easeOutQuad:tu,easeInOutQuad:su,easeInCubic:ru,easeOutCubic:iu,easeInOutCubic:nu,easeInQuart:ou,easeOutQuart:au,easeInOutQuart:lu,easeInQuint:cu,easeOutQuint:hu,easeInOutQuint:uu},jn=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Je=function(e){e.mounted&&(jn(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Mn(e,t,s,a){if(e.mounted){var m=new Date().getTime(),b=1;Je(e),e.animation=function(){if(!e.mounted)return jn(e.animation);var C=new Date().getTime()-m,r=C/s,i=Tn[t],l=i(r);C>=s?(a(b),e.animation=null):e.animation&&(a(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function du(e){var t=e.scale,s=e.positionX,a=e.positionY;return!(Number.isNaN(t)||Number.isNaN(s)||Number.isNaN(a))}function ft(e,t,s,a){var m=du(t);if(!(!e.mounted||!m)){var b=e.setTransformState,C=e.transformState,r=C.scale,i=C.positionX,l=C.positionY,d=t.scale-r,o=t.positionX-i,p=t.positionY-l;s===0?b(t.scale,t.positionX,t.positionY):Mn(e,a,s,function(_){var y=r+d*_,g=i+o*_,n=l+p*_;b(y,g,n)})}}function fu(e,t,s){var a=e.offsetWidth,m=e.offsetHeight,b=t.offsetWidth,C=t.offsetHeight,r=b*s,i=C*s,l=a-r,d=m-i;return{wrapperWidth:a,wrapperHeight:m,newContentWidth:r,newDiffWidth:l,newContentHeight:i,newDiffHeight:d}}var pu=function(e,t,s,a,m,b,C){var r=e>t?s*(C?1:.5):0,i=a>m?b*(C?1:.5):0,l=e-t-r,d=r,o=a-m-i,p=i;return{minPositionX:l,maxPositionX:d,minPositionY:o,maxPositionY:p}},Rr=function(e,t){var s=e.wrapperComponent,a=e.contentComponent,m=e.setup.centerZoomedOut;if(!s||!a)throw new Error("Components are not mounted");var b=fu(s,a,t),C=b.wrapperWidth,r=b.wrapperHeight,i=b.newContentWidth,l=b.newDiffWidth,d=b.newContentHeight,o=b.newDiffHeight,p=pu(C,i,l,r,d,o,!!m);return p},rr=function(e,t,s,a){return a?e<t?Qe(t,2):e>s?Qe(s,2):Qe(e,2):Qe(e,2)},mt=function(e,t){var s=Rr(e,t);return e.bounds=s,s};function Qt(e,t,s,a,m,b,C){var r=s.minPositionX,i=s.minPositionY,l=s.maxPositionX,d=s.maxPositionY,o=0,p=0;C&&(o=m,p=b);var _=rr(e,r-o,l+o,a),y=rr(t,i-p,d+p,a);return{x:_,y}}function Ls(e,t,s,a,m,b){var C=e.transformState,r=C.scale,i=C.positionX,l=C.positionY,d=a-r;if(typeof t!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var o=i-t*d,p=l-s*d,_=Qt(o,p,m,b,0,0,null);return _}function Zt(e,t,s,a,m){var b=m?a:0,C=t-b;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(t)&&e<=C?C:e}var ui=function(e,t){var s=e.setup.panning.excluded,a=e.isInitialized,m=e.wrapperComponent,b=t.target,C="shadowRoot"in b&&"composedPath"in t,r=C?t.composedPath().some(function(d){return d instanceof Element?m?.contains(d):!1}):m?.contains(b),i=a&&b&&r;if(!i)return!1;var l=As(b,s);return!l},di=function(e){var t=e.isInitialized,s=e.isPanning,a=e.setup,m=a.panning.disabled,b=t&&s&&!m;return!!b},mu=function(e,t){var s=e.transformState,a=s.positionX,m=s.positionY;e.isPanning=!0;var b=t.clientX,C=t.clientY;e.startCoords={x:b-a,y:C-m}},vu=function(e,t){var s=t.touches,a=e.transformState,m=a.positionX,b=a.positionY;e.isPanning=!0;var C=s.length===1;if(C){var r=s[0].clientX,i=s[0].clientY;e.startCoords={x:r-m,y:i-b}}};function gu(e){var t=e.transformState,s=t.positionX,a=t.positionY,m=t.scale,b=e.setup,C=b.disabled,r=b.limitToBounds,i=b.centerZoomedOut,l=e.wrapperComponent;if(!(C||!l||!e.bounds)){var d=e.bounds,o=d.maxPositionX,p=d.minPositionX,_=d.maxPositionY,y=d.minPositionY,g=s>o||s<p,n=a>_||a<y,f=s>o?l.offsetWidth:e.setup.minPositionX||0,h=a>_?l.offsetHeight:e.setup.minPositionY||0,u=Ls(e,f,h,m,e.bounds,r||i),v=u.x,S=u.y;return{scale:m,positionX:g?v:s,positionY:n?S:a}}}function Nn(e,t,s,a,m){var b=e.setup.limitToBounds,C=e.wrapperComponent,r=e.bounds,i=e.transformState,l=i.scale,d=i.positionX,o=i.positionY;if(!(C===null||r===null||t===d&&s===o)){var p=Qt(t,s,r,b,a,m,C),_=p.x,y=p.y;e.setTransformState(l,_,y)}}var _u=function(e,t,s){var a=e.startCoords,m=e.transformState,b=e.setup.panning,C=b.lockAxisX,r=b.lockAxisY,i=m.positionX,l=m.positionY;if(!a)return{x:i,y:l};var d=t-a.x,o=s-a.y,p=C?i:d,_=r?l:o;return{x:p,y:_}},ut=function(e,t){var s=e.setup,a=e.transformState,m=a.scale,b=s.minScale,C=s.disablePadding;return t>0&&m>=b&&!C?t:0},bu=function(e){var t=e.mounted,s=e.setup,a=s.disabled,m=s.velocityAnimation,b=e.transformState.scale,C=m.disabled,r=!C||b>1||!a||t;return!!r},xu=function(e){var t=e.mounted,s=e.velocity,a=e.bounds,m=e.setup,b=m.disabled,C=m.velocityAnimation,r=e.transformState.scale,i=C.disabled,l=!i||r>1||!b||t;return!(!l||!s||!a)};function Su(e,t){var s=e.setup.velocityAnimation,a=s.equalToMove,m=s.animationTime,b=s.sensitivity;return a?m*t*b:m}function fi(e,t,s,a,m,b,C,r,i,l){if(m){if(t>C&&s>C){var d=C+(e-C)*l;return d>i?i:d<C?C:d}if(t<b&&s<b){var d=b+(e-b)*l;return d<r?r:d>b?b:d}}return a?t:rr(e,b,C,m)}function yu(e,t){var s=1;return t?Math.min(s,e.offsetWidth/window.innerWidth):s}function Cu(e,t){var s=bu(e);if(s){var a=e.lastMousePosition,m=e.velocityTime,b=e.setup,C=e.wrapperComponent,r=b.velocityAnimation.equalToMove,i=Date.now();if(a&&m&&C){var l=yu(C,r),d=t.x-a.x,o=t.y-a.y,p=d/l,_=o/l,y=i-m,g=d*d+o*o,n=Math.sqrt(g)/y;e.velocity={velocityX:p,velocityY:_,total:n}}e.lastMousePosition=t,e.velocityTime=i}}function wu(e){var t=e.velocity,s=e.bounds,a=e.setup,m=e.wrapperComponent,b=xu(e);if(!(!b||!t||!s||!m)){var C=t.velocityX,r=t.velocityY,i=t.total,l=s.maxPositionX,d=s.minPositionX,o=s.maxPositionY,p=s.minPositionY,_=a.limitToBounds,y=a.alignmentAnimation,g=a.zoomAnimation,n=a.panning,f=n.lockAxisY,h=n.lockAxisX,u=g.animationType,v=y.sizeX,S=y.sizeY,w=y.velocityAlignmentTime,k=w,x=Su(e,i),E=Math.max(x,k),A=ut(e,v),j=ut(e,S),T=A*m.offsetWidth/100,N=j*m.offsetHeight/100,I=l+T,F=d-T,H=o+N,z=p-N,D=e.transformState,M=new Date().getTime();Mn(e,u,E,function(P){var O=e.transformState,U=O.scale,K=O.positionX,X=O.positionY,G=new Date().getTime()-M,ne=G/k,L=Tn[y.animationType],B=1-L(Math.min(1,ne)),$=1-P,W=K+C*$,J=X+r*$,Y=fi(W,D.positionX,K,h,_,d,l,F,I,B),oe=fi(J,D.positionY,X,f,_,p,o,z,H,B);(K!==W||X!==J)&&e.setTransformState(U,Y,oe)})}}function pi(e,t){var s=e.transformState.scale;Je(e),mt(e,s),window.TouchEvent!==void 0&&t instanceof TouchEvent?vu(e,t):mu(e,t)}function Dr(e,t){var s=e.transformState.scale,a=e.setup,m=a.minScale,b=a.alignmentAnimation,C=b.disabled,r=b.sizeX,i=b.sizeY,l=b.animationTime,d=b.animationType,o=C||s<m||!r&&!i;if(!o){var p=gu(e);p&&ft(e,p,t??l,d)}}function mi(e,t,s){var a=e.startCoords,m=e.setup,b=m.alignmentAnimation,C=b.sizeX,r=b.sizeY;if(a){var i=_u(e,t,s),l=i.x,d=i.y,o=ut(e,C),p=ut(e,r);Cu(e,{x:l,y:d}),Nn(e,l,d,o,p)}}function Eu(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,s=e.velocity,a=e.wrapperComponent,m=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var b=a?.getBoundingClientRect(),C=m?.getBoundingClientRect(),r=b?.width||0,i=b?.height||0,l=C?.width||0,d=C?.height||0,o=r<l||i<d,p=!t&&s&&s?.total>.1&&o;p?wu(e):Dr(e)}}function Lr(e,t,s,a){var m=e.setup,b=m.minScale,C=m.maxScale,r=m.limitToBounds,i=Zt(Qe(t,2),b,C,0,!1),l=mt(e,i),d=Ls(e,s,a,i,l,r),o=d.x,p=d.y;return{scale:i,positionX:o,positionY:p}}function Pn(e,t,s){var a=e.transformState.scale,m=e.wrapperComponent,b=e.setup,C=b.minScale,r=b.limitToBounds,i=b.zoomAnimation,l=i.disabled,d=i.animationTime,o=i.animationType,p=l||a>=C;if((a>=1||r)&&Dr(e),!(p||!m||!e.mounted)){var _=t||m.offsetWidth/2,y=s||m.offsetHeight/2,g=Lr(e,C,_,y);g&&ft(e,g,d,o)}}var ht=function(){return ht=Object.assign||function(t){for(var s,a=1,m=arguments.length;a<m;a++){s=arguments[a];for(var b in s)Object.prototype.hasOwnProperty.call(s,b)&&(t[b]=s[b])}return t},ht.apply(this,arguments)};function vi(e,t,s){for(var a=0,m=t.length,b;a<m;a++)(b||!(a in t))&&(b||(b=Array.prototype.slice.call(t,0,a)),b[a]=t[a]);return e.concat(b||Array.prototype.slice.call(t))}var is={scale:1,positionX:0,positionY:0},jt={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}},ir={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},On=function(e){var t,s,a,m;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:is.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:is.scale,positionX:(a=e.initialPositionX)!==null&&a!==void 0?a:is.positionX,positionY:(m=e.initialPositionY)!==null&&m!==void 0?m:is.positionY}},gi=function(e){var t=ht({},jt);return Object.keys(e).forEach(function(s){var a=typeof e[s]<"u",m=typeof jt[s]<"u";if(m&&a){var b=Object.prototype.toString.call(jt[s]),C=b==="[object Object]",r=b==="[object Array]";C?t[s]=ht(ht({},jt[s]),e[s]):r?t[s]=vi(vi([],jt[s],!0),e[s]):t[s]=e[s]}}),t},Bn=function(e,t,s){var a=e.transformState.scale,m=e.wrapperComponent,b=e.setup,C=b.maxScale,r=b.minScale,i=b.zoomAnimation,l=b.smooth,d=i.size;if(!m)throw new Error("Wrapper is not mounted");var o=l?a*Math.exp(t*s):a+t*s,p=Zt(Qe(o,3),r,C,d,!1);return p};function In(e,t,s,a,m){var b=e.wrapperComponent,C=e.transformState,r=C.scale,i=C.positionX,l=C.positionY;if(!b)return console.error("No WrapperComponent found");var d=b.offsetWidth,o=b.offsetHeight,p=(d/2-i)/r,_=(o/2-l)/r,y=Bn(e,t,s),g=Lr(e,y,p,_);if(!g)return console.error("Error during zoom event. New transformation state was not calculated.");ft(e,g,a,m)}function Fn(e,t,s,a){var m=e.setup,b=e.wrapperComponent,C=m.limitToBounds,r=On(e.props),i=e.transformState,l=i.scale,d=i.positionX,o=i.positionY;if(b){var p=Rr(e,r.scale),_=Qt(r.positionX,r.positionY,p,C,0,0,b),y={scale:r.scale,positionX:_.x,positionY:_.y};l===r.scale&&d===r.positionX&&o===r.positionY||(a?.(),ft(e,y,t,s))}}function ku(e,t,s,a){var m=e.getBoundingClientRect(),b=t.getBoundingClientRect(),C=s.getBoundingClientRect(),r=b.x*a.scale,i=b.y*a.scale;return{x:(m.x-C.x+r)/a.scale,y:(m.y-C.y+i)/a.scale}}function Ru(e,t,s){var a=e.wrapperComponent,m=e.contentComponent,b=e.transformState,C=e.setup,r=C.limitToBounds,i=C.minScale,l=C.maxScale;if(!a||!m)return b;var d=a.getBoundingClientRect(),o=t.getBoundingClientRect(),p=ku(t,a,m,b),_=p.x,y=p.y,g=o.width/b.scale,n=o.height/b.scale,f=a.offsetWidth/g,h=a.offsetHeight/n,u=Zt(s||Math.min(f,h),i,l,0,!1),v=(d.width-g*u)/2,S=(d.height-n*u)/2,w=(d.left-_)*u+v,k=(d.top-y)*u+S,x=Rr(e,u),E=Qt(w,k,x,r,0,0,a),A=E.x,j=E.y;return{positionX:A,positionY:j,scale:u}}var Du=function(e){return function(t,s,a){t===void 0&&(t=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),In(e,1,t,s,a)}},Lu=function(e){return function(t,s,a){t===void 0&&(t=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),In(e,-1,t,s,a)}},Au=function(e){return function(t,s,a,m,b){m===void 0&&(m=300),b===void 0&&(b="easeOut");var C=e.transformState,r=C.positionX,i=C.positionY,l=C.scale,d=e.wrapperComponent,o=e.contentComponent,p=e.setup.disabled;if(!(p||!d||!o)){var _={positionX:Number.isNaN(t)?r:t,positionY:Number.isNaN(s)?i:s,scale:Number.isNaN(a)?l:a};ft(e,_,m,b)}}},Tu=function(e){return function(t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut"),Fn(e,t,s)}},ju=function(e){return function(t,s,a){s===void 0&&(s=200),a===void 0&&(a="easeOut");var m=e.transformState,b=e.wrapperComponent,C=e.contentComponent;if(b&&C){var r=Hn(t||m.scale,b,C);ft(e,r,s,a)}}},Mu=function(e){return function(t,s,a,m){a===void 0&&(a=600),m===void 0&&(m="easeOut"),Je(e);var b=e.wrapperComponent,C=typeof t=="string"?document.getElementById(t):t;if(b&&C&&b.contains(C)){var r=Ru(e,C,s);ft(e,r,a,m)}}},vs=function(e){return{instance:e,zoomIn:Du(e),zoomOut:Lu(e),setTransform:Au(e),resetTransform:Tu(e),centerView:ju(e),zoomToElement:Mu(e)}},nr=function(e){return{instance:e,state:e.transformState}},Se=function(e){var t={};return Object.assign(t,nr(e)),Object.assign(t,vs(e)),t},Ks=!1;function Xs(){try{var e={get passive(){return Ks=!0,!1}};return e}catch{return Ks=!1,Ks}}var ns=".".concat(ir.wrapperClass),As=function(e,t){return t.some(function(s){return e.matches("".concat(ns," ").concat(s,", ").concat(ns," .").concat(s,", ").concat(ns," ").concat(s," *, ").concat(ns," .").concat(s," *"))})},or=function(e){e&&clearTimeout(e)},Nu=function(e,t,s){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(s,")")},Hn=function(e,t,s){var a=s.offsetWidth*e,m=s.offsetHeight*e,b=(t.offsetWidth-a)/2,C=(t.offsetHeight-m)/2;return{scale:e,positionX:b,positionY:C}};function Pu(e){return function(t){e.forEach(function(s){typeof s=="function"?s(t):s!=null&&(s.current=t)})}}var Ou=function(e,t){var s=e.setup.wheel,a=s.disabled,m=s.wheelDisabled,b=s.touchPadDisabled,C=s.excluded,r=e.isInitialized,i=e.isPanning,l=t.target,d=r&&!i&&!a&&l;if(!d||m&&!t.ctrlKey||b&&t.ctrlKey)return!1;var o=As(l,C);return!o},Bu=function(e){return e?e.deltaY<0?1:-1:0};function Iu(e,t){var s=Bu(e),a=Qh(t,s);return a}function zn(e,t,s){var a=t.getBoundingClientRect(),m=0,b=0;if("clientX"in e)m=(e.clientX-a.left)/s,b=(e.clientY-a.top)/s;else{var C=e.touches[0];m=(C.clientX-a.left)/s,b=(C.clientY-a.top)/s}return(Number.isNaN(m)||Number.isNaN(b))&&console.error("No mouse or touch offset found"),{x:m,y:b}}var Fu=function(e,t,s,a,m){var b=e.transformState.scale,C=e.wrapperComponent,r=e.setup,i=r.maxScale,l=r.minScale,d=r.zoomAnimation,o=r.disablePadding,p=d.size,_=d.disabled;if(!C)throw new Error("Wrapper is not mounted");var y=b+t*s,g=a?!1:!_,n=Zt(Qe(y,3),l,i,p,g&&!o);return n},Hu=function(e,t){var s=e.previousWheelEvent,a=e.transformState.scale,m=e.setup,b=m.maxScale,C=m.minScale;return s?a<b||a>C||Math.sign(s.deltaY)!==Math.sign(t.deltaY)||s.deltaY>0&&s.deltaY<t.deltaY||s.deltaY<0&&s.deltaY>t.deltaY||Math.sign(s.deltaY)!==Math.sign(t.deltaY):!1},zu=function(e,t){var s=e.setup.pinch,a=s.disabled,m=s.excluded,b=e.isInitialized,C=t.target,r=b&&!a&&C;if(!r)return!1;var i=As(C,m);return!i},Wu=function(e){var t=e.setup.pinch.disabled,s=e.isInitialized,a=e.pinchStartDistance,m=s&&!t&&a;return!!m},$u=function(e,t,s){var a=s.getBoundingClientRect(),m=e.touches,b=Qe(m[0].clientX-a.left,5),C=Qe(m[0].clientY-a.top,5),r=Qe(m[1].clientX-a.left,5),i=Qe(m[1].clientY-a.top,5);return{x:(b+r)/2/t,y:(C+i)/2/t}},Wn=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))},Uu=function(e,t){var s=e.pinchStartScale,a=e.pinchStartDistance,m=e.setup,b=m.maxScale,C=m.minScale,r=m.zoomAnimation,i=m.disablePadding,l=r.size,d=r.disabled;if(!s||a===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var o=t/a,p=o*s;return Zt(Qe(p,2),C,b,l,!d&&!i)},qu=160,Ku=100,Xu=function(e,t){var s=e.props,a=s.onWheelStart,m=s.onZoomStart;e.wheelStopEventTimer||(Je(e),Ce(Se(e),t,a),Ce(Se(e),t,m))},Yu=function(e,t){var s=e.props,a=s.onWheel,m=s.onZoom,b=e.contentComponent,C=e.setup,r=e.transformState,i=r.scale,l=C.limitToBounds,d=C.centerZoomedOut,o=C.zoomAnimation,p=C.wheel,_=C.disablePadding,y=C.smooth,g=o.size,n=o.disabled,f=p.step,h=p.smoothStep;if(!b)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=Iu(t,null),v=y?h*Math.abs(t.deltaY):f,S=Fu(e,u,v,!t.ctrlKey);if(i!==S){var w=mt(e,S),k=zn(t,b,i),x=n||g===0||d||_,E=l&&x,A=Ls(e,k.x,k.y,S,w,E),j=A.x,T=A.y;e.previousWheelEvent=t,e.setTransformState(S,j,T),Ce(Se(e),t,a),Ce(Se(e),t,m)}},Vu=function(e,t){var s=e.props,a=s.onWheelStop,m=s.onZoomStop;or(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Pn(e,t.x,t.y),e.wheelAnimationTimer=null)},Ku);var b=Hu(e,t);b&&(or(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ce(Se(e),t,a),Ce(Se(e),t,m))},qu))},$n=function(e){for(var t=0,s=0,a=0;a<2;a+=1)t+=e.touches[a].clientX,s+=e.touches[a].clientY;var m=t/2,b=s/2;return{x:m,y:b}},Gu=function(e,t){var s=Wn(t);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var a=$n(t);e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y,Je(e)},Qu=function(e,t){var s=e.contentComponent,a=e.pinchStartDistance,m=e.wrapperComponent,b=e.transformState.scale,C=e.setup,r=C.limitToBounds,i=C.centerZoomedOut,l=C.zoomAnimation,d=C.alignmentAnimation,o=l.disabled,p=l.size;if(!(a===null||!s)){var _=$u(t,b,s);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var y=Wn(t),g=Uu(e,y),n=$n(t),f=n.x-(e.pinchLastCenterX||0),h=n.y-(e.pinchLastCenterY||0);if(!(g===b&&f===0&&h===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var u=mt(e,g),v=o||p===0||i,S=r&&v,w=Ls(e,_.x,_.y,g,u,S),k=w.x,x=w.y;e.pinchMidpoint=_,e.lastDistance=y;var E=d.sizeX,A=d.sizeY,j=ut(e,E),T=ut(e,A),N=k+f,I=x+h,F=Qt(N,I,u,r,j,T,m),H=F.x,z=F.y;e.setTransformState(g,H,z)}}}},Zu=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Pn(e,t?.x,t?.y)},Un=function(e,t){var s=e.props.onZoomStop,a=e.setup.doubleClick.animationTime;or(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ce(Se(e),t,s)},a)},Ju=function(e,t){var s=e.props,a=s.onZoomStart,m=s.onZoom,b=e.setup.doubleClick,C=b.animationTime,r=b.animationType;Ce(Se(e),t,a),Fn(e,C,r,function(){return Ce(Se(e),t,m)}),Un(e,t)};function ed(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function td(e,t){var s=e.setup,a=e.doubleClickStopEventTimer,m=e.transformState,b=e.contentComponent,C=m.scale,r=e.props,i=r.onZoomStart,l=r.onZoom,d=s.doubleClick,o=d.disabled,p=d.mode,_=d.step,y=d.animationTime,g=d.animationType;if(!o&&!a){if(p==="reset")return Ju(e,t);if(!b)return console.error("No ContentComponent found");var n=ed(p,e.transformState.scale),f=Bn(e,n,_);if(C!==f){Ce(Se(e),t,i);var h=zn(t,b,C),u=Lr(e,f,h.x,h.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");Ce(Se(e),t,l),ft(e,u,y,g),Un(e,t)}}}var sd=function(e,t){var s=e.isInitialized,a=e.setup,m=e.wrapperComponent,b=a.doubleClick,C=b.disabled,r=b.excluded,i=t.target,l=m?.contains(i),d=s&&i&&l&&!C;if(!d)return!1;var o=As(i,r);return!o},rd=(function(){function e(t){var s=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(){s.initializeWindowEvents()},this.unmount=function(){s.cleanupWindowEvents()},this.update=function(a){s.props=a,mt(s,s.transformState.scale),s.setup=gi(a)},this.initializeWindowEvents=function(){var a,m,b=Xs(),C=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,r=C?.defaultView;(m=s.wrapperComponent)===null||m===void 0||m.addEventListener("wheel",s.onWheelPanning,b),r?.addEventListener("mousedown",s.onPanningStart,b),r?.addEventListener("mousemove",s.onPanning,b),r?.addEventListener("mouseup",s.onPanningStop,b),C?.addEventListener("mouseleave",s.clearPanning,b),r?.addEventListener("keyup",s.setKeyUnPressed,b),r?.addEventListener("keydown",s.setKeyPressed,b)},this.cleanupWindowEvents=function(){var a,m,b=Xs(),C=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,r=C?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,b),r?.removeEventListener("mousemove",s.onPanning,b),r?.removeEventListener("mouseup",s.onPanningStop,b),C?.removeEventListener("mouseleave",s.clearPanning,b),r?.removeEventListener("keyup",s.setKeyUnPressed,b),r?.removeEventListener("keydown",s.setKeyPressed,b),document.removeEventListener("mouseleave",s.clearPanning,b),Je(s),(m=s.observer)===null||m===void 0||m.disconnect()},this.handleInitializeWrapperEvents=function(a){var m=Xs();a.addEventListener("wheel",s.onWheelZoom,m),a.addEventListener("dblclick",s.onDoubleClick,m),a.addEventListener("touchstart",s.onTouchPanningStart,m),a.addEventListener("touchmove",s.onTouchPanning,m),a.addEventListener("touchend",s.onTouchPanningStop,m)},this.handleInitialize=function(a,m){var b=!1,C=s.setup.centerOnInit,r=function(i,l){for(var d=0,o=i;d<o.length;d++){var p=o[d];if(p.target===l)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(i){i(Se(s))}),s.observer=new ResizeObserver(function(i){if(r(i,a)||r(i,m))if(C&&!b){var l=m.offsetWidth,d=m.offsetHeight;(l>0||d>0)&&(b=!0,s.setCenter())}else Je(s),mt(s,s.transformState.scale),Dr(s,0)}),s.observer.observe(a),s.observer.observe(m)},this.onWheelZoom=function(a){var m=s.setup.disabled;if(!m){var b=Ou(s,a);if(b){var C=s.isPressingKeys(s.setup.wheel.activationKeys);C&&(Xu(s,a),Yu(s,a),Vu(s,a))}}},this.onWheelPanning=function(a){var m=s.setup,b=m.disabled,C=m.wheel,r=m.panning;if(!(!s.wrapperComponent||!s.contentComponent||b||!C.wheelDisabled||r.disabled||!r.wheelPanning||a.ctrlKey)){a.preventDefault(),a.stopPropagation();var i=s.transformState,l=i.positionX,d=i.positionY,o=l-a.deltaX,p=d-a.deltaY,_=r.lockAxisX?l:o,y=r.lockAxisY?d:p,g=s.setup.alignmentAnimation,n=g.sizeX,f=g.sizeY,h=ut(s,n),u=ut(s,f);_===l&&y===d||Nn(s,_,y,h,u)}},this.onPanningStart=function(a){var m=s.setup.disabled,b=s.props.onPanningStart;if(!m){var C=ui(s,a);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(a.button===0&&!s.setup.panning.allowLeftClickPan||a.button===1&&!s.setup.panning.allowMiddleClickPan||a.button===2&&!s.setup.panning.allowRightClickPan||(a.preventDefault(),a.stopPropagation(),Je(s),pi(s,a),Ce(Se(s),a,b)))}}},this.onPanning=function(a){var m=s.setup.disabled,b=s.props.onPanning;if(!m){var C=di(s);if(C){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(a.preventDefault(),a.stopPropagation(),mi(s,a.clientX,a.clientY),Ce(Se(s),a,b))}}},this.onPanningStop=function(a){var m=s.props.onPanningStop;s.isPanning&&(Eu(s),Ce(Se(s),a,m))},this.onPinchStart=function(a){var m=s.setup.disabled,b=s.props,C=b.onPinchingStart,r=b.onZoomStart;if(!m){var i=zu(s,a);i&&(Gu(s,a),Je(s),Ce(Se(s),a,C),Ce(Se(s),a,r))}},this.onPinch=function(a){var m=s.setup.disabled,b=s.props,C=b.onPinching,r=b.onZoom;if(!m){var i=Wu(s);i&&(a.preventDefault(),a.stopPropagation(),Qu(s,a),Ce(Se(s),a,C),Ce(Se(s),a,r))}},this.onPinchStop=function(a){var m=s.props,b=m.onPinchingStop,C=m.onZoomStop;s.pinchStartScale&&(Zu(s),Ce(Se(s),a,b),Ce(Se(s),a,C))},this.onTouchPanningStart=function(a){var m=s.setup.disabled,b=s.props.onPanningStart;if(!m){var C=ui(s,a);if(C){var r=s.lastTouch&&+new Date-s.lastTouch<200&&a.touches.length===1;if(!r){s.lastTouch=+new Date,Je(s);var i=a.touches,l=i.length===1,d=i.length===2;l&&(Je(s),pi(s,a),Ce(Se(s),a,b)),d&&s.onPinchStart(a)}}}},this.onTouchPanning=function(a){var m=s.setup.disabled,b=s.props.onPanning;if(s.isPanning&&a.touches.length===1){if(m)return;var C=di(s);if(!C)return;a.preventDefault(),a.stopPropagation();var r=a.touches[0];mi(s,r.clientX,r.clientY),Ce(Se(s),a,b)}else a.touches.length>1&&s.onPinch(a)},this.onTouchPanningStop=function(a){s.onPanningStop(a),s.onPinchStop(a)},this.onDoubleClick=function(a){var m=s.setup.disabled;if(!m){var b=sd(s,a);b&&td(s,a)}},this.clearPanning=function(a){s.isPanning&&s.onPanningStop(a)},this.setKeyPressed=function(a){s.pressedKeys[a.key]=!0},this.setKeyUnPressed=function(a){s.pressedKeys[a.key]=!1},this.isPressingKeys=function(a){return a.length?!!a.find(function(m){return s.pressedKeys[m]}):!0},this.setTransformState=function(a,m,b){var C=s.props.onTransformed;if(!Number.isNaN(a)&&!Number.isNaN(m)&&!Number.isNaN(b)){a!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=a),s.transformState.positionX=m,s.transformState.positionY=b,s.applyTransformation();var r=Se(s);s.onChangeCallbacks.forEach(function(i){return i(r)}),Ce(r,{scale:a,positionX:m,positionY:b},C)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var a=Hn(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(a.scale,a.positionX,a.positionY)}},this.handleTransformStyles=function(a,m,b){return s.props.customTransform?s.props.customTransform(a,m,b):Nu(a,m,b)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var a=s.transformState,m=a.scale,b=a.positionX,C=a.positionY,r=s.handleTransformStyles(b,C,m);s.contentComponent.style.transform=r}},this.getContext=function(){return Se(s)},this.onChange=function(a){return s.onChangeCallbacks.has(a)||s.onChangeCallbacks.add(a),function(){s.onChangeCallbacks.delete(a)}},this.onInit=function(a){return s.onInitCallbacks.has(a)||s.onInitCallbacks.add(a),function(){s.onInitCallbacks.delete(a)}},this.init=function(a,m){s.cleanupWindowEvents(),s.wrapperComponent=a,s.contentComponent=m,mt(s,s.transformState.scale),s.handleInitializeWrapperEvents(a),s.handleInitialize(a,m),s.initializeWindowEvents(),s.isInitialized=!0;var b=Se(s);Ce(b,void 0,s.props.onInit)},this.props=t,this.setup=gi(this.props),this.transformState=On(this.props)}return e})(),Ts=Z.createContext(null),id=function(e,t){return typeof e=="function"?e(t):e},nd=Z.forwardRef(function(e,t){var s=R.useRef(new rd(e)).current,a=id(e.children,vs(s));return R.useImperativeHandle(t,function(){return vs(s)},[s]),R.useEffect(function(){s.update(e)},[s,e]),Z.createElement(Ts.Provider,{value:s},a)});Z.forwardRef(function(e,t){var s=R.useRef(null),a=R.useContext(Ts);return R.useEffect(function(){return a.onChange(function(m){if(s.current){var b=0,C=0;s.current.style.transform=a.handleTransformStyles(b,C,1/m.instance.transformState.scale)}})},[a]),Z.createElement("div",ht({},e,{ref:Pu([s,t])}))});function od(e,t){t===void 0&&(t={});var s=t.insertAt;if(!(typeof document>"u")){var a=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",s==="top"&&a.firstChild?a.insertBefore(m,a.firstChild):a.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var ad=`.transform-component-module_wrapper__SPB86 {
32
- position: relative;
33
- width: -moz-fit-content;
34
- width: fit-content;
35
- height: -moz-fit-content;
36
- height: fit-content;
37
- overflow: hidden;
38
- -webkit-touch-callout: none; /* iOS Safari */
39
- -webkit-user-select: none; /* Safari */
40
- -khtml-user-select: none; /* Konqueror HTML */
41
- -moz-user-select: none; /* Firefox */
42
- -ms-user-select: none; /* Internet Explorer/Edge */
43
- user-select: none;
44
- margin: 0;
45
- padding: 0;
46
- transform: translate3d(0, 0, 0);
47
- }
48
- .transform-component-module_content__FBWxo {
49
- display: flex;
50
- flex-wrap: wrap;
51
- width: -moz-fit-content;
52
- width: fit-content;
53
- height: -moz-fit-content;
54
- height: fit-content;
55
- margin: 0;
56
- padding: 0;
57
- transform-origin: 0% 0%;
58
- }
59
- .transform-component-module_content__FBWxo img {
60
- pointer-events: none;
61
- }
62
- `,_i={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};od(ad);var ld=function(e){var t=e.children,s=e.wrapperClass,a=s===void 0?"":s,m=e.contentClass,b=m===void 0?"":m,C=e.wrapperStyle,r=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,d=e.contentProps,o=d===void 0?{}:d,p=R.useContext(Ts),_=p.init,y=p.cleanupWindowEvents,g=R.useRef(null),n=R.useRef(null);return R.useEffect(function(){var f=g.current,h=n.current;return f!==null&&h!==null&&_&&_?.(f,h),function(){y?.()}},[]),Z.createElement("div",ht({},l,{ref:g,className:"".concat(ir.wrapperClass," ").concat(_i.wrapper," ").concat(a),style:C}),Z.createElement("div",ht({},o,{ref:n,className:"".concat(ir.contentClass," ").concat(_i.content," ").concat(b),style:r}),t))},qn=function(){var e=R.useContext(Ts);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},cd=function(){var e=qn();return vs(e)};function hd(e){var t=qn(),s=R.useState(e(nr(t))),a=s[0],m=s[1];return R.useEffect(function(){var b=!0,C=t.onChange(function(r){b&&m(e(nr(r.instance)))});return function(){C(),b=!1}},[e,t]),a}function ud(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 dd(e,t){return nt({queryKey:le.files.tree(e||"",t),queryFn:()=>he.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function fd(e,t){return nt({queryKey:le.files.content(e||"",t||""),queryFn:()=>he.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function pd(e){const t=Te();return R.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function md(){const e=Te();return Ue({mutationFn:t=>he.post("/files/write",t),onSuccess:(t,s)=>{const a=le.files.content(s.workingDir,s.path),m=e.getQueryData(a);e.setQueryData(a,{content:s.content,language:m?.language||ud(s.path)})}})}function vd(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function gd(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const _d=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function bd(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&_d.has(t)?gr:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?Ht:t==="json"?ea:t==="md"||t==="mdx"||t==="txt"?Qi:Io}const bi=({depth:e,active:t,onClick:s,leftIcon:a,rightIcon:m,label:b})=>c.jsxs("button",{type:"button",onClick:s,className:me("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:[c.jsx("span",{className:"shrink-0",children:m}),c.jsx("span",{className:"shrink-0 text-neutral-500",children:a}),c.jsx("span",{className:"truncate text-neutral-700",children:b})]}),Kn=({workingDir:e,path:t,depth:s,expanded:a,toggleDir:m,onFileSelect:b,selectedFilePath:C})=>{const{data:r,isLoading:i,isError:l}=dd(e,t),d=R.useMemo(()=>r?.items??[],[r?.items]);return i?c.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+s*14},children:"Loading..."}):l?c.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+s*14},children:"Failed to load"}):c.jsx("div",{className:"space-y-0.5",children:d.map(o=>{if(o.type==="directory"){const n=vd(t,o.name),f=a.has(n);return c.jsxs("div",{children:[c.jsx(bi,{depth:s,onClick:()=>m(n),rightIcon:f?c.jsx(dt,{size:14,className:"text-neutral-400"}):c.jsx(gt,{size:14,className:"text-neutral-400"}),leftIcon:f?c.jsx(Zi,{size:14,className:"text-amber-500"}):c.jsx(Bo,{size:14,className:"text-amber-500"}),label:o.name}),f&&c.jsx(Kn,{workingDir:e,path:n,depth:s+1,expanded:a,toggleDir:m,onFileSelect:b,selectedFilePath:C})]},n)}const p=gd(t,o.name),_=bd(o),y=C===p,g=_===gr;return c.jsx(bi,{depth:s,active:y,onClick:()=>b(p),rightIcon:c.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?c.jsx(_,{size:14,className:g?"text-emerald-600":"text-sky-600"}):null,label:o.name},p)})})},xd=({workingDir:e,className:t,onFileSelect:s,selectedFilePath:a,onCollapse:m})=>{const[b,C]=R.useState(()=>new Set),r=pd(e),i=R.useCallback(l=>{C(d=>{const o=new Set(d);return o.has(l)?o.delete(l):o.add(l),o})},[]);return c.jsxs("div",{className:me("h-full flex flex-col",t),children:[c.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:"Files"}),c.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||"No workingDir"})]}),c.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&c.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:"Refresh file tree",children:c.jsx(Ta,{size:13})}),m&&c.jsx("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:"Collapse file tree",children:c.jsx(ya,{size:13})})]})]}),c.jsx("div",{className:"flex-1 overflow-auto p-2",children:e?c.jsx(Kn,{workingDir:e,path:"/",depth:0,expanded:b,toggleDir:i,onFileSelect:s,selectedFilePath:a}):c.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:"No workspace selected."})})]})},Sd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function yd(e){const t=e.split(".").pop()?.toLowerCase();return t?Sd.has(t):!1}function Cd(e,t){const s="/api",a=new URLSearchParams({workingDir:e,path:t});if(cr()){const m=hr();m&&a.set("token",m)}return`${s}/files/image?${a.toString()}`}const wd=({filePath:e})=>{const{zoomIn:t,zoomOut:s,centerView:a}=cd(),m=hd(C=>C.state.scale),b=Math.round(m*100);return c.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:[c.jsx("button",{type:"button",onClick:()=>s(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:"Zoom out",children:c.jsx(za,{size:14})}),c.jsxs("button",{type:"button",onClick:()=>a(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:"Reset zoom",children:[b,"%"]}),c.jsx("button",{type:"button",onClick:()=>t(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:"Zoom in",children:c.jsx(Fa,{size:14})}),c.jsx("button",{type:"button",onClick:()=>a(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:"Fit to view",children:c.jsx(_a,{size:13})}),c.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Ed=({workingDir:e,filePath:t})=>{const[s,a]=R.useState(!1),m=Cd(e,t);return s?c.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"Failed to load image."}):c.jsx(nd,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsx(wd,{filePath:t}),c.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:c.jsx(ld,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:c.jsx("img",{src:m,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>a(!0)})})})]})})};function kd(e){const t=e.split("/");return t[t.length-1]||e}function Rd(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 Dd=({active:e,name:t,isDirty:s,onClick:a,onClose:m})=>c.jsxs("button",{type:"button",onClick:a,className:me("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:[c.jsx("span",{className:me("w-2 h-2 rounded-full",s?"bg-amber-500":"bg-transparent")}),c.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),c.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":"Close tab",title:"Close",children:c.jsx(bs,{size:12})})]}),Ld=({workingDir:e,className:t})=>{const[s,a]=R.useState([]),[m,b]=R.useState(null),C=md(),[r,i]=R.useState(280),[l,d]=R.useState(!1),[o,p]=R.useState(!1),_=R.useRef(280),y=R.useCallback(()=>{d(j=>(j?i(_.current):_.current=r,!j))},[r]),g=R.useCallback(j=>{j.preventDefault(),p(!0);const T=j.clientX,N=r,I=H=>{const z=H.clientX-T,D=Math.min(480,Math.max(160,N+z));i(D)},F=()=>{p(!1),document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",F)},[r]);R.useEffect(()=>{a([]),b(null)},[e]);const n=R.useMemo(()=>s.find(j=>j.path===m)||null,[s,m]),{data:f,isFetching:h,isError:u,error:v}=fd(e,n?.isImage?null:m);R.useEffect(()=>{!m||!f||a(j=>j.map(T=>T.path!==m||T.isDirty||T.loaded?T:{...T,language:f.language||T.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[m,f]);const S=R.useCallback(j=>{a(T=>{if(T.find(F=>F.path===j))return T;const I=yd(j);return[...T,{path:j,name:kd(j),language:Rd(j),content:"",savedContent:"",isDirty:!1,loaded:I,isImage:I}]}),b(j)},[]),w=R.useCallback(j=>{a(T=>{const N=T.filter(I=>I.path!==j);return b(I=>I!==j?I:N.length?N[N.length-1].path:null),N})},[]),k=R.useCallback(j=>{a(T=>T.map(N=>{if(N.path!==m)return N;const I=j!==N.savedContent;return{...N,content:j,isDirty:I}}))},[m]),x=R.useCallback(async()=>{!e||!n||(await C.mutateAsync({workingDir:e,path:n.path,content:n.content}),a(j=>j.map(T=>T.path===n.path?{...T,savedContent:T.content,isDirty:!1,loaded:!0}:T)))},[e,n,C]),E=R.useRef(()=>{});R.useEffect(()=>{E.current=()=>{x().catch(()=>{})}},[x]),R.useEffect(()=>{const j=T=>{(T.metaKey||T.ctrlKey)&&T.key.toLowerCase()==="s"&&(T.preventDefault(),E.current())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const A=R.useCallback((j,T)=>{j.addCommand(T.KeyMod.CtrlCmd|T.KeyCode.KeyS,()=>{E.current()})},[]);return c.jsxs("div",{className:me("flex h-full overflow-hidden bg-white",t),style:o?{userSelect:"none",cursor:"col-resize"}:void 0,children:[c.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:r,transition:o?"none":"width 0.15s ease"},children:l?c.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:c.jsx("button",{type:"button",onClick:y,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:"Expand file tree",children:c.jsx(wa,{size:16})})}):c.jsx(c.Fragment,{children:c.jsx(xd,{workingDir:e,onFileSelect:S,selectedFilePath:n?.path||null,onCollapse:y},e||"no-working-dir")})}),!l&&c.jsx("div",{onMouseDown:g,className:me("w-1 shrink-0 cursor-col-resize transition-colors",o?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),c.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[c.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:[s.length===0?c.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:"No open files"}):s.map(j=>c.jsx(Dd,{active:j.path===m,name:j.name,isDirty:j.isDirty,onClick:()=>b(j.path),onClose:T=>{T.stopPropagation(),w(j.path)}},j.path)),c.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[C.isPending&&c.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[c.jsx(Ae,{size:14,className:"animate-spin"}),"Saving"]}),n?.isDirty&&!C.isPending&&c.jsx("span",{className:"text-[11px] text-amber-600",children:"Unsaved"})]})]}),c.jsx("div",{className:"flex-1 min-h-0 relative",children:e?n?n.isImage?c.jsx(Ed,{workingDir:e,filePath:n.path}):c.jsxs(c.Fragment,{children:[c.jsx(Gh,{path:n.path,value:n.content,language:n.language,theme:"vs-light",height:"100%",onChange:j=>k(j??""),onMount:A,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0}}),h&&!n.loaded&&c.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:c.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[c.jsx(Ae,{size:14,className:"animate-spin"}),"Loading file..."]})}),u&&c.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:["Failed to load file",v instanceof Error?`: ${v.message}`:"","."]})]}):c.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"Select a file from the tree to open."}):c.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:"No workspace selected."})})]})]})};function Xn(e){return nt({queryKey:le.git.changes(e||""),queryFn:()=>he.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function Yn(e,t,s){return nt({queryKey:le.git.diff(e||"",t||"",s),queryFn:()=>he.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:s}}),enabled:!!e&&!!t})}function Vn(e,t){return nt({queryKey:le.git.commitFiles(e||"",t||""),queryFn:()=>he.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function Gn(e,t,s){return nt({queryKey:le.git.commitDiff(e||"",t||"",s||""),queryFn:()=>he.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:s||""}}),enabled:!!e&&!!t&&!!s})}const xi={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"},Ad={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function Td(e){const t=e.split("/");return t[t.length-1]||e}function jd(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Md=({entry:e,selected:t,onClick:s})=>{const a=xi[e.status]||xi.M,m=Ad[e.status]||e.status,b=jd(e.path);return c.jsxs("button",{type:"button",onClick:s,className:me("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:[c.jsx("span",{className:me("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",a),title:m,children:e.status}),c.jsx("span",{className:"text-xs text-neutral-900 truncate",children:Td(e.path)}),b&&c.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:b})]})},Si=({title:e,entries:t,type:s,selectedKey:a,onSelect:m})=>t.length===0?null:c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:e}),c.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),c.jsx("div",{className:"space-y-0.5",children:t.map(b=>{const C=`${s}:${b.path}`;return c.jsx(Md,{entry:b,selected:a===C,onClick:()=>m(b.path,s)},C)})})]}),Nd=({line:e,lineNum:t})=>{let s="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",a="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),c.jsxs("div",{className:me("flex",s),children:[c.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),c.jsx("span",{className:me("pl-2 whitespace-pre",a),children:e})]})},Pd=({workingDir:e,filePath:t,type:s})=>{const{data:a,isLoading:m,isError:b}=Yn(e,t,s);if(m)return c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:"Failed to load diff."});const C=a?.diff||"";if(!C.trim())return c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:"No diff content available."});const r=C.split(`
63
- `);return c.jsx("div",{className:"flex-1 overflow-auto font-mono text-xs leading-5",children:r.map((i,l)=>c.jsx(Nd,{line:i,lineNum:l+1},l))})},Od=({workingDir:e})=>{const{data:t,isLoading:s,isError:a}=Xn(e),[m,b]=R.useState(null),[C,r]=R.useState(260),[i,l]=R.useState(!1),d=R.useCallback(n=>{n.preventDefault(),l(!0);const f=n.clientX,h=C,u=S=>{const w=S.clientX-f,k=Math.min(480,Math.max(160,h+w));r(k)},v=()=>{l(!1),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",v)},[C]),o=m?`${m.type}:${m.path}`:null,p=(n,f)=>{b({path:n,type:f})};if(!e)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:"No workspace selected."});if(s)return c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-sm",children:"Loading changes..."})]});if(a)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:"Failed to load changes."});const _=t?.uncommitted||[],y=t?.committed||[],g=_.length+y.length;return c.jsxs("div",{className:"flex h-full bg-white",style:i?{userSelect:"none",cursor:"col-resize"}:void 0,children:[c.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:C},children:[c.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(zt,{size:14,className:"text-neutral-500"}),c.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:"Changes"}),g>0&&c.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:g})]})}),c.jsx("div",{className:"flex-1 overflow-auto p-1.5",children:g===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[c.jsx(zt,{size:28,className:"mb-2"}),c.jsx("span",{className:"text-xs",children:"No pending changes"})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx(Si,{title:"Uncommitted",entries:_,type:"uncommitted",selectedKey:o,onSelect:p}),c.jsx(Si,{title:"Committed",entries:y,type:"committed",selectedKey:o,onSelect:p})]})})]}),c.jsx("div",{onMouseDown:d,className:me("w-1 shrink-0 cursor-col-resize transition-colors",i?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),c.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[c.jsx(Ht,{size:14,className:"text-neutral-500"}),c.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:m.path}),c.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",m.type,")"]})]}),c.jsx(Pd,{workingDir:e,filePath:m.path,type:m.type})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx(Ht,{size:28}),c.jsx("span",{className:"text-xs",children:"Select a file to view diff"})]})})})]})},Ys=50,yi={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 Bd(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:s<86400?`${Math.floor(s/3600)}h ago`:s<604800?`${Math.floor(s/86400)}d ago`:new Date(e*1e3).toLocaleDateString()}function Id(e){const t=e.split("/");return t[t.length-1]||e}function Fd(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const Hd=`
64
- .history-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
65
- .history-scroll::-webkit-scrollbar-track { background: transparent; }
66
- .history-scroll::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 2px; }
67
- .history-scroll::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }
68
- `,zd=({line:e,lineNum:t})=>{let s="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(s="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(s="bg-red-50",a="text-red-800"):e.startsWith("@@")?(s="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),c.jsxs("div",{className:me("flex",s),children:[c.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),c.jsx("span",{className:me("pl-2 whitespace-pre",a),children:e})]})},Wd=({workingDir:e,hash:t,filePath:s})=>{const{data:a,isLoading:m,isError:b}=Gn(e,t,s);if(m)return c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:"Failed to load diff."});const C=a?.diff||"";if(!C.trim())return c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:"No diff content available."});const r=C.split(`
69
- `);return c.jsx("div",{className:"flex-1 overflow-auto history-scroll font-mono text-xs leading-5",children:r.map((i,l)=>c.jsx(zd,{line:i,lineNum:l+1},l))})},$d=({workingDir:e,hash:t,selectedPath:s,onSelectFile:a})=>{const{data:m,isLoading:b}=Vn(e,t);if(b)return c.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[c.jsx(Ae,{size:12,className:"animate-spin"}),c.jsx("span",{children:"Loading..."})]});const C=m?.files||[];return C.length===0?c.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:"No files changed"}):c.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:C.map(r=>{const i=yi[r.status]||yi.M,l=Fd(r.path);return c.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),a(r.path)},className:me("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",s===r.path?"bg-blue-50":"hover:bg-neutral-50"),children:[c.jsx("span",{className:me("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",i),children:r.status}),c.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:Id(r.path)}),l&&c.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:l})]},r.path)})})},Ud=({workingDir:e})=>{const{data:t,isLoading:s,isError:a,fetchNextPage:m,hasNextPage:b,isFetchingNextPage:C}=Ki({queryKey:le.git.log(e||""),queryFn:({pageParam:v=0})=>he.get("/git/log",{params:{workingDir:e||"",limit:String(Ys),skip:String(v)}}),initialPageParam:0,getNextPageParam:(v,S)=>v.commits.length<Ys?void 0:S.length*Ys,enabled:!!e}),r=t?.pages.flatMap(v=>v.commits)||[],[i,l]=R.useState(null),[d,o]=R.useState(null),[p,_]=R.useState(280),[y,g]=R.useState(!1),n=R.useCallback(v=>{v.preventDefault(),g(!0);const S=v.clientX,w=p,k=E=>{const A=Math.min(480,Math.max(180,w+(E.clientX-S)));_(A)},x=()=>{g(!1),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",x)},[p]),f=v=>{i===v?(l(null),o(null)):(l(v),o(null))},h=R.useRef(null);if(!e)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:"No workspace selected."});if(s)return c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-sm",children:"Loading history..."})]});if(a)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:"Failed to load history."});if(r.length===0)return c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[c.jsx(Ct,{size:28,className:"mb-2"}),c.jsx("span",{className:"text-xs",children:"No commit history"})]});const u=r.find(v=>v.hash===i);return c.jsxs("div",{className:"flex h-full bg-white",style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[c.jsx("style",{children:Hd}),c.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:p},children:[c.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ct,{size:14,className:"text-neutral-500"}),c.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:"History"}),c.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:r.length})]})}),c.jsxs("div",{ref:h,className:"flex-1 overflow-auto history-scroll p-1.5",children:[r.map(v=>{const S=i===v.hash;return c.jsxs("div",{children:[c.jsxs("button",{type:"button",onClick:()=>f(v.hash),className:me("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",S?"bg-blue-50":"hover:bg-neutral-50"),children:[c.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:c.jsx("div",{className:me("w-2 h-2 rounded-full shrink-0 transition-colors",S?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:v.shortHash}),c.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:v.message}),c.jsx(gt,{size:12,className:me("shrink-0 text-neutral-400 transition-transform",S&&"rotate-90")})]}),c.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[c.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:v.author}),c.jsx("span",{className:"text-[10px] text-neutral-400",children:Bd(v.timestamp)})]})]})]}),S&&c.jsxs(c.Fragment,{children:[v.body&&c.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:v.body}),c.jsx($d,{workingDir:e,hash:v.hash,selectedPath:d,onSelectFile:o})]})]},v.hash)}),b&&c.jsx("button",{type:"button",onClick:()=>m(),disabled:C,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:C?c.jsxs(c.Fragment,{children:[c.jsx(Ae,{size:12,className:"animate-spin"})," Loading..."]}):"Load more"})]})]}),c.jsx("div",{onMouseDown:n,className:me("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),c.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:d&&i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[c.jsx(Ht,{size:14,className:"text-neutral-500"}),c.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:d}),c.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",u?.shortHash,")"]})]}),c.jsx(Wd,{workingDir:e,hash:i,filePath:d})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx(Ht,{size:28}),c.jsx("span",{className:"text-xs",children:i?"Select a file to view diff":"Select a commit to view changes"})]})})})]})},qd=[{key:"changes",label:"Changes",icon:c.jsx(zt,{size:14})},{key:"history",label:"History",icon:c.jsx(Ct,{size:14})},{key:"editor",label:"Editor",icon:c.jsx(Ss,{size:14})},{key:"terminal",label:"Terminal",icon:c.jsx(ls,{size:14})},{key:"preview",label:"Preview",icon:c.jsx(_s,{size:14})}],Kd=[{key:"history",label:"History",icon:c.jsx(Ct,{size:14})},{key:"editor",label:"Editor",icon:c.jsx(Ss,{size:14})},{key:"terminal",label:"Terminal",icon:c.jsx(ls,{size:14})},{key:"preview",label:"Preview",icon:c.jsx(_s,{size:14})}],Xd=({active:e,onClick:t,icon:s,label:a})=>c.jsxs("button",{onClick:t,className:me("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:[s,c.jsx("span",{children:a})]}),Yd=({icon:e,title:t})=>c.jsx("div",{className:"flex-1 flex items-center justify-center bg-white",children:c.jsxs("div",{className:"flex flex-col items-center gap-2 text-neutral-400",children:[e,c.jsx("span",{className:"text-sm font-medium text-neutral-500",children:t}),c.jsx("span",{className:"text-xs",children:"Coming soon..."})]})}),Qn=Z.memo(function({className:t,sessionId:s,workingDir:a,projectId:m,hideChanges:b}){const C=b?Kd:qd,[r,i]=R.useState(b?"history":"changes"),{data:l}=Fo(m??""),d=R.useMemo(()=>{if(!l?.quickCommands)return[];try{return JSON.parse(l.quickCommands)}catch{return[]}},[l?.quickCommands]),[o,p]=R.useState([]),_=R.useRef(void 0);return R.useEffect(()=>{a&&a!==_.current&&(_.current=a,p(y=>y.includes(a)?y:[...y,a]))},[a]),c.jsxs("div",{className:me("flex flex-col h-full bg-white",t),children:[c.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:C.map(y=>c.jsx(Xd,{active:r===y.key,onClick:()=>i(y.key),icon:y.icon,label:y.label},y.key))}),c.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[r==="editor"&&c.jsx(Ld,{workingDir:a}),o.map(y=>c.jsx("div",{className:"h-full absolute inset-0",style:{display:r==="terminal"&&a===y?"block":"none"},children:c.jsx(zc,{cwd:y,quickCommands:d})},y)),r==="preview"&&c.jsx(Yd,{icon:c.jsx(_s,{size:32}),title:"Preview"}),r==="changes"&&c.jsx(Od,{workingDir:a}),r==="history"&&c.jsx(Ud,{workingDir:a})]})]})});function Zn(e){return nt({queryKey:le.workspaces.list(e),queryFn:()=>he.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Vd(e){const t=Te();return Ue({mutationFn:s=>he.post(`/tasks/${e}/workspaces`,s),onSuccess:()=>{t.invalidateQueries({queryKey:le.workspaces.list(e)}),t.invalidateQueries({queryKey:le.tasks.all})}})}function Gd(){const e=Te();return Ue({mutationFn:({id:t,commitMessage:s})=>he.post(`/workspaces/${t}/merge`,{commitMessage:s}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Ar(){return Ue({mutationFn:({workspaceId:e,editorType:t})=>he.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function Jn(e){return nt({queryKey:le.workspaces.gitStatus(e),queryFn:()=>he.get(`/workspaces/${e}/git-status`),enabled:!!e})}function Qd(){const e=Te();return Ue({mutationFn:t=>he.post(`/workspaces/${t}/rebase`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})},onError:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})}})}function Zd(){const e=Te();return Ue({mutationFn:t=>he.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(s)})}})}const Ci=1500,Jd=3e3;function ef(e){const[t,s]=R.useState(null),a=R.useRef(0),m=R.useRef(null),b=R.useRef(null);return R.useEffect(()=>{if(!e)return;const C=()=>{b.current&&(clearTimeout(b.current),b.current=null)},r=ot.connect();r.emit(rt.SUBSCRIBE,{topic:"task",id:e},d=>{});const i=d=>{s(d),b.current=setTimeout(()=>s(null),Jd)},l=d=>{if(d.taskId!==e)return;const o={status:d.status,currentCommand:d.currentCommand,currentIndex:d.currentIndex,totalCommands:d.totalCommands,error:d.error};if(d.status==="running"){C(),m.current=null,a.current===0&&(a.current=Date.now()),s(o);return}const p=a.current>0?Date.now()-a.current:0,_=Ci-p;a.current===0?(a.current=Date.now(),s({status:"running",totalCommands:d.totalCommands,currentIndex:d.totalCommands}),m.current=o,b.current=setTimeout(()=>i(o),Ci)):_>0?(m.current=o,C(),b.current=setTimeout(()=>i(o),_)):i(o)};return r.on(Oe.WORKSPACE_SETUP_PROGRESS,l),()=>{r.off(Oe.WORKSPACE_SETUP_PROGRESS,l),C(),a.current=0,m.current=null}},[e]),t}function eo(){const e=Te();return Ue({mutationFn:t=>he.post(`/sessions/${t}/start`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.sessions.detail(s)})}})}function to(){const e=Te();return Ue({mutationFn:t=>he.post(`/sessions/${t}/stop`),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:le.sessions.detail(s)})}})}function Tr(){const e=Te();return Ue({mutationFn:({id:t,message:s})=>he.post(`/sessions/${t}/message`,{message:s}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all})}})}function so(e,t){return R.useMemo(()=>{for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.tokenUsage&&typeof a.tokenUsage.totalTokens=="number"&&a.tokenUsage.totalTokens>0)return{totalTokens:a.tokenUsage.totalTokens,modelContextWindow:a.tokenUsage.modelContextWindow}}return t??null},[e,t])}const tf="/api";async function sf(e){const t=new FormData;t.append("file",e);const s={};if(cr()){const m=hr();m&&(s.Authorization=`Bearer ${m}`)}const a=await fetch(`${tf}/attachments/upload`,{method:"POST",body:t,headers:s});if(!a.ok){const m=await a.json().catch(()=>({}));throw new Error(m.error||`Upload failed (${a.status})`)}return a.json()}let rf=0;function ro(){const[e,t]=R.useState([]),s=R.useRef(e);s.current=e;const a=R.useCallback(async l=>{const d=l.map(o=>({tempId:`tmp-${++rf}`,file:o,progress:0,status:"uploading"}));t(o=>[...o,...d]),await Promise.allSettled(d.map(async o=>{try{const p=await sf(o.file);t(_=>_.map(y=>y.tempId===o.tempId?{...y,status:"done",progress:100,attachment:p}:y))}catch(p){t(_=>_.map(y=>y.tempId===o.tempId?{...y,status:"error",error:p instanceof Error?p.message:"Upload failed"}:y))}}))},[]),m=R.useCallback(l=>{t(d=>d.filter(o=>o.tempId!==l))},[]),b=R.useCallback(()=>{t([])},[]),C=R.useCallback(()=>{const l=s.current.filter(d=>d.status==="done"&&d.attachment);return l.length===0?"":l.map(d=>{const o=d.attachment;return`${o.mimeType.startsWith("image/")?"!":""}[${o.originalName}](${o.storagePath})`}).join(`
70
- `)},[]),r=e.length>0,i=e.some(l=>l.status==="uploading");return{files:e,addFiles:a,removeFile:m,clear:b,buildMarkdownLinks:C,hasFiles:r,isUploading:i}}const nf="/api";function of(e){if(!cr())return e;const t=hr();if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}token=${encodeURIComponent(t)}`}function af(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function io({files:e,onRemove:t}){return e.length===0?null:c.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(s=>c.jsx(lf,{item:s,onRemove:t},s.tempId))})}function lf({item:e,onRemove:t}){const s=e.file.type.startsWith("image/"),a=e.status==="error",m=e.status==="uploading";return c.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${a?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[s&&e.status==="done"&&e.attachment?c.jsx("img",{src:of(`${nf}${e.attachment.url}`),alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):c.jsx("span",{className:"flex-shrink-0",children:m?c.jsx(Ae,{size:16,className:"animate-spin text-neutral-400"}):s?c.jsx(gr,{size:16,className:"text-neutral-400"}):c.jsx(Qi,{size:16,className:"text-neutral-400"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate font-medium",children:e.file.name}),a?c.jsx("div",{className:"truncate text-red-500",children:e.error}):c.jsx("div",{className:"text-neutral-400",children:af(e.file.size)})]}),c.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:c.jsx(bs,{size:10})})]})}function no({isOpen:e,onClose:t,taskId:s,taskTitle:a,taskDescription:m}){const[b,C]=R.useState([]),[r,i]=R.useState(""),[l,d]=R.useState(""),[o,p]=R.useState("idle"),[_,y]=R.useState(null),g=Te(),n=Vd(s),f=eo();R.useEffect(()=>{e&&he.get("/demo/agents").then(S=>{C(S.agents);const w=S.agents.find(k=>k.available);w&&i(w.type)})},[e]),R.useEffect(()=>{if(e){const S=[a];m&&S.push(m),d(S.join(`
71
-
72
- `)),p("idle"),y(null)}},[e,a,m]);const h=o!=="idle",u=async()=>{if(!(!r||!l.trim())){y(null);try{p("creating-workspace");const S=await n.mutateAsync({});p("creating-session");const w=await he.post(`/workspaces/${S.id}/sessions`,{agentType:r,prompt:l.trim()});p("starting-session"),await f.mutateAsync(w.id),await g.invalidateQueries({queryKey:le.workspaces.list(s)}),p("idle"),t()}catch(S){p("idle"),y(S instanceof Error?S.message:"启动失败,请重试")}}},v={idle:"启动","creating-workspace":"创建工作空间...","creating-session":"创建会话...","starting-session":"启动 Agent..."};return c.jsx(xs,{isOpen:e,onClose:h?()=>{}:t,title:"启动 Agent",action:c.jsxs(c.Fragment,{children:[c.jsx(it,{variant:"outline",onClick:t,disabled:h,children:"取消"}),c.jsx(it,{onClick:u,disabled:h||!r||!l.trim(),children:v[o]})]}),children:c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:"选择 Agent"}),c.jsxs("div",{className:"flex gap-2 flex-wrap",children:[b.length===0&&c.jsx("span",{className:"text-sm text-neutral-400",children:"加载中..."}),b.map(S=>c.jsxs(it,{variant:r===S.type?"default":"outline",size:"sm",disabled:!S.available||h,onClick:()=>i(S.type),children:[S.name,S.available&&S.version&&` (${S.version})`,!S.available&&" (不可用)"]},S.type))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:"任务描述"}),c.jsx("textarea",{value:l,onChange:S=>d(S.target.value),rows:5,disabled:h,placeholder:"描述你想让 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"})]}),_&&c.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:_})]})})}const oo=({isOpen:e,onClose:t,onConfirm:s,title:a,description:m,confirmText:b="确认",cancelText:C="取消",variant:r="default",isLoading:i=!1})=>{const l=r==="danger";return c.jsx(xs,{isOpen:e,onClose:t,title:a,className:"max-w-sm",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:t,disabled:i,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:C}),c.jsx("button",{onClick:s,disabled:i,className:me("px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50",l?"bg-red-500 text-white hover:bg-red-600":"bg-neutral-900 text-white hover:bg-black"),children:i?"处理中...":b})]}),children:c.jsxs("div",{className:"flex gap-4",children:[l&&c.jsx("div",{className:"shrink-0 w-10 h-10 rounded-full bg-red-50 flex items-center justify-center",children:c.jsx(_r,{size:20,className:"text-red-500"})}),c.jsx("div",{className:"text-sm text-neutral-600 leading-relaxed pt-1",children:m})]})})};function cf({workspaceId:e,gitStatus:t,onResolve:s}){const a=Zd();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const m=t.operation==="rebase"?"Rebase":"Merge";return c.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:[c.jsx(_r,{size:18,className:"text-amber-600 shrink-0"}),c.jsx("div",{className:"flex-1 min-w-0",children:c.jsxs("p",{className:"text-sm font-medium text-amber-900",children:[m," 冲突 — ",t.conflictedFiles.length," 个文件"]})}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsx(it,{variant:"outline",size:"sm",onClick:()=>a.mutate(e),disabled:a.isPending,children:"中止操作"}),c.jsx(it,{size:"sm",onClick:s,children:"解决冲突"})]})]})}function hf(e,t,s,a){const m=s.map(b=>`- ${b}`).join(`
73
- `);return a===sr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
74
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"].join(`
75
- `)}function uf({open:e,onOpenChange:t,workspaceId:s,conflictOp:a,conflictedFiles:m,sourceBranch:b,targetBranch:C,sessions:r}){const[i,l]=R.useState(""),d=Tr(),o=Ar(),p=()=>{if(!i)return;const g=hf(b,C,m,a);d.mutate({id:i,message:g},{onSuccess:()=>t(!1)})},_=()=>{o.mutate({workspaceId:s},{onSuccess:()=>t(!1)})},y=a==="REBASE"?"Rebase":"Merge";return c.jsx(xs,{isOpen:e,onClose:()=>t(!1),title:`解决 ${y} 冲突`,action:c.jsxs("div",{className:"flex gap-2",children:[c.jsx(it,{variant:"outline",onClick:_,children:"在 IDE 中打开"}),c.jsx(it,{onClick:p,disabled:!i||d.isPending,children:d.isPending?"发送中...":"AI 辅助解决"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsxs("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:["冲突文件(",m.length,")"]}),c.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:m.map(g=>c.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:g},g))})]}),r.length>0&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:"选择 Session(AI 辅助解决)"}),c.jsxs("select",{value:i,onChange:g=>l(g.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:[c.jsx("option",{value:"",children:"选择一个 Session..."}),r.map(g=>c.jsxs("option",{value:g.id,children:[g.agentType," — ",g.status]},g.id))]})]}),r.length===0&&c.jsx("p",{className:"text-sm text-neutral-500",children:"没有可用的 Session,请在 IDE 中手动解决冲突。"})]})})}function pt({children:e,variant:t}){const s={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 c.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${s[t]}`,children:e})}function df({gitStatus:e,branchName:t,targetBranch:s}){return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),c.jsx(Yi,{size:14,className:"text-neutral-400"}),c.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:s})]}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&c.jsxs(pt,{variant:"danger",children:[c.jsx(ra,{size:12}),e.uncommittedCount," 个未提交变更"]}),e.conflictedFiles.length>0&&c.jsxs(pt,{variant:"warning",children:[c.jsx(_r,{size:12}),e.conflictedFiles.length," 个冲突文件"]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&c.jsxs(pt,{variant:"warning",children:[c.jsx(Ae,{size:12,className:"animate-spin"}),"变基进行中"]}),e.operation==="merge"&&e.conflictedFiles.length===0&&c.jsxs(pt,{variant:"warning",children:[c.jsx(Ae,{size:12,className:"animate-spin"}),"合并进行中"]}),e.ahead>0&&c.jsxs(pt,{variant:"success",children:[c.jsx(Ir,{size:12}),"领先 ",e.ahead," 个提交"]}),e.behind>0&&c.jsxs(pt,{variant:"warning",children:["落后 ",e.behind," 个提交"]}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&c.jsxs(pt,{variant:"neutral",children:[c.jsx(Ir,{size:12}),"已是最新"]})]}),e.hasUncommittedChanges&&c.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:"工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。"})]})}function ff({open:e,onOpenChange:t,workspaceId:s,branchName:a,targetBranch:m,commitMessage:b,onConflict:C}){const{data:r,isLoading:i}=Jn(s),l=Qd(),d=Gd(),[o,p]=R.useState(null),[_,y]=R.useState("select"),[g,n]=R.useState(""),f=r?r.conflictedFiles.length>0:!1,h=r?r.operation!=="idle":!1,u=r?.hasUncommittedChanges??!1;R.useEffect(()=>{e&&(y("select"),p(null),n(b??""))},[e,b]);const v=()=>{p(null),l.mutate(s,{onSuccess:()=>t(!1),onError:x=>{const E=x;E.status===409?(t(!1),C()):p(E.message??"变基失败")}})},S=()=>{p(null),y("confirm")},w=()=>{p(null);const x=g.trim()||void 0;d.mutate({id:s,commitMessage:x},{onSuccess:()=>t(!1),onError:E=>{const A=E;A.status===409?(t(!1),C()):p(A.message??"合并失败")}})},k=_==="confirm"?"确认合并":"Git 操作";return c.jsx(xs,{isOpen:e,onClose:()=>t(!1),title:k,children:i||!r?c.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[c.jsx(Ae,{size:18,className:"animate-spin"}),c.jsx("span",{className:"text-sm",children:"加载分支状态..."})]}):_==="confirm"?c.jsx(mf,{editableMessage:g,setEditableMessage:n,error:o,isPending:d.isPending,onConfirm:w,onBack:()=>y("select"),branchName:a,targetBranch:m}):c.jsx(pf,{gitStatus:r,branchName:a,targetBranch:m,error:o,isDirty:u,hasConflicts:f,isOperationInProgress:h,rebasePending:l.isPending,mergePending:d.isPending,onRebase:v,onMerge:S})})}function pf({gitStatus:e,branchName:t,targetBranch:s,error:a,isDirty:m,hasConflicts:b,isOperationInProgress:C,rebasePending:r,mergePending:i,onRebase:l,onMerge:d}){return c.jsxs("div",{className:"space-y-5",children:[c.jsx(df,{gitStatus:e,branchName:t,targetBranch:s}),a&&c.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("button",{onClick:l,disabled:r||b||C||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:[c.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:c.jsx(ca,{size:16,className:"text-blue-600"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-neutral-900",children:r?"变基中...":"变基 (Rebase)"}),c.jsxs("div",{className:"text-xs text-neutral-500",children:["将当前分支变基到最新的 ",s]})]})]}),c.jsxs("button",{onClick:d,disabled:i||b||C||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:[c.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:c.jsx(Ji,{size:16,className:"text-emerald-600"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i?"合并中...":"合并 (Merge)"}),c.jsxs("div",{className:"text-xs text-neutral-500",children:["Squash merge 到 ",s]})]})]})]})]})}function mf({editableMessage:e,setEditableMessage:t,error:s,isPending:a,onConfirm:m,onBack:b,branchName:C,targetBranch:r}){return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:C}),c.jsx(Yi,{size:14,className:"text-neutral-400"}),c.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:"提交消息"}),c.jsx("textarea",{value:e,onChange:i=>t(i.target.value),placeholder:"输入提交消息...",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()&&c.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:"留空将使用默认消息"})]}),s&&c.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:s}),c.jsxs("div",{className:"flex gap-2 justify-end",children:[c.jsx("button",{onClick:b,disabled:a,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:"返回"}),c.jsx("button",{onClick:m,disabled:a,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:a?c.jsxs(c.Fragment,{children:[c.jsx(Ae,{size:14,className:"animate-spin"}),"合并中..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Ji,{size:14}),"确认合并"]})})]})]})}const vf=675,wi=320,Ei=1200,gf=c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[c.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:c.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:[c.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),c.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),c.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),c.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:"Select a task from the sidebar to view logs, monitor execution, or interact with an agent."})]}),ki=[{status:ae.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:c.jsx(dr,{className:"w-3 h-3"})},{status:ae.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:c.jsx(fr,{className:"w-3 h-3"})},{status:ae.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:c.jsx(pr,{className:"w-3 h-3"})},{status:ae.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:c.jsx(mr,{className:"w-3 h-3"})},{status:ae.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:c.jsx(vr,{className:"w-3 h-3"})}];function _f({status:e,onChangeStatus:t}){const[s,a]=R.useState(!1),m=R.useRef(null);R.useEffect(()=>{if(!s)return;const C=r=>{m.current&&!m.current.contains(r.target)&&a(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s]);const b=ki.find(C=>C.status===e);return c.jsxs("div",{className:"relative",ref:m,children:[c.jsxs("button",{onClick:()=>t&&a(C=>!C),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${b.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[b.icon,c.jsx("span",{children:e}),t&&c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${s?"rotate-180":""}`,children:c.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),s&&c.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:ki.filter(C=>C.status!==e).map(C=>c.jsxs("button",{onClick:()=>{t?.(C.status),a(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${C.hoverClass}`,children:[c.jsx("span",{className:C.className.split(" ").find(r=>r.startsWith("text-")),children:C.icon}),c.jsx("span",{className:"text-neutral-700",children:C.status})]},C.status))})]})}function bf({task:e,onDeleteTask:t,isDeleting:s,onTaskStatusChange:a}){const[m,b]=R.useState(""),[C,r]=R.useState(!1),[i,l]=R.useState(!1),[d,o]=R.useState(!1),[p,_]=R.useState(!1),[y,g]=R.useState(!1),n=R.useRef(null),f=R.useRef(null),h=R.useRef(null),{scrollRef:u,contentRef:v,isAtBottom:S,scrollToBottom:w}=xn({resize:"smooth",initial:"instant"}),[k,x]=R.useState(vf),[E,A]=R.useState(!0),[j,T]=R.useState(!1),N=R.useRef(0),I=R.useRef(0),F=R.useRef(null),{data:H,isLoading:z}=Zn(e?.id??""),D=ef(e?.id),M=R.useMemo(()=>{if(!H)return null;const V=ge=>{const qe=ge.createdAt,Ze=ge.endedAt??ge.startedAt??qe;if(!Ze)return 0;const Ye=Date.parse(Ze);return Number.isNaN(Ye)?0:Ye},ee=(ge,qe)=>{const Ze=ge.filter(Ye=>qe.includes(Ye.status));return Ze.length===0?null:Ze.sort((Ye,st)=>V(st)-V(Ye))[0]??null},xe=H.filter(ge=>ge.status==="ACTIVE"&&Array.isArray(ge.sessions)).flatMap(ge=>ge.sessions??[]),ye=ee(xe,[we.RUNNING])??ee(xe,[we.PENDING])??ee(xe,[we.COMPLETED,we.FAILED,we.CANCELLED]);if(ye)return ye;const Me=H.filter(ge=>ge.status==="MERGED"&&Array.isArray(ge.sessions)).flatMap(ge=>ge.sessions??[]);return ee(Me,[we.COMPLETED,we.FAILED,we.CANCELLED])},[H]),P=M?.id??"",O=M?.status===we.RUNNING||M?.status===we.PENDING,U=R.useMemo(()=>!M||!H?!1:!H.some(ee=>ee.status==="ACTIVE"&&ee.sessions?.some(xe=>xe.id===M.id)),[M,H]),K=R.useMemo(()=>{if(H){for(const V of H)if(V.status==="ACTIVE"&&V.worktreePath)return V.worktreePath;return H[0]?.worktreePath}},[H]),X=R.useMemo(()=>H?H.find(ee=>ee.status==="ACTIVE")?.id:void 0,[H]),{data:G}=Jn(X??""),ne=R.useMemo(()=>H?H.find(ee=>ee.status==="ACTIVE")?.sessions??[]:[],[H]),L=R.useMemo(()=>H?H.find(ee=>ee.status==="ACTIVE")?.branchName??"":"",[H]),B=R.useMemo(()=>H?H.find(ee=>ee.status==="ACTIVE")?.commitMessage:void 0,[H]),$=Te();R.useEffect(()=>{if(!y)return;const V=ee=>{n.current&&!n.current.contains(ee.target)&&g(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[y]);const W=Tr(),J=Ar(),Y=R.useCallback(()=>{X&&J.mutate({workspaceId:X})},[X,J]),oe=R.useCallback(()=>{!e?.id||!t||(t(e.id),l(!1))},[e?.id,t]),{isConnected:de,isLoadingSnapshot:be,logs:Ee,entries:te,attach:Re}=Fi({sessionId:P,onExit:R.useCallback(()=>{$.invalidateQueries({queryKey:["workspaces"]})},[$])});R.useEffect(()=>{if(!e?.id)return;const V=ot.connect();V.emit(rt.SUBSCRIBE,{topic:"task",id:e.id});const ee=xe=>{xe.taskId===e.id&&$.invalidateQueries({queryKey:["tasks"]})};return V.on(Oe.TASK_UPDATED,ee),()=>{V.off(Oe.TASK_UPDATED,ee),V.emit(rt.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,$]),R.useEffect(()=>{if(!P)return;const V=ot.connect(),ee=xe=>{xe.sessionId===P&&$.invalidateQueries({queryKey:["workspaces"]})};return V.on(Oe.SESSION_COMPLETED,ee),()=>{V.off(Oe.SESSION_COMPLETED,ee)}},[P,$]);const{todos:De}=Hi(te),{files:Q,addFiles:re,removeFile:fe,clear:se,buildMarkdownLinks:q,hasFiles:ie,isUploading:pe}=ro(),Ie=R.useMemo(()=>{if(!M?.tokenUsage)return;const V=M.tokenUsage;if(typeof V.totalTokens=="number")return V},[M?.tokenUsage]),je=so(Ee,Ie);R.useEffect(()=>{P&&de&&Re()},[P,de,Re]);const Xe=R.useRef(e?.id);R.useEffect(()=>{Xe.current!==e?.id&&w(),Xe.current=e?.id},[e?.id,w]);const Fe=to(),Pe=R.useRef(!1),ve=R.useCallback(async()=>{if(!m.trim()&&!ie||!P||Pe.current||pe)return;Pe.current=!0;const V=q(),ee=[m.trim(),V].filter(Boolean).join(`
76
-
77
- `);b(""),se(),f.current&&(f.current.style.height="60px"),W.mutate({id:P,message:ee},{onSuccess:()=>{Re()},onSettled:()=>{Pe.current=!1}})},[m,P,W,Re,ie,pe,q,se]),kt=R.useCallback(async()=>{P&&(await Fe.mutateAsync(P),$.invalidateQueries({queryKey:["workspaces"]}))},[P,Fe,$]),js=R.useCallback(V=>{const ee=V.target.files;ee&&ee.length>0&&re(Array.from(ee)),V.target.value=""},[re]),Rt=R.useCallback(V=>{const ee=V.clipboardData.items,xe=[];for(const ye of ee)if(ye.kind==="file"){const Me=ye.getAsFile();Me&&xe.push(Me)}xe.length>0&&(V.preventDefault(),re(xe))},[re]),[Dt,Lt]=R.useState(!1),Jt=R.useCallback(V=>{V.preventDefault(),Lt(!0)},[]),Ms=R.useCallback(V=>{V.preventDefault(),Lt(!1)},[]),Ns=R.useCallback(V=>{V.preventDefault(),Lt(!1);const ee=V.dataTransfer.files;ee.length>0&&re(Array.from(ee))},[re]),At=R.useCallback(V=>{const ee=V.clientX-N.current,xe=Math.max(wi,Math.min(I.current+ee,Ei));F.current&&(F.current.style.width=`${xe}px`),I.current=I.current},[]),Le=R.useCallback(()=>{if(T(!1),F.current){const V=F.current.getBoundingClientRect().width;x(Math.max(wi,Math.min(Math.round(V),Ei)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);R.useEffect(()=>{if(j)return document.addEventListener("mousemove",At),document.addEventListener("mouseup",Le),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",At),document.removeEventListener("mouseup",Le),document.body.style.cursor="",document.body.style.userSelect=""}},[j,At,Le]);const He=R.useCallback(V=>{V.preventDefault(),N.current=V.clientX,I.current=k,T(!0)},[k]),ze=R.useCallback(()=>{A(V=>!V)},[]),tt=R.useCallback(V=>{b(V.target.value);const ee=V.target;ee.style.height="auto";const xe=ee.scrollHeight;ee.style.height=`${Math.max(60,Math.min(xe,300))}px`},[]),We=R.useMemo(()=>{const V=[];if(H&&H.length>0){const ee=H.some(Me=>Me.status==="ACTIVE"),xe=H.some(Me=>Me.sessions?.some(ge=>ge.status===we.RUNNING||ge.status===we.PENDING)),ye=H.some(Me=>Me.status==="ACTIVE");xe&&V.push("正在运行的 Agent 将被停止"),ye&&V.push("分支上未合并的变更将丢失"),ee&&V.push("关联的工作目录(worktree)将被清理")}return V},[H]);return e?c.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[c.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:[c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[c.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),c.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),c.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),c.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx(_f,{status:e.status,onChangeStatus:a?V=>a(e.id,V):void 0}),X&&c.jsx("button",{onClick:()=>_(!0),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:"Git 操作",children:c.jsx(ua,{size:18})}),c.jsx("button",{onClick:Y,disabled:!X,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:"Open in IDE",children:c.jsx(Ss,{size:18})}),c.jsx("button",{onClick:ze,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:"Toggle Workspace",children:E?c.jsx(ka,{size:18}):c.jsx(Da,{size:18})}),t&&c.jsxs("div",{className:"relative",ref:n,children:[c.jsx("button",{onClick:()=>g(V=>!V),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:"More actions",children:c.jsx(Gi,{size:18})}),y&&c.jsx("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:c.jsxs("button",{onClick:()=>{l(!0),g(!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:[c.jsx(qi,{size:15}),c.jsx("span",{children:"删除任务"})]})})]})]})]}),X&&G&&c.jsx(cf,{workspaceId:X,gitStatus:G,onResolve:()=>o(!0)}),c.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c.jsxs("div",{ref:F,className:`flex flex-col bg-white relative ${E?"flex-shrink-0":"flex-1"}`,style:{width:E?k:"100%"},children:[c.jsxs("div",{className:"relative flex-1 min-h-0",children:[c.jsx("div",{ref:u,className:"h-full overflow-y-auto px-6 pt-6 pb-4",children:c.jsxs("div",{ref:v,className:"w-full",children:[c.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:c.jsx("p",{className:"text-sm text-neutral-500 leading-relaxed",children:e.description})}),D&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[D.status==="running"&&c.jsxs(c.Fragment,{children:[c.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:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),c.jsxs("span",{children:["Setup (",D.currentIndex,"/",D.totalCommands,"): ",c.jsx("code",{children:D.currentCommand})]})]}),D.status==="completed"&&c.jsx("span",{className:"text-emerald-600",children:"Setup 完成"}),D.status==="failed"&&c.jsxs("span",{className:"text-red-500",children:["Setup 失败: ",D.error]})]}),z?c.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[c.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),c.jsx("span",{className:"text-sm",children:"Loading..."})]}):P?be?c.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[c.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),c.jsx("span",{className:"text-sm",children:"Loading logs..."})]}):Ee.length===0?c.jsx("div",{className:"text-neutral-400 text-center py-8",children:O?"Waiting for agent output...":"No logs recorded for this session."}):c.jsx(zi,{logs:Ee}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[c.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:c.jsx(St,{size:24,className:"text-neutral-400 ml-0.5"})}),c.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:"尚未启动 Agent"}),c.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:"选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。"}),c.jsxs(it,{onClick:()=>r(!0),children:[c.jsx(St,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!S&&c.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":"Scroll to bottom",children:[c.jsx(Xi,{size:14}),c.jsx("span",{children:"回到底部"})]})]}),De.length>0&&c.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:c.jsx(Wi,{todos:De})}),U?c.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:c.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[c.jsx("span",{className:"text-sm text-neutral-500",children:"代码已合并,以上为历史沟通记录"}),c.jsxs(it,{size:"sm",onClick:()=>r(!0),children:[c.jsx(St,{size:14,className:"mr-1.5"}),"启动新 Agent"]})]})}):c.jsx("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Jt,onDragLeave:Ms,onDrop:Ns,children:c.jsxs("div",{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 ${Dt?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[c.jsx(io,{files:Q,onRemove:fe}),c.jsx("textarea",{ref:f,value:m,onChange:tt,onPaste:Rt,onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&(V.preventDefault(),ve())},rows:1,placeholder:Dt?"Drop files here...":P&&!O?"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"}}),c.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:js}),c.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{onClick:()=>h.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:"Upload file",children:c.jsx($i,{size:18})}),c.jsx(Sn,{usage:je})]}),c.jsx("div",{className:"flex items-center gap-2",children:O&&!m.trim()&&!ie?c.jsx("button",{onClick:kt,disabled:Fe.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:c.jsx(Ui,{size:14})}):c.jsx("button",{onClick:ve,disabled:!m.trim()&&!ie||pe,className:`p-2 rounded-lg transition-all duration-200 ${(m.trim()||ie)&&!pe?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:c.jsx(Vi,{size:18})})})]})]})})]}),E&&c.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:He}),E&&c.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:c.jsx(Qn,{sessionId:P||void 0,workingDir:K,projectId:e.projectId})})]}),c.jsx(no,{isOpen:C,onClose:()=>r(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),X&&c.jsx(ff,{open:p,onOpenChange:_,workspaceId:X,branchName:L,targetBranch:e.mainBranch,commitMessage:B,onConflict:()=>o(!0)}),X&&G&&G.conflictOp&&c.jsx(uf,{open:d,onOpenChange:o,workspaceId:X,conflictOp:G.conflictOp,conflictedFiles:G.conflictedFiles,sourceBranch:L,targetBranch:e.mainBranch,sessions:ne}),c.jsx(oo,{isOpen:i,onClose:()=>l(!1),onConfirm:oe,title:"删除任务",description:c.jsxs(c.Fragment,{children:[c.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),We.length>0&&c.jsx("ul",{className:"mt-2 space-y-1",children:We.map((V,ee)=>c.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[c.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),c.jsx("span",{children:V})]},ee))})]}),confirmText:"删除",variant:"danger",isLoading:s})]}):gf}function xf(e){switch(e){case Ge.TODO:return ae.Pending;case Ge.IN_PROGRESS:return ae.Running;case Ge.IN_REVIEW:return ae.Review;case Ge.DONE:return ae.Done;case Ge.CANCELLED:return ae.Cancelled}}function Sf(e){switch(e){case ae.Pending:return Ge.TODO;case ae.Running:return Ge.IN_PROGRESS;case ae.Review:return Ge.IN_REVIEW;case ae.Done:return Ge.DONE;case ae.Cancelled:return Ge.CANCELLED}}function yf(e){switch(e){case It.CLAUDE_CODE:return"Claude Code";case It.GEMINI_CLI:return"Gemini CLI";case It.CURSOR_AGENT:return"Cursor Agent"}}const Ri=["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 Cf(e,t){let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a)|0;return Math.abs(s)%t}function wf(e){return{id:e.id,name:e.name,color:e.color||Ri[Cf(e.name,Ri.length)]}}function Ef(e){if(!e||e.length===0)return{agent:"—",branch:"—"};const t=e.find(m=>m.status==="ACTIVE")??e[0],s=t.branchName,a=t.sessions;if(a&&a.length>0){const m=a[a.length-1];return{agent:yf(m.agentType),branch:s}}return{agent:"—",branch:s}}function kf(e){const{agent:t,branch:s}=Ef(e.workspaces);return{id:e.id,projectId:e.projectId,title:e.title,status:xf(e.status),agent:t,branch:s,description:e.description??""}}function Rf(e,t){const s={};return nt({queryKey:le.tasks.list(e,t),queryFn:()=>he.get(`/projects/${e}/tasks`,{params:s}),enabled:!!e})}function Df(e){const t=Te();return Ue({mutationFn:s=>he.post(`/projects/${e}/tasks`,s),onSuccess:()=>{t.invalidateQueries({queryKey:le.tasks.list(e)}),t.invalidateQueries({queryKey:le.tasks.stats(e)})}})}function Lf(){const e=Te();return Ue({mutationFn:({id:t,status:s})=>he.patch(`/tasks/${t}/status`,{status:s}),onSuccess:t=>{e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.tasks.detail(t.id)})}})}function Af(){const e=Te();return Ue({mutationFn:t=>he.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:le.tasks.all})}})}function Tf(e){const t=Te(),s=R.useRef(new Set);R.useEffect(()=>{if(e.length===0)return;const a=ot.connect(),m=s.current,b=new Set(e);for(const i of b)m.has(i)||a.emit(rt.SUBSCRIBE,{topic:"project",id:i},l=>{l.success&&m.add(i)});for(const i of m)b.has(i)||a.emit(rt.UNSUBSCRIBE,{topic:"project",id:i},()=>{m.delete(i)});const C=i=>{t.invalidateQueries({queryKey:le.tasks.list(i.projectId)}),t.invalidateQueries({queryKey:le.tasks.detail(i.taskId)})},r=i=>{t.invalidateQueries({queryKey:le.tasks.list(i.projectId)}),t.removeQueries({queryKey:le.tasks.detail(i.taskId)})};return a.on(Oe.TASK_UPDATED,C),a.on(Oe.TASK_DELETED,r),()=>{a.off(Oe.TASK_UPDATED,C),a.off(Oe.TASK_DELETED,r);for(const i of m)a.emit(rt.UNSUBSCRIBE,{topic:"project",id:i});m.clear()}},[e,t])}const ao=768;function jf(e){const t=window.matchMedia(`(max-width: ${ao-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Mf(){return window.innerWidth<ao}function Nf(){return!1}function Pf(){return R.useSyncExternalStore(jf,Mf,Nf)}const Di={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 Of(e){const t=e.split("/");return t[t.length-1]||e}function Bf(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function If({workingDir:e,filePath:t,type:s}){const{data:a,isLoading:m,isError:b}=Yn(e,t,s);if(m)return c.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[c.jsx(Ae,{size:14,className:"animate-spin"}),c.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return c.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:"Failed to load diff."});const C=a?.diff||"";if(!C.trim())return c.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No diff content."});const r=C.split(`
78
- `);return c.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,l)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),c.jsx("div",{className:me("px-3 whitespace-pre",d,o),children:i},l)})})}function Ff({entry:e,type:t,workingDir:s}){const[a,m]=R.useState(!1),b=Di[e.status]||Di.M,C=Bf(e.path);return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>m(r=>!r),className:me("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[c.jsx("span",{className:me("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Of(e.path)}),C&&c.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),c.jsx("span",{className:"text-neutral-400 shrink-0",children:a?c.jsx(dt,{size:14}):c.jsx(gt,{size:14})})]}),a&&c.jsx(If,{workingDir:s,filePath:e.path,type:t})]})}function Li({title:e,entries:t,type:s,workingDir:a,defaultOpen:m}){const[b,C]=R.useState(m);return t.length===0?null:c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>C(r=>!r),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[c.jsx("span",{className:"text-neutral-400",children:b?c.jsx(dt,{size:14}):c.jsx(gt,{size:14})}),c.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:e}),c.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),b&&c.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(r=>c.jsx(Ff,{entry:r,type:s,workingDir:a},`${s}:${r.path}`))})]})}function Hf({workingDir:e}){const{data:t,isLoading:s,isError:a}=Xn(e);if(!e)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."});if(s)return c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-sm",children:"Loading changes..."})]});if(a)return c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load changes."});const m=t?.uncommitted||[],b=t?.committed||[];return m.length+b.length===0?c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[c.jsx(zt,{size:28,className:"mb-3"}),c.jsx("span",{className:"text-sm",children:"No pending changes"})]}):c.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[c.jsx(Li,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),c.jsx(Li,{title:"Committed",entries:b,type:"committed",workingDir:e,defaultOpen:!1})]})}const Vs=50,Ai={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 zf(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:s<86400?`${Math.floor(s/3600)}h ago`:s<604800?`${Math.floor(s/86400)}d ago`:new Date(e*1e3).toLocaleDateString()}function Wf(e){const t=e.split("/");return t[t.length-1]||e}function $f(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Uf({workingDir:e,hash:t,filePath:s}){const{data:a,isLoading:m,isError:b}=Gn(e,t,s);if(m)return c.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[c.jsx(Ae,{size:14,className:"animate-spin"}),c.jsx("span",{className:"text-xs",children:"Loading diff..."})]});if(b)return c.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:"Failed to load diff."});const C=a?.diff||"";if(!C.trim())return c.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No diff content."});const r=C.split(`
79
- `);return c.jsx("div",{className:"overflow-x-auto bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:r.map((i,l)=>{let d="",o="text-neutral-400";return i.startsWith("+")&&!i.startsWith("+++")?(d="bg-emerald-950/40",o="text-emerald-400"):i.startsWith("-")&&!i.startsWith("---")?(d="bg-red-950/40",o="text-red-400"):i.startsWith("@@")&&(d="bg-blue-950/30",o="text-blue-400"),c.jsx("div",{className:me("px-3 whitespace-pre",d,o),children:i},l)})})}function qf({entry:e,workingDir:t,hash:s}){const[a,m]=R.useState(!1),b=Ai[e.status]||Ai.M,C=$f(e.path);return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>m(r=>!r),className:me("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[c.jsx("span",{className:me("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",b),children:e.status}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Wf(e.path)}),C&&c.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:C})]}),c.jsx("span",{className:"text-neutral-400 shrink-0",children:a?c.jsx(dt,{size:14}):c.jsx(gt,{size:14})})]}),a&&c.jsx(Uf,{workingDir:t,hash:s,filePath:e.path})]})}function Kf({commit:e,workingDir:t}){const[s,a]=R.useState(!1),{data:m,isLoading:b}=Vn(t,s?e.hash:null),C=m?.files||[];return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>a(r=>!r),className:me("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",s&&"bg-neutral-50"),children:[c.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:c.jsx("div",{className:me("w-2.5 h-2.5 rounded-full shrink-0",s?"bg-blue-500":"bg-neutral-300")})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),c.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[c.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),c.jsx("span",{className:"text-[11px] text-neutral-400",children:zf(e.timestamp)})]})]}),c.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:s?c.jsx(dt,{size:14}):c.jsx(gt,{size:14})})]}),s&&c.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&c.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),b?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[c.jsx(Ae,{size:14,className:"animate-spin"}),c.jsx("span",{className:"text-xs",children:"Loading files..."})]}):C.length===0?c.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:"No files changed"}):c.jsx("div",{className:"divide-y divide-neutral-100",children:C.map(r=>c.jsx(qf,{entry:r,workingDir:t,hash:e.hash},r.path))})]})]})}function Xf({workingDir:e}){const{data:t,isLoading:s,isError:a,fetchNextPage:m,hasNextPage:b,isFetchingNextPage:C}=Ki({queryKey:le.git.log(e||""),queryFn:({pageParam:i=0})=>he.get("/git/log",{params:{workingDir:e||"",limit:String(Vs),skip:String(i)}}),initialPageParam:0,getNextPageParam:(i,l)=>i.commits.length<Vs?void 0:l.length*Vs,enabled:!!e}),r=t?.pages.flatMap(i=>i.commits)||[];return e?s?c.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[c.jsx(Ae,{size:16,className:"animate-spin mr-2"}),c.jsx("span",{className:"text-sm",children:"Loading history..."})]}):a?c.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:"Failed to load history."}):r.length===0?c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[c.jsx(Ct,{size:28,className:"mb-3"}),c.jsx("span",{className:"text-sm",children:"No commit history"})]}):c.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-y-contain",children:[c.jsx("div",{className:"divide-y divide-neutral-100",children:r.map(i=>c.jsx(Kf,{commit:i,workingDir:e},i.hash))}),b&&c.jsx("button",{type:"button",onClick:()=>m(),disabled:C,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:C?c.jsxs(c.Fragment,{children:[c.jsx(Ae,{size:14,className:"animate-spin"})," Loading..."]}):"Load more"})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:"No workspace selected."})}function Yf({status:e}){const t={[ae.Running]:"bg-blue-500",[ae.Review]:"bg-amber-500",[ae.Pending]:"bg-neutral-400",[ae.Done]:"bg-emerald-500",[ae.Cancelled]:"bg-neutral-400"};return c.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const Vf=[{key:"chat",label:"Chat",icon:xa},{key:"changes",label:"Changes",icon:zt},{key:"history",label:"History",icon:Ct},{key:"workspace",label:"Workspace",icon:Zi}];function Gf({task:e,onBack:t,onDeleteTask:s,isDeleting:a}){const[m,b]=R.useState("chat"),[C,r]=R.useState(""),[i,l]=R.useState(!1),[d,o]=R.useState(!1),[p,_]=R.useState(!1),y=R.useRef(null),g=R.useRef(null),n=R.useRef(null),{scrollRef:f,contentRef:h,isAtBottom:u,scrollToBottom:v}=xn({resize:"smooth",initial:"instant"}),S=Te();R.useEffect(()=>{if(!p)return;const Q=re=>{y.current&&!y.current.contains(re.target)&&_(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[p]);const{data:w,isLoading:k}=Zn(e.id),x=R.useMemo(()=>{if(!w)return null;const Q=w.filter(se=>se.status==="ACTIVE"&&Array.isArray(se.sessions)).flatMap(se=>se.sessions??[]),re=se=>{const q=se.createdAt,ie=se.endedAt??se.startedAt??q;if(!ie)return 0;const pe=Date.parse(ie);return Number.isNaN(pe)?0:pe},fe=se=>{const q=Q.filter(ie=>se.includes(ie.status));return q.length===0?null:q.sort((ie,pe)=>re(pe)-re(ie))[0]??null};return fe([we.RUNNING])??fe([we.PENDING])??fe([we.COMPLETED,we.FAILED,we.CANCELLED])},[w]),E=x?.id??"",A=x?.status===we.RUNNING||x?.status===we.PENDING,j=R.useMemo(()=>{if(w){for(const Q of w)if(Q.status==="ACTIVE"&&Q.worktreePath)return Q.worktreePath;return w[0]?.worktreePath}},[w]),T=R.useMemo(()=>{if(w)return w.find(Q=>Q.status==="ACTIVE")?.id},[w]),N=R.useMemo(()=>{const Q=[];if(w&&w.length>0){const re=w.some(se=>se.status==="ACTIVE");w.some(se=>se.sessions?.some(q=>q.status===we.RUNNING||q.status===we.PENDING))&&Q.push("正在运行的 Agent 将被停止"),re&&(Q.push("分支上未合并的变更将丢失"),Q.push("关联的工作目录(worktree)将被清理"))}return Q},[w]),I=Tr(),F=Ar(),H=to(),{isConnected:z,isLoadingSnapshot:D,logs:M,entries:P,attach:O}=Fi({sessionId:E,onExit:R.useCallback(()=>{S.invalidateQueries({queryKey:["workspaces"]})},[S])}),{todos:U}=Hi(P),{files:K,addFiles:X,removeFile:G,clear:ne,buildMarkdownLinks:L,hasFiles:B,isUploading:$}=ro(),W=R.useMemo(()=>{if(!x?.tokenUsage)return;const Q=x.tokenUsage;if(typeof Q.totalTokens=="number")return Q},[x?.tokenUsage]),J=so(M,W);R.useEffect(()=>{E&&z&&O()},[E,z,O]),R.useEffect(()=>{v()},[e.id,v]);const Y=R.useRef(!1),oe=R.useCallback(async()=>{if(!C.trim()&&!B||!E||Y.current||$)return;Y.current=!0;const Q=L(),re=[C.trim(),Q].filter(Boolean).join(`
80
-
81
- `);r(""),ne(),g.current&&(g.current.style.height="40px"),I.mutate({id:E,message:re},{onSuccess:()=>O(),onSettled:()=>{Y.current=!1}})},[C,E,I,O,B,$,L,ne]),de=R.useCallback(async()=>{E&&(await H.mutateAsync(E),S.invalidateQueries({queryKey:["workspaces"]}))},[E,H,S]),be=R.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&X(Array.from(re)),Q.target.value=""},[X]),Ee=R.useCallback(Q=>{const re=Q.clipboardData.items,fe=[];for(const se of re)if(se.kind==="file"){const q=se.getAsFile();q&&fe.push(q)}fe.length>0&&(Q.preventDefault(),X(fe))},[X]),te=R.useCallback(Q=>{r(Q.target.value);const re=Q.target;re.style.height="auto",re.style.height=`${Math.max(40,Math.min(re.scrollHeight,140))}px`},[]),Re=R.useCallback(()=>{T&&F.mutate({workspaceId:T})},[T,F]),De=R.useRef(null);return R.useEffect(()=>{const Q=window.visualViewport;if(!Q)return;let re=!1;const fe=()=>{De.current&&(De.current.style.height=`${Q.height}px`,De.current.style.top=`${Q.offsetTop}px`)},se=()=>fe(),q=()=>{re||fe()},ie=()=>{re=!0},pe=()=>{re=!1,requestAnimationFrame(fe)};return Q.addEventListener("resize",se),Q.addEventListener("scroll",q),document.addEventListener("touchstart",ie,{passive:!0}),document.addEventListener("touchend",pe,{passive:!0}),document.addEventListener("touchcancel",pe,{passive:!0}),()=>{Q.removeEventListener("resize",se),Q.removeEventListener("scroll",q),document.removeEventListener("touchstart",ie),document.removeEventListener("touchend",pe),document.removeEventListener("touchcancel",pe)}},[]),R.useEffect(()=>{const Q=De.current;if(!Q)return;const re=fe=>{let se=fe.target;for(;se&&se!==Q;){if(se.tagName==="TEXTAREA"){if(se.scrollHeight>se.clientHeight)return;se=se.parentElement;continue}const ie=window.getComputedStyle(se).overflowY;if((ie==="auto"||ie==="scroll")&&se.scrollHeight>se.clientHeight)return;se=se.parentElement}fe.preventDefault()};return Q.addEventListener("touchmove",re,{passive:!1}),()=>Q.removeEventListener("touchmove",re)},[]),c.jsxs("div",{ref:De,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[c.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[c.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[c.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:c.jsx(Ro,{size:18})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),c.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[c.jsx("span",{className:`font-medium ${e.projectColor}`,children:e.projectName}),c.jsx("span",{className:"text-neutral-300",children:"/"}),c.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),c.jsx(Yf,{status:e.status}),c.jsx("button",{onClick:Re,disabled:!T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:c.jsx(Ss,{size:16})}),s&&c.jsxs("div",{className:"relative",ref:y,children:[c.jsx("button",{onClick:()=>_(Q=>!Q),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:c.jsx(Gi,{size:16})}),p&&c.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:c.jsxs("button",{onClick:()=>{o(!0),_(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[c.jsx(qi,{size:15}),c.jsx("span",{children:"删除任务"})]})})]})]}),c.jsx("div",{className:"flex border-t border-neutral-100",children:Vf.map(({key:Q,label:re,icon:fe})=>c.jsxs("button",{onClick:()=>b(Q),className:`flex-1 flex items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors ${m===Q?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[c.jsx(fe,{size:13}),c.jsx("span",{children:re})]},Q))})]}),m==="chat"&&c.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[c.jsxs("div",{className:"relative flex-1 min-h-0",children:[c.jsx("div",{ref:f,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-3 pt-3 pb-2",children:c.jsxs("div",{ref:h,children:[c.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:c.jsx("p",{className:"text-[13px] text-neutral-500 leading-relaxed",children:e.description})}),k?c.jsx(Ti,{label:"Loading..."}):E?D?c.jsx(Ti,{label:"Loading logs..."}):M.length===0?c.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:A?"Waiting for agent output...":"No logs recorded."}):c.jsx(zi,{logs:M}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:c.jsx(St,{size:20,className:"text-neutral-400 ml-0.5"})}),c.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:"尚未启动 Agent"}),c.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:"选择一个 Agent 来执行此任务"}),c.jsxs(it,{onClick:()=>l(!0),children:[c.jsx(St,{size:16,className:"mr-1.5"}),"启动 Agent"]})]})]})}),!u&&c.jsxs("button",{onClick:()=>v(),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:[c.jsx(Xi,{size:12}),c.jsx("span",{children:"回到底部"})]})]}),U.length>0&&c.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:c.jsx(Wi,{todos:U,compact:!0})}),E&&c.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:c.jsxs("div",{className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[c.jsx(io,{files:K,onRemove:G}),c.jsx("textarea",{ref:g,value:C,onChange:te,onPaste:Ee,onKeyDown:Q=>{Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),oe())},rows:1,placeholder:A?"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}}),c.jsx("input",{ref:n,type:"file",multiple:!0,className:"hidden",onChange:be}),c.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx("button",{onClick:()=>n.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:c.jsx($i,{size:15})}),c.jsx(Sn,{usage:J})]}),A&&!C.trim()&&!B?c.jsx("button",{onClick:de,disabled:H.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:c.jsx(Ui,{size:12})}):c.jsx("button",{onClick:oe,disabled:!C.trim()&&!B||$,className:`p-1.5 rounded-lg transition-colors ${(C.trim()||B)&&!$?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:c.jsx(Vi,{size:15})})]})]})})]}),m==="changes"&&c.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:c.jsx(Hf,{workingDir:j})}),m==="history"&&c.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:c.jsx(Xf,{workingDir:j})}),m==="workspace"&&c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(Qn,{sessionId:E||void 0,workingDir:j,projectId:e.projectId,className:"h-full",hideChanges:!0})}),c.jsx(no,{isOpen:i,onClose:()=>l(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),c.jsx(oo,{isOpen:d,onClose:()=>o(!1),onConfirm:()=>{s?.(e.id),o(!1)},title:"删除任务",description:c.jsxs(c.Fragment,{children:[c.jsxs("p",{children:["确认删除任务「",e.title,"」?此操作不可撤销。"]}),N.length>0&&c.jsx("ul",{className:"mt-2 space-y-1",children:N.map((Q,re)=>c.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[c.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),c.jsx("span",{children:Q})]},re))})]}),confirmText:"删除",variant:"danger",isLoading:a})]})}function Ti({label:e}){return c.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[c.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),c.jsx("span",{className:"text-sm",children:e})]})}var Qf=Object.defineProperty,gs=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,ji=(e,t,s)=>t in e?Qf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ar=(e,t)=>{for(var s in t||(t={}))lo.call(t,s)&&ji(e,s,t[s]);if(gs)for(var s of gs(t))co.call(t,s)&&ji(e,s,t[s]);return e},lr=(e,t)=>{var s={};for(var a in e)lo.call(e,a)&&t.indexOf(a)<0&&(s[a]=e[a]);if(e!=null&&gs)for(var a of gs(e))t.indexOf(a)<0&&co.call(e,a)&&(s[a]=e[a]);return s};var vt;(e=>{const t=class ce{constructor(i,l,d,o){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<ce.MIN_VERSION||i>ce.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let p=[];for(let y=0;y<this.size;y++)p.push(!1);for(let y=0;y<this.size;y++)this.modules.push(p.slice()),this.isFunction.push(p.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(d);if(this.drawCodewords(_),o==-1){let y=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const n=this.getPenaltyScore();n<y&&(o=g,y=n),this.applyMask(g)}}m(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(i,l){const d=e.QrSegment.makeSegments(i);return ce.encodeSegments(d,l)}static encodeBinary(i,l){const d=e.QrSegment.makeBytes(i);return ce.encodeSegments([d],l)}static encodeSegments(i,l,d=1,o=40,p=-1,_=!0){if(!(ce.MIN_VERSION<=d&&d<=o&&o<=ce.MAX_VERSION)||p<-1||p>7)throw new RangeError("Invalid value");let y,g;for(y=d;;y++){const u=ce.getNumDataCodewords(y,l)*8,v=C.getTotalBits(i,y);if(v<=u){g=v;break}if(y>=o)throw new RangeError("Data too long")}for(const u of[ce.Ecc.MEDIUM,ce.Ecc.QUARTILE,ce.Ecc.HIGH])_&&g<=ce.getNumDataCodewords(y,u)*8&&(l=u);let n=[];for(const u of i){s(u.mode.modeBits,4,n),s(u.numChars,u.mode.numCharCountBits(y),n);for(const v of u.getData())n.push(v)}m(n.length==g);const f=ce.getNumDataCodewords(y,l)*8;m(n.length<=f),s(0,Math.min(4,f-n.length),n),s(0,(8-n.length%8)%8,n),m(n.length%8==0);for(let u=236;n.length<f;u^=253)s(u,8,n);let h=[];for(;h.length*8<n.length;)h.push(0);return n.forEach((u,v)=>h[v>>>3]|=u<<7-(v&7)),new ce(y,l,h,p)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let d=0;d<l;d++)for(let o=0;o<l;o++)d==0&&o==0||d==0&&o==l-1||d==l-1&&o==0||this.drawAlignmentPattern(i[d],i[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let d=l;for(let p=0;p<10;p++)d=d<<1^(d>>>9)*1335;const o=(l<<10|d)^21522;m(o>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,a(o,p));this.setFunctionModule(8,7,a(o,6)),this.setFunctionModule(8,8,a(o,7)),this.setFunctionModule(7,8,a(o,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,a(o,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,a(o,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,a(o,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;m(l>>>18==0);for(let d=0;d<18;d++){const o=a(l,d),p=this.size-11+d%3,_=Math.floor(d/3);this.setFunctionModule(p,_,o),this.setFunctionModule(_,p,o)}}drawFinderPattern(i,l){for(let d=-4;d<=4;d++)for(let o=-4;o<=4;o++){const p=Math.max(Math.abs(o),Math.abs(d)),_=i+o,y=l+d;0<=_&&_<this.size&&0<=y&&y<this.size&&this.setFunctionModule(_,y,p!=2&&p!=4)}}drawAlignmentPattern(i,l){for(let d=-2;d<=2;d++)for(let o=-2;o<=2;o++)this.setFunctionModule(i+o,l+d,Math.max(Math.abs(o),Math.abs(d))!=1)}setFunctionModule(i,l,d){this.modules[l][i]=d,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,d=this.errorCorrectionLevel;if(i.length!=ce.getNumDataCodewords(l,d))throw new RangeError("Invalid argument");const o=ce.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l],p=ce.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l],_=Math.floor(ce.getNumRawDataModules(l)/8),y=o-_%o,g=Math.floor(_/o);let n=[];const f=ce.reedSolomonComputeDivisor(p);for(let u=0,v=0;u<o;u++){let S=i.slice(v,v+g-p+(u<y?0:1));v+=S.length;const w=ce.reedSolomonComputeRemainder(S,f);u<y&&S.push(0),n.push(S.concat(w))}let h=[];for(let u=0;u<n[0].length;u++)n.forEach((v,S)=>{(u!=g-p||S>=y)&&h.push(v[u])});return m(h.length==_),h}drawCodewords(i){if(i.length!=Math.floor(ce.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let o=0;o<this.size;o++)for(let p=0;p<2;p++){const _=d-p,g=(d+1&2)==0?this.size-1-o:o;!this.isFunction[g][_]&&l<i.length*8&&(this.modules[g][_]=a(i[l>>>3],7-(l&7)),l++)}}m(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let d=0;d<this.size;d++){let o;switch(i){case 0:o=(d+l)%2==0;break;case 1:o=l%2==0;break;case 2:o=d%3==0;break;case 3:o=(d+l)%3==0;break;case 4:o=(Math.floor(d/3)+Math.floor(l/2))%2==0;break;case 5:o=d*l%2+d*l%3==0;break;case 6:o=(d*l%2+d*l%3)%2==0;break;case 7:o=((d+l)%2+d*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][d]&&o&&(this.modules[l][d]=!this.modules[l][d])}}getPenaltyScore(){let i=0;for(let p=0;p<this.size;p++){let _=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[p][n]==_?(y++,y==5?i+=ce.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),_||(i+=this.finderPenaltyCountPatterns(g)*ce.PENALTY_N3),_=this.modules[p][n],y=1);i+=this.finderPenaltyTerminateAndCount(_,y,g)*ce.PENALTY_N3}for(let p=0;p<this.size;p++){let _=!1,y=0,g=[0,0,0,0,0,0,0];for(let n=0;n<this.size;n++)this.modules[n][p]==_?(y++,y==5?i+=ce.PENALTY_N1:y>5&&i++):(this.finderPenaltyAddHistory(y,g),_||(i+=this.finderPenaltyCountPatterns(g)*ce.PENALTY_N3),_=this.modules[n][p],y=1);i+=this.finderPenaltyTerminateAndCount(_,y,g)*ce.PENALTY_N3}for(let p=0;p<this.size-1;p++)for(let _=0;_<this.size-1;_++){const y=this.modules[p][_];y==this.modules[p][_+1]&&y==this.modules[p+1][_]&&y==this.modules[p+1][_+1]&&(i+=ce.PENALTY_N2)}let l=0;for(const p of this.modules)l=p.reduce((_,y)=>_+(y?1:0),l);const d=this.size*this.size,o=Math.ceil(Math.abs(l*20-d*10)/d)-1;return m(0<=o&&o<=9),i+=o*ce.PENALTY_N4,m(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let o=this.size-7;d.length<i;o-=l)d.splice(1,0,o);return d}}static getNumRawDataModules(i){if(i<ce.MIN_VERSION||i>ce.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;l-=(25*d-10)*d-55,i>=7&&(l-=36)}return m(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(ce.getNumRawDataModules(i)/8)-ce.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*ce.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let o=0;o<i-1;o++)l.push(0);l.push(1);let d=1;for(let o=0;o<i;o++){for(let p=0;p<l.length;p++)l[p]=ce.reedSolomonMultiply(l[p],d),p+1<l.length&&(l[p]^=l[p+1]);d=ce.reedSolomonMultiply(d,2)}return l}static reedSolomonComputeRemainder(i,l){let d=l.map(o=>0);for(const o of i){const p=o^d.shift();d.push(0),l.forEach((_,y)=>d[y]^=ce.reedSolomonMultiply(_,p))}return d}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let d=0;for(let o=7;o>=0;o--)d=d<<1^(d>>>7)*285,d^=(l>>>o&1)*i;return m(d>>>8==0),d}finderPenaltyCountPatterns(i){const l=i[1];m(l<=this.size*3);const d=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(d&&i[0]>=l*4&&i[6]>=l?1:0)+(d&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,d){return i&&(this.finderPenaltyAddHistory(l,d),l=0),l+=this.size,this.finderPenaltyAddHistory(l,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function s(r,i,l){if(i<0||i>31||r>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)l.push(r>>>d&1)}function a(r,i){return(r>>>i&1)!=0}function m(r){if(!r)throw new Error("Assertion error")}const b=class ke{constructor(i,l,d){if(this.mode=i,this.numChars=l,this.bitData=d,l<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let l=[];for(const d of i)s(d,8,l);return new ke(ke.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!ke.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let d=0;d<i.length;){const o=Math.min(i.length-d,3);s(parseInt(i.substring(d,d+o),10),o*3+1,l),d+=o}return new ke(ke.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!ke.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],d;for(d=0;d+2<=i.length;d+=2){let o=ke.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;o+=ke.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),s(o,11,l)}return d<i.length&&s(ke.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,l),new ke(ke.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:ke.isNumeric(i)?[ke.makeNumeric(i)]:ke.isAlphanumeric(i)?[ke.makeAlphanumeric(i)]:[ke.makeBytes(ke.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)s(i,8,l);else if(i<16384)s(2,2,l),s(i,14,l);else if(i<1e6)s(6,3,l),s(i,21,l);else throw new RangeError("ECI assignment value out of range");return new ke(ke.Mode.ECI,0,l)}static isNumeric(i){return ke.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return ke.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let d=0;for(const o of i){const p=o.mode.numCharCountBits(l);if(o.numChars>=1<<p)return 1/0;d+=4+p+o.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?l.push(i.charCodeAt(d)):(l.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return l}};b.NUMERIC_REGEX=/^[0-9]*$/,b.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,b.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let C=b;e.QrSegment=b})(vt||(vt={}));(e=>{(t=>{const s=class{constructor(m,b){this.ordinal=m,this.formatBits=b}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(vt||(vt={}));(e=>{(t=>{const s=class{constructor(m,b){this.modeBits=m,this.numBitsCharCount=b}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(vt||(vt={}));var xt=vt;var Zf={L:xt.QrCode.Ecc.LOW,M:xt.QrCode.Ecc.MEDIUM,Q:xt.QrCode.Ecc.QUARTILE,H:xt.QrCode.Ecc.HIGH},ho=128,uo="L",fo="#FFFFFF",po="#000000",mo=!1,vo=1,Jf=4,ep=0,tp=.1;function go(e,t=0){const s=[];return e.forEach(function(a,m){let b=null;a.forEach(function(C,r){if(!C&&b!==null){s.push(`M${b+t} ${m+t}h${r-b}v1H${b+t}z`),b=null;return}if(r===a.length-1){if(!C)return;b===null?s.push(`M${r+t},${m+t} h1v1H${r+t}z`):s.push(`M${b+t},${m+t} h${r+1-b}v1H${b+t}z`);return}C&&b===null&&(b=r)})}),s.join("")}function _o(e,t){return e.slice().map((s,a)=>a<t.y||a>=t.y+t.h?s:s.map((m,b)=>b<t.x||b>=t.x+t.w?m:!1))}function sp(e,t,s,a){if(a==null)return null;const m=e.length+s*2,b=Math.floor(t*tp),C=m/t,r=(a.width||b)*C,i=(a.height||b)*C,l=a.x==null?e.length/2-r/2:a.x*C,d=a.y==null?e.length/2-i/2:a.y*C,o=a.opacity==null?1:a.opacity;let p=null;if(a.excavate){let y=Math.floor(l),g=Math.floor(d),n=Math.ceil(r+l-y),f=Math.ceil(i+d-g);p={x:y,y:g,w:n,h:f}}const _=a.crossOrigin;return{x:l,y:d,h:i,w:r,excavation:p,opacity:o,crossOrigin:_}}function rp(e,t){return t!=null?Math.max(Math.floor(t),0):e?Jf:ep}function bo({value:e,level:t,minVersion:s,includeMargin:a,marginSize:m,imageSettings:b,size:C,boostLevel:r}){let i=Z.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((g,n)=>(g.push(...xt.QrSegment.makeSegments(n)),g),[]);return xt.QrCode.encodeSegments(y,Zf[t],s,void 0,void 0,r)},[e,t,s,r]);const{cells:l,margin:d,numCells:o,calculatedImageSettings:p}=Z.useMemo(()=>{let _=i.getModules();const y=rp(a,m),g=_.length+y*2,n=sp(_,C,y,b);return{cells:_,margin:y,numCells:g,calculatedImageSettings:n}},[i,C,b,a,m]);return{qrcode:i,margin:d,cells:l,numCells:o,calculatedImageSettings:p}}var ip=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),np=Z.forwardRef(function(t,s){const a=t,{value:m,size:b=ho,level:C=uo,bgColor:r=fo,fgColor:i=po,includeMargin:l=mo,minVersion:d=vo,boostLevel:o,marginSize:p,imageSettings:_}=a,g=lr(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:n}=g,f=lr(g,["style"]),h=_?.src,u=Z.useRef(null),v=Z.useRef(null),S=Z.useCallback(I=>{u.current=I,typeof s=="function"?s(I):s&&(s.current=I)},[s]),[w,k]=Z.useState(!1),{margin:x,cells:E,numCells:A,calculatedImageSettings:j}=bo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:l,marginSize:p,imageSettings:_,size:b});Z.useEffect(()=>{if(u.current!=null){const I=u.current,F=I.getContext("2d");if(!F)return;let H=E;const z=v.current,D=j!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;D&&j.excavation!=null&&(H=_o(E,j.excavation));const M=window.devicePixelRatio||1;I.height=I.width=b*M;const P=b/A*M;F.scale(P,P),F.fillStyle=r,F.fillRect(0,0,A,A),F.fillStyle=i,ip?F.fill(new Path2D(go(H,x))):E.forEach(function(O,U){O.forEach(function(K,X){K&&F.fillRect(X+x,U+x,1,1)})}),j&&(F.globalAlpha=j.opacity),D&&F.drawImage(z,j.x+x,j.y+x,j.w,j.h)}}),Z.useEffect(()=>{k(!1)},[h]);const T=ar({height:b,width:b},n);let N=null;return h!=null&&(N=Z.createElement("img",{src:h,key:h,style:{display:"none"},onLoad:()=>{k(!0)},ref:v,crossOrigin:j?.crossOrigin})),Z.createElement(Z.Fragment,null,Z.createElement("canvas",ar({style:T,height:b,width:b,ref:S,role:"img"},f)),N)});np.displayName="QRCodeCanvas";var xo=Z.forwardRef(function(t,s){const a=t,{value:m,size:b=ho,level:C=uo,bgColor:r=fo,fgColor:i=po,includeMargin:l=mo,minVersion:d=vo,boostLevel:o,title:p,marginSize:_,imageSettings:y}=a,g=lr(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:n,cells:f,numCells:h,calculatedImageSettings:u}=bo({value:m,level:C,minVersion:d,boostLevel:o,includeMargin:l,marginSize:_,imageSettings:y,size:b});let v=f,S=null;y!=null&&u!=null&&(u.excavation!=null&&(v=_o(f,u.excavation)),S=Z.createElement("image",{href:y.src,height:u.h,width:u.w,x:u.x+n,y:u.y+n,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const w=go(v,n);return Z.createElement("svg",ar({height:b,width:b,viewBox:`0 0 ${h} ${h}`,ref:s,role:"img"},g),!!p&&Z.createElement("title",null,p),Z.createElement("path",{fill:r,d:`M0,0 h${h}v${h}H0z`,shapeRendering:"crispEdges"}),Z.createElement("path",{fill:i,d:w,shapeRendering:"crispEdges"}),S)});xo.displayName="QRCodeSVG";function op(){return nt({queryKey:le.tunnel.status,queryFn:()=>he.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?1e4:!1})}function ap(){const e=Te();return Ue({mutationFn:()=>{const t=parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10);return he.post("/tunnel/start",{port:t})},onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function lp(){const e=Te();return Ue({mutationFn:()=>he.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function Mi(){const{data:e}=op(),t=ap(),s=lp(),[a,m]=R.useState(!1),[b,C]=R.useState(null),r=R.useRef(null),[i,l]=R.useState({top:0,right:0}),[d,o]=R.useState(!1),p=e?.running??!1,_=t.isPending,y=e?.shareableUrl,g=e?.token;R.useEffect(()=>{if(a&&r.current){const v=r.current.getBoundingClientRect();l({top:v.bottom+8,right:window.innerWidth-v.right})}},[a]);const n=R.useCallback(()=>{p?m(!0):t.mutate(void 0,{onSuccess:()=>m(!0)})},[p,t]),f=R.useCallback(()=>{y&&(navigator.clipboard.writeText(y),C("url"),setTimeout(()=>C(null),2e3))},[y]),h=R.useCallback(()=>{g&&(navigator.clipboard.writeText(g),C("token"),setTimeout(()=>C(null),2e3))},[g]),u=R.useCallback(()=>{s.mutate(),m(!1),o(!1)},[s]);return c.jsxs("div",{className:"relative",children:[c.jsx("button",{ref:r,onClick:n,disabled:_,className:`p-1.5 rounded-md transition-colors ${p?"text-emerald-600 hover:bg-emerald-50":"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100"}`,title:p?"Tunnel active":"Share via tunnel",children:_?c.jsx(Ae,{size:16,className:"animate-spin"}):c.jsx(_s,{size:16})}),p&&!_&&c.jsx("span",{className:"absolute top-0.5 right-0.5 w-2 h-2 bg-emerald-500 rounded-full"}),a&&p&&_t.createPortal(c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>m(!1)}),c.jsxs("div",{className:"fixed z-[101] w-80 bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:i.top,right:i.right},children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("span",{className:"text-xs font-medium text-emerald-600 flex items-center gap-1.5",children:[c.jsx("span",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full inline-block"}),"Tunnel Active"]}),c.jsx("button",{onClick:()=>m(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:c.jsx(bs,{size:14})})]}),g&&c.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-emerald-50 rounded text-xs text-emerald-700",children:[c.jsx(Ma,{size:12}),c.jsx("span",{children:"Token protected"})]}),y&&c.jsx("div",{className:"flex justify-center py-3",children:c.jsx(xo,{value:y,size:160})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{readOnly:!0,value:y??e?.url??"",className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:v=>v.target.select()}),c.jsx("button",{onClick:f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",title:"Copy shareable link",children:b==="url"?c.jsx(as,{size:14,className:"text-emerald-500"}):c.jsx(Fr,{size:14})})]}),g&&c.jsxs("div",{className:"mt-2",children:[c.jsx("button",{onClick:()=>o(!d),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:d?"Hide token":"Show token"}),d&&c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsx("code",{className:"flex-1 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:g}),c.jsx("button",{onClick:h,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:"Copy token",children:b==="token"?c.jsx(as,{size:14,className:"text-emerald-500"}):c.jsx(Fr,{size:14})})]})]}),c.jsx("button",{onClick:u,disabled:s.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:s.isPending?"Stopping...":"Stop Tunnel"})]})]}),document.body)]})}const Ni={idle:"Create & Start","creating-task":"Creating Task...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},Mt=R.lazy(()=>Ii(()=>import("./modal-D7xekFRe.js").then(e=>e.m),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.Modal}))),Gs=R.lazy(()=>Ii(()=>import("./folder-picker-B7s6TEGt.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12])).then(e=>({default:e.FolderPicker}))),Pi=c.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-900",children:[c.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),c.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Oi=c.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),cp=260,hp=600,Bi=400;function Cp(){const[e,t]=R.useState(null),[s,a]=R.useState(null),[m,b]=R.useState(Bi),[C,r]=R.useState(!1),[i,l]=R.useState(!1),[d,o]=R.useState(""),[p,_]=R.useState(""),[y,g]=R.useState(""),[n,f]=R.useState(""),[h,u]=R.useState(""),[v,S]=R.useState(""),[w,k]=R.useState([]),[x,E]=R.useState("idle"),A=R.useRef(!1),j=R.useRef(0),T=R.useRef(Bi),N=R.useRef(null),I=Te(),{data:F,isLoading:H}=Ho(),z=F?.data??[],D=R.useMemo(()=>z.map(wf),[z]),M=R.useMemo(()=>z.map(q=>q.id),[z]);Tf(M);const{data:P,isLoading:O}=Rf(s??""),U=qo({queries:s?[]:z.map(q=>({queryKey:le.tasks.list(q.id),queryFn:()=>he.get(`/projects/${q.id}/tasks`,{params:{limit:"100"}})}))}),K=!s&&U.some(q=>q.isLoading),X=R.useMemo(()=>{if(s)return P?.data??[];const q=[];for(const ie of U)ie.data?.data&&q.push(...ie.data.data);return q},[s,P,U]),G=R.useMemo(()=>X.map(kf),[X]),ne=R.useMemo(()=>new Set,[]),L=R.useMemo(()=>{if(!e)return null;const q=G.find(pe=>pe.id===e);if(!q)return null;const ie=z.find(pe=>pe.id===q.projectId);return{id:q.id,projectId:q.projectId,projectName:ie?.name??"Unknown",projectColor:ie?.color??"text-neutral-500",title:q.title,status:q.status,branch:q.branch,mainBranch:ie?.mainBranch??"main",description:q.description}},[e,G,z]),B=zo(),$=Df(h),W=Af(),J=Lf(),Y=R.useCallback(q=>{W.mutate(q,{onSuccess:()=>{e===q&&t(null),I.invalidateQueries({queryKey:le.tasks.all})}})},[W,e,I]),oe=R.useCallback((q,ie)=>{J.mutate({id:q,status:Sf(ie)},{onError:()=>{Do.error("状态变更失败,该操作不被允许")}})},[J]),de=R.useCallback(q=>{q.preventDefault(),A.current=!0,j.current=q.clientX,T.current=m,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[m]);R.useEffect(()=>{const q=pe=>{if(!A.current)return;const Ie=pe.clientX-j.current,je=Math.max(cp,Math.min(hp,T.current+Ie));b(je)},ie=()=>{A.current&&(A.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ie)}},[]);const be=R.useCallback(()=>{r(!0)},[]),Ee=R.useCallback(()=>{u(s??z[0]?.id??""),S(""),E("idle"),l(!0),he.get("/demo/agents").then(q=>{k(q.agents);const ie=q.agents.find(pe=>pe.available);ie&&S(ie.type)})},[s,z]),te=R.useCallback(()=>{r(!1),o(""),_("")},[]),Re=R.useCallback(()=>{x==="idle"&&(l(!1),g(""),f(""),u(""),S(""),E("idle"))},[x]),De=R.useCallback(async()=>{if(!(!d.trim()||!p.trim()))try{await B.mutateAsync({name:d.trim(),repoPath:p.trim()}),te()}catch{}},[d,p,B,te]),Q=eo(),re=R.useCallback(async()=>{if(!(!y.trim()||!h))try{E("creating-task");const q=await $.mutateAsync({title:y.trim(),description:n.trim()||void 0});if(v){const ie=[y.trim(),n.trim()].filter(Boolean).join(`
82
-
83
- `);E("creating-workspace");const pe=await he.post(`/tasks/${q.id}/workspaces`,{});E("creating-session");const Ie=await he.post(`/workspaces/${pe.id}/sessions`,{agentType:v,prompt:ie});E("starting-session"),await Q.mutateAsync(Ie.id),await I.invalidateQueries({queryKey:le.workspaces.list(q.id)})}t(q.id),E("idle"),l(!1),g(""),f(""),u(""),S("")}catch{E("idle")}},[y,n,h,v,$,Q,I]),fe=H||O||K;return Pf()?e&&L?c.jsxs(c.Fragment,{children:[c.jsx(Gf,{task:L,onBack:()=>t(null),onDeleteTask:Y,isDeleting:W.isPending}),c.jsx(R.Suspense,{fallback:null,children:c.jsx(Mt,{isOpen:C,onClose:te,title:"Create New Project",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:te,className:"px-4 py-2 text-sm text-neutral-600",children:"Cancel"}),c.jsx("button",{onClick:De,disabled:!d.trim()||!p.trim()||B.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${d.trim()&&p.trim()&&!B.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:B.isPending?"Creating...":"Create"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),c.jsx("input",{type:"text",value:d,onChange:q=>o(q.target.value),placeholder:"e.g., Agent Tower",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),c.jsx(Gs,{value:p,onChange:_})]})]})})})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[c.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Pi,Oi]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Mi,{}),c.jsx(Mr,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:c.jsx(Or,{size:16})})]})]}),fe&&G.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:"Loading..."}):c.jsx(Jr,{tasks:G,projects:D,selectedTaskId:null,onSelectTask:t,filterProjectId:s,setFilterProjectId:a,width:"100%",onCreateProject:be,onCreateTask:Ee,activeTaskIds:ne,onTaskStatusChange:oe})]}),c.jsxs(R.Suspense,{fallback:null,children:[c.jsx(Mt,{isOpen:C,onClose:te,title:"Create New Project",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:te,className:"px-4 py-2 text-sm text-neutral-600",children:"Cancel"}),c.jsx("button",{onClick:De,disabled:!d.trim()||!p.trim()||B.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg ${d.trim()&&p.trim()&&!B.isPending?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:B.isPending?"Creating...":"Create"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),c.jsx("input",{type:"text",value:d,onChange:q=>o(q.target.value),placeholder:"e.g., Agent Tower",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400",autoFocus:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),c.jsx(Gs,{value:p,onChange:_})]})]})}),c.jsx(Mt,{isOpen:i,onClose:Re,title:"Create New Task",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:Re,disabled:x!=="idle",className:"px-4 py-2 text-sm text-neutral-600 disabled:opacity-50",children:"Cancel"}),c.jsx("button",{onClick:re,disabled:!y.trim()||!h||x!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg ${y.trim()&&h&&x==="idle"?"bg-neutral-900 text-white":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ni[x]})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex gap-3",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project"}),c.jsx(es,{value:h,onChange:u,options:z.map(q=>({value:q.id,label:q.name})),placeholder:"Select project...",disabled:x!=="idle"})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Agent"}),c.jsx(es,{value:v,onChange:S,options:w.map(q=>({value:q.type,label:q.name+(q.available&&q.version?` (${q.version})`:""),disabled:!q.available})),placeholder:w.length===0?"Loading...":"Select agent...",disabled:x!=="idle"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Task Title"}),c.jsx("input",{type:"text",value:y,onChange:q=>g(q.target.value),placeholder:"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",disabled:x!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&re()}})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Description"}),c.jsx("textarea",{rows:3,value:n,onChange:q=>f(q.target.value),placeholder:"Optional...",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 resize-none",disabled:x!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&re()}})]})]})})]})]}):c.jsxs("div",{ref:N,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[c.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:[c.jsxs("div",{className:"flex items-center gap-2",children:[Pi,Oi]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Mi,{}),c.jsx(Mr,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:c.jsx(Or,{size:16})})]})]}),c.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[fe&&G.length===0?c.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:m},children:"Loading..."}):c.jsx(Jr,{tasks:G,projects:D,selectedTaskId:e,onSelectTask:t,filterProjectId:s,setFilterProjectId:a,width:m,onCreateProject:be,onCreateTask:Ee,activeTaskIds:ne,onTaskStatusChange:oe,onDeleteTask:Y}),c.jsx("div",{onMouseDown:de,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:"Drag to resize"}),c.jsx(bf,{task:L,onDeleteTask:Y,isDeleting:W.isPending,onTaskStatusChange:oe})]}),c.jsxs(R.Suspense,{fallback:null,children:[c.jsx(Mt,{isOpen:C,onClose:te,title:"Create New Project",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:te,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors",children:"Cancel"}),c.jsx("button",{onClick:De,disabled:!d.trim()||!p.trim()||B.isPending,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${d.trim()&&p.trim()&&!B.isPending?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:B.isPending?"Creating...":"Create Project"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project Name"}),c.jsx("input",{type:"text",value:d,onChange:q=>o(q.target.value),placeholder:"e.g., Agent Tower",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors",autoFocus:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Repository Path"}),c.jsx(Gs,{value:p,onChange:_})]}),B.isError&&c.jsx("p",{className:"text-xs text-red-500",children:B.error instanceof Error?B.error.message:"Failed to create project"})]})}),c.jsx(Mt,{isOpen:i,onClose:Re,title:"Create New Task",action:c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:Re,disabled:x!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:"Cancel"}),c.jsx("button",{onClick:re,disabled:!y.trim()||!h||x!=="idle",className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${y.trim()&&h&&x==="idle"?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:Ni[x]})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex gap-3",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Project"}),c.jsx(es,{value:h,onChange:u,options:z.map(q=>({value:q.id,label:q.name})),placeholder:"Select project...",disabled:x!=="idle"})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Agent"}),c.jsx(es,{value:v,onChange:S,options:w.map(q=>({value:q.type,label:q.name+(q.available&&q.version?` (${q.version})`:""),disabled:!q.available})),placeholder:w.length===0?"Loading...":"Select agent...",disabled:x!=="idle"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Task Title"}),c.jsx("input",{type:"text",value:y,onChange:q=>g(q.target.value),placeholder:"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:x!=="idle",onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&re()}})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:"Description"}),c.jsx("textarea",{rows:3,value:n,onChange:q=>f(q.target.value),placeholder:"Optional description...",className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors resize-none",disabled:x!=="idle",onKeyDown:q=>{(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&!q.nativeEvent.isComposing&&q.nativeEvent.keyCode!==229&&re()}})]}),$.isError&&c.jsx("p",{className:"text-xs text-red-500",children:$.error instanceof Error?$.error.message:"Failed to create task"})]})})]})]})}export{Cp as ProjectKanbanPage};