agent-tower 0.5.3-beta.0 → 0.5.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/agent-icons/claude-code.svg +1 -0
- package/dist/web/agent-icons/codex.svg +1 -0
- package/dist/web/agent-icons/cursor-agent.svg +1 -0
- package/dist/web/agent-icons/gemini-cli.svg +1 -0
- package/dist/web/assets/AgentDemoPage-Cc1sKLmE.js +1 -0
- package/dist/web/assets/AgentLogo-DQId6FqS.js +1 -0
- package/dist/web/assets/{ConversationPage-Cyiw8Hra.js → ConversationPage-BXDIbwTR.js} +2 -2
- package/dist/web/assets/CreateTaskInput-CDynnXvO.js +2 -0
- package/dist/web/assets/{DemoPage-SywVXjL0.js → DemoPage-BeL28u5_.js} +2 -2
- package/dist/web/assets/{GeneralSettingsPage-CTymytF6.js → GeneralSettingsPage-CFc1CWWl.js} +1 -1
- package/dist/web/assets/{Icons-DmLVnVdg.js → Icons-EVcY239B.js} +1 -1
- package/dist/web/assets/LoadingPreviewPage-CRwEvHz_.js +1 -0
- package/dist/web/assets/{McpSettingsPage-DyolUN8C.js → McpSettingsPage-BujDKp8T.js} +1 -1
- package/dist/web/assets/{MemberAvatar-u6jTOiDY.js → MemberAvatar-Bvlu6rk3.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-BBop2Bu4.js → NotificationSettingsPage-Dsn-5Uft.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-Bw-eI0cF.js → ProfileSettingsPage-CuhQBP_t.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-BFf2FZVz.js → ProjectKanbanPage-DiEo6BK_.js} +34 -34
- package/dist/web/assets/{ProjectSettingsPage-BJ4sOhMl.js → ProjectSettingsPage-Cj46vZYF.js} +1 -1
- package/dist/web/assets/ProviderSettingsPage-G7pPagR6.js +54 -0
- package/dist/web/assets/{SettingsMasterDetail-CdimTj5n.js → SettingsMasterDetail-_vE8P7ke.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-CqQTc5AI.js → TeamSettingsPage-CC_QgVbE.js} +1 -1
- package/dist/web/assets/arc-DWusz5nt.js +1 -0
- package/dist/web/assets/architectureDiagram-3BPJPVTR-BzUiKOFe.js +36 -0
- package/dist/web/assets/{arrow-left-B6KMicbE.js → arrow-left-C_pxdzZL.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-6_0hov2h.js → blockDiagram-GPEHLZMM-BGx2sLYW.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-Br6Tzu3R.js → c4Diagram-AAUBKEIU-BCihVD7R.js} +1 -1
- package/dist/web/assets/channel-BBvaRDfe.js +1 -0
- package/dist/web/assets/check-C7Na6M49.js +1 -0
- package/dist/web/assets/{chevron-down-Cur5jANy.js → chevron-down-DuZqUX3d.js} +1 -1
- package/dist/web/assets/{chevron-right-R3KVa8oQ.js → chevron-right-BTjA7BSq.js} +1 -1
- package/dist/web/assets/{chevron-up-DcLdFanO.js → chevron-up-BeZXjQ4W.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-D8zyttB-.js → chunk-2J33WTMH-BVhYZ0vK.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-Cqi9xJ8M.js → chunk-4BX2VUAB-amtolJb4.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Dxjaitf1.js → chunk-55IACEB6-Bi5q9Evi.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-CAn8Y9XB.js → chunk-727SXJPM-Bb_qV3PR.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-B4sECH9U.js → chunk-AQP2D5EJ-BhFBU2pH.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-Ckd3e1dg.js → chunk-FMBD7UC4-CbBz10YF.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-h5WBT7BK.js → chunk-ND2GUHAM-B930BNNl.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-Cdzk46MK.js → chunk-QZHKN3VN-YlRfC0oD.js} +1 -1
- package/dist/web/assets/{circle-alert-OKyZ9U2p.js → circle-alert-DCm2E91k.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-XuAtffBc.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-XuAtffBc.js +1 -0
- package/dist/web/assets/code-block-OCS4YCEC-ImXQka3_.js +2 -0
- package/dist/web/assets/{confirm-dialog-BAnxa2C9.js → confirm-dialog-Cc27tq8j.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-CbFey2pd.js → cose-bilkent-S5V4N54A-Di3PzbLp.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-Bd2eIyf3.js → dagre-BM42HDAG-DD7qiU9m.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CXONvVnW.js → diagram-2AECGRRQ-Bgr-CjRi.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-B2E90mVs.js → diagram-5GNKFQAL-CvRORhH2.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-ByaC99pb.js → diagram-KO2AKTUF-CkVyLyvM.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DwVBF2fn.js → diagram-LMA3HP47-B-CPQQuU.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-FWRddceo.js → diagram-OG6HWLK6-DXow9CgH.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-ye6i3SGj.js → erDiagram-TEJ5UH35-BPLJJwjL.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-B6l7qTcg.js → flowDiagram-I6XJVG4X-ggyugmK6.js} +1 -1
- package/dist/web/assets/{folder-B0m3OL2U.js → folder-B35uD7uF.js} +1 -1
- package/dist/web/assets/{folder-picker-D5XrSfLA.js → folder-picker-DFxfUtH5.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-BCCqDrep.js → ganttDiagram-6RSMTGT7-317n6mcW.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-Ca4ANaSw.js → gitGraphDiagram-PVQCEYII-DTUyiJew.js} +1 -1
- package/dist/web/assets/{index-C9hQg1KT.js → index-BwKL3rKp.js} +5 -5
- package/dist/web/assets/index-DgO-2xBV.css +1 -0
- package/dist/web/assets/{index-DbO4YyUv.js → index-OY1TIdAK.js} +116 -9
- package/dist/web/assets/{infoDiagram-5YYISTIA-D1V1Tezr.js → infoDiagram-5YYISTIA-1GXYdkvW.js} +1 -1
- package/dist/web/assets/{input-Dqnd4oTj.js → input-6lLP89Y3.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DnGiJn9p.js → ishikawaDiagram-YF4QCWOH-DSGxwLxL.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-QFxbLfhN.js → journeyDiagram-JHISSGLW-Bk9wMzSo.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BA2nBc7B.js → kanban-definition-UN3LZRKU-BW3QAONh.js} +4 -4
- package/dist/web/assets/{layers-CfFYGUtI.js → layers-CDcLPjE5.js} +1 -1
- package/dist/web/assets/{linear-DpASQZmA.js → linear-DTyT0tZy.js} +1 -1
- package/dist/web/assets/{loader-circle-B5Lfi46Y.js → loader-circle-DDrZegLO.js} +1 -1
- package/dist/web/assets/mermaid-NOHMQCX5-CeIvIbfU.js +122 -0
- package/dist/web/assets/{message-square-CEefL0sf.js → message-square-CunpcgQi.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-C7QuD-ms.js → mindmap-definition-RKZ34NQL-CMuh1LCP.js} +2 -2
- package/dist/web/assets/{modal-CAB_bs-c.js → modal-D8uSzIAd.js} +1 -1
- package/dist/web/assets/{pencil-B__GQn9r.js → pencil-BTaYfjKo.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-Bf5diCKb.js → pieDiagram-4H26LBE5-8PB3-bCK.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-BMbcPnH3.js → quadrantDiagram-W4KKPZXB-Dpf14KEr.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-CUPvJXMk.js → requirementDiagram-4Y6WPE33-ClTLx63o.js} +1 -1
- package/dist/web/assets/{rotate-ccw-5d-eMwsw.js → rotate-ccw-bVmcWqcA.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-C77g6vmK.js → sankeyDiagram-5OEKKPKP-ChlGi0jn.js} +1 -1
- package/dist/web/assets/select-tNVeGe-v.js +1 -0
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-xGOV8CdQ.js → sequenceDiagram-3UESZ5HK-6tJ810tk.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Bc0piegy.js → stateDiagram-AJRCARHV-Cc5dwA5r.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-EVHRu9u3.js +1 -0
- package/dist/web/assets/{switch-bLlDOWNp.js → switch-7jE2n-KP.js} +1 -1
- package/dist/web/assets/{terminal-Bh2qSv0U.js → terminal-D5iU4zAj.js} +1 -1
- package/dist/web/assets/{textarea-BcVRpxhF.js → textarea-DVa2Yvj4.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-CcACRt_V.js → timeline-definition-PNZ67QCA-q32Hcn4m.js} +3 -3
- package/dist/web/assets/{trash-2-8Pu6lwnW.js → trash-2-z7TLHqpU.js} +1 -1
- package/dist/web/assets/{upload-DNwyW_bv.js → upload-DeI535ZH.js} +1 -1
- package/dist/web/assets/{use-profiles-BIqkQu69.js → use-profiles-BS_Mkp5d.js} +1 -1
- package/dist/web/assets/{use-providers-BOyY0DcV.js → use-providers-CWfLQ--R.js} +1 -1
- package/dist/web/assets/useNormalizedLogs-DW37m6Ji.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-BC9RHBQ5.js → vennDiagram-CIIHVFJN-VxBXMI4P.js} +5 -5
- package/dist/web/assets/{wardley-L42UT6IY-BgPj73Dc.js → wardley-L42UT6IY-BvNOQGfh.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-PbfDUndy.js → wardleyDiagram-YWT4CUSO-DMTZkLB4.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-D87KYJUM.js → xychartDiagram-2RQKCTM6-BaJ2kymJ.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/AgentDemoPage-CUgqAjq9.js +0 -1
- package/dist/web/assets/CreateTaskInput-BILlpv9b.js +0 -2
- package/dist/web/assets/ProviderSettingsPage-BlLaN0i2.js +0 -54
- package/dist/web/assets/arc-Ddp5hhH6.js +0 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-CpK7WDLU.js +0 -36
- package/dist/web/assets/channel-Bg_GO2e9.js +0 -1
- package/dist/web/assets/check-D9lM__p8.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BeJctdRx.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BeJctdRx.js +0 -1
- package/dist/web/assets/code-block-OCS4YCEC-VMJOsrkF.js +0 -2
- package/dist/web/assets/index-C4twOgZR.css +0 -1
- package/dist/web/assets/log-adapter-CjgRCCYG.js +0 -1
- package/dist/web/assets/mermaid-NOHMQCX5-7FmPQynq.js +0 -122
- package/dist/web/assets/select-BJfNuuIV.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CiRT9t6d.js +0 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{$ as en,a0 as qn,a1 as Fc,a2 as zc,a3 as Hc,a4 as Ii,a5 as Wc,a6 as $c,k as ot,a7 as Uc,a8 as qc,r as C,a9 as Kc,aa as Xc,ab as Vc,ac as Yc,ad as Kn,ae as Xn,af as Gc,ag as Qc,ah as Zc,h as De,ai as le,G as Jt,i as Rt,l as _t,m as he,q as ie,u as ce,j as t,U as ft,L as Jc,g as ee,B as ke,aj as ha,ak as fa,al as ma,_ as us,X as is,am as ed,an as td,s as sd,ao as rd,ap as id,aq as nd,t as ct,H as Zt,I as at,J as ws,ar as pa,as as tn,Z as od,at as ga,au as sn,av as va,aw as xa,ax as _a,ay as ad,az as ld,aA as cd,aB as dd,aC as ud,K as Vn,T as Yn}from"./index-DbO4YyUv.js";import{S as rt,W as ls,a as Et,C as Vs,A as Bt,T as It}from"./log-adapter-CjgRCCYG.js";import{C as qr}from"./confirm-dialog-BAnxa2C9.js";import{c as ba,a as ya,b as Sa,I as wa,d as Ca,A as Gn,G as ka}from"./Icons-DmLVnVdg.js";import{C as xt}from"./chevron-down-Cur5jANy.js";import{C as Nt}from"./chevron-right-R3KVa8oQ.js";import{f as rn,S as hd,b as nn,u as on,A as Ys,c as an,d as ln,g as fd,F as Ea,G as ja,Z as md,I as Na,T as cn,h as pd,a as Ra,P as Aa,i as gd,C as Qn,B as Zn,e as Jn}from"./CreateTaskInput-BILlpv9b.js";import{a as vd,F as xd,f as _d,g as bd,e as yd,u as Sd}from"./folder-picker-D5XrSfLA.js";import{M as Kr}from"./message-square-CEefL0sf.js";import{L as Ns}from"./layers-CfFYGUtI.js";import{S as Rs,P as dn,Q as un,s as wd,c as hn,u as Ma,a as Ta,b as Nr,T as Rr}from"./mermaid-NOHMQCX5-7FmPQynq.js";import{M as Ft}from"./MemberAvatar-u6jTOiDY.js";import{C as Da}from"./chevron-up-DcLdFanO.js";import{C as qt}from"./check-D9lM__p8.js";import{M as Ms,T as tr}from"./modal-CAB_bs-c.js";import{S as cs}from"./select-BJfNuuIV.js";import{u as sr}from"./use-providers-BOyY0DcV.js";import{P as es,T as fn}from"./trash-2-8Pu6lwnW.js";import{T as Ar,C as eo}from"./terminal-Bh2qSv0U.js";import{F as La}from"./folder-B0m3OL2U.js";import{L as Xe}from"./loader-circle-B5Lfi46Y.js";import{U as Mr,C as Cd}from"./upload-DNwyW_bv.js";import{A as Gs}from"./arrow-left-B6KMicbE.js";import{R as kd}from"./rotate-ccw-5d-eMwsw.js";import"./circle-alert-OKyZ9U2p.js";var Ed=class extends en{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:qn()})}getOptimisticResult(e){return e.behavior=qn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,n=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:i}=n,o=r.fetchMeta?.fetchMore?.direction,l=v&&o==="forward",u=p&&o==="forward",c=v&&o==="backward",g=p&&o==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:zc(s,r.data),hasPreviousPage:Fc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!l&&!c,isRefetching:m&&!u&&!g}}};function to(e,s){const r=new Set(s);return e.filter(n=>!r.has(n))}function jd(e,s,r){const n=e.slice(0);return n[s]=r,n}var Nd=class extends Hc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Ii.batch(()=>{const r=this.#t,n=this.#h(this.#i);n.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const p=n.map(u=>u.observer),m=p.map(u=>u.getCurrentResult()),v=r.length!==p.length,i=p.some((u,c)=>u!==r[c]),o=v||i,l=o?!0:m.some((u,c)=>{const g=this.#e[c];return!g||!Wc(u,g)});!o&&!l||(o&&(this.#c=n,this.#t=p),this.#e=m,this.hasListeners()&&(o&&(to(r,p).forEach(u=>{u.destroy()}),to(p,r).forEach(u=>{u.subscribe(c=>{this.#f(u,c)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),n=r.map(m=>m.observer.getOptimisticResult(m.defaultedQueryOptions)),p=r.map(m=>m.defaultedQueryOptions.queryHash);return[n,m=>this.#u(m??n,s,p),()=>this.#d(n,r)]}#d(e,s){return s.map((r,n)=>{const p=e[n];return r.defaultedQueryOptions.notifyOnChangeProps?p:r.observer.trackResult(p,m=>{s.forEach(v=>{v.observer.trackProp(m)})})})}#u(e,s,r){if(s){const n=this.#l,p=r!==void 0&&n!==void 0&&(n.length!==r.length||r.some((m,v)=>m!==n[v]));return(!this.#s||this.#e!==this.#a||p||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=$c(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(n=>{const p=n.options.queryHash;if(!p)return;const m=s.get(p);m?m.push(n):s.set(p,[n])});const r=[];return e.forEach(n=>{const p=this.#r.defaultQueryOptions(n),v=s.get(p.queryHash)?.shift()??new en(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=jd(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Ii.batch(()=>{this.listeners.forEach(n=>{n(this.#e)})})}}};function Rd({queries:e,...s},r){const n=ot(),p=Uc(),m=qc(),v=C.useMemo(()=>e.map(x=>{const a=n.defaultQueryOptions(x);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,n,p]);v.forEach(x=>{Kc(x);const a=n.getQueryCache().get(x.queryHash);Xc(x,m,a)}),Vc(m);const[i]=C.useState(()=>new Nd(n,v,s)),[o,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(x=>c?i.subscribe(Ii.batchCalls(x)):Yc,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const _=o.some((x,a)=>Kn(v[a],x))?o.flatMap((x,a)=>{const h=v[a];if(h){const d=new en(n,h);if(Kn(h,x))return Xn(h,d,m);Gc(x,p)&&Xn(h,d,m)}return[]}):[];if(_.length>0)throw Promise.all(_);const y=o.find((x,a)=>{const h=v[a];return h&&Qc({result:x,errorResetBoundary:m,throwOnError:h.throwOnError,query:n.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return l(u())}function mn(e,s){return Zc(e,Ed)}const Ad=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Md=De("arrow-right",Ad);const Td=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Pa=De("ban",Td);const Dd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ld=De("chevron-left",Dd);const Pd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Cs=De("clock-3",Pd);const Od=[["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"}]],rr=De("code-xml",Od);const Id=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],so=De("copy-plus",Id);const Bd=[["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"}]],Oa=De("ellipsis-vertical",Bd);const Fd=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],pn=De("external-link",Fd);const zd=[["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"}]],Hd=De("file-braces-corner",zd);const Wd=[["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"}]],Tr=De("file-code-corner",Wd);const $d=[["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"}]],Ud=De("file-exclamation-point",$d);const qd=[["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"}]],Xr=De("folder-open",qd);const Kd=[["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"}]],Ts=De("git-graph",Kd);const Xd=[["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"}]],As=De("history",Xd);const Vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Yd=De("info",Vd);const Gd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],Qd=De("lock-keyhole",Gd);const Zd=[["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"}]],Jd=De("maximize",Zd);const eu=[["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"}]],tu=De("panel-left-close",eu);const su=[["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"}]],ru=De("panel-left-open",su);const iu=[["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"}]],nu=De("panel-right-close",iu);const ou=[["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"}]],Bi=De("panel-right-open",ou);const au=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],lu=De("pen-line",au);const cu=[["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"}]],Ut=De("play",cu);const du=[["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"}]],ir=De("refresh-cw",du);const uu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],hu=De("save",uu);const fu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ia=De("settings-2",fu);const mu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],ro=De("smartphone",mu);const pu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],xr=De("user-plus",pu);const gu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],vu=De("zoom-in",gu);const xu=[["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"}]],_u=De("zoom-out",xu),Vr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ds(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function gn(e){return"nodeType"in e}function vt(e){var s,r;return e?Ds(e)?e:gn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function vn(e){const{Document:s}=vt(e);return e instanceof s}function nr(e){return Ds(e)?!1:e instanceof vt(e).HTMLElement}function Ba(e){return e instanceof vt(e).SVGElement}function Ls(e){return e?Ds(e)?e.document:gn(e)?vn(e)?e:nr(e)||Ba(e)?e.ownerDocument:document:document:document}const Kt=Vr?C.useLayoutEffect:C.useEffect;function Yr(e){const s=C.useRef(e);return Kt(()=>{s.current=e}),C.useCallback(function(){for(var r=arguments.length,n=new Array(r),p=0;p<r;p++)n[p]=arguments[p];return s.current==null?void 0:s.current(...n)},[])}function bu(){const e=C.useRef(null),s=C.useCallback((n,p)=>{e.current=setInterval(n,p)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Qs(e,s){s===void 0&&(s=[e]);const r=C.useRef(e);return Kt(()=>{r.current!==e&&(r.current=e)},s),r}function or(e,s){const r=C.useRef();return C.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...s])}function Dr(e){const s=Yr(e),r=C.useRef(null),n=C.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,n]}function Lr(e){const s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}let gi={};function Gr(e,s){return C.useMemo(()=>{if(s)return s;const r=gi[e]==null?0:gi[e]+1;return gi[e]=r,e+"-"+r},[e,s])}function Fa(e){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),p=1;p<r;p++)n[p-1]=arguments[p];return n.reduce((m,v)=>{const i=Object.entries(v);for(const[o,l]of i){const u=m[o];u!=null&&(m[o]=u+e*l)}return m},{...s})}}const js=Fa(1),Pr=Fa(-1);function yu(e){return"clientX"in e&&"clientY"in e}function xn(e){if(!e)return!1;const{KeyboardEvent:s}=vt(e.target);return s&&e instanceof s}function Su(e){if(!e)return!1;const{TouchEvent:s}=vt(e.target);return s&&e instanceof s}function Or(e){if(Su(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return yu(e)?{x:e.clientX,y:e.clientY}:null}const Zs=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Zs.Translate.toString(e),Zs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:n}=e;return s+" "+r+"ms "+n}}}),io="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function wu(e){return e.matches(io)?e:e.querySelector(io)}const Cu={display:"none"};function ku(e){let{id:s,value:r}=e;return le.createElement("div",{id:s,style:Cu},r)}function Eu(e){let{id:s,announcement:r,ariaLiveType:n="assertive"}=e;const p={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 le.createElement("div",{id:s,style:p,role:"status","aria-live":n,"aria-atomic":!0},r)}function ju(){const[e,s]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&s(n)},[]),announcement:e}}const za=C.createContext(null);function Nu(e){const s=C.useContext(za);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Ru(){const[e]=C.useState(()=>new Set),s=C.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[C.useCallback(n=>{let{type:p,event:m}=n;e.forEach(v=>{var i;return(i=v[p])==null?void 0:i.call(v,m)})},[e]),s]}const Au={draggable:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BwKL3rKp.js","assets/index-OY1TIdAK.js","assets/index-DgO-2xBV.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a2 as en,a3 as qn,a4 as zc,a5 as Wc,a6 as Hc,a7 as Ii,a8 as $c,a9 as Uc,k as ot,aa as qc,ab as Kc,r as C,ac as Xc,ad as Vc,ae as Yc,af as Gc,ag as Kn,ah as Xn,ai as Qc,aj as Zc,ak as Jc,h as Oe,al as de,H as Jt,i as Rt,l as _t,m as me,q as ae,u as ue,j as t,Y as ft,M as ed,g as ee,B as Te,am as ha,an as fa,ao as ma,a1 as us,X as is,ap as td,aq as sd,s as rd,ar as id,as as nd,at as od,t as ct,I as Zt,J as at,K as ws,au as pa,av as tn,$ as ad,aw as ga,ax as sn,ay as va,az as xa,aA as _a,aB as ld,aC as cd,aD as dd,aE as ud,aF as hd,N as Vn,W as Yn}from"./index-OY1TIdAK.js";import{S as rt,Q as rn,h as fd,i as nn,W as ls,j as Et,C as Vs,A as Bt,b as jr,T as It}from"./mermaid-NOHMQCX5-CeIvIbfU.js";import{C as Ur}from"./confirm-dialog-Cc27tq8j.js";import{c as ba,a as ya,b as Sa,I as wa,d as Ca,A as Gn,G as ka}from"./Icons-EVcY239B.js";import{C as xt}from"./chevron-down-DuZqUX3d.js";import{C as Nt}from"./chevron-right-BTjA7BSq.js";import{f as on,S as md,b as an,u as ln,A as Ys,c as cn,d as dn,g as pd,F as Ea,G as ja,Z as gd,I as Na,T as un,h as vd,a as Ra,P as Aa,i as xd,C as Qn,B as Zn,e as Jn}from"./CreateTaskInput-CDynnXvO.js";import{a as _d,F as bd,f as yd,g as Sd,e as wd,u as Cd}from"./folder-picker-DFxfUtH5.js";import{M as qr}from"./message-square-CunpcgQi.js";import{L as Ns}from"./layers-CDcLPjE5.js";import{S as Rs,P as hn,u as Ma,a as Ta,T as Nr}from"./useNormalizedLogs-DW37m6Ji.js";import{M as Ft}from"./MemberAvatar-Bvlu6rk3.js";import{C as Da}from"./chevron-up-BeZXjQ4W.js";import{C as qt}from"./check-C7Na6M49.js";import{M as Ms,T as tr}from"./modal-D8uSzIAd.js";import{S as cs}from"./select-tNVeGe-v.js";import{u as sr}from"./use-providers-CWfLQ--R.js";import{P as es,T as fn}from"./trash-2-z7TLHqpU.js";import{T as Rr,C as eo}from"./terminal-D5iU4zAj.js";import{F as La}from"./folder-B35uD7uF.js";import{L as Ye}from"./loader-circle-DDrZegLO.js";import{U as Ar,C as kd}from"./upload-DeI535ZH.js";import{A as Gs}from"./arrow-left-C_pxdzZL.js";import{A as Pa}from"./AgentLogo-DQId6FqS.js";import{R as Ed}from"./rotate-ccw-bVmcWqcA.js";import"./circle-alert-DCm2E91k.js";var jd=class extends en{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:qn()})}getOptimisticResult(e){return e.behavior=qn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,l=v&&n==="forward",u=p&&n==="forward",c=v&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Wc(s,r.data),hasPreviousPage:zc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!l&&!c,isRefetching:m&&!u&&!g}}};function to(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function Nd(e,s,r){const o=e.slice(0);return o[s]=r,o}var Rd=class extends Hc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Ii.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const p=o.map(u=>u.observer),m=p.map(u=>u.getCurrentResult()),v=r.length!==p.length,i=p.some((u,c)=>u!==r[c]),n=v||i,l=n?!0:m.some((u,c)=>{const g=this.#e[c];return!g||!$c(u,g)});!n&&!l||(n&&(this.#c=o,this.#t=p),this.#e=m,this.hasListeners()&&(n&&(to(r,p).forEach(u=>{u.destroy()}),to(p,r).forEach(u=>{u.subscribe(c=>{this.#f(u,c)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),o=r.map(m=>m.observer.getOptimisticResult(m.defaultedQueryOptions)),p=r.map(m=>m.defaultedQueryOptions.queryHash);return[o,m=>this.#u(m??o,s,p),()=>this.#d(o,r)]}#d(e,s){return s.map((r,o)=>{const p=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?p:r.observer.trackResult(p,m=>{s.forEach(v=>{v.observer.trackProp(m)})})})}#u(e,s,r){if(s){const o=this.#l,p=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((m,v)=>m!==o[v]));return(!this.#s||this.#e!==this.#a||p||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Uc(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(o=>{const p=o.options.queryHash;if(!p)return;const m=s.get(p);m?m.push(o):s.set(p,[o])});const r=[];return e.forEach(o=>{const p=this.#r.defaultQueryOptions(o),v=s.get(p.queryHash)?.shift()??new en(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Nd(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Ii.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Ad({queries:e,...s},r){const o=ot(),p=qc(),m=Kc(),v=C.useMemo(()=>e.map(x=>{const a=o.defaultQueryOptions(x);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,o,p]);v.forEach(x=>{Xc(x);const a=o.getQueryCache().get(x.queryHash);Vc(x,m,a)}),Yc(m);const[i]=C.useState(()=>new Rd(o,v,s)),[n,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(x=>c?i.subscribe(Ii.batchCalls(x)):Gc,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const _=n.some((x,a)=>Kn(v[a],x))?n.flatMap((x,a)=>{const h=v[a];if(h){const d=new en(o,h);if(Kn(h,x))return Xn(h,d,m);Qc(x,p)&&Xn(h,d,m)}return[]}):[];if(_.length>0)throw Promise.all(_);const y=n.find((x,a)=>{const h=v[a];return h&&Zc({result:x,errorResetBoundary:m,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return l(u())}function mn(e,s){return Jc(e,jd)}const Md=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Td=Oe("arrow-right",Md);const Dd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oa=Oe("ban",Dd);const Ld=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Pd=Oe("chevron-left",Ld);const Od=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Cs=Oe("clock-3",Od);const Id=[["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"}]],Kr=Oe("code-xml",Id);const Bd=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],so=Oe("copy-plus",Bd);const Fd=[["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"}]],Ia=Oe("ellipsis-vertical",Fd);const zd=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],pn=Oe("external-link",zd);const Wd=[["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"}]],Hd=Oe("file-braces-corner",Wd);const $d=[["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"}]],Mr=Oe("file-code-corner",$d);const Ud=[["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"}]],qd=Oe("file-exclamation-point",Ud);const Kd=[["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"}]],Xr=Oe("folder-open",Kd);const Xd=[["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"}]],Ts=Oe("git-graph",Xd);const Vd=[["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"}]],As=Oe("history",Vd);const Yd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Gd=Oe("info",Yd);const Qd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],Zd=Oe("lock-keyhole",Qd);const Jd=[["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"}]],eu=Oe("maximize",Jd);const tu=[["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"}]],su=Oe("panel-left-close",tu);const ru=[["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"}]],iu=Oe("panel-left-open",ru);const nu=[["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"}]],ou=Oe("panel-right-close",nu);const au=[["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"}]],Bi=Oe("panel-right-open",au);const lu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],cu=Oe("pen-line",lu);const du=[["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"}]],Ut=Oe("play",du);const uu=[["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"}]],rr=Oe("refresh-cw",uu);const hu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],fu=Oe("save",hu);const mu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ba=Oe("settings-2",mu);const pu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],ro=Oe("smartphone",pu);const gu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],vr=Oe("user-plus",gu);const vu=[["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"}]],xu=Oe("zoom-in",vu);const _u=[["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"}]],bu=Oe("zoom-out",_u),Vr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ds(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function gn(e){return"nodeType"in e}function vt(e){var s,r;return e?Ds(e)?e:gn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function vn(e){const{Document:s}=vt(e);return e instanceof s}function ir(e){return Ds(e)?!1:e instanceof vt(e).HTMLElement}function Fa(e){return e instanceof vt(e).SVGElement}function Ls(e){return e?Ds(e)?e.document:gn(e)?vn(e)?e:ir(e)||Fa(e)?e.ownerDocument:document:document:document}const Kt=Vr?C.useLayoutEffect:C.useEffect;function Yr(e){const s=C.useRef(e);return Kt(()=>{s.current=e}),C.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function yu(){const e=C.useRef(null),s=C.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Qs(e,s){s===void 0&&(s=[e]);const r=C.useRef(e);return Kt(()=>{r.current!==e&&(r.current=e)},s),r}function nr(e,s){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Tr(e){const s=Yr(e),r=C.useRef(null),o=C.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Dr(e){const s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}let gi={};function Gr(e,s){return C.useMemo(()=>{if(s)return s;const r=gi[e]==null?0:gi[e]+1;return gi[e]=r,e+"-"+r},[e,s])}function za(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,v)=>{const i=Object.entries(v);for(const[n,l]of i){const u=m[n];u!=null&&(m[n]=u+e*l)}return m},{...s})}}const js=za(1),Lr=za(-1);function Su(e){return"clientX"in e&&"clientY"in e}function xn(e){if(!e)return!1;const{KeyboardEvent:s}=vt(e.target);return s&&e instanceof s}function wu(e){if(!e)return!1;const{TouchEvent:s}=vt(e.target);return s&&e instanceof s}function Pr(e){if(wu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Su(e)?{x:e.clientX,y:e.clientY}:null}const Zs=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Zs.Translate.toString(e),Zs.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),io="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Cu(e){return e.matches(io)?e:e.querySelector(io)}const ku={display:"none"};function Eu(e){let{id:s,value:r}=e;return de.createElement("div",{id:s,style:ku},r)}function ju(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={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 de.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function Nu(){const[e,s]=C.useState("");return{announce:C.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const Wa=C.createContext(null);function Ru(e){const s=C.useContext(Wa);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Au(){const[e]=C.useState(()=>new Set),s=C.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[C.useCallback(o=>{let{type:p,event:m}=o;e.forEach(v=>{var i;return(i=v[p])==null?void 0:i.call(v,m)})},[e]),s]}const Mu={draggable:`
|
|
3
3
|
To pick up a draggable item, press the space bar.
|
|
4
4
|
While dragging, use the arrow keys to move the item.
|
|
5
5
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},Mu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Tu(e){let{announcements:s=Mu,container:r,hiddenTextDescribedById:n,screenReaderInstructions:p=Au}=e;const{announce:m,announcement:v}=ju(),i=Gr("DndLiveRegion"),[o,l]=C.useState(!1);if(C.useEffect(()=>{l(!0)},[]),Nu(C.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:_}=c;s.onDragMove&&m(s.onDragMove({active:g,over:_}))},onDragOver(c){let{active:g,over:_}=c;m(s.onDragOver({active:g,over:_}))},onDragEnd(c){let{active:g,over:_}=c;m(s.onDragEnd({active:g,over:_}))},onDragCancel(c){let{active:g,over:_}=c;m(s.onDragCancel({active:g,over:_}))}}),[m,s])),!o)return null;const u=le.createElement(le.Fragment,null,le.createElement(ku,{id:n,value:p.draggable}),le.createElement(Eu,{id:i,announcement:v}));return r?Jt.createPortal(u,r):u}var nt;(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"})(nt||(nt={}));function Ir(){}function Du(e,s){return C.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Lu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return C.useMemo(()=>[...s].filter(n=>n!=null),[...s])}const Tt=Object.freeze({x:0,y:0});function Pu(e,s){const r=Or(e);if(!r)return"0 0";const n={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return n.x+"% "+n.y+"%"}function Ou(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return n-r}function Iu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Bu(e,s){const r=Math.max(s.top,e.top),n=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-n,i=m-r;if(n<p&&r<m){const o=s.width*s.height,l=e.width*e.height,u=v*i,c=u/(o+l-u);return Number(c.toFixed(4))}return 0}const Fu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const p=[];for(const m of n){const{id:v}=m,i=r.get(v);if(i){const o=Bu(i,s);o>0&&p.push({id:v,data:{droppableContainer:m,value:o}})}}return p.sort(Ou)};function zu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ha(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Tt}function Hu(e){return function(r){for(var n=arguments.length,p=new Array(n>1?n-1:0),m=1;m<n;m++)p[m-1]=arguments[m];return p.reduce((v,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const Wu=Hu(1);function Wa(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function $u(e,s,r){const n=Wa(s);if(!n)return e;const{scaleX:p,scaleY:m,x:v,y:i}=n,o=e.left-v-(1-p)*parseFloat(r),l=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:l,right:o+u,bottom:l+c,left:o}}const Uu={ignoreTransform:!1};function ar(e,s){s===void 0&&(s=Uu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=vt(e).getComputedStyle(e);l&&(r=$u(r,l,u))}const{top:n,left:p,width:m,height:v,bottom:i,right:o}=r;return{top:n,left:p,width:m,height:v,bottom:i,right:o}}function no(e){return ar(e,{ignoreTransform:!0})}function qu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Ku(e,s){return s===void 0&&(s=vt(e).getComputedStyle(e)),s.position==="fixed"}function Xu(e,s){s===void 0&&(s=vt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function _n(e,s){const r=[];function n(p){if(s!=null&&r.length>=s||!p)return r;if(vn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!nr(p)||Ba(p)||r.includes(p))return r;const m=vt(e).getComputedStyle(p);return p!==e&&Xu(p,m)&&r.push(p),Ku(p,m)?r:n(p.parentNode)}return e?n(e):r}function $a(e){const[s]=_n(e,1);return s??null}function vi(e){return!Vr||!e?null:Ds(e)?e:gn(e)?vn(e)||e===Ls(e).scrollingElement?window:nr(e)?e:null:null}function Ua(e){return Ds(e)?e.scrollX:e.scrollLeft}function qa(e){return Ds(e)?e.scrollY:e.scrollTop}function Fi(e){return{x:Ua(e),y:qa(e)}}var lt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(lt||(lt={}));function Ka(e){return!Vr||!e?!1:e===document.scrollingElement}function Xa(e){const s={x:0,y:0},r=Ka(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=n.y,i=e.scrollLeft>=n.x;return{isTop:p,isLeft:m,isBottom:v,isRight:i,maxScroll:n,minScroll:s}}const Vu={x:.2,y:.2};function Yu(e,s,r,n,p){let{top:m,left:v,right:i,bottom:o}=r;n===void 0&&(n=10),p===void 0&&(p=Vu);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=Xa(e),_={x:0,y:0},y={x:0,y:0},x={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+x.height?(_.y=lt.Backward,y.y=n*Math.abs((s.top+x.height-m)/x.height)):!u&&o>=s.bottom-x.height&&(_.y=lt.Forward,y.y=n*Math.abs((s.bottom-x.height-o)/x.height)),!g&&i>=s.right-x.width?(_.x=lt.Forward,y.x=n*Math.abs((s.right-x.width-i)/x.width)):!c&&v<=s.left+x.width&&(_.x=lt.Backward,y.x=n*Math.abs((s.left+x.width-v)/x.width)),{direction:_,speed:y}}function Gu(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:n,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:n,bottom:p,width:e.clientWidth,height:e.clientHeight}}function Va(e){return e.reduce((s,r)=>js(s,Fi(r)),Tt)}function Qu(e){return e.reduce((s,r)=>s+Ua(r),0)}function Zu(e){return e.reduce((s,r)=>s+qa(r),0)}function Ya(e,s){if(s===void 0&&(s=ar),!e)return;const{top:r,left:n,bottom:p,right:m}=s(e);$a(e)&&(p<=0||m<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ju=[["x",["left","right"],Qu],["y",["top","bottom"],Zu]];class bn{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=_n(r),p=Va(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,i]of Ju)for(const o of v)Object.defineProperty(this,o,{get:()=>{const l=i(n),u=p[m]-l;return this.rect[o]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Us{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var p;(p=this.target)==null||p.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function eh(e){const{EventTarget:s}=vt(e);return e instanceof s?e:Ls(e)}function xi(e,s){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var kt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(kt||(kt={}));function oo(e){e.preventDefault()}function th(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 Ga={start:[$e.Space,$e.Enter],cancel:[$e.Esc],end:[$e.Space,$e.Enter,$e.Tab]},sh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case $e.Right:return{...r,x:r.x+25};case $e.Left:return{...r,x:r.x-25};case $e.Down:return{...r,y:r.y+25};case $e.Up:return{...r,y:r.y-25}}};class Qa{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new Us(Ls(r)),this.windowListeners=new Us(vt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(kt.Resize,this.handleCancel),this.windowListeners.add(kt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(kt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&Ya(n),r(Tt)}handleKeyDown(s){if(xn(s)){const{active:r,context:n,options:p}=this.props,{keyboardCodes:m=Ga,coordinateGetter:v=sh,scrollBehavior:i="smooth"}=p,{code:o}=s;if(m.end.includes(o)){this.handleEnd(s);return}if(m.cancel.includes(o)){this.handleCancel(s);return}const{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:Tt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:n.current,currentCoordinates:u});if(c){const g=Pr(c,u),_={x:0,y:0},{scrollableAncestors:y}=n.current;for(const x of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:S,minScroll:k}=Xa(x),j=Gu(x),w={x:Math.min(a===$e.Right?j.right-j.width/2:j.right,Math.max(a===$e.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===$e.Down?j.bottom-j.height/2:j.bottom,Math.max(a===$e.Down?j.top:j.top+j.height/2,c.y))},E=a===$e.Right&&!d||a===$e.Left&&!f,R=a===$e.Down&&!b||a===$e.Up&&!h;if(E&&w.x!==c.x){const P=x.scrollLeft+g.x,M=a===$e.Right&&P<=S.x||a===$e.Left&&P>=k.x;if(M&&!g.y){x.scrollTo({left:P,behavior:i});return}M?_.x=x.scrollLeft-P:_.x=a===$e.Right?x.scrollLeft-S.x:x.scrollLeft-k.x,_.x&&x.scrollBy({left:-_.x,behavior:i});break}else if(R&&w.y!==c.y){const P=x.scrollTop+g.y,M=a===$e.Down&&P<=S.y||a===$e.Up&&P>=k.y;if(M&&!g.x){x.scrollTo({top:P,behavior:i});return}M?_.y=x.scrollTop-P:_.y=a===$e.Down?x.scrollTop-S.y:x.scrollTop-k.y,_.y&&x.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,js(Pr(c,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Qa.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:n=Ga,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(n.start.includes(v)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function ao(e){return!!(e&&"distance"in e)}function lo(e){return!!(e&&"delay"in e)}class yn{constructor(s,r,n){var p;n===void 0&&(n=eh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Ls(v),this.documentListeners=new Us(this.document),this.listeners=new Us(n),this.windowListeners=new Us(vt(v)),this.initialCoordinates=(p=Or(m))!=null?p:Tt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(kt.Resize,this.handleCancel),this.windowListeners.add(kt.DragStart,oo),this.windowListeners.add(kt.VisibilityChange,this.handleCancel),this.windowListeners.add(kt.ContextMenu,oo),this.documentListeners.add(kt.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(ao(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:p}=this.props;p(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(kt.Click,th,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(kt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:i}}=m;if(!p)return;const o=(r=Or(s))!=null?r:Tt,l=Pr(p,o);if(!n&&i){if(ao(i)){if(i.tolerance!=null&&xi(l,i.tolerance))return this.handleCancel();if(xi(l,i.distance))return this.handleStart()}if(lo(i)&&xi(l,i.tolerance))return this.handleCancel();this.handlePending(i,l);return}s.cancelable&&s.preventDefault(),v(o)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===$e.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const rh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Sn extends yn{constructor(s){const{event:r}=s,n=Ls(r.target);super(s,rh,n)}}Sn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const ih={move:{name:"mousemove"},end:{name:"mouseup"}};var zi;(function(e){e[e.RightClick=2]="RightClick"})(zi||(zi={}));class nh extends yn{constructor(s){super(s,ih,Ls(s.event.target))}}nh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return r.button===zi.RightClick?!1:(n?.({event:r}),!0)}}];const _i={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class oh extends yn{constructor(s){super(s,_i)}static setup(){return window.addEventListener(_i.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(_i.move.name,s)};function s(){}}}oh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;const{touches:p}=r;return p.length>1?!1:(n?.({event:r}),!0)}}];var qs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qs||(qs={}));var Br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Br||(Br={}));function ah(e){let{acceleration:s,activator:r=qs.Pointer,canScroll:n,draggingRect:p,enabled:m,interval:v=5,order:i=Br.TreeOrder,pointerCoordinates:o,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const _=ch({delta:c,disabled:!m}),[y,x]=bu(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case qs.Pointer:return o?{top:o.y,bottom:o.y,left:o.x,right:o.x}:null;case qs.DraggableRect:return p}},[r,p,o]),f=C.useRef(null),b=C.useCallback(()=>{const k=f.current;if(!k)return;const j=a.current.x*h.current.x,w=a.current.y*h.current.y;k.scrollBy(j,w)},[]),S=C.useMemo(()=>i===Br.TreeOrder?[...l].reverse():l,[i,l]);C.useEffect(()=>{if(!m||!l.length||!d){x();return}for(const k of S){if(n?.(k)===!1)continue;const j=l.indexOf(k),w=u[j];if(!w)continue;const{direction:E,speed:R}=Yu(k,w,d,s,g);for(const P of["x","y"])_[P][E[P]]||(R[P]=0,E[P]=0);if(R.x>0||R.y>0){x(),f.current=k,y(b,v),a.current=R,h.current=E;return}}a.current={x:0,y:0},h.current={x:0,y:0},x()},[s,b,n,x,m,v,JSON.stringify(d),JSON.stringify(_),y,l,S,u,JSON.stringify(g)])}const lh={x:{[lt.Backward]:!1,[lt.Forward]:!1},y:{[lt.Backward]:!1,[lt.Forward]:!1}};function ch(e){let{delta:s,disabled:r}=e;const n=Lr(s);return or(p=>{if(r||!n||!p)return lh;const m={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[lt.Backward]:p.x[lt.Backward]||m.x===-1,[lt.Forward]:p.x[lt.Forward]||m.x===1},y:{[lt.Backward]:p.y[lt.Backward]||m.y===-1,[lt.Forward]:p.y[lt.Forward]||m.y===1}}},[r,s,n])}function dh(e,s){const r=s!=null?e.get(s):void 0,n=r?r.node.current:null;return or(p=>{var m;return s==null?null:(m=n??p)!=null?m:null},[n,s])}function uh(e,s){return C.useMemo(()=>e.reduce((r,n)=>{const{sensor:p}=n,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,n)}));return[...r,...m]},[]),[e,s])}var Js;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Js||(Js={}));var Hi;(function(e){e.Optimized="optimized"})(Hi||(Hi={}));const co=new Map;function hh(e,s){let{dragging:r,dependencies:n,config:p}=s;const[m,v]=C.useState(null),{frequency:i,measure:o,strategy:l}=p,u=C.useRef(e),c=a(),g=Qs(c),_=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),y=C.useRef(null),x=or(h=>{if(c&&!r)return co;if(!h||h===co||u.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const b=f.node.current,S=b?new bn(o(b),b):null;f.rect.current=S,S&&d.set(f.id,S)}return d}return h},[e,m,r,c,o]);return C.useEffect(()=>{u.current=e},[e]),C.useEffect(()=>{c||_()},[r,c]),C.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),C.useEffect(()=>{c||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},i))},[i,c,_,...n]),{droppableRects:x,measureDroppableContainers:_,measuringScheduled:m!=null};function a(){switch(l){case Js.Always:return!1;case Js.BeforeDragging:return r;default:return!r}}}function wn(e,s){return or(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function fh(e,s){return wn(e,s)}function mh(e){let{callback:s,disabled:r}=e;const n=Yr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(n)},[n,r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function Qr(e){let{callback:s,disabled:r}=e;const n=Yr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(n)},[r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function ph(e){return new bn(ar(e),e)}function uo(e,s,r){s===void 0&&(s=ph);const[n,p]=C.useState(null);function m(){p(o=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=o??r)!=null?l:null}const u=s(e);return JSON.stringify(o)===JSON.stringify(u)?o:u})}const v=mh({callback(o){if(e)for(const l of o){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=Qr({callback:m});return Kt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),n}function gh(e){const s=wn(e);return Ha(e,s)}const ho=[];function vh(e){const s=C.useRef(e),r=or(n=>e?n&&n!==ho&&e&&s.current&&e.parentNode===s.current.parentNode?n:_n(e):ho,[e]);return C.useEffect(()=>{s.current=e},[e]),r}function xh(e){const[s,r]=C.useState(null),n=C.useRef(e),p=C.useCallback(m=>{const v=vi(m.target);v&&r(i=>i?(i.set(v,Fi(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const m=n.current;if(e!==m){v(m);const i=e.map(o=>{const l=vi(o);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,Fi(l)]):null}).filter(o=>o!=null);r(i.length?new Map(i):null),n.current=e}return()=>{v(e),v(m)};function v(i){i.forEach(o=>{const l=vi(o);l?.removeEventListener("scroll",p)})}},[p,e]),C.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>js(m,v),Tt):Va(e):Tt,[e,s])}function fo(e,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const n=e!==Tt;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?Pr(e,r.current):Tt}function _h(e){C.useEffect(()=>{if(!Vr)return;const s=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function bh(e,s){return C.useMemo(()=>e.reduce((r,n)=>{let{eventName:p,handler:m}=n;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function Za(e){return C.useMemo(()=>e?qu(e):null,[e])}const mo=[];function yh(e,s){s===void 0&&(s=ar);const[r]=e,n=Za(r?vt(r):null),[p,m]=C.useState(mo);function v(){m(()=>e.length?e.map(o=>Ka(o)?n:new bn(s(o),o)):mo)}const i=Qr({callback:v});return Kt(()=>{i?.disconnect(),v(),e.forEach(o=>i?.observe(o))},[e]),p}function Ja(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return nr(s)?s:e}function Sh(e){let{measure:s}=e;const[r,n]=C.useState(null),p=C.useCallback(l=>{for(const{target:u}of l)if(nr(u)){n(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Qr({callback:p}),v=C.useCallback(l=>{const u=Ja(l);m?.disconnect(),u&&m?.observe(u),n(u?s(u):null)},[s,m]),[i,o]=Dr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:o}),[r,i,o])}const wh=[{sensor:Sn,options:{}},{sensor:Qa,options:{}}],Ch={current:{}},Er={draggable:{measure:no},droppable:{measure:no,strategy:Js.WhileDragging,frequency:Hi.Optimized},dragOverlay:{measure:ar}};class Ks extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const kh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ks,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ir},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Er,measureDroppableContainers:Ir,windowRect:null,measuringScheduled:!1},el={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ir,draggableNodes:new Map,over:null,measureDroppableContainers:Ir},lr=C.createContext(el),tl=C.createContext(kh);function Eh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ks}}}function jh(e,s){switch(s.type){case nt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case nt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case nt.DragEnd:case nt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nt.RegisterDroppable:{const{element:r}=s,{id:n}=r,p=new Ks(e.droppable.containers);return p.set(n,r),{...e,droppable:{...e.droppable,containers:p}}}case nt.SetDroppableDisabled:{const{id:r,key:n,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||n!==m.key)return e;const v=new Ks(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case nt.UnregisterDroppable:{const{id:r,key:n}=s,p=e.droppable.containers.get(r);if(!p||n!==p.key)return e;const m=new Ks(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Nh(e){let{disabled:s}=e;const{active:r,activatorEvent:n,draggableNodes:p}=C.useContext(lr),m=Lr(n),v=Lr(r?.id);return C.useEffect(()=>{if(!s&&!n&&m&&v!=null){if(!xn(m)||document.activeElement===m.target)return;const i=p.get(v);if(!i)return;const{activatorNode:o,node:l}=i;if(!o.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[o.current,l.current]){if(!u)continue;const c=wu(u);if(c){c.focus();break}}})}},[n,s,p,v,m]),null}function sl(e,s){let{transform:r,...n}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...n}),r):r}function Rh(e){return C.useMemo(()=>({draggable:{...Er.draggable,...e?.draggable},droppable:{...Er.droppable,...e?.droppable},dragOverlay:{...Er.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ah(e){let{activeNode:s,measure:r,initialRect:n,config:p=!0}=e;const m=C.useRef(!1),{x:v,y:i}=typeof p=="boolean"?{x:p,y:p}:p;Kt(()=>{if(!v&&!i||!s){m.current=!1;return}if(m.current||!n)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=Ha(u,n);if(v||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=$a(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,i,n,r])}const Zr=C.createContext({...Tt,scaleX:1,scaleY:1});var Qt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Qt||(Qt={}));const Mh=C.memo(function(s){var r,n,p,m;let{id:v,accessibility:i,autoScroll:o=!0,children:l,sensors:u=wh,collisionDetection:c=Fu,measuring:g,modifiers:_,...y}=s;const x=C.useReducer(jh,void 0,Eh),[a,h]=x,[d,f]=Ru(),[b,S]=C.useState(Qt.Uninitialized),k=b===Qt.Initialized,{draggable:{active:j,nodes:w,translate:E},droppable:{containers:R}}=a,P=j!=null?w.get(j):null,M=C.useRef({initial:null,translated:null}),T=C.useMemo(()=>{var Re;return j!=null?{id:j,data:(Re=P?.data)!=null?Re:Ch,rect:M}:null},[j,P]),B=C.useRef(null),[D,F]=C.useState(null),[$,A]=C.useState(null),O=Qs(y,Object.values(y)),L=Gr("DndDescribedBy",v),I=C.useMemo(()=>R.getEnabled(),[R]),U=Rh(g),{droppableRects:Y,measureDroppableContainers:q,measuringScheduled:W}=hh(I,{dragging:k,dependencies:[E.x,E.y],config:U.droppable}),K=dh(w,j),N=C.useMemo(()=>$?Or($):null,[$]),z=He(),V=fh(K,U.draggable.measure);Ah({activeNode:j!=null?w.get(j):null,config:z.layoutShiftCompensation,initialRect:V,measure:U.draggable.measure});const X=uo(K,U.draggable.measure,V),re=uo(K?K.parentElement:null),J=C.useRef({activatorEvent:null,active:null,activeNode:K,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=R.getNodeFor((r=J.current.over)==null?void 0:r.id),ve=Sh({measure:U.dragOverlay.measure}),pe=(n=ve.nodeRef.current)!=null?n:K,Le=k?(p=ve.rect)!=null?p:X:null,oe=!!(ve.nodeRef.current&&ve.rect),dt=gh(oe?null:X),ge=Za(pe?vt(pe):null),Ee=vh(k?se??K:null),Ze=yh(Ee),tt=sl(_,{transform:{x:E.x-dt.x,y:E.y-dt.y,scaleX:1,scaleY:1},activatorEvent:$,active:T,activeNodeRect:X,containerNodeRect:re,draggingNodeRect:Le,over:J.current.over,overlayNodeRect:ve.rect,scrollableAncestors:Ee,scrollableAncestorRects:Ze,windowRect:ge}),Se=N?js(N,E):null,it=xh(Ee),xe=fo(it),je=fo(it,[X]),Ie=js(tt,xe),Pe=Le?Wu(Le,tt):null,Ne=T&&Pe?c({active:T,collisionRect:Pe,droppableRects:Y,droppableContainers:I,pointerCoordinates:Se}):null,Me=Iu(Ne,"id"),[be,ye]=C.useState(null),H=oe?tt:js(tt,je),G=zu(H,(m=be?.rect)!=null?m:null,X),Z=C.useRef(null),ae=C.useCallback((Re,Ae)=>{let{sensor:we,options:We}=Ae;if(B.current==null)return;const Ce=w.get(B.current);if(!Ce)return;const Je=Re.nativeEvent,Ye=new we({active:B.current,activeNode:Ce,event:Je,options:We,context:J,onAbort(Ge){if(!w.get(Ge))return;const{onDragAbort:mt}=O.current,ut={id:Ge};mt?.(ut),d({type:"onDragAbort",event:ut})},onPending(Ge,bt,mt,ut){if(!w.get(Ge))return;const{onDragPending:wt}=O.current,Be={id:Ge,constraint:bt,initialCoordinates:mt,offset:ut};wt?.(Be),d({type:"onDragPending",event:Be})},onStart(Ge){const bt=B.current;if(bt==null)return;const mt=w.get(bt);if(!mt)return;const{onDragStart:ut}=O.current,At={activatorEvent:Je,active:{id:bt,data:mt.data,rect:M}};Jt.unstable_batchedUpdates(()=>{ut?.(At),S(Qt.Initializing),h({type:nt.DragStart,initialCoordinates:Ge,active:bt}),d({type:"onDragStart",event:At}),F(Z.current),A(Je)})},onMove(Ge){h({type:nt.DragMove,coordinates:Ge})},onEnd:qe(nt.DragEnd),onCancel:qe(nt.DragCancel)});Z.current=Ye;function qe(Ge){return async function(){const{active:mt,collisions:ut,over:At,scrollAdjustedTranslate:wt}=J.current;let Be=null;if(mt&&wt){const{cancelDrop:Dt}=O.current;Be={activatorEvent:Je,active:mt,collisions:ut,delta:wt,over:At},Ge===nt.DragEnd&&typeof Dt=="function"&&await Promise.resolve(Dt(Be))&&(Ge=nt.DragCancel)}B.current=null,Jt.unstable_batchedUpdates(()=>{h({type:Ge}),S(Qt.Uninitialized),ye(null),F(null),A(null),Z.current=null;const Dt=Ge===nt.DragEnd?"onDragEnd":"onDragCancel";if(Be){const Lt=O.current[Dt];Lt?.(Be),d({type:Dt,event:Be})}})}}},[w]),de=C.useCallback((Re,Ae)=>(we,We)=>{const Ce=we.nativeEvent,Je=w.get(We);if(B.current!==null||!Je||Ce.dndKit||Ce.defaultPrevented)return;const Ye={active:Je};Re(we,Ae.options,Ye)===!0&&(Ce.dndKit={capturedBy:Ae.sensor},B.current=We,ae(we,Ae))},[w,ae]),fe=uh(u,de);_h(u),Kt(()=>{X&&b===Qt.Initializing&&S(Qt.Initialized)},[X,b]),C.useEffect(()=>{const{onDragMove:Re}=O.current,{active:Ae,activatorEvent:we,collisions:We,over:Ce}=J.current;if(!Ae||!we)return;const Je={active:Ae,activatorEvent:we,collisions:We,delta:{x:Ie.x,y:Ie.y},over:Ce};Jt.unstable_batchedUpdates(()=>{Re?.(Je),d({type:"onDragMove",event:Je})})},[Ie.x,Ie.y]),C.useEffect(()=>{const{active:Re,activatorEvent:Ae,collisions:we,droppableContainers:We,scrollAdjustedTranslate:Ce}=J.current;if(!Re||B.current==null||!Ae||!Ce)return;const{onDragOver:Je}=O.current,Ye=We.get(Me),qe=Ye&&Ye.rect.current?{id:Ye.id,rect:Ye.rect.current,data:Ye.data,disabled:Ye.disabled}:null,Ge={active:Re,activatorEvent:Ae,collisions:we,delta:{x:Ce.x,y:Ce.y},over:qe};Jt.unstable_batchedUpdates(()=>{ye(qe),Je?.(Ge),d({type:"onDragOver",event:Ge})})},[Me]),Kt(()=>{J.current={activatorEvent:$,active:T,activeNode:K,collisionRect:Pe,collisions:Ne,droppableRects:Y,draggableNodes:w,draggingNode:pe,draggingNodeRect:Le,droppableContainers:R,over:be,scrollableAncestors:Ee,scrollAdjustedTranslate:Ie},M.current={initial:Le,translated:Pe}},[T,K,Ne,Pe,w,pe,Le,Y,R,be,Ee,Ie]),ah({...z,delta:E,draggingRect:Pe,pointerCoordinates:Se,scrollableAncestors:Ee,scrollableAncestorRects:Ze});const Ve=C.useMemo(()=>({active:T,activeNode:K,activeNodeRect:X,activatorEvent:$,collisions:Ne,containerNodeRect:re,dragOverlay:ve,draggableNodes:w,droppableContainers:R,droppableRects:Y,over:be,measureDroppableContainers:q,scrollableAncestors:Ee,scrollableAncestorRects:Ze,measuringConfiguration:U,measuringScheduled:W,windowRect:ge}),[T,K,X,$,Ne,re,ve,w,R,Y,be,q,Ee,Ze,U,W,ge]),Te=C.useMemo(()=>({activatorEvent:$,activators:fe,active:T,activeNodeRect:X,ariaDescribedById:{draggable:L},dispatch:h,draggableNodes:w,over:be,measureDroppableContainers:q}),[$,fe,T,X,h,L,w,be,q]);return le.createElement(za.Provider,{value:f},le.createElement(lr.Provider,{value:Te},le.createElement(tl.Provider,{value:Ve},le.createElement(Zr.Provider,{value:G},l)),le.createElement(Nh,{disabled:i?.restoreFocus===!1})),le.createElement(Tu,{...i,hiddenTextDescribedById:L}));function He(){const Re=D?.autoScrollEnabled===!1,Ae=typeof o=="object"?o.enabled===!1:o===!1,we=k&&!Re&&!Ae;return typeof o=="object"?{...o,enabled:we}:{enabled:we}}}),Th=C.createContext(null),po="button",Dh="Draggable";function Lh(e){let{id:s,data:r,disabled:n=!1,attributes:p}=e;const m=Gr(Dh),{activators:v,activatorEvent:i,active:o,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=C.useContext(lr),{role:_=po,roleDescription:y="draggable",tabIndex:x=0}=p??{},a=o?.id===s,h=C.useContext(a?Zr:Th),[d,f]=Dr(),[b,S]=Dr(),k=bh(v,s),j=Qs(r);Kt(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:b,data:j}),()=>{const E=c.get(s);E&&E.key===m&&c.delete(s)}),[c,s]);const w=C.useMemo(()=>({role:_,tabIndex:x,"aria-disabled":n,"aria-pressed":a&&_===po?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[n,_,x,a,y,u.draggable]);return{active:o,activatorEvent:i,activeNodeRect:l,attributes:w,isDragging:a,listeners:n?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:S,transform:h}}function Ph(){return C.useContext(tl)}const Oh="Droppable",Ih={timeout:25};function Bh(e){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:p}=e;const m=Gr(Oh),{active:v,dispatch:i,over:o,measureDroppableContainers:l}=C.useContext(lr),u=C.useRef({disabled:r}),c=C.useRef(!1),g=C.useRef(null),_=C.useRef(null),{disabled:y,updateMeasurementsFor:x,timeout:a}={...Ih,...p},h=Qs(x??n),d=C.useCallback(()=>{if(!c.current){c.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),_.current=null},a)},[a]),f=Qr({callback:d,disabled:y||!v}),b=C.useCallback((w,E)=>{f&&(E&&(f.unobserve(E),c.current=!1),w&&f.observe(w))},[f]),[S,k]=Dr(b),j=Qs(s);return C.useEffect(()=>{!f||!S.current||(f.disconnect(),c.current=!1,f.observe(S.current))},[S,f]),C.useEffect(()=>(i({type:nt.RegisterDroppable,element:{id:n,key:m,disabled:r,node:S,rect:g,data:j}}),()=>i({type:nt.UnregisterDroppable,key:m,id:n})),[n]),C.useEffect(()=>{r!==u.current.disabled&&(i({type:nt.SetDroppableDisabled,id:n,key:m,disabled:r}),u.current.disabled=r)},[n,m,r,i]),{active:v,rect:g,isOver:o?.id===n,node:S,over:o,setNodeRef:k}}function Fh(e){let{animation:s,children:r}=e;const[n,p]=C.useState(null),[m,v]=C.useState(null),i=Lr(r);return!r&&!n&&i&&p(i),Kt(()=>{if(!m)return;const o=n?.key,l=n?.props.id;if(o==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,n,m]),le.createElement(le.Fragment,null,r,n?C.cloneElement(n,{ref:v}):null)}const zh={x:0,y:0,scaleX:1,scaleY:1};function Hh(e){let{children:s}=e;return le.createElement(lr.Provider,{value:el},le.createElement(Zr.Provider,{value:zh},s))}const Wh={position:"fixed",touchAction:"none"},$h=e=>xn(e)?"transform 250ms ease":void 0,Uh=C.forwardRef((e,s)=>{let{as:r,activatorEvent:n,adjustScale:p,children:m,className:v,rect:i,style:o,transform:l,transition:u=$h}=e;if(!i)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...Wh,width:i.width,height:i.height,top:i.top,left:i.left,transform:Zs.Transform.toString(c),transformOrigin:p&&n?Pu(n,i):void 0,transition:typeof u=="function"?u(n):u,...o};return le.createElement(r,{className:v,style:g,ref:s},m)}),qh=e=>s=>{let{active:r,dragOverlay:n}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[i,o]of Object.entries(m.active))o!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,o));if(m!=null&&m.dragOverlay)for(const[i,o]of Object.entries(m.dragOverlay))o!==void 0&&n.node.style.setProperty(i,o);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&n.node.classList.add(v.dragOverlay),function(){for(const[o,l]of Object.entries(p))r.node.style.setProperty(o,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},Kh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:Zs.Transform.toString(s)},{transform:Zs.Transform.toString(r)}]},Xh={duration:250,easing:"ease",keyframes:Kh,sideEffects:qh({styles:{active:{opacity:"0"}}})};function Vh(e){let{config:s,draggableNodes:r,droppableContainers:n,measuringConfiguration:p}=e;return Yr((m,v)=>{if(s===null)return;const i=r.get(m);if(!i)return;const o=i.node.current;if(!o)return;const l=Ja(v);if(!l)return;const{transform:u}=vt(v).getComputedStyle(v),c=Wa(u);if(!c)return;const g=typeof s=="function"?s:Yh(s);return Ya(o,p.draggable.measure),g({active:{id:m,data:i.data,node:o,rect:p.draggable.measure(o)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:n,measuringConfiguration:p,transform:c})})}function Yh(e){const{duration:s,easing:r,sideEffects:n,keyframes:p}={...Xh,...e};return m=>{let{active:v,dragOverlay:i,transform:o,...l}=m;if(!s)return;const u={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},c={scaleX:o.scaleX!==1?v.rect.width*o.scaleX/i.rect.width:1,scaleY:o.scaleY!==1?v.rect.height*o.scaleY/i.rect.height:1},g={x:o.x-u.x,y:o.y-u.y,...c},_=p({...l,active:v,dragOverlay:i,transform:{initial:o,final:g}}),[y]=_,x=_[_.length-1];if(JSON.stringify(y)===JSON.stringify(x))return;const a=n?.({active:v,dragOverlay:i,...l}),h=i.node.animate(_,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let go=0;function Gh(e){return C.useMemo(()=>{if(e!=null)return go++,go},[e])}const Qh=le.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:n,style:p,transition:m,modifiers:v,wrapperElement:i="div",className:o,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggableNodes:y,droppableContainers:x,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:S}=Ph(),k=C.useContext(Zr),j=Gh(c?.id),w=sl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:S}),E=wn(g),R=Vh({config:n,draggableNodes:y,droppableContainers:x,measuringConfiguration:d}),P=E?a.setRef:void 0;return le.createElement(Hh,null,le.createElement(Fh,{animation:R},c&&j?le.createElement(Uh,{key:j,id:c.id,ref:P,as:i,activatorEvent:u,adjustScale:s,className:o,transition:m,rect:E,style:{zIndex:l,...p},transform:w},r):null))}),rl=768;function Zh(e){const s=window.matchMedia(`(max-width: ${rl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Jh(){return window.innerWidth<rl}function ef(){return!1}function il(){return C.useSyncExternalStore(Zh,Jh,ef)}function Cn(e){return Rt({queryKey:ie.workspaces.list(e),queryFn:()=>he.get(`/tasks/${e}/workspaces`),enabled:!!e})}function nl(e){const s=ot();return _t({mutationFn:r=>he.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie.workspaces.list(e)}),s.invalidateQueries({queryKey:ie.tasks.all})}})}function ol(){const e=ot();return _t({mutationFn:({id:s,commitMessage:r})=>he.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ie.workspaces.all}),e.invalidateQueries({queryKey:ie.tasks.all}),e.invalidateQueries({queryKey:ie.git.all})},onError:()=>{e.invalidateQueries({queryKey:ie.git.all})}})}function tf(){const e=ot();return _t({mutationFn:s=>he.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ie.workspaces.all}),e.invalidateQueries({queryKey:ie.tasks.all})}})}function kn(){return _t({mutationFn:({workspaceId:e,editorType:s})=>he.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function En(e,s={}){return Rt({queryKey:ie.workspaces.gitStatus(e),queryFn:()=>he.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function al(){const e=ot();return _t({mutationFn:s=>he.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ie.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ie.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ie.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ie.git.all})}})}function jn(){const e=ot();return _t({mutationFn:s=>he.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ie.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ie.git.all})}})}function sf(e,s){const r=[];if(!e||e.length===0)return r;const n=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===rt.RUNNING||v.status===rt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),n&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Nn({isOpen:e,onClose:s,onConfirm:r,taskId:n,taskTitle:p,workspaces:m,isLoading:v}){const{t:i}=ce(),{data:o,isLoading:l}=Cn(m===void 0&&e?n:""),u=m??o,c=m===void 0&&e&&l,g=C.useMemo(()=>sf(u,i),[u,i]);return t.jsx(qr,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((_,y)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:_})]},y))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const ue={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Wi={[ue.Review]:{label:"Review",icon:Ca,iconClass:"text-warning",accentClass:"text-warning"},[ue.Running]:{label:"Running",icon:wa,iconClass:"text-info",accentClass:"text-info"},[ue.Pending]:{label:"Pending",icon:Sa,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ue.Done]:{label:"Done",icon:ya,iconClass:"text-success/80",accentClass:"text-success"},[ue.Cancelled]:{label:"Cancelled",icon:ba,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},rf=[ue.Review,ue.Running,ue.Pending,ue.Done,ue.Cancelled],ll=C.createContext(null),nf=3e4;function of(e=nf){const[,s]=C.useState(0);C.useEffect(()=>{const r=setInterval(()=>s(n=>n+1),e);return()=>clearInterval(r)},[e])}function af(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?ft("{count}s ago",{count:s}):s<3600?ft("{count}m ago",{count:Math.floor(s/60)}):s<86400?ft("{count}h ago",{count:Math.floor(s/3600)}):ft("{count}d ago",{count:Math.floor(s/86400)})}function lf({task:e,status:s,isSelected:r,isAgentActive:n,project:p,onSelectTask:m,onTaskStatusChange:v,onDeleteTask:i,disableDrag:o}){const{t:l}=ce(),u=C.useContext(ll),c=C.useRef(null),g=!!e.projectArchivedAt,_=g||!!o,{attributes:y,listeners:x,setNodeRef:a,isDragging:h}=Lh({id:e.id,data:{task:e,fromStatus:s},disabled:_}),d=C.useCallback(T=>{c.current=T,a(T),u&&(T?u.registry.set(e.id,T):u.registry.delete(e.id))},[a,u,e.id]);C.useEffect(()=>()=>{u?.registry.delete(e.id)},[e.id,u]);const[f,b]=C.useState(null),[S,k]=C.useState(!1),j=C.useRef(null),w=C.useRef(null),E=C.useCallback(T=>{g||!v&&!i||(T.preventDefault(),b({x:T.clientX,y:T.clientY}))},[g,v,i]),R=C.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),P=C.useCallback(T=>{if(!o||g||!v&&!i)return;const B=T.touches[0];if(!B)return;const{clientX:D,clientY:F}=B;w.current=setTimeout(()=>{w.current=null,b({x:D,y:F})},500)},[o,g,v,i]);C.useEffect(()=>{if(!f)return;const T=B=>{j.current&&!j.current.contains(B.target)&&b(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[f]);const M=p?p.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>m(e.id),onContextMenu:E,onTouchStart:P,onTouchEnd:R,onTouchMove:R,title:M,"aria-label":M?`${e.title} — ${M}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
6
|
+
`},Tu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Du(e){let{announcements:s=Tu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=Mu}=e;const{announce:m,announcement:v}=Nu(),i=Gr("DndLiveRegion"),[n,l]=C.useState(!1);if(C.useEffect(()=>{l(!0)},[]),Ru(C.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:_}=c;s.onDragMove&&m(s.onDragMove({active:g,over:_}))},onDragOver(c){let{active:g,over:_}=c;m(s.onDragOver({active:g,over:_}))},onDragEnd(c){let{active:g,over:_}=c;m(s.onDragEnd({active:g,over:_}))},onDragCancel(c){let{active:g,over:_}=c;m(s.onDragCancel({active:g,over:_}))}}),[m,s])),!n)return null;const u=de.createElement(de.Fragment,null,de.createElement(Eu,{id:o,value:p.draggable}),de.createElement(ju,{id:i,announcement:v}));return r?Jt.createPortal(u,r):u}var nt;(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"})(nt||(nt={}));function Or(){}function Lu(e,s){return C.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Pu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return C.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Tt=Object.freeze({x:0,y:0});function Ou(e,s){const r=Pr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Iu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Bu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Fu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-o,i=m-r;if(o<p&&r<m){const n=s.width*s.height,l=e.width*e.height,u=v*i,c=u/(n+l-u);return Number(c.toFixed(4))}return 0}const zu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:v}=m,i=r.get(v);if(i){const n=Fu(i,s);n>0&&p.push({id:v,data:{droppableContainer:m,value:n}})}}return p.sort(Iu)};function Wu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ha(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Tt}function Hu(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((v,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const $u=Hu(1);function $a(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Uu(e,s,r){const o=$a(s);if(!o)return e;const{scaleX:p,scaleY:m,x:v,y:i}=o,n=e.left-v-(1-p)*parseFloat(r),l=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:l,right:n+u,bottom:l+c,left:n}}const qu={ignoreTransform:!1};function or(e,s){s===void 0&&(s=qu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=vt(e).getComputedStyle(e);l&&(r=Uu(r,l,u))}const{top:o,left:p,width:m,height:v,bottom:i,right:n}=r;return{top:o,left:p,width:m,height:v,bottom:i,right:n}}function no(e){return or(e,{ignoreTransform:!0})}function Ku(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Xu(e,s){return s===void 0&&(s=vt(e).getComputedStyle(e)),s.position==="fixed"}function Vu(e,s){s===void 0&&(s=vt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function _n(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(vn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!ir(p)||Fa(p)||r.includes(p))return r;const m=vt(e).getComputedStyle(p);return p!==e&&Vu(p,m)&&r.push(p),Xu(p,m)?r:o(p.parentNode)}return e?o(e):r}function Ua(e){const[s]=_n(e,1);return s??null}function vi(e){return!Vr||!e?null:Ds(e)?e:gn(e)?vn(e)||e===Ls(e).scrollingElement?window:ir(e)?e:null:null}function qa(e){return Ds(e)?e.scrollX:e.scrollLeft}function Ka(e){return Ds(e)?e.scrollY:e.scrollTop}function Fi(e){return{x:qa(e),y:Ka(e)}}var lt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(lt||(lt={}));function Xa(e){return!Vr||!e?!1:e===document.scrollingElement}function Va(e){const s={x:0,y:0},r=Xa(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:v,isRight:i,maxScroll:o,minScroll:s}}const Yu={x:.2,y:.2};function Gu(e,s,r,o,p){let{top:m,left:v,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Yu);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=Va(e),_={x:0,y:0},y={x:0,y:0},x={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+x.height?(_.y=lt.Backward,y.y=o*Math.abs((s.top+x.height-m)/x.height)):!u&&n>=s.bottom-x.height&&(_.y=lt.Forward,y.y=o*Math.abs((s.bottom-x.height-n)/x.height)),!g&&i>=s.right-x.width?(_.x=lt.Forward,y.x=o*Math.abs((s.right-x.width-i)/x.width)):!c&&v<=s.left+x.width&&(_.x=lt.Backward,y.x=o*Math.abs((s.left+x.width-v)/x.width)),{direction:_,speed:y}}function Qu(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function Ya(e){return e.reduce((s,r)=>js(s,Fi(r)),Tt)}function Zu(e){return e.reduce((s,r)=>s+qa(r),0)}function Ju(e){return e.reduce((s,r)=>s+Ka(r),0)}function Ga(e,s){if(s===void 0&&(s=or),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Ua(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const eh=[["x",["left","right"],Zu],["y",["top","bottom"],Ju]];class bn{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=_n(r),p=Ya(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,i]of eh)for(const n of v)Object.defineProperty(this,n,{get:()=>{const l=i(o),u=p[m]-l;return this.rect[n]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Us{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function th(e){const{EventTarget:s}=vt(e);return e instanceof s?e:Ls(e)}function xi(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var kt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(kt||(kt={}));function oo(e){e.preventDefault()}function sh(e){e.stopPropagation()}var Ue;(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"})(Ue||(Ue={}));const Qa={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},rh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class Za{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new Us(Ls(r)),this.windowListeners=new Us(vt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(kt.Resize,this.handleCancel),this.windowListeners.add(kt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(kt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Ga(o),r(Tt)}handleKeyDown(s){if(xn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Qa,coordinateGetter:v=rh,scrollBehavior:i="smooth"}=p,{code:n}=s;if(m.end.includes(n)){this.handleEnd(s);return}if(m.cancel.includes(n)){this.handleCancel(s);return}const{collisionRect:l}=o.current,u=l?{x:l.left,y:l.top}:Tt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Lr(c,u),_={x:0,y:0},{scrollableAncestors:y}=o.current;for(const x of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:S,minScroll:k}=Va(x),j=Qu(x),w={x:Math.min(a===Ue.Right?j.right-j.width/2:j.right,Math.max(a===Ue.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===Ue.Down?j.bottom-j.height/2:j.bottom,Math.max(a===Ue.Down?j.top:j.top+j.height/2,c.y))},E=a===Ue.Right&&!d||a===Ue.Left&&!f,R=a===Ue.Down&&!b||a===Ue.Up&&!h;if(E&&w.x!==c.x){const P=x.scrollLeft+g.x,M=a===Ue.Right&&P<=S.x||a===Ue.Left&&P>=k.x;if(M&&!g.y){x.scrollTo({left:P,behavior:i});return}M?_.x=x.scrollLeft-P:_.x=a===Ue.Right?x.scrollLeft-S.x:x.scrollLeft-k.x,_.x&&x.scrollBy({left:-_.x,behavior:i});break}else if(R&&w.y!==c.y){const P=x.scrollTop+g.y,M=a===Ue.Down&&P<=S.y||a===Ue.Up&&P>=k.y;if(M&&!g.x){x.scrollTo({top:P,behavior:i});return}M?_.y=x.scrollTop-P:_.y=a===Ue.Down?x.scrollTop-S.y:x.scrollTop-k.y,_.y&&x.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,js(Lr(c,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Za.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Qa,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function ao(e){return!!(e&&"distance"in e)}function lo(e){return!!(e&&"delay"in e)}class yn{constructor(s,r,o){var p;o===void 0&&(o=th(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Ls(v),this.documentListeners=new Us(this.document),this.listeners=new Us(o),this.windowListeners=new Us(vt(v)),this.initialCoordinates=(p=Pr(m))!=null?p:Tt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(kt.Resize,this.handleCancel),this.windowListeners.add(kt.DragStart,oo),this.windowListeners.add(kt.VisibilityChange,this.handleCancel),this.windowListeners.add(kt.ContextMenu,oo),this.documentListeners.add(kt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(ao(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(kt.Click,sh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(kt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=Pr(s))!=null?r:Tt,l=Lr(p,n);if(!o&&i){if(ao(i)){if(i.tolerance!=null&&xi(l,i.tolerance))return this.handleCancel();if(xi(l,i.distance))return this.handleStart()}if(lo(i)&&xi(l,i.tolerance))return this.handleCancel();this.handlePending(i,l);return}s.cancelable&&s.preventDefault(),v(n)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ue.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const ih={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Sn extends yn{constructor(s){const{event:r}=s,o=Ls(r.target);super(s,ih,o)}}Sn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const nh={move:{name:"mousemove"},end:{name:"mouseup"}};var zi;(function(e){e[e.RightClick=2]="RightClick"})(zi||(zi={}));class oh extends yn{constructor(s){super(s,nh,Ls(s.event.target))}}oh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===zi.RightClick?!1:(o?.({event:r}),!0)}}];const _i={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ah extends yn{constructor(s){super(s,_i)}static setup(){return window.addEventListener(_i.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(_i.move.name,s)};function s(){}}}ah.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var qs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qs||(qs={}));var Ir;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ir||(Ir={}));function lh(e){let{acceleration:s,activator:r=qs.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:i=Ir.TreeOrder,pointerCoordinates:n,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const _=dh({delta:c,disabled:!m}),[y,x]=yu(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case qs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case qs.DraggableRect:return p}},[r,p,n]),f=C.useRef(null),b=C.useCallback(()=>{const k=f.current;if(!k)return;const j=a.current.x*h.current.x,w=a.current.y*h.current.y;k.scrollBy(j,w)},[]),S=C.useMemo(()=>i===Ir.TreeOrder?[...l].reverse():l,[i,l]);C.useEffect(()=>{if(!m||!l.length||!d){x();return}for(const k of S){if(o?.(k)===!1)continue;const j=l.indexOf(k),w=u[j];if(!w)continue;const{direction:E,speed:R}=Gu(k,w,d,s,g);for(const P of["x","y"])_[P][E[P]]||(R[P]=0,E[P]=0);if(R.x>0||R.y>0){x(),f.current=k,y(b,v),a.current=R,h.current=E;return}}a.current={x:0,y:0},h.current={x:0,y:0},x()},[s,b,o,x,m,v,JSON.stringify(d),JSON.stringify(_),y,l,S,u,JSON.stringify(g)])}const ch={x:{[lt.Backward]:!1,[lt.Forward]:!1},y:{[lt.Backward]:!1,[lt.Forward]:!1}};function dh(e){let{delta:s,disabled:r}=e;const o=Dr(s);return nr(p=>{if(r||!o||!p)return ch;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[lt.Backward]:p.x[lt.Backward]||m.x===-1,[lt.Forward]:p.x[lt.Forward]||m.x===1},y:{[lt.Backward]:p.y[lt.Backward]||m.y===-1,[lt.Forward]:p.y[lt.Forward]||m.y===1}}},[r,s,o])}function uh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return nr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function hh(e,s){return C.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...m]},[]),[e,s])}var Js;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Js||(Js={}));var Wi;(function(e){e.Optimized="optimized"})(Wi||(Wi={}));const co=new Map;function fh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=C.useState(null),{frequency:i,measure:n,strategy:l}=p,u=C.useRef(e),c=a(),g=Qs(c),_=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),y=C.useRef(null),x=nr(h=>{if(c&&!r)return co;if(!h||h===co||u.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const b=f.node.current,S=b?new bn(n(b),b):null;f.rect.current=S,S&&d.set(f.id,S)}return d}return h},[e,m,r,c,n]);return C.useEffect(()=>{u.current=e},[e]),C.useEffect(()=>{c||_()},[r,c]),C.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),C.useEffect(()=>{c||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},i))},[i,c,_,...o]),{droppableRects:x,measureDroppableContainers:_,measuringScheduled:m!=null};function a(){switch(l){case Js.Always:return!1;case Js.BeforeDragging:return r;default:return!r}}}function wn(e,s){return nr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function mh(e,s){return wn(e,s)}function ph(e){let{callback:s,disabled:r}=e;const o=Yr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function Qr(e){let{callback:s,disabled:r}=e;const o=Yr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function gh(e){return new bn(or(e),e)}function uo(e,s,r){s===void 0&&(s=gh);const[o,p]=C.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=n??r)!=null?l:null}const u=s(e);return JSON.stringify(n)===JSON.stringify(u)?n:u})}const v=ph({callback(n){if(e)for(const l of n){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=Qr({callback:m});return Kt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),o}function vh(e){const s=wn(e);return Ha(e,s)}const ho=[];function xh(e){const s=C.useRef(e),r=nr(o=>e?o&&o!==ho&&e&&s.current&&e.parentNode===s.current.parentNode?o:_n(e):ho,[e]);return C.useEffect(()=>{s.current=e},[e]),r}function _h(e){const[s,r]=C.useState(null),o=C.useRef(e),p=C.useCallback(m=>{const v=vi(m.target);v&&r(i=>i?(i.set(v,Fi(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const m=o.current;if(e!==m){v(m);const i=e.map(n=>{const l=vi(n);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,Fi(l)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{v(e),v(m)};function v(i){i.forEach(n=>{const l=vi(n);l?.removeEventListener("scroll",p)})}},[p,e]),C.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>js(m,v),Tt):Ya(e):Tt,[e,s])}function fo(e,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const o=e!==Tt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Lr(e,r.current):Tt}function bh(e){C.useEffect(()=>{if(!Vr)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function yh(e,s){return C.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function Ja(e){return C.useMemo(()=>e?Ku(e):null,[e])}const mo=[];function Sh(e,s){s===void 0&&(s=or);const[r]=e,o=Ja(r?vt(r):null),[p,m]=C.useState(mo);function v(){m(()=>e.length?e.map(n=>Xa(n)?o:new bn(s(n),n)):mo)}const i=Qr({callback:v});return Kt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),p}function el(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return ir(s)?s:e}function wh(e){let{measure:s}=e;const[r,o]=C.useState(null),p=C.useCallback(l=>{for(const{target:u}of l)if(ir(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Qr({callback:p}),v=C.useCallback(l=>{const u=el(l);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[i,n]=Tr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const Ch=[{sensor:Sn,options:{}},{sensor:Za,options:{}}],kh={current:{}},kr={draggable:{measure:no},droppable:{measure:no,strategy:Js.WhileDragging,frequency:Wi.Optimized},dragOverlay:{measure:or}};class Ks extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const Eh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ks,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Or},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kr,measureDroppableContainers:Or,windowRect:null,measuringScheduled:!1},tl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Or,draggableNodes:new Map,over:null,measureDroppableContainers:Or},ar=C.createContext(tl),sl=C.createContext(Eh);function jh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ks}}}function Nh(e,s){switch(s.type){case nt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case nt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case nt.DragEnd:case nt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nt.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new Ks(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case nt.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new Ks(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case nt.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new Ks(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Rh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=C.useContext(ar),m=Dr(o),v=Dr(r?.id);return C.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!xn(m)||document.activeElement===m.target)return;const i=p.get(v);if(!i)return;const{activatorNode:n,node:l}=i;if(!n.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[n.current,l.current]){if(!u)continue;const c=Cu(u);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function rl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Ah(e){return C.useMemo(()=>({draggable:{...kr.draggable,...e?.draggable},droppable:{...kr.droppable,...e?.droppable},dragOverlay:{...kr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Mh(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=C.useRef(!1),{x:v,y:i}=typeof p=="boolean"?{x:p,y:p}:p;Kt(()=>{if(!v&&!i||!s){m.current=!1;return}if(m.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=Ha(u,o);if(v||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Ua(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,i,o,r])}const Zr=C.createContext({...Tt,scaleX:1,scaleY:1});var Qt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Qt||(Qt={}));const Th=C.memo(function(s){var r,o,p,m;let{id:v,accessibility:i,autoScroll:n=!0,children:l,sensors:u=Ch,collisionDetection:c=zu,measuring:g,modifiers:_,...y}=s;const x=C.useReducer(Nh,void 0,jh),[a,h]=x,[d,f]=Au(),[b,S]=C.useState(Qt.Uninitialized),k=b===Qt.Initialized,{draggable:{active:j,nodes:w,translate:E},droppable:{containers:R}}=a,P=j!=null?w.get(j):null,M=C.useRef({initial:null,translated:null}),T=C.useMemo(()=>{var Ee;return j!=null?{id:j,data:(Ee=P?.data)!=null?Ee:kh,rect:M}:null},[j,P]),B=C.useRef(null),[D,F]=C.useState(null),[H,A]=C.useState(null),O=Qs(y,Object.values(y)),L=Gr("DndDescribedBy",v),I=C.useMemo(()=>R.getEnabled(),[R]),$=Ah(g),{droppableRects:V,measureDroppableContainers:U,measuringScheduled:W}=fh(I,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),q=uh(w,j),N=C.useMemo(()=>H?Pr(H):null,[H]),z=we(),X=mh(q,$.draggable.measure);Mh({activeNode:j!=null?w.get(j):null,config:z.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const K=uo(q,$.draggable.measure,X),re=uo(q?q.parentElement:null),Z=C.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=R.getNodeFor((r=Z.current.over)==null?void 0:r.id),_e=wh({measure:$.dragOverlay.measure}),ve=(o=_e.nodeRef.current)!=null?o:q,Ie=k?(p=_e.rect)!=null?p:K:null,ce=!!(_e.nodeRef.current&&_e.rect),dt=vh(ce?null:K),xe=Ja(ve?vt(ve):null),De=xh(k?se??q:null),Ze=Sh(De),tt=rl(_,{transform:{x:E.x-dt.x,y:E.y-dt.y,scaleX:1,scaleY:1},activatorEvent:H,active:T,activeNodeRect:K,containerNodeRect:re,draggingNodeRect:Ie,over:Z.current.over,overlayNodeRect:_e.rect,scrollableAncestors:De,scrollableAncestorRects:Ze,windowRect:xe}),Ae=N?js(N,E):null,Ge=_h(De),be=fo(Ge),Me=fo(Ge,[K]),Be=js(tt,be),Le=Ie?$u(Ie,tt):null,Pe=T&&Le?c({active:T,collisionRect:Le,droppableRects:V,droppableContainers:I,pointerCoordinates:Ae}):null,Xe=Bu(Pe,"id"),[Ce,ye]=C.useState(null),G=ce?tt:js(tt,Me),ne=Wu(G,(m=Ce?.rect)!=null?m:null,K),oe=C.useRef(null),Y=C.useCallback((Ee,pe)=>{let{sensor:je,options:Je}=pe;if(B.current==null)return;const qe=w.get(B.current);if(!qe)return;const it=Ee.nativeEvent,Ne=new je({active:B.current,activeNode:qe,event:it,options:Je,context:Z,onAbort(ze){if(!w.get(ze))return;const{onDragAbort:mt}=O.current,ut={id:ze};mt?.(ut),d({type:"onDragAbort",event:ut})},onPending(ze,bt,mt,ut){if(!w.get(ze))return;const{onDragPending:wt}=O.current,We={id:ze,constraint:bt,initialCoordinates:mt,offset:ut};wt?.(We),d({type:"onDragPending",event:We})},onStart(ze){const bt=B.current;if(bt==null)return;const mt=w.get(bt);if(!mt)return;const{onDragStart:ut}=O.current,At={activatorEvent:it,active:{id:bt,data:mt.data,rect:M}};Jt.unstable_batchedUpdates(()=>{ut?.(At),S(Qt.Initializing),h({type:nt.DragStart,initialCoordinates:ze,active:bt}),d({type:"onDragStart",event:At}),F(oe.current),A(it)})},onMove(ze){h({type:nt.DragMove,coordinates:ze})},onEnd:Re(nt.DragEnd),onCancel:Re(nt.DragCancel)});oe.current=Ne;function Re(ze){return async function(){const{active:mt,collisions:ut,over:At,scrollAdjustedTranslate:wt}=Z.current;let We=null;if(mt&&wt){const{cancelDrop:Dt}=O.current;We={activatorEvent:it,active:mt,collisions:ut,delta:wt,over:At},ze===nt.DragEnd&&typeof Dt=="function"&&await Promise.resolve(Dt(We))&&(ze=nt.DragCancel)}B.current=null,Jt.unstable_batchedUpdates(()=>{h({type:ze}),S(Qt.Uninitialized),ye(null),F(null),A(null),oe.current=null;const Dt=ze===nt.DragEnd?"onDragEnd":"onDragCancel";if(We){const Lt=O.current[Dt];Lt?.(We),d({type:Dt,event:We})}})}}},[w]),J=C.useCallback((Ee,pe)=>(je,Je)=>{const qe=je.nativeEvent,it=w.get(Je);if(B.current!==null||!it||qe.dndKit||qe.defaultPrevented)return;const Ne={active:it};Ee(je,pe.options,Ne)===!0&&(qe.dndKit={capturedBy:pe.sensor},B.current=Je,Y(je,pe))},[w,Y]),ie=hh(u,J);bh(u),Kt(()=>{K&&b===Qt.Initializing&&S(Qt.Initialized)},[K,b]),C.useEffect(()=>{const{onDragMove:Ee}=O.current,{active:pe,activatorEvent:je,collisions:Je,over:qe}=Z.current;if(!pe||!je)return;const it={active:pe,activatorEvent:je,collisions:Je,delta:{x:Be.x,y:Be.y},over:qe};Jt.unstable_batchedUpdates(()=>{Ee?.(it),d({type:"onDragMove",event:it})})},[Be.x,Be.y]),C.useEffect(()=>{const{active:Ee,activatorEvent:pe,collisions:je,droppableContainers:Je,scrollAdjustedTranslate:qe}=Z.current;if(!Ee||B.current==null||!pe||!qe)return;const{onDragOver:it}=O.current,Ne=Je.get(Xe),Re=Ne&&Ne.rect.current?{id:Ne.id,rect:Ne.rect.current,data:Ne.data,disabled:Ne.disabled}:null,ze={active:Ee,activatorEvent:pe,collisions:je,delta:{x:qe.x,y:qe.y},over:Re};Jt.unstable_batchedUpdates(()=>{ye(Re),it?.(ze),d({type:"onDragOver",event:ze})})},[Xe]),Kt(()=>{Z.current={activatorEvent:H,active:T,activeNode:q,collisionRect:Le,collisions:Pe,droppableRects:V,draggableNodes:w,draggingNode:ve,draggingNodeRect:Ie,droppableContainers:R,over:Ce,scrollableAncestors:De,scrollAdjustedTranslate:Be},M.current={initial:Ie,translated:Le}},[T,q,Pe,Le,w,ve,Ie,V,R,Ce,De,Be]),lh({...z,delta:E,draggingRect:Le,pointerCoordinates:Ae,scrollableAncestors:De,scrollableAncestorRects:Ze});const he=C.useMemo(()=>({active:T,activeNode:q,activeNodeRect:K,activatorEvent:H,collisions:Pe,containerNodeRect:re,dragOverlay:_e,draggableNodes:w,droppableContainers:R,droppableRects:V,over:Ce,measureDroppableContainers:U,scrollableAncestors:De,scrollableAncestorRects:Ze,measuringConfiguration:$,measuringScheduled:W,windowRect:xe}),[T,q,K,H,Pe,re,_e,w,R,V,Ce,U,De,Ze,$,W,xe]),ke=C.useMemo(()=>({activatorEvent:H,activators:ie,active:T,activeNodeRect:K,ariaDescribedById:{draggable:L},dispatch:h,draggableNodes:w,over:Ce,measureDroppableContainers:U}),[H,ie,T,K,h,L,w,Ce,U]);return de.createElement(Wa.Provider,{value:f},de.createElement(ar.Provider,{value:ke},de.createElement(sl.Provider,{value:he},de.createElement(Zr.Provider,{value:ne},l)),de.createElement(Rh,{disabled:i?.restoreFocus===!1})),de.createElement(Du,{...i,hiddenTextDescribedById:L}));function we(){const Ee=D?.autoScrollEnabled===!1,pe=typeof n=="object"?n.enabled===!1:n===!1,je=k&&!Ee&&!pe;return typeof n=="object"?{...n,enabled:je}:{enabled:je}}}),Dh=C.createContext(null),po="button",Lh="Draggable";function Ph(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=Gr(Lh),{activators:v,activatorEvent:i,active:n,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=C.useContext(ar),{role:_=po,roleDescription:y="draggable",tabIndex:x=0}=p??{},a=n?.id===s,h=C.useContext(a?Zr:Dh),[d,f]=Tr(),[b,S]=Tr(),k=yh(v,s),j=Qs(r);Kt(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:b,data:j}),()=>{const E=c.get(s);E&&E.key===m&&c.delete(s)}),[c,s]);const w=C.useMemo(()=>({role:_,tabIndex:x,"aria-disabled":o,"aria-pressed":a&&_===po?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[o,_,x,a,y,u.draggable]);return{active:n,activatorEvent:i,activeNodeRect:l,attributes:w,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:S,transform:h}}function Oh(){return C.useContext(sl)}const Ih="Droppable",Bh={timeout:25};function Fh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=Gr(Ih),{active:v,dispatch:i,over:n,measureDroppableContainers:l}=C.useContext(ar),u=C.useRef({disabled:r}),c=C.useRef(!1),g=C.useRef(null),_=C.useRef(null),{disabled:y,updateMeasurementsFor:x,timeout:a}={...Bh,...p},h=Qs(x??o),d=C.useCallback(()=>{if(!c.current){c.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),_.current=null},a)},[a]),f=Qr({callback:d,disabled:y||!v}),b=C.useCallback((w,E)=>{f&&(E&&(f.unobserve(E),c.current=!1),w&&f.observe(w))},[f]),[S,k]=Tr(b),j=Qs(s);return C.useEffect(()=>{!f||!S.current||(f.disconnect(),c.current=!1,f.observe(S.current))},[S,f]),C.useEffect(()=>(i({type:nt.RegisterDroppable,element:{id:o,key:m,disabled:r,node:S,rect:g,data:j}}),()=>i({type:nt.UnregisterDroppable,key:m,id:o})),[o]),C.useEffect(()=>{r!==u.current.disabled&&(i({type:nt.SetDroppableDisabled,id:o,key:m,disabled:r}),u.current.disabled=r)},[o,m,r,i]),{active:v,rect:g,isOver:n?.id===o,node:S,over:n,setNodeRef:k}}function zh(e){let{animation:s,children:r}=e;const[o,p]=C.useState(null),[m,v]=C.useState(null),i=Dr(r);return!r&&!o&&i&&p(i),Kt(()=>{if(!m)return;const n=o?.key,l=o?.props.id;if(n==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,o,m]),de.createElement(de.Fragment,null,r,o?C.cloneElement(o,{ref:v}):null)}const Wh={x:0,y:0,scaleX:1,scaleY:1};function Hh(e){let{children:s}=e;return de.createElement(ar.Provider,{value:tl},de.createElement(Zr.Provider,{value:Wh},s))}const $h={position:"fixed",touchAction:"none"},Uh=e=>xn(e)?"transform 250ms ease":void 0,qh=C.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:i,style:n,transform:l,transition:u=Uh}=e;if(!i)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...$h,width:i.width,height:i.height,top:i.top,left:i.left,transform:Zs.Transform.toString(c),transformOrigin:p&&o?Ou(o,i):void 0,transition:typeof u=="function"?u(o):u,...n};return de.createElement(r,{className:v,style:g,ref:s},m)}),Kh=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[i,n]of Object.entries(m.active))n!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(m!=null&&m.dragOverlay)for(const[i,n]of Object.entries(m.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[n,l]of Object.entries(p))r.node.style.setProperty(n,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},Xh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:Zs.Transform.toString(s)},{transform:Zs.Transform.toString(r)}]},Vh={duration:250,easing:"ease",keyframes:Xh,sideEffects:Kh({styles:{active:{opacity:"0"}}})};function Yh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return Yr((m,v)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const l=el(v);if(!l)return;const{transform:u}=vt(v).getComputedStyle(v),c=$a(u);if(!c)return;const g=typeof s=="function"?s:Gh(s);return Ga(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function Gh(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...Vh,...e};return m=>{let{active:v,dragOverlay:i,transform:n,...l}=m;if(!s)return;const u={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},c={scaleX:n.scaleX!==1?v.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?v.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-u.x,y:n.y-u.y,...c},_=p({...l,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=_,x=_[_.length-1];if(JSON.stringify(y)===JSON.stringify(x))return;const a=o?.({active:v,dragOverlay:i,...l}),h=i.node.animate(_,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let go=0;function Qh(e){return C.useMemo(()=>{if(e!=null)return go++,go},[e])}const Zh=de.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:v,wrapperElement:i="div",className:n,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggableNodes:y,droppableContainers:x,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:S}=Oh(),k=C.useContext(Zr),j=Qh(c?.id),w=rl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:S}),E=wn(g),R=Yh({config:o,draggableNodes:y,droppableContainers:x,measuringConfiguration:d}),P=E?a.setRef:void 0;return de.createElement(Hh,null,de.createElement(zh,{animation:R},c&&j?de.createElement(qh,{key:j,id:c.id,ref:P,as:i,activatorEvent:u,adjustScale:s,className:n,transition:m,rect:E,style:{zIndex:l,...p},transform:w},r):null))}),il=768;function Jh(e){const s=window.matchMedia(`(max-width: ${il-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function ef(){return window.innerWidth<il}function tf(){return!1}function nl(){return C.useSyncExternalStore(Jh,ef,tf)}function Cn(e){return Rt({queryKey:ae.workspaces.list(e),queryFn:()=>me.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ol(e){const s=ot();return _t({mutationFn:r=>me.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ae.workspaces.list(e)}),s.invalidateQueries({queryKey:ae.tasks.all})}})}function al(){const e=ot();return _t({mutationFn:({id:s,commitMessage:r})=>me.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all}),e.invalidateQueries({queryKey:ae.git.all})},onError:()=>{e.invalidateQueries({queryKey:ae.git.all})}})}function sf(){const e=ot();return _t({mutationFn:s=>me.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function kn(){return _t({mutationFn:({workspaceId:e,editorType:s})=>me.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function En(e,s={}){return Rt({queryKey:ae.workspaces.gitStatus(e),queryFn:()=>me.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function ll(){const e=ot();return _t({mutationFn:s=>me.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function jn(){const e=ot();return _t({mutationFn:s=>me.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ae.git.all})}})}function rf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===rt.RUNNING||v.status===rt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Nn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:i}=ue(),{data:n,isLoading:l}=Cn(m===void 0&&e?o:""),u=m??n,c=m===void 0&&e&&l,g=C.useMemo(()=>rf(u,i),[u,i]);return t.jsx(Ur,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((_,y)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:_})]},y))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const fe={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Hi={[fe.Review]:{label:"Review",icon:Ca,iconClass:"text-warning",accentClass:"text-warning"},[fe.Running]:{label:"Running",icon:wa,iconClass:"text-info",accentClass:"text-info"},[fe.Pending]:{label:"Pending",icon:Sa,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[fe.Done]:{label:"Done",icon:ya,iconClass:"text-success/80",accentClass:"text-success"},[fe.Cancelled]:{label:"Cancelled",icon:ba,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},nf=[fe.Review,fe.Running,fe.Pending,fe.Done,fe.Cancelled],cl=C.createContext(null),of=3e4;function af(e=of){const[,s]=C.useState(0);C.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function lf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?ft("{count}s ago",{count:s}):s<3600?ft("{count}m ago",{count:Math.floor(s/60)}):s<86400?ft("{count}h ago",{count:Math.floor(s/3600)}):ft("{count}d ago",{count:Math.floor(s/86400)})}function cf({task:e,status:s,isSelected:r,isAgentActive:o,project:p,onSelectTask:m,onTaskStatusChange:v,onDeleteTask:i,disableDrag:n}){const{t:l}=ue(),u=C.useContext(cl),c=C.useRef(null),g=!!e.projectArchivedAt,_=g||!!n,{attributes:y,listeners:x,setNodeRef:a,isDragging:h}=Ph({id:e.id,data:{task:e,fromStatus:s},disabled:_}),d=C.useCallback(T=>{c.current=T,a(T),u&&(T?u.registry.set(e.id,T):u.registry.delete(e.id))},[a,u,e.id]);C.useEffect(()=>()=>{u?.registry.delete(e.id)},[e.id,u]);const[f,b]=C.useState(null),[S,k]=C.useState(!1),j=C.useRef(null),w=C.useRef(null),E=C.useCallback(T=>{g||!v&&!i||(T.preventDefault(),b({x:T.clientX,y:T.clientY}))},[g,v,i]),R=C.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),P=C.useCallback(T=>{if(!n||g||!v&&!i)return;const B=T.touches[0];if(!B)return;const{clientX:D,clientY:F}=B;w.current=setTimeout(()=>{w.current=null,b({x:D,y:F})},500)},[n,g,v,i]);C.useEffect(()=>{if(!f)return;const T=B=>{j.current&&!j.current.contains(B.target)&&b(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[f]);const M=p?p.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>m(e.id),onContextMenu:E,onTouchStart:P,onTouchEnd:R,onTouchMove:R,title:M,"aria-label":M?`${e.title} — ${M}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
7
7
|
${h?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,..._?{}:x,..._?{}:y,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:B}=
|
|
8
|
+
${r?"bg-accent":"hover:bg-accent/50"}`,..._?{}:x,..._?{}:y,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:B}=Hi[s];return t.jsx(T,{className:`${B} ${s===fe.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?l("源码已删除"):l("已删除")}),o&&t.jsxs("span",{className:"relative inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-success/70"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-success"})]}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:lf(e.updatedAt)}),p&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${p.color.replace("text-","bg-")}`})]}),f&&t.jsxs("div",{ref:j,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:f.x,top:f.y},children:[v&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:l("Move to")}),nf.filter(T=>T!==s).map(T=>{const{icon:B,label:D,accentClass:F}=Hi[T];return t.jsxs("button",{onClick:()=>{v(e.id,T),b(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(B,{className:`w-3.5 h-3.5 ${F}`}),t.jsx("span",{className:"text-foreground/80",children:l(D)})]},T)})]}),i&&t.jsxs(t.Fragment,{children:[v&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{k(!0),b(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:l("Delete Task")})]})]})]}),t.jsx(Nn,{isOpen:S,onClose:()=>k(!1),onConfirm:()=>{i?.(e.id),k(!1)},taskId:e.id,taskTitle:e.title})]})}const df=C.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:i,activeTaskIds:n,isDragging:l,dragFromStatus:u,onTaskStatusChange:c,onDeleteTask:g,disableDrag:_}){const{t:y}=ue(),[x,a]=C.useState(p);af();const h=r.length===0,d=l&&u===o,f=l&&u!==o,{setNodeRef:b,isOver:S}=Fh({id:`group-${o}`,data:{status:o}}),k=o===fe.Review,j=y(s),w=l?d&&(x||!0):x;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!l&&a(E=>!E),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:j}),k&&!h?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:w?t.jsx(xt,{size:12}):t.jsx(Nt,{size:12})})]}),f&&t.jsx("div",{ref:b,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
9
|
${S?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:S?y("Drop into {title}",{title:j}):y("Drop here")})}),w&&!f&&t.jsx("div",{ref:d?void 0:b,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
10
10
|
${S&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
11
|
-
${h&&l?"border border-dashed border-border mx-2":""}`,children:h?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:y("No tasks")}):r.map(E=>{const R=m===E.id,P=
|
|
12
|
-
${x===
|
|
13
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:_(A?"New Task":"Deleted projects are read-only"),children:[t.jsx(
|
|
14
|
-
`).map(
|
|
11
|
+
${h&&l?"border border-dashed border-border mx-2":""}`,children:h?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:y("No tasks")}):r.map(E=>{const R=m===E.id,P=n?.has(E.id)??!1,M=E.projectId?i.find(T=>T.id===E.projectId):void 0;return t.jsx(cf,{task:E,status:o,isSelected:R,isAgentActive:P,project:M,onSelectTask:v,onTaskStatusChange:E.projectArchivedAt?void 0:c,onDeleteTask:E.projectArchivedAt?void 0:g,disableDrag:_},E.id)})})]})}),uf=12,hf=50;function ff({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ue(),[v,i]=C.useState(""),[n,l]=C.useState(0),u=C.useRef(null);C.useEffect(()=>{e&&(i(""),l(0))},[e]);const c=C.useMemo(()=>{const y=v.trim().toLowerCase();return y?r.filter(x=>x.title.toLowerCase().includes(y)).slice(0,hf):r.slice(0,uf)},[r,v]);C.useEffect(()=>{l(0)},[v]),C.useEffect(()=>{u.current?.children[n]?.scrollIntoView({block:"nearest"})},[n]);const g=C.useCallback(y=>{p(y),s()},[p,s]),_=C.useCallback(y=>{if(y.key==="Escape")y.preventDefault(),s();else if(y.key==="ArrowDown")y.preventDefault(),l(x=>Math.min(x+1,c.length-1));else if(y.key==="ArrowUp")y.preventDefault(),l(x=>Math.max(x-1,0));else if(y.key==="Enter"&&!y.nativeEvent.isComposing){y.preventDefault();const x=c[n];x&&g(x.id)}},[s,c,n,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(on,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:y=>i(y.target.value),onKeyDown:_,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((y,x)=>{const a=o.find(f=>f.id===y.projectId),{icon:h,iconClass:d}=Hi[y.status];return t.jsxs("button",{onClick:()=>g(y.id),onMouseEnter:()=>l(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
+
${x===n?"bg-accent":""}`,children:[t.jsx(h,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:y.title,children:y.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},y.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const mf=260,pf=220;function gf(e){const s={[fe.Review]:[],[fe.Running]:[],[fe.Pending]:[],[fe.Done]:[],[fe.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const vf=[{status:fe.Review,title:"Review",defaultOpen:!0},{status:fe.Running,title:"Running",defaultOpen:!0},{status:fe.Pending,title:"Pending",defaultOpen:!1},{status:fe.Done,title:"Done",defaultOpen:!1},{status:fe.Cancelled,title:"Cancelled",defaultOpen:!1}];function vo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:i,onCreateProject:n,isCreateActive:l,activeTaskIds:u,onTaskStatusChange:c,onDeleteTask:g}){const{t:_}=ue(),y=nl(),[x,a]=C.useState(null),[h,d]=C.useState(null),[f,b]=C.useState(!1),S=C.useRef(new Map),k=C.useRef(new Set),j=C.useRef(new Map),w=C.useMemo(()=>({registry:S.current}),[]),E=C.useCallback(L=>{L.remove(),k.current.delete(L)},[]),R=p?e.filter(L=>L.projectId===p):e,P=C.useCallback((L,I)=>{const $=document.querySelector(`[data-task-group-status="${L}"]`);if(!$)return null;const U=($.querySelector("button")??$).getBoundingClientRect();return U.width===0||U.height===0?null:new DOMRect(U.left+8,U.bottom+4,I.width,I.height)},[]),M=C.useCallback((L,I,$,V=!1)=>{const U=document.createElement("div");U.setAttribute("aria-hidden","true"),U.innerHTML=$;const W=U.firstElementChild;W&&(W.style.cssText="",W.className=W.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),W.style.pointerEvents="none",W.style.width=`${L.width}px`,W.style.height=`${L.height}px`,W.style.margin="0",W.style.backgroundColor="var(--sidebar-accent)",W.style.borderRadius="0.375rem",W.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",W.style.opacity="0.96",W.style.transition="none",W.setAttribute("tabindex","-1")),Object.assign(U.style,{position:"fixed",left:`${L.left}px`,top:`${L.top}px`,width:`${L.width}px`,height:`${L.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(U),k.current.add(U);const q=I.left-L.left,N=I.top-L.top;U.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${q}px, ${N}px)`,opacity:V?.12:.96,offset:1}],{duration:V?pf:mf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>E(U),()=>E(U))},[E]);C.useLayoutEffect(()=>{const L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,I=new Map;for(const $ of R){const V=S.current.get($.id);if(!V)continue;const U={status:$.status,rect:V.getBoundingClientRect(),html:V.outerHTML};if(I.set($.id,U),L)continue;const W=j.current.get($.id);if(!W||W.status===$.status)continue;const q=U.rect.left-W.rect.left,N=U.rect.top-W.rect.top;Math.abs(q)<1&&Math.abs(N)<1||M(W.rect,U.rect,W.html)}if(!L)for(const[$,V]of j.current){if(I.has($))continue;const U=R.find(q=>q.id===$);if(!U||U.status===V.status)continue;const W=P(U.status,V.rect);W&&M(V.rect,W,V.html,!0)}j.current=I},[R,M,P]),C.useEffect(()=>()=>{for(const L of k.current)L.remove();k.current.clear()},[]);const T=Pu(Lu(Sn,{activationConstraint:{distance:8}})),B=C.useCallback(L=>{const I=L.active.data.current?.task,$=L.active.data.current?.fromStatus;I&&a(I),$&&d($)},[]),D=C.useCallback(L=>{a(null),d(null);const{active:I,over:$}=L;if(!$)return;const V=I.data.current?.task,U=I.data.current?.fromStatus,W=$.data.current?.status;!V||!U||!W||V.projectArchivedAt||U!==W&&c?.(V.id,W)},[c]),A=!!!(p?s.find(L=>L.id===p)??null:null)?.archivedAt,O=gf(R);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[n&&t.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:_("New Project"),children:[t.jsx(_d,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Project")})]}),t.jsxs("button",{onClick:i,disabled:!A,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
13
|
+
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:_(A?"New Task":"Deleted projects are read-only"),children:[t.jsx(md,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Task")})]}),t.jsxs("button",{onClick:()=>b(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:_("Search"),children:[t.jsx(on,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("Search")})]}),t.jsxs(ed,{to:"/conversations",className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:_("对话"),children:[t.jsx(qr,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("对话")})]})]}),R.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Ns,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:_("No tasks")}),A&&i?t.jsx("button",{onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:_("New Task")}):null]}):t.jsx(cl.Provider,{value:w,children:t.jsxs(Th,{sensors:T,onDragStart:B,onDragEnd:D,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:vf.map(({status:L,title:I,defaultOpen:$})=>t.jsx(df,{title:I,tasks:O[L],status:L,defaultOpen:$,selectedTaskId:r,onSelectTask:o,projects:s,activeTaskIds:u,isDragging:x!==null,dragFromStatus:h,onTaskStatusChange:c,onDeleteTask:g,disableDrag:y},L))}),t.jsx(Zh,{dropAnimation:null,children:x?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:x.title,children:x.title})}):null})]})}),R.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:_("{count} tasks",{count:R.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:_("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:_("{count} tasks",{count:0})})}),t.jsx(ff,{isOpen:f,onClose:()=>b(!1),tasks:R,projects:s,onSelectTask:o})]})}const xf=10,_f=24,dl=xf*_f,bf=8;function yf(e,s=dl){return e>s+bf}function Sf(e,s){return e.includes(s)?e:[...e,s]}function wf(e,s){return e.filter(r=>r!==s)}function Cf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const Jr=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function xo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function kf(e,s=[],r=[]){const o=new Set(r.filter(m=>Jr.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const i=xo(m.sortTime)-xo(v.sortTime);return i!==0?i:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function Ef(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function jf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Nf(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const v=r[p];return v?`${v} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function Rf(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Af({status:e}){const{t:s}=ue();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(Ef(e))})}function Mf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:l}=ue(),[u,c]=C.useState(Rf),g=C.useMemo(()=>e.filter(y=>Jr.has(y.status)).sort((y,x)=>Date.parse(x.updatedAt??x.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const _=Nf(g,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(y=>!y),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:_})]}),u?t.jsx(xt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Da,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(y=>{const x=s.get(y.memberId),a=r.get(y.workRequestId),h=!!(y.sessionId&&o),d=!!x,f=i===y.id,b=m&&v===y.memberId,S=a?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:S,className:ee("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>y.sessionId&&o?.(y.sessionId),onKeyDown:k=>{!h||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(y.sessionId))},children:[t.jsx(Ft,{name:x?.name??l("Agent"),avatar:x?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:x?.name??l("Agent")}),t.jsx("span",{className:ee("shrink-0",jf(y.status)),children:t.jsx(Af,{status:y.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&o?.(y.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${x?.name??l("Agent")}`,children:t.jsx(Bi,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${x?.name??l("Agent")}`,children:t.jsx(Rs,{size:12})})]}),d&&f&&x&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>p(x.id,!1),children:[t.jsx(Rs,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop only")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(x.id,!0),children:[t.jsx(Oa,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Br="/api",Tf=240,Df=/(^|\n)(```|~~~)[^\S\r\n]*mermaid(?:[\s\r\n]|$)/i;let $i=null;function Lf(e){return Df.test(e)}function Pf(){return $i??=sd(async()=>{const{mermaid:e}=await import("./index-BwKL3rKp.js").then(s=>s.bm);return{mermaid:e}},__vite__mapDeps([0,1,2])).then(({mermaid:e})=>({mermaid:e})),$i}function Of(e){const s=Lf(e),[r,o]=C.useState();return C.useEffect(()=>{if(!s){o(void 0);return}let p=!0;return Pf().then(m=>{p&&o(m)}).catch(()=>{$i=null,p&&o(void 0)}),()=>{p=!1}},[s]),s?r:void 0}let _o=0;function If(e,s){return _o+=1,{id:`pending-room-message-${Date.now()}-${_o}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function ul(e){return"pendingStatus"in e}const Bf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Br}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Ff(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function zf(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Ui(e,s){if(s.length===0)return e;const r=new Set(s.map(zf));return e.split(`
|
|
14
|
+
`).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const v of r){if(m===v)return null;if(m.startsWith(`${v} `)||m.startsWith(`${v} `))return`${p}${m.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
15
|
`).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
17
|
-
`).trim()}function
|
|
17
|
+
`).trim()}function Wf(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qi(e,s){return e instanceof Error?e.message:s}function Hf(e,s=Tf){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function $f(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function Uf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function bo(e){return e.membershipStatus!=="REMOVED"}function qf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Kf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Xf(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(v=>qf(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(p.length===0)return o;const m=p.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function Vf(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function Yf({content:e,isUser:s}){const r=Of(e);return t.jsx("div",{className:ee("prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(rn,{urlTransform:Bf,components:nn,plugins:r,controls:r?fd:void 0,children:e})})}function Gf({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,i)=>[v.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const i=`${Br}${v.url}`;if(v.mimeType.startsWith("image/")){const l=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:i,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(Ea,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:Ff(v.sizeBytes)})]}),t.jsx(pn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Qf({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m}){const v=C.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:i=[],isLoading:n}=pd(v),l=i.length>0?Ui(s,i):s;return t.jsxs(t.Fragment,{children:[l.trim()&&t.jsx(em,{message:e,content:l,attachments:i,isUser:o,tone:p}),t.jsx(Gf,{hasAttachmentIds:v.length>0,attachments:i,isLoading:n,onOpenImage:m})]})}function Zf({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(is,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(Pd,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${Br}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${Br}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(pn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Nt,{size:24,"aria-hidden":!0})})]})}function Jf({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
|
|
18
18
|
|
|
19
|
-
`);return m?{content:m,mentions:n,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Jf({message:e,content:s,attachments:r,isUser:n,tone:p=n?"user":"agent"}){const{t:m}=ce(),v=C.useId(),i=C.useRef(null),[o,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(null),y=ed(e.teamRunId,e.id,!1),x=y.data?.content,a=x?Ui(x,r):void 0,d=!!(a&&a!==s)?a:s,f=!!(e.isTruncated&&!dl(e)),b=o?.messageId===e.id&&o.content===d&&o.expanded,S=C.useCallback(()=>{const R=i.current;R&&c(bf(R.scrollHeight))},[]);C.useLayoutEffect(()=>{S();const R=i.current;if(!R)return;const P=window.requestAnimationFrame(S),M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(R),window.addEventListener("resize",S),()=>{window.cancelAnimationFrame(P),M?.disconnect(),window.removeEventListener("resize",S)}},[d,S]);const k=C.useCallback(async()=>{if(_(null),b){l({messageId:e.id,content:d,expanded:!1});return}if(f&&!x){const R=await y.refetch();if(R.error){_(qi(R.error,m("Failed to load full message")));return}const P=R.data?.content?Ui(R.data.content,r):d;l({messageId:e.id,content:P,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,f,x,y,b,e.id,d,m]),j=(u||f)&&!b,w=u||f,E=y.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:v,ref:i,onLoadCapture:S,className:ee("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:cl}:void 0,children:[t.jsx(Vf,{content:d,isUser:n}),j&&t.jsx("div",{className:ee("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),w&&t.jsxs("button",{type:"button","aria-expanded":b,"aria-controls":v,"aria-label":m(b?"Collapse message":"Expand full message"),disabled:E,onClick:()=>{k()},className:ee("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",E?"cursor-wait opacity-70":""),children:[b?t.jsx(Da,{size:13}):t.jsx(xt,{size:13}),t.jsx("span",{children:m(E?"Loading":b?"Collapse message":"Expand full message")})]}),g&&t.jsx("div",{className:ee("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:g})]})}function ul({senderName:e,avatar:s,createdAt:r,isUser:n,isSystem:p,children:m,headerAddon:v,bubbleClassName:i,isPending:o}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:ee("group flex items-start gap-3",n?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!n&&t.jsx(Ft,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:ee("flex min-w-0 max-w-[min(86%,46rem)] flex-col",n?"items-end":"items-start"),children:[t.jsxs("div",{className:ee("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",n?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:zf(r)}),v]}),t.jsx("div",{className:ee("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",n?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,o?"opacity-70":""),children:m})]}),n&&t.jsx(Ft,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function em({message:e,senderName:s,senderMember:r,memberById:n,displayContent:p,onOpenImage:m}){const{t:v}=ce(),i=e.senderType==="user",o=e.senderType==="system",l=dl(e)?e.pendingStatus:null,u=e.mentions??[],c=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",_=g?qf(e,n):[],y=t.jsxs(t.Fragment,{children:[g&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:_.join(", "),children:[t.jsx(Qd,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),_.length>0?`: ${_.join(", ")}`:""]})]}),!o&&c>0&&u.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",c]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(ul,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:o,headerAddon:y,bubbleClassName:i&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Gf,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:i&&l!=="failed",tone:o?"system":void 0,onOpenImage:m})})}function tm({request:e,member:s,onApprove:r,onReject:n,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:i}=ce();return t.jsx(ul,{senderName:s?.name??i("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Cs,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Hf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(ke,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(qt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(ke,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:n,children:[t.jsx(is,{size:12}),t.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function hl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:n,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:i,centered:o}){const{t:l}=ce(),u=ha(e.id),c=fa(e.id),g=ma(e.id),[_,y]=C.useState(""),[x,a]=C.useState(!1),[h,d]=C.useState(null),[f,b]=C.useState(0),[S,k]=C.useState([]),[j,w]=C.useState(!1),[E,R]=C.useState(null),[P,M]=C.useState([]),[T,B]=C.useState(null),D=C.useRef(null),F=C.useRef(null),{files:$,addFiles:A,removeFile:O,clear:L,restoreFiles:I,buildMarkdownLinks:U,getDoneAttachments:Y,isUploading:q}=nn(),W=$.some(H=>H.status==="done"&&H.attachment),[K,N]=C.useState(null),{scrollRef:z,contentRef:V,isAtBottom:X,scrollToBottom:re}=on({resize:"smooth",initial:"instant"}),J=C.useMemo(()=>new Map((e.members??[]).map(H=>[H.id,H])),[e.members]),se=C.useMemo(()=>(e.members??[]).filter(bo),[e.members]),ve=C.useMemo(()=>new Map((e.invocations??[]).map(H=>[H.id,H])),[e.invocations]),pe=C.useMemo(()=>{const H=new Set(s.map(Z=>Z.id)),G=P.filter(Z=>!H.has(Z.id));return[...s,...G].sort((Z,ae)=>{const de=Date.parse(Z.createdAt??""),fe=Date.parse(ae.createdAt??"");return(Number.isNaN(de)?0:de)-(Number.isNaN(fe)?0:fe)})},[s,P]),Le=C.useMemo(()=>new Map((e.workRequests??[]).map(H=>[H.id,H])),[e.workRequests]),oe=C.useMemo(()=>Cf(pe,e.workRequests??[],e.invocations??[]),[pe,e.invocations,e.workRequests]),dt=C.useMemo(()=>(e.invocations??[]).filter(H=>Jr.has(H.status)),[e.invocations]),ge=C.useMemo(()=>S.map(H=>J.get(H)).filter(H=>!!H).filter(bo),[J,S]),Ee=C.useMemo(()=>{const H=h?.query??"";return se.filter(G=>$f(G,H)).sort((G,Z)=>{const ae=S.includes(G.id),de=S.includes(Z.id);return ae!==de?ae?1:-1:G.name.localeCompare(Z.name)})},[se,h?.query,S]),Ze=!r&&(x||!!h)&&Ee.length>0,tt=C.useCallback((H,G)=>{if(G==null){d(null);return}d(Wf(H,G)),b(0)},[]),Se=C.useCallback(H=>{k(fe=>yf(fe,H.id));const G=`@${H.name} `;if(h){const fe=`${_.slice(0,h.start)}${G}${_.slice(h.end)}`,Ve=h.start+G.length;y(fe),d(null),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(Ve,Ve)});return}const Z=_.length===0||/\s$/.test(_)?"":" ",ae=`${_}${Z}${G}`,de=ae.length;y(ae),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(de,de)})},[_,h]),it=C.useCallback(H=>{k(G=>Sf(G,H))},[]),xe=C.useCallback(H=>{const G=H.target.value;y(G),R(null);const Z=H.target;Z.style.height="auto",Z.style.height=`${Math.max(i?40:72,Math.min(Z.scrollHeight,i?140:240))}px`,a(!1),tt(G,Z.selectionStart)},[i,tt]),je=C.useCallback(H=>{const G=H.target.files;G&&G.length>0&&(A(Array.from(G)),R(null)),H.target.value=""},[A]),Ie=C.useCallback(H=>{const G=[];for(const Z of H.clipboardData.items)if(Z.kind==="file"){const ae=Z.getAsFile();ae&&G.push(ae)}G.length>0&&(H.preventDefault(),A(G),R(null))},[A]),Pe=C.useCallback(async()=>{if(r||j||q)return;const H=U(),G=Y().map(He=>He.id),Z=wf(S,se),ae=Zf({draft:_,attachmentMarkdown:H,attachmentIds:G,mentions:Z});if(!ae||!_.trim()&&!W)return;const de=Of(e.id,ae),fe=_,Ve=S,Te=$;M(He=>[...He,de]),y(""),k([]),a(!1),d(null),L(),D.current&&(D.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),w(!0),R(null);try{const He=await p(ae);M(Re=>Re.filter(Ae=>Ae.id!==de.id)),He&&typeof He=="object"&&"id"in He&&requestAnimationFrame(()=>re())}catch(He){const Re=He instanceof Error?He.message:"Failed to send room message";M(Ae=>Ae.map(we=>we.id===de.id?{...we,pendingStatus:"failed",error:Re}:we)),y(Ae=>Ae.length===0?fe:Ae),k(Ae=>Ae.length===0?Ve:Ae),I(Te),R(Re),requestAnimationFrame(()=>re())}finally{w(!1)}},[se,$,U,L,i,_,Y,W,j,q,p,r,I,re,S,e.id]),Ne=C.useCallback(H=>{const G=H.nativeEvent.isComposing||H.nativeEvent.keyCode===229;if(Ze){if(H.key==="ArrowDown"){H.preventDefault(),b(Z=>(Z+1)%Ee.length);return}if(H.key==="ArrowUp"){H.preventDefault(),b(Z=>(Z-1+Ee.length)%Ee.length);return}if(H.key==="Enter"&&!G||H.key==="Tab"){H.preventDefault();const Z=Ee[f]??Ee[0];Z&&Se(Z);return}if(H.key==="Escape"){H.preventDefault(),d(null),a(!1);return}}H.key==="Enter"&&!H.shiftKey&&!H.repeat&&!G&&(H.preventDefault(),Pe())},[Se,Pe,f,Ee,Ze]);C.useEffect(()=>{y(""),k([]),a(!1),d(null),R(null),M([]),L(),B(null),D.current&&(D.current.style.height=i?"40px":"72px")},[L,i,e.id]);const Me=u.isError?u.error:c.isError?c.error:null,be=u.isPending||c.isPending,ye=C.useCallback((H,G)=>{g.mutate({memberId:H,cancelQueued:G},{onSuccess:()=>B(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[K&&t.jsx(Qf,{images:K.images,index:K.index,onClose:()=>N(null),onSelect:H=>N(G=>G&&{...G,index:H})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:z,className:ee("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:V,className:ee(i?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[oe.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(us,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:l("No room messages yet")})]}):oe.map(H=>{if(H.kind==="pendingApproval"){const fe=H.request,Ve=J.get(fe.targetMemberId),Te=u.isPending&&u.variables===fe.id,He=c.isPending&&c.variables===fe.id;return t.jsx(tm,{request:fe,member:Ve,onApprove:()=>u.mutate(fe.id),onReject:()=>c.mutate(fe.id),isActionPending:be,isApprovePending:Te,isRejectPending:He},H.key)}const G=H.message,Z=Xf(G,J,ve),ae=G.senderType==="user"?l("你"):G.senderType==="system"?l("System"):Z?.name??l("Agent"),de=Kf(G,J);return t.jsx(em,{message:G,senderName:ae,senderMember:Z,memberById:J,displayContent:de,onOpenImage:(fe,Ve)=>N({images:fe,index:Ve})},H.key)}),Me&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(Me,l("Failed to update work request"))}),g.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(g.error,l("Failed to stop member work"))})]})}),!X&&t.jsxs("button",{type:"button",onClick:()=>re(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:l("Back to bottom")})]})]}),t.jsx("div",{className:ee("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:ee(o&&"max-w-4xl mx-auto"),children:[t.jsx(Af,{invocations:dt,memberById:J,workRequestById:Le,onViewInvocationSession:m,onStopMember:ye,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:T,onToggleStopConfirm:H=>B(G=>G===H?null:H)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:n??l("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ze&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:l(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ee.map((H,G)=>{const Z=S.includes(H.id),ae=G===f;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(G),onMouseDown:de=>{de.preventDefault(),Se(H)},className:ee("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ae?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ft,{name:H.name,avatar:H.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:H.name}),Z&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:l("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[H.providerId,H.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Gn,{size:15,className:"text-neutral-400"})]},H.id)})})]}),ge.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:ge.map(H=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",H.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:H.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>it(H.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:l("Remove mention"),"aria-label":`${l("Remove mention")} ${H.name}`,children:t.jsx(is,{size:12})})]},H.id))}),t.jsx(an,{files:$,onRemove:O}),t.jsx("textarea",{ref:D,value:_,rows:i?1:void 0,onChange:xe,onKeyDown:Ne,onPaste:Ie,onClick:H=>tt(_,H.currentTarget.selectionStart),onSelect:H=>tt(_,H.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:ee("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:ee("flex items-center justify-between",i?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:je}),t.jsx("button",{type:"button",onClick:()=>F.current?.click(),title:l("Upload file"),"aria-label":l("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(dn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{a(H=>!H),d(null),requestAnimationFrame(()=>D.current?.focus())},disabled:ge.length===0&&se.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:ee("rounded-lg transition-colors",i?"p-1.5":"p-2",x?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",ge.length===0&&se.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Gn,{size:i?15:18})}),ge.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[ge.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Pe()},disabled:r||j||q||!_.trim()&&!W,title:l(q?"Uploading...":j?"发送中...":"发送"),"aria-label":l(q?"Uploading...":j?"发送中...":"发送"),className:ee("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(_.trim()||W)&&!r&&!j&&!q?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||q?"opacity-70":""),children:t.jsx(ln,{size:i?15:18})})]}),E&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:E})]})]})})]})}function sm(e){return e?e.slice(0,8):""}function yo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Rn(e){return e?.workspaceKind===ls.MAIN_DIRECTORY}function hs(e){return e?Rn(e)?"Project directory":e.branchName:"—"}function ts(e){return e?.workingDir||e?.worktreePath||void 0}function An(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),n=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?n.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,o=!!(p&&m.id===p),l=o?"main":m.parentWorkspaceId?"child":"root",u=i?.name??(m.ownerMemberId?`Member ${sm(m.ownerMemberId)}`:void 0),c=Rn(m)?"Project directory":o?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:o?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?hs(v):void 0,isMain:o}}).sort((m,v)=>{const i=l=>l.kind==="main"?0:l.kind==="child"?1:2,o=i(m)-i(v);return o!==0?o:yo(m.workspace.createdAt)-yo(v.workspace.createdAt)})}function fl(e,s,r){if(e?.length)return r&&e.some(n=>n.id===r)?r:s?.mainWorkspaceId&&e.some(n=>n.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(n=>n.status===Et.ACTIVE)?.id??e[0]?.id}function ml(e,s){return!e||e.status!==Et.ACTIVE||Rn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function pl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Mn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},rm=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],gl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],im=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],vl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],nm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function zs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Mn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function bs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Mn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function bi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Mn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function om(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function am(e){return{name:e.name.trim(),aliases:om(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function So(e,s){return e instanceof Error?e.message:s}function wo(e){return e.membershipStatus!=="REMOVED"}function Ki(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Co(e){return Ki(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function ko(e){return gl.find(s=>s.value===e)?.label??e}function lm(e){return vl.find(s=>s.value===e)?.label??e}function Ot({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Eo({icon:e,title:s,description:r,action:n}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,n?t.jsx("div",{className:"mt-4",children:n}):null]})}function cm({isOpen:e,onClose:s,teamRun:r}){const{t:n}=ce(),{data:p=[]}=sd(),{data:m=[]}=sr(),v=rd(r.id),i=id(r.id),o=nd(r.id),l=C.useRef(!1),[u,c]=C.useState("edit"),[g,_]=C.useState(null),[y,x]=C.useState(""),[a,h]=C.useState(zs()),[d,f]=C.useState(null),[b,S]=C.useState(null),k=r.members??[],j=C.useMemo(()=>k.filter(wo),[k]),w=C.useMemo(()=>b&&wo(b)&&!j.some(K=>K.id===b.id)?[...j,b]:j,[b,j]),E=g?j.find(K=>K.id===g)??null:null,R=b?.id===g?b:E,P=y?p.find(K=>K.id===y)??null:null,M=v.isPending||i.isPending||o.isPending,T=w.filter(Ki).length,B=C.useMemo(()=>{const K=m.map(({provider:N,availability:z})=>({value:N.id,label:N.name+(z.type==="NOT_FOUND"?n(" (不可用)"):""),disabled:z.type==="NOT_FOUND"}));return a.providerId&&!K.some(N=>N.value===a.providerId)&&K.unshift({value:a.providerId,label:`${a.providerId}${n(" (不可用)")}`,disabled:!0}),K},[a.providerId,m,n]);C.useEffect(()=>{if(!e){l.current=!1,S(null);return}if(l.current)return;l.current=!0;const K=w[0]??null;c(K?"edit":"add-preset"),_(K?.id??null),x(""),h(K?bs(K):zs()),f(null)},[w,e]),C.useEffect(()=>{b&&j.some(K=>K.id===b.id)&&S(null)},[b,j]),C.useEffect(()=>{u==="add-preset"&&P&&h(bi(P))},[u,P]);const D=(K,N)=>{h(z=>({...z,[K]:N}))},F=(K,N)=>{h(z=>({...z,capabilities:{...z.capabilities,[K]:N}}))},$=K=>{c("edit"),_(K.id),x(""),h(bs(K))},A=()=>{c("add-preset"),_(null);const K=P??p[0]??null;x(K?.id??""),h(K?bi(K):zs())},O=()=>{c("add-custom"),_(null),x(""),h(zs())},L=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),I=u==="add-preset"?!!y:u==="edit"?!!(R&&L):L,U=async()=>{try{if(u==="add-preset"){if(!y)return;const N=await v.mutateAsync({memberPresetId:y});ct.success(n("Member added")),S(N),c("edit"),_(N.id),x(""),h(bs(N));return}const K=am(a);if(!K.name||!K.providerId||!K.rolePrompt){ct.error(n("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:K});ct.success(n("Member added")),S(N),c("edit"),_(N.id),h(bs(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:K});ct.success(n("Member updated")),S(z=>z?.id===N.id?N:z),_(N.id),h(bs(N))}}catch(K){ct.error(So(K,n("Failed to save member")))}},Y=async()=>{if(d)try{if(await o.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const K=w.find(N=>N.id!==d.id)??null;_(K?.id??null),c(K?"edit":"add-preset"),h(K?bs(K):zs())}S(K=>K?.id===d.id?null:K),f(null),ct.success(n("Member removed"))}catch(K){ct.error(So(K,n("Failed to remove member")))}},q=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(xr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:n("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(so,{size:13}),n("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Eo,{icon:t.jsx(xr,{size:18}),title:n("No member presets"),description:n("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(es,{size:13}),n("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(K=>{const N=y===K.id;return t.jsxs("button",{type:"button",onClick:()=>{x(K.id),h(bi(K))},className:ee("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ft,{name:K.name,avatar:K.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:K.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:K.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[n(ko(K.workspacePolicy))," · ",n(lm(K.sessionPolicy))]})]}),N?t.jsx(qt,{size:16,className:"shrink-0 text-neutral-900"}):null]},K.id)})})})]}),W=()=>{const K=u==="edit";return K&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Eo,{icon:t.jsx(us,{size:18}),title:n("Select a member"),description:n("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(es,{size:13}),n("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[K?t.jsx(Ia,{size:15,className:"text-neutral-500"}):t.jsx(es,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n(K?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:n(K?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),K&&R?t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(fn,{size:13}),n("Remove")]}):t.jsxs(ke,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(xr,{size:13}),n("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[K&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ft,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:ee("h-2 w-2 shrink-0 rounded-full",Co(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",n(ko(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Name")}),t.jsx("input",{value:a.name,onChange:N=>D("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>D("aliasesText",N.target.value),placeholder:n("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Provider")}),t.jsx(cs,{value:a.providerId,onChange:N=>D("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>D("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Workspace policy")}),t.jsx(cs,{value:a.workspacePolicy,onChange:N=>D("workspacePolicy",N),options:gl.map(N=>({value:N.value,label:n(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Trigger policy")}),t.jsx(cs,{value:a.triggerPolicy,onChange:N=>D("triggerPolicy",N),options:im.map(N=>({value:N.value,label:n(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Session policy")}),t.jsx(cs,{value:a.sessionPolicy,onChange:N=>D("sessionPolicy",N),options:vl.map(N=>({value:N.value,label:n(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Queue policy")}),t.jsx(cs,{value:a.queueManagementPolicy,onChange:N=>D("queueManagementPolicy",N),options:nm.map(N=>({value:N.value,label:n(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:n("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>D("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ot,{children:n("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:rm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:z=>F(N.key,z.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:n(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Ms,{isOpen:e,onClose:M?()=>{}:s,title:n("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(ke,{type:"button",variant:"outline",onClick:s,disabled:M,children:n("Close")}),t.jsx(ke,{type:"button",onClick:U,disabled:M||!I,children:n(M?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:n("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[w.length," ",n("active")," · ",T," ",n("working")]})]}),t.jsx(ke,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:M,title:n("Add member"),children:t.jsx(es,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:w.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:n("No active members")}):t.jsx("div",{className:"space-y-1",children:w.map(K=>{const N=u==="edit"&&g===K.id;return t.jsxs("button",{type:"button",onClick:()=>$(K),className:ee("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ft,{name:K.name,avatar:K.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:ee("h-1.5 w-1.5 shrink-0 rounded-full",Co(K))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:K.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:K.providerId})]}),t.jsx(lu,{size:13,className:ee("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},K.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:M,className:ee("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(xr,{size:12}),n("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:M,className:ee("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(so,{size:12}),n("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?q():W()})]})}),t.jsx(qr,{isOpen:!!d,onClose:()=>f(null),onConfirm:Y,title:n("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:n("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?n("Remove this member from future TeamRun work?"):""}),d&&Ki(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(tr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:n("确认后会停止当前工作并取消队列")})]}):null]})})]})}const dm=[],um=[],hm=[],fm=240;function mm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const jo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function yi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function No(e,s){return e instanceof Error?e.message:s}function pm(e,s=fm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function _r(e){return e?e.instructionPreview??pm(e.instruction):""}function gm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function vm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function xm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function _m(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function bm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function ym(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Sm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function wm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Cm(e,s){return s.find(r=>r.memberId===e.id&&Jr.has(r.status))}function xl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:n,onViewInvocationSession:p}){const{t:m}=ce(),v=ha(e.id),i=fa(e.id),o=ma(e.id),[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(!1),[x,a]=C.useState(!1),h=e.members??dm,d=C.useMemo(()=>h.filter(D=>D.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??um,b=e.invocations??hm,S=C.useMemo(()=>An(s,e),[e,s]),k=C.useMemo(()=>new Map(f.map(D=>[D.id,D])),[f]),j=C.useMemo(()=>[...f].filter(D=>D.status==="PENDING_APPROVAL").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),w=C.useMemo(()=>[...f].filter(D=>D.status==="QUEUED").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),E=C.useMemo(()=>[...h].map(D=>({member:D,status:mm(D.status)})).sort((D,F)=>jo[D.status]-jo[F.status]),[h]),R=v.isError?v.error:i.isError?i.error:null,P=v.isPending||i.isPending,M=S.find(D=>D.workspace.id===r),T=e.messages??[],B=E.filter(({status:D})=>D==="running"||D==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(cm,{isOpen:x,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ns,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(Kr,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:T.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:B>0?`${B}/${d.length}`:d.length}),B>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),w.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:w.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(Cs,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(D=>{const F=h.find(O=>O.id===D.targetMemberId),$=v.isPending&&v.variables===D.id,A=i.isPending&&i.variables===D.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ft,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:_r(D)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(_m(D.requesterType))}),t.jsx("span",{children:yi(D.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(D.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:11}),t.jsx("span",{className:"truncate",children:m($?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(D.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(is,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},D.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(Ia,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:D,status:F})=>{const $=Cm(D,b),A=wm(b.filter(W=>W.memberId===D.id)),O=$?k.get($.workRequestId):void 0,L=c===D.id,I=F==="running"||F==="waiting room reply",U=I&&!!$,Y=l===D.id,q=o.isPending&&o.variables?.memberId===D.id;return t.jsxs("div",{className:ee("bg-white",L&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ft,{name:D.name,avatar:D.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:ee("h-1.5 w-1.5 shrink-0 rounded-full",xm(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:D.name}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",vm(F)),children:m(gm(F))})]}),I&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:_r(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>u(Y?null:D.id),disabled:o.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Rs,{size:12})}),$?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p($.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(Bi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(L?null:D.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":L,children:L?t.jsx(xt,{size:13}):t.jsx(Nt,{size:13})})]})]}),U&&Y&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:D.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Rs,{size:10}),t.jsx("span",{children:q&&o.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:D.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Pa,{size:10}),t.jsx("span",{children:q&&o.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),L&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:D.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(W=>{const K=k.get(W.workRequestId),N=!!(W.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:ee("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",bm(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:yi(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(K)||W.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&p?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(Bi,{size:10}),t.jsx("span",{children:m("Log")})]})]})},W.id)})})]}),E[E.length-1]?.member.id!==D.id&&!L&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},D.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(o.error,m("Failed to stop member work"))})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:w.length})]}),t.jsx("div",{className:"space-y-1",children:w.map(D=>{const F=h.find($=>$.id===D.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ft,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(D)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:yi(D.createdAt)})]})},D.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(D=>!D),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":_,"aria-label":m("Workspaces"),children:[t.jsx(Ns,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[M&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:hs(M.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:S.length}),_?t.jsx(xt,{size:13,className:"text-neutral-400"}):t.jsx(Nt,{size:13,className:"text-neutral-400"})]})]}),_&&t.jsx("div",{className:"space-y-1.5",children:S.map(D=>{const F=r===D.workspace.id;return t.jsx("div",{className:ee("rounded-md border bg-white px-3 py-2",F?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(D.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Sm(D.roleLabel)),children:m(D.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ym(D.workspace.status)),children:D.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:hs(D.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[D.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",D.ownerName]}),D.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",D.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>n?.(D.workspace.id),disabled:!n||F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[F?t.jsx(qt,{size:11}):t.jsx(ja,{size:11}),t.jsx("span",{children:m(F?"Selected":"Select")})]})]})},D.workspace.id)})})]}),j.length===0&&w.length===0&&E.every(({status:D})=>D==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Si={exports:{}},Ro;function km(){return Ro||(Ro=1,(function(e,s){(function(r,n){e.exports=n()})(self,(()=>(()=>{var r={4567:function(v,i,o){var l=this&&this.__decorate||function(f,b,S,k){var j,w=arguments.length,E=w<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,S,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(w<3?j(E):w>3?j(b,S,E):j(b,S))||E);return w>3&&E&&Object.defineProperty(b,S,E),E},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=o(9042),g=o(6114),_=o(9924),y=o(844),x=o(5596),a=o(4725),h=o(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
19
|
+
`);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function em({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent"}){const{t:m}=ue(),v=C.useId(),i=C.useRef(null),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(null),y=td(e.teamRunId,e.id,!1),x=y.data?.content,a=x?Ui(x,r):void 0,d=!!(a&&a!==s)?a:s,f=!!(e.isTruncated&&!ul(e)),b=n?.messageId===e.id&&n.content===d&&n.expanded,S=C.useCallback(()=>{const R=i.current;R&&c(yf(R.scrollHeight))},[]);C.useLayoutEffect(()=>{S();const R=i.current;if(!R)return;const P=window.requestAnimationFrame(S),M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(R),window.addEventListener("resize",S),()=>{window.cancelAnimationFrame(P),M?.disconnect(),window.removeEventListener("resize",S)}},[d,S]);const k=C.useCallback(async()=>{if(_(null),b){l({messageId:e.id,content:d,expanded:!1});return}if(f&&!x){const R=await y.refetch();if(R.error){_(qi(R.error,m("Failed to load full message")));return}const P=R.data?.content?Ui(R.data.content,r):d;l({messageId:e.id,content:P,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,f,x,y,b,e.id,d,m]),j=(u||f)&&!b,w=u||f,E=y.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:v,ref:i,onLoadCapture:S,className:ee("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:dl}:void 0,children:[t.jsx(Yf,{content:d,isUser:o}),j&&t.jsx("div",{className:ee("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),w&&t.jsxs("button",{type:"button","aria-expanded":b,"aria-controls":v,"aria-label":m(b?"Collapse message":"Expand full message"),disabled:E,onClick:()=>{k()},className:ee("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",E?"cursor-wait opacity-70":""),children:[b?t.jsx(Da,{size:13}):t.jsx(xt,{size:13}),t.jsx("span",{children:m(E?"Loading":b?"Collapse message":"Expand full message")})]}),g&&t.jsx("div",{className:ee("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:g})]})}function hl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:v,bubbleClassName:i,isPending:n}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:ee("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Ft,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:ee("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:ee("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Wf(r)}),v]}),t.jsx("div",{className:ee("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,n?"opacity-70":""),children:m})]}),o&&t.jsx(Ft,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function tm({message:e,senderName:s,senderMember:r,memberById:o,displayContent:p,onOpenImage:m}){const{t:v}=ue(),i=e.senderType==="user",n=e.senderType==="system",l=ul(e)?e.pendingStatus:null,u=e.mentions??[],c=e.workRequestIds?.length??0,g=e.visibility==="PRIVATE",_=g?Kf(e,o):[],y=t.jsxs(t.Fragment,{children:[g&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:_.join(", "),children:[t.jsx(Zd,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),_.length>0?`: ${_.join(", ")}`:""]})]}),!n&&c>0&&u.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",c]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(hl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:i,isSystem:n,headerAddon:y,bubbleClassName:i&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Qf,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:i&&l!=="failed",tone:n?"system":void 0,onOpenImage:m})})}function sm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:i}=ue();return t.jsx(hl,{senderName:s?.name??i("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Cs,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Hf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(qt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(is,{size:12}),t.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function fl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:i,centered:n}){const{t:l}=ue(),u=ha(e.id),c=fa(e.id),g=ma(e.id),[_,y]=C.useState(""),[x,a]=C.useState(!1),[h,d]=C.useState(null),[f,b]=C.useState(0),[S,k]=C.useState([]),[j,w]=C.useState(!1),[E,R]=C.useState(null),[P,M]=C.useState([]),[T,B]=C.useState(null),D=C.useRef(null),F=C.useRef(null),{files:H,addFiles:A,removeFile:O,clear:L,restoreFiles:I,buildMarkdownLinks:$,getDoneAttachments:V,isUploading:U}=an(),W=H.some(G=>G.status==="done"&&G.attachment),[q,N]=C.useState(null),{scrollRef:z,contentRef:X,isAtBottom:K,scrollToBottom:re}=ln({resize:"smooth",initial:"instant"}),Z=C.useMemo(()=>new Map((e.members??[]).map(G=>[G.id,G])),[e.members]),se=C.useMemo(()=>(e.members??[]).filter(bo),[e.members]),_e=C.useMemo(()=>new Map((e.invocations??[]).map(G=>[G.id,G])),[e.invocations]),ve=C.useMemo(()=>{const G=new Set(s.map(oe=>oe.id)),ne=P.filter(oe=>!G.has(oe.id));return[...s,...ne].sort((oe,Y)=>{const J=Date.parse(oe.createdAt??""),ie=Date.parse(Y.createdAt??"");return(Number.isNaN(J)?0:J)-(Number.isNaN(ie)?0:ie)})},[s,P]),Ie=C.useMemo(()=>new Map((e.workRequests??[]).map(G=>[G.id,G])),[e.workRequests]),ce=C.useMemo(()=>kf(ve,e.workRequests??[],e.invocations??[]),[ve,e.invocations,e.workRequests]),dt=C.useMemo(()=>(e.invocations??[]).filter(G=>Jr.has(G.status)),[e.invocations]),xe=C.useMemo(()=>S.map(G=>Z.get(G)).filter(G=>!!G).filter(bo),[Z,S]),De=C.useMemo(()=>{const G=h?.query??"";return se.filter(ne=>Uf(ne,G)).sort((ne,oe)=>{const Y=S.includes(ne.id),J=S.includes(oe.id);return Y!==J?Y?1:-1:ne.name.localeCompare(oe.name)})},[se,h?.query,S]),Ze=!r&&(x||!!h)&&De.length>0,tt=C.useCallback((G,ne)=>{if(ne==null){d(null);return}d($f(G,ne)),b(0)},[]),Ae=C.useCallback(G=>{k(ie=>Sf(ie,G.id));const ne=`@${G.name} `;if(h){const ie=`${_.slice(0,h.start)}${ne}${_.slice(h.end)}`,he=h.start+ne.length;y(ie),d(null),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(he,he)});return}const oe=_.length===0||/\s$/.test(_)?"":" ",Y=`${_}${oe}${ne}`,J=Y.length;y(Y),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(J,J)})},[_,h]),Ge=C.useCallback(G=>{k(ne=>wf(ne,G))},[]),be=C.useCallback(G=>{const ne=G.target.value;y(ne),R(null);const oe=G.target;oe.style.height="auto",oe.style.height=`${Math.max(i?40:72,Math.min(oe.scrollHeight,i?140:240))}px`,a(!1),tt(ne,oe.selectionStart)},[i,tt]),Me=C.useCallback(G=>{const ne=G.target.files;ne&&ne.length>0&&(A(Array.from(ne)),R(null)),G.target.value=""},[A]),Be=C.useCallback(G=>{const ne=[];for(const oe of G.clipboardData.items)if(oe.kind==="file"){const Y=oe.getAsFile();Y&&ne.push(Y)}ne.length>0&&(G.preventDefault(),A(ne),R(null))},[A]),Le=C.useCallback(async()=>{if(r||j||U)return;const G=$(),ne=V().map(we=>we.id),oe=Cf(S,se),Y=Jf({draft:_,attachmentMarkdown:G,attachmentIds:ne,mentions:oe});if(!Y||!_.trim()&&!W)return;const J=If(e.id,Y),ie=_,he=S,ke=H;M(we=>[...we,J]),y(""),k([]),a(!1),d(null),L(),D.current&&(D.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),w(!0),R(null);try{const we=await p(Y);M(Ee=>Ee.filter(pe=>pe.id!==J.id)),we&&typeof we=="object"&&"id"in we&&requestAnimationFrame(()=>re())}catch(we){const Ee=we instanceof Error?we.message:"Failed to send room message";M(pe=>pe.map(je=>je.id===J.id?{...je,pendingStatus:"failed",error:Ee}:je)),y(pe=>pe.length===0?ie:pe),k(pe=>pe.length===0?he:pe),I(ke),R(Ee),requestAnimationFrame(()=>re())}finally{w(!1)}},[se,H,$,L,i,_,V,W,j,U,p,r,I,re,S,e.id]),Pe=C.useCallback(G=>{const ne=G.nativeEvent.isComposing||G.nativeEvent.keyCode===229;if(Ze){if(G.key==="ArrowDown"){G.preventDefault(),b(oe=>(oe+1)%De.length);return}if(G.key==="ArrowUp"){G.preventDefault(),b(oe=>(oe-1+De.length)%De.length);return}if(G.key==="Enter"&&!ne||G.key==="Tab"){G.preventDefault();const oe=De[f]??De[0];oe&&Ae(oe);return}if(G.key==="Escape"){G.preventDefault(),d(null),a(!1);return}}G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!ne&&(G.preventDefault(),Le())},[Ae,Le,f,De,Ze]);C.useEffect(()=>{y(""),k([]),a(!1),d(null),R(null),M([]),L(),B(null),D.current&&(D.current.style.height=i?"40px":"72px")},[L,i,e.id]);const Xe=u.isError?u.error:c.isError?c.error:null,Ce=u.isPending||c.isPending,ye=C.useCallback((G,ne)=>{g.mutate({memberId:G,cancelQueued:ne},{onSuccess:()=>B(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[q&&t.jsx(Zf,{images:q.images,index:q.index,onClose:()=>N(null),onSelect:G=>N(ne=>ne&&{...ne,index:G})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:z,className:ee("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:X,className:ee(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[ce.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(us,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:l("No room messages yet")})]}):ce.map(G=>{if(G.kind==="pendingApproval"){const ie=G.request,he=Z.get(ie.targetMemberId),ke=u.isPending&&u.variables===ie.id,we=c.isPending&&c.variables===ie.id;return t.jsx(sm,{request:ie,member:he,onApprove:()=>u.mutate(ie.id),onReject:()=>c.mutate(ie.id),isActionPending:Ce,isApprovePending:ke,isRejectPending:we},G.key)}const ne=G.message,oe=Vf(ne,Z,_e),Y=ne.senderType==="user"?l("你"):ne.senderType==="system"?l("System"):oe?.name??l("Agent"),J=Xf(ne,Z);return t.jsx(tm,{message:ne,senderName:Y,senderMember:oe,memberById:Z,displayContent:J,onOpenImage:(ie,he)=>N({images:ie,index:he})},G.key)}),Xe&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(Xe,l("Failed to update work request"))}),g.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:qi(g.error,l("Failed to stop member work"))})]})}),!K&&t.jsxs("button",{type:"button",onClick:()=>re(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:l("Back to bottom")})]})]}),t.jsx("div",{className:ee("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:ee(n&&"max-w-4xl mx-auto"),children:[t.jsx(Mf,{invocations:dt,memberById:Z,workRequestById:Ie,onViewInvocationSession:m,onStopMember:ye,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:T,onToggleStopConfirm:G=>B(ne=>ne===G?null:G)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??l("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ze&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:l(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:De.map((G,ne)=>{const oe=S.includes(G.id),Y=ne===f;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(ne),onMouseDown:J=>{J.preventDefault(),Ae(G)},className:ee("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",Y?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ft,{name:G.name,avatar:G.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:G.name}),oe&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:l("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[G.providerId,G.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Gn,{size:15,className:"text-neutral-400"})]},G.id)})})]}),xe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:xe.map(G=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",G.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:G.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Ge(G.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:l("Remove mention"),"aria-label":`${l("Remove mention")} ${G.name}`,children:t.jsx(is,{size:12})})]},G.id))}),t.jsx(cn,{files:H,onRemove:O}),t.jsx("textarea",{ref:D,value:_,rows:i?1:void 0,onChange:be,onKeyDown:Pe,onPaste:Be,onClick:G=>tt(_,G.currentTarget.selectionStart),onSelect:G=>tt(_,G.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:ee("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:ee("flex items-center justify-between",i?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:Me}),t.jsx("button",{type:"button",onClick:()=>F.current?.click(),title:l("Upload file"),"aria-label":l("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(hn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{a(G=>!G),d(null),requestAnimationFrame(()=>D.current?.focus())},disabled:xe.length===0&&se.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:ee("rounded-lg transition-colors",i?"p-1.5":"p-2",x?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",xe.length===0&&se.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Gn,{size:i?15:18})}),xe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[xe.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Le()},disabled:r||j||U||!_.trim()&&!W,title:l(U?"Uploading...":j?"发送中...":"发送"),"aria-label":l(U?"Uploading...":j?"发送中...":"发送"),className:ee("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(_.trim()||W)&&!r&&!j&&!U?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||U?"opacity-70":""),children:t.jsx(dn,{size:i?15:18})})]}),E&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:E})]})]})})]})}function rm(e){return e?e.slice(0,8):""}function yo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Rn(e){return e?.workspaceKind===ls.MAIN_DIRECTORY}function hs(e){return e?Rn(e)?"Project directory":e.branchName:"—"}function ts(e){return e?.workingDir||e?.worktreePath||void 0}function An(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),l=n?"main":m.parentWorkspaceId?"child":"root",u=i?.name??(m.ownerMemberId?`Member ${rm(m.ownerMemberId)}`:void 0),c=Rn(m)?"Project directory":n?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:n?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?hs(v):void 0,isMain:n}}).sort((m,v)=>{const i=l=>l.kind==="main"?0:l.kind==="child"?1:2,n=i(m)-i(v);return n!==0?n:yo(m.workspace.createdAt)-yo(v.workspace.createdAt)})}function ml(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Et.ACTIVE)?.id??e[0]?.id}function pl(e,s){return!e||e.status!==Et.ACTIVE||Rn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function gl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Mn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},im=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],vl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],nm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],xl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],om=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function zs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Mn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function bs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Mn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function bi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Mn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function am(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function lm(e){return{name:e.name.trim(),aliases:am(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function So(e,s){return e instanceof Error?e.message:s}function wo(e){return e.membershipStatus!=="REMOVED"}function Ki(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Co(e){return Ki(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function ko(e){return vl.find(s=>s.value===e)?.label??e}function cm(e){return xl.find(s=>s.value===e)?.label??e}function Ot({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Eo({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function dm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ue(),{data:p=[]}=rd(),{data:m=[]}=sr(),v=id(r.id),i=nd(r.id),n=od(r.id),l=C.useRef(!1),[u,c]=C.useState("edit"),[g,_]=C.useState(null),[y,x]=C.useState(""),[a,h]=C.useState(zs()),[d,f]=C.useState(null),[b,S]=C.useState(null),k=r.members??[],j=C.useMemo(()=>k.filter(wo),[k]),w=C.useMemo(()=>b&&wo(b)&&!j.some(q=>q.id===b.id)?[...j,b]:j,[b,j]),E=g?j.find(q=>q.id===g)??null:null,R=b?.id===g?b:E,P=y?p.find(q=>q.id===y)??null:null,M=v.isPending||i.isPending||n.isPending,T=w.filter(Ki).length,B=C.useMemo(()=>{const q=m.map(({provider:N,availability:z})=>({value:N.id,label:N.name+(z.type==="NOT_FOUND"?o(" (不可用)"):""),disabled:z.type==="NOT_FOUND"}));return a.providerId&&!q.some(N=>N.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,m,o]);C.useEffect(()=>{if(!e){l.current=!1,S(null);return}if(l.current)return;l.current=!0;const q=w[0]??null;c(q?"edit":"add-preset"),_(q?.id??null),x(""),h(q?bs(q):zs()),f(null)},[w,e]),C.useEffect(()=>{b&&j.some(q=>q.id===b.id)&&S(null)},[b,j]),C.useEffect(()=>{u==="add-preset"&&P&&h(bi(P))},[u,P]);const D=(q,N)=>{h(z=>({...z,[q]:N}))},F=(q,N)=>{h(z=>({...z,capabilities:{...z.capabilities,[q]:N}}))},H=q=>{c("edit"),_(q.id),x(""),h(bs(q))},A=()=>{c("add-preset"),_(null);const q=P??p[0]??null;x(q?.id??""),h(q?bi(q):zs())},O=()=>{c("add-custom"),_(null),x(""),h(zs())},L=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),I=u==="add-preset"?!!y:u==="edit"?!!(R&&L):L,$=async()=>{try{if(u==="add-preset"){if(!y)return;const N=await v.mutateAsync({memberPresetId:y});ct.success(o("Member added")),S(N),c("edit"),_(N.id),x(""),h(bs(N));return}const q=lm(a);if(!q.name||!q.providerId||!q.rolePrompt){ct.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:q});ct.success(o("Member added")),S(N),c("edit"),_(N.id),h(bs(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:q});ct.success(o("Member updated")),S(z=>z?.id===N.id?N:z),_(N.id),h(bs(N))}}catch(q){ct.error(So(q,o("Failed to save member")))}},V=async()=>{if(d)try{if(await n.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const q=w.find(N=>N.id!==d.id)??null;_(q?.id??null),c(q?"edit":"add-preset"),h(q?bs(q):zs())}S(q=>q?.id===d.id?null:q),f(null),ct.success(o("Member removed"))}catch(q){ct.error(So(q,o("Failed to remove member")))}},U=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(vr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(so,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Eo,{icon:t.jsx(vr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(es,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(q=>{const N=y===q.id;return t.jsxs("button",{type:"button",onClick:()=>{x(q.id),h(bi(q))},className:ee("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ft,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(ko(q.workspacePolicy))," · ",o(cm(q.sessionPolicy))]})]}),N?t.jsx(qt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),W=()=>{const q=u==="edit";return q&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Eo,{icon:t.jsx(us,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(es,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Ba,{size:15,className:"text-neutral-500"}):t.jsx(es,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&R?t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(fn,{size:13}),o("Remove")]}):t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(vr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ft,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:ee("h-2 w-2 shrink-0 rounded-full",Co(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",o(ko(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>D("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>D("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Provider")}),t.jsx(cs,{value:a.providerId,onChange:N=>D("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>D("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Workspace policy")}),t.jsx(cs,{value:a.workspacePolicy,onChange:N=>D("workspacePolicy",N),options:vl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Trigger policy")}),t.jsx(cs,{value:a.triggerPolicy,onChange:N=>D("triggerPolicy",N),options:nm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Session policy")}),t.jsx(cs,{value:a.sessionPolicy,onChange:N=>D("sessionPolicy",N),options:xl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Queue policy")}),t.jsx(cs,{value:a.queueManagementPolicy,onChange:N=>D("queueManagementPolicy",N),options:om.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>D("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Ot,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:im.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:z=>F(N.key,z.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Ms,{isOpen:e,onClose:M?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:M,children:o("Close")}),t.jsx(Te,{type:"button",onClick:$,disabled:M||!I,children:o(M?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[w.length," ",o("active")," · ",T," ",o("working")]})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:M,title:o("Add member"),children:t.jsx(es,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:w.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:w.map(q=>{const N=u==="edit"&&g===q.id;return t.jsxs("button",{type:"button",onClick:()=>H(q),className:ee("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ft,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:ee("h-1.5 w-1.5 shrink-0 rounded-full",Co(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(cu,{size:13,className:ee("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:M,className:ee("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(vr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:M,className:ee("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(so,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?U():W()})]})}),t.jsx(Ur,{isOpen:!!d,onClose:()=>f(null),onConfirm:V,title:o("Remove member"),variant:"danger",isLoading:n.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&Ki(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(tr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const um=[],hm=[],fm=[],mm=240;function pm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const jo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function yi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function No(e,s){return e instanceof Error?e.message:s}function gm(e,s=mm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function xr(e){return e?e.instructionPreview??gm(e.instruction):""}function vm(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function xm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function _m(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function bm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function ym(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Sm(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function wm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Cm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function km(e,s){return s.find(r=>r.memberId===e.id&&Jr.has(r.status))}function _l({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ue(),v=ha(e.id),i=fa(e.id),n=ma(e.id),[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(!1),[x,a]=C.useState(!1),h=e.members??um,d=C.useMemo(()=>h.filter(D=>D.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??hm,b=e.invocations??fm,S=C.useMemo(()=>An(s,e),[e,s]),k=C.useMemo(()=>new Map(f.map(D=>[D.id,D])),[f]),j=C.useMemo(()=>[...f].filter(D=>D.status==="PENDING_APPROVAL").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),w=C.useMemo(()=>[...f].filter(D=>D.status==="QUEUED").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),E=C.useMemo(()=>[...h].map(D=>({member:D,status:pm(D.status)})).sort((D,F)=>jo[D.status]-jo[F.status]),[h]),R=v.isError?v.error:i.isError?i.error:null,P=v.isPending||i.isPending,M=S.find(D=>D.workspace.id===r),T=e.messages??[],B=E.filter(({status:D})=>D==="running"||D==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(dm,{isOpen:x,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ns,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(qr,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:T.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:B>0?`${B}/${d.length}`:d.length}),B>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),w.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(Cs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:w.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(Cs,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(D=>{const F=h.find(O=>O.id===D.targetMemberId),H=v.isPending&&v.variables===D.id,A=i.isPending&&i.variables===D.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ft,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:xr(D)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(bm(D.requesterType))}),t.jsx("span",{children:yi(D.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(D.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:11}),t.jsx("span",{className:"truncate",children:m(H?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(D.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(is,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},D.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(Ba,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:D,status:F})=>{const H=km(D,b),A=Cm(b.filter(W=>W.memberId===D.id)),O=H?k.get(H.workRequestId):void 0,L=c===D.id,I=F==="running"||F==="waiting room reply",$=I&&!!H,V=l===D.id,U=n.isPending&&n.variables?.memberId===D.id;return t.jsxs("div",{className:ee("bg-white",L&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ft,{name:D.name,avatar:D.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:ee("h-1.5 w-1.5 shrink-0 rounded-full",_m(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:D.name}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",xm(F)),children:m(vm(F))})]}),I&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:xr(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(V?null:D.id),disabled:n.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Rs,{size:12})}),H?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(H.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(Bi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(L?null:D.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":L,children:L?t.jsx(xt,{size:13}):t.jsx(Nt,{size:13})})]})]}),$&&V&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:D.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Rs,{size:10}),t.jsx("span",{children:U&&n.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:D.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Oa,{size:10}),t.jsx("span",{children:U&&n.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),L&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:D.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(W=>{const q=k.get(W.workRequestId),N=!!(W.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:ee("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ym(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:yi(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:xr(q)||W.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&p?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(Bi,{size:10}),t.jsx("span",{children:m("Log")})]})]})},W.id)})})]}),E[E.length-1]?.member.id!==D.id&&!L&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},D.id)})}),n.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:No(n.error,m("Failed to stop member work"))})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Cs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:w.length})]}),t.jsx("div",{className:"space-y-1",children:w.map(D=>{const F=h.find(H=>H.id===D.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ft,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:xr(D)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:yi(D.createdAt)})]})},D.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(D=>!D),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":_,"aria-label":m("Workspaces"),children:[t.jsx(Ns,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[M&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:hs(M.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:S.length}),_?t.jsx(xt,{size:13,className:"text-neutral-400"}):t.jsx(Nt,{size:13,className:"text-neutral-400"})]})]}),_&&t.jsx("div",{className:"space-y-1.5",children:S.map(D=>{const F=r===D.workspace.id;return t.jsx("div",{className:ee("rounded-md border bg-white px-3 py-2",F?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(D.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",wm(D.roleLabel)),children:m(D.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Sm(D.workspace.status)),children:D.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:hs(D.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[D.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",D.ownerName]}),D.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",D.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(D.workspace.id),disabled:!o||F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[F?t.jsx(qt,{size:11}):t.jsx(ja,{size:11}),t.jsx("span",{children:m(F?"Selected":"Select")})]})]})},D.workspace.id)})})]}),j.length===0&&w.length===0&&E.every(({status:D})=>D==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Si={exports:{}},Ro;function Em(){return Ro||(Ro=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,i,n){var l=this&&this.__decorate||function(f,b,S,k){var j,w=arguments.length,E=w<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,S,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(w<3?j(E):w>3?j(b,S,E):j(b,S))||E);return w>3&&E&&Object.defineProperty(b,S,E),E},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=n(9042),g=n(6114),_=n(9924),y=n(844),x=n(5596),a=n(4725),h=n(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
20
|
`)))),this.register(this._terminal.onA11yTab((S=>this._handleTab(S)))),this.register(this._terminal.onKey((S=>this._handleKey(S.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new x.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let b=0;b<f;b++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
21
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const S=this._terminal.buffer,k=S.lines.length.toString();for(let j=f;j<=b;j++){const w=S.translateBufferLineToString(S.ydisp+j,!0),E=(S.ydisp+j+1).toString(),R=this._rowElements[j];R&&(w.length===0?R.innerText=" ":R.textContent=w,R.setAttribute("aria-posinset",E),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const S=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let j,w;if(b===0?(j=S,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(j=this._rowElements.shift(),w=S,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const 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(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(v,i)=>{function o(g){return g.replace(/\r?\n/g,"\r")}function l(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function u(g,_,y,x){g=l(g=o(g),y.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),_.value=""}function c(g,_,y){const x=y.getBoundingClientRect(),a=g.clientX-x.left-10,h=g.clientY-x.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${a}px`,_.style.top=`${h}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=o,i.bracketTextForPaste=l,i.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,_,y,x){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),_,y,x)},i.paste=u,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,_,y,x,a){c(g,_,y),a&&x.rightClickSelect(g),_.value=x.selectionText,_.select()}},7239:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const l=o(1505);i.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(u,c,g){this._css.set(u,c,g)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,g){this._color.set(u,c,g)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(o,l,u,c){o.addEventListener(l,u,c);let g=!1;return{dispose:()=>{g||(g=!0,o.removeEventListener(l,u,c))}}}},6465:function(v,i,o){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=o(3656),g=o(8460),_=o(844),y=o(2585);let x=i.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,d){this._element=a,this._mouseService=h,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=a.composedPath();for(let f=0;f<d.length;f++){const b=d[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[S,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(S)&&(b=this._checkLinkProviderResult(S,a,b)):k.provideLinks(a.y,(j=>{var w,E;if(this._isMouseOut)return;const R=j?.map((P=>({link:P})));(w=this._activeProviderReplies)===null||w===void 0||w.set(S,R),b=this._checkLinkProviderResult(S,a,b),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let S=0;S<b.length;S++){const k=b[S],j=k.link.range.start.y<a?0:k.link.range.start.x,w=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=w;E++){if(d.has(E)){b.splice(S--,1);break}d.add(E)}}}}_checkLinkProviderResult(a,h,d){var f;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let S=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&b){const k=b.find((j=>this._linkAtPosition(j.link,h)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const j=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((w=>this._linkAtPosition(w.link,h)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,b;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,b,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&((S=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||S===void 0?void 0:S.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(a,h){const d=a.range,f=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(a,h){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=f}_positionFromMouseEvent(a,h,d){const f=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,f,b){return{x1:a,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:b}}};i.Linkifier2=x=l([u(0,y.IBufferService)],x)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,o){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=o(511),g=o(2585);let _=i.OscLinkProvider=class{constructor(x,a,h){this._bufferService=x,this._optionsService=a,this._oscLinkService=h}provideLinks(x,a){var h;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,S=new c.CellData,k=d.getTrimmedLength();let j=-1,w=-1,E=!1;for(let R=0;R<k;R++)if(w!==-1||d.hasContent(R)){if(d.loadCell(R,S),S.hasExtendedAttrs()&&S.extended.urlId){if(w===-1){w=R,j=S.extended.urlId;continue}E=S.extended.urlId!==j}else w!==-1&&(E=!0);if(E||w!==-1&&R===k-1){const P=(h=this._oscLinkService.getLinkData(j))===null||h===void 0?void 0:h.uri;if(P){const M={start:{x:w+1,y:x},end:{x:R+(E||R!==k-1?0:1),y:x}};let T=!1;if(!b?.allowNonHttpProtocols)try{const B=new URL(P);["http:","https:"].includes(B.protocol)||(T=!0)}catch{T=!0}T||f.push({text:P,range:M,activate:(B,D)=>b?b.activate(B,D,M):y(0,D),hover:(B,D)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,B,D,M)},leave:(B,D)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.call(b,B,D,M)}})}E=!1,S.hasExtendedAttrs()&&S.extended.urlId?(w=R,j=S.extended.urlId):(w=-1,j=-1)}}a(f)}};function y(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
21
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const S=this._terminal.buffer,k=S.lines.length.toString();for(let j=f;j<=b;j++){const w=S.translateBufferLineToString(S.ydisp+j,!0),E=(S.ydisp+j+1).toString(),R=this._rowElements[j];R&&(w.length===0?R.innerText=" ":R.textContent=w,R.setAttribute("aria-posinset",E),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const S=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let j,w;if(b===0?(j=S,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(j=this._rowElements.shift(),w=S,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const 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(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(v,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function l(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function u(g,_,y,x){g=l(g=n(g),y.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),_.value=""}function c(g,_,y){const x=y.getBoundingClientRect(),a=g.clientX-x.left-10,h=g.clientY-x.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${a}px`,_.style.top=`${h}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=l,i.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,_,y,x){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),_,y,x)},i.paste=u,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,_,y,x,a){c(g,_,y),a&&x.rightClickSelect(g),_.value=x.selectionText,_.select()}},7239:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const l=n(1505);i.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(u,c,g){this._css.set(u,c,g)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,g){this._color.set(u,c,g)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,l,u,c){n.addEventListener(l,u,c);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(l,u,c))}}}},6465:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=n(3656),g=n(8460),_=n(844),y=n(2585);let x=i.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,d){this._element=a,this._mouseService=h,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=a.composedPath();for(let f=0;f<d.length;f++){const b=d[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[S,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(S)&&(b=this._checkLinkProviderResult(S,a,b)):k.provideLinks(a.y,(j=>{var w,E;if(this._isMouseOut)return;const R=j?.map((P=>({link:P})));(w=this._activeProviderReplies)===null||w===void 0||w.set(S,R),b=this._checkLinkProviderResult(S,a,b),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let S=0;S<b.length;S++){const k=b[S],j=k.link.range.start.y<a?0:k.link.range.start.x,w=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=w;E++){if(d.has(E)){b.splice(S--,1);break}d.add(E)}}}}_checkLinkProviderResult(a,h,d){var f;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let S=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&b){const k=b.find((j=>this._linkAtPosition(j.link,h)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const j=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((w=>this._linkAtPosition(w.link,h)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,b;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,b,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&((S=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||S===void 0?void 0:S.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(a,h){const d=a.range,f=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(a,h){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=f}_positionFromMouseEvent(a,h,d){const f=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,f,b){return{x1:a,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:b}}};i.Linkifier2=x=l([u(0,y.IBufferService)],x)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,n){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let _=i.OscLinkProvider=class{constructor(x,a,h){this._bufferService=x,this._optionsService=a,this._oscLinkService=h}provideLinks(x,a){var h;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,S=new c.CellData,k=d.getTrimmedLength();let j=-1,w=-1,E=!1;for(let R=0;R<k;R++)if(w!==-1||d.hasContent(R)){if(d.loadCell(R,S),S.hasExtendedAttrs()&&S.extended.urlId){if(w===-1){w=R,j=S.extended.urlId;continue}E=S.extended.urlId!==j}else w!==-1&&(E=!0);if(E||w!==-1&&R===k-1){const P=(h=this._oscLinkService.getLinkData(j))===null||h===void 0?void 0:h.uri;if(P){const M={start:{x:w+1,y:x},end:{x:R+(E||R!==k-1?0:1),y:x}};let T=!1;if(!b?.allowNonHttpProtocols)try{const B=new URL(P);["http:","https:"].includes(B.protocol)||(T=!0)}catch{T=!0}T||f.push({text:P,range:M,activate:(B,D)=>b?b.activate(B,D,M):y(0,D),hover:(B,D)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,B,D,M)},leave:(B,D)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.call(b,B,D,M)}})}E=!1,S.hasExtendedAttrs()&&S.extended.urlId?(w=R,j=S.extended.urlId):(w=-1,j=-1)}}a(f)}};function y(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
22
|
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=_=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],_)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(o,l){this._parentWindow=o,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,l,u){this._rowCount=u,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,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 o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const l=o(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=u},3236:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const l=o(3614),u=o(3656),c=o(6465),g=o(9042),_=o(3730),y=o(1680),x=o(3107),a=o(5744),h=o(2950),d=o(1296),f=o(428),b=o(4269),S=o(5114),k=o(8934),j=o(3230),w=o(9312),E=o(4725),R=o(6731),P=o(8055),M=o(8969),T=o(8460),B=o(844),D=o(6114),F=o(8437),$=o(2584),A=o(7399),O=o(5941),L=o(9074),I=o(2585),U=o(5435),Y=o(4567),q=typeof window<"u"?window.document:null;class W extends M.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(N={}){super(N),this.browser=D,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new T.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new T.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new T.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new T.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new T.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new T.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new T.EventEmitter),this._onBlur=this.register(new T.EventEmitter),this._onA11yCharEmitter=this.register(new T.EventEmitter),this._onA11yTabEmitter=this.register(new T.EventEmitter),this._onWillOpen=this.register(new T.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(L.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((z,V)=>this.refresh(z,V)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((z=>this._reportWindowsOptions(z)))),this.register(this._inputHandler.onColor((z=>this._handleColorEvent(z)))),this.register((0,T.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,T.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((z=>this._afterResize(z.cols,z.rows)))),this.register((0,B.toDisposable)((()=>{var z,V;this._customKeyEventHandler=void 0,(V=(z=this.element)===null||z===void 0?void 0:z.parentNode)===null||V===void 0||V.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const z of N){let V,X="";switch(z.index){case 256:V="foreground",X="10";break;case 257:V="background",X="11";break;case 258:V="cursor",X="12";break;default:V="ansi",X="4;"+z.index}switch(z.type){case 0:const re=P.color.toColorRGB(V==="ansi"?this._themeService.colors.ansi[z.index]:this._themeService.colors[V]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${X};${(0,O.toRgbString)(re)}${$.C1_ESCAPED.ST}`);break;case 1:if(V==="ansi")this._themeService.modifyColors((J=>J.ansi[z.index]=P.rgba.toColor(...z.color)));else{const J=V;this._themeService.modifyColors((se=>se[J]=P.rgba.toColor(...z.color)))}break;case 2:this._themeService.restoreColor(z.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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 N=this.buffer.ybase+this.buffer.y,z=this.buffer.lines.get(N);if(!z)return;const V=Math.min(this.buffer.x,this.cols-1),X=this._renderService.dimensions.css.cell.height,re=z.getWidth(V),J=this._renderService.dimensions.css.cell.width*re,se=this.buffer.y*this._renderService.dimensions.css.cell.height,ve=V*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ve+"px",this.textarea.style.top=se+"px",this.textarea.style.width=J+"px",this.textarea.style.height=X+"px",this.textarea.style.lineHeight=X+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(z=>{this.hasSelection()&&(0,l.copyHandler)(z,this._selectionService)})));const N=z=>(0,l.handlePasteEvent)(z,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,u.addDisposableDomListener)(this.element,"paste",N)),D.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(z=>{z.button===2&&(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(z=>{(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),D.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(z=>{z.button===1&&(0,l.moveTextAreaUnderMouseCursor)(z,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var z;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const V=q.createDocumentFragment();this._viewportElement=q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),V.appendChild(this._viewportElement),this._viewportScrollArea=q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),V.appendChild(this.screenElement),this.textarea=q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),D.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,(z=this._document.defaultView)!==null&&z!==void 0?z:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(X=>this._handleTextAreaFocus(X)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((X=>this._onRender.fire(X)))),this.onResize((X=>this._renderService.resize(X.cols,X.rows))),this._compositionView=q.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(V);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((X=>this._renderService.handleSelectionChanged(X.start,X.end,X.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((X=>{this.textarea.value=X,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((X=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(X=>this._selectionService.handleMouseDown(X)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(X=>this._handleScreenReaderModeOptionChange(X)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(X=>{!this._overviewRulerRenderer&&X&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,z=this.element;function V(J){const se=N._mouseService.getMouseReportCoords(J,N.screenElement);if(!se)return!1;let ve,pe;switch(J.overrideType||J.type){case"mousemove":pe=32,J.buttons===void 0?(ve=3,J.button!==void 0&&(ve=J.button<3?J.button:3)):ve=1&J.buttons?0:4&J.buttons?1:2&J.buttons?2:3;break;case"mouseup":pe=0,ve=J.button<3?J.button:3;break;case"mousedown":pe=1,ve=J.button<3?J.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(J)===0)return!1;pe=J.deltaY<0?0:1,ve=4;break;default:return!1}return!(pe===void 0||ve===void 0||ve>4)&&N.coreMouseService.triggerMouseEvent({col:se.col,row:se.row,x:se.x,y:se.y,button:ve,action:pe,ctrl:J.ctrlKey,alt:J.altKey,shift:J.shiftKey})}const X={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:J=>(V(J),J.buttons||(this._document.removeEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.removeEventListener("mousemove",X.mousedrag)),this.cancel(J)),wheel:J=>(V(J),this.cancel(J,!0)),mousedrag:J=>{J.buttons&&V(J)},mousemove:J=>{J.buttons||V(J)}};this.register(this.coreMouseService.onProtocolChange((J=>{J?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(J)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&J?X.mousemove||(z.addEventListener("mousemove",re.mousemove),X.mousemove=re.mousemove):(z.removeEventListener("mousemove",X.mousemove),X.mousemove=null),16&J?X.wheel||(z.addEventListener("wheel",re.wheel,{passive:!1}),X.wheel=re.wheel):(z.removeEventListener("wheel",X.wheel),X.wheel=null),2&J?X.mouseup||(z.addEventListener("mouseup",re.mouseup),X.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",X.mouseup),z.removeEventListener("mouseup",X.mouseup),X.mouseup=null),4&J?X.mousedrag||(X.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",X.mousedrag),X.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(z,"mousedown",(J=>{if(J.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(J))return V(J),X.mouseup&&this._document.addEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.addEventListener("mousemove",X.mousedrag),this.cancel(J)}))),this.register((0,u.addDisposableDomListener)(z,"wheel",(J=>{if(!X.wheel){if(!this.buffer.hasScrollback){const se=this.viewport.getLinesScrolled(J);if(se===0)return;const ve=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(J.deltaY<0?"A":"B");let pe="";for(let Le=0;Le<Math.abs(se);Le++)pe+=ve;return this.coreService.triggerDataEvent(pe,!0),this.cancel(J,!0)}return this.viewport.handleWheel(J)?this.cancel(J):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(z,"touchstart",(J=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(J),this.cancel(J)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(z,"touchmove",(J=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(J)?void 0:this.cancel(J)}),{passive:!1}))}refresh(N,z){var V;(V=this._renderService)===null||V===void 0||V.refreshRows(N,z)}updateCursorStyle(N){var z;!((z=this._selectionService)===null||z===void 0)&&z.shouldColumnSelect(N)?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(N,z,V=0){var X;V===1?(super.scrollLines(N,z,V),this.refresh(0,this.rows-1)):(X=this.viewport)===null||X===void 0||X.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const z=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),z}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,z,V){this._selectionService.setSelection(N,z,V)}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 N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,z){var V;(V=this._selectionService)===null||V===void 0||V.selectLines(N,z)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const z=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!z&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;z||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const V=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),V.type===3||V.type===2){const X=this.rows-1;return this.scrollLines(V.type===2?-X:X),this.cancel(N,!0)}return V.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(V.cancel&&this.cancel(N,!0),!V.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(V.key!==$.C0.ETX&&V.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:V.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(V.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,z){const V=N.isMac&&!this.options.macOptionIsMeta&&z.altKey&&!z.ctrlKey&&!z.metaKey||N.isWindows&&z.altKey&&z.ctrlKey&&!z.metaKey||N.isWindows&&z.getModifierState("AltGraph");return z.type==="keypress"?V:V&&(!z.keyCode||z.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(z){return z.keyCode===16||z.keyCode===17||z.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let z;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)z=N.charCode;else if(N.which===null||N.which===void 0)z=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;z=N.which}return!(!z||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(z=String.fromCharCode(z),this._onKey.fire({key:z,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(z,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const z=N.data;return this.coreService.triggerDataEvent(z,!0),this.cancel(N),!0}return!1}resize(N,z){N!==this.cols||z!==this.rows?super.resize(N,z):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,z){var V,X;(V=this._charSizeService)===null||V===void 0||V.measure(),(X=this.viewport)===null||X===void 0||X.syncScrollArea(!0)}clear(){var N;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 z=1;z<this.rows;z++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,z;this.options.rows=this.rows,this.options.cols=this.cols;const V=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(z=this.viewport)===null||z===void 0||z.reset(),this._customKeyEventHandler=V,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent($.C0.ESC+"[I"):this.coreService.triggerDataEvent($.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const z=this._renderService.dimensions.css.canvas.width.toFixed(0),V=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${V};${z}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const X=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[6;${re};${X}t`)}}cancel(N,z){if(this.options.cancelEvents||z)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=W},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(o,l=1e3){this._renderCallback=o,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,l,u){this._rowCount=u,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l)}}},1680:function(v,i,o){var l=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(k<3?S(j):k>3?S(d,f,j):S(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=o(3656),g=o(4725),_=o(8460),y=o(844),x=o(2585);let a=i.Viewport=class extends y.Disposable{constructor(h,d,f,b,S,k,j,w){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=b,this._charSizeService=S,this._renderService=k,this._coreBrowserService=j,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.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(w.colors),this.register(w.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let b,S="";const k=[],j=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let E=h;E<j;E++){const R=w.get(E);if(!R)continue;const P=(f=w.get(E+1))===null||f===void 0?void 0:f.isWrapped;if(S+=R.translateToString(!P),!P||E===w.length-1){const M=document.createElement("div");M.textContent=S,k.push(M),S.length>0&&(b=M),S=""}}return{bufferElements:k,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};i.Viewport=a=l([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,i,o){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=o(3656),g=o(4725),_=o(844),y=o(2585);let x=i.BufferDecorationRenderer=class extends _.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((b=>this._removeDecoration(b)))),this.register((0,_.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(d=a.options.x)!==null&&d!==void 0?d:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};i.BufferDecorationRenderer=x=l([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],x)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(o){if(o.options.overviewRulerOptions){for(const l of this._zones)if(l.color===o.options.overviewRulerOptions.color&&l.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,o.marker.line))return;if(this._lineAdjacentToZone(l,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(l,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,l){return l>=o.startBufferLine&&l<=o.endBufferLine}_lineAdjacentToZone(o,l,u){return l>=o.startBufferLine-this._linePadding[u||"full"]&&l<=o.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(o,l){o.startBufferLine=Math.min(o.startBufferLine,l),o.endBufferLine=Math.max(o.endBufferLine,l)}}},5744:function(v,i,o){var l=this&&this.__decorate||function(b,S,k,j){var w,E=arguments.length,R=E<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,S,k,j);else for(var P=b.length-1;P>=0;P--)(w=b[P])&&(R=(E<3?w(R):E>3?w(S,k,R):w(S,k))||R);return E>3&&R&&Object.defineProperty(S,k,R),R},u=this&&this.__param||function(b,S){return function(k,j){S(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=o(5871),g=o(3656),_=o(4725),y=o(844),x=o(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,S,k,j,w,E,R){var P;super(),this._viewportElement=b,this._screenElement=S,this._bufferService=k,this._decorationService=j,this._renderService=w,this._optionsService=E,this._coreBrowseService=R,this._colorZoneStore=new c.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(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var T;(T=this._canvas)===null||T===void 0||T.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=S,h.right=b,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=S,a.center=S,a.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const S of b)S.position!=="full"&&this._renderColorZone(S);for(const S of b)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(d[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,S){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=l([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,_.IRenderService),u(5,x.IOptionsService),u(6,_.ICoreBrowserService)],f)},2950:function(v,i,o){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=o(4725),g=o(2585),_=o(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,h,d,f,b){this._textarea=x,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=b,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(x,"");this._dataAlreadySent=h,a.length>x.length?this._coreService.triggerDataEvent(h,!0):a.length<x.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],y)},9806:(v,i)=>{function o(l,u,c){const g=c.getBoundingClientRect(),_=l.getComputedStyle(c),y=parseInt(_.getPropertyValue("padding-left")),x=parseInt(_.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-x]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=o,i.getCoords=function(l,u,c,g,_,y,x,a,h){if(!y)return;const d=o(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),_),d):void 0}},9504:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const l=o(2584);function u(a,h,d,f){const b=a-c(a,d),S=h-c(h,d),k=Math.abs(b-S)-(function(j,w,E){let R=0;const P=j-c(j,E),M=w-c(w,E);for(let T=0;T<Math.abs(P-M);T++){const B=g(j,w)==="A"?-1:1,D=E.buffer.lines.get(P+B*T);D?.isWrapped&&R++}return R})(a,h,d);return x(k,y(g(a,h),f))}function c(a,h){let d=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function _(a,h,d,f,b,S){let k=a,j=h,w="";for(;k!==d||j!==f;)k+=b?1:-1,b&&k>S.cols-1?(w+=S.buffer.translateBufferLineToString(j,!1,a,k),k=0,a=0,j++):!b&&k<0&&(w+=S.buffer.translateBufferLineToString(j,!1,0,a+1),k=S.cols-1,a=k,j--);return w+S.buffer.translateBufferLineToString(j,!1,a,k)}function y(a,h){const d=h?"O":"[";return l.C0.ESC+d+a}function x(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}i.moveToCellSequence=function(a,h,d,f){const b=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,E,R,P,M,T){return u(E,P,M,T).length===0?"":x(_(w,E,w,E-c(E,M),!1,M).length,y("D",T))})(b,S,0,h,d,f)+u(S,h,d,f)+(function(w,E,R,P,M,T){let B;B=u(E,P,M,T).length>0?P-c(P,M):E;const D=P,F=(function($,A,O,L,I,U){let Y;return Y=u(O,L,I,U).length>0?L-c(L,I):A,$<O&&Y<=L||$>=O&&Y<L?"C":"D"})(w,E,R,P,M,T);return x(_(w,B,R,D,F==="C",M).length,y(F,T))})(b,S,a,h,d,f);let k;if(S===h)return k=b>a?"D":"C",x(Math.abs(b-a),y(k,f));k=S>h?"D":"C";const j=Math.abs(S-h);return x((function(w,E){return E.cols-w})(S>h?a:b,d)+(j-1)*d.cols+1+((S>h?b:a)-1),y(k,f))}},1296:function(v,i,o){var l=this&&this.__decorate||function(M,T,B,D){var F,$=arguments.length,A=$<3?T:D===null?D=Object.getOwnPropertyDescriptor(T,B):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,T,B,D);else for(var O=M.length-1;O>=0;O--)(F=M[O])&&(A=($<3?F(A):$>3?F(T,B,A):F(T,B))||A);return $>3&&A&&Object.defineProperty(T,B,A),A},u=this&&this.__param||function(M,T){return function(B,D){T(B,D,M)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=o(3787),g=o(2550),_=o(2223),y=o(6171),x=o(4725),a=o(8055),h=o(8460),d=o(844),f=o(2585),b="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",j="xterm-bg-",w="xterm-focus",E="xterm-selection";let R=1,P=i.DomRenderer=class extends d.Disposable{constructor(M,T,B,D,F,$,A,O,L,I){super(),this._element=M,this._screenElement=T,this._viewportElement=B,this._linkifier2=D,this._charSizeService=$,this._optionsService=A,this._bufferService=O,this._coreBrowserService=L,this._themeService=I,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(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=F.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(b+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),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/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const T=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=T,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(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let T=`${this._terminalSelector} .${S} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;T+=`${this._terminalSelector} .${S} .xterm-dim { color: ${a.color.multiplyOpacity(M.foreground,.5).css};}`,T+=`${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;}`,T+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",T+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,T+=`${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,T+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[B,D]of M.ansi.entries())T+=`${this._terminalSelector} .${k}${B} { color: ${D.css}; }${this._terminalSelector} .${k}${B}.xterm-dim { color: ${a.color.multiplyOpacity(D,.5).css}; }${this._terminalSelector} .${j}${B} { background-color: ${D.css}; }`;T+=`${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(M.background).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${j}${_.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=T}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,T){for(let B=this._rowElements.length;B<=T;B++){const D=document.createElement("div");this._rowContainer.appendChild(D),this._rowElements.push(D)}for(;this._rowElements.length>T;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,T){this._refreshRowElements(M,T),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,T,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,T,B),this.renderRows(0,this._bufferService.rows-1),!M||!T)return;const D=M[1]-this._bufferService.buffer.ydisp,F=T[1]-this._bufferService.buffer.ydisp,$=Math.max(D,0),A=Math.min(F,this._bufferService.rows-1);if($>=this._bufferService.rows||A<0)return;const O=document.createDocumentFragment();if(B){const L=M[0]>T[0];O.appendChild(this._createSelectionElement($,L?T[0]:M[0],L?M[0]:T[0],A-$+1))}else{const L=D===$?M[0]:0,I=$===F?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement($,L,I));const U=A-$-1;if(O.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,U)),$!==A){const Y=F===A?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(A,0,Y))}}this._selectionContainer.appendChild(O)}_createSelectionElement(M,T,B,D=1){const F=document.createElement("div");return F.style.height=D*this.dimensions.css.cell.height+"px",F.style.top=M*this.dimensions.css.cell.height+"px",F.style.left=T*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(B-T)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const M of this._rowElements)M.replaceChildren()}renderRows(M,T){const B=this._bufferService.buffer,D=B.ybase+B.y,F=Math.min(B.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let L=M;L<=T;L++){const I=L+B.ydisp,U=this._rowElements[L],Y=B.lines.get(I);if(!U||!Y)break;U.replaceChildren(...this._rowFactory.createRow(Y,I,I===D,A,O,F,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,T,B,D,F,$){B<0&&(M=0),D<0&&(T=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),D=Math.max(Math.min(D,A),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,L=O.ybase+O.y,I=Math.min(O.x,F-1),U=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,q=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=B;W<=D;++W){const K=W+O.ydisp,N=this._rowElements[W],z=O.lines.get(K);if(!N||!z)break;N.replaceChildren(...this._rowFactory.createRow(z,K,K===L,Y,q,I,U,this.dimensions.css.cell.width,this._widthCache,$?W===B?M:0:-1,$?(W===D?T:F)-1:-1))}}};i.DomRenderer=P=l([u(4,f.IInstantiationService),u(5,x.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],P)},3787:function(v,i,o){var l=this&&this.__decorate||function(k,j,w,E){var R,P=arguments.length,M=P<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,w):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,j,w,E);else for(var T=k.length-1;T>=0;T--)(R=k[T])&&(M=(P<3?R(M):P>3?R(j,w,M):R(j,w))||M);return P>3&&M&&Object.defineProperty(j,w,M),M},u=this&&this.__param||function(k,j){return function(w,E){j(w,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=o(2223),g=o(643),_=o(511),y=o(2585),x=o(8055),a=o(4725),h=o(4269),d=o(6171),f=o(3734);let b=i.DomRendererRowFactory=class{constructor(k,j,w,E,R,P,M){this._document=k,this._characterJoinerService=j,this._optionsService=w,this._coreBrowserService=E,this._coreService=R,this._decorationService=P,this._themeService=M,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,w){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=w}createRow(k,j,w,E,R,P,M,T,B,D,F){const $=[],A=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let L,I=k.getNoBgTrimmedLength();w&&I<P+1&&(I=P+1);let U=0,Y="",q=0,W=0,K=0,N=!1,z=0,V=!1,X=0;const re=[],J=D!==-1&&F!==-1;for(let se=0;se<I;se++){k.loadCell(se,this._workCell);let ve=this._workCell.getWidth();if(ve===0)continue;let pe=!1,Le=se,oe=this._workCell;if(A.length>0&&se===A[0][0]){pe=!0;const ye=A.shift();oe=new h.JoinedCellData(this._workCell,k.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),Le=ye[1]-1,ve=oe.getWidth()}const dt=this._isCellInSelection(se,j),ge=w&&se===P,Ee=J&&se>=D&&se<=F;let Ze=!1;this._decorationService.forEachDecorationAtCell(se,j,void 0,(ye=>{Ze=!0}));let tt=oe.getChars()||g.WHITESPACE_CELL_CHAR;if(tt===" "&&(oe.isUnderline()||oe.isOverline())&&(tt=" "),X=ve*T-B.get(tt,oe.isBold(),oe.isItalic()),L){if(U&&(dt&&V||!dt&&!V&&oe.bg===q)&&(dt&&V&&O.selectionForeground||oe.fg===W)&&oe.extended.ext===K&&Ee===N&&X===z&&!ge&&!pe&&!Ze){Y+=tt,U++;continue}U&&(L.textContent=Y),L=this._document.createElement("span"),U=0,Y=""}else L=this._document.createElement("span");if(q=oe.bg,W=oe.fg,K=oe.extended.ext,N=Ee,z=X,V=dt,pe&&P>=se&&P<=Le&&(P=se),!this._coreService.isCursorHidden&&ge){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&re.push("xterm-cursor-blink"),re.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline")}}if(oe.isBold()&&re.push("xterm-bold"),oe.isItalic()&&re.push("xterm-italic"),oe.isDim()&&re.push("xterm-dim"),Y=oe.isInvisible()?g.WHITESPACE_CELL_CHAR:oe.getChars()||g.WHITESPACE_CELL_CHAR,oe.isUnderline()&&(re.push(`xterm-underline-${oe.extended.underlineStyle}`),Y===" "&&(Y=" "),!oe.isUnderlineColorDefault()))if(oe.isUnderlineColorRGB())L.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(oe.getUnderlineColor()).join(",")})`;else{let ye=oe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&oe.isBold()&&ye<8&&(ye+=8),L.style.textDecorationColor=O.ansi[ye].css}oe.isOverline()&&(re.push("xterm-overline"),Y===" "&&(Y=" ")),oe.isStrikethrough()&&re.push("xterm-strikethrough"),Ee&&(L.style.textDecoration="underline");let Se=oe.getFgColor(),it=oe.getFgColorMode(),xe=oe.getBgColor(),je=oe.getBgColorMode();const Ie=!!oe.isInverse();if(Ie){const ye=Se;Se=xe,xe=ye;const H=it;it=je,je=H}let Pe,Ne,Me,be=!1;switch(this._decorationService.forEachDecorationAtCell(se,j,void 0,(ye=>{ye.options.layer!=="top"&&be||(ye.backgroundColorRGB&&(je=50331648,xe=ye.backgroundColorRGB.rgba>>8&16777215,Pe=ye.backgroundColorRGB),ye.foregroundColorRGB&&(it=50331648,Se=ye.foregroundColorRGB.rgba>>8&16777215,Ne=ye.foregroundColorRGB),be=ye.options.layer==="top")})),!be&&dt&&(Pe=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,xe=Pe.rgba>>8&16777215,je=50331648,be=!0,O.selectionForeground&&(it=50331648,Se=O.selectionForeground.rgba>>8&16777215,Ne=O.selectionForeground)),be&&re.push("xterm-decoration-top"),je){case 16777216:case 33554432:Me=O.ansi[xe],re.push(`xterm-bg-${xe}`);break;case 50331648:Me=x.rgba.toColor(xe>>16,xe>>8&255,255&xe),this._addStyle(L,`background-color:#${S((xe>>>0).toString(16),"0",6)}`);break;default:Ie?(Me=O.foreground,re.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Me=O.background}switch(Pe||oe.isDim()&&(Pe=x.color.multiplyOpacity(Me,.5)),it){case 16777216:case 33554432:oe.isBold()&&Se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Se+=8),this._applyMinimumContrast(L,Me,O.ansi[Se],oe,Pe,void 0)||re.push(`xterm-fg-${Se}`);break;case 50331648:const ye=x.rgba.toColor(Se>>16&255,Se>>8&255,255&Se);this._applyMinimumContrast(L,Me,ye,oe,Pe,Ne)||this._addStyle(L,`color:#${S(Se.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(L,Me,O.foreground,oe,Pe,void 0)||Ie&&re.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}re.length&&(L.className=re.join(" "),re.length=0),ge||pe||Ze?L.textContent=Y:U++,X!==this.defaultSpacing&&(L.style.letterSpacing=`${X}px`),$.push(L),se=Le}return L&&U&&(L.textContent=Y),$}_applyMinimumContrast(k,j,w,E,R,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const M=this._getContrastCache(E);let T;if(R||P||(T=M.getColor(j.rgba,w.rgba)),T===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);T=x.color.ensureContrastRatio(R||j,P||w,B),M.setColor((R||j).rgba,(P||w).rgba,T??null)}return!!T&&(this._addStyle(k,`color:${T.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const w=this._selectionStart,E=this._selectionEnd;return!(!w||!E)&&(this._columnSelectMode?w[0]<=E[0]?k>=w[0]&&j>=w[1]&&k<E[0]&&j<=E[1]:k<w[0]&&j>=w[1]&&k>=E[0]&&j<=E[1]:j>w[1]&&j<E[1]||w[1]===E[1]&&j===w[1]&&k>=w[0]&&k<E[0]||w[1]<E[1]&&j===E[1]&&k<E[0]||w[1]<E[1]&&j===w[1]&&k>=w[0])}};function S(k,j,w){for(;k.length<w;)k=j+k;return k}i.DomRendererRowFactory=b=l([u(1,a.ICharacterJoinerService),u(2,y.IOptionsService),u(3,a.ICoreBrowserService),u(4,y.ICoreService),u(5,y.IDecorationService),u(6,a.IThemeService)],b)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.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=o.createElement("span"),u=o.createElement("span");u.style.fontWeight="bold";const c=o.createElement("span");c.style.fontStyle="italic";const g=o.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),o.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(o,l,u,c){o===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=o,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(o,l,u){let c=0;if(!l&&!u&&o.length===1&&(c=o.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(o,0);let g=o;l&&(g+="B"),u&&(g+="I");let _=this._holey.get(g);if(_===void 0){let y=0;l&&(y|=1),u&&(y|=2),_=this._measure(o,y),this._holey.set(g,_)}return _}_measure(o,l){const u=this._measureElements[l];return u.textContent=o.repeat(32),u.offsetWidth/32}}},2223:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const l=o(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function o(l){return 57508<=l&&l<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},i.isPowerlineGlyph=o,i.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},i.excludeFromContrastRatioDemands=function(l){return o(l)||(function(u){return 9472<=u&&u<=9631})(l)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(o){this._bufferService=o,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 o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,l=this.selectionEnd;return!(!o||!l)&&(o[1]>l[1]||o[1]===l[1]&&o[0]>l[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,o){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=o(2585),g=o(8460),_=o(844);let y=i.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new x(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=l([u(2,c.IOptionsService)],y);class x{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,i,o){var l=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(k<3?S(j):k>3?S(d,f,j):S(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=o(3734),g=o(643),_=o(511),y=o(2585);class x extends c.AttributeData{constructor(d,f,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=x;let a=i.CharacterJoinerService=class _l{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const b=[],S=f.translateToString(!0);let k=0,j=0,w=0,E=f.getFg(0),R=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==R){if(P-k>1){const M=this._getJoinedRanges(S,w,j,f,k);for(let T=0;T<M.length;T++)b.push(M[T])}k=P,w=j,E=this._workCell.fg,R=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(S,w,j,f,k);for(let M=0;M<P.length;M++)b.push(P[M])}return b}_getJoinedRanges(d,f,b,S,k){const j=d.substring(f,b);let w=[];try{w=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const R=this._characterJoiners[E].handler(j);for(let P=0;P<R.length;P++)_l._mergeRanges(w,R[P])}catch(R){console.error(R)}return this._stringRangesToCellRanges(w,S,k),w}_stringRangesToCellRanges(d,f,b){let S=0,k=!1,j=0,w=d[S];if(w){for(let E=b;E<this._bufferService.cols;E++){const R=f.getWidth(E),P=f.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&w[0]<=j&&(w[0]=E,k=!0),w[1]<=j){if(w[1]=E,w=d[++S],!w)break;w[0]<=j?(w[0]=E,k=!0):k=!1}j+=P}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let b=!1;for(let S=0;S<d.length;S++){const k=d[S];if(b){if(f[1]<=k[0])return d[S-1][1]=f[1],d;if(f[1]<=k[1])return d[S-1][1]=Math.max(f[1],k[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(f[1]<=k[0])return d.splice(S,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),b=!0)}}return b?d[d.length-1][1]=f[1]:d.push(f),d}};i.CharacterJoinerService=a=l([u(0,y.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(o,l){this._textarea=o,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(v,i,o){var l=this&&this.__decorate||function(y,x,a,h){var d,f=arguments.length,b=f<3?x:h===null?h=Object.getOwnPropertyDescriptor(x,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,x,a,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(b=(f<3?d(b):f>3?d(x,a,b):d(x,a))||b);return f>3&&b&&Object.defineProperty(x,a,b),b},u=this&&this.__param||function(y,x){return function(a,h){x(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=o(4725),g=o(9806);let _=i.MouseService=class{constructor(y,x){this._renderService=y,this._charSizeService=x}getCoords(y,x,a,h,d){return(0,g.getCoords)(window,y,x,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,x){const a=(0,g.getCoordsRelativeToElement)(window,y,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};i.MouseService=_=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],_)},3230:function(v,i,o){var l=this&&this.__decorate||function(b,S,k,j){var w,E=arguments.length,R=E<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,S,k,j);else for(var P=b.length-1;P>=0;P--)(w=b[P])&&(R=(E<3?w(R):E>3?w(S,k,R):w(S,k))||R);return E>3&&R&&Object.defineProperty(S,k,R),R},u=this&&this.__param||function(b,S){return function(k,j){S(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=o(3656),g=o(6193),_=o(5596),y=o(4725),x=o(8460),a=o(844),h=o(7226),d=o(2585);let f=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,S,k,j,w,E,R,P){if(super(),this._rowCount=b,this._charSizeService=j,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((M,T)=>this._renderRows(M,T))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const M=new R.window.IntersectionObserver((T=>this._handleIntersectionChange(T[T.length-1])),{threshold:0});M.observe(S),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,S,this._rowCount))}_renderRows(b,S){this._renderer.value&&(b=Math.min(b,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(b,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:S}),this._onRender.fire({start:b,end:S}),this._isNextRenderRedrawOnly=!0)}resize(b,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,S;this._renderer.value&&((S=(b=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,S))):this._renderer.value.handleResize(b,S),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,S,k){var j;this._selectionState.start=b,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(b,S,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};i.RenderService=f=l([u(2,d.IOptionsService),u(3,y.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,y.ICoreBrowserService),u(7,y.IThemeService)],f)},9312:function(v,i,o){var l=this&&this.__decorate||function(w,E,R,P){var M,T=arguments.length,B=T<3?E:P===null?P=Object.getOwnPropertyDescriptor(E,R):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(w,E,R,P);else for(var D=w.length-1;D>=0;D--)(M=w[D])&&(B=(T<3?M(B):T>3?M(E,R,B):M(E,R))||B);return T>3&&B&&Object.defineProperty(E,R,B),B},u=this&&this.__param||function(w,E){return function(R,P){E(R,P,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=o(9806),g=o(9504),_=o(456),y=o(4725),x=o(8460),a=o(844),h=o(6114),d=o(4841),f=o(511),b=o(2585),S=" ",k=new RegExp(S,"g");let j=i.SelectionService=class extends a.Disposable{constructor(w,E,R,P,M,T,B,D,F){super(),this._element=w,this._screenElement=E,this._linkifier=R,this._bufferService=P,this._coreService=M,this._mouseService=T,this._optionsService=B,this._renderService=D,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=$=>this._handleMouseMove($),this._mouseUpListener=$=>this._handleMouseUp($),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim(($=>this._handleTrim($))),this.register(this._bufferService.buffers.onBufferActivate(($=>this._handleBufferActivate($)))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!w||!E||w[0]===E[0]&&w[1]===E[1])}get selectionText(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!w||!E)return"";const R=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(w[0]===E[0])return"";const M=w[0]<E[0]?w[0]:E[0],T=w[0]<E[0]?E[0]:w[0];for(let B=w[1];B<=E[1];B++){const D=R.translateBufferLineToString(B,!0,M,T);P.push(D)}}else{const M=w[1]===E[1]?E[0]:void 0;P.push(R.translateBufferLineToString(w[1],!0,w[0],M));for(let T=w[1]+1;T<=E[1]-1;T++){const B=R.lines.get(T),D=R.translateBufferLineToString(T,!0);B?.isWrapped?P[P.length-1]+=D:P.push(D)}if(w[1]!==E[1]){const T=R.lines.get(E[1]),B=R.translateBufferLineToString(E[1],!0,0,E[0]);T&&T.isWrapped?P[P.length-1]+=B:P.push(B)}}return P.map((M=>M.replace(k," "))).join(h.isWindows?`\r
|
|
23
|
+
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=_=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],_)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,l){this._parentWindow=n,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,l,u){this._rowCount=u,n=n!==void 0?n:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,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 n=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const l=n(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=u},3236:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const l=n(3614),u=n(3656),c=n(6465),g=n(9042),_=n(3730),y=n(1680),x=n(3107),a=n(5744),h=n(2950),d=n(1296),f=n(428),b=n(4269),S=n(5114),k=n(8934),j=n(3230),w=n(9312),E=n(4725),R=n(6731),P=n(8055),M=n(8969),T=n(8460),B=n(844),D=n(6114),F=n(8437),H=n(2584),A=n(7399),O=n(5941),L=n(9074),I=n(2585),$=n(5435),V=n(4567),U=typeof window<"u"?window.document:null;class W extends M.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(N={}){super(N),this.browser=D,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new T.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new T.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new T.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new T.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new T.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new T.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new T.EventEmitter),this._onBlur=this.register(new T.EventEmitter),this._onA11yCharEmitter=this.register(new T.EventEmitter),this._onA11yTabEmitter=this.register(new T.EventEmitter),this._onWillOpen=this.register(new T.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(L.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((z,X)=>this.refresh(z,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((z=>this._reportWindowsOptions(z)))),this.register(this._inputHandler.onColor((z=>this._handleColorEvent(z)))),this.register((0,T.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,T.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((z=>this._afterResize(z.cols,z.rows)))),this.register((0,B.toDisposable)((()=>{var z,X;this._customKeyEventHandler=void 0,(X=(z=this.element)===null||z===void 0?void 0:z.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const z of N){let X,K="";switch(z.index){case 256:X="foreground",K="10";break;case 257:X="background",K="11";break;case 258:X="cursor",K="12";break;default:X="ansi",K="4;"+z.index}switch(z.type){case 0:const re=P.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[z.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${H.C0.ESC}]${K};${(0,O.toRgbString)(re)}${H.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((Z=>Z.ansi[z.index]=P.rgba.toColor(...z.color)));else{const Z=X;this._themeService.modifyColors((se=>se[Z]=P.rgba.toColor(...z.color)))}break;case 2:this._themeService.restoreColor(z.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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 N=this.buffer.ybase+this.buffer.y,z=this.buffer.lines.get(N);if(!z)return;const X=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,re=z.getWidth(X),Z=this._renderService.dimensions.css.cell.width*re,se=this.buffer.y*this._renderService.dimensions.css.cell.height,_e=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=_e+"px",this.textarea.style.top=se+"px",this.textarea.style.width=Z+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(z=>{this.hasSelection()&&(0,l.copyHandler)(z,this._selectionService)})));const N=z=>(0,l.handlePasteEvent)(z,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,u.addDisposableDomListener)(this.element,"paste",N)),D.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(z=>{z.button===2&&(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(z=>{(0,l.rightClickHandler)(z,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),D.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(z=>{z.button===1&&(0,l.moveTextAreaUnderMouseCursor)(z,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var z;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=U.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=U.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=U.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=U.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),D.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,(z=this._document.defaultView)!==null&&z!==void 0?z:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=U.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,z=this.element;function X(Z){const se=N._mouseService.getMouseReportCoords(Z,N.screenElement);if(!se)return!1;let _e,ve;switch(Z.overrideType||Z.type){case"mousemove":ve=32,Z.buttons===void 0?(_e=3,Z.button!==void 0&&(_e=Z.button<3?Z.button:3)):_e=1&Z.buttons?0:4&Z.buttons?1:2&Z.buttons?2:3;break;case"mouseup":ve=0,_e=Z.button<3?Z.button:3;break;case"mousedown":ve=1,_e=Z.button<3?Z.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(Z)===0)return!1;ve=Z.deltaY<0?0:1,_e=4;break;default:return!1}return!(ve===void 0||_e===void 0||_e>4)&&N.coreMouseService.triggerMouseEvent({col:se.col,row:se.row,x:se.x,y:se.y,button:_e,action:ve,ctrl:Z.ctrlKey,alt:Z.altKey,shift:Z.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:Z=>(X(Z),Z.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(Z)),wheel:Z=>(X(Z),this.cancel(Z,!0)),mousedrag:Z=>{Z.buttons&&X(Z)},mousemove:Z=>{Z.buttons||X(Z)}};this.register(this.coreMouseService.onProtocolChange((Z=>{Z?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Z)),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&Z?K.mousemove||(z.addEventListener("mousemove",re.mousemove),K.mousemove=re.mousemove):(z.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&Z?K.wheel||(z.addEventListener("wheel",re.wheel,{passive:!1}),K.wheel=re.wheel):(z.removeEventListener("wheel",K.wheel),K.wheel=null),2&Z?K.mouseup||(z.addEventListener("mouseup",re.mouseup),K.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),z.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&Z?K.mousedrag||(K.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(z,"mousedown",(Z=>{if(Z.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Z))return X(Z),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(Z)}))),this.register((0,u.addDisposableDomListener)(z,"wheel",(Z=>{if(!K.wheel){if(!this.buffer.hasScrollback){const se=this.viewport.getLinesScrolled(Z);if(se===0)return;const _e=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Z.deltaY<0?"A":"B");let ve="";for(let Ie=0;Ie<Math.abs(se);Ie++)ve+=_e;return this.coreService.triggerDataEvent(ve,!0),this.cancel(Z,!0)}return this.viewport.handleWheel(Z)?this.cancel(Z):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(z,"touchstart",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Z),this.cancel(Z)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(z,"touchmove",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Z)?void 0:this.cancel(Z)}),{passive:!1}))}refresh(N,z){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,z)}updateCursorStyle(N){var z;!((z=this._selectionService)===null||z===void 0)&&z.shouldColumnSelect(N)?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(N,z,X=0){var K;X===1?(super.scrollLines(N,z,X),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const z=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),z}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,z,X){this._selectionService.setSelection(N,z,X)}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 N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,z){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,z)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const z=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!z&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;z||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const K=this.rows-1;return this.scrollLines(X.type===2?-K:K),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==H.C0.ETX&&X.key!==H.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,z){const X=N.isMac&&!this.options.macOptionIsMeta&&z.altKey&&!z.ctrlKey&&!z.metaKey||N.isWindows&&z.altKey&&z.ctrlKey&&!z.metaKey||N.isWindows&&z.getModifierState("AltGraph");return z.type==="keypress"?X:X&&(!z.keyCode||z.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(z){return z.keyCode===16||z.keyCode===17||z.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let z;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)z=N.charCode;else if(N.which===null||N.which===void 0)z=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;z=N.which}return!(!z||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(z=String.fromCharCode(z),this._onKey.fire({key:z,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(z,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const z=N.data;return this.coreService.triggerDataEvent(z,!0),this.cancel(N),!0}return!1}resize(N,z){N!==this.cols||z!==this.rows?super.resize(N,z):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,z){var X,K;(X=this._charSizeService)===null||X===void 0||X.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var N;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 z=1;z<this.rows;z++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,z;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(z=this.viewport)===null||z===void 0||z.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(H.C0.ESC+"[I"):this.coreService.triggerDataEvent(H.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const z=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[4;${X};${z}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[6;${re};${K}t`)}}cancel(N,z){if(this.options.cancelEvents||z)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=W},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,l=1e3){this._renderCallback=n,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,l,u){this._rowCount=u,n=n!==void 0?n:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,l)}}},1680:function(v,i,n){var l=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(k<3?S(j):k>3?S(d,f,j):S(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=n(3656),g=n(4725),_=n(8460),y=n(844),x=n(2585);let a=i.Viewport=class extends y.Disposable{constructor(h,d,f,b,S,k,j,w){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=b,this._charSizeService=S,this._renderService=k,this._coreBrowserService=j,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.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(w.colors),this.register(w.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let b,S="";const k=[],j=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let E=h;E<j;E++){const R=w.get(E);if(!R)continue;const P=(f=w.get(E+1))===null||f===void 0?void 0:f.isWrapped;if(S+=R.translateToString(!P),!P||E===w.length-1){const M=document.createElement("div");M.textContent=S,k.push(M),S.length>0&&(b=M),S=""}}return{bufferElements:k,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};i.Viewport=a=l([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=n(3656),g=n(4725),_=n(844),y=n(2585);let x=i.BufferDecorationRenderer=class extends _.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((b=>this._removeDecoration(b)))),this.register((0,_.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(d=a.options.x)!==null&&d!==void 0?d:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};i.BufferDecorationRenderer=x=l([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],x)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(n){if(n.options.overviewRulerOptions){for(const l of this._zones)if(l.color===n.options.overviewRulerOptions.color&&l.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,n.marker.line))return;if(this._lineAdjacentToZone(l,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(l,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,l){return l>=n.startBufferLine&&l<=n.endBufferLine}_lineAdjacentToZone(n,l,u){return l>=n.startBufferLine-this._linePadding[u||"full"]&&l<=n.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(n,l){n.startBufferLine=Math.min(n.startBufferLine,l),n.endBufferLine=Math.max(n.endBufferLine,l)}}},5744:function(v,i,n){var l=this&&this.__decorate||function(b,S,k,j){var w,E=arguments.length,R=E<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,S,k,j);else for(var P=b.length-1;P>=0;P--)(w=b[P])&&(R=(E<3?w(R):E>3?w(S,k,R):w(S,k))||R);return E>3&&R&&Object.defineProperty(S,k,R),R},u=this&&this.__param||function(b,S){return function(k,j){S(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=n(5871),g=n(3656),_=n(4725),y=n(844),x=n(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,S,k,j,w,E,R){var P;super(),this._viewportElement=b,this._screenElement=S,this._bufferService=k,this._decorationService=j,this._renderService=w,this._optionsService=E,this._coreBrowseService=R,this._colorZoneStore=new c.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(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var T;(T=this._canvas)===null||T===void 0||T.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=S,h.right=b,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=S,a.center=S,a.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const S of b)S.position!=="full"&&this._renderColorZone(S);for(const S of b)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(d[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,S){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=l([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,_.IRenderService),u(5,x.IOptionsService),u(6,_.ICoreBrowserService)],f)},2950:function(v,i,n){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,S=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(S=(b<3?f(S):b>3?f(a,h,S):f(a,h))||S);return b>3&&S&&Object.defineProperty(a,h,S),S},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),_=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,h,d,f,b){this._textarea=x,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=b,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(x,"");this._dataAlreadySent=h,a.length>x.length?this._coreService.triggerDataEvent(h,!0):a.length<x.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],y)},9806:(v,i)=>{function n(l,u,c){const g=c.getBoundingClientRect(),_=l.getComputedStyle(c),y=parseInt(_.getPropertyValue("padding-left")),x=parseInt(_.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-x]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(l,u,c,g,_,y,x,a,h){if(!y)return;const d=n(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),_),d):void 0}},9504:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const l=n(2584);function u(a,h,d,f){const b=a-c(a,d),S=h-c(h,d),k=Math.abs(b-S)-(function(j,w,E){let R=0;const P=j-c(j,E),M=w-c(w,E);for(let T=0;T<Math.abs(P-M);T++){const B=g(j,w)==="A"?-1:1,D=E.buffer.lines.get(P+B*T);D?.isWrapped&&R++}return R})(a,h,d);return x(k,y(g(a,h),f))}function c(a,h){let d=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function _(a,h,d,f,b,S){let k=a,j=h,w="";for(;k!==d||j!==f;)k+=b?1:-1,b&&k>S.cols-1?(w+=S.buffer.translateBufferLineToString(j,!1,a,k),k=0,a=0,j++):!b&&k<0&&(w+=S.buffer.translateBufferLineToString(j,!1,0,a+1),k=S.cols-1,a=k,j--);return w+S.buffer.translateBufferLineToString(j,!1,a,k)}function y(a,h){const d=h?"O":"[";return l.C0.ESC+d+a}function x(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}i.moveToCellSequence=function(a,h,d,f){const b=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,E,R,P,M,T){return u(E,P,M,T).length===0?"":x(_(w,E,w,E-c(E,M),!1,M).length,y("D",T))})(b,S,0,h,d,f)+u(S,h,d,f)+(function(w,E,R,P,M,T){let B;B=u(E,P,M,T).length>0?P-c(P,M):E;const D=P,F=(function(H,A,O,L,I,$){let V;return V=u(O,L,I,$).length>0?L-c(L,I):A,H<O&&V<=L||H>=O&&V<L?"C":"D"})(w,E,R,P,M,T);return x(_(w,B,R,D,F==="C",M).length,y(F,T))})(b,S,a,h,d,f);let k;if(S===h)return k=b>a?"D":"C",x(Math.abs(b-a),y(k,f));k=S>h?"D":"C";const j=Math.abs(S-h);return x((function(w,E){return E.cols-w})(S>h?a:b,d)+(j-1)*d.cols+1+((S>h?b:a)-1),y(k,f))}},1296:function(v,i,n){var l=this&&this.__decorate||function(M,T,B,D){var F,H=arguments.length,A=H<3?T:D===null?D=Object.getOwnPropertyDescriptor(T,B):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,T,B,D);else for(var O=M.length-1;O>=0;O--)(F=M[O])&&(A=(H<3?F(A):H>3?F(T,B,A):F(T,B))||A);return H>3&&A&&Object.defineProperty(T,B,A),A},u=this&&this.__param||function(M,T){return function(B,D){T(B,D,M)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),_=n(2223),y=n(6171),x=n(4725),a=n(8055),h=n(8460),d=n(844),f=n(2585),b="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",j="xterm-bg-",w="xterm-focus",E="xterm-selection";let R=1,P=i.DomRenderer=class extends d.Disposable{constructor(M,T,B,D,F,H,A,O,L,I){super(),this._element=M,this._screenElement=T,this._viewportElement=B,this._linkifier2=D,this._charSizeService=H,this._optionsService=A,this._bufferService=O,this._coreBrowserService=L,this._themeService=I,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(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(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(b+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),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/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const T=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=T,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(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let T=`${this._terminalSelector} .${S} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;T+=`${this._terminalSelector} .${S} .xterm-dim { color: ${a.color.multiplyOpacity(M.foreground,.5).css};}`,T+=`${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;}`,T+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",T+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,T+=`${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,T+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[B,D]of M.ansi.entries())T+=`${this._terminalSelector} .${k}${B} { color: ${D.css}; }${this._terminalSelector} .${k}${B}.xterm-dim { color: ${a.color.multiplyOpacity(D,.5).css}; }${this._terminalSelector} .${j}${B} { background-color: ${D.css}; }`;T+=`${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(M.background).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${j}${_.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=T}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,T){for(let B=this._rowElements.length;B<=T;B++){const D=document.createElement("div");this._rowContainer.appendChild(D),this._rowElements.push(D)}for(;this._rowElements.length>T;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,T){this._refreshRowElements(M,T),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,T,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,T,B),this.renderRows(0,this._bufferService.rows-1),!M||!T)return;const D=M[1]-this._bufferService.buffer.ydisp,F=T[1]-this._bufferService.buffer.ydisp,H=Math.max(D,0),A=Math.min(F,this._bufferService.rows-1);if(H>=this._bufferService.rows||A<0)return;const O=document.createDocumentFragment();if(B){const L=M[0]>T[0];O.appendChild(this._createSelectionElement(H,L?T[0]:M[0],L?M[0]:T[0],A-H+1))}else{const L=D===H?M[0]:0,I=H===F?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,L,I));const $=A-H-1;if(O.appendChild(this._createSelectionElement(H+1,0,this._bufferService.cols,$)),H!==A){const V=F===A?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(A,0,V))}}this._selectionContainer.appendChild(O)}_createSelectionElement(M,T,B,D=1){const F=document.createElement("div");return F.style.height=D*this.dimensions.css.cell.height+"px",F.style.top=M*this.dimensions.css.cell.height+"px",F.style.left=T*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(B-T)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const M of this._rowElements)M.replaceChildren()}renderRows(M,T){const B=this._bufferService.buffer,D=B.ybase+B.y,F=Math.min(B.x,this._bufferService.cols-1),H=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let L=M;L<=T;L++){const I=L+B.ydisp,$=this._rowElements[L],V=B.lines.get(I);if(!$||!V)break;$.replaceChildren(...this._rowFactory.createRow(V,I,I===D,A,O,F,H,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,T,B,D,F,H){B<0&&(M=0),D<0&&(T=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),D=Math.max(Math.min(D,A),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,L=O.ybase+O.y,I=Math.min(O.x,F-1),$=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=B;W<=D;++W){const q=W+O.ydisp,N=this._rowElements[W],z=O.lines.get(q);if(!N||!z)break;N.replaceChildren(...this._rowFactory.createRow(z,q,q===L,V,U,I,$,this.dimensions.css.cell.width,this._widthCache,H?W===B?M:0:-1,H?(W===D?T:F)-1:-1))}}};i.DomRenderer=P=l([u(4,f.IInstantiationService),u(5,x.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],P)},3787:function(v,i,n){var l=this&&this.__decorate||function(k,j,w,E){var R,P=arguments.length,M=P<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,w):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,j,w,E);else for(var T=k.length-1;T>=0;T--)(R=k[T])&&(M=(P<3?R(M):P>3?R(j,w,M):R(j,w))||M);return P>3&&M&&Object.defineProperty(j,w,M),M},u=this&&this.__param||function(k,j){return function(w,E){j(w,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=n(2223),g=n(643),_=n(511),y=n(2585),x=n(8055),a=n(4725),h=n(4269),d=n(6171),f=n(3734);let b=i.DomRendererRowFactory=class{constructor(k,j,w,E,R,P,M){this._document=k,this._characterJoinerService=j,this._optionsService=w,this._coreBrowserService=E,this._coreService=R,this._decorationService=P,this._themeService=M,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,w){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=w}createRow(k,j,w,E,R,P,M,T,B,D,F){const H=[],A=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let L,I=k.getNoBgTrimmedLength();w&&I<P+1&&(I=P+1);let $=0,V="",U=0,W=0,q=0,N=!1,z=0,X=!1,K=0;const re=[],Z=D!==-1&&F!==-1;for(let se=0;se<I;se++){k.loadCell(se,this._workCell);let _e=this._workCell.getWidth();if(_e===0)continue;let ve=!1,Ie=se,ce=this._workCell;if(A.length>0&&se===A[0][0]){ve=!0;const ye=A.shift();ce=new h.JoinedCellData(this._workCell,k.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),Ie=ye[1]-1,_e=ce.getWidth()}const dt=this._isCellInSelection(se,j),xe=w&&se===P,De=Z&&se>=D&&se<=F;let Ze=!1;this._decorationService.forEachDecorationAtCell(se,j,void 0,(ye=>{Ze=!0}));let tt=ce.getChars()||g.WHITESPACE_CELL_CHAR;if(tt===" "&&(ce.isUnderline()||ce.isOverline())&&(tt=" "),K=_e*T-B.get(tt,ce.isBold(),ce.isItalic()),L){if($&&(dt&&X||!dt&&!X&&ce.bg===U)&&(dt&&X&&O.selectionForeground||ce.fg===W)&&ce.extended.ext===q&&De===N&&K===z&&!xe&&!ve&&!Ze){V+=tt,$++;continue}$&&(L.textContent=V),L=this._document.createElement("span"),$=0,V=""}else L=this._document.createElement("span");if(U=ce.bg,W=ce.fg,q=ce.extended.ext,N=De,z=K,X=dt,ve&&P>=se&&P<=Ie&&(P=se),!this._coreService.isCursorHidden&&xe){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&re.push("xterm-cursor-blink"),re.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline")}}if(ce.isBold()&&re.push("xterm-bold"),ce.isItalic()&&re.push("xterm-italic"),ce.isDim()&&re.push("xterm-dim"),V=ce.isInvisible()?g.WHITESPACE_CELL_CHAR:ce.getChars()||g.WHITESPACE_CELL_CHAR,ce.isUnderline()&&(re.push(`xterm-underline-${ce.extended.underlineStyle}`),V===" "&&(V=" "),!ce.isUnderlineColorDefault()))if(ce.isUnderlineColorRGB())L.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(ce.getUnderlineColor()).join(",")})`;else{let ye=ce.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ce.isBold()&&ye<8&&(ye+=8),L.style.textDecorationColor=O.ansi[ye].css}ce.isOverline()&&(re.push("xterm-overline"),V===" "&&(V=" ")),ce.isStrikethrough()&&re.push("xterm-strikethrough"),De&&(L.style.textDecoration="underline");let Ae=ce.getFgColor(),Ge=ce.getFgColorMode(),be=ce.getBgColor(),Me=ce.getBgColorMode();const Be=!!ce.isInverse();if(Be){const ye=Ae;Ae=be,be=ye;const G=Ge;Ge=Me,Me=G}let Le,Pe,Xe,Ce=!1;switch(this._decorationService.forEachDecorationAtCell(se,j,void 0,(ye=>{ye.options.layer!=="top"&&Ce||(ye.backgroundColorRGB&&(Me=50331648,be=ye.backgroundColorRGB.rgba>>8&16777215,Le=ye.backgroundColorRGB),ye.foregroundColorRGB&&(Ge=50331648,Ae=ye.foregroundColorRGB.rgba>>8&16777215,Pe=ye.foregroundColorRGB),Ce=ye.options.layer==="top")})),!Ce&&dt&&(Le=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,be=Le.rgba>>8&16777215,Me=50331648,Ce=!0,O.selectionForeground&&(Ge=50331648,Ae=O.selectionForeground.rgba>>8&16777215,Pe=O.selectionForeground)),Ce&&re.push("xterm-decoration-top"),Me){case 16777216:case 33554432:Xe=O.ansi[be],re.push(`xterm-bg-${be}`);break;case 50331648:Xe=x.rgba.toColor(be>>16,be>>8&255,255&be),this._addStyle(L,`background-color:#${S((be>>>0).toString(16),"0",6)}`);break;default:Be?(Xe=O.foreground,re.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Xe=O.background}switch(Le||ce.isDim()&&(Le=x.color.multiplyOpacity(Xe,.5)),Ge){case 16777216:case 33554432:ce.isBold()&&Ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ae+=8),this._applyMinimumContrast(L,Xe,O.ansi[Ae],ce,Le,void 0)||re.push(`xterm-fg-${Ae}`);break;case 50331648:const ye=x.rgba.toColor(Ae>>16&255,Ae>>8&255,255&Ae);this._applyMinimumContrast(L,Xe,ye,ce,Le,Pe)||this._addStyle(L,`color:#${S(Ae.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(L,Xe,O.foreground,ce,Le,void 0)||Be&&re.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}re.length&&(L.className=re.join(" "),re.length=0),xe||ve||Ze?L.textContent=V:$++,K!==this.defaultSpacing&&(L.style.letterSpacing=`${K}px`),H.push(L),se=Ie}return L&&$&&(L.textContent=V),H}_applyMinimumContrast(k,j,w,E,R,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const M=this._getContrastCache(E);let T;if(R||P||(T=M.getColor(j.rgba,w.rgba)),T===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);T=x.color.ensureContrastRatio(R||j,P||w,B),M.setColor((R||j).rgba,(P||w).rgba,T??null)}return!!T&&(this._addStyle(k,`color:${T.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const w=this._selectionStart,E=this._selectionEnd;return!(!w||!E)&&(this._columnSelectMode?w[0]<=E[0]?k>=w[0]&&j>=w[1]&&k<E[0]&&j<=E[1]:k<w[0]&&j>=w[1]&&k>=E[0]&&j<=E[1]:j>w[1]&&j<E[1]||w[1]===E[1]&&j===w[1]&&k>=w[0]&&k<E[0]||w[1]<E[1]&&j===E[1]&&k<E[0]||w[1]<E[1]&&j===w[1]&&k>=w[0])}};function S(k,j,w){for(;k.length<w;)k=j+k;return k}i.DomRendererRowFactory=b=l([u(1,a.ICharacterJoinerService),u(2,y.IOptionsService),u(3,a.ICoreBrowserService),u(4,y.ICoreService),u(5,y.IDecorationService),u(6,a.IThemeService)],b)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=n.createElement("span"),u=n.createElement("span");u.style.fontWeight="bold";const c=n.createElement("span");c.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),n.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(n,l,u,c){n===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=n,this._fontSize=l,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(n,l,u){let c=0;if(!l&&!u&&n.length===1&&(c=n.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(n,0);let g=n;l&&(g+="B"),u&&(g+="I");let _=this._holey.get(g);if(_===void 0){let y=0;l&&(y|=1),u&&(y|=2),_=this._measure(n,y),this._holey.set(g,_)}return _}_measure(n,l){const u=this._measureElements[l];return u.textContent=n.repeat(32),u.offsetWidth/32}}},2223:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const l=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function n(l){return 57508<=l&&l<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},i.excludeFromContrastRatioDemands=function(l){return n(l)||(function(u){return 9472<=u&&u<=9631})(l)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,l=this.selectionEnd;return!(!n||!l)&&(n[1]>l[1]||n[1]===l[1]&&n[0]>l[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=n(2585),g=n(8460),_=n(844);let y=i.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new x(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=l([u(2,c.IOptionsService)],y);class x{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,i,n){var l=this&&this.__decorate||function(h,d,f,b){var S,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(j=(k<3?S(j):k>3?S(d,f,j):S(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=n(3734),g=n(643),_=n(511),y=n(2585);class x extends c.AttributeData{constructor(d,f,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=x;let a=i.CharacterJoinerService=class bl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const b=[],S=f.translateToString(!0);let k=0,j=0,w=0,E=f.getFg(0),R=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==R){if(P-k>1){const M=this._getJoinedRanges(S,w,j,f,k);for(let T=0;T<M.length;T++)b.push(M[T])}k=P,w=j,E=this._workCell.fg,R=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(S,w,j,f,k);for(let M=0;M<P.length;M++)b.push(P[M])}return b}_getJoinedRanges(d,f,b,S,k){const j=d.substring(f,b);let w=[];try{w=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const R=this._characterJoiners[E].handler(j);for(let P=0;P<R.length;P++)bl._mergeRanges(w,R[P])}catch(R){console.error(R)}return this._stringRangesToCellRanges(w,S,k),w}_stringRangesToCellRanges(d,f,b){let S=0,k=!1,j=0,w=d[S];if(w){for(let E=b;E<this._bufferService.cols;E++){const R=f.getWidth(E),P=f.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&w[0]<=j&&(w[0]=E,k=!0),w[1]<=j){if(w[1]=E,w=d[++S],!w)break;w[0]<=j?(w[0]=E,k=!0):k=!1}j+=P}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let b=!1;for(let S=0;S<d.length;S++){const k=d[S];if(b){if(f[1]<=k[0])return d[S-1][1]=f[1],d;if(f[1]<=k[1])return d[S-1][1]=Math.max(f[1],k[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(f[1]<=k[0])return d.splice(S,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),b=!0)}}return b?d[d.length-1][1]=f[1]:d.push(f),d}};i.CharacterJoinerService=a=l([u(0,y.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,l){this._textarea=n,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(v,i,n){var l=this&&this.__decorate||function(y,x,a,h){var d,f=arguments.length,b=f<3?x:h===null?h=Object.getOwnPropertyDescriptor(x,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,x,a,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(b=(f<3?d(b):f>3?d(x,a,b):d(x,a))||b);return f>3&&b&&Object.defineProperty(x,a,b),b},u=this&&this.__param||function(y,x){return function(a,h){x(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let _=i.MouseService=class{constructor(y,x){this._renderService=y,this._charSizeService=x}getCoords(y,x,a,h,d){return(0,g.getCoords)(window,y,x,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,x){const a=(0,g.getCoordsRelativeToElement)(window,y,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};i.MouseService=_=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],_)},3230:function(v,i,n){var l=this&&this.__decorate||function(b,S,k,j){var w,E=arguments.length,R=E<3?S:j===null?j=Object.getOwnPropertyDescriptor(S,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,S,k,j);else for(var P=b.length-1;P>=0;P--)(w=b[P])&&(R=(E<3?w(R):E>3?w(S,k,R):w(S,k))||R);return E>3&&R&&Object.defineProperty(S,k,R),R},u=this&&this.__param||function(b,S){return function(k,j){S(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=n(3656),g=n(6193),_=n(5596),y=n(4725),x=n(8460),a=n(844),h=n(7226),d=n(2585);let f=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,S,k,j,w,E,R,P){if(super(),this._rowCount=b,this._charSizeService=j,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((M,T)=>this._renderRows(M,T))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const M=new R.window.IntersectionObserver((T=>this._handleIntersectionChange(T[T.length-1])),{threshold:0});M.observe(S),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,S,this._rowCount))}_renderRows(b,S){this._renderer.value&&(b=Math.min(b,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(b,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:S}),this._onRender.fire({start:b,end:S}),this._isNextRenderRedrawOnly=!0)}resize(b,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,S;this._renderer.value&&((S=(b=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,S))):this._renderer.value.handleResize(b,S),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,S,k){var j;this._selectionState.start=b,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(b,S,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};i.RenderService=f=l([u(2,d.IOptionsService),u(3,y.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,y.ICoreBrowserService),u(7,y.IThemeService)],f)},9312:function(v,i,n){var l=this&&this.__decorate||function(w,E,R,P){var M,T=arguments.length,B=T<3?E:P===null?P=Object.getOwnPropertyDescriptor(E,R):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(w,E,R,P);else for(var D=w.length-1;D>=0;D--)(M=w[D])&&(B=(T<3?M(B):T>3?M(E,R,B):M(E,R))||B);return T>3&&B&&Object.defineProperty(E,R,B),B},u=this&&this.__param||function(w,E){return function(R,P){E(R,P,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=n(9806),g=n(9504),_=n(456),y=n(4725),x=n(8460),a=n(844),h=n(6114),d=n(4841),f=n(511),b=n(2585),S=" ",k=new RegExp(S,"g");let j=i.SelectionService=class extends a.Disposable{constructor(w,E,R,P,M,T,B,D,F){super(),this._element=w,this._screenElement=E,this._linkifier=R,this._bufferService=P,this._coreService=M,this._mouseService=T,this._optionsService=B,this._renderService=D,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=H=>this._handleMouseMove(H),this._mouseUpListener=H=>this._handleMouseUp(H),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((H=>this._handleTrim(H))),this.register(this._bufferService.buffers.onBufferActivate((H=>this._handleBufferActivate(H)))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!w||!E||w[0]===E[0]&&w[1]===E[1])}get selectionText(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!w||!E)return"";const R=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(w[0]===E[0])return"";const M=w[0]<E[0]?w[0]:E[0],T=w[0]<E[0]?E[0]:w[0];for(let B=w[1];B<=E[1];B++){const D=R.translateBufferLineToString(B,!0,M,T);P.push(D)}}else{const M=w[1]===E[1]?E[0]:void 0;P.push(R.translateBufferLineToString(w[1],!0,w[0],M));for(let T=w[1]+1;T<=E[1]-1;T++){const B=R.lines.get(T),D=R.translateBufferLineToString(T,!0);B?.isWrapped?P[P.length-1]+=D:P.push(D)}if(w[1]!==E[1]){const T=R.lines.get(E[1]),B=R.translateBufferLineToString(E[1],!0,0,E[0]);T&&T.isWrapped?P[P.length-1]+=B:P.push(B)}}return P.map((M=>M.replace(k," "))).join(h.isWindows?`\r
|
|
24
24
|
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(w){const E=this._getMouseBufferCoords(w),R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(R&&P&&E)&&this._areCoordsInSelection(E,R,P)}isCellInSelection(w,E){const R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!R||!P)&&this._areCoordsInSelection([w,E],R,P)}_areCoordsInSelection(w,E,R){return w[1]>E[1]&&w[1]<R[1]||E[1]===R[1]&&w[1]===E[1]&&w[0]>=E[0]&&w[0]<R[0]||E[1]<R[1]&&w[1]===R[1]&&w[0]<R[0]||E[1]<R[1]&&w[1]===E[1]&&w[0]>=E[0]}_selectWordAtCursor(w,E){var R,P;const M=(P=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||P===void 0?void 0:P.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(w);return!!T&&(this._selectWordAt(T,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,E){this._model.clearSelection(),w=Math.max(w,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const E=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(w){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=R?0:(E>R&&(E-=R),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const 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(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const E=this._getMouseBufferCoords(w);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.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(w),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(w),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const P=R.lines.get(this._model.selectionEnd[1]);P&&P.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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const E=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const P=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,R=!(!w||!E||w[0]===E[0]&&w[1]===E[1]);R?w&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,E,R)):this._oldHasSelection&&this._fireOnSelectionChange(w,E,R)}_fireOnSelectionChange(w,E,R){this._oldSelectionStart=w,this._oldSelectionEnd=E,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(w,E){let R=E;for(let P=0;E>=P;P++){const M=w.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&E!==P&&(R+=M-1)}return R}setSelection(w,E,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,E],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,E,R=!0,P=!0){if(w[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,T=M.lines.get(w[1]);if(!T)return;const B=M.translateBufferLineToString(w[1],!1);let D=this._convertViewportColToCharacterIndex(T,w[0]),F=D;const $=w[0]-D;let A=0,O=0,L=0,I=0;if(B.charAt(D)===" "){for(;D>0&&B.charAt(D-1)===" ";)D--;for(;F<B.length&&B.charAt(F+1)===" ";)F++}else{let q=w[0],W=w[0];T.getWidth(q)===0&&(A++,q--),T.getWidth(W)===2&&(O++,W++);const K=T.getString(W).length;for(K>1&&(I+=K-1,F+=K-1);q>0&&D>0&&!this._isCharWordSeparator(T.loadCell(q-1,this._workCell));){T.loadCell(q-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,q--):N>1&&(L+=N-1,D-=N-1),D--,q--}for(;W<T.length&&F+1<B.length&&!this._isCharWordSeparator(T.loadCell(W+1,this._workCell));){T.loadCell(W+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,W++):N>1&&(I+=N-1,F+=N-1),F++,W++}}F++;let U=D+$-A+L,Y=Math.min(this._bufferService.cols,F-D+A+O-L-I);if(E||B.slice(D,F).trim()!==""){if(R&&U===0&&T.getCodePoint(0)!==32){const q=M.lines.get(w[1]-1);if(q&&T.isWrapped&&q.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(W){const K=this._bufferService.cols-W.start;U-=K,Y+=K}}}if(P&&U+Y===this._bufferService.cols&&T.getCodePoint(this._bufferService.cols-1)!==32){const q=M.lines.get(w[1]+1);if(q?.isWrapped&&q.getCodePoint(0)!==32){const W=this._getWordAt([0,w[1]+1],!1,!1,!0);W&&(Y+=W.length)}}return{start:U,length:Y}}}_selectWordAt(w,E){const R=this._getWordAt(w,E);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[R.start,w[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(w){const E=this._getWordAt(w,!0);if(E){let R=w[1];for(;E.start<0;)E.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,R]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const E=this._bufferService.buffer.getWrappedRangeForLine(w),R={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,d.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=j=l([u(3,b.IBufferService),u(4,b.ICoreService),u(5,y.IMouseService),u(6,b.IOptionsService),u(7,y.IRenderService),u(8,y.ICoreBrowserService)],j)},4725:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const l=o(8343);i.ICharSizeService=(0,l.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),i.IMouseService=(0,l.createDecorator)("MouseService"),i.IRenderService=(0,l.createDecorator)("RenderService"),i.ISelectionService=(0,l.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,i,o){var l=this&&this.__decorate||function(j,w,E,R){var P,M=arguments.length,T=M<3?w:R===null?R=Object.getOwnPropertyDescriptor(w,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(j,w,E,R);else for(var B=j.length-1;B>=0;B--)(P=j[B])&&(T=(M<3?P(T):M>3?P(w,E,T):P(w,E))||T);return M>3&&T&&Object.defineProperty(w,E,T),T},u=this&&this.__param||function(j,w){return function(E,R){w(E,R,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=o(7239),g=o(8055),_=o(8460),y=o(844),x=o(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],w=[0,95,135,175,215,255];for(let E=0;E<216;E++){const R=w[E/36%6|0],P=w[E/6%6|0],M=w[E%6];j.push({css:g.channels.toCss(R,P,M),rgba:g.channels.toRgba(R,P,M)})}for(let E=0;E<24;E++){const R=8+10*E;j.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return j})());let S=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(j={}){const w=this._colors;if(w.foreground=k(j.foreground,a),w.background=k(j.background,h),w.cursor=k(j.cursor,d),w.cursorAccent=k(j.cursorAccent,f),w.selectionBackgroundTransparent=k(j.selectionBackground,b),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(w.ansi.length-16,j.extendedAnsi.length);for(let R=0;R<E;R++)w.ansi[R+16]=k(j.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[j]=this._restoreColors.ansi[j]}else for(let w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}modifyColors(j){j(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(j,w){if(j!==void 0)try{return g.css.toColor(j)}catch{}return w}i.ThemeService=S=l([u(0,x.IOptionsService)],S)},6349:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const l=o(8460),u=o(844);class c extends u.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 x=0;x<Math.min(_,this.length);x++)y[x]=this._array[this._getCyclicIndex(x)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,y,...x){if(y){for(let a=_;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let a=this._length-1;a>=_;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(_+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:_,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,x){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let h=y-1;h>=0;h--)this.set(_+h+x,this.get(_+h));const a=_+y+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<y;a++)this.set(_+a+x,this.get(_+a))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}i.CircularList=c},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function o(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=u<=1?l[g]:l[g]&&o(l[g],u-1);return c}},8055:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const l=o(6114);let u=0,c=0,g=0,_=0;var y,x,a,h,d;function f(S){const k=S.toString(16);return k.length<2?"0"+k:k}function b(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,j,w,E){return E!==void 0?`#${f(k)}${f(j)}${f(w)}${f(E)}`:`#${f(k)}${f(j)}${f(w)}`},S.toRgba=function(k,j,w,E=255){return(k<<24|j<<16|w<<8|E)>>>0}})(y||(i.channels=y={})),(function(S){function k(j,w){return _=Math.round(255*w),[u,c,g]=d.toChannels(j.rgba),{css:y.toCss(u,c,g,_),rgba:y.toRgba(u,c,g,_)}}S.blend=function(j,w){if(_=(255&w.rgba)/255,_===1)return{css:w.css,rgba:w.rgba};const E=w.rgba>>24&255,R=w.rgba>>16&255,P=w.rgba>>8&255,M=j.rgba>>24&255,T=j.rgba>>16&255,B=j.rgba>>8&255;return u=M+Math.round((E-M)*_),c=T+Math.round((R-T)*_),g=B+Math.round((P-B)*_),{css:y.toCss(u,c,g),rgba:y.toRgba(u,c,g)}},S.isOpaque=function(j){return(255&j.rgba)==255},S.ensureContrastRatio=function(j,w,E){const R=d.ensureContrastRatio(j.rgba,w.rgba,E);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},S.opaque=function(j){const w=(255|j.rgba)>>>0;return[u,c,g]=d.toChannels(w),{css:y.toCss(u,c,g),rgba:w}},S.opacity=k,S.multiplyOpacity=function(j,w){return _=255&j.rgba,k(j,_*w/255)},S.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(x||(i.color=x={})),(function(S){let k,j;if(!l.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const E=w.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}S.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return u=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),_=parseInt(w.slice(4,5).repeat(2),16),d.toColor(u,c,g,_);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const E=w.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return u=parseInt(E[1]),c=parseInt(E[2]),g=parseInt(E[3]),_=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,_);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,_]=k.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,c,g,_),css:w}}})(a||(i.css=a={})),(function(S){function k(j,w,E){const R=j/255,P=w/255,M=E/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}S.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},S.relativeLuminance2=k})(h||(i.rgb=h={})),(function(S){function k(w,E,R){const P=w>>24&255,M=w>>16&255,T=w>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,$=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));for(;$<R&&(B>0||D>0||F>0);)B-=Math.max(0,Math.ceil(.1*B)),D-=Math.max(0,Math.ceil(.1*D)),F-=Math.max(0,Math.ceil(.1*F)),$=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));return(B<<24|D<<16|F<<8|255)>>>0}function j(w,E,R){const P=w>>24&255,M=w>>16&255,T=w>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,$=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));for(;$<R&&(B<255||D<255||F<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),D=Math.min(255,D+Math.ceil(.1*(255-D))),F=Math.min(255,F+Math.ceil(.1*(255-F))),$=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));return(B<<24|D<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(w,E,R){const P=h.relativeLuminance(w>>8),M=h.relativeLuminance(E>>8);if(b(P,M)<R){if(M<P){const D=k(w,E,R),F=b(P,h.relativeLuminance(D>>8));if(F<R){const $=j(w,E,R);return F>b(P,h.relativeLuminance($>>8))?D:$}return D}const T=j(w,E,R),B=b(P,h.relativeLuminance(T>>8));if(B<R){const D=k(w,E,R);return B>b(P,h.relativeLuminance(D>>8))?T:D}return T}},S.reduceLuminance=k,S.increaseLuminance=j,S.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},S.toColor=function(w,E,R,P){return{css:y.toCss(w,E,R,P),rgba:y.toRgba(w,E,R,P)}}})(d||(i.rgba=d={})),i.toPaddedHex=f,i.contrastRatio=b},8969:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const l=o(844),u=o(2585),c=o(4348),g=o(7866),_=o(744),y=o(7302),x=o(6975),a=o(8460),h=o(1753),d=o(1480),f=o(7994),b=o(9282),S=o(5435),k=o(5981),j=o(2660);let w=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((P=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(P.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(P){for(const M in P)this.optionsService.options[M]=P[M]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new y.OptionsService(P)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(x.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((M=>{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((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((M,T)=>this._inputHandler.parse(M,T)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,M){this._writeBuffer.write(P,M)}writeSync(P,M){this._logService.logLevel<=u.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(P,M)}resize(P,M){isNaN(P)||isNaN(M)||(P=Math.max(P,_.MINIMUM_COLS),M=Math.max(M,_.MINIMUM_ROWS),this._bufferService.resize(P,M))}scroll(P,M=!1){this._bufferService.scroll(P,M)}scrollLines(P,M,T){this._bufferService.scrollLines(P,M,T)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const M=P-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(P,M){return this._inputHandler.registerEscHandler(P,M)}registerDcsHandler(P,M){return this._inputHandler.registerDcsHandler(P,M)}registerCsiHandler(P,M){return this._inputHandler.registerCsiHandler(P,M)}registerOscHandler(P,M){return this._inputHandler.registerOscHandler(P,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?P=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const M of P)M.dispose()}))}}}i.CoreTerminal=E},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===o)return void this._listeners.splice(l,1)}}})),this._event}fire(o,l){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,o,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(o,l){return o((u=>l.fire(u)))}},5435:function(v,i,o){var l=this&&this.__decorate||function($,A,O,L){var I,U=arguments.length,Y=U<3?A:L===null?L=Object.getOwnPropertyDescriptor(A,O):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate($,A,O,L);else for(var q=$.length-1;q>=0;q--)(I=$[q])&&(Y=(U<3?I(Y):U>3?I(A,O,Y):I(A,O))||Y);return U>3&&Y&&Object.defineProperty(A,O,Y),Y},u=this&&this.__param||function($,A){return function(O,L){A(O,L,$)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=o(2584),g=o(7116),_=o(2015),y=o(844),x=o(482),a=o(8437),h=o(8460),d=o(643),f=o(511),b=o(3734),S=o(2585),k=o(6242),j=o(6351),w=o(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function P($,A){if($>24)return A.setWinLines||!1;switch($){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(i.WindowsOptionsReportType=M={}));let T=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,O,L,I,U,Y,q,W,K=new _.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=O,this._coreService=L,this._logService=I,this._optionsService=U,this._oscLinkService=Y,this._coreMouseService=q,this._unicodeService=W,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new D(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:z.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,z,V)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:z,data:V})})),this._parser.setDcsHandlerFallback(((N,z,V)=>{z==="HOOK"&&(V=V.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:z,payload:V})})),this._parser.setPrintHandler(((N,z,V)=>this.print(N,z,V))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),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 N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((N,z)=>this.requestStatusString(N,z))))}_preserveStack(A,O,L,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=L,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([A,new Promise(((O,L)=>setTimeout((()=>L("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,O){let L,I=this._activeBuffer.x,U=this._activeBuffer.y,Y=0;const q=this._parseStack.paused;if(q){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(L),L;I=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(Y=this._parseStack.position+R)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(W=>String.fromCharCode(W))).join("")}"`),typeof A=="string"?A.split("").map((W=>W.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),q||this._dirtyRowTracker.clearRange(),A.length>R)for(let W=Y;W<A.length;W+=R){const K=W+R<A.length?W+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(W,K),this._parseBuffer):this._utf8Decoder.decode(A.subarray(W,K),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,N))return this._preserveStack(I,U,N,W),this._logSlowResolvingAsync(L),L}else if(!q){const W=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,W))return this._preserveStack(I,U,W,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===I&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,O,L){let I,U;const Y=this._charsetService.charset,q=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,z=this._curAttrData;let V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-O>0&&V.getWidth(this._activeBuffer.x-1)===2&&V.setCellFromCodePoint(this._activeBuffer.x-1,0,1,z.fg,z.bg,z.extended);for(let X=O;X<L;++X){if(I=A[X],U=this._unicodeService.wcwidth(I),I<127&&Y){const re=Y[String.fromCharCode(I)];re&&(I=re.charCodeAt(0))}if(q&&this._onA11yChar.fire((0,x.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=W){if(K){for(;this._activeBuffer.x<W;)V.setCellFromCodePoint(this._activeBuffer.x++,0,1,z.fg,z.bg,z.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),V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,U===2)continue}if(N&&(V.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(z),z),V.getWidth(W-1)===2&&V.setCellFromCodePoint(W-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,z.fg,z.bg,z.extended)),V.setCellFromCodePoint(this._activeBuffer.x++,I,U,z.fg,z.bg,z.extended),U>0)for(;--U;)V.setCellFromCodePoint(this._activeBuffer.x++,0,0,z.fg,z.bg,z.extended)}else V.getWidth(this._activeBuffer.x-1)?V.addCodepointToCell(this._activeBuffer.x-1,I):V.addCodepointToCell(this._activeBuffer.x-2,I)}L-O>0&&(V.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<W&&L-O>0&&V.getWidth(this._activeBuffer.x)===0&&!V.hasContent(this._activeBuffer.x)&&V.setCellFromCodePoint(this._activeBuffer.x,0,1,z.fg,z.bg,z.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,O){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,O):this._parser.registerCsiHandler(A,(L=>!P(L.params[0],this._optionsService.rawOptions.windowOptions)||O(L)))}registerDcsHandler(A,O){return this._parser.registerDcsHandler(A,new j.DcsHandler(O))}registerEscHandler(A,O){return this._parser.registerEscHandler(A,O)}registerOscHandler(A,O){return this._parser.registerOscHandler(A,new k.OscHandler(O))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=A,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+O)}cursorUp(A){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const O=A.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const O=A.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,O,L,I=!1,U=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);Y.replaceCells(O,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),I&&(Y.isWrapped=!1)}_resetBufferLine(A,O=!1){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),L.isWrapped=!1)}eraseInDisplay(A,O=!1){let L;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);L<this._bufferService.rows;L++)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(A,O=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;O--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y;let I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;O--;)this._activeBuffer.lines.splice(L,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const O=A.params[0]||1,L=new Uint32Array(O);for(let I=0;I<O;++I)L[I]=this._parser.precedingCodepoint;return this.print(L,0,L.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,O){const L=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:U}=this._coreMouseService,Y=this._coreService,{buffers:q,cols:W}=this._bufferService,{active:K,alt:N}=q,z=this._optionsService.rawOptions,V=se=>se?1:2,X=A.params[0];return re=X,J=O?X===2?4:X===4?V(Y.modes.insertMode):X===12?3:X===20?V(z.convertEol):0:X===1?V(L.applicationCursorKeys):X===3?z.windowOptions.setWinLines?W===80?2:W===132?1:0:0:X===6?V(L.origin):X===7?V(L.wraparound):X===8?3:X===9?V(I==="X10"):X===12?V(z.cursorBlink):X===25?V(!Y.isCursorHidden):X===45?V(L.reverseWraparound):X===66?V(L.applicationKeypad):X===67?4:X===1e3?V(I==="VT200"):X===1002?V(I==="DRAG"):X===1003?V(I==="ANY"):X===1004?V(L.sendFocus):X===1005?4:X===1006?V(U==="SGR"):X===1015?4:X===1016?V(U==="SGR_PIXELS"):X===1048?1:X===47||X===1047||X===1049?V(K===N):X===2004?V(L.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${re};${J}$y`),!0;var re,J}_updateAttrColor(A,O,L,I,U){return O===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([L,I,U])):O===5&&(A&=-50331904,A|=33554432|255&L),A}_extractColor(A,O,L){const I=[0,0,-1,0,0,0];let U=0,Y=0;do{if(I[Y+U]=A.params[O+Y],A.hasSubParams(O+Y)){const q=A.getSubParams(O+Y);let W=0;do I[1]===5&&(U=1),I[Y+W+1+U]=q[W];while(++W<q.length&&W+Y+1+U<I.length);break}if(I[1]===5&&Y+U>=2||I[1]===2&&Y+U>=5)break;I[1]&&(U=1)}while(++Y+O<A.length&&Y+U<I.length);for(let q=2;q<I.length;++q)I[q]===-1&&(I[q]=0);switch(I[0]){case 38:L.fg=this._updateAttrColor(L.fg,I[1],I[3],I[4],I[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,I[1],I[3],I[4],I[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,I[1],I[3],I[4],I[5])}return Y}_processUnderline(A,O){O.extended=O.extended.clone(),(!~A||A>5)&&(A=1),O.extended.underlineStyle=A,O.fg|=268435456,A===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=A.length;let L;const I=this._curAttrData;for(let U=0;U<O;U++)L=A.params[U],L>=30&&L<=37?(I.fg&=-50331904,I.fg|=16777216|L-30):L>=40&&L<=47?(I.bg&=-50331904,I.bg|=16777216|L-40):L>=90&&L<=97?(I.fg&=-50331904,I.fg|=16777224|L-90):L>=100&&L<=107?(I.bg&=-50331904,I.bg|=16777224|L-100):L===0?this._processSGR0(I):L===1?I.fg|=134217728:L===3?I.bg|=67108864:L===4?(I.fg|=268435456,this._processUnderline(A.hasSubParams(U)?A.getSubParams(U)[0]:1,I)):L===5?I.fg|=536870912:L===7?I.fg|=67108864:L===8?I.fg|=1073741824:L===9?I.fg|=2147483648:L===2?I.bg|=134217728:L===21?this._processUnderline(2,I):L===22?(I.fg&=-134217729,I.bg&=-134217729):L===23?I.bg&=-67108865:L===24?(I.fg&=-268435457,this._processUnderline(0,I)):L===25?I.fg&=-536870913:L===27?I.fg&=-67108865:L===28?I.fg&=-1073741825:L===29?I.fg&=2147483647:L===39?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):L===49?(I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?U+=this._extractColor(A,U,I):L===53?I.bg|=1073741824:L===55?I.bg&=-1073741825:L===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):L===100?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${L}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const O=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${L}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const O=A.params[0]||1;switch(O){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 L=O%2==1;return this._optionsService.options.cursorBlink=L,!0}setScrollRegion(A){const O=A.params[0]||1;let L;return(A.length<2||(L=A.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(A){if(!P(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const O=[],L=A.split(";");for(;L.length>1;){const I=L.shift(),U=L.shift();if(/^\d+$/.exec(I)){const Y=parseInt(I);if(F(Y))if(U==="?")O.push({type:0,index:Y});else{const q=(0,w.parseColor)(U);q&&O.push({type:1,index:Y,color:q})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(A){const O=A.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(A,O){this._getCurrentLinkId()&&this._finishHyperlink();const L=A.split(":");let I;const U=L.findIndex((Y=>Y.startsWith("id=")));return U!==-1&&(I=L[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,O){const L=A.split(";");for(let I=0;I<L.length&&!(O>=this._specialColors.length);++I,++O)if(L[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const U=(0,w.parseColor)(L[I]);U&&this._onColor.fire([{type:1,index:this._specialColors[O],color:U}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const O=[],L=A.split(";");for(let I=0;I<L.length;++I)if(/^\d+$/.exec(L[I])){const U=parseInt(L[I]);F(U)&&O.push({type:2,index:U})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const L=this._activeBuffer.ybase+this._activeBuffer.y+O,I=this._activeBuffer.lines.get(L);I&&(I.fill(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,O){const L=this._bufferService.buffer,I=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${U}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,O){this._dirtyRowTracker.markRangeDirty(A,O)}}i.InputHandler=B;let D=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,A){$>A&&(T=$,$=A,A=T),$<this.start&&(this.start=$),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F($){return 0<=$&&$<256}D=l([u(0,S.IBufferService)],D)},844:(v,i)=>{function o(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.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}},i.toDisposable=function(l){return{dispose:l}},i.disposeArray=o,i.getDisposeArrayDisposable=function(l){return{dispose:()=>o(l)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(u,c,g){this._data[u]||(this._data[u]={}),this._data[u][c]=g}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=o,i.FourKeyMap=class{constructor(){this._data=new o}set(l,u,c,g,_){this._data.get(l,u)||this._data.set(l,u,new o),this._data.get(l,u).set(c,g,_)}get(l,u,c,g){var _;return(_=this._data.get(l,u))===null||_===void 0?void 0:_.get(c,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const o=i.isNode?"node":navigator.userAgent,l=i.isNode?"node":navigator.platform;i.isFirefox=o.includes("Firefox"),i.isLegacyEdge=o.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(o),i.getSafariVersion=function(){if(!i.isSafari)return 0;const u=o.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),i.isIpad=l==="iPad",i.isIphone=l==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),i.isLinux=l.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(o)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let o=0;i.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(o=this._search(this._getKey(l)),this._array.splice(o,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(o=this._search(u),o===-1)||this._getKey(this._array[o])!==u)return!1;do if(this._array[o]===l)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(o=this._search(l),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===l))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===l)}forEachByKey(l,u){if(this._array.length!==0&&(o=this._search(l),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===l))do u(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const _=this._getKey(this._array[g]);if(_>l)c=g-1;else{if(!(_<l)){for(;g>0&&this._getKey(this._array[g-1])===l;)g--;return g}u=g+1}}return u}}},7226:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const l=o(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,x=0,a=_.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),x=Math.max(y,x),h=_.timeRemaining(),1.5*x>h)return a-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-y))}ms`),void this._start();a=h}this.clear()}}class c extends u{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const l=o(643);i.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),_=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);_&&g&&(_.isWrapped=g[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&g[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new o;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=o;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=l},9092:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const l=o(6349),u=o(7226),c=o(3734),g=o(8437),_=o(4634),y=o(511),x=o(643),a=o(4863),h=o(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,f,b){this._hasScrollback=d,this._optionsService=f,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(d,b);let j=0;if(this._rows<f)for(let w=this._rows;w<f;w++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,b)));else for(let w=this._rows;w>f;w--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let j=0;j<this.lines.length;j++)S+=+this.lines.get(j).resize(d,b);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const S=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,f,S.countRemoved)}}_reflowLargerAdjustViewport(d,f,b){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let w=this.lines.get(j);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const E=[w];for(;w.isWrapped&&j>0;)w=this.lines.get(--j),E.unshift(w);const R=this.ybase+this.y;if(R>=j&&R<j+E.length)continue;const P=E[E.length-1].getTrimmedLength(),M=(0,_.reflowSmallerGetNewLineLengths)(E,this._cols,d),T=M.length-E.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+T):Math.max(0,this.lines.length-this.lines.maxLength+T);const D=[];for(let I=0;I<T;I++){const U=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);D.push(U)}D.length>0&&(S.push({start:j+E.length+k,newLines:D}),k+=D.length),E.push(...D);let F=M.length-1,$=M[F];$===0&&(F--,$=M[F]);let A=E.length-T-1,O=P;for(;A>=0;){const I=Math.min(O,$);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[A],O-I,$-I,I,!0),$-=I,$===0&&(F--,$=M[F]),O-=I,O===0){A--;const U=Math.max(A,0);O=(0,_.getWrappedLineTrimmedLength)(E,U,this._cols)}}for(let I=0;I<E.length;I++)M[I]<d&&E[I].setCell(M[I],b);let L=T-B;for(;L-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+T,this.ybase+f-1)}if(S.length>0){const j=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const E=this.lines.length;let R=E-1,P=0,M=S[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let T=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(M&&M.start>R+T){for(let $=M.newLines.length-1;$>=0;$--)this.lines.set(F--,M.newLines[$]);F++,j.push({index:R+1,amount:M.newLines.length}),T+=M.newLines.length,M=S[++P]}else this.lines.set(F,w[R--]);let B=0;for(let F=j.length-1;F>=0;F--)j[F].index+=B,this.lines.onInsertEmitter.fire(j[F]),B+=j[F].amount;const D=Math.max(0,E+k-this.lines.maxLength);D>0&&this.lines.onTrimEmitter.fire(D)}}translateBufferLineToString(d,f,b=0,S){const k=this.lines.get(d);return k?k.translateToString(f,b,S):""}getWrappedRangeForLine(d){let f=d,b=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new a.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const l=o(3734),u=o(511),c=o(643),g=o(482);i.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],d=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return _=3*a,h.content=this._data[_+0],h.fg=this._data[_+1],h.bg=this._data[_+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,d,f,b,S){268435456&b&&(this._extendedAttrs[a]=S),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*a+0]=d)}insertCells(a,h,d,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const b=new u.CellData;for(let S=this.length-a-h-1;S>=0;--S)this.setCell(a+h+S,this.loadCell(a+S,b));for(let S=0;S<h;++S)this.setCell(a+S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,d,f){if(a%=this.length,h<this.length-a){const b=new u.CellData;for(let S=0;S<this.length-a-h;++S)this.setCell(a+S,this.loadCell(a+h+S,b));for(let S=this.length-h;S<this.length;++S)this.setCell(S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,d,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,d)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let S=0;S<f.length;S++){const k=parseInt(f[S],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let S=0;S<b.length;S++){const k=parseInt(b[S],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new y(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,d,f,b){const S=a._data;if(b)for(let j=f-1;j>=0;j--){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}else for(let j=0;j<f;j++){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}const k=Object.keys(a._combined);for(let j=0;j<k.length;j++){const w=parseInt(k[j],10);w>=h&&(this._combined[w-h+d]=a._combined[w])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const b=this._data[3*h+0],S=2097151&b;f+=2097152&b?this._combined[h]:S?(0,g.stringFromCodePoint)(S):c.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(o,l){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return l*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(v,i)=>{function o(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const g=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,_=l[u+1].getWidth(0)===2;return g&&_?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(l,u,c,g,_){const y=[];for(let x=0;x<l.length-1;x++){let a=x,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(x)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=x&&g<a){x+=d.length-1;continue}let f=0,b=o(d,f,u),S=1,k=0;for(;S<d.length;){const w=o(d,S,u),E=w-k,R=c-b,P=Math.min(E,R);d[f].copyCellsFrom(d[S],k,b,P,!1),b+=P,b===c&&(f++,b=0),k+=P,k===w&&(S++,k=0),b===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,b++,1,!1),d[f-1].setCell(c-1,_))}d[f].replaceCells(b,c,_);let j=0;for(let w=d.length-1;w>0&&(w>f||d[w].getTrimmedLength()===0);w--)j++;j>0&&(y.push(x+d.length-j),y.push(j)),x+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,_=u[g],y=0;for(let x=0;x<l.length;x++)if(_===x){const a=u[++g];l.onDeleteEmitter.fire({index:x-y,amount:a}),x+=a-1,y+=a,_=u[++g]}else c.push(x);return{layout:c,countRemoved:y}},i.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let g=0;g<u.length;g++)c.push(l.get(u[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=u.length},i.reflowSmallerGetNewLineLengths=function(l,u,c){const g=[],_=l.map(((h,d)=>o(l,d,u))).reduce(((h,d)=>h+d));let y=0,x=0,a=0;for(;a<_;){if(_-a<c){g.push(_-a);break}y+=c;const h=o(l,x,u);y>h&&(y-=h,x++);const d=l[x].getWidth(y-1)===2;d&&y--;const f=d?c-1:c;g.push(f),a+=f}return g},i.getWrappedLineTrimmedLength=o},5295:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const l=o(8460),u=o(844),c=o(9092);class g extends u.Disposable{constructor(y,x){super(),this._optionsService=y,this._bufferService=x,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 c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,x){this._normal.resize(y,x),this._alt.resize(y,x),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const l=o(482),u=o(643),c=o(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const x=new g;return x.setFromCharData(y),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(y[u.CHAR_DATA_CHAR_INDEX].length===2){const a=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=y[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const l=o(8460),u=o(844);class c{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=c._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,u.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}i.Marker=c,c._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var o,l,u;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
-
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(o||(i.C0=o={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(l||(i.C1=l={})),(function(c){c.ST=`${o.ESC}\\`})(u||(i.C1_ESCAPED=u={}))},7399:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const l=o(2584),u={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(c,g,_,y){const x={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){x.key=l.C0.ESC+l.C0.DEL;break}x.key=l.C0.DEL;break;case 9:if(c.shiftKey){x.key=l.C0.ESC+"[Z";break}x.key=l.C0.HT,x.cancel=!0;break;case 13:x.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,x.cancel=!0;break;case 27:x.key=l.C0.ESC,c.altKey&&(x.key=l.C0.ESC+l.C0.ESC),x.cancel=!0;break;case 37:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"D",x.key===l.C0.ESC+"[1;3D"&&(x.key=l.C0.ESC+(_?"b":"[1;5D"))):x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"C",x.key===l.C0.ESC+"[1;3C"&&(x.key=l.C0.ESC+(_?"f":"[1;5C"))):x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"A",_||x.key!==l.C0.ESC+"[1;3A"||(x.key=l.C0.ESC+"[1;5A")):x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"B",_||x.key!==l.C0.ESC+"[1;3B"||(x.key=l.C0.ESC+"[1;5B")):x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(x.key=l.C0.ESC+"[2~");break;case 46:x.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:x.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:x.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?x.type=2:c.ctrlKey?x.key=l.C0.ESC+"[5;"+(a+1)+"~":x.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?x.type=3:c.ctrlKey?x.key=l.C0.ESC+"[6;"+(a+1)+"~":x.key=l.C0.ESC+"[6~";break;case 112:x.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:x.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:x.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:x.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:x.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:x.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:x.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:x.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:x.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:x.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:x.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:x.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(_&&!y||!c.altKey||c.metaKey)!_||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?x.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(x.key=l.C0.US),c.key==="@"&&(x.key=l.C0.NUL)):c.keyCode===65&&(x.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)x.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let b=String.fromCharCode(f);c.shiftKey&&(b=b.toUpperCase()),x.key=l.C0.ESC+b}else if(c.keyCode===32)x.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),x.key=l.C0.ESC+f,x.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?x.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?x.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?x.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?x.key=l.C0.DEL:c.keyCode===219?x.key=l.C0.ESC:c.keyCode===220?x.key=l.C0.FS:c.keyCode===221&&(x.key=l.C0.GS)}return x}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},i.utf32ToString=function(o,l=0,u=o.length){let c="";for(let g=l;g<u;++g){let _=o[g];_>65535?(_-=65536,c+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):c+=String.fromCharCode(_)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,l){const u=o.length;if(!u)return 0;let c=0,g=0;if(this._interim){const _=o.charCodeAt(g++);56320<=_&&_<=57343?l[c++]=1024*(this._interim-55296)+_-56320+65536:(l[c++]=this._interim,l[c++]=_),this._interim=0}for(let _=g;_<u;++_){const y=o.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=u)return this._interim=y,c;const x=o.charCodeAt(_);56320<=x&&x<=57343?l[c++]=1024*(y-55296)+x-56320+65536:(l[c++]=y,l[c++]=x)}else y!==65279&&(l[c++]=y)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,l){const u=o.length;if(!u)return 0;let c,g,_,y,x=0,a=0,h=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)S<<=6,S|=k;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=w-j;for(;h<E;){if(h>=u)return 0;if(k=o[h++],(192&k)!=128){h--,b=!0;break}this.interim[j++]=k,S<<=6,S|=63&k}b||(w===2?S<128?h--:l[x++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(l[x++]=S):S<65536||S>1114111||(l[x++]=S)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(c=o[f])||128&(g=o[f+1])||128&(_=o[f+2])||128&(y=o[f+3]));)l[x++]=c,l[x++]=g,l[x++]=_,l[x++]=y,f+=4;if(c=o[f++],c<128)l[x++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,x;if(g=o[f++],(192&g)!=128){f--;continue}if(a=(31&c)<<6|63&g,a<128){f--;continue}l[x++]=a}else if((240&c)==224){if(f>=u)return this.interim[0]=c,x;if(g=o[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=o[f++],(192&_)!=128){f--;continue}if(a=(15&c)<<12|(63&g)<<6|63&_,a<2048||a>=55296&&a<=57343||a===65279)continue;l[x++]=a}else if((248&c)==240){if(f>=u)return this.interim[0]=c,x;if(g=o[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=o[f++],(192&_)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=_,x;if(y=o[f++],(192&y)!=128){f--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&_)<<6|63&y,a<65536||a>1114111)continue;l[x++]=a}}return x}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const o=[[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 u;i.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<o.length;++c)u.fill(0,o[c][0],o[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,_){let y,x=0,a=_.length-1;if(g<_[0][0]||g>_[a][1])return!1;for(;a>=x;)if(y=x+a>>1,g>_[y][1])x=y+1;else{if(!(g<_[y][0]))return!0;a=y-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const l=o(8460),u=o(844);class c extends u.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new 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 x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const x=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,y);if(h){const f=b=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(x,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=c},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const o=/^([\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 u(c,g){const _=c.toString(16),y=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=o.exec(g);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,y=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(g.slice(_*x,_*x+_),16);y[x]=_===1?a<<4:_===2?a:_===3?a>>4:a>>8}return y}},i.toRgbString=function(c,g=16){const[_,y,x]=c;return`rgb:${u(_,g)}/${u(y,g)}/${u(x,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const l=o(482),u=o(8742),c=o(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,x){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(x),{dispose:()=>{const h=a.indexOf(x);h!==-1&&a.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,x){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(y,x,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,x,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,x,a))}unhook(y,x=!0){if(this._active.length){let a=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(y),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const _=new u.Params;_.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,x,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,x,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let x=!1;if(this._hitLimit)x=!1;else if(y&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=_,this._data="",this._hitLimit=!1,a)));return this._params=_,this._data="",this._hitLimit=!1,x}}},2015:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const l=o(844),u=o(8742),c=o(6242),g=o(6351);class _{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,b){this.table[d<<8|h]=f<<4|b}addMany(h,d,f,b){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=f<<4|b}}i.TransitionTable=_;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new _(4095),h=Array.apply(null,Array(256)).map(((j,w)=>w)),d=(j,w)=>h.slice(j,w),f=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const S=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),S)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(y,0,2,0),a.add(y,8,5,8),a.add(y,6,0,6),a.add(y,11,0,11),a.add(y,13,13,13),a})();class x extends l.Disposable{constructor(h=i.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,b)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<h.intermediates.length;++S){const k=h.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(d[0]>b||b>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=b,f}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const b=this._escHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const b=this._csiHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,d,f,b,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=S}parse(h,d,f){let b,S=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&E>-1){for(;E>=0&&(b=w[E](this._params),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&E>-1){for(;E>=0&&(b=w[E](),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=h[this._parseStack.chunkPos],b=this._oscParser.end(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let w=j;w<d;++w){switch(S=h[w],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let T=w+1;;++T){if(T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:w,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|S];let R=E?E.length-1:-1;for(;R>=0&&(b=E[R](this._params),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(3,E,R,k,w),b;R<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++w<d&&(S=h[w])>47&&S<60);w--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const P=this._escHandlers[this._collect<<8|S];let M=P?P.length-1:-1;for(;M>=0&&(b=P[M](),b!==!0);M--)if(b instanceof Promise)return this._preserveStack(4,P,M,k,w),b;M<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 T=w+1;;++T)if(T>=d||(S=h[T])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,w,T),w=T-1;break}break;case 14:if(b=this._dcsParser.unhook(S!==24&&S!==26),b)return this._preserveStack(6,[],0,k,w),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let T=w+1;;T++)if(T>=d||(S=h[T])<32||S>127&&S<y){this._oscParser.put(h,w,T),w=T-1;break}break;case 6:if(b=this._oscParser.end(S!==24&&S!==26),b)return this._preserveStack(5,[],0,k,w),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=x},6242:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const l=o(5770),u=o(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(_),{dispose:()=>{const x=y.indexOf(_);x!==-1&&y.splice(x,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,_,y){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(g,_,y);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,_,y))}start(){this.reset(),this._state=1}put(g,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const x=g[_++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&y-_>0&&this._put(g,_,y)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,y=_,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;x>=0&&(y=this._active[x].end(g),y!==!0);x--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,y;x--}for(;x>=0;x--)if(y=this._active[x].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,_,y){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,_,y),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,_}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const o=2147483647;class l{static fromArray(c){const g=new l;if(!c.length)return g;for(let _=Array.isArray(c[0])?1:0;_<c.length;++_){const y=c[_];if(Array.isArray(y))for(let x=0;x<y.length;++x)g.addSubParam(y[x]);else g.addParam(y)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&c.push(Array.prototype.slice.call(this._subParams,_,y))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>o?o:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>o?o:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,_=255&this._subParamsIdx[c];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&(c[g]=this._subParams.slice(_,y))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[g-1];_[g-1]=~y?Math.min(10*y+c,o):c}}i.Params=l},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===o){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(l,1)}}},8771:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const l=o(3785),u=o(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,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(c){const g=this._buffer.lines.get(c);if(g)return new l.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const l=o(511);i.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new l.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const l=o(8771),u=o(8460),c=o(844);class g extends c.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new u.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)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,l){return this._core.registerCsiHandler(o,(u=>l(u.toArray())))}addCsiHandler(o,l){return this.registerCsiHandler(o,l)}registerDcsHandler(o,l){return this._core.registerDcsHandler(o,((u,c)=>l(u,c.toArray())))}addDcsHandler(o,l){return this.registerDcsHandler(o,l)}registerEscHandler(o,l){return this._core.registerEscHandler(o,l)}addEscHandler(o,l){return this.registerEscHandler(o,l)}registerOscHandler(o,l){return this._core.registerOscHandler(o,l)}addOscHandler(o,l){return this.registerOscHandler(o,l)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(v,i,o){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=o(8460),g=o(844),_=o(5295),y=o(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let x=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=d.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=d.ybase+d.scrollTop,S=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;S===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(S+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=S-b+1;d.lines.shiftElements(b+1,k-1,-1),d.lines.set(S,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};i.BufferService=x=l([u(0,y.IOptionsService)],x)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,l){this._charsets[o]=l,this.glevel===o&&(this.charset=l)}}},1753:function(v,i,o){var l=this&&this.__decorate||function(f,b,S,k){var j,w=arguments.length,E=w<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,S,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(w<3?j(E):w>3?j(b,S,E):j(b,S))||E);return w>3&&E&&Object.defineProperty(b,S,E),E},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=o(2585),g=o(8460),_=o(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function x(f,b){let S=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(S|=64,S|=f.action):(S|=3&f.button,4&f.button&&(S|=64),8&f.button&&(S|=128),f.action===32?S|=32:f.action!==0||b||(S|=3)),S}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[x(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.x};${f.y}${b}`}};let d=i.CoreMouseService=class extends _.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(h))this.addEncoding(S,h[S]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,b,S){if(S){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};i.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,i,o){var l=this&&this.__decorate||function(d,f,b,S){var k,j=arguments.length,w=j<3?f:S===null?S=Object.getOwnPropertyDescriptor(f,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,f,b,S);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(w=(j<3?k(w):j>3?k(f,b,w):k(f,b))||w);return j>3&&w&&Object.defineProperty(f,b,w),w},u=this&&this.__param||function(d,f){return function(b,S){f(b,S,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=o(1439),g=o(8460),_=o(844),y=o(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends _.Disposable{constructor(d,f,b){super(),this._bufferService=d,this._logService=f,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=h=l([u(0,y.IBufferService),u(1,y.ILogService),u(2,y.IOptionsService)],h)},9074:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const l=o(8055),u=o(8460),c=o(844),g=o(6106);let _=0,y=0;class x extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new a(d);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,b){var S,k,j;let w=0,E=0;for(const R of this._decorations.getKeyIterator(f))w=(S=R.options.x)!==null&&S!==void 0?S:0,E=w+((k=R.options.width)!==null&&k!==void 0?k:1),d>=w&&d<E&&(!b||((j=R.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&(yield R)}forEachDecorationAtCell(d,f,b,S){this._decorations.forEachByKey(f,(k=>{var j,w,E;_=(j=k.options.x)!==null&&j!==void 0?j:0,y=_+((w=k.options.width)!==null&&w!==void 0?w:1),d>=_&&d<y&&(!b||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&S(k)}))}}i.DecorationService=x;class a extends c.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(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const l=o(2585),u=o(8343);class c{constructor(..._){this._entries=new Map;for(const[y,x]of _)this.set(y,x)}set(_,y){const x=this._entries.get(_);return this._entries.set(_,y),x}forEach(_){for(const[y,x]of this._entries.entries())_(y,x)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const y=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),x=[];for(const h of y){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);x.push(d)}const a=y.length>0?y[0].index:_.length;if(_.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${_.length} static arguments`);return new g(..._,...x)}}},7866:function(v,i,o){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=o(844),g=o(2585),_={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,x=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};i.LogService=x=l([u(0,g.IOptionsService)],x),i.setTraceLogger=function(a){y=a},i.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...b){if(y.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,b);y.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const S=f.apply(this,b);return y.trace(`GlyphRenderer#${f.name} return`,S),S}}},7302:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const l=o(8460),u=o(844),c=o(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in x)if(h in a)try{const d=x[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((h=>{h===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((h=>{x.indexOf(h)!==-1&&a()}))}_setupOptions(){const x=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:x.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[x]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=_},2660:function(v,i,o){var l=this&&this.__decorate||function(_,y,x,a){var h,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(_,y,x,a);else for(var b=_.length-1;b>=0;b--)(h=_[b])&&(f=(d<3?h(f):d>3?h(y,x,f):h(y,x))||f);return d>3&&f&&Object.defineProperty(y,x,f),f},u=this&&this.__param||function(_,y){return function(x,a){y(x,a,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=o(2585);let g=i.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const b=y.addMarker(y.ybase+y.y),S={data:_,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(S,b))),this._dataByLinkId.set(S.id,S),S.id}const x=_,a=this._getEntryIdKey(x),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const d=y.addMarker(y.ybase+y.y),f={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(_,y){const x=this._dataByLinkId.get(_);if(x&&x.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const x=_.lines.indexOf(y);x!==-1&&(_.lines.splice(x,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};i.OscLinkService=g=l([u(0,c.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const o="di$target",l="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(u){return u[l]||[]},i.createDecorator=function(u){if(i.serviceRegistry.has(u))return i.serviceRegistry.get(u);const c=function(g,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,h){a[o]===a?a[l].push({id:x,index:h}):(a[l]=[{id:x,index:h}],a[o]=a)})(c,g,y)};return c.toString=()=>u,i.serviceRegistry.set(u,c),c}},2585:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const l=o(8343);var u;i.IBufferService=(0,l.createDecorator)("BufferService"),i.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),i.ICoreService=(0,l.createDecorator)("CoreService"),i.ICharsetService=(0,l.createDecorator)("CharsetService"),i.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(u||(i.LogLevelEnum=u={})),i.ILogService=(0,l.createDecorator)("LogService"),i.IOptionsService=(0,l.createDecorator)("OptionsService"),i.IOscLinkService=(0,l.createDecorator)("OscLinkService"),i.IUnicodeService=(0,l.createDecorator)("UnicodeService"),i.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const l=o(8460),u=o(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const _=c.length;for(let y=0;y<_;++y){let x=c.charCodeAt(y);if(55296<=x&&x<=56319){if(++y>=_)return g+this.wcwidth(x);const a=c.charCodeAt(y);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(x)}return g}}}},n={};function p(v){var i=n[v];if(i!==void 0)return i.exports;var o=n[v]={exports:{}};return r[v].call(o.exports,o,o.exports,p),o.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=p(9042),o=p(3236),l=p(844),u=p(5741),c=p(8285),g=p(7975),_=p(7090),y=["cols","rows"];class x extends l.Disposable{constructor(h){super(),this._core=this.register(new o.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],f=(b,S)=>{this._checkReadonlyOptions(b),this._core.options[b]=S};for(const b in this._core.options){const S={get:d.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,S)}}_checkReadonlyOptions(h){if(y.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,f){this._verifyIntegers(h,d,f),this._core.select(h,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
|
|
27
|
-
`,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return i}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=x})(),m})()))})(Si)),Si.exports}var Em
|
|
28
|
-
\x1B[90m[Process exited with code ${x}]\x1B[0m`),
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),C.useLayoutEffect(()=>{if(!m.current)return;const x=new
|
|
30
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
25
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(w){const E=this._getMouseBufferCoords(w),R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(R&&P&&E)&&this._areCoordsInSelection(E,R,P)}isCellInSelection(w,E){const R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!R||!P)&&this._areCoordsInSelection([w,E],R,P)}_areCoordsInSelection(w,E,R){return w[1]>E[1]&&w[1]<R[1]||E[1]===R[1]&&w[1]===E[1]&&w[0]>=E[0]&&w[0]<R[0]||E[1]<R[1]&&w[1]===R[1]&&w[0]<R[0]||E[1]<R[1]&&w[1]===E[1]&&w[0]>=E[0]}_selectWordAtCursor(w,E){var R,P;const M=(P=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||P===void 0?void 0:P.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(w);return!!T&&(this._selectWordAt(T,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,E){this._model.clearSelection(),w=Math.max(w,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const E=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(w){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=R?0:(E>R&&(E-=R),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const 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(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const E=this._getMouseBufferCoords(w);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.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(w),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(w),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const P=R.lines.get(this._model.selectionEnd[1]);P&&P.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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const E=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const P=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,R=!(!w||!E||w[0]===E[0]&&w[1]===E[1]);R?w&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,E,R)):this._oldHasSelection&&this._fireOnSelectionChange(w,E,R)}_fireOnSelectionChange(w,E,R){this._oldSelectionStart=w,this._oldSelectionEnd=E,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(w,E){let R=E;for(let P=0;E>=P;P++){const M=w.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&E!==P&&(R+=M-1)}return R}setSelection(w,E,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,E],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,E,R=!0,P=!0){if(w[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,T=M.lines.get(w[1]);if(!T)return;const B=M.translateBufferLineToString(w[1],!1);let D=this._convertViewportColToCharacterIndex(T,w[0]),F=D;const H=w[0]-D;let A=0,O=0,L=0,I=0;if(B.charAt(D)===" "){for(;D>0&&B.charAt(D-1)===" ";)D--;for(;F<B.length&&B.charAt(F+1)===" ";)F++}else{let U=w[0],W=w[0];T.getWidth(U)===0&&(A++,U--),T.getWidth(W)===2&&(O++,W++);const q=T.getString(W).length;for(q>1&&(I+=q-1,F+=q-1);U>0&&D>0&&!this._isCharWordSeparator(T.loadCell(U-1,this._workCell));){T.loadCell(U-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,U--):N>1&&(L+=N-1,D-=N-1),D--,U--}for(;W<T.length&&F+1<B.length&&!this._isCharWordSeparator(T.loadCell(W+1,this._workCell));){T.loadCell(W+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,W++):N>1&&(I+=N-1,F+=N-1),F++,W++}}F++;let $=D+H-A+L,V=Math.min(this._bufferService.cols,F-D+A+O-L-I);if(E||B.slice(D,F).trim()!==""){if(R&&$===0&&T.getCodePoint(0)!==32){const U=M.lines.get(w[1]-1);if(U&&T.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(W){const q=this._bufferService.cols-W.start;$-=q,V+=q}}}if(P&&$+V===this._bufferService.cols&&T.getCodePoint(this._bufferService.cols-1)!==32){const U=M.lines.get(w[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const W=this._getWordAt([0,w[1]+1],!1,!1,!0);W&&(V+=W.length)}}return{start:$,length:V}}}_selectWordAt(w,E){const R=this._getWordAt(w,E);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[R.start,w[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(w){const E=this._getWordAt(w,!0);if(E){let R=w[1];for(;E.start<0;)E.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,R]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const E=this._bufferService.buffer.getWrappedRangeForLine(w),R={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,d.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=j=l([u(3,b.IBufferService),u(4,b.ICoreService),u(5,y.IMouseService),u(6,b.IOptionsService),u(7,y.IRenderService),u(8,y.ICoreBrowserService)],j)},4725:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const l=n(8343);i.ICharSizeService=(0,l.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),i.IMouseService=(0,l.createDecorator)("MouseService"),i.IRenderService=(0,l.createDecorator)("RenderService"),i.ISelectionService=(0,l.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,i,n){var l=this&&this.__decorate||function(j,w,E,R){var P,M=arguments.length,T=M<3?w:R===null?R=Object.getOwnPropertyDescriptor(w,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(j,w,E,R);else for(var B=j.length-1;B>=0;B--)(P=j[B])&&(T=(M<3?P(T):M>3?P(w,E,T):P(w,E))||T);return M>3&&T&&Object.defineProperty(w,E,T),T},u=this&&this.__param||function(j,w){return function(E,R){w(E,R,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=n(7239),g=n(8055),_=n(8460),y=n(844),x=n(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],w=[0,95,135,175,215,255];for(let E=0;E<216;E++){const R=w[E/36%6|0],P=w[E/6%6|0],M=w[E%6];j.push({css:g.channels.toCss(R,P,M),rgba:g.channels.toRgba(R,P,M)})}for(let E=0;E<24;E++){const R=8+10*E;j.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return j})());let S=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(j={}){const w=this._colors;if(w.foreground=k(j.foreground,a),w.background=k(j.background,h),w.cursor=k(j.cursor,d),w.cursorAccent=k(j.cursorAccent,f),w.selectionBackgroundTransparent=k(j.selectionBackground,b),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(w.ansi.length-16,j.extendedAnsi.length);for(let R=0;R<E;R++)w.ansi[R+16]=k(j.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[j]=this._restoreColors.ansi[j]}else for(let w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}modifyColors(j){j(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(j,w){if(j!==void 0)try{return g.css.toColor(j)}catch{}return w}i.ThemeService=S=l([u(0,x.IOptionsService)],S)},6349:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const l=n(8460),u=n(844);class c extends u.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 x=0;x<Math.min(_,this.length);x++)y[x]=this._array[this._getCyclicIndex(x)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,y,...x){if(y){for(let a=_;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let a=this._length-1;a>=_;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(_+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:_,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,x){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let h=y-1;h>=0;h--)this.set(_+h+x,this.get(_+h));const a=_+y+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<y;a++)this.set(_+a+x,this.get(_+a))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}i.CircularList=c},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=u<=1?l[g]:l[g]&&n(l[g],u-1);return c}},8055:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const l=n(6114);let u=0,c=0,g=0,_=0;var y,x,a,h,d;function f(S){const k=S.toString(16);return k.length<2?"0"+k:k}function b(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,j,w,E){return E!==void 0?`#${f(k)}${f(j)}${f(w)}${f(E)}`:`#${f(k)}${f(j)}${f(w)}`},S.toRgba=function(k,j,w,E=255){return(k<<24|j<<16|w<<8|E)>>>0}})(y||(i.channels=y={})),(function(S){function k(j,w){return _=Math.round(255*w),[u,c,g]=d.toChannels(j.rgba),{css:y.toCss(u,c,g,_),rgba:y.toRgba(u,c,g,_)}}S.blend=function(j,w){if(_=(255&w.rgba)/255,_===1)return{css:w.css,rgba:w.rgba};const E=w.rgba>>24&255,R=w.rgba>>16&255,P=w.rgba>>8&255,M=j.rgba>>24&255,T=j.rgba>>16&255,B=j.rgba>>8&255;return u=M+Math.round((E-M)*_),c=T+Math.round((R-T)*_),g=B+Math.round((P-B)*_),{css:y.toCss(u,c,g),rgba:y.toRgba(u,c,g)}},S.isOpaque=function(j){return(255&j.rgba)==255},S.ensureContrastRatio=function(j,w,E){const R=d.ensureContrastRatio(j.rgba,w.rgba,E);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},S.opaque=function(j){const w=(255|j.rgba)>>>0;return[u,c,g]=d.toChannels(w),{css:y.toCss(u,c,g),rgba:w}},S.opacity=k,S.multiplyOpacity=function(j,w){return _=255&j.rgba,k(j,_*w/255)},S.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(x||(i.color=x={})),(function(S){let k,j;if(!l.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const E=w.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}S.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return u=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(w.slice(1,2).repeat(2),16),c=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),_=parseInt(w.slice(4,5).repeat(2),16),d.toColor(u,c,g,_);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const E=w.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return u=parseInt(E[1]),c=parseInt(E[2]),g=parseInt(E[3]),_=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,_);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,_]=k.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,c,g,_),css:w}}})(a||(i.css=a={})),(function(S){function k(j,w,E){const R=j/255,P=w/255,M=E/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}S.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},S.relativeLuminance2=k})(h||(i.rgb=h={})),(function(S){function k(w,E,R){const P=w>>24&255,M=w>>16&255,T=w>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));for(;H<R&&(B>0||D>0||F>0);)B-=Math.max(0,Math.ceil(.1*B)),D-=Math.max(0,Math.ceil(.1*D)),F-=Math.max(0,Math.ceil(.1*F)),H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));return(B<<24|D<<16|F<<8|255)>>>0}function j(w,E,R){const P=w>>24&255,M=w>>16&255,T=w>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));for(;H<R&&(B<255||D<255||F<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),D=Math.min(255,D+Math.ceil(.1*(255-D))),F=Math.min(255,F+Math.ceil(.1*(255-F))),H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(P,M,T));return(B<<24|D<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(w,E,R){const P=h.relativeLuminance(w>>8),M=h.relativeLuminance(E>>8);if(b(P,M)<R){if(M<P){const D=k(w,E,R),F=b(P,h.relativeLuminance(D>>8));if(F<R){const H=j(w,E,R);return F>b(P,h.relativeLuminance(H>>8))?D:H}return D}const T=j(w,E,R),B=b(P,h.relativeLuminance(T>>8));if(B<R){const D=k(w,E,R);return B>b(P,h.relativeLuminance(D>>8))?T:D}return T}},S.reduceLuminance=k,S.increaseLuminance=j,S.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},S.toColor=function(w,E,R,P){return{css:y.toCss(w,E,R,P),rgba:y.toRgba(w,E,R,P)}}})(d||(i.rgba=d={})),i.toPaddedHex=f,i.contrastRatio=b},8969:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const l=n(844),u=n(2585),c=n(4348),g=n(7866),_=n(744),y=n(7302),x=n(6975),a=n(8460),h=n(1753),d=n(1480),f=n(7994),b=n(9282),S=n(5435),k=n(5981),j=n(2660);let w=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((P=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(P.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(P){for(const M in P)this.optionsService.options[M]=P[M]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new y.OptionsService(P)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(x.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((M=>{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((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((M,T)=>this._inputHandler.parse(M,T)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,M){this._writeBuffer.write(P,M)}writeSync(P,M){this._logService.logLevel<=u.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(P,M)}resize(P,M){isNaN(P)||isNaN(M)||(P=Math.max(P,_.MINIMUM_COLS),M=Math.max(M,_.MINIMUM_ROWS),this._bufferService.resize(P,M))}scroll(P,M=!1){this._bufferService.scroll(P,M)}scrollLines(P,M,T){this._bufferService.scrollLines(P,M,T)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const M=P-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(P,M){return this._inputHandler.registerEscHandler(P,M)}registerDcsHandler(P,M){return this._inputHandler.registerDcsHandler(P,M)}registerCsiHandler(P,M){return this._inputHandler.registerCsiHandler(P,M)}registerOscHandler(P,M){return this._inputHandler.registerOscHandler(P,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?P=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const M of P)M.dispose()}))}}}i.CoreTerminal=E},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===n)return void this._listeners.splice(l,1)}}})),this._event}fire(n,l){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,n,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,l){return n((u=>l.fire(u)))}},5435:function(v,i,n){var l=this&&this.__decorate||function(H,A,O,L){var I,$=arguments.length,V=$<3?A:L===null?L=Object.getOwnPropertyDescriptor(A,O):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(H,A,O,L);else for(var U=H.length-1;U>=0;U--)(I=H[U])&&(V=($<3?I(V):$>3?I(A,O,V):I(A,O))||V);return $>3&&V&&Object.defineProperty(A,O,V),V},u=this&&this.__param||function(H,A){return function(O,L){A(O,L,H)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),_=n(2015),y=n(844),x=n(482),a=n(8437),h=n(8460),d=n(643),f=n(511),b=n(3734),S=n(2585),k=n(6242),j=n(6351),w=n(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function P(H,A){if(H>24)return A.setWinLines||!1;switch(H){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function(H){H[H.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",H[H.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(i.WindowsOptionsReportType=M={}));let T=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,O,L,I,$,V,U,W,q=new _.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=O,this._coreService=L,this._logService=I,this._optionsService=$,this._oscLinkService=V,this._coreMouseService=U,this._unicodeService=W,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new D(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:z.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,z,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:z,data:X})})),this._parser.setDcsHandlerFallback(((N,z,X)=>{z==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:z,payload:X})})),this._parser.setPrintHandler(((N,z,X)=>this.print(N,z,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),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 N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((N,z)=>this.requestStatusString(N,z))))}_preserveStack(A,O,L,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=L,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([A,new Promise(((O,L)=>setTimeout((()=>L("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,O){let L,I=this._activeBuffer.x,$=this._activeBuffer.y,V=0;const U=this._parseStack.paused;if(U){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(L),L;I=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(V=this._parseStack.position+R)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(W=>String.fromCharCode(W))).join("")}"`),typeof A=="string"?A.split("").map((W=>W.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),U||this._dirtyRowTracker.clearRange(),A.length>R)for(let W=V;W<A.length;W+=R){const q=W+R<A.length?W+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(W,q),this._parseBuffer):this._utf8Decoder.decode(A.subarray(W,q),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,N))return this._preserveStack(I,$,N,W),this._logSlowResolvingAsync(L),L}else if(!U){const W=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,W))return this._preserveStack(I,$,W,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===I&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,O,L){let I,$;const V=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,z=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-O>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,z.fg,z.bg,z.extended);for(let K=O;K<L;++K){if(I=A[K],$=this._unicodeService.wcwidth(I),I<127&&V){const re=V[String.fromCharCode(I)];re&&(I=re.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,x.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=W){if(q){for(;this._activeBuffer.x<W;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,z.fg,z.bg,z.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),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,$===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(z),z),X.getWidth(W-1)===2&&X.setCellFromCodePoint(W-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,z.fg,z.bg,z.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,I,$,z.fg,z.bg,z.extended),$>0)for(;--$;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,z.fg,z.bg,z.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,I):X.addCodepointToCell(this._activeBuffer.x-2,I)}L-O>0&&(X.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<W&&L-O>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,z.fg,z.bg,z.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,O){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,O):this._parser.registerCsiHandler(A,(L=>!P(L.params[0],this._optionsService.rawOptions.windowOptions)||O(L)))}registerDcsHandler(A,O){return this._parser.registerDcsHandler(A,new j.DcsHandler(O))}registerEscHandler(A,O){return this._parser.registerEscHandler(A,O)}registerOscHandler(A,O){return this._parser.registerOscHandler(A,new k.OscHandler(O))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=A,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+O)}cursorUp(A){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const O=A.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const O=A.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,O,L,I=!1,$=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);V.replaceCells(O,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),I&&(V.isWrapped=!1)}_resetBufferLine(A,O=!1){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),L.isWrapped=!1)}eraseInDisplay(A,O=!1){let L;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);L<this._bufferService.rows;L++)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,O);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(A,O=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;O--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y;let I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;O--;)this._activeBuffer.lines.splice(L,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const O=A.params[0]||1,L=new Uint32Array(O);for(let I=0;I<O;++I)L[I]=this._parser.precedingCodepoint;return this.print(L,0,L.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,O){const L=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:$}=this._coreMouseService,V=this._coreService,{buffers:U,cols:W}=this._bufferService,{active:q,alt:N}=U,z=this._optionsService.rawOptions,X=se=>se?1:2,K=A.params[0];return re=K,Z=O?K===2?4:K===4?X(V.modes.insertMode):K===12?3:K===20?X(z.convertEol):0:K===1?X(L.applicationCursorKeys):K===3?z.windowOptions.setWinLines?W===80?2:W===132?1:0:0:K===6?X(L.origin):K===7?X(L.wraparound):K===8?3:K===9?X(I==="X10"):K===12?X(z.cursorBlink):K===25?X(!V.isCursorHidden):K===45?X(L.reverseWraparound):K===66?X(L.applicationKeypad):K===67?4:K===1e3?X(I==="VT200"):K===1002?X(I==="DRAG"):K===1003?X(I==="ANY"):K===1004?X(L.sendFocus):K===1005?4:K===1006?X($==="SGR"):K===1015?4:K===1016?X($==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?X(q===N):K===2004?X(L.bracketedPasteMode):0,V.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${re};${Z}$y`),!0;var re,Z}_updateAttrColor(A,O,L,I,$){return O===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([L,I,$])):O===5&&(A&=-50331904,A|=33554432|255&L),A}_extractColor(A,O,L){const I=[0,0,-1,0,0,0];let $=0,V=0;do{if(I[V+$]=A.params[O+V],A.hasSubParams(O+V)){const U=A.getSubParams(O+V);let W=0;do I[1]===5&&($=1),I[V+W+1+$]=U[W];while(++W<U.length&&W+V+1+$<I.length);break}if(I[1]===5&&V+$>=2||I[1]===2&&V+$>=5)break;I[1]&&($=1)}while(++V+O<A.length&&V+$<I.length);for(let U=2;U<I.length;++U)I[U]===-1&&(I[U]=0);switch(I[0]){case 38:L.fg=this._updateAttrColor(L.fg,I[1],I[3],I[4],I[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,I[1],I[3],I[4],I[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,I[1],I[3],I[4],I[5])}return V}_processUnderline(A,O){O.extended=O.extended.clone(),(!~A||A>5)&&(A=1),O.extended.underlineStyle=A,O.fg|=268435456,A===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=A.length;let L;const I=this._curAttrData;for(let $=0;$<O;$++)L=A.params[$],L>=30&&L<=37?(I.fg&=-50331904,I.fg|=16777216|L-30):L>=40&&L<=47?(I.bg&=-50331904,I.bg|=16777216|L-40):L>=90&&L<=97?(I.fg&=-50331904,I.fg|=16777224|L-90):L>=100&&L<=107?(I.bg&=-50331904,I.bg|=16777224|L-100):L===0?this._processSGR0(I):L===1?I.fg|=134217728:L===3?I.bg|=67108864:L===4?(I.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,I)):L===5?I.fg|=536870912:L===7?I.fg|=67108864:L===8?I.fg|=1073741824:L===9?I.fg|=2147483648:L===2?I.bg|=134217728:L===21?this._processUnderline(2,I):L===22?(I.fg&=-134217729,I.bg&=-134217729):L===23?I.bg&=-67108865:L===24?(I.fg&=-268435457,this._processUnderline(0,I)):L===25?I.fg&=-536870913:L===27?I.fg&=-67108865:L===28?I.fg&=-1073741825:L===29?I.fg&=2147483647:L===39?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):L===49?(I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?$+=this._extractColor(A,$,I):L===53?I.bg|=1073741824:L===55?I.bg&=-1073741825:L===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):L===100?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${L}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const O=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${L}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const O=A.params[0]||1;switch(O){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 L=O%2==1;return this._optionsService.options.cursorBlink=L,!0}setScrollRegion(A){const O=A.params[0]||1;let L;return(A.length<2||(L=A.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(A){if(!P(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const O=[],L=A.split(";");for(;L.length>1;){const I=L.shift(),$=L.shift();if(/^\d+$/.exec(I)){const V=parseInt(I);if(F(V))if($==="?")O.push({type:0,index:V});else{const U=(0,w.parseColor)($);U&&O.push({type:1,index:V,color:U})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(A){const O=A.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(A,O){this._getCurrentLinkId()&&this._finishHyperlink();const L=A.split(":");let I;const $=L.findIndex((V=>V.startsWith("id=")));return $!==-1&&(I=L[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,O){const L=A.split(";");for(let I=0;I<L.length&&!(O>=this._specialColors.length);++I,++O)if(L[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const $=(0,w.parseColor)(L[I]);$&&this._onColor.fire([{type:1,index:this._specialColors[O],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const O=[],L=A.split(";");for(let I=0;I<L.length;++I)if(/^\d+$/.exec(L[I])){const $=parseInt(L[I]);F($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const L=this._activeBuffer.ybase+this._activeBuffer.y+O,I=this._activeBuffer.lines.get(L);I&&(I.fill(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,O){const L=this._bufferService.buffer,I=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,O){this._dirtyRowTracker.markRangeDirty(A,O)}}i.InputHandler=B;let D=class{constructor(H){this._bufferService=H,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(H){H<this.start?this.start=H:H>this.end&&(this.end=H)}markRangeDirty(H,A){H>A&&(T=H,H=A,A=T),H<this.start&&(this.start=H),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(H){return 0<=H&&H<256}D=l([u(0,S.IBufferService)],D)},844:(v,i)=>{function n(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.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}},i.toDisposable=function(l){return{dispose:l}},i.disposeArray=n,i.getDisposeArrayDisposable=function(l){return{dispose:()=>n(l)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(u,c,g){this._data[u]||(this._data[u]={}),this._data[u][c]=g}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(l,u,c,g,_){this._data.get(l,u)||this._data.set(l,u,new n),this._data.get(l,u).set(c,g,_)}get(l,u,c,g){var _;return(_=this._data.get(l,u))===null||_===void 0?void 0:_.get(c,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,l=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const u=n.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),i.isIpad=l==="iPad",i.isIphone=l==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),i.isLinux=l.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(n=this._search(this._getKey(l)),this._array.splice(n,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(n=this._search(u),n===-1)||this._getKey(this._array[n])!==u)return!1;do if(this._array[n]===l)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(n=this._search(l),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===l))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===l)}forEachByKey(l,u){if(this._array.length!==0&&(n=this._search(l),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===l))do u(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const _=this._getKey(this._array[g]);if(_>l)c=g-1;else{if(!(_<l)){for(;g>0&&this._getKey(this._array[g-1])===l;)g--;return g}u=g+1}}return u}}},7226:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const l=n(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,x=0,a=_.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),x=Math.max(y,x),h=_.timeRemaining(),1.5*x>h)return a-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-y))}ms`),void this._start();a=h}this.clear()}}class c extends u{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const l=n(643);i.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),_=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);_&&g&&(_.isWrapped=g[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&g[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new n;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=n;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=l},9092:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const l=n(6349),u=n(7226),c=n(3734),g=n(8437),_=n(4634),y=n(511),x=n(643),a=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,f,b){this._hasScrollback=d,this._optionsService=f,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(d,b);let j=0;if(this._rows<f)for(let w=this._rows;w<f;w++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,b)));else for(let w=this._rows;w>f;w--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let j=0;j<this.lines.length;j++)S+=+this.lines.get(j).resize(d,b);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const S=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,f,S.countRemoved)}}_reflowLargerAdjustViewport(d,f,b){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let w=this.lines.get(j);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const E=[w];for(;w.isWrapped&&j>0;)w=this.lines.get(--j),E.unshift(w);const R=this.ybase+this.y;if(R>=j&&R<j+E.length)continue;const P=E[E.length-1].getTrimmedLength(),M=(0,_.reflowSmallerGetNewLineLengths)(E,this._cols,d),T=M.length-E.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+T):Math.max(0,this.lines.length-this.lines.maxLength+T);const D=[];for(let I=0;I<T;I++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);D.push($)}D.length>0&&(S.push({start:j+E.length+k,newLines:D}),k+=D.length),E.push(...D);let F=M.length-1,H=M[F];H===0&&(F--,H=M[F]);let A=E.length-T-1,O=P;for(;A>=0;){const I=Math.min(O,H);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[A],O-I,H-I,I,!0),H-=I,H===0&&(F--,H=M[F]),O-=I,O===0){A--;const $=Math.max(A,0);O=(0,_.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let I=0;I<E.length;I++)M[I]<d&&E[I].setCell(M[I],b);let L=T-B;for(;L-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+T,this.ybase+f-1)}if(S.length>0){const j=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const E=this.lines.length;let R=E-1,P=0,M=S[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let T=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(M&&M.start>R+T){for(let H=M.newLines.length-1;H>=0;H--)this.lines.set(F--,M.newLines[H]);F++,j.push({index:R+1,amount:M.newLines.length}),T+=M.newLines.length,M=S[++P]}else this.lines.set(F,w[R--]);let B=0;for(let F=j.length-1;F>=0;F--)j[F].index+=B,this.lines.onInsertEmitter.fire(j[F]),B+=j[F].amount;const D=Math.max(0,E+k-this.lines.maxLength);D>0&&this.lines.onTrimEmitter.fire(D)}}translateBufferLineToString(d,f,b=0,S){const k=this.lines.get(d);return k?k.translateToString(f,b,S):""}getWrappedRangeForLine(d){let f=d,b=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new a.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const l=n(3734),u=n(511),c=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],d=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return _=3*a,h.content=this._data[_+0],h.fg=this._data[_+1],h.bg=this._data[_+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,d,f,b,S){268435456&b&&(this._extendedAttrs[a]=S),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*a+0]=d)}insertCells(a,h,d,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const b=new u.CellData;for(let S=this.length-a-h-1;S>=0;--S)this.setCell(a+h+S,this.loadCell(a+S,b));for(let S=0;S<h;++S)this.setCell(a+S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,d,f){if(a%=this.length,h<this.length-a){const b=new u.CellData;for(let S=0;S<this.length-a-h;++S)this.setCell(a+S,this.loadCell(a+h+S,b));for(let S=this.length-h;S<this.length;++S)this.setCell(S,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,d,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,d)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let S=0;S<f.length;S++){const k=parseInt(f[S],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let S=0;S<b.length;S++){const k=parseInt(b[S],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new y(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,d,f,b){const S=a._data;if(b)for(let j=f-1;j>=0;j--){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}else for(let j=0;j<f;j++){for(let w=0;w<3;w++)this._data[3*(d+j)+w]=S[3*(h+j)+w];268435456&S[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}const k=Object.keys(a._combined);for(let j=0;j<k.length;j++){const w=parseInt(k[j],10);w>=h&&(this._combined[w-h+d]=a._combined[w])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const b=this._data[3*h+0],S=2097151&b;f+=2097152&b?this._combined[h]:S?(0,g.stringFromCodePoint)(S):c.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,l){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return l*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(v,i)=>{function n(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const g=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,_=l[u+1].getWidth(0)===2;return g&&_?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(l,u,c,g,_){const y=[];for(let x=0;x<l.length-1;x++){let a=x,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(x)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=x&&g<a){x+=d.length-1;continue}let f=0,b=n(d,f,u),S=1,k=0;for(;S<d.length;){const w=n(d,S,u),E=w-k,R=c-b,P=Math.min(E,R);d[f].copyCellsFrom(d[S],k,b,P,!1),b+=P,b===c&&(f++,b=0),k+=P,k===w&&(S++,k=0),b===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,b++,1,!1),d[f-1].setCell(c-1,_))}d[f].replaceCells(b,c,_);let j=0;for(let w=d.length-1;w>0&&(w>f||d[w].getTrimmedLength()===0);w--)j++;j>0&&(y.push(x+d.length-j),y.push(j)),x+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,_=u[g],y=0;for(let x=0;x<l.length;x++)if(_===x){const a=u[++g];l.onDeleteEmitter.fire({index:x-y,amount:a}),x+=a-1,y+=a,_=u[++g]}else c.push(x);return{layout:c,countRemoved:y}},i.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let g=0;g<u.length;g++)c.push(l.get(u[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=u.length},i.reflowSmallerGetNewLineLengths=function(l,u,c){const g=[],_=l.map(((h,d)=>n(l,d,u))).reduce(((h,d)=>h+d));let y=0,x=0,a=0;for(;a<_;){if(_-a<c){g.push(_-a);break}y+=c;const h=n(l,x,u);y>h&&(y-=h,x++);const d=l[x].getWidth(y-1)===2;d&&y--;const f=d?c-1:c;g.push(f),a+=f}return g},i.getWrappedLineTrimmedLength=n},5295:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const l=n(8460),u=n(844),c=n(9092);class g extends u.Disposable{constructor(y,x){super(),this._optionsService=y,this._bufferService=x,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 c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,x){this._normal.resize(y,x),this._alt.resize(y,x),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const l=n(482),u=n(643),c=n(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const x=new g;return x.setFromCharData(y),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(y[u.CHAR_DATA_CHAR_INDEX].length===2){const a=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=y[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const l=n(8460),u=n(844);class c{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=c._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,u.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}i.Marker=c,c._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var n,l,u;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
+
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(n||(i.C0=n={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(l||(i.C1=l={})),(function(c){c.ST=`${n.ESC}\\`})(u||(i.C1_ESCAPED=u={}))},7399:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const l=n(2584),u={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(c,g,_,y){const x={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){x.key=l.C0.ESC+l.C0.DEL;break}x.key=l.C0.DEL;break;case 9:if(c.shiftKey){x.key=l.C0.ESC+"[Z";break}x.key=l.C0.HT,x.cancel=!0;break;case 13:x.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,x.cancel=!0;break;case 27:x.key=l.C0.ESC,c.altKey&&(x.key=l.C0.ESC+l.C0.ESC),x.cancel=!0;break;case 37:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"D",x.key===l.C0.ESC+"[1;3D"&&(x.key=l.C0.ESC+(_?"b":"[1;5D"))):x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"C",x.key===l.C0.ESC+"[1;3C"&&(x.key=l.C0.ESC+(_?"f":"[1;5C"))):x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"A",_||x.key!==l.C0.ESC+"[1;3A"||(x.key=l.C0.ESC+"[1;5A")):x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"B",_||x.key!==l.C0.ESC+"[1;3B"||(x.key=l.C0.ESC+"[1;5B")):x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(x.key=l.C0.ESC+"[2~");break;case 46:x.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:x.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:x.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?x.type=2:c.ctrlKey?x.key=l.C0.ESC+"[5;"+(a+1)+"~":x.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?x.type=3:c.ctrlKey?x.key=l.C0.ESC+"[6;"+(a+1)+"~":x.key=l.C0.ESC+"[6~";break;case 112:x.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:x.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:x.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:x.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:x.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:x.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:x.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:x.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:x.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:x.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:x.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:x.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(_&&!y||!c.altKey||c.metaKey)!_||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?x.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(x.key=l.C0.US),c.key==="@"&&(x.key=l.C0.NUL)):c.keyCode===65&&(x.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)x.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let b=String.fromCharCode(f);c.shiftKey&&(b=b.toUpperCase()),x.key=l.C0.ESC+b}else if(c.keyCode===32)x.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),x.key=l.C0.ESC+f,x.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?x.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?x.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?x.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?x.key=l.C0.DEL:c.keyCode===219?x.key=l.C0.ESC:c.keyCode===220?x.key=l.C0.FS:c.keyCode===221&&(x.key=l.C0.GS)}return x}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,l=0,u=n.length){let c="";for(let g=l;g<u;++g){let _=n[g];_>65535?(_-=65536,c+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):c+=String.fromCharCode(_)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,l){const u=n.length;if(!u)return 0;let c=0,g=0;if(this._interim){const _=n.charCodeAt(g++);56320<=_&&_<=57343?l[c++]=1024*(this._interim-55296)+_-56320+65536:(l[c++]=this._interim,l[c++]=_),this._interim=0}for(let _=g;_<u;++_){const y=n.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=u)return this._interim=y,c;const x=n.charCodeAt(_);56320<=x&&x<=57343?l[c++]=1024*(y-55296)+x-56320+65536:(l[c++]=y,l[c++]=x)}else y!==65279&&(l[c++]=y)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,l){const u=n.length;if(!u)return 0;let c,g,_,y,x=0,a=0,h=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)S<<=6,S|=k;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=w-j;for(;h<E;){if(h>=u)return 0;if(k=n[h++],(192&k)!=128){h--,b=!0;break}this.interim[j++]=k,S<<=6,S|=63&k}b||(w===2?S<128?h--:l[x++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(l[x++]=S):S<65536||S>1114111||(l[x++]=S)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(c=n[f])||128&(g=n[f+1])||128&(_=n[f+2])||128&(y=n[f+3]));)l[x++]=c,l[x++]=g,l[x++]=_,l[x++]=y,f+=4;if(c=n[f++],c<128)l[x++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(a=(31&c)<<6|63&g,a<128){f--;continue}l[x++]=a}else if((240&c)==224){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=n[f++],(192&_)!=128){f--;continue}if(a=(15&c)<<12|(63&g)<<6|63&_,a<2048||a>=55296&&a<=57343||a===65279)continue;l[x++]=a}else if((248&c)==240){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=n[f++],(192&_)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=_,x;if(y=n[f++],(192&y)!=128){f--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&_)<<6|63&y,a<65536||a>1114111)continue;l[x++]=a}}return x}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],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 u;i.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<n.length;++c)u.fill(0,n[c][0],n[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,_){let y,x=0,a=_.length-1;if(g<_[0][0]||g>_[a][1])return!1;for(;a>=x;)if(y=x+a>>1,g>_[y][1])x=y+1;else{if(!(g<_[y][0]))return!0;a=y-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const l=n(8460),u=n(844);class c extends u.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new 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 x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const x=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,y);if(h){const f=b=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(x,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=c},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function u(c,g){const _=c.toString(16),y=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=n.exec(g);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,y=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(g.slice(_*x,_*x+_),16);y[x]=_===1?a<<4:_===2?a:_===3?a>>4:a>>8}return y}},i.toRgbString=function(c,g=16){const[_,y,x]=c;return`rgb:${u(_,g)}/${u(y,g)}/${u(x,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const l=n(482),u=n(8742),c=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,x){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(x),{dispose:()=>{const h=a.indexOf(x);h!==-1&&a.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,x){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(y,x,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,x,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,x,a))}unhook(y,x=!0){if(this._active.length){let a=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(y),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const _=new u.Params;_.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,x,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,x,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let x=!1;if(this._hitLimit)x=!1;else if(y&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=_,this._data="",this._hitLimit=!1,a)));return this._params=_,this._data="",this._hitLimit=!1,x}}},2015:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const l=n(844),u=n(8742),c=n(6242),g=n(6351);class _{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,b){this.table[d<<8|h]=f<<4|b}addMany(h,d,f,b){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=f<<4|b}}i.TransitionTable=_;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new _(4095),h=Array.apply(null,Array(256)).map(((j,w)=>w)),d=(j,w)=>h.slice(j,w),f=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const S=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),S)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(y,0,2,0),a.add(y,8,5,8),a.add(y,6,0,6),a.add(y,11,0,11),a.add(y,13,13,13),a})();class x extends l.Disposable{constructor(h=i.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,b)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<h.intermediates.length;++S){const k=h.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(d[0]>b||b>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=b,f}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const b=this._escHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const b=this._csiHandlers[f];return b.push(d),{dispose:()=>{const S=b.indexOf(d);S!==-1&&b.splice(S,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,d,f,b,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=S}parse(h,d,f){let b,S=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&E>-1){for(;E>=0&&(b=w[E](this._params),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&E>-1){for(;E>=0&&(b=w[E](),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=h[this._parseStack.chunkPos],b=this._oscParser.end(S!==24&&S!==26,f),b)return b;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let w=j;w<d;++w){switch(S=h[w],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let T=w+1;;++T){if(T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}if(++T>=d||(S=h[T])<32||S>126&&S<y){this._printHandler(h,w,T),w=T-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:w,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|S];let R=E?E.length-1:-1;for(;R>=0&&(b=E[R](this._params),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(3,E,R,k,w),b;R<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++w<d&&(S=h[w])>47&&S<60);w--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const P=this._escHandlers[this._collect<<8|S];let M=P?P.length-1:-1;for(;M>=0&&(b=P[M](),b!==!0);M--)if(b instanceof Promise)return this._preserveStack(4,P,M,k,w),b;M<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 T=w+1;;++T)if(T>=d||(S=h[T])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,w,T),w=T-1;break}break;case 14:if(b=this._dcsParser.unhook(S!==24&&S!==26),b)return this._preserveStack(6,[],0,k,w),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let T=w+1;;T++)if(T>=d||(S=h[T])<32||S>127&&S<y){this._oscParser.put(h,w,T),w=T-1;break}break;case 6:if(b=this._oscParser.end(S!==24&&S!==26),b)return this._preserveStack(5,[],0,k,w),b;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=x},6242:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const l=n(5770),u=n(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(_),{dispose:()=>{const x=y.indexOf(_);x!==-1&&y.splice(x,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,_,y){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(g,_,y);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,_,y))}start(){this.reset(),this._state=1}put(g,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const x=g[_++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&y-_>0&&this._put(g,_,y)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,y=_,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;x>=0&&(y=this._active[x].end(g),y!==!0);x--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,y;x--}for(;x>=0;x--)if(y=this._active[x].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,_,y){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,_,y),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,_}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class l{static fromArray(c){const g=new l;if(!c.length)return g;for(let _=Array.isArray(c[0])?1:0;_<c.length;++_){const y=c[_];if(Array.isArray(y))for(let x=0;x<y.length;++x)g.addSubParam(y[x]);else g.addParam(y)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&c.push(Array.prototype.slice.call(this._subParams,_,y))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>n?n:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>n?n:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,_=255&this._subParamsIdx[c];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&(c[g]=this._subParams.slice(_,y))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[g-1];_[g-1]=~y?Math.min(10*y+c,n):c}}i.Params=l},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===n){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(l,1)}}},8771:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const l=n(3785),u=n(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,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(c){const g=this._buffer.lines.get(c);if(g)return new l.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const l=n(511);i.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new l.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const l=n(8771),u=n(8460),c=n(844);class g extends c.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new u.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)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,l){return this._core.registerCsiHandler(n,(u=>l(u.toArray())))}addCsiHandler(n,l){return this.registerCsiHandler(n,l)}registerDcsHandler(n,l){return this._core.registerDcsHandler(n,((u,c)=>l(u,c.toArray())))}addDcsHandler(n,l){return this.registerDcsHandler(n,l)}registerEscHandler(n,l){return this._core.registerEscHandler(n,l)}addEscHandler(n,l){return this.registerEscHandler(n,l)}registerOscHandler(n,l){return this._core.registerOscHandler(n,l)}addOscHandler(n,l){return this.registerOscHandler(n,l)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=n(8460),g=n(844),_=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let x=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=d.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=d.ybase+d.scrollTop,S=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;S===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(S+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=S-b+1;d.lines.shiftElements(b+1,k-1,-1),d.lines.set(S,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};i.BufferService=x=l([u(0,y.IOptionsService)],x)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,l){this._charsets[n]=l,this.glevel===n&&(this.charset=l)}}},1753:function(v,i,n){var l=this&&this.__decorate||function(f,b,S,k){var j,w=arguments.length,E=w<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,S,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(w<3?j(E):w>3?j(b,S,E):j(b,S))||E);return w>3&&E&&Object.defineProperty(b,S,E),E},u=this&&this.__param||function(f,b){return function(S,k){b(S,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=n(2585),g=n(8460),_=n(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function x(f,b){let S=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(S|=64,S|=f.action):(S|=3&f.button,4&f.button&&(S|=64),8&f.button&&(S|=128),f.action===32?S|=32:f.action!==0||b||(S|=3)),S}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[x(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.x};${f.y}${b}`}};let d=i.CoreMouseService=class extends _.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(h))this.addEncoding(S,h[S]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,b,S){if(S){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};i.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,i,n){var l=this&&this.__decorate||function(d,f,b,S){var k,j=arguments.length,w=j<3?f:S===null?S=Object.getOwnPropertyDescriptor(f,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,f,b,S);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(w=(j<3?k(w):j>3?k(f,b,w):k(f,b))||w);return j>3&&w&&Object.defineProperty(f,b,w),w},u=this&&this.__param||function(d,f){return function(b,S){f(b,S,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=n(1439),g=n(8460),_=n(844),y=n(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends _.Disposable{constructor(d,f,b){super(),this._bufferService=d,this._logService=f,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=h=l([u(0,y.IBufferService),u(1,y.ILogService),u(2,y.IOptionsService)],h)},9074:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const l=n(8055),u=n(8460),c=n(844),g=n(6106);let _=0,y=0;class x extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new a(d);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,b){var S,k,j;let w=0,E=0;for(const R of this._decorations.getKeyIterator(f))w=(S=R.options.x)!==null&&S!==void 0?S:0,E=w+((k=R.options.width)!==null&&k!==void 0?k:1),d>=w&&d<E&&(!b||((j=R.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&(yield R)}forEachDecorationAtCell(d,f,b,S){this._decorations.forEachByKey(f,(k=>{var j,w,E;_=(j=k.options.x)!==null&&j!==void 0?j:0,y=_+((w=k.options.width)!==null&&w!==void 0?w:1),d>=_&&d<y&&(!b||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&S(k)}))}}i.DecorationService=x;class a extends c.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(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const l=n(2585),u=n(8343);class c{constructor(..._){this._entries=new Map;for(const[y,x]of _)this.set(y,x)}set(_,y){const x=this._entries.get(_);return this._entries.set(_,y),x}forEach(_){for(const[y,x]of this._entries.entries())_(y,x)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const y=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),x=[];for(const h of y){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);x.push(d)}const a=y.length>0?y[0].index:_.length;if(_.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${_.length} static arguments`);return new g(..._,...x)}}},7866:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,S=arguments.length,k=S<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(S<3?b(k):S>3?b(h,d,k):b(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=n(844),g=n(2585),_={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,x=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};i.LogService=x=l([u(0,g.IOptionsService)],x),i.setTraceLogger=function(a){y=a},i.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...b){if(y.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,b);y.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const S=f.apply(this,b);return y.trace(`GlyphRenderer#${f.name} return`,S),S}}},7302:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const l=n(8460),u=n(844),c=n(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in x)if(h in a)try{const d=x[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((h=>{h===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((h=>{x.indexOf(h)!==-1&&a()}))}_setupOptions(){const x=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:x.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[x]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=_},2660:function(v,i,n){var l=this&&this.__decorate||function(_,y,x,a){var h,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(_,y,x,a);else for(var b=_.length-1;b>=0;b--)(h=_[b])&&(f=(d<3?h(f):d>3?h(y,x,f):h(y,x))||f);return d>3&&f&&Object.defineProperty(y,x,f),f},u=this&&this.__param||function(_,y){return function(x,a){y(x,a,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const b=y.addMarker(y.ybase+y.y),S={data:_,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(S,b))),this._dataByLinkId.set(S.id,S),S.id}const x=_,a=this._getEntryIdKey(x),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const d=y.addMarker(y.ybase+y.y),f={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(_,y){const x=this._dataByLinkId.get(_);if(x&&x.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const x=_.lines.indexOf(y);x!==-1&&(_.lines.splice(x,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};i.OscLinkService=g=l([u(0,c.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",l="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(u){return u[l]||[]},i.createDecorator=function(u){if(i.serviceRegistry.has(u))return i.serviceRegistry.get(u);const c=function(g,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,h){a[n]===a?a[l].push({id:x,index:h}):(a[l]=[{id:x,index:h}],a[n]=a)})(c,g,y)};return c.toString=()=>u,i.serviceRegistry.set(u,c),c}},2585:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const l=n(8343);var u;i.IBufferService=(0,l.createDecorator)("BufferService"),i.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),i.ICoreService=(0,l.createDecorator)("CoreService"),i.ICharsetService=(0,l.createDecorator)("CharsetService"),i.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(u||(i.LogLevelEnum=u={})),i.ILogService=(0,l.createDecorator)("LogService"),i.IOptionsService=(0,l.createDecorator)("OptionsService"),i.IOscLinkService=(0,l.createDecorator)("OscLinkService"),i.IUnicodeService=(0,l.createDecorator)("UnicodeService"),i.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const l=n(8460),u=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const _=c.length;for(let y=0;y<_;++y){let x=c.charCodeAt(y);if(55296<=x&&x<=56319){if(++y>=_)return g+this.wcwidth(x);const a=c.charCodeAt(y);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(x)}return g}}}},o={};function p(v){var i=o[v];if(i!==void 0)return i.exports;var n=o[v]={exports:{}};return r[v].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=p(9042),n=p(3236),l=p(844),u=p(5741),c=p(8285),g=p(7975),_=p(7090),y=["cols","rows"];class x extends l.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],f=(b,S)=>{this._checkReadonlyOptions(b),this._core.options[b]=S};for(const b in this._core.options){const S={get:d.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,S)}}_checkReadonlyOptions(h){if(y.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,f){this._verifyIntegers(h,d,f),this._core.select(h,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
|
|
27
|
+
`,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return i}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=x})(),m})()))})(Si)),Si.exports}var jm=Em();var Nm=2,Rm=1,Am=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},i=v.top+v.bottom,n=v.right+v.left,l=o-i,u=p-n-s;return{cols:Math.max(Nm,Math.floor(u/e.css.cell.width)),rows:Math.max(Rm,Math.floor(l/e.css.cell.height))}}};function Mm(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[v,i]=C.useState(null),[n,l]=C.useState(()=>Zt.isConnected()),[u,c]=C.useState(!1),[g,_]=C.useState(!1),[y,x]=C.useState(!1),a=C.useRef({onOutput:p,onExit:m});a.current={onOutput:p,onExit:m};const h=C.useRef(null);h.current=v,C.useEffect(()=>{if(!v)return;const k=Zt.getSocket(),j=()=>{l(!0),c(!1),i(null),x(!0)},w=()=>{l(!1),c(!1)},E=T=>{T.terminalId===v&&a.current.onOutput?.(T.data)},R=T=>{T.terminalId===v&&(c(!1),a.current.onExit?.(T.exitCode),i(null))},P=T=>{T.terminalId===v&&c(!0)},M=T=>{T.terminalId===v&&c(!1)};return k.on("connect",j),k.on("disconnect",w),k.on(at.TERMINAL_STDOUT,E),k.on(at.TERMINAL_EXIT,R),k.on(at.TERMINAL_SUBSCRIBED,P),k.on(at.TERMINAL_UNSUBSCRIBED,M),l(k.connected),k.connected&&k.emit(ws.SUBSCRIBE,{topic:"terminal",id:v},T=>{T.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",w),k.off(at.TERMINAL_STDOUT,E),k.off(at.TERMINAL_EXIT,R),k.off(at.TERMINAL_SUBSCRIBED,P),k.off(at.TERMINAL_UNSUBSCRIBED,M),k.emit(ws.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=C.useCallback(async()=>{const k=Zt.getSocket();if(!k.connected)return null;_(!0);try{const j=await me.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(j.terminalId),x(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{_(!1)}},[s,r,o]),f=C.useCallback(async()=>{const k=h.current;if(k){try{await me.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),c(!1)}},[]),b=C.useCallback(k=>{const j=h.current;if(!j)return;Zt.getSocket().emit(ws.TERMINAL_INPUT,{terminalId:j,data:k})},[]),S=C.useCallback((k,j)=>{const w=h.current;if(!w)return;Zt.getSocket().emit(ws.TERMINAL_RESIZE,{terminalId:w,cols:k,rows:j})},[]);return C.useEffect(()=>()=>{const k=h.current;k&&me.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:n,isAttached:u,isCreating:g,needsRecreate:y,create:d,destroy:f,sendInput:b,resize:S}}const Tm={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"},Dm=de.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=C.useRef(null),v=C.useRef(null),i=C.useRef(null),n=C.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:g,sendInput:_,resize:y}=Mm({cwd:s,onOutput:C.useCallback(x=>{v.current?.write(x)},[]),onExit:C.useCallback(x=>{v.current?.writeln(`\r
|
|
28
|
+
\x1B[90m[Process exited with code ${x}]\x1B[0m`),o?.(x)},[o])});return C.useEffect(()=>{if(!c)return;const x=v.current;x&&x.writeln(`\r
|
|
29
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),C.useLayoutEffect(()=>{if(!m.current)return;const x=new jm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Tm,scrollback:5e3,convertEol:!0}),a=new Am;x.loadAddon(a),x.open(m.current);const h=(d=0)=>{if(!(d>=5))try{const b=m.current;if(!b||b.clientWidth===0||b.clientHeight===0){setTimeout(()=>h(d+1),50);return}a.fit(),y(x.cols,x.rows)}catch{setTimeout(()=>h(d+1),50)}};return h(0),setTimeout(()=>h(1),100),v.current=x,i.current=a,()=>{x.dispose(),v.current=null,i.current=null}},[y]),C.useEffect(()=>{n.current||(n.current=!0,g())},[g]),C.useEffect(()=>{const x=v.current;if(!x||!u)return;const a=x.onData(h=>{_(h)});return()=>a.dispose()},[_,u]),C.useEffect(()=>{u&&p?.({sendInput:_})},[u,_,p]),C.useEffect(()=>{if(!r)return;const x=i.current,a=v.current,h=m.current;if(!x||!a||!h)return;let d=!1,f;const b=S=>{d||S>=5||(f=requestAnimationFrame(()=>{if(!d)if(h.clientWidth>0&&h.clientHeight>0)try{x.fit(),y(a.cols,a.rows)}catch{}else setTimeout(()=>b(S+1),30)}))};return b(0),()=>{d=!0,f!=null&&cancelAnimationFrame(f)}},[r,y]),C.useEffect(()=>{if(!m.current)return;const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=i.current,h=v.current,d=m.current;a&&h&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),y(h.cols,h.rows))}catch{}})});return x.observe(m.current),()=>x.disconnect()},[y]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),Lm=de.memo(function({commands:s,onSelect:r}){const{t:o}=ue(),[p,m]=C.useState(!1),v=C.useRef(null),i=C.useRef(null);return C.useEffect(()=>{if(!p)return;const n=l=>{v.current&&!v.current.contains(l.target)&&i.current&&!i.current.contains(l.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:i,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(gd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(xt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((n,l)=>t.jsxs("button",{onClick:()=>{r(n.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:[t.jsx(Ut,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},l))})})]})]})});let wi=0;function Ao(){return wi+=1,{id:`shell-${wi}`,order:wi}}const Pm=de.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:p}=ue(),[m,v]=C.useState(()=>[Ao()]),[i,n]=C.useState(()=>m[0].id),l=C.useRef(new Map),u=C.useCallback(()=>{const x=Ao();v(a=>[...a,x]),n(x.id)},[]),c=C.useCallback((x,a)=>{a.stopPropagation(),l.current.delete(x),v(h=>{const d=h.filter(f=>f.id!==x);return x===i&&d.length>0&&n(d[d.length-1].id),d})},[i]),g=C.useCallback(x=>{l.current.delete(x),v(a=>{const h=a.filter(d=>d.id!==x);return x===i&&h.length>0&&n(h[h.length-1].id),h})},[i]),_=C.useCallback((x,a)=>{l.current.set(x,a.sendInput)},[]),y=C.useCallback(x=>{const a=l.current.get(i);a&&a(x+"\r")},[i]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:m.map(x=>t.jsxs("button",{onClick:()=>n(x.id),className:ee("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",x.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Rr,{size:11,className:"shrink-0"}),t.jsx("span",{children:p("Shell {count}",{count:x.order})}),m.length>1&&t.jsx("span",{onClick:a=>c(x.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(is,{size:10})})]},x.id))}),t.jsx("button",{onClick:u,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:p("New Terminal"),children:t.jsx(es,{size:14})}),o.length>0&&t.jsx(Lm,{commands:o,onSelect:y})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Rr,{size:28}),t.jsx("span",{className:"text-xs",children:p("No terminals open")}),t.jsx("button",{onClick:u,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:p("New Terminal")})]})}):m.map(x=>t.jsx("div",{className:"absolute inset-0",style:{display:x.id===i?"block":"none"},children:t.jsx(Dm,{cwd:s,isVisible:r&&x.id===i,onExit:()=>g(x.id),onReady:a=>_(x.id,a)})},x.id))})]})});function Mo(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Om(e){if(Array.isArray(e))return e}function Im(e,s,r){return(s=Um(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Bm(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,v,i=[],n=!0,l=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(n=(o=m.call(r)).done)&&(i.push(o.value),i.length!==s);n=!0);}catch(u){l=!0,p=u}finally{try{if(!n&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw p}}return i}}function Fm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
30
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Do(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?To(Object(r),!0).forEach(function(o){Im(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):To(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function zm(e,s){if(e==null)return{};var r,o,p=Wm(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function Wm(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Hm(e,s){return Om(e)||Bm(e,s)||qm(e,s)||Fm()}function $m(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Um(e){var s=$m(e,"string");return typeof s=="symbol"?s:s+""}function qm(e,s){if(e){if(typeof e=="string")return Mo(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mo(e,s):void 0}}function Km(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Lo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Po(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lo(Object(r),!0).forEach(function(o){Km(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Xm(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function $s(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function Fr(e){return{}.toString.call(e).includes("Object")}function Vm(e){return!Object.keys(e).length}function er(e){return typeof e=="function"}function Ym(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Gm(e,s){return Fr(s)||ss("changeType"),Object.keys(s).some(function(r){return!Ym(e,r)})&&ss("changeField"),s}function Qm(e){er(e)||ss("selectorType")}function Zm(e){er(e)||Fr(e)||ss("handlerType"),Fr(e)&&Object.values(e).some(function(s){return!er(s)})&&ss("handlersType")}function Jm(e){e||ss("initialIsRequired"),Fr(e)||ss("initialType"),Vm(e)&&ss("initialContent")}function ep(e,s){throw new Error(e[s]||e.default)}var tp={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"},ss=$s(ep)(tp),_r={changes:Gm,selector:Qm,handler:Zm,initial:Jm};function sp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_r.initial(e),_r.handler(s);var r={current:e},o=$s(np)(r,s),p=$s(ip)(r),m=$s(_r.changes)(e),v=$s(rp)(r);function i(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return _r.selector(l),l(r.current)}function n(l){Xm(o,p,m,v)(l)}return[i,n]}function rp(e,s){return er(s)?s(e.current):s}function ip(e,s){return e.current=Po(Po({},e.current),s),s}function np(e,s,r){return er(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var op={create:sp},ap={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function lp(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function cp(e){return{}.toString.call(e).includes("Object")}function dp(e){return e||Oo("configIsRequired"),cp(e)||Oo("configType"),e.urls?(up(),{paths:{vs:e.urls.monacoBase}}):e}function up(){console.warn(yl.deprecation)}function hp(e,s){throw new Error(e[s]||e.default)}var yl={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
31
31
|
You are using deprecated way of configuration.
|
|
32
32
|
|
|
33
33
|
Instead of using
|
|
@@ -36,7 +36,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
36
36
|
monaco.config({ paths: { vs: '...' } })
|
|
37
37
|
|
|
38
38
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},Oo=ap(up)(bl),hp={config:cp},fp=function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function yl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],yl(e[r],s[r]))}),Do(Do({},e),s)}var mp={type:"cancelation",msg:"operation is manually canceled"};function Ci(e){var s=!1,r=new Promise(function(n,p){e.then(function(m){return s?p(mp):n(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var pp=["monaco"],gp=np.create({config:op,isInitialized:!1,resolve:null,reject:null,monaco:null}),Sl=Hm(gp,2),cr=Sl[0],ei=Sl[1];function vp(e){var s=hp.config(e),r=s.monaco,n=Fm(s,pp);ei(function(p){return{config:yl(p.config,n),monaco:r}})}function xp(){var e=cr(function(s){var r=s.monaco,n=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:n,resolve:p}});if(!e.isInitialized){if(ei({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ci(ki);if(window.monaco&&window.monaco.editor)return wl(window.monaco),e.resolve(window.monaco),Ci(ki);fp(_p,yp)(Sp)}return Ci(ki)}function _p(e){return document.body.appendChild(e)}function bp(e){var s=document.createElement("script");return e&&(s.src=e),s}function yp(e){var s=cr(function(n){var p=n.config,m=n.reject;return{config:p,reject:m}}),r=bp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Sp(){var e=cr(function(r){var n=r.config,p=r.resolve,m=r.reject;return{config:n,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var n=r.m||r;wl(n),e.resolve(n)},function(r){e.reject(r)})}function wl(e){cr().monaco||ei({monaco:e})}function wp(){return cr(function(e){var s=e.monaco;return s})}var ki=new Promise(function(e,s){return ei({resolve:e,reject:s})}),Cl={config:vp,init:xp,__getMonacoInstance:wp},Cp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ei=Cp,kp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ep=kp;function jp({children:e}){return le.createElement("div",{style:Ep.container},e)}var Np=jp,Rp=Np;function Ap({width:e,height:s,isEditorReady:r,loading:n,_ref:p,className:m,wrapperProps:v}){return le.createElement("section",{style:{...Ei.wrapper,width:e,height:s},...v},!r&&le.createElement(Rp,null,n),le.createElement("div",{ref:p,style:{...Ei.fullWidth,...!r&&Ei.hide},className:m}))}var Mp=Ap,kl=C.memo(Mp);function Tp(e){C.useEffect(e,[])}var El=Tp;function Dp(e,s,r=!0){let n=C.useRef(!0);C.useEffect(n.current||!r?()=>{n.current=!1}:e,s)}var St=Dp;function Xs(){}function ks(e,s,r,n){return Lp(e,n)||Pp(e,s,r,n)}function Lp(e,s){return e.editor.getModel(jl(e,s))}function Pp(e,s,r,n){return e.editor.createModel(s,r,n?jl(e,n):void 0)}function jl(e,s){return e.Uri.parse(s)}function Op({original:e,modified:s,language:r,originalLanguage:n,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:o=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:_="100%",className:y,wrapperProps:x={},beforeMount:a=Xs,onMount:h=Xs}){let[d,f]=C.useState(!1),[b,S]=C.useState(!0),k=C.useRef(null),j=C.useRef(null),w=C.useRef(null),E=C.useRef(h),R=C.useRef(a),P=C.useRef(!1);El(()=>{let D=Cl.init();return D.then(F=>(j.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?B():D.cancel()}),St(()=>{if(k.current&&j.current){let D=k.current.getOriginalEditor(),F=ks(j.current,e||"",n||r||"text",m||"");F!==D.getModel()&&D.setModel(F)}},[m],d),St(()=>{if(k.current&&j.current){let D=k.current.getModifiedEditor(),F=ks(j.current,s||"",p||r||"text",v||"");F!==D.getModel()&&D.setModel(F)}},[v],d),St(()=>{let D=k.current.getModifiedEditor();D.getOption(j.current.editor.EditorOption.readOnly)?D.setValue(s||""):s!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[s],d),St(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:D,modified:F}=k.current.getModel();j.current.editor.setModelLanguage(D,n||r||"text"),j.current.editor.setModelLanguage(F,p||r||"text")},[r,n,p],d),St(()=>{j.current?.editor.setTheme(l)},[l],d),St(()=>{k.current?.updateOptions(c)},[c],d);let M=C.useCallback(()=>{if(!j.current)return;R.current(j.current);let D=ks(j.current,e||"",n||r||"text",m||""),F=ks(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:D,modified:F})},[r,s,p,e,n,m,v]),T=C.useCallback(()=>{!P.current&&w.current&&(k.current=j.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...c}),M(),j.current?.editor.setTheme(l),f(!0),P.current=!0)},[c,l,M]);C.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),C.useEffect(()=>{!b&&!d&&T()},[b,d,T]);function B(){let D=k.current?.getModel();i||D?.original?.dispose(),o||D?.modified?.dispose(),k.current?.dispose()}return le.createElement(kl,{width:_,height:g,isEditorReady:d,loading:u,_ref:w,className:y,wrapperProps:x})}var Ip=Op;C.memo(Ip);function Bp(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var Fp=Bp,yr=new Map;function zp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:n,language:p,path:m,theme:v="light",line:i,loading:o="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:_="100%",height:y="100%",className:x,wrapperProps:a={},beforeMount:h=Xs,onMount:d=Xs,onChange:f,onValidate:b=Xs}){let[S,k]=C.useState(!1),[j,w]=C.useState(!0),E=C.useRef(null),R=C.useRef(null),P=C.useRef(null),M=C.useRef(d),T=C.useRef(h),B=C.useRef(),D=C.useRef(n),F=Fp(m),$=C.useRef(!1),A=C.useRef(!1);El(()=>{let I=Cl.init();return I.then(U=>(E.current=U)&&w(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>R.current?L():I.cancel()}),St(()=>{let I=ks(E.current,e||n||"",s||p||"",m||r||"");I!==R.current?.getModel()&&(c&&yr.set(F,R.current?.saveViewState()),R.current?.setModel(I),c&&R.current?.restoreViewState(yr.get(m)))},[m],S),St(()=>{R.current?.updateOptions(l)},[l],S),St(()=>{!R.current||n===void 0||(R.current.getOption(E.current.editor.EditorOption.readOnly)?R.current.setValue(n):n!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[n],S),St(()=>{let I=R.current?.getModel();I&&p&&E.current?.editor.setModelLanguage(I,p)},[p],S),St(()=>{i!==void 0&&R.current?.revealLine(i)},[i],S),St(()=>{E.current?.editor.setTheme(v)},[v],S);let O=C.useCallback(()=>{if(!(!P.current||!E.current)&&!$.current){T.current(E.current);let I=m||r,U=ks(E.current,n||e||"",s||p||"",I||"");R.current=E.current?.editor.create(P.current,{model:U,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(yr.get(I)),E.current.editor.setTheme(v),i!==void 0&&R.current.revealLine(i),k(!0),$.current=!0}},[e,s,r,n,p,m,l,u,c,v,i]);C.useEffect(()=>{S&&M.current(R.current,E.current)},[S]),C.useEffect(()=>{!j&&!S&&O()},[j,S,O]),D.current=n,C.useEffect(()=>{S&&f&&(B.current?.dispose(),B.current=R.current?.onDidChangeModelContent(I=>{A.current||f(R.current.getValue(),I)}))},[S,f]),C.useEffect(()=>{if(S){let I=E.current.editor.onDidChangeMarkers(U=>{let Y=R.current.getModel()?.uri;if(Y&&U.find(q=>q.path===Y.path)){let q=E.current.editor.getModelMarkers({resource:Y});b?.(q)}});return()=>{I?.dispose()}}return()=>{}},[S,b]);function L(){B.current?.dispose(),g?c&&yr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return le.createElement(kl,{width:_,height:y,isEditorReady:S,loading:o,_ref:P,className:x,wrapperProps:a})}var Hp=zp,Wp=C.memo(Hp),$p=Wp,jt=function(e,s){return Number(e.toFixed(s))},Up=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},qp=function(e){return-Math.cos(e*Math.PI)/2+.5},Kp=function(e){return e},Xp=function(e){return e*e},Vp=function(e){return e*(2-e)},Yp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Gp=function(e){return e*e*e},Qp=function(e){return--e*e*e+1},Zp=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Jp=function(e){return e*e*e*e},eg=function(e){return 1- --e*e*e*e},tg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},sg=function(e){return e*e*e*e*e},rg=function(e){return 1+--e*e*e*e*e},ig=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Nl={easeOut:qp,linear:Kp,easeInQuad:Xp,easeOutQuad:Vp,easeInOutQuad:Yp,easeInCubic:Gp,easeOutCubic:Qp,easeInOutCubic:Zp,easeInQuart:Jp,easeOutQuart:eg,easeInOutQuart:tg,easeInQuint:sg,easeOutQuint:rg,easeInOutQuint:ig},Rl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Mt=function(e){e.mounted&&(Rl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Al(e,s,r,n){if(e.mounted){var p=new Date().getTime(),m=1;Mt(e),e.animation=function(){if(!e.mounted)return Rl(e.animation);var v=new Date().getTime()-p,i=v/r,o=Nl[s],l=o(i);v>=r?(n(m),e.animation=null):e.animation&&(n(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ng(e){var s=e.scale,r=e.positionX,n=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(n))}function os(e,s,r,n){var p=ng(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY,u=s.scale-i,c=s.positionX-o,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):Al(e,n,r,function(_){var y=i+u*_,x=o+c*_,a=l+g*_;m(y,x,a)})}}function og(e,s,r){var n=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,i=m*r,o=v*r,l=n-i,u=p-o;return{wrapperWidth:n,wrapperHeight:p,newContentWidth:i,newDiffWidth:l,newContentHeight:o,newDiffHeight:u}}var ag=function(e,s,r,n,p,m,v){var i=e>s?r*(v?1:.5):0,o=n>p?m*(v?1:.5):0,l=e-s-i,u=i,c=n-p-o,g=o;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Tn=function(e,s){var r=e.wrapperComponent,n=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!n)throw new Error("Components are not mounted");var m=og(r,n,s),v=m.wrapperWidth,i=m.wrapperHeight,o=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=ag(v,o,l,i,u,c,!!p);return g},Xi=function(e,s,r,n){return n?e<s?jt(s,2):e>r?jt(r,2):jt(e,2):jt(e,2)},ds=function(e,s){var r=Tn(e,s);return e.bounds=r,r};function dr(e,s,r,n,p,m,v){var i=r.minPositionX,o=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var _=Xi(e,i-c,l+c,n),y=Xi(s,o-g,u+g,n);return{x:_,y}}function ti(e,s,r,n,p,m){var v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY,u=n-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:l};var c=o-s*u,g=l-r*u,_=dr(c,g,p,m,0,0,null);return _}function ur(e,s,r,n,p){var m=p?n:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Io=function(e,s){var r=e.setup.panning.excluded,n=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,i=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),o=n&&m&&i;if(!o)return!1;var l=si(m,r);return!l},Bo=function(e){var s=e.isInitialized,r=e.isPanning,n=e.setup,p=n.panning.disabled,m=s&&r&&!p;return!!m},lg=function(e,s){var r=e.transformState,n=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-n,y:v-p}},cg=function(e,s){var r=s.touches,n=e.transformState,p=n.positionX,m=n.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,o=r[0].clientY;e.startCoords={x:i-p,y:o-m}}};function dg(e){var s=e.transformState,r=s.positionX,n=s.positionY,p=s.scale,m=e.setup,v=m.disabled,i=m.limitToBounds,o=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,_=u.maxPositionY,y=u.minPositionY,x=r>c||r<g,a=n>_||n<y,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=n>_?l.offsetHeight:e.setup.minPositionY||0,f=ti(e,h,d,p,e.bounds,i||o),b=f.x,S=f.y;return{scale:p,positionX:x?b:r,positionY:a?S:n}}}function Ml(e,s,r,n,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,o=e.transformState,l=o.scale,u=o.positionX,c=o.positionY;if(!(v===null||i===null||s===u&&r===c)){var g=dr(s,r,i,m,n,p,v),_=g.x,y=g.y;e.setTransformState(l,_,y)}}var ug=function(e,s,r){var n=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,i=m.lockAxisY,o=p.positionX,l=p.positionY;if(!n)return{x:o,y:l};var u=s-n.x,c=r-n.y,g=v?o:u,_=i?l:c;return{x:g,y:_}},ns=function(e,s){var r=e.setup,n=e.transformState,p=n.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},hg=function(e){var s=e.mounted,r=e.setup,n=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,i=!v||m>1||!n||s;return!!i},fg=function(e){var s=e.mounted,r=e.velocity,n=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,i=e.transformState.scale,o=v.disabled,l=!o||i>1||!m||s;return!(!l||!r||!n)};function mg(e,s){var r=e.setup.velocityAnimation,n=r.equalToMove,p=r.animationTime,m=r.sensitivity;return n?p*s*m:p}function Fo(e,s,r,n,p,m,v,i,o,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>o?o:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<i?i:u>m?m:u}}return n?s:Xi(e,m,v,p)}function pg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function gg(e,s){var r=hg(e);if(r){var n=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,i=m.velocityAnimation.equalToMove,o=Date.now();if(n&&p&&v){var l=pg(v,i),u=s.x-n.x,c=s.y-n.y,g=u/l,_=c/l,y=o-p,x=u*u+c*c,a=Math.sqrt(x)/y;e.velocity={velocityX:g,velocityY:_,total:a}}e.lastMousePosition=s,e.velocityTime=o}}function vg(e){var s=e.velocity,r=e.bounds,n=e.setup,p=e.wrapperComponent,m=fg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,i=s.velocityY,o=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,_=n.limitToBounds,y=n.alignmentAnimation,x=n.zoomAnimation,a=n.panning,h=a.lockAxisY,d=a.lockAxisX,f=x.animationType,b=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,j=k,w=mg(e,o),E=Math.max(w,j),R=ns(e,b),P=ns(e,S),M=R*p.offsetWidth/100,T=P*p.offsetHeight/100,B=l+M,D=u-M,F=c+T,$=g-T,A=e.transformState,O=new Date().getTime();Al(e,f,E,function(L){var I=e.transformState,U=I.scale,Y=I.positionX,q=I.positionY,W=new Date().getTime()-O,K=W/j,N=Nl[y.animationType],z=1-N(Math.min(1,K)),V=1-L,X=Y+v*V,re=q+i*V,J=Fo(X,A.positionX,Y,d,_,u,l,D,B,z),se=Fo(re,A.positionY,q,h,_,g,c,$,F,z);(Y!==X||q!==re)&&e.setTransformState(U,J,se)})}}function zo(e,s){var r=e.transformState.scale;Mt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?cg(e,s):lg(e,s)}function Dn(e,s){var r=e.transformState.scale,n=e.setup,p=n.minScale,m=n.alignmentAnimation,v=m.disabled,i=m.sizeX,o=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!i&&!o;if(!c){var g=dg(e);g&&os(e,g,s??l,u)}}function Ho(e,s,r){var n=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(n){var o=ug(e,s,r),l=o.x,u=o.y,c=ns(e,v),g=ns(e,i);gg(e,{x:l,y:u}),Ml(e,l,u,c,g)}}function xg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,n=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=n?.getBoundingClientRect(),v=p?.getBoundingClientRect(),i=m?.width||0,o=m?.height||0,l=v?.width||0,u=v?.height||0,c=i<l||o<u,g=!s&&r&&r?.total>.1&&c;g?vg(e):Dn(e)}}function Ln(e,s,r,n){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,o=ur(jt(s,2),m,v,0,!1),l=ds(e,o),u=ti(e,r,n,o,l,i),c=u.x,g=u.y;return{scale:o,positionX:c,positionY:g}}function Tl(e,s,r){var n=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,i=m.limitToBounds,o=m.zoomAnimation,l=o.disabled,u=o.animationTime,c=o.animationType,g=l||n>=v;if((n>=1||i)&&Dn(e),!(g||!p||!e.mounted)){var _=s||p.offsetWidth/2,y=r||p.offsetHeight/2,x=Ln(e,v,_,y);x&&os(e,x,u,c)}}var rs=function(){return rs=Object.assign||function(s){for(var r,n=1,p=arguments.length;n<p;n++){r=arguments[n];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},rs.apply(this,arguments)};function Wo(e,s,r){for(var n=0,p=s.length,m;n<p;n++)(m||!(n in s))&&(m||(m=Array.prototype.slice.call(s,0,n)),m[n]=s[n]);return e.concat(m||Array.prototype.slice.call(s))}var Sr={scale:1,positionX:0,positionY:0},Hs={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}},Vi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Dl=function(e){var s,r,n,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Sr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Sr.scale,positionX:(n=e.initialPositionX)!==null&&n!==void 0?n:Sr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Sr.positionY}},$o=function(e){var s=rs({},Hs);return Object.keys(e).forEach(function(r){var n=typeof e[r]<"u",p=typeof Hs[r]<"u";if(p&&n){var m=Object.prototype.toString.call(Hs[r]),v=m==="[object Object]",i=m==="[object Array]";v?s[r]=rs(rs({},Hs[r]),e[r]):i?s[r]=Wo(Wo([],Hs[r],!0),e[r]):s[r]=e[r]}}),s},Ll=function(e,s,r){var n=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,i=m.minScale,o=m.zoomAnimation,l=m.smooth,u=o.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?n*Math.exp(s*r):n+s*r,g=ur(jt(c,3),i,v,u,!1);return g};function Pl(e,s,r,n,p){var m=e.wrapperComponent,v=e.transformState,i=v.scale,o=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-o)/i,_=(c/2-l)/i,y=Ll(e,s,r),x=Ln(e,y,g,_);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");os(e,x,n,p)}function Ol(e,s,r,n){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Dl(e.props),o=e.transformState,l=o.scale,u=o.positionX,c=o.positionY;if(m){var g=Tn(e,i.scale),_=dr(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:_.x,positionY:_.y};l===i.scale&&u===i.positionX&&c===i.positionY||(n?.(),os(e,y,s,r))}}function _g(e,s,r,n){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),i=m.x*n.scale,o=m.y*n.scale;return{x:(p.x-v.x+i)/n.scale,y:(p.y-v.y+o)/n.scale}}function bg(e,s,r){var n=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,i=v.limitToBounds,o=v.minScale,l=v.maxScale;if(!n||!p)return m;var u=n.getBoundingClientRect(),c=s.getBoundingClientRect(),g=_g(s,n,p,m),_=g.x,y=g.y,x=c.width/m.scale,a=c.height/m.scale,h=n.offsetWidth/x,d=n.offsetHeight/a,f=ur(r||Math.min(h,d),o,l,0,!1),b=(u.width-x*f)/2,S=(u.height-a*f)/2,k=(u.left-_)*f+b,j=(u.top-y)*f+S,w=Tn(e,f),E=dr(k,j,w,i,0,0,n),R=E.x,P=E.y;return{positionX:R,positionY:P,scale:f}}var yg=function(e){return function(s,r,n){s===void 0&&(s=.5),r===void 0&&(r=300),n===void 0&&(n="easeOut"),Pl(e,1,s,r,n)}},Sg=function(e){return function(s,r,n){s===void 0&&(s=.5),r===void 0&&(r=300),n===void 0&&(n="easeOut"),Pl(e,-1,s,r,n)}},wg=function(e){return function(s,r,n,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,i=v.positionX,o=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var _={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?o:r,scale:Number.isNaN(n)?l:n};os(e,_,p,m)}}},Cg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Ol(e,s,r)}},kg=function(e){return function(s,r,n){r===void 0&&(r=200),n===void 0&&(n="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var i=Il(s||p.scale,m,v);os(e,i,r,n)}}},Eg=function(e){return function(s,r,n,p){n===void 0&&(n=600),p===void 0&&(p="easeOut"),Mt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=bg(e,v,r);os(e,i,n,p)}}},Hr=function(e){return{instance:e,zoomIn:yg(e),zoomOut:Sg(e),setTransform:wg(e),resetTransform:Cg(e),centerView:kg(e),zoomToElement:Eg(e)}},Yi=function(e){return{instance:e,state:e.transformState}},Ue=function(e){var s={};return Object.assign(s,Yi(e)),Object.assign(s,Hr(e)),s},ji=!1;function Ni(){try{var e={get passive(){return ji=!0,!1}};return e}catch{return ji=!1,ji}}var wr=".".concat(Vi.wrapperClass),si=function(e,s){return s.some(function(r){return e.matches("".concat(wr," ").concat(r,", ").concat(wr," .").concat(r,", ").concat(wr," ").concat(r," *, ").concat(wr," .").concat(r," *"))})},Gi=function(e){e&&clearTimeout(e)},jg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Il=function(e,s,r){var n=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-n)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function Ng(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Rg=function(e,s){var r=e.setup.wheel,n=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,o=e.isPanning,l=s.target,u=i&&!o&&!n&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=si(l,v);return!c},Ag=function(e){return e?e.deltaY<0?1:-1:0};function Mg(e,s){var r=Ag(e),n=Up(s,r);return n}function Bl(e,s,r){var n=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-n.left)/r,m=(e.clientY-n.top)/r;else{var v=e.touches[0];p=(v.clientX-n.left)/r,m=(v.clientY-n.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var Tg=function(e,s,r,n,p){var m=e.transformState.scale,v=e.wrapperComponent,i=e.setup,o=i.maxScale,l=i.minScale,u=i.zoomAnimation,c=i.disablePadding,g=u.size,_=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,x=n?!1:!_,a=ur(jt(y,3),l,o,g,x&&!c);return a},Dg=function(e,s){var r=e.previousWheelEvent,n=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?n<m||n>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Lg=function(e,s){var r=e.setup.pinch,n=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,i=m&&!n&&v;if(!i)return!1;var o=si(v,p);return!o},Pg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,n=e.pinchStartDistance,p=r&&!s&&n;return!!p},Og=function(e,s,r){var n=r.getBoundingClientRect(),p=e.touches,m=jt(p[0].clientX-n.left,5),v=jt(p[0].clientY-n.top,5),i=jt(p[1].clientX-n.left,5),o=jt(p[1].clientY-n.top,5);return{x:(m+i)/2/s,y:(v+o)/2/s}},Fl=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))},Ig=function(e,s){var r=e.pinchStartScale,n=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,i=p.zoomAnimation,o=p.disablePadding,l=i.size,u=i.disabled;if(!r||n===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/n,g=c*r;return ur(jt(g,2),v,m,l,!u&&!o)},Bg=160,Fg=100,zg=function(e,s){var r=e.props,n=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Mt(e),Qe(Ue(e),s,n),Qe(Ue(e),s,p))},Hg=function(e,s){var r=e.props,n=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,i=e.transformState,o=i.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,_=v.disablePadding,y=v.smooth,x=c.size,a=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Mg(s,null),b=y?d*Math.abs(s.deltaY):h,S=Tg(e,f,b,!s.ctrlKey);if(o!==S){var k=ds(e,S),j=Bl(s,m,o),w=a||x===0||u||_,E=l&&w,R=ti(e,j.x,j.y,S,k,E),P=R.x,M=R.y;e.previousWheelEvent=s,e.setTransformState(S,P,M),Qe(Ue(e),s,n),Qe(Ue(e),s,p)}},Wg=function(e,s){var r=e.props,n=r.onWheelStop,p=r.onZoomStop;Gi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Tl(e,s.x,s.y),e.wheelAnimationTimer=null)},Fg);var m=Dg(e,s);m&&(Gi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(Ue(e),s,n),Qe(Ue(e),s,p))},Bg))},zl=function(e){for(var s=0,r=0,n=0;n<2;n+=1)s+=e.touches[n].clientX,r+=e.touches[n].clientY;var p=s/2,m=r/2;return{x:p,y:m}},$g=function(e,s){var r=Fl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var n=zl(s);e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y,Mt(e)},Ug=function(e,s){var r=e.contentComponent,n=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,i=v.limitToBounds,o=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(n===null||!r)){var _=Og(s,m,r);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var y=Fl(s),x=Ig(e,y),a=zl(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ds(e,x),b=c||g===0||o,S=i&&b,k=ti(e,_.x,_.y,x,f,S),j=k.x,w=k.y;e.pinchMidpoint=_,e.lastDistance=y;var E=u.sizeX,R=u.sizeY,P=ns(e,E),M=ns(e,R),T=j+h,B=w+d,D=dr(T,B,f,i,P,M,p),F=D.x,$=D.y;e.setTransformState(x,F,$)}}}},qg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Tl(e,s?.x,s?.y)},Hl=function(e,s){var r=e.props.onZoomStop,n=e.setup.doubleClick.animationTime;Gi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(Ue(e),s,r)},n)},Kg=function(e,s){var r=e.props,n=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Qe(Ue(e),s,n),Ol(e,v,i,function(){return Qe(Ue(e),s,p)}),Hl(e,s)};function Xg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Vg(e,s){var r=e.setup,n=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,i=e.props,o=i.onZoomStart,l=i.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,_=u.step,y=u.animationTime,x=u.animationType;if(!c&&!n){if(g==="reset")return Kg(e,s);if(!m)return console.error("No ContentComponent found");var a=Xg(g,e.transformState.scale),h=Ll(e,a,_);if(v!==h){Qe(Ue(e),s,o);var d=Bl(s,m,v),f=Ln(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ue(e),s,l),os(e,f,y,x),Hl(e,s)}}}var Yg=function(e,s){var r=e.isInitialized,n=e.setup,p=e.wrapperComponent,m=n.doubleClick,v=m.disabled,i=m.excluded,o=s.target,l=p?.contains(o),u=r&&o&&l&&!v;if(!u)return!1;var c=si(o,i);return!c},Gg=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(n){r.props=n,ds(r,r.transformState.scale),r.setup=$o(n)},this.initializeWindowEvents=function(){var n,p,m=Ni(),v=(n=r.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,i=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var n,p,m=Ni(),v=(n=r.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Mt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(n){var p=Ni();n.addEventListener("wheel",r.onWheelZoom,p),n.addEventListener("dblclick",r.onDoubleClick,p),n.addEventListener("touchstart",r.onTouchPanningStart,p),n.addEventListener("touchmove",r.onTouchPanning,p),n.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(n,p){var m=!1,v=r.setup.centerOnInit,i=function(o,l){for(var u=0,c=o;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(o){o(Ue(r))}),r.observer=new ResizeObserver(function(o){if(i(o,n)||i(o,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Mt(r),ds(r,r.transformState.scale),Dn(r,0)}),r.observer.observe(n),r.observer.observe(p)},this.onWheelZoom=function(n){var p=r.setup.disabled;if(!p){var m=Rg(r,n);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(zg(r,n),Hg(r,n),Wg(r,n))}}},this.onWheelPanning=function(n){var p=r.setup,m=p.disabled,v=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||i.disabled||!i.wheelPanning||n.ctrlKey)){n.preventDefault(),n.stopPropagation();var o=r.transformState,l=o.positionX,u=o.positionY,c=l-n.deltaX,g=u-n.deltaY,_=i.lockAxisX?l:c,y=i.lockAxisY?u:g,x=r.setup.alignmentAnimation,a=x.sizeX,h=x.sizeY,d=ns(r,a),f=ns(r,h);_===l&&y===u||Ml(r,_,y,d,f)}},this.onPanningStart=function(n){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Io(r,n);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(n.button===0&&!r.setup.panning.allowLeftClickPan||n.button===1&&!r.setup.panning.allowMiddleClickPan||n.button===2&&!r.setup.panning.allowRightClickPan||(n.preventDefault(),n.stopPropagation(),Mt(r),zo(r,n),Qe(Ue(r),n,m)))}}},this.onPanning=function(n){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=Bo(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(n.preventDefault(),n.stopPropagation(),Ho(r,n.clientX,n.clientY),Qe(Ue(r),n,m))}}},this.onPanningStop=function(n){var p=r.props.onPanningStop;r.isPanning&&(xg(r),Qe(Ue(r),n,p))},this.onPinchStart=function(n){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,i=m.onZoomStart;if(!p){var o=Lg(r,n);o&&($g(r,n),Mt(r),Qe(Ue(r),n,v),Qe(Ue(r),n,i))}},this.onPinch=function(n){var p=r.setup.disabled,m=r.props,v=m.onPinching,i=m.onZoom;if(!p){var o=Pg(r);o&&(n.preventDefault(),n.stopPropagation(),Ug(r,n),Qe(Ue(r),n,v),Qe(Ue(r),n,i))}},this.onPinchStop=function(n){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(qg(r),Qe(Ue(r),n,m),Qe(Ue(r),n,v))},this.onTouchPanningStart=function(n){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Io(r,n);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&n.touches.length===1;if(!i){r.lastTouch=+new Date,Mt(r);var o=n.touches,l=o.length===1,u=o.length===2;l&&(Mt(r),zo(r,n),Qe(Ue(r),n,m)),u&&r.onPinchStart(n)}}}},this.onTouchPanning=function(n){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&n.touches.length===1){if(p)return;var v=Bo(r);if(!v)return;n.preventDefault(),n.stopPropagation();var i=n.touches[0];Ho(r,i.clientX,i.clientY),Qe(Ue(r),n,m)}else n.touches.length>1&&r.onPinch(n)},this.onTouchPanningStop=function(n){r.onPanningStop(n),r.onPinchStop(n)},this.onDoubleClick=function(n){var p=r.setup.disabled;if(!p){var m=Yg(r,n);m&&Vg(r,n)}},this.clearPanning=function(n){r.isPanning&&r.onPanningStop(n)},this.setKeyPressed=function(n){r.pressedKeys[n.key]=!0},this.setKeyUnPressed=function(n){r.pressedKeys[n.key]=!1},this.isPressingKeys=function(n){return n.length?!!n.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(n,p,m){var v=r.props.onTransformed;if(!Number.isNaN(n)&&!Number.isNaN(p)&&!Number.isNaN(m)){n!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=n),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Ue(r);r.onChangeCallbacks.forEach(function(o){return o(i)}),Qe(i,{scale:n,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var n=Il(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(n.scale,n.positionX,n.positionY)}},this.handleTransformStyles=function(n,p,m){return r.props.customTransform?r.props.customTransform(n,p,m):jg(n,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var n=r.transformState,p=n.scale,m=n.positionX,v=n.positionY,i=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ue(r)},this.onChange=function(n){return r.onChangeCallbacks.has(n)||r.onChangeCallbacks.add(n),function(){r.onChangeCallbacks.delete(n)}},this.onInit=function(n){return r.onInitCallbacks.has(n)||r.onInitCallbacks.add(n),function(){r.onInitCallbacks.delete(n)}},this.init=function(n,p){r.cleanupWindowEvents(),r.wrapperComponent=n,r.contentComponent=p,ds(r,r.transformState.scale),r.handleInitializeWrapperEvents(n),r.handleInitialize(n,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ue(r);Qe(m,void 0,r.props.onInit)},this.props=s,this.setup=$o(this.props),this.transformState=Dl(this.props)}return e})(),ri=le.createContext(null),Qg=function(e,s){return typeof e=="function"?e(s):e},Zg=le.forwardRef(function(e,s){var r=C.useRef(new Gg(e)).current,n=Qg(e.children,Hr(r));return C.useImperativeHandle(s,function(){return Hr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),le.createElement(ri.Provider,{value:r},n)});le.forwardRef(function(e,s){var r=C.useRef(null),n=C.useContext(ri);return C.useEffect(function(){return n.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=n.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[n]),le.createElement("div",rs({},e,{ref:Ng([r,s])}))});function Jg(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&n.firstChild?n.insertBefore(p,n.firstChild):n.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var ev=`.transform-component-module_wrapper__SPB86 {
|
|
39
|
+
`},Oo=lp(hp)(yl),fp={config:dp},mp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function Sl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Sl(e[r],s[r]))}),Do(Do({},e),s)}var pp={type:"cancelation",msg:"operation is manually canceled"};function Ci(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(pp):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var gp=["monaco"],vp=op.create({config:ap,isInitialized:!1,resolve:null,reject:null,monaco:null}),wl=Hm(vp,2),lr=wl[0],ei=wl[1];function xp(e){var s=fp.config(e),r=s.monaco,o=zm(s,gp);ei(function(p){return{config:Sl(p.config,o),monaco:r}})}function _p(){var e=lr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(ei({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ci(ki);if(window.monaco&&window.monaco.editor)return Cl(window.monaco),e.resolve(window.monaco),Ci(ki);mp(bp,Sp)(wp)}return Ci(ki)}function bp(e){return document.body.appendChild(e)}function yp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Sp(e){var s=lr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=yp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function wp(){var e=lr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Cl(o),e.resolve(o)},function(r){e.reject(r)})}function Cl(e){lr().monaco||ei({monaco:e})}function Cp(){return lr(function(e){var s=e.monaco;return s})}var ki=new Promise(function(e,s){return ei({resolve:e,reject:s})}),kl={config:xp,init:_p,__getMonacoInstance:Cp},kp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ei=kp,Ep={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},jp=Ep;function Np({children:e}){return de.createElement("div",{style:jp.container},e)}var Rp=Np,Ap=Rp;function Mp({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return de.createElement("section",{style:{...Ei.wrapper,width:e,height:s},...v},!r&&de.createElement(Ap,null,o),de.createElement("div",{ref:p,style:{...Ei.fullWidth,...!r&&Ei.hide},className:m}))}var Tp=Mp,El=C.memo(Tp);function Dp(e){C.useEffect(e,[])}var jl=Dp;function Lp(e,s,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var St=Lp;function Xs(){}function ks(e,s,r,o){return Pp(e,o)||Op(e,s,r,o)}function Pp(e,s){return e.editor.getModel(Nl(e,s))}function Op(e,s,r,o){return e.editor.createModel(s,r,o?Nl(e,o):void 0)}function Nl(e,s){return e.Uri.parse(s)}function Ip({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:_="100%",className:y,wrapperProps:x={},beforeMount:a=Xs,onMount:h=Xs}){let[d,f]=C.useState(!1),[b,S]=C.useState(!0),k=C.useRef(null),j=C.useRef(null),w=C.useRef(null),E=C.useRef(h),R=C.useRef(a),P=C.useRef(!1);jl(()=>{let D=kl.init();return D.then(F=>(j.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?B():D.cancel()}),St(()=>{if(k.current&&j.current){let D=k.current.getOriginalEditor(),F=ks(j.current,e||"",o||r||"text",m||"");F!==D.getModel()&&D.setModel(F)}},[m],d),St(()=>{if(k.current&&j.current){let D=k.current.getModifiedEditor(),F=ks(j.current,s||"",p||r||"text",v||"");F!==D.getModel()&&D.setModel(F)}},[v],d),St(()=>{let D=k.current.getModifiedEditor();D.getOption(j.current.editor.EditorOption.readOnly)?D.setValue(s||""):s!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[s],d),St(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),St(()=>{let{original:D,modified:F}=k.current.getModel();j.current.editor.setModelLanguage(D,o||r||"text"),j.current.editor.setModelLanguage(F,p||r||"text")},[r,o,p],d),St(()=>{j.current?.editor.setTheme(l)},[l],d),St(()=>{k.current?.updateOptions(c)},[c],d);let M=C.useCallback(()=>{if(!j.current)return;R.current(j.current);let D=ks(j.current,e||"",o||r||"text",m||""),F=ks(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:D,modified:F})},[r,s,p,e,o,m,v]),T=C.useCallback(()=>{!P.current&&w.current&&(k.current=j.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...c}),M(),j.current?.editor.setTheme(l),f(!0),P.current=!0)},[c,l,M]);C.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),C.useEffect(()=>{!b&&!d&&T()},[b,d,T]);function B(){let D=k.current?.getModel();i||D?.original?.dispose(),n||D?.modified?.dispose(),k.current?.dispose()}return de.createElement(El,{width:_,height:g,isEditorReady:d,loading:u,_ref:w,className:y,wrapperProps:x})}var Bp=Ip;C.memo(Bp);function Fp(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var zp=Fp,br=new Map;function Wp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:i,loading:n="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:_="100%",height:y="100%",className:x,wrapperProps:a={},beforeMount:h=Xs,onMount:d=Xs,onChange:f,onValidate:b=Xs}){let[S,k]=C.useState(!1),[j,w]=C.useState(!0),E=C.useRef(null),R=C.useRef(null),P=C.useRef(null),M=C.useRef(d),T=C.useRef(h),B=C.useRef(),D=C.useRef(o),F=zp(m),H=C.useRef(!1),A=C.useRef(!1);jl(()=>{let I=kl.init();return I.then($=>(E.current=$)&&w(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?L():I.cancel()}),St(()=>{let I=ks(E.current,e||o||"",s||p||"",m||r||"");I!==R.current?.getModel()&&(c&&br.set(F,R.current?.saveViewState()),R.current?.setModel(I),c&&R.current?.restoreViewState(br.get(m)))},[m],S),St(()=>{R.current?.updateOptions(l)},[l],S),St(()=>{!R.current||o===void 0||(R.current.getOption(E.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],S),St(()=>{let I=R.current?.getModel();I&&p&&E.current?.editor.setModelLanguage(I,p)},[p],S),St(()=>{i!==void 0&&R.current?.revealLine(i)},[i],S),St(()=>{E.current?.editor.setTheme(v)},[v],S);let O=C.useCallback(()=>{if(!(!P.current||!E.current)&&!H.current){T.current(E.current);let I=m||r,$=ks(E.current,o||e||"",s||p||"",I||"");R.current=E.current?.editor.create(P.current,{model:$,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(br.get(I)),E.current.editor.setTheme(v),i!==void 0&&R.current.revealLine(i),k(!0),H.current=!0}},[e,s,r,o,p,m,l,u,c,v,i]);C.useEffect(()=>{S&&M.current(R.current,E.current)},[S]),C.useEffect(()=>{!j&&!S&&O()},[j,S,O]),D.current=o,C.useEffect(()=>{S&&f&&(B.current?.dispose(),B.current=R.current?.onDidChangeModelContent(I=>{A.current||f(R.current.getValue(),I)}))},[S,f]),C.useEffect(()=>{if(S){let I=E.current.editor.onDidChangeMarkers($=>{let V=R.current.getModel()?.uri;if(V&&$.find(U=>U.path===V.path)){let U=E.current.editor.getModelMarkers({resource:V});b?.(U)}});return()=>{I?.dispose()}}return()=>{}},[S,b]);function L(){B.current?.dispose(),g?c&&br.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return de.createElement(El,{width:_,height:y,isEditorReady:S,loading:n,_ref:P,className:x,wrapperProps:a})}var Hp=Wp,$p=C.memo(Hp),Up=$p,jt=function(e,s){return Number(e.toFixed(s))},qp=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Kp=function(e){return-Math.cos(e*Math.PI)/2+.5},Xp=function(e){return e},Vp=function(e){return e*e},Yp=function(e){return e*(2-e)},Gp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Qp=function(e){return e*e*e},Zp=function(e){return--e*e*e+1},Jp=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},eg=function(e){return e*e*e*e},tg=function(e){return 1- --e*e*e*e},sg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},rg=function(e){return e*e*e*e*e},ig=function(e){return 1+--e*e*e*e*e},ng=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Rl={easeOut:Kp,linear:Xp,easeInQuad:Vp,easeOutQuad:Yp,easeInOutQuad:Gp,easeInCubic:Qp,easeOutCubic:Zp,easeInOutCubic:Jp,easeInQuart:eg,easeOutQuart:tg,easeInOutQuart:sg,easeInQuint:rg,easeOutQuint:ig,easeInOutQuint:ng},Al=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Mt=function(e){e.mounted&&(Al(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Ml(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;Mt(e),e.animation=function(){if(!e.mounted)return Al(e.animation);var v=new Date().getTime()-p,i=v/r,n=Rl[s],l=n(i);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function og(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function os(e,s,r,o){var p=og(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY,u=s.scale-i,c=s.positionX-n,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):Ml(e,o,r,function(_){var y=i+u*_,x=n+c*_,a=l+g*_;m(y,x,a)})}}function ag(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,i=m*r,n=v*r,l=o-i,u=p-n;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:i,newDiffWidth:l,newContentHeight:n,newDiffHeight:u}}var lg=function(e,s,r,o,p,m,v){var i=e>s?r*(v?1:.5):0,n=o>p?m*(v?1:.5):0,l=e-s-i,u=i,c=o-p-n,g=n;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Tn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=ag(r,o,s),v=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=lg(v,n,l,i,u,c,!!p);return g},Xi=function(e,s,r,o){return o?e<s?jt(s,2):e>r?jt(r,2):jt(e,2):jt(e,2)},ds=function(e,s){var r=Tn(e,s);return e.bounds=r,r};function cr(e,s,r,o,p,m,v){var i=r.minPositionX,n=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var _=Xi(e,i-c,l+c,o),y=Xi(s,n-g,u+g,o);return{x:_,y}}function ti(e,s,r,o,p,m){var v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY,u=o-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:l};var c=n-s*u,g=l-r*u,_=cr(c,g,p,m,0,0,null);return _}function dr(e,s,r,o,p){var m=p?o:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Io=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,i=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),n=o&&m&&i;if(!n)return!1;var l=si(m,r);return!l},Bo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},cg=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-o,y:v-p}},dg=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function ug(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,v=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,_=u.maxPositionY,y=u.minPositionY,x=r>c||r<g,a=o>_||o<y,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>_?l.offsetHeight:e.setup.minPositionY||0,f=ti(e,h,d,p,e.bounds,i||n),b=f.x,S=f.y;return{scale:p,positionX:x?b:r,positionY:a?S:o}}}function Tl(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,n=e.transformState,l=n.scale,u=n.positionX,c=n.positionY;if(!(v===null||i===null||s===u&&r===c)){var g=cr(s,r,i,m,o,p,v),_=g.x,y=g.y;e.setTransformState(l,_,y)}}var hg=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,i=m.lockAxisY,n=p.positionX,l=p.positionY;if(!o)return{x:n,y:l};var u=s-o.x,c=r-o.y,g=v?n:u,_=i?l:c;return{x:g,y:_}},ns=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},fg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,i=!v||m>1||!o||s;return!!i},mg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,i=e.transformState.scale,n=v.disabled,l=!n||i>1||!m||s;return!(!l||!r||!o)};function pg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function Fo(e,s,r,o,p,m,v,i,n,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>n?n:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<i?i:u>m?m:u}}return o?s:Xi(e,m,v,p)}function gg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function vg(e,s){var r=fg(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(o&&p&&v){var l=gg(v,i),u=s.x-o.x,c=s.y-o.y,g=u/l,_=c/l,y=n-p,x=u*u+c*c,a=Math.sqrt(x)/y;e.velocity={velocityX:g,velocityY:_,total:a}}e.lastMousePosition=s,e.velocityTime=n}}function xg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=mg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,i=s.velocityY,n=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,_=o.limitToBounds,y=o.alignmentAnimation,x=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=x.animationType,b=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,j=k,w=pg(e,n),E=Math.max(w,j),R=ns(e,b),P=ns(e,S),M=R*p.offsetWidth/100,T=P*p.offsetHeight/100,B=l+M,D=u-M,F=c+T,H=g-T,A=e.transformState,O=new Date().getTime();Ml(e,f,E,function(L){var I=e.transformState,$=I.scale,V=I.positionX,U=I.positionY,W=new Date().getTime()-O,q=W/j,N=Rl[y.animationType],z=1-N(Math.min(1,q)),X=1-L,K=V+v*X,re=U+i*X,Z=Fo(K,A.positionX,V,d,_,u,l,D,B,z),se=Fo(re,A.positionY,U,h,_,g,c,H,F,z);(V!==K||U!==re)&&e.setTransformState($,Z,se)})}}function zo(e,s){var r=e.transformState.scale;Mt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?dg(e,s):cg(e,s)}function Dn(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,v=m.disabled,i=m.sizeX,n=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!i&&!n;if(!c){var g=ug(e);g&&os(e,g,s??l,u)}}function Wo(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(o){var n=hg(e,s,r),l=n.x,u=n.y,c=ns(e,v),g=ns(e,i);vg(e,{x:l,y:u}),Tl(e,l,u,c,g)}}function _g(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),v=p?.getBoundingClientRect(),i=m?.width||0,n=m?.height||0,l=v?.width||0,u=v?.height||0,c=i<l||n<u,g=!s&&r&&r?.total>.1&&c;g?xg(e):Dn(e)}}function Ln(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,n=dr(jt(s,2),m,v,0,!1),l=ds(e,n),u=ti(e,r,o,n,l,i),c=u.x,g=u.y;return{scale:n,positionX:c,positionY:g}}function Dl(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,l=n.disabled,u=n.animationTime,c=n.animationType,g=l||o>=v;if((o>=1||i)&&Dn(e),!(g||!p||!e.mounted)){var _=s||p.offsetWidth/2,y=r||p.offsetHeight/2,x=Ln(e,v,_,y);x&&os(e,x,u,c)}}var rs=function(){return rs=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},rs.apply(this,arguments)};function Ho(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var yr={scale:1,positionX:0,positionY:0},Ws={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}},Vi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ll=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:yr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:yr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:yr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:yr.positionY}},$o=function(e){var s=rs({},Ws);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof Ws[r]<"u";if(p&&o){var m=Object.prototype.toString.call(Ws[r]),v=m==="[object Object]",i=m==="[object Array]";v?s[r]=rs(rs({},Ws[r]),e[r]):i?s[r]=Ho(Ho([],Ws[r],!0),e[r]):s[r]=e[r]}}),s},Pl=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,i=m.minScale,n=m.zoomAnimation,l=m.smooth,u=n.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,g=dr(jt(c,3),i,v,u,!1);return g};function Ol(e,s,r,o,p){var m=e.wrapperComponent,v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-n)/i,_=(c/2-l)/i,y=Pl(e,s,r),x=Ln(e,y,g,_);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");os(e,x,o,p)}function Il(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Ll(e.props),n=e.transformState,l=n.scale,u=n.positionX,c=n.positionY;if(m){var g=Tn(e,i.scale),_=cr(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:_.x,positionY:_.y};l===i.scale&&u===i.positionX&&c===i.positionY||(o?.(),os(e,y,s,r))}}function bg(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),i=m.x*o.scale,n=m.y*o.scale;return{x:(p.x-v.x+i)/o.scale,y:(p.y-v.y+n)/o.scale}}function yg(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,i=v.limitToBounds,n=v.minScale,l=v.maxScale;if(!o||!p)return m;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=bg(s,o,p,m),_=g.x,y=g.y,x=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/x,d=o.offsetHeight/a,f=dr(r||Math.min(h,d),n,l,0,!1),b=(u.width-x*f)/2,S=(u.height-a*f)/2,k=(u.left-_)*f+b,j=(u.top-y)*f+S,w=Tn(e,f),E=cr(k,j,w,i,0,0,o),R=E.x,P=E.y;return{positionX:R,positionY:P,scale:f}}var Sg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Ol(e,1,s,r,o)}},wg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Ol(e,-1,s,r,o)}},Cg=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,i=v.positionX,n=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var _={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?l:o};os(e,_,p,m)}}},kg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Il(e,s,r)}},Eg=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var i=Bl(s||p.scale,m,v);os(e,i,r,o)}}},jg=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Mt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=yg(e,v,r);os(e,i,o,p)}}},zr=function(e){return{instance:e,zoomIn:Sg(e),zoomOut:wg(e),setTransform:Cg(e),resetTransform:kg(e),centerView:Eg(e),zoomToElement:jg(e)}},Yi=function(e){return{instance:e,state:e.transformState}},Ke=function(e){var s={};return Object.assign(s,Yi(e)),Object.assign(s,zr(e)),s},ji=!1;function Ni(){try{var e={get passive(){return ji=!0,!1}};return e}catch{return ji=!1,ji}}var Sr=".".concat(Vi.wrapperClass),si=function(e,s){return s.some(function(r){return e.matches("".concat(Sr," ").concat(r,", ").concat(Sr," .").concat(r,", ").concat(Sr," ").concat(r," *, ").concat(Sr," .").concat(r," *"))})},Gi=function(e){e&&clearTimeout(e)},Ng=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Bl=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function Rg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Ag=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,n=e.isPanning,l=s.target,u=i&&!n&&!o&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=si(l,v);return!c},Mg=function(e){return e?e.deltaY<0?1:-1:0};function Tg(e,s){var r=Mg(e),o=qp(s,r);return o}function Fl(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var v=e.touches[0];p=(v.clientX-o.left)/r,m=(v.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var Dg=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,i=e.setup,n=i.maxScale,l=i.minScale,u=i.zoomAnimation,c=i.disablePadding,g=u.size,_=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,x=o?!1:!_,a=dr(jt(y,3),l,n,g,x&&!c);return a},Lg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?o<m||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Pg=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,i=m&&!o&&v;if(!i)return!1;var n=si(v,p);return!n},Og=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Ig=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=jt(p[0].clientX-o.left,5),v=jt(p[0].clientY-o.top,5),i=jt(p[1].clientX-o.left,5),n=jt(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(v+n)/2/s}},zl=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))},Bg=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,i=p.zoomAnimation,n=p.disablePadding,l=i.size,u=i.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return dr(jt(g,2),v,m,l,!u&&!n)},Fg=160,zg=100,Wg=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Mt(e),Qe(Ke(e),s,o),Qe(Ke(e),s,p))},Hg=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,i=e.transformState,n=i.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,_=v.disablePadding,y=v.smooth,x=c.size,a=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Tg(s,null),b=y?d*Math.abs(s.deltaY):h,S=Dg(e,f,b,!s.ctrlKey);if(n!==S){var k=ds(e,S),j=Fl(s,m,n),w=a||x===0||u||_,E=l&&w,R=ti(e,j.x,j.y,S,k,E),P=R.x,M=R.y;e.previousWheelEvent=s,e.setTransformState(S,P,M),Qe(Ke(e),s,o),Qe(Ke(e),s,p)}},$g=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;Gi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Dl(e,s.x,s.y),e.wheelAnimationTimer=null)},zg);var m=Lg(e,s);m&&(Gi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(Ke(e),s,o),Qe(Ke(e),s,p))},Fg))},Wl=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},Ug=function(e,s){var r=zl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Wl(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Mt(e)},qg=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,i=v.limitToBounds,n=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(o===null||!r)){var _=Ig(s,m,r);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var y=zl(s),x=Bg(e,y),a=Wl(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ds(e,x),b=c||g===0||n,S=i&&b,k=ti(e,_.x,_.y,x,f,S),j=k.x,w=k.y;e.pinchMidpoint=_,e.lastDistance=y;var E=u.sizeX,R=u.sizeY,P=ns(e,E),M=ns(e,R),T=j+h,B=w+d,D=cr(T,B,f,i,P,M,p),F=D.x,H=D.y;e.setTransformState(x,F,H)}}}},Kg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Dl(e,s?.x,s?.y)},Hl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;Gi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(Ke(e),s,r)},o)},Xg=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Qe(Ke(e),s,o),Il(e,v,i,function(){return Qe(Ke(e),s,p)}),Hl(e,s)};function Vg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Yg(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,i=e.props,n=i.onZoomStart,l=i.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,_=u.step,y=u.animationTime,x=u.animationType;if(!c&&!o){if(g==="reset")return Xg(e,s);if(!m)return console.error("No ContentComponent found");var a=Vg(g,e.transformState.scale),h=Pl(e,a,_);if(v!==h){Qe(Ke(e),s,n);var d=Fl(s,m,v),f=Ln(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ke(e),s,l),os(e,f,y,x),Hl(e,s)}}}var Gg=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,v=m.disabled,i=m.excluded,n=s.target,l=p?.contains(n),u=r&&n&&l&&!v;if(!u)return!1;var c=si(n,i);return!c},Qg=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ds(r,r.transformState.scale),r.setup=$o(o)},this.initializeWindowEvents=function(){var o,p,m=Ni(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=Ni(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Mt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Ni();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,v=r.setup.centerOnInit,i=function(n,l){for(var u=0,c=n;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Ke(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Mt(r),ds(r,r.transformState.scale),Dn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=Ag(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Wg(r,o),Hg(r,o),$g(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,v=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,l=n.positionX,u=n.positionY,c=l-o.deltaX,g=u-o.deltaY,_=i.lockAxisX?l:c,y=i.lockAxisY?u:g,x=r.setup.alignmentAnimation,a=x.sizeX,h=x.sizeY,d=ns(r,a),f=ns(r,h);_===l&&y===u||Tl(r,_,y,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Io(r,o);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),Mt(r),zo(r,o),Qe(Ke(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=Bo(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),Wo(r,o.clientX,o.clientY),Qe(Ke(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(_g(r),Qe(Ke(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=Pg(r,o);n&&(Ug(r,o),Mt(r),Qe(Ke(r),o,v),Qe(Ke(r),o,i))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinching,i=m.onZoom;if(!p){var n=Og(r);n&&(o.preventDefault(),o.stopPropagation(),qg(r,o),Qe(Ke(r),o,v),Qe(Ke(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(Kg(r),Qe(Ke(r),o,m),Qe(Ke(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Io(r,o);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,Mt(r);var n=o.touches,l=n.length===1,u=n.length===2;l&&(Mt(r),zo(r,o),Qe(Ke(r),o,m)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var v=Bo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];Wo(r,i.clientX,i.clientY),Qe(Ke(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=Gg(r,o);m&&Yg(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Ke(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Qe(i,{scale:o,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Bl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):Ng(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,v=o.positionY,i=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ke(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,ds(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ke(r);Qe(m,void 0,r.props.onInit)},this.props=s,this.setup=$o(this.props),this.transformState=Ll(this.props)}return e})(),ri=de.createContext(null),Zg=function(e,s){return typeof e=="function"?e(s):e},Jg=de.forwardRef(function(e,s){var r=C.useRef(new Qg(e)).current,o=Zg(e.children,zr(r));return C.useImperativeHandle(s,function(){return zr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),de.createElement(ri.Provider,{value:r},o)});de.forwardRef(function(e,s){var r=C.useRef(null),o=C.useContext(ri);return C.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=o.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[o]),de.createElement("div",rs({},e,{ref:Rg([r,s])}))});function ev(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var tv=`.transform-component-module_wrapper__SPB86 {
|
|
40
40
|
position: relative;
|
|
41
41
|
width: -moz-fit-content;
|
|
42
42
|
width: fit-content;
|
|
@@ -67,23 +67,23 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
67
67
|
.transform-component-module_content__FBWxo img {
|
|
68
68
|
pointer-events: none;
|
|
69
69
|
}
|
|
70
|
-
`,Uo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Jg(ev);var tv=function(e){var s=e.children,r=e.wrapperClass,n=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,i=e.contentStyle,o=e.wrapperProps,l=o===void 0?{}:o,u=e.contentProps,c=u===void 0?{}:u,g=C.useContext(ri),_=g.init,y=g.cleanupWindowEvents,x=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=x.current,d=a.current;return h!==null&&d!==null&&_&&_?.(h,d),function(){y?.()}},[]),le.createElement("div",rs({},l,{ref:x,className:"".concat(Vi.wrapperClass," ").concat(Uo.wrapper," ").concat(n),style:v}),le.createElement("div",rs({},c,{ref:a,className:"".concat(Vi.contentClass," ").concat(Uo.content," ").concat(m),style:i}),s))},Wl=function(){var e=C.useContext(ri);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},sv=function(){var e=Wl();return Hr(e)};function rv(e){var s=Wl(),r=C.useState(e(Yi(s))),n=r[0],p=r[1];return C.useEffect(function(){var m=!0,v=s.onChange(function(i){m&&p(e(Yi(i.instance)))});return function(){v(),m=!1}},[e,s]),n}function iv(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 nv(e,s){return Rt({queryKey:ie.files.tree(e||"",s),queryFn:()=>he.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function ov(e,s){return Rt({queryKey:ie.files.content(e||"",s||""),queryFn:()=>he.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function av(e){const s=ot();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function lv(){const e=ot();return _t({mutationFn:s=>he.post("/files/write",s),onSuccess:(s,r)=>{const n=ie.files.content(r.workingDir,r.path),p=e.getQueryData(n);e.setQueryData(n,{content:r.content,language:p?.language||iv(r.path)})}})}function cv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function dv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const uv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function hv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&uv.has(s)?Na:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Tr:s==="json"?Hd:s==="md"||s==="mdx"||s==="txt"?Ea:xd}const qo=({depth:e,active:s,onClick:r,leftIcon:n,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:ee("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:n}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),$l=({workingDir:e,path:s,depth:r,expanded:n,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ce(),{data:o,isLoading:l,isError:u}=nv(e,s),c=C.useMemo(()=>o?.items??[],[o?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=cv(s,g.name),d=n.has(h);return t.jsxs("div",{children:[t.jsx(qo,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(xt,{size:14,className:"text-neutral-400"}):t.jsx(Nt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(Xr,{size:14,className:"text-amber-500"}):t.jsx(La,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx($l,{workingDir:e,path:h,depth:r+1,expanded:n,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const _=dv(s,g.name),y=hv(g),x=v===_,a=y===Na;return t.jsx(qo,{depth:r,active:x,onClick:()=>m(_),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},_)})})},fv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:n,onCollapse:p})=>{const{t:m}=ce(),[v,i]=C.useState(()=>new Set),o=av(e),l=C.useCallback(u=>{i(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:ee("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(ir,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(tu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx($l,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:n}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},mv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function pv(e){const s=e.split(".").pop()?.toLowerCase();return s?mv.has(s):!1}function gv(e,s){const r="/api",n=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${n.toString()}`}const vv=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:n,centerView:p}=sv(),m=rv(i=>i.state.scale),v=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>n(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(_u,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(vu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Jd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},xv=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[n,p]=C.useState(!1),m=gv(e,s);return n?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Zg,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(vv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(tv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function _v(e){const s=e.split("/");return s[s.length-1]||e}function bv(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 yv=({active:e,name:s,isDirty:r,onClick:n,onClose:p})=>{const{t:m}=ce();return t.jsxs("button",{type:"button",onClick:n,className:ee("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:ee("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(is,{size:12})})]})},Sv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:n}=ce(),[p,m]=C.useState([]),[v,i]=C.useState(null),o=lv(),[l,u]=C.useState(280),[c,g]=C.useState(!1),[_,y]=C.useState(!1),x=C.useRef(280),a=C.useCallback(()=>{g(T=>(T?u(x.current):x.current=l,!T))},[l]),h=C.useCallback(T=>{T.preventDefault(),y(!0);const B=T.clientX,D=l,F=A=>{const O=A.clientX-B,L=Math.min(480,Math.max(160,D+O));u(L)},$=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",$)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",$)},[l]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(T=>T.path===v)||null,[p,v]),{data:f,isFetching:b,isError:S,error:k}=ov(e,d?.isImage?null:v);C.useEffect(()=>{!v||!f||m(T=>T.map(B=>B.path!==v||B.isDirty||B.loaded?B:{...B,language:f.language||B.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[v,f]);const j=C.useCallback(T=>{m(B=>{if(B.find($=>$.path===T))return B;const F=pv(T);return[...B,{path:T,name:_v(T),language:bv(T),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(T)},[]),w=C.useCallback(T=>{m(B=>{const D=B.filter(F=>F.path!==T);return i(F=>F!==T?F:D.length?D[D.length-1].path:null),D})},[]),E=C.useCallback(T=>{m(B=>B.map(D=>{if(D.path!==v)return D;const F=T!==D.savedContent;return{...D,content:T,isDirty:F}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await o.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(T=>T.map(B=>B.path===d.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[d,r,o,e]),P=C.useRef(()=>{});C.useEffect(()=>{P.current=()=>{R().catch(()=>{})}},[R]),C.useEffect(()=>{const T=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),P.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[r]);const M=C.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{P.current()})},[]);return t.jsxs("div",{className:ee("flex h-full overflow-hidden bg-white",s),style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:c?36:l,transition:_?"none":"width 0.15s ease"},children:c?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:n("Expand file tree"),children:t.jsx(ru,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(fv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[p.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:n("No open files")}):p.map(T=>t.jsx(yv,{active:T.path===v,name:T.name,isDirty:T.isDirty,onClick:()=>i(T.path),onClose:B=>{B.stopPropagation(),w(T.path)}},T.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:n("Read-only")}),o.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),n("Saving")]}),d?.isDirty&&!o.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:n("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(xv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx($p,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:T=>E(T??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!d.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),n("Loading file...")]})}),S&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[n("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:n("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:n("No workspace selected.")})})]})]})};function ii(e,s={}){return Rt({queryKey:ie.git.changes(e||""),queryFn:()=>he.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Ul(e,s,r){return Rt({queryKey:ie.git.diff(e||"",s||"",r),queryFn:()=>he.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Pn(e,s){return Rt({queryKey:ie.git.commitFiles(e||"",s||""),queryFn:()=>he.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function On(e,s,r){return Rt({queryKey:ie.git.commitDiff(e||"",s||"",r||""),queryFn:()=>he.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function ql({isOpen:e,onClose:s,branchName:r,targetBranch:n,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:o}=ce(),[l,u]=C.useState(""),[c,g]=C.useState(!1);C.useEffect(()=>{e&&(g(!1),u(p??""))},[e]),C.useEffect(()=>{c||!e||u(p??"")},[p,c,e]);const _=()=>{m||s()};return t.jsx(Ms,{isOpen:e,onClose:_,title:o("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:_,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:o("取消")}),t.jsx("button",{onClick:()=>i(l.trim()||void 0),disabled:m,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:14,className:"animate-spin"}),o("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Mr,{size:14}),o("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Md,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:n})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:o("提交消息")}),t.jsx("textarea",{value:l,onChange:y=>{g(!0),u(y.target.value)},placeholder:o("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:o("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:o("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function ys(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Kl(e){if(!(e instanceof pa)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Vs.REBASE&&s.conflictOp!==Vs.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(n=>typeof n=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:ys(s,"sourceBranch"),targetBranch:ys(s,"targetBranch"),sourceWorktreePath:ys(s,"sourceWorktreePath"),targetWorktreePath:ys(s,"targetWorktreePath"),sourceWorkspaceId:ys(s,"sourceWorkspaceId"),targetWorkspaceId:ys(s,"targetWorkspaceId")}}function Ko(e,s,r,n){const p=Kl(e);if(p){r(p);return}n(e instanceof Error?e.message:s)}function Xl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:n,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:i}){const{t:o}=ce(),{data:l,isLoading:u}=En(e),c=al(),g=ol(),_=jn(),[y,x]=C.useState(!1),[a,h]=C.useState(null);if(C.useEffect(()=>{y&&m?.()},[y,m]),u||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("正在检查工作区状态...")})]});const d=l.conflictedFiles.length>0,f=l.operation!=="idle",b=l.hasUncommittedChanges||l.untrackedCount>0,S=l.uncommittedCount+l.untrackedCount,k=!d&&!f&&!b,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!b&&!d,w=()=>{h(null),c.mutate(e,{onError:M=>{Ko(M,o("更新失败,请稍后重试"),T=>v(T),h)}})},E=()=>{h(null),x(!0)},R=M=>{h(null),g.mutate({id:e,commitMessage:M},{onSuccess:()=>x(!1),onError:T=>{Ko(T,o("提交失败,请稍后重试"),B=>{x(!1),v(B)},h)}})},P=()=>{g.isPending||(x(!1),h(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Yd,{size:13}),t.jsx("span",{className:"text-xs",children:o("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),b&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Ud,{size:12,className:"shrink-0"}),t.jsx("span",{children:o("{count} 个本地改动未处理,需要先整理后再继续",{count:S})})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(tr,{size:13,className:"shrink-0"}),t.jsx("span",{children:o("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:o("处理冲突")}),t.jsx("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:_.isPending?o("正在撤销..."):o("撤销操作")})]})]}),f&&!d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Xe,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?o("正在同步源分支更新..."):o("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Cd,{size:12}),_.isPending?o("正在撤销..."):o("撤销操作")]})]}),!d&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:o("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:w,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ir,{size:12}),c.isPending?o("正在同步..."):o("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:o("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!b?t.jsxs("button",{onClick:E,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Mr,{size:12}),o("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:o(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Mr,{size:12}),o("提交变更")]})]})]})]})}),t.jsx(ql,{isOpen:y,onClose:P,branchName:s,targetBranch:r,commitMessage:n,isPending:g.isPending,error:a,onConfirm:R})]})}const Ri=50,Ai=400,Xo={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"},Vo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Vl(e){const s=e.split("/");return s[s.length-1]||e}function wv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Cv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?ft("{count}s ago",{count:r}):r<3600?ft("{count}m ago",{count:Math.floor(r/60)}):r<86400?ft("{count}h ago",{count:Math.floor(r/3600)}):r<604800?ft("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function jr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Qi=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:ee("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),kv=({line:e,lineNum:s})=>{let r="",n="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",n="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(n="text-muted-foreground/70"),t.jsxs("div",{className:ee("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:ee("pl-2 whitespace-pre",n),children:e})]})},Yl=({diff:e})=>{const{t:s}=ce(),[r,n]=C.useState(!1),p=C.useMemo(()=>e.split(`
|
|
71
|
-
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Ai,v=m?p.slice(0,Ai):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((i,o)=>t.jsx(kv,{line:i,lineNum:o+1},o)),m&&t.jsx("button",{type:"button",onClick:()=>n(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Ai})})]})},Ev=({workingDir:e,path:s,diffType:r,enabled:n})=>{const{t:p}=ce(),{data:m,isLoading:v,isError:i}=Ul(e,n?s:null,r);return!n||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Xe,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Yl,{diff:m?.diff||""})},jv=({workingDir:e,hash:s,path:r,enabled:n})=>{const{t:p}=ce(),{data:m,isLoading:v,isError:i}=On(e,n?s:null,n?r:null);return!n||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Xe,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Yl,{diff:m?.diff||""})},Mi=({entry:e,source:s,workingDir:r,flash:n,registerNode:p})=>{const[m,v]=C.useState(!1),[i,o]=C.useState(!1),l=C.useRef(null),u=jr(s,e.path);C.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),C.useEffect(()=>{const _=l.current;if(!_||i)return;const y=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(o(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(_),()=>y.disconnect()},[i]);const c=Xo[e.status]||Xo.M,g=wv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:ee("rounded-md border border-border bg-background overflow-hidden transition-shadow",n&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(_=>!_),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Nt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(xt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:ee("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Vl(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Qi,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Ev,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(jv,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function Nv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const n=r.path.split("/");let p=s;for(let m=0;m<n.length-1;m++){const v=n[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return Gl(s)}function Gl(e){const s=new Map;for(const r of e.dirs.values()){let n=Gl(r);for(;n.dirs.size===1&&n.files.length===0;){const p=[...n.dirs.values()][0];n={...p,name:`${n.name}/${p.name}`}}s.set(n.name,n)}return{...e,dirs:s}}const Rv=({dir:e,depth:s,activeKey:r,onSelect:n})=>{const[p,m]=C.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(Xr,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(La,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Ql,{node:e,depth:s+1,activeKey:r,onSelect:n})]})},Ql=({node:e,depth:s,activeKey:r,onSelect:n})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(Rv,{dir:p,depth:s,activeKey:r,onSelect:n},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>n(p),className:ee("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:ee("w-1.5 h-1.5 rounded-full shrink-0",Vo[p.status]||Vo.M)}),t.jsx("span",{className:ee("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Vl(p.path)})]},p.cardKey)})]}),Av=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:n}=ce(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:o}=mn({queryKey:ie.git.log(e),queryFn:({pageParam:u=0})=>he.get("/git/log",{params:{workingDir:e,limit:String(Ri),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Ri?void 0:c.length*Ri}),l=p?.pages.flatMap(u=>u.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Xe,{size:11,className:"animate-spin"}),t.jsx("span",{children:n("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:n("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:ee("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:ee("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:ee("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",Cv(u.timestamp)]})]})]},u.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:o,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:11,className:"animate-spin"})," ",n("正在加载...")]}):n("加载更多提交")})]})},Mv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:n,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:o})=>{const{t:l}=ce(),[u,c]=C.useState({kind:"overview"}),[g,_]=C.useState(""),[y,x]=C.useState(null),[a,h]=C.useState(null),{data:d,isLoading:f,isError:b}=ii(e),S=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=Pn(e,S),w=C.useRef(new Map),E=C.useRef(null),R=C.useRef(null),P=C.useCallback((q,W)=>{W?w.current.set(q,W):w.current.delete(q)},[]),{uncommitted:M,committed:T,commitFiles:B}=C.useMemo(()=>{const q=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},z=(k?.files||[]).filter(q).map(V=>({...V,cardKey:jr(N,V.path)}));return{uncommitted:[],committed:[],commitFiles:z}}const W=(d?.uncommitted||[]).filter(q).map(N=>({...N,cardKey:jr({kind:"working",diffType:"uncommitted"},N.path)})),K=(d?.committed||[]).filter(q).map(N=>({...N,cardKey:jr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:W,committed:K,commitFiles:[]}},[u,d,k,g]),D=u.kind==="commit"?B:[...M,...T],F=C.useMemo(()=>Nv(D),[D]),$=C.useMemo(()=>{let q=0,W=0;for(const K of D)q+=K.additions??0,W+=K.deletions??0;return{additions:q,deletions:W,files:D.length}},[D]),A=C.useCallback(()=>{const q=E.current;if(!q)return;const W=q.getBoundingClientRect().top;let K=null,N=Number.NEGATIVE_INFINITY;for(const[z,V]of w.current){const X=V.getBoundingClientRect().top-W;X<=48&&X>N&&(N=X,K=z)}if(!K){let z=null,V=Number.POSITIVE_INFINITY;for(const[X,re]of w.current){const J=re.getBoundingClientRect().top-W;J<V&&(V=J,z=X)}K=z}x(K)},[]);C.useEffect(()=>{const q=E.current;if(!q)return;let W=0;const K=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(A)};return q.addEventListener("scroll",K,{passive:!0}),()=>{q.removeEventListener("scroll",K),cancelAnimationFrame(W)}},[A]);const O=C.useCallback(q=>{const W=w.current.get(q.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),x(q.cardKey),h(q.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),L=C.useCallback(q=>{c(W=>W.kind==="commit"&&W.commit.hash===q.hash?{kind:"overview"}:{kind:"commit",commit:q}),_(""),x(null),E.current?.scrollTo({top:0})},[]),I=C.useCallback(()=>{c({kind:"overview"}),_(""),x(null),E.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const U=m&&s&&r&&n,Y=u.kind==="commit"?j:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[U&&i&&o&&t.jsx(Xl,{workspaceId:s,branchName:r,targetBranch:n,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:o}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:$.files})}),t.jsx(Qi,{additions:$.additions,deletions:$.deletions}),r&&n&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Gs,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:n})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Gs,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(Qi,{className:"ml-auto",additions:$.additions,deletions:$.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:Y?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(q=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},q))}):b&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):D.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Tr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(q=>t.jsx(Mi,{entry:q,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===q.cardKey,registerNode:P},q.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[M.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(q=>t.jsx(Mi,{entry:q,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===q.cardKey,registerNode:P},q.cardKey))})]}),T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(q=>t.jsx(Mi,{entry:q,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===q.cardKey,registerNode:P},q.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(rn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:q=>_(q.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:D.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(Ql,{node:F,depth:0,activeKey:y,onSelect:O})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(As,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Av,{workingDir:e,selectedHash:S,onSelectCommit:L})})]})]})]})]})},Ti=50,Yo={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 Tv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?ft("{count}s ago",{count:r}):r<3600?ft("{count}m ago",{count:Math.floor(r/60)}):r<86400?ft("{count}h ago",{count:Math.floor(r/3600)}):r<604800?ft("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Dv(e){const s=e.split("/");return s[s.length-1]||e}function Lv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Pv=({line:e,lineNum:s})=>{let r="",n="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",n="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(n="text-muted-foreground/70"),t.jsxs("div",{className:ee("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:ee("pl-2 whitespace-pre",n),children:e})]})},Ov=({workingDir:e,hash:s,filePath:r})=>{const{t:n}=ce(),{data:p,isLoading:m,isError:v}=On(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:n("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:n("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:n("No diff content available.")});const o=i.split(`
|
|
72
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((l,u)=>t.jsx(Pv,{line:l,lineNum:u+1},u))})},Iv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:n})=>{const{t:p}=ce(),{data:m,isLoading:v}=Pn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Xe,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(o=>{const l=Yo[o.status]||Yo.M,u=Lv(o.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),n(o.path)},className:ee("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:ee("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:o.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Dv(o.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},o.path)})})},Bv=({workingDir:e})=>{const{t:s}=ce(),{data:r,isLoading:n,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=mn({queryKey:ie.git.log(e||""),queryFn:({pageParam:S=0})=>he.get("/git/log",{params:{workingDir:e||"",limit:String(Ti),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,k)=>S.commits.length<Ti?void 0:k.length*Ti,enabled:!!e}),o=r?.pages.flatMap(S=>S.commits)||[],[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(280),[x,a]=C.useState(!1),h=C.useCallback(S=>{S.preventDefault(),a(!0);const k=S.clientX,j=_,w=R=>{const P=Math.min(480,Math.max(180,j+(R.clientX-k)));y(P)},E=()=>{a(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)},[_]),d=S=>{l===S?(u(null),g(null)):(u(S),g(null))},f=C.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(n)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(o.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(As,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const b=o.find(S=>S.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:_},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:o.length})]})}),t.jsxs("div",{ref:f,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[o.map(S=>{const k=l===S.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:ee("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:ee("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:S.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:S.message}),t.jsx(Nt,{size:12,className:ee("shrink-0 text-muted-foreground/70 transition-transform",k&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:S.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Tv(S.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[S.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:S.body}),t.jsx(Iv,{workingDir:e,hash:S.hash,selectedPath:c,onSelectFile:g})]})]},S.hash)}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:c&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Tr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:c}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",b?.shortHash,")"]})]}),t.jsx(Ov,{workingDir:e,hash:l,filePath:c})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Tr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function Fv(e){return Rt({queryKey:ie.previews.status(e??""),queryFn:async()=>{const s=await he.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function zv(e){const s=ot();return _t({mutationFn:r=>he.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:ie.previews.status(e)}),s.invalidateQueries({queryKey:ie.workspaces.all}))}})}function Hv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Wv({workspaceId:e,readOnly:s}){const{t:r}=ce(),{data:n,isLoading:p,refetch:m,isFetching:v}=Fv(e),i=zv(e),[o,l]=C.useState(""),[u,c]=C.useState(0);C.useEffect(()=>{l(n?.target??"")},[n?.target]);const g=C.useMemo(()=>!n?.ready||!n.viewUrl?null:`${n.viewUrl}?_=${u}`,[u,n?.ready,n?.viewUrl]),_=async()=>{if(e)try{await i.mutateAsync(o.trim()||null),c(x=>x+1),ct.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");ct.error(a)}},y=async()=>{await m(),c(x=>x+1)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:o,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),_())},disabled:s||i.isPending,placeholder:Hv(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"}),t.jsxs(ke,{type:"button",size:"sm",variant:"outline",onClick:_,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(Xe,{className:"animate-spin"}):t.jsx(hu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(ke,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Xe,{className:"animate-spin"}):t.jsx(ir,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),n?.ready&&n.viewUrl&&t.jsx(ke,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:n.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(pn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:p?r("Checking preview target..."):n?.ready?`${r("Proxying")} ${n.target}`:n?.configured?`${r("Preview target is not reachable")}${n.error?`: ${n.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:n?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function $v(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Go(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Uv(e){return e.length<=34?e:`...${e.slice(-31)}`}function Zl({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:n,disabled:p,className:m,buttonClassName:v}){const{t:i}=ce(),[o,l]=C.useState(!1),u=C.useRef(null),c=C.useMemo(()=>An(e,s),[e,s]),g=c.find(_=>_.workspace.id===r)??c[0];return C.useEffect(()=>{if(!o)return;const _=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[o]),c.length<=1?null:t.jsxs("div",{ref:u,className:ee("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(_=>!_),disabled:p,className:ee("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:i("Workspace"),children:[t.jsx(Ns,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Uv(hs(g.workspace))}),t.jsx(xt,{size:13,className:ee("shrink-0 text-neutral-400 transition-transform",o&&"rotate-180")})]}),o&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(_=>{const y=_.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{n(_.workspace.id),l(!1)},className:ee("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:y?t.jsx(qt,{size:13}):t.jsx(ja,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(_.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(_.roleLabel)),children:i(_.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",$v(_.workspace.status)),children:_.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:hs(_.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[_.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",_.ownerName]}),_.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",_.parentBranchName]}),t.jsx("span",{children:_.workspace.id.slice(0,8)})]})]})]},_.workspace.id)})})]})}const qv=[{key:"review",label:"Changes",icon:t.jsx(Ts,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ka,{size:14})}],Kv=[{key:"history",label:"History",icon:t.jsx(As,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(rr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ka,{size:14})}],Xv=({active:e,onClick:s,icon:r,label:n})=>t.jsxs("button",{type:"button",onClick:s,className:ee("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:n})]}),Vv=({active:e,onClick:s,icon:r,label:n})=>t.jsx("button",{type:"button",onClick:s,title:n,"aria-label":n,"aria-pressed":e,className:ee("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Jl=le.memo(function({className:s,sessionId:r,workspaceId:n,workingDir:p,projectId:m,hideChanges:v,readOnly:i,repoDeleted:o,teamRun:l,teamStatus:u,gitProps:c,workspaces:g,selectedWorkspaceId:_,onSelectWorkspace:y,variant:x="tabs",expanded:a,onExpandedChange:h,minContentWidth:d=520,tabRef:f}){const{t:b}=ce(),S=tn(W=>W.setVisibleContext),k=x==="rail",[j,w]=C.useState(!1),E=k?a??j:!0,R=C.useCallback(W=>{a===void 0&&w(W),h?.(W)},[a,h]),P=C.useMemo(()=>{const W=v?Kv:qv,K=i?W.filter(N=>N.key!=="terminal"):W;return l?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...K]:K},[v,i,l]),[M,T]=C.useState(v?"history":"review"),B=C.useCallback(W=>{T(W),k&&R(!0)},[k,R]);C.useImperativeHandle(f,()=>({setTab:W=>B(W)}),[B]);const{data:D}=_d(m??""),F=C.useMemo(()=>{if(!D?.quickCommands)return[];try{return JSON.parse(D.quickCommands)}catch{return[]}},[D?.quickCommands]),[$,A]=C.useState([]),O=C.useRef(void 0);C.useEffect(()=>{p&&p!==O.current&&(O.current=p,A(W=>W.includes(p)?W:[...W,p]))},[p]),C.useEffect(()=>{P.some(W=>W.key===M)||T(P[0]?.key??(v?"history":"review"))},[M,v,P]),C.useEffect(()=>{if(k&&!E)return;const W=M==="review"?"changes":M==="history"?"history":null;if(!n||!p||!W){S(null);return}return S({workspaceId:n,workingDir:p,tab:W}),()=>{S(null)}},[M,E,k,S,p,n]);const L=!!y&&An(g,l).length>1,I=P.find(W=>W.key===M)??P[0],U=I?b(I.label):"",Y=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:b(o?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,q=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[L&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Zl,{workspaces:g,teamRun:l,selectedWorkspaceId:_,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[M==="team-status"&&l&&u,M==="editor"&&t.jsx(Sv,{workingDir:p,readOnly:i}),$.map(W=>{const K=M==="terminal"&&p===W;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:K?"block":"none"},children:t.jsx(Lm,{cwd:W,isVisible:K,quickCommands:F})},W)}),M==="preview"&&t.jsx(Wv,{workspaceId:n,readOnly:i}),M==="review"&&t.jsx(Mv,{workingDir:p,workspaceId:n,branchName:c?.branchName,targetBranch:c?.targetBranch,commitMessage:c?.commitMessage,canRunGitOperations:c?.canRunGitOperations,onRefreshCommitMessage:c?.onRefreshCommitMessage,onConflict:c?.onConflict,onResolveConflicts:c?.onResolveConflicts}),M==="history"&&t.jsx(Bv,{workingDir:p})]})]});return k?t.jsxs("div",{className:ee("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:P.map(W=>t.jsx(Vv,{active:E&&M===W.key,onClick:()=>B(W.key),icon:W.icon,label:b(W.label)},W.key))}),E&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:d},children:[Y,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:I?.icon}),t.jsx("span",{className:"truncate",children:U})]}),t.jsx("button",{type:"button",onClick:()=>R(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:b("收起"),"aria-label":b("收起"),children:t.jsx(nu,{size:15})})]}),q]})]}):t.jsxs("div",{className:ee("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&Y,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:P.map(W=>t.jsx(Xv,{active:M===W.key,onClick:()=>B(W.key),icon:W.icon,label:b(W.label)},W.key))}),q]})}),Qo=1500,Yv=3e3;function Gv(e){const[s,r]=C.useState(null),n=C.useRef(0),p=C.useRef(null),m=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},i=Zt.connect(),o=u=>{r(u),m.current=setTimeout(()=>r(null),Yv)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,n.current===0&&(n.current=Date.now()),r(c);return}const g=n.current>0?Date.now()-n.current:0,_=Qo-g;n.current===0?(n.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>o(c),Qo)):_>0?(p.current=c,v(),m.current=setTimeout(()=>o(c),_)):o(c)};return i.on(at.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(at.WORKSPACE_SETUP_PROGRESS,l),v(),n.current=0,p.current=null}},[e]),s}function In(){const e=ot();return _t({mutationFn:s=>he.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ie.sessions.detail(r)}),e.invalidateQueries({queryKey:ie.tasks.all})}})}function ec(){const e=ot();return _t({mutationFn:s=>he.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ie.sessions.detail(r)})}})}function Bn(){const e=ot();return _t({mutationFn:({id:s,message:r,providerId:n})=>he.post(`/sessions/${s}/message`,{message:r,providerId:n}),onSuccess:()=>{e.invalidateQueries({queryKey:ie.workspaces.all}),e.invalidateQueries({queryKey:ie.tasks.all})}})}function tc({isOpen:e,onClose:s,onStarted:r,taskId:n,taskTitle:p,taskDescription:m,taskPrompt:v}){const{t:i}=ce(),[o,l]=C.useState(""),[u,c]=C.useState(""),[g,_]=C.useState(ls.WORKTREE),[y,x]=C.useState("idle"),[a,h]=C.useState(null),d=ot(),f=nl(n),b=In(),{data:S,isLoading:k}=sr();C.useEffect(()=>{if(!e||!S)return;const M=S.find(T=>T.availability.type!=="NOT_FOUND");M&&l(M.provider.id)},[e,S]),C.useEffect(()=>{if(e){const M=[p];m&&M.push(m),c(v?.trim()||M.join(`
|
|
70
|
+
`,Uo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};ev(tv);var sv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,l=n===void 0?{}:n,u=e.contentProps,c=u===void 0?{}:u,g=C.useContext(ri),_=g.init,y=g.cleanupWindowEvents,x=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=x.current,d=a.current;return h!==null&&d!==null&&_&&_?.(h,d),function(){y?.()}},[]),de.createElement("div",rs({},l,{ref:x,className:"".concat(Vi.wrapperClass," ").concat(Uo.wrapper," ").concat(o),style:v}),de.createElement("div",rs({},c,{ref:a,className:"".concat(Vi.contentClass," ").concat(Uo.content," ").concat(m),style:i}),s))},$l=function(){var e=C.useContext(ri);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},rv=function(){var e=$l();return zr(e)};function iv(e){var s=$l(),r=C.useState(e(Yi(s))),o=r[0],p=r[1];return C.useEffect(function(){var m=!0,v=s.onChange(function(i){m&&p(e(Yi(i.instance)))});return function(){v(),m=!1}},[e,s]),o}function nv(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 ov(e,s){return Rt({queryKey:ae.files.tree(e||"",s),queryFn:()=>me.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function av(e,s){return Rt({queryKey:ae.files.content(e||"",s||""),queryFn:()=>me.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function lv(e){const s=ot();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function cv(){const e=ot();return _t({mutationFn:s=>me.post("/files/write",s),onSuccess:(s,r)=>{const o=ae.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||nv(r.path)})}})}function dv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function uv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const hv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function fv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&hv.has(s)?Na:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Mr:s==="json"?Hd:s==="md"||s==="mdx"||s==="txt"?Ea:bd}const qo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:ee("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Ul=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ue(),{data:n,isLoading:l,isError:u}=ov(e,s),c=C.useMemo(()=>n?.items??[],[n?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=dv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(qo,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(xt,{size:14,className:"text-neutral-400"}):t.jsx(Nt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(Xr,{size:14,className:"text-amber-500"}):t.jsx(La,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Ul,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const _=uv(s,g.name),y=fv(g),x=v===_,a=y===Na;return t.jsx(qo,{depth:r,active:x,onClick:()=>m(_),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},_)})})},mv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ue(),[v,i]=C.useState(()=>new Set),n=lv(e),l=C.useCallback(u=>{i(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:ee("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(rr,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(su,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Ul,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},pv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function gv(e){const s=e.split(".").pop()?.toLowerCase();return s?pv.has(s):!1}function vv(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const xv=({filePath:e})=>{const{t:s}=ue(),{zoomIn:r,zoomOut:o,centerView:p}=rv(),m=iv(i=>i.state.scale),v=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(bu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(xu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(eu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},_v=({workingDir:e,filePath:s})=>{const{t:r}=ue(),[o,p]=C.useState(!1),m=vv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Jg,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(xv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(sv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function bv(e){const s=e.split("/");return s[s.length-1]||e}function yv(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 Sv=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ue();return t.jsxs("button",{type:"button",onClick:o,className:ee("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:ee("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(is,{size:12})})]})},wv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=ue(),[p,m]=C.useState([]),[v,i]=C.useState(null),n=cv(),[l,u]=C.useState(280),[c,g]=C.useState(!1),[_,y]=C.useState(!1),x=C.useRef(280),a=C.useCallback(()=>{g(T=>(T?u(x.current):x.current=l,!T))},[l]),h=C.useCallback(T=>{T.preventDefault(),y(!0);const B=T.clientX,D=l,F=A=>{const O=A.clientX-B,L=Math.min(480,Math.max(160,D+O));u(L)},H=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H)},[l]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(T=>T.path===v)||null,[p,v]),{data:f,isFetching:b,isError:S,error:k}=av(e,d?.isImage?null:v);C.useEffect(()=>{!v||!f||m(T=>T.map(B=>B.path!==v||B.isDirty||B.loaded?B:{...B,language:f.language||B.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[v,f]);const j=C.useCallback(T=>{m(B=>{if(B.find(H=>H.path===T))return B;const F=gv(T);return[...B,{path:T,name:bv(T),language:yv(T),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(T)},[]),w=C.useCallback(T=>{m(B=>{const D=B.filter(F=>F.path!==T);return i(F=>F!==T?F:D.length?D[D.length-1].path:null),D})},[]),E=C.useCallback(T=>{m(B=>B.map(D=>{if(D.path!==v)return D;const F=T!==D.savedContent;return{...D,content:T,isDirty:F}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(T=>T.map(B=>B.path===d.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[d,r,n,e]),P=C.useRef(()=>{});C.useEffect(()=>{P.current=()=>{R().catch(()=>{})}},[R]),C.useEffect(()=>{const T=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),P.current())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[r]);const M=C.useCallback((T,B)=>{T.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{P.current()})},[]);return t.jsxs("div",{className:ee("flex h-full overflow-hidden bg-white",s),style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:c?36:l,transition:_?"none":"width 0.15s ease"},children:c?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:o("Expand file tree"),children:t.jsx(iu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(mv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[p.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):p.map(T=>t.jsx(Sv,{active:T.path===v,name:T.name,isDirty:T.isDirty,onClick:()=>i(T.path),onClose:B=>{B.stopPropagation(),w(T.path)}},T.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),n.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!n.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(_v,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(Up,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:T=>E(T??""),onMount:M,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!d.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),o("Loading file...")]})}),S&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[o("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("No workspace selected.")})})]})]})};function ii(e,s={}){return Rt({queryKey:ae.git.changes(e||""),queryFn:()=>me.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function ql(e,s,r){return Rt({queryKey:ae.git.diff(e||"",s||"",r),queryFn:()=>me.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Pn(e,s){return Rt({queryKey:ae.git.commitFiles(e||"",s||""),queryFn:()=>me.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function On(e,s,r){return Rt({queryKey:ae.git.commitDiff(e||"",s||"",r||""),queryFn:()=>me.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Kl({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:n}=ue(),[l,u]=C.useState(""),[c,g]=C.useState(!1);C.useEffect(()=>{e&&(g(!1),u(p??""))},[e]),C.useEffect(()=>{c||!e||u(p??"")},[p,c,e]);const _=()=>{m||s()};return t.jsx(Ms,{isOpen:e,onClose:_,title:n("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:_,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:n("取消")}),t.jsx("button",{onClick:()=>i(l.trim()||void 0),disabled:m,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:14,className:"animate-spin"}),n("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ar,{size:14}),n("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Td,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:n("提交消息")}),t.jsx("textarea",{value:l,onChange:y=>{g(!0),u(y.target.value)},placeholder:n("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:n("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:n("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function ys(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Xl(e){if(!(e instanceof pa)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Vs.REBASE&&s.conflictOp!==Vs.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:ys(s,"sourceBranch"),targetBranch:ys(s,"targetBranch"),sourceWorktreePath:ys(s,"sourceWorktreePath"),targetWorktreePath:ys(s,"targetWorktreePath"),sourceWorkspaceId:ys(s,"sourceWorkspaceId"),targetWorkspaceId:ys(s,"targetWorkspaceId")}}function Ko(e,s,r,o){const p=Xl(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Vl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:i}){const{t:n}=ue(),{data:l,isLoading:u}=En(e),c=ll(),g=al(),_=jn(),[y,x]=C.useState(!1),[a,h]=C.useState(null);if(C.useEffect(()=>{y&&m?.()},[y,m]),u||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const d=l.conflictedFiles.length>0,f=l.operation!=="idle",b=l.hasUncommittedChanges||l.untrackedCount>0,S=l.uncommittedCount+l.untrackedCount,k=!d&&!f&&!b,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!b&&!d,w=()=>{h(null),c.mutate(e,{onError:M=>{Ko(M,n("更新失败,请稍后重试"),T=>v(T),h)}})},E=()=>{h(null),x(!0)},R=M=>{h(null),g.mutate({id:e,commitMessage:M},{onSuccess:()=>x(!1),onError:T=>{Ko(T,n("提交失败,请稍后重试"),B=>{x(!1),v(B)},h)}})},P=()=>{g.isPending||(x(!1),h(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Gd,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),b&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(qd,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:S})})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(tr,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:n("处理冲突")}),t.jsx("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:_.isPending?n("正在撤销..."):n("撤销操作")})]})]}),f&&!d&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Ye,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>_.mutate(e),disabled:_.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(kd,{size:12}),_.isPending?n("正在撤销..."):n("撤销操作")]})]}),!d&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:w,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(rr,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!b?t.jsxs("button",{onClick:E,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Ar,{size:12}),n("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:n(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Ar,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Kl,{isOpen:y,onClose:P,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:a,onConfirm:R})]})}const Ri=50,Ai=400,Xo={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"},Vo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Yl(e){const s=e.split("/");return s[s.length-1]||e}function Cv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function kv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?ft("{count}s ago",{count:r}):r<3600?ft("{count}m ago",{count:Math.floor(r/60)}):r<86400?ft("{count}h ago",{count:Math.floor(r/3600)}):r<604800?ft("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Er(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Qi=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:ee("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Ev=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:ee("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:ee("pl-2 whitespace-pre",o),children:e})]})},Gl=({diff:e})=>{const{t:s}=ue(),[r,o]=C.useState(!1),p=C.useMemo(()=>e.split(`
|
|
71
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Ai,v=m?p.slice(0,Ai):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((i,n)=>t.jsx(Ev,{line:i,lineNum:n+1},n)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Ai})})]})},jv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=ql(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ye,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Gl,{diff:m?.diff||""})},Nv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=On(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ye,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Gl,{diff:m?.diff||""})},Mi=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=C.useState(!1),[i,n]=C.useState(!1),l=C.useRef(null),u=Er(s,e.path);C.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),C.useEffect(()=>{const _=l.current;if(!_||i)return;const y=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(n(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(_),()=>y.disconnect()},[i]);const c=Xo[e.status]||Xo.M,g=Cv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:ee("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(_=>!_),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Nt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(xt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:ee("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Yl(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Qi,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(jv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(Nv,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function Rv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const v=o[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return Ql(s)}function Ql(e){const s=new Map;for(const r of e.dirs.values()){let o=Ql(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const Av=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=C.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(Xr,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(La,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Zl,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Zl=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(Av,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:ee("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:ee("w-1.5 h-1.5 rounded-full shrink-0",Vo[p.status]||Vo.M)}),t.jsx("span",{className:ee("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Yl(p.path)})]},p.cardKey)})]}),Mv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ue(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:n}=mn({queryKey:ae.git.log(e),queryFn:({pageParam:u=0})=>me.get("/git/log",{params:{workingDir:e,limit:String(Ri),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Ri?void 0:c.length*Ri}),l=p?.pages.flatMap(u=>u.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Ye,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:ee("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:ee("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:ee("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",kv(u.timestamp)]})]})]},u.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:n,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Tv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n})=>{const{t:l}=ue(),[u,c]=C.useState({kind:"overview"}),[g,_]=C.useState(""),[y,x]=C.useState(null),[a,h]=C.useState(null),{data:d,isLoading:f,isError:b}=ii(e),S=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=Pn(e,S),w=C.useRef(new Map),E=C.useRef(null),R=C.useRef(null),P=C.useCallback((U,W)=>{W?w.current.set(U,W):w.current.delete(U)},[]),{uncommitted:M,committed:T,commitFiles:B}=C.useMemo(()=>{const U=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},z=(k?.files||[]).filter(U).map(X=>({...X,cardKey:Er(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:z}}const W=(d?.uncommitted||[]).filter(U).map(N=>({...N,cardKey:Er({kind:"working",diffType:"uncommitted"},N.path)})),q=(d?.committed||[]).filter(U).map(N=>({...N,cardKey:Er({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:W,committed:q,commitFiles:[]}},[u,d,k,g]),D=u.kind==="commit"?B:[...M,...T],F=C.useMemo(()=>Rv(D),[D]),H=C.useMemo(()=>{let U=0,W=0;for(const q of D)U+=q.additions??0,W+=q.deletions??0;return{additions:U,deletions:W,files:D.length}},[D]),A=C.useCallback(()=>{const U=E.current;if(!U)return;const W=U.getBoundingClientRect().top;let q=null,N=Number.NEGATIVE_INFINITY;for(const[z,X]of w.current){const K=X.getBoundingClientRect().top-W;K<=48&&K>N&&(N=K,q=z)}if(!q){let z=null,X=Number.POSITIVE_INFINITY;for(const[K,re]of w.current){const Z=re.getBoundingClientRect().top-W;Z<X&&(X=Z,z=K)}q=z}x(q)},[]);C.useEffect(()=>{const U=E.current;if(!U)return;let W=0;const q=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(A)};return U.addEventListener("scroll",q,{passive:!0}),()=>{U.removeEventListener("scroll",q),cancelAnimationFrame(W)}},[A]);const O=C.useCallback(U=>{const W=w.current.get(U.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),x(U.cardKey),h(U.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),L=C.useCallback(U=>{c(W=>W.kind==="commit"&&W.commit.hash===U.hash?{kind:"overview"}:{kind:"commit",commit:U}),_(""),x(null),E.current?.scrollTo({top:0})},[]),I=C.useCallback(()=>{c({kind:"overview"}),_(""),x(null),E.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const $=m&&s&&r&&o,V=u.kind==="commit"?j:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&i&&n&&t.jsx(Vl,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:H.files})}),t.jsx(Qi,{additions:H.additions,deletions:H.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Gs,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Gs,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(Qi,{className:"ml-auto",additions:H.additions,deletions:H.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:V?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(U=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},U))}):b&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):D.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Mr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(U=>t.jsx(Mi,{entry:U,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===U.cardKey,registerNode:P},U.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[M.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(U=>t.jsx(Mi,{entry:U,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===U.cardKey,registerNode:P},U.cardKey))})]}),T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(U=>t.jsx(Mi,{entry:U,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===U.cardKey,registerNode:P},U.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(on,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:U=>_(U.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:D.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(Zl,{node:F,depth:0,activeKey:y,onSelect:O})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(As,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Mv,{workingDir:e,selectedHash:S,onSelectCommit:L})})]})]})]})]})},Ti=50,Yo={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 Dv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?ft("{count}s ago",{count:r}):r<3600?ft("{count}m ago",{count:Math.floor(r/60)}):r<86400?ft("{count}h ago",{count:Math.floor(r/3600)}):r<604800?ft("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Lv(e){const s=e.split("/");return s[s.length-1]||e}function Pv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Ov=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:ee("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:ee("pl-2 whitespace-pre",o),children:e})]})},Iv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ue(),{data:p,isLoading:m,isError:v}=On(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Ye,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
72
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((l,u)=>t.jsx(Ov,{line:l,lineNum:u+1},u))})},Bv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ue(),{data:m,isLoading:v}=Pn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Ye,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const l=Yo[n.status]||Yo.M,u=Pv(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:ee("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:ee("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Lv(n.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},n.path)})})},Fv=({workingDir:e})=>{const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=mn({queryKey:ae.git.log(e||""),queryFn:({pageParam:S=0})=>me.get("/git/log",{params:{workingDir:e||"",limit:String(Ti),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,k)=>S.commits.length<Ti?void 0:k.length*Ti,enabled:!!e}),n=r?.pages.flatMap(S=>S.commits)||[],[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(280),[x,a]=C.useState(!1),h=C.useCallback(S=>{S.preventDefault(),a(!0);const k=S.clientX,j=_,w=R=>{const P=Math.min(480,Math.max(180,j+(R.clientX-k)));y(P)},E=()=>{a(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)},[_]),d=S=>{l===S?(u(null),g(null)):(u(S),g(null))},f=C.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Ye,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(n.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(As,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const b=n.find(S=>S.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:_},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:n.length})]})}),t.jsxs("div",{ref:f,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(S=>{const k=l===S.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:ee("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:ee("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:S.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:S.message}),t.jsx(Nt,{size:12,className:ee("shrink-0 text-muted-foreground/70 transition-transform",k&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:S.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Dv(S.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[S.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:S.body}),t.jsx(Bv,{workingDir:e,hash:S.hash,selectedPath:c,onSelectFile:g})]})]},S.hash)}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:c&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Mr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:c}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",b?.shortHash,")"]})]}),t.jsx(Iv,{workingDir:e,hash:l,filePath:c})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Mr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function zv(e){return Rt({queryKey:ae.previews.status(e??""),queryFn:async()=>{const s=await me.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function Wv(e){const s=ot();return _t({mutationFn:r=>me.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:ae.previews.status(e)}),s.invalidateQueries({queryKey:ae.workspaces.all}))}})}function Hv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function $v({workspaceId:e,readOnly:s}){const{t:r}=ue(),{data:o,isLoading:p,refetch:m,isFetching:v}=zv(e),i=Wv(e),[n,l]=C.useState(""),[u,c]=C.useState(0);C.useEffect(()=>{l(o?.target??"")},[o?.target]);const g=C.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${u}`,[u,o?.ready,o?.viewUrl]),_=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),c(x=>x+1),ct.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");ct.error(a)}},y=async()=>{await m(),c(x=>x+1)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:n,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),_())},disabled:s||i.isPending,placeholder:Hv(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"}),t.jsxs(Te,{type:"button",size:"sm",variant:"outline",onClick:_,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(Ye,{className:"animate-spin"}):t.jsx(fu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Te,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Ye,{className:"animate-spin"}):t.jsx(rr,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Te,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(pn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:p?r("Checking preview target..."):o?.ready?`${r("Proxying")} ${o.target}`:o?.configured?`${r("Preview target is not reachable")}${o.error?`: ${o.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:o?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function Uv(e){switch(e){case Et.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Et.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Et.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Et.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Go(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function qv(e){return e.length<=34?e:`...${e.slice(-31)}`}function Jl({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:i}=ue(),[n,l]=C.useState(!1),u=C.useRef(null),c=C.useMemo(()=>An(e,s),[e,s]),g=c.find(_=>_.workspace.id===r)??c[0];return C.useEffect(()=>{if(!n)return;const _=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[n]),c.length<=1?null:t.jsxs("div",{ref:u,className:ee("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(_=>!_),disabled:p,className:ee("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:i("Workspace"),children:[t.jsx(Ns,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:qv(hs(g.workspace))}),t.jsx(xt,{size:13,className:ee("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(_=>{const y=_.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(_.workspace.id),l(!1)},className:ee("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:y?t.jsx(qt,{size:13}):t.jsx(ja,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(_.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Go(_.roleLabel)),children:i(_.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Uv(_.workspace.status)),children:_.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:hs(_.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[_.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",_.ownerName]}),_.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",_.parentBranchName]}),t.jsx("span",{children:_.workspace.id.slice(0,8)})]})]})]},_.workspace.id)})})]})}const Kv=[{key:"review",label:"Changes",icon:t.jsx(Ts,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Kr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Rr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ka,{size:14})}],Xv=[{key:"history",label:"History",icon:t.jsx(As,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Kr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Rr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ka,{size:14})}],Vv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:ee("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),Yv=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:ee("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),ec=de.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,readOnly:i,repoDeleted:n,teamRun:l,teamStatus:u,gitProps:c,workspaces:g,selectedWorkspaceId:_,onSelectWorkspace:y,variant:x="tabs",expanded:a,onExpandedChange:h,minContentWidth:d=520,tabRef:f}){const{t:b}=ue(),S=tn(W=>W.setVisibleContext),k=x==="rail",[j,w]=C.useState(!1),E=k?a??j:!0,R=C.useCallback(W=>{a===void 0&&w(W),h?.(W)},[a,h]),P=C.useMemo(()=>{const W=v?Xv:Kv,q=i?W.filter(N=>N.key!=="terminal"):W;return l?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...q]:q},[v,i,l]),[M,T]=C.useState(v?"history":"review"),B=C.useCallback(W=>{T(W),k&&R(!0)},[k,R]);C.useImperativeHandle(f,()=>({setTab:W=>B(W)}),[B]);const{data:D}=yd(m??""),F=C.useMemo(()=>{if(!D?.quickCommands)return[];try{return JSON.parse(D.quickCommands)}catch{return[]}},[D?.quickCommands]),[H,A]=C.useState([]),O=C.useRef(void 0);C.useEffect(()=>{p&&p!==O.current&&(O.current=p,A(W=>W.includes(p)?W:[...W,p]))},[p]),C.useEffect(()=>{P.some(W=>W.key===M)||T(P[0]?.key??(v?"history":"review"))},[M,v,P]),C.useEffect(()=>{if(k&&!E)return;const W=M==="review"?"changes":M==="history"?"history":null;if(!o||!p||!W){S(null);return}return S({workspaceId:o,workingDir:p,tab:W}),()=>{S(null)}},[M,E,k,S,p,o]);const L=!!y&&An(g,l).length>1,I=P.find(W=>W.key===M)??P[0],$=I?b(I.label):"",V=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:b(n?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,U=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[L&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Jl,{workspaces:g,teamRun:l,selectedWorkspaceId:_,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[M==="team-status"&&l&&u,M==="editor"&&t.jsx(wv,{workingDir:p,readOnly:i}),H.map(W=>{const q=M==="terminal"&&p===W;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:q?"block":"none"},children:t.jsx(Pm,{cwd:W,isVisible:q,quickCommands:F})},W)}),M==="preview"&&t.jsx($v,{workspaceId:o,readOnly:i}),M==="review"&&t.jsx(Tv,{workingDir:p,workspaceId:o,branchName:c?.branchName,targetBranch:c?.targetBranch,commitMessage:c?.commitMessage,canRunGitOperations:c?.canRunGitOperations,onRefreshCommitMessage:c?.onRefreshCommitMessage,onConflict:c?.onConflict,onResolveConflicts:c?.onResolveConflicts}),M==="history"&&t.jsx(Fv,{workingDir:p})]})]});return k?t.jsxs("div",{className:ee("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:P.map(W=>t.jsx(Yv,{active:E&&M===W.key,onClick:()=>B(W.key),icon:W.icon,label:b(W.label)},W.key))}),E&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:d},children:[V,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:I?.icon}),t.jsx("span",{className:"truncate",children:$})]}),t.jsx("button",{type:"button",onClick:()=>R(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:b("收起"),"aria-label":b("收起"),children:t.jsx(ou,{size:15})})]}),U]})]}):t.jsxs("div",{className:ee("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&V,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:P.map(W=>t.jsx(Vv,{active:M===W.key,onClick:()=>B(W.key),icon:W.icon,label:b(W.label)},W.key))}),U]})}),Qo=1500,Gv=3e3;function Qv(e){const[s,r]=C.useState(null),o=C.useRef(0),p=C.useRef(null),m=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},i=Zt.connect(),n=u=>{r(u),m.current=setTimeout(()=>r(null),Gv)},l=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const g=o.current>0?Date.now()-o.current:0,_=Qo-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>n(c),Qo)):_>0?(p.current=c,v(),m.current=setTimeout(()=>n(c),_)):n(c)};return i.on(at.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(at.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function In(){const e=ot();return _t({mutationFn:s=>me.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function tc(){const e=ot();return _t({mutationFn:s=>me.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ae.sessions.detail(r)})}})}function Bn(){const e=ot();return _t({mutationFn:({id:s,message:r,providerId:o})=>me.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.workspaces.all}),e.invalidateQueries({queryKey:ae.tasks.all})}})}function sc({isOpen:e,onClose:s,onStarted:r,taskId:o,taskTitle:p,taskDescription:m,taskPrompt:v}){const{t:i}=ue(),[n,l]=C.useState(""),[u,c]=C.useState(""),[g,_]=C.useState(ls.WORKTREE),[y,x]=C.useState("idle"),[a,h]=C.useState(null),d=ot(),f=ol(o),b=In(),{data:S,isLoading:k}=sr();C.useEffect(()=>{if(!e||!S)return;const M=S.find(T=>T.availability.type!=="NOT_FOUND");M&&l(M.provider.id)},[e,S]),C.useEffect(()=>{if(e){const M=[p];m&&M.push(m),c(v?.trim()||M.join(`
|
|
73
73
|
|
|
74
|
-
`)),_(ls.WORKTREE),x("idle"),h(null)}},[e,p,m,v]);const j=y!=="idle",w=async()=>{if(!(!
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...
|
|
77
|
-
`)}function
|
|
78
|
-
`)}function n0(e){if(e.teamRunId)return{type:"team_room",message:i0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:r0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function oc({open:e,onOpenChange:s,workspaceId:r,conflictOp:n,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:i,worktreePath:o,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sessions:x,currentSessionId:a,teamRunId:h}){const{t:d}=ce(),[f,b]=C.useState(""),S=Bn(),k=sn(h??""),j=kn(),w=!!h,E=a||f,R=w?k.isPending:S.isPending,P=()=>{const F=n0({workspaceId:r,worktreePath:o,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:n,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ct.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},M=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},T=n==="REBASE"?"Rebase":"Merge",B=!w&&!a&&x.length>0,D=w||!!E;return t.jsx(Ms,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:T}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(ke,{onClick:P,disabled:!D||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(F=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:F},F))})]}),w&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),B&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:F=>b(F.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),x.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!E&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function o0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,n)=>({files:r.files+1,additions:r.additions+(n.additions??0),deletions:r.deletions+(n.deletions??0)}),{files:0,additions:0,deletions:0})}function Zo(e,s,r,n){const p=Kl(e);if(p){r(p);return}n(e instanceof Error?e.message:s)}function ac({workspaceId:e,branchName:s,targetBranch:r,commitMessage:n,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:i,onOpenChanges:o,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ce(),_=al(),y=ol(),x=jn(),[a,h]=C.useState(!1),[d,f]=C.useState(null),b=C.useMemo(()=>o0(p),[p]),S=b.additions+b.deletions,k=b.files>0&&S>0,j=(m?.conflictedFiles.length??0)>0,w=!!(m&&m.operation!=="idle"),E=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),R=(m?.uncommittedCount??0)+(m?.untrackedCount??0),P=(m?.behind??0)>0,M=(m?.ahead??0)>0,T=v||!m&&i,B=!!(i&&e&&m&&P&&!j&&!w&&!E),D=!!(i&&e&&m&&M&&!P&&!j&&!w&&!E);if(C.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const F=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):R>0?g("{count} 未提交",{count:R}):P?g("落后 {count}",{count:m?.behind??0}):g(M?"可合并":"已是最新"),$=g("{files} 个文件 · {lines} 行",{files:b.files,lines:S}),A=()=>{B&&(f(null),_.mutate(e,{onError:U=>{Zo(U,g("更新失败,请稍后重试"),Y=>u(Y),f)}}))},O=()=>{D&&(f(null),h(!0))},L=U=>{f(null),y.mutate({id:e,commitMessage:U},{onSuccess:()=>h(!1),onError:Y=>{Zo(Y,g("提交失败,请稍后重试"),q=>{h(!1),u(q)},f)}})},I=()=>{y.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ee("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:o,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Ts,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:$}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[b.additions>0&&t.jsxs("span",{className:"text-success",children:["+",b.additions]}),b.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",b.deletions]})]}),j&&t.jsx(tr,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:F})]}),t.jsx(Nt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[w&&t.jsx("button",{type:"button",onClick:()=>x.mutate(e),disabled:x.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:x.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:A,disabled:!B||_.isPending||T,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(P?"同步更新":"已是最新"),children:[_.isPending?t.jsx(Xe,{size:12,className:"animate-spin"}):t.jsx(ir,{size:12}),t.jsx("span",{children:_.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!D||y.isPending||T,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:D?g("合并到 {target}",{target:r}):g("提交变更"),children:[y.isPending?t.jsx(Xe,{size:12,className:"animate-spin"}):t.jsx(Mr,{size:12}),t.jsx("span",{children:y.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(ql,{isOpen:a,onClose:I,branchName:s,targetBranch:r,commitMessage:n,isPending:y.isPending,error:d,onConfirm:L})]})}function a0({agentType:e,workingDir:s}){return Rt({queryKey:ie.system.slashCommandCatalog(e,s),queryFn:async()=>(await he.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function l0(e,s){const r=new Set,n=[];for(const p of[...e,...s]){const m=p.command.trim().toLowerCase();!m||r.has(m)||(r.add(m),n.push(p.kind?p:{...p,kind:"builtin"}))}return n}function ni(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function c0(e){return ni(e.command)}function d0(e,s){if(!s)return 1e3;const r=c0(e),n=e.aliases?.map(ni)??[],p=[r,...n];let m=0;for(const i of p)i===s?m=Math.max(m,500):i.startsWith(s)?m=Math.max(m,400-(i.length-s.length)):i.includes(s)&&(m=Math.max(m,250-i.indexOf(s)));return m>0?m:`${r} ${n.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function Jo(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:ni(s[2]),replaceStart:r}}function lc(e,s){const r=ni(s);return r?e.map((n,p)=>({command:n,index:p,score:d0(n,r)})).filter(n=>n.score>0).sort((n,p)=>p.score-n.score||n.index-p.index||n.command.command.localeCompare(p.command.command)).map(n=>n.command):e.slice()}const u0=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],h0=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],f0=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],m0=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],p0={[Bt.CODEX]:u0,[Bt.CLAUDE_CODE]:h0,[Bt.GEMINI_CLI]:f0,[Bt.CURSOR_AGENT]:m0};function cc(e){return e.trim().toLowerCase().replace(/^\//,"")}function g0(e){return e?(p0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function v0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?cc(s[1]):null}function x0(e,s){return lc(e,cc(s))}function _0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function dc({agentType:e,workingDir:s,input:r,setInput:n,textareaRef:p,minHeight:m,maxHeight:v}){const[i,o]=C.useState(0),{data:l=[]}=a0({agentType:e,workingDir:s}),u=C.useMemo(()=>l0(g0(e),l),[e,l]),c=C.useMemo(()=>v0(r),[r]),g=C.useMemo(()=>c===null?[]:x0(u,c),[u,c]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{o(0)},[e,c]),C.useEffect(()=>{i<g.length||o(0)},[g.length,i]);const y=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;n(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,n,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),o(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),o(h=>(h-1+g.length)%g.length),!0):_0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allCommands:u,query:c,filteredCommands:g,selectedIndex:i,setSelectedIndex:o,applyCommand:y,handleKeyDown:x}}function b0({agentType:e,workingDir:s}){return Rt({queryKey:ie.system.skillCatalog(e,s),queryFn:async()=>(await he.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Bt.CODEX,staleTime:3e4})}function y0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function uc({agentType:e,workingDir:s,input:r,setInput:n,textareaRef:p,minHeight:m,maxHeight:v}){const[i,o]=C.useState(0),{data:l=[]}=b0({agentType:e,workingDir:s}),c=C.useMemo(()=>e===Bt.CODEX?Jo(r):null,[e,r])?.query??null,g=C.useMemo(()=>c===null?[]:lc(l,c),[c,l]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{o(0)},[e,c]),C.useEffect(()=>{i<g.length||o(0)},[g.length,i]);const y=C.useCallback(a=>{const h=Jo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;n(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,n,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),o(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),o(h=>(h-1+g.length)%g.length),!0):y0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:o,applySkill:y,handleKeyDown:x}}const S0="/api",w0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${S0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ss=520,Di=48,C0=4,k0=420;function E0(){const{t:e}=ce();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ea=[{status:ue.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ca,{className:"w-3 h-3"})},{status:ue.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(wa,{className:"w-3 h-3"})},{status:ue.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Sa,{className:"w-3 h-3"})},{status:ue.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(ya,{className:"w-3 h-3"})},{status:ue.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ba,{className:"w-3 h-3"})}];function j0({status:e,onChangeStatus:s}){const{t:r}=ce(),[n,p]=C.useState(!1),m=C.useRef(null);C.useEffect(()=>{if(!n)return;const i=o=>{m.current&&!m.current.contains(o.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n]);const v=ea.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${n?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),n&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ea.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(o=>o.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function ta({state:e,onRetry:s}){const{t:r}=ce(),n=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:n}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(ke,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:n})]})}function N0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:n,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ce(),[i,o]=C.useState(""),[l,u]=C.useState(!1),[c,g]=C.useState(!1),[_,y]=C.useState(!1),[x,a]=C.useState(!1),[h,d]=C.useState(!1),[f,b]=C.useState(!1),[S,k]=C.useState(null),j=C.useRef(null),[w,E]=C.useState(!1),[R,P]=C.useState(null),[M,T]=C.useState(void 0),[B,D]=C.useState(!1),F=C.useRef(null),$=C.useRef(null),A=C.useRef(null),O=C.useRef(null),{scrollRef:L,contentRef:I,isAtBottom:U,scrollToBottom:Y}=on({resize:"smooth",initial:"instant"}),[q,W]=C.useState(!1),[K,N]=C.useState(Ss),[z,V]=C.useState(!1),X=C.useRef(0),re=C.useRef(Ss),J=C.useRef(null),{data:se,isLoading:ve}=Cn(e?.id??""),pe=Gv(e?.id),{data:Le}=va(e?.id??""),{data:oe}=xa(Le?.id??""),dt=sn(Le?.id??""),ge=Le??null,Ee=!!ge,Ze=Le===null,tt=!!(e?.id&&Le===null),{data:Se,isLoading:it}=_a(e?.id??"",tt);C.useEffect(()=>{D(!1),P(null),T(void 0)},[e?.id]);const xe=C.useMemo(()=>fl(se,ge,M),[M,ge,se]);C.useEffect(()=>{M&&!se?.some(Q=>Q.id===M)&&T(void 0)},[M,se]);const je=C.useMemo(()=>se?.find(Q=>Q.id===xe),[xe,se]),Ie=je?.status===Et.ACTIVE?je.id:void 0,Pe=ml(je,ge);C.useEffect(()=>{if(!B||!se)return;se.some(ne=>ne.status==="ACTIVE"&&ne.sessions&&ne.sessions.length>0)&&D(!1)},[se,B]);const Ne=C.useMemo(()=>{if(B||!se)return null;const Q=ht=>{const pi=ht.createdAt,Fs=ht.endedAt??ht.startedAt??pi;if(!Fs)return 0;const _s=Date.parse(Fs);return Number.isNaN(_s)?0:_s},ne=(ht,pi)=>{const Fs=ht.filter(_s=>pi.includes(_s.status));return Fs.length===0?null:Fs.sort((_s,Bc)=>Q(Bc)-Q(_s))[0]??null},Ke=se.filter(ht=>ht.status==="ACTIVE"&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]),yt=ne(Ke,[rt.RUNNING])??ne(Ke,[rt.PENDING])??ne(Ke,[rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(yt)return yt;const gt=se.filter(ht=>(ht.status==="MERGED"||ht.status==="ABANDONED"||ht.status==="HIBERNATED")&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]);return ne(gt,[rt.COMPLETED,rt.FAILED,rt.CANCELLED])},[se,B]),Me=Ne?.id??"",be=Ee?R??"":Me,ye=C.useMemo(()=>{if(!R||!se)return null;for(const Q of se){const ne=Q.sessions?.find(Ke=>Ke.id===R);if(ne)return ne}return null},[R,se]),H=C.useMemo(()=>{if(!R||!ge?.invocations)return null;const Q=ge.invocations.filter(ne=>ne.sessionId===R);return Q.length===0?null:Q.sort((ne,Ke)=>{const yt=Date.parse(ne.updatedAt??ne.createdAt??""),gt=Date.parse(Ke.updatedAt??Ke.createdAt??"");return(Number.isNaN(gt)?0:gt)-(Number.isNaN(yt)?0:yt)})[0]??null},[R,ge?.invocations]),G=C.useMemo(()=>!H?.memberId||!ge?.members?null:ge.members.find(Q=>Q.id===H.memberId)??null,[H?.memberId,ge?.members]),Z=R?ye:Ne??null,ae=Z?.status===rt.RUNNING||Z?.status===rt.PENDING,de=!!e?.projectArchivedAt,fe=!!e?.projectRepoDeletedAt,Ve=v(fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Te}=sr(),[He,Re]=C.useState(null);C.useEffect(()=>{Re(Ne?.providerId??null)},[Ne?.providerId]);const Ae=C.useMemo(()=>!Ne||!se?!1:!se.some(ne=>ne.status==="ACTIVE"&&ne.sessions?.some(Ke=>Ke.id===Ne.id)),[Ne,se]),we=C.useMemo(()=>{if(!(!se||B)){if(je)return ts(je);for(const Q of se)if(Q.status==="ACTIVE"&&ts(Q))return ts(Q);return ts(se[0])}},[B,je,se]),We=dc({agentType:Ne?.agentType,workingDir:we,input:i,setInput:o,textareaRef:A,minHeight:60,maxHeight:300}),Ce=uc({agentType:Ne?.agentType,workingDir:we,input:i,setInput:o,textareaRef:A,minHeight:60,maxHeight:300}),Je=tn(Q=>Q.setVisibleContext),Ye=!!(Pe&&Ie&&we&&!de),{data:qe,isLoading:Ge}=En(Ie??"",{enabled:Ye}),{data:bt}=ii(we,{enabled:Ye});C.useEffect(()=>{if(!(q||!Ye||!Ie||!we))return Je({workspaceId:Ie,workingDir:we,tab:"changes"}),()=>{Je(null)}},[q,Ie,Je,Ye,we]);const mt=je?.sessions??[],ut=hs(je),At=je?.commitMessage,wt=C.useMemo(()=>pl(je,se,e?.mainBranch??""),[je,e?.mainBranch,se]),Be=C.useMemo(()=>qe?.conflictOp&&qe.conflictedFiles.length>0?{conflictOp:qe.conflictOp,conflictedFiles:qe.conflictedFiles}:S,[qe?.conflictOp,qe?.conflictedFiles,S]),Dt=Be?.targetWorkspaceId??Ie,Lt=Be?.targetWorktreePath??je?.worktreePath,ms=Be?.sourceBranch??ut,oi=Be?.targetBranch??wt,et=ot(),ps=C.useCallback(async()=>e?.id?et.fetchQuery({queryKey:ie.tasks.body(e.id),queryFn:()=>he.get(`/tasks/${e.id}/body`)}):null,[et,e?.id]),Ps=C.useCallback(()=>e?.id?et.invalidateQueries({queryKey:ie.workspaces.list(e.id)}):Promise.resolve(),[e?.id,et]);C.useEffect(()=>{if(!w)return;const Q=ne=>{$.current&&!$.current.contains(ne.target)&&E(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[w]);const Os=Bn(),Xt=kn(),as=ad(),hr=nl(e?.id??""),Is=In(),gs=tf(),zt=C.useMemo(()=>!se||se.some(ne=>ne.status==="ACTIVE")?null:se.find(ne=>ne.status==="HIBERNATED")??null,[se]),vs=C.useRef(null);C.useEffect(()=>{zt&&vs.current!==zt.id&&(gs.isPending||(vs.current=zt.id,gs.mutate(zt.id,{onSettled:()=>{vs.current=null}})))},[zt,gs]);const ai=C.useCallback(async()=>{if(!e?.id)return;const Q=Ne?.providerId??Te?.find(ne=>ne.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Ke=(await ps())?.prompt??e.title;await as.mutateAsync(e.id),D(!0);const yt=await hr.mutateAsync({}),gt=await he.post(`/workspaces/${yt.id}/sessions`,{providerId:Q,prompt:Ke});await Is.mutateAsync(gt.id),await et.invalidateQueries({queryKey:ie.workspaces.list(e.id)})}catch(ne){console.error("[retry] failed:",ne),D(!1)}finally{d(!1)}}},[e?.id,e?.title,Ne?.providerId,Te,ps,as,hr,Is,et]),Bs=C.useCallback(async()=>{e?.id&&(await ps(),u(!0))},[ps,e?.id]),fr=C.useCallback(()=>{je?.id&&Xt.mutate({workspaceId:je.id})},[Xt,je?.id]),li=C.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),mr=C.useCallback(Q=>{P(Q),requestAnimationFrame(()=>{Y()})},[Y]),pr=C.useCallback(()=>{P(null)},[]),xs=C.useCallback(Q=>{k(Q??null),b(!0)},[]),ci=C.useCallback(Q=>dt.mutateAsync(Q),[dt]),Vt=C.useCallback(()=>{et.invalidateQueries({queryKey:ld.all})},[et]),{isConnected:gr,isLoadingSnapshot:Yt,logs:te,entries:me,attach:Fe}=Ma({sessionId:be,sessionStatus:Z?.status,onExit:C.useCallback(()=>{et.invalidateQueries({queryKey:["workspaces"]})},[et])});C.useEffect(()=>{if(!e?.id)return;const Q=Zt.connect();Q.emit(ws.SUBSCRIBE,{topic:"task",id:e.id});const ne=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:["tasks"]}),Vt())},Ke=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:ie.workspaces.list(e.id)}),Vt())},yt=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:ie.workspaces.list(e.id)}),Vt())};return Q.on(at.TASK_UPDATED,ne),Q.on(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ke),Q.on(at.WORKSPACE_HIBERNATED,yt),()=>{Q.off(at.TASK_UPDATED,ne),Q.off(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ke),Q.off(at.WORKSPACE_HIBERNATED,yt),Q.emit(ws.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,et,Vt]),C.useEffect(()=>{if(!be)return;const Q=Zt.connect(),ne=Ke=>{Ke.sessionId===be&&(et.invalidateQueries({queryKey:["workspaces"]}),Vt())};return Q.on(at.SESSION_COMPLETED,ne),()=>{Q.off(at.SESSION_COMPLETED,ne)}},[be,et,Vt]);const{todos:Oe}=Ta(me),{files:Ct,addFiles:pt,removeFile:ze,clear:Ht,buildMarkdownLinks:Wt,hasFiles:Pt,isUploading:vr}=nn(),Nc=C.useMemo(()=>sc(Z),[Z?.tokenUsage]),zn=Ra(te,Nc);C.useEffect(()=>{be&&gr&&Fe()},[be,gr,Fe]);const Hn=C.useRef(e?.id);C.useEffect(()=>{if(Hn.current!==e?.id&&L.current){const Q=L.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}Hn.current=e?.id},[e?.id,L]);const di=ec(),ui=C.useRef(!1),Wn=C.useCallback(async()=>{if(!i.trim()&&!Pt||!be||ui.current||vr)return;ui.current=!0;const Q=Wt(),ne=[i.trim(),Q].filter(Boolean).join(`
|
|
74
|
+
`)),_(ls.WORKTREE),x("idle"),h(null)}},[e,p,m,v]);const j=y!=="idle",w=async()=>{if(!(!n||!u.trim())){h(null);try{x("creating-workspace");const M=await f.mutateAsync({workspaceKind:g});x("creating-session");const T=await me.post(`/workspaces/${M.id}/sessions`,{providerId:n,prompt:u.trim()});x("starting-session"),await b.mutateAsync(T.id),await d.invalidateQueries({queryKey:ae.workspaces.list(o)}),x("idle"),r?.(),s()}catch(M){x("idle"),h(M instanceof Error?M.message:i("启动失败,请重试"))}}},E={idle:i("启动"),"creating-workspace":i("创建工作空间..."),"creating-session":i("创建会话..."),"starting-session":i("启动 Agent...")},R=(S??[]).map(({provider:M,availability:T})=>{const B=T.type!=="NOT_FOUND";return{value:M.id,label:B?M.name:`${M.name}${i(" (不可用)")}`,icon:t.jsx(Pa,{agentType:M.agentType,className:"size-4"}),disabled:!B}}),P=[{value:ls.WORKTREE,label:i("工作树模式")},{value:ls.MAIN_DIRECTORY,label:i("本地模式")}];return t.jsx(Ms,{isOpen:e,onClose:j?()=>{}:s,title:i("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{variant:"outline",onClick:s,disabled:j,children:i("取消")}),t.jsx(Te,{onClick:w,disabled:j||!n||!u.trim(),children:E[y]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("Agent")}),t.jsx(cs,{value:n,onChange:l,options:R,placeholder:i(k?"加载中...":"选择 Agent"),disabled:j||k})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("模式")}),t.jsx(cs,{value:g,onChange:M=>_(M),options:P,disabled:j})]})]}),g===ls.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:i("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:i("任务描述")}),t.jsx("textarea",{value:u,onChange:M=>c(M.target.value),rows:5,disabled:j,placeholder:i("描述你想让 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"})]}),a&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:a})]})})}function rc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function Zv(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(n=>n.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const v=e?.agentType??p?.agentType??r?.agentType??null,i=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:i,agentType:v}}function ic({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:i}=ue(),n=Zv(e,s,{providerId:p,agentType:m});return!n&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${n.title}`,children:[t.jsx(Pa,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:ad(n.label,o?12:18)})]}),t.jsx(un,{usage:r,tooltipSide:v})]})}function Jv({isOpen:e,onClose:s,taskId:r}){const{t:o}=ue(),[p,m]=C.useState("AUTO"),[v,i]=C.useState(null),[n,l]=C.useState([]),[u,c]=C.useState(null),g=ga();C.useEffect(()=>{e&&(m("AUTO"),i(null),l([]),c(null))},[e]);const _=g.isPending,y=!!v||n.length>0,x=async()=>{if(!_){if(!v&&n.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...n.length>0?{memberPresetIds:n}:{}}),s()}catch(h){if(h instanceof pa&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=_||!y;return t.jsxs(Ms,{isOpen:e,onClose:_?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:_,children:o("取消")}),t.jsx(Te,{type:"button",onClick:x,disabled:a,children:o(_?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(vd,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:l,disabled:_}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function e0({commands:e,selectedIndex:s,query:r,hasCatalog:o,title:p="Slash Commands",queryPrefix:m="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:l=!1,onSelect:u}){const c=l?"px-1.5 pb-1.5":"px-2 pb-2",g=l?"px-2 py-1.5":"px-2.5 py-2",_=l?"max-h-36":"max-h-48";return t.jsxs("div",{className:l?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${l?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:p}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?t.jsx("div",{className:`${l?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?i??`No matches for ${m}${r}`:v}):t.jsx("div",{className:`${c} ${_} overflow-y-auto`,children:e.map((y,x)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(y),className:`w-full rounded-lg border text-left transition-colors ${x===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?t.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),t.jsx("div",{className:`${l?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Gt=12,wr=8;function Wr({open:e,anchorRef:s,commands:r,selectedIndex:o,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:l,insertionHint:u,compact:c=!1,onSelect:g}){const _=C.useRef(null),[y,x]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){x(null);return}const a=s.current;if(!a)return;let h=0;const d=()=>{const S=s.current;if(!S)return;const k=S.getBoundingClientRect(),j=window.innerWidth,w=window.innerHeight,E=c?260:320,R=c?j-Gt*2:560,P=Math.min(Math.max(k.width,E),Math.max(E,R)),M=Math.min(Math.max(Gt,k.left),Math.max(Gt,j-Gt-P)),T=w-k.bottom-wr-Gt,B=k.top-wr-Gt,D=_.current?.offsetHeight??(c?220:280),F=c?240:320,H=T<180&&B>T,O=Math.max(120,Math.min(F,H?B:T)),L=H?Math.max(Gt,k.top-wr-Math.min(D,O)):Math.min(w-Gt-Math.min(D,O),k.bottom+wr);x({top:L,left:M,width:P,maxHeight:O})},f=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};f();const b=new ResizeObserver(f);return b.observe(a),_.current&&b.observe(_.current),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),window.visualViewport?.addEventListener("resize",f),window.visualViewport?.addEventListener("scroll",f),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),window.visualViewport?.removeEventListener("resize",f),window.visualViewport?.removeEventListener("scroll",f)}},[s,r.length,c,e,p,o]),!e||!y||typeof document>"u"?null:Jt.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:_,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:t.jsx(e0,{commands:r,selectedIndex:o,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:l,insertionHint:u,compact:c,onSelect:g})})}),document.body)}function t0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ue(),p=jn();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(tr,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Te,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function nc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
+
`):"- 未获取到冲突文件列表"}function oc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function s0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function r0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function i0(e,s,r,o,p){const m=nc(r),v=oc(p);return o===Vs.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
76
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...s0(e,p)].join(`
|
|
77
|
+
`)}function n0(e){const s=e.conflictOp===Vs.REBASE?"Rebase":"Merge",r=nc(e.conflictedFiles),o=[...oc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Vs.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":r0(e)].join(`
|
|
78
|
+
`)}function o0(e){if(e.teamRunId)return{type:"team_room",message:n0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:i0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function ac({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:i,worktreePath:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sessions:x,currentSessionId:a,teamRunId:h}){const{t:d}=ue(),[f,b]=C.useState(""),S=Bn(),k=sn(h??""),j=kn(),w=!!h,E=a||f,R=w?k.isPending:S.isPending,P=()=>{const F=o0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ct.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},M=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},T=o==="REBASE"?"Rebase":"Merge",B=!w&&!a&&x.length>0,D=w||!!E;return t.jsx(Ms,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:T}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Te,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(Te,{onClick:P,disabled:!D||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(F=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:F},F))})]}),w&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),B&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:F=>b(F.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),x.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!E&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function a0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function Zo(e,s,r,o){const p=Xl(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function lc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:i,onOpenChanges:n,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ue(),_=ll(),y=al(),x=jn(),[a,h]=C.useState(!1),[d,f]=C.useState(null),b=C.useMemo(()=>a0(p),[p]),S=b.additions+b.deletions,k=b.files>0&&S>0,j=(m?.conflictedFiles.length??0)>0,w=!!(m&&m.operation!=="idle"),E=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),R=(m?.uncommittedCount??0)+(m?.untrackedCount??0),P=(m?.behind??0)>0,M=(m?.ahead??0)>0,T=v||!m&&i,B=!!(i&&e&&m&&P&&!j&&!w&&!E),D=!!(i&&e&&m&&M&&!P&&!j&&!w&&!E);if(C.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const F=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):R>0?g("{count} 未提交",{count:R}):P?g("落后 {count}",{count:m?.behind??0}):g(M?"可合并":"已是最新"),H=g("{files} 个文件 · {lines} 行",{files:b.files,lines:S}),A=()=>{B&&(f(null),_.mutate(e,{onError:$=>{Zo($,g("更新失败,请稍后重试"),V=>u(V),f)}}))},O=()=>{D&&(f(null),h(!0))},L=$=>{f(null),y.mutate({id:e,commitMessage:$},{onSuccess:()=>h(!1),onError:V=>{Zo(V,g("提交失败,请稍后重试"),U=>{h(!1),u(U)},f)}})},I=()=>{y.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ee("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Ts,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[b.additions>0&&t.jsxs("span",{className:"text-success",children:["+",b.additions]}),b.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",b.deletions]})]}),j&&t.jsx(tr,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:F})]}),t.jsx(Nt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[w&&t.jsx("button",{type:"button",onClick:()=>x.mutate(e),disabled:x.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:x.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:A,disabled:!B||_.isPending||T,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(P?"同步更新":"已是最新"),children:[_.isPending?t.jsx(Ye,{size:12,className:"animate-spin"}):t.jsx(rr,{size:12}),t.jsx("span",{children:_.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!D||y.isPending||T,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:D?g("合并到 {target}",{target:r}):g("提交变更"),children:[y.isPending?t.jsx(Ye,{size:12,className:"animate-spin"}):t.jsx(Ar,{size:12}),t.jsx("span",{children:y.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(Kl,{isOpen:a,onClose:I,branchName:s,targetBranch:r,commitMessage:o,isPending:y.isPending,error:d,onConfirm:L})]})}function l0({agentType:e,workingDir:s}){return Rt({queryKey:ae.system.slashCommandCatalog(e,s),queryFn:async()=>(await me.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function c0(e,s){const r=new Set,o=[];for(const p of[...e,...s]){const m=p.command.trim().toLowerCase();!m||r.has(m)||(r.add(m),o.push(p.kind?p:{...p,kind:"builtin"}))}return o}function ni(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function d0(e){return ni(e.command)}function u0(e,s){if(!s)return 1e3;const r=d0(e),o=e.aliases?.map(ni)??[],p=[r,...o];let m=0;for(const i of p)i===s?m=Math.max(m,500):i.startsWith(s)?m=Math.max(m,400-(i.length-s.length)):i.includes(s)&&(m=Math.max(m,250-i.indexOf(s)));return m>0?m:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function Jo(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:ni(s[2]),replaceStart:r}}function cc(e,s){const r=ni(s);return r?e.map((o,p)=>({command:o,index:p,score:u0(o,r)})).filter(o=>o.score>0).sort((o,p)=>p.score-o.score||o.index-p.index||o.command.command.localeCompare(p.command.command)).map(o=>o.command):e.slice()}const h0=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],f0=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],m0=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],p0=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],g0={[Bt.CODEX]:h0,[Bt.CLAUDE_CODE]:f0,[Bt.GEMINI_CLI]:m0,[Bt.CURSOR_AGENT]:p0};function dc(e){return e.trim().toLowerCase().replace(/^\//,"")}function v0(e){return e?(g0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function x0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?dc(s[1]):null}function _0(e,s){return cc(e,dc(s))}function b0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function uc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=l0({agentType:e,workingDir:s}),u=C.useMemo(()=>c0(v0(e),l),[e,l]),c=C.useMemo(()=>x0(r),[r]),g=C.useMemo(()=>c===null?[]:_0(u,c),[u,c]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,c]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):b0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allCommands:u,query:c,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:x}}function y0({agentType:e,workingDir:s}){return Rt({queryKey:ae.system.skillCatalog(e,s),queryFn:async()=>(await me.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Bt.CODEX,staleTime:3e4})}function S0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function hc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=y0({agentType:e,workingDir:s}),c=C.useMemo(()=>e===Bt.CODEX?Jo(r):null,[e,r])?.query??null,g=C.useMemo(()=>c===null?[]:cc(l,c),[c,l]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,c]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const h=Jo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):S0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:x}}const w0="/api",C0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${w0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ss=520,Di=48,k0=4,E0=420;function j0(){const{t:e}=ue();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ea=[{status:fe.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ca,{className:"w-3 h-3"})},{status:fe.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(wa,{className:"w-3 h-3"})},{status:fe.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Sa,{className:"w-3 h-3"})},{status:fe.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(ya,{className:"w-3 h-3"})},{status:fe.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ba,{className:"w-3 h-3"})}];function N0({status:e,onChangeStatus:s}){const{t:r}=ue(),[o,p]=C.useState(!1),m=C.useRef(null);C.useEffect(()=>{if(!o)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const v=ea.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ea.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function ta({state:e,onRetry:s}){const{t:r}=ue(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function R0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),[i,n]=C.useState(""),[l,u]=C.useState(!1),[c,g]=C.useState(!1),[_,y]=C.useState(!1),[x,a]=C.useState(!1),[h,d]=C.useState(!1),[f,b]=C.useState(!1),[S,k]=C.useState(null),j=C.useRef(null),[w,E]=C.useState(!1),[R,P]=C.useState(null),[M,T]=C.useState(void 0),[B,D]=C.useState(!1),F=C.useRef(null),H=C.useRef(null),A=C.useRef(null),O=C.useRef(null),{scrollRef:L,contentRef:I,isAtBottom:$,scrollToBottom:V}=ln({resize:"smooth",initial:"instant"}),[U,W]=C.useState(!1),[q,N]=C.useState(Ss),[z,X]=C.useState(!1),K=C.useRef(0),re=C.useRef(Ss),Z=C.useRef(null),{data:se,isLoading:_e}=Cn(e?.id??""),ve=Qv(e?.id),{data:Ie}=va(e?.id??""),{data:ce}=xa(Ie?.id??""),dt=sn(Ie?.id??""),xe=Ie??null,De=!!xe,Ze=Ie===null,tt=!!(e?.id&&Ie===null),{data:Ae,isLoading:Ge}=_a(e?.id??"",tt);C.useEffect(()=>{D(!1),P(null),T(void 0)},[e?.id]);const be=C.useMemo(()=>ml(se,xe,M),[M,xe,se]);C.useEffect(()=>{M&&!se?.some(Q=>Q.id===M)&&T(void 0)},[M,se]);const Me=C.useMemo(()=>se?.find(Q=>Q.id===be),[be,se]),Be=Me?.status===Et.ACTIVE?Me.id:void 0,Le=pl(Me,xe);C.useEffect(()=>{if(!B||!se)return;se.some(le=>le.status==="ACTIVE"&&le.sessions&&le.sessions.length>0)&&D(!1)},[se,B]);const Pe=C.useMemo(()=>{if(B||!se)return null;const Q=ht=>{const pi=ht.createdAt,Fs=ht.endedAt??ht.startedAt??pi;if(!Fs)return 0;const _s=Date.parse(Fs);return Number.isNaN(_s)?0:_s},le=(ht,pi)=>{const Fs=ht.filter(_s=>pi.includes(_s.status));return Fs.length===0?null:Fs.sort((_s,Fc)=>Q(Fc)-Q(_s))[0]??null},Ve=se.filter(ht=>ht.status==="ACTIVE"&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]),yt=le(Ve,[rt.RUNNING])??le(Ve,[rt.PENDING])??le(Ve,[rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(yt)return yt;const gt=se.filter(ht=>(ht.status==="MERGED"||ht.status==="ABANDONED"||ht.status==="HIBERNATED")&&Array.isArray(ht.sessions)).flatMap(ht=>ht.sessions??[]);return le(gt,[rt.COMPLETED,rt.FAILED,rt.CANCELLED])},[se,B]),Xe=Pe?.id??"",Ce=De?R??"":Xe,ye=C.useMemo(()=>{if(!R||!se)return null;for(const Q of se){const le=Q.sessions?.find(Ve=>Ve.id===R);if(le)return le}return null},[R,se]),G=C.useMemo(()=>{if(!R||!xe?.invocations)return null;const Q=xe.invocations.filter(le=>le.sessionId===R);return Q.length===0?null:Q.sort((le,Ve)=>{const yt=Date.parse(le.updatedAt??le.createdAt??""),gt=Date.parse(Ve.updatedAt??Ve.createdAt??"");return(Number.isNaN(gt)?0:gt)-(Number.isNaN(yt)?0:yt)})[0]??null},[R,xe?.invocations]),ne=C.useMemo(()=>!G?.memberId||!xe?.members?null:xe.members.find(Q=>Q.id===G.memberId)??null,[G?.memberId,xe?.members]),oe=R?ye:Pe??null,Y=oe?.status===rt.RUNNING||oe?.status===rt.PENDING,J=!!e?.projectArchivedAt,ie=!!e?.projectRepoDeletedAt,he=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ke}=sr(),[we,Ee]=C.useState(null);C.useEffect(()=>{Ee(Pe?.providerId??null)},[Pe?.providerId]);const pe=C.useMemo(()=>!Pe||!se?!1:!se.some(le=>le.status==="ACTIVE"&&le.sessions?.some(Ve=>Ve.id===Pe.id)),[Pe,se]),je=C.useMemo(()=>{if(!(!se||B)){if(Me)return ts(Me);for(const Q of se)if(Q.status==="ACTIVE"&&ts(Q))return ts(Q);return ts(se[0])}},[B,Me,se]),Je=uc({agentType:Pe?.agentType,workingDir:je,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),qe=hc({agentType:Pe?.agentType,workingDir:je,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),it=tn(Q=>Q.setVisibleContext),Ne=!!(Le&&Be&&je&&!J),{data:Re,isLoading:ze}=En(Be??"",{enabled:Ne}),{data:bt}=ii(je,{enabled:Ne});C.useEffect(()=>{if(!(U||!Ne||!Be||!je))return it({workspaceId:Be,workingDir:je,tab:"changes"}),()=>{it(null)}},[U,Be,it,Ne,je]);const mt=Me?.sessions??[],ut=hs(Me),At=Me?.commitMessage,wt=C.useMemo(()=>gl(Me,se,e?.mainBranch??""),[Me,e?.mainBranch,se]),We=C.useMemo(()=>Re?.conflictOp&&Re.conflictedFiles.length>0?{conflictOp:Re.conflictOp,conflictedFiles:Re.conflictedFiles}:S,[Re?.conflictOp,Re?.conflictedFiles,S]),Dt=We?.targetWorkspaceId??Be,Lt=We?.targetWorktreePath??Me?.worktreePath,ms=We?.sourceBranch??ut,oi=We?.targetBranch??wt,et=ot(),ps=C.useCallback(async()=>e?.id?et.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>me.get(`/tasks/${e.id}/body`)}):null,[et,e?.id]),Ps=C.useCallback(()=>e?.id?et.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,et]);C.useEffect(()=>{if(!w)return;const Q=le=>{H.current&&!H.current.contains(le.target)&&E(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[w]);const Os=Bn(),Xt=kn(),as=ld(),ur=ol(e?.id??""),Is=In(),gs=sf(),zt=C.useMemo(()=>!se||se.some(le=>le.status==="ACTIVE")?null:se.find(le=>le.status==="HIBERNATED")??null,[se]),vs=C.useRef(null);C.useEffect(()=>{zt&&vs.current!==zt.id&&(gs.isPending||(vs.current=zt.id,gs.mutate(zt.id,{onSettled:()=>{vs.current=null}})))},[zt,gs]);const ai=C.useCallback(async()=>{if(!e?.id)return;const Q=Pe?.providerId??ke?.find(le=>le.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),d(!0);try{const Ve=(await ps())?.prompt??e.title;await as.mutateAsync(e.id),D(!0);const yt=await ur.mutateAsync({}),gt=await me.post(`/workspaces/${yt.id}/sessions`,{providerId:Q,prompt:Ve});await Is.mutateAsync(gt.id),await et.invalidateQueries({queryKey:ae.workspaces.list(e.id)})}catch(le){console.error("[retry] failed:",le),D(!1)}finally{d(!1)}}},[e?.id,e?.title,Pe?.providerId,ke,ps,as,ur,Is,et]),Bs=C.useCallback(async()=>{e?.id&&(await ps(),u(!0))},[ps,e?.id]),hr=C.useCallback(()=>{Me?.id&&Xt.mutate({workspaceId:Me.id})},[Xt,Me?.id]),li=C.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),fr=C.useCallback(Q=>{P(Q),requestAnimationFrame(()=>{V()})},[V]),mr=C.useCallback(()=>{P(null)},[]),xs=C.useCallback(Q=>{k(Q??null),b(!0)},[]),ci=C.useCallback(Q=>dt.mutateAsync(Q),[dt]),Vt=C.useCallback(()=>{et.invalidateQueries({queryKey:cd.all})},[et]),{isConnected:pr,isLoadingSnapshot:Yt,logs:te,entries:ge,attach:He}=Ma({sessionId:Ce,sessionStatus:oe?.status,onExit:C.useCallback(()=>{et.invalidateQueries({queryKey:["workspaces"]})},[et])});C.useEffect(()=>{if(!e?.id)return;const Q=Zt.connect();Q.emit(ws.SUBSCRIBE,{topic:"task",id:e.id});const le=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:["tasks"]}),Vt())},Ve=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Vt())},yt=gt=>{gt.taskId===e.id&&(et.invalidateQueries({queryKey:ae.workspaces.list(e.id)}),Vt())};return Q.on(at.TASK_UPDATED,le),Q.on(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ve),Q.on(at.WORKSPACE_HIBERNATED,yt),()=>{Q.off(at.TASK_UPDATED,le),Q.off(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ve),Q.off(at.WORKSPACE_HIBERNATED,yt),Q.emit(ws.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,et,Vt]),C.useEffect(()=>{if(!Ce)return;const Q=Zt.connect(),le=Ve=>{Ve.sessionId===Ce&&(et.invalidateQueries({queryKey:["workspaces"]}),Vt())};return Q.on(at.SESSION_COMPLETED,le),()=>{Q.off(at.SESSION_COMPLETED,le)}},[Ce,et,Vt]);const{todos:Fe}=Ta(ge),{files:Ct,addFiles:pt,removeFile:$e,clear:Wt,buildMarkdownLinks:Ht,hasFiles:Pt,isUploading:gr}=an(),Rc=C.useMemo(()=>rc(oe),[oe?.tokenUsage]),zn=Ra(te,Rc);C.useEffect(()=>{Ce&&pr&&He()},[Ce,pr,He]);const Wn=C.useRef(e?.id);C.useEffect(()=>{if(Wn.current!==e?.id&&L.current){const Q=L.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}Wn.current=e?.id},[e?.id,L]);const di=tc(),ui=C.useRef(!1),Hn=C.useCallback(async()=>{if(!i.trim()&&!Pt||!Ce||ui.current||gr)return;ui.current=!0;const Q=Ht(),le=[i.trim(),Q].filter(Boolean).join(`
|
|
79
79
|
|
|
80
|
-
`);o(""),Ht(),A.current&&(A.current.style.height="60px"),Os.mutate({id:be,message:ne,providerId:He??void 0},{onSuccess:()=>{Fe()},onSettled:()=>{ui.current=!1}})},[i,be,Os,Fe,Pt,vr,Wt,Ht,He]),Rc=C.useCallback(async()=>{be&&(await di.mutateAsync(be),et.invalidateQueries({queryKey:["workspaces"]}))},[be,di,et]),Ac=C.useCallback(Q=>{const ne=Q.target.files;ne&&ne.length>0&&pt(Array.from(ne)),Q.target.value=""},[pt]),Mc=C.useCallback(Q=>{const ne=Q.clipboardData.items,Ke=[];for(const yt of ne)if(yt.kind==="file"){const gt=yt.getAsFile();gt&&Ke.push(gt)}Ke.length>0&&(Q.preventDefault(),pt(Ke))},[pt]),[$n,hi]=C.useState(!1),Tc=C.useCallback(Q=>{Q.preventDefault(),hi(!0)},[]),Dc=C.useCallback(Q=>{Q.preventDefault(),hi(!1)},[]),Lc=C.useCallback(Q=>{Q.preventDefault(),hi(!1);const ne=Q.dataTransfer.files;ne.length>0&&pt(Array.from(ne))},[pt]),$t=C.useCallback(Q=>{const ne=J.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ke=ne?Math.max(Ss,ne-Di-C0-k0):Ss;return Math.max(Ss,Math.min(Math.round(Q),Ke))},[]),fi=C.useCallback(Q=>{const ne=Q.clientX-X.current;N($t(re.current-ne))},[$t]),mi=C.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(z)return document.addEventListener("mousemove",fi),document.addEventListener("mouseup",mi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",fi),document.removeEventListener("mouseup",mi),document.body.style.cursor="",document.body.style.userSelect=""}},[mi,fi,z]);const Pc=C.useCallback(Q=>{Q.preventDefault(),X.current=Q.clientX,re.current=K,V(!0)},[K]);C.useEffect(()=>{!q||z||N(Q=>$t(Q))},[$t,q,z]),C.useEffect(()=>{if(!q)return;const Q=()=>{N(ne=>$t(ne))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[$t,q]);const Oc=C.useCallback(()=>{N(Q=>$t(Q)),W(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[$t]),Ic=C.useCallback(Q=>{o(Q.target.value);const ne=Q.target;ne.style.height="auto";const Ke=ne.scrollHeight;ne.style.height=`${Math.max(60,Math.min(Ke,300))}px`},[]),Un=Ye&&Ie?t.jsx(ac,{workspaceId:Ie,branchName:ut,targetBranch:wt,commitMessage:At,changes:bt,gitStatus:qe,isGitStatusLoading:Ge,canRunGitOperations:Pe,onOpenChanges:Oc,onRefreshCommitMessage:Ps,onConflict:xs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(j0,{status:e.status,onChangeStatus:!de&&n?Q=>n(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:fr,disabled:!we||de,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(rr,{size:16})}),(s||Ze)&&!de&&t.jsxs("div",{className:"relative",ref:$,children:[t.jsx("button",{onClick:()=>E(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(Oa,{size:16})}),w&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[Ze&&t.jsxs("button",{onClick:()=>{g(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(es,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(kd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{y(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),Pe&&Ie&&qe&&t.jsx(e0,{workspaceId:Ie,gitStatus:qe,onResolve:()=>xs()}),t.jsxs("div",{ref:J,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ee&&ge?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(rc,{session:Z,providers:Te,usage:zn,providerIdFallback:G?.providerId,agentTypeFallback:Z?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(ke,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:pr,children:[t.jsx(Gs,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:I,className:"w-full max-w-4xl mx-auto",children:Yt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):te.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(ae?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:te})})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Oe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Rr,{todos:Oe})})})]}):t.jsx(hl,{teamRun:ge,messages:oe??ge.messages??[],readOnly:de,readOnlyMessage:Ve,onSendMessage:ci,onViewInvocationSession:mr,changeSummaryBar:Un,centered:!0}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:I,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(it||Se?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:it?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Se?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(un,{urlTransform:w0,components:hn,children:Se.body})}):null}),pe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[pe.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:pe.currentIndex,total:pe.totalCommands,command:pe.currentCommand})})]}),pe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),pe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:pe.error})})]}),!de&&p&&(ve||Me)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ta,{state:p,onRetry:p.status==="failed"?Bs:void 0})}):null,ve?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):Me?Yt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):te.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(ae?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:te}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Ut,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(de?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:de?Ve:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!de&&p?t.jsx(ta,{state:p}):null,!de&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(ke,{onClick:Bs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),Ze&&t.jsxs(ke,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(es,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Oe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Rr,{todos:Oe})})}),de?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Ve})})}):Ae?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(ke,{size:"sm",onClick:Bs,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Tc,onDragLeave:Dc,onDrop:Lc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Un,t.jsxs("div",{ref:F,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${$n?"border-info bg-info/5":"border-border"}`,children:[t.jsx(an,{files:Ct,onRemove:ze}),t.jsx("textarea",{ref:A,value:i,onChange:Ic,onPaste:Mc,onKeyDown:Q=>{Ce.handleKeyDown(Q)||We.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),Wn())},rows:1,placeholder:v($n?"Drop files here...":Me&&!ae?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:O,type:"file",multiple:!0,className:"hidden",onChange:Ac}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>O.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(dn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ne&&Te&&t.jsx(Aa,{providers:Te,currentProviderId:He,agentType:Ne.agentType,onSelect:Re}),t.jsx(cn,{usage:zn}),ae&&!i.trim()&&!Pt?t.jsx("button",{onClick:Rc,disabled:di.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Rs,{size:14})}):t.jsx("button",{onClick:Wn,disabled:!i.trim()&&!Pt||vr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Pt)&&!vr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(ln,{size:18})})]})]})]})]}),t.jsx(Wr,{open:We.query!==null,anchorRef:F,commands:We.filteredCommands,selectedIndex:We.selectedIndex,query:We.query??"",hasCatalog:We.allCommands.length>0,onSelect:We.applyCommand}),t.jsx(Wr,{open:Ce.query!==null,anchorRef:F,commands:Ce.filteredSkills,selectedIndex:Ce.selectedIndex,query:Ce.query??"",hasCatalog:Ce.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ce.applySkill})]})]})}),q&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Pc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:q?Di+K:Di},children:t.jsx(Jl,{sessionId:Me||void 0,workspaceId:xe,workingDir:we,projectId:e.projectId,readOnly:de,repoDeleted:fe,teamRun:ge,teamStatus:ge?t.jsx(xl,{teamRun:ge,workspaces:se,selectedWorkspaceId:xe,onSelectWorkspace:T,onViewInvocationSession:mr}):void 0,workspaces:se,selectedWorkspaceId:xe,onSelectWorkspace:T,variant:"rail",expanded:q,onExpandedChange:Q=>{Q&&N(ne=>$t(ne)),W(Q)},minContentWidth:Ss,tabRef:j,gitProps:Pe&&Ie?{branchName:ut,targetBranch:wt,commitMessage:At,canRunGitOperations:!0,onRefreshCommitMessage:Ps,onConflict:xs,onResolveConflicts:()=>xs()}:void 0})})]}),!de&&t.jsx(tc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Se?.title??e.title,taskDescription:Se?.body??"",taskPrompt:Se?.prompt,onStarted:()=>m?.(e.id)}),Ze&&!de&&t.jsx(Zv,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),Pe&&Dt&&Be&&t.jsx(oc,{open:f,onOpenChange:Q=>{b(Q),Q||k(null)},workspaceId:Dt,conflictOp:Be.conflictOp,conflictedFiles:Be.conflictedFiles,sourceBranch:ms,targetBranch:oi,operation:qe?.operation,worktreePath:Lt,mergeAborted:Be.mergeAborted,mergeStrategy:Be.mergeStrategy,sourceWorkspaceId:Be.sourceWorkspaceId,targetWorkspaceId:Be.targetWorkspaceId,sourceWorktreePath:Be.sourceWorktreePath,targetWorktreePath:Be.targetWorktreePath,sessions:mt,currentSessionId:Ee?void 0:Me,teamRunId:ge?.id}),t.jsx(qr,{isOpen:x,onClose:()=>a(!1),onConfirm:ai,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Nn,{isOpen:_,onClose:()=>y(!1),onConfirm:li,taskId:e.id,taskTitle:e.title,workspaces:se,isLoading:r})]}):t.jsx(E0,{})}function Fn(e){switch(e){case It.TODO:return ue.Pending;case It.IN_PROGRESS:return ue.Running;case It.IN_REVIEW:return ue.Review;case It.DONE:return ue.Done;case It.CANCELLED:return ue.Cancelled}}function R0(e){switch(e){case ue.Pending:return It.TODO;case ue.Running:return It.IN_PROGRESS;case ue.Review:return It.IN_REVIEW;case ue.Done:return It.DONE;case ue.Cancelled:return It.CANCELLED}}function A0(e){switch(e){case Bt.CLAUDE_CODE:return"Claude Code";case Bt.GEMINI_CLI:return"Gemini CLI";case Bt.CURSOR_AGENT:return"Cursor Agent";case Bt.CODEX:return"Codex"}}const $r=["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 hc(e,s){let r=0;for(let n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n)|0;return Math.abs(r)%s}function fc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function mc(e){return e?e.workspaceKind===ls.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function M0(e){return{id:e.id,name:e.name,color:e.color||$r[hc(e.name,$r.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function T0(e){const s=fc(e);if(!s)return{agent:"—",branch:"—"};const r=mc(s),n=s.sessions;if(n&&n.length>0){const p=n[n.length-1];return{agent:A0(p.agentType),branch:r}}return{agent:"—",branch:r}}function D0(e){const{agent:s,branch:r}=T0(e.workspaces),n=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Fn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,projectArchivedAt:n?.archivedAt??null,projectRepoDeletedAt:n?.repoDeletedAt??null}}function L0(e,s,r){const n=fc(e.workspaces,r),p=mc(n);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||$r[hc(s.name,$r.length)],title:e.titlePreview??e.title,status:Fn(e.status),branch:p,mainBranch:n?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const sa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function P0(e){const s=e.split("/");return s[s.length-1]||e}function O0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function I0({workingDir:e,filePath:s,type:r}){const{t:n}=ce(),{data:p,isLoading:m,isError:v}=Ul(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:n("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:n("No diff content available.")});const o=i.split(`
|
|
81
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:
|
|
82
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:o.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function U0({entry:e,workingDir:s,hash:r}){const[n,p]=C.useState(!1),m=ia[e.status]||ia.M,v=W0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",n&&"bg-neutral-50"),children:[t.jsx("span",{className:ee("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:H0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:n?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})})]}),n&&t.jsx($0,{workingDir:s,hash:r,filePath:e.path})]})}function q0({commit:e,workingDir:s}){const{t:r}=ce(),[n,p]=C.useState(!1),{data:m,isLoading:v}=Pn(s,n?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(o=>!o),className:ee("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",n&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:ee("w-2.5 h-2.5 rounded-full shrink-0",n?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:z0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:n?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})})]}),n&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Xe,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(o=>t.jsx(U0,{entry:o,workingDir:s,hash:e.hash},o.path))})]})]})}function K0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:n,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=mn({queryKey:ie.git.log(e||""),queryFn:({pageParam:l=0})=>he.get("/git/log",{params:{workingDir:e||"",limit:String(Li),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Li?void 0:u.length*Li,enabled:!!e}),o=r?.pages.flatMap(l=>l.commits)||[];return e?n?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Xe,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):o.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(As,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:o.map(l=>t.jsx(q0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Xe,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const X0="/api",V0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${X0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Y0({status:e}){const s={[ue.Running]:"bg-blue-500",[ue.Review]:"bg-amber-500",[ue.Pending]:"bg-neutral-400",[ue.Done]:"bg-emerald-500",[ue.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const G0=[{key:"chat",label:"Chat",icon:Kr},{key:"changes",label:"Changes",icon:Ts},{key:"history",label:"History",icon:As},{key:"workspace",label:"Workspace",icon:Xr}],Q0=[{key:"chat",label:"Team room",icon:Kr},{key:"team-status",label:"Team Status",icon:us},{key:"changes",label:"Changes",icon:Ts},{key:"workspace",label:"Workspace",icon:Xr}];function na({state:e,onRetry:s}){const{t:r}=ce(),n=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:n}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(ke,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:n})]})}function Z0({task:e,onBack:s,onDeleteTask:r,isDeleting:n,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ce(),i=tn(te=>te.setVisibleContext),[o,l]=C.useState("chat"),[u,c]=C.useState(""),[g,_]=C.useState(!1),[y,x]=C.useState(!1),[a,h]=C.useState(!1),[d,f]=C.useState(null),[b,S]=C.useState(void 0),k=C.useRef(null),j=C.useRef(null),w=C.useRef(null),E=C.useRef(null),{scrollRef:R,contentRef:P,isAtBottom:M,scrollToBottom:T}=on({resize:"smooth",initial:"instant"}),B=ot();C.useEffect(()=>{if(!a)return;const te=me=>{j.current&&!j.current.contains(me.target)&&h(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[a]);const{data:D,isLoading:F}=Cn(e.id),{data:$}=va(e.id),{data:A}=xa($?.id??""),O=sn($?.id??""),L=$??null,I=L?Q0:G0,U=$===null,{data:Y,isLoading:q}=_a(e.id,U),W=!!e.projectArchivedAt,K=!!e.projectRepoDeletedAt,N=v(K?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");C.useEffect(()=>{S(void 0),f(null)},[e.id]),C.useEffect(()=>{L&&o==="history"&&l("chat"),!L&&o==="team-status"&&l("chat")},[o,L]);const z=C.useMemo(()=>fl(D,L,b),[b,L,D]);C.useEffect(()=>{b&&!D?.some(te=>te.id===b)&&S(void 0)},[b,D]);const V=C.useMemo(()=>D?.find(te=>te.id===z),[z,D]),X=C.useMemo(()=>{if(D){if(V)return ts(V);for(const te of D)if(te.status==="ACTIVE"&&ts(te))return ts(te);return ts(D[0])}},[V,D]),re=V?.status===Et.ACTIVE?V.id:void 0,J=ml(V,L),se=V?.branchName??"",ve=V?.commitMessage,pe=C.useMemo(()=>pl(V,D,e?.mainBranch??""),[V,e?.mainBranch,D]),Le=!!(J&&re&&X&&!W),{data:oe,isLoading:dt}=En(re??"",{enabled:Le}),{data:ge}=ii(X,{enabled:Le}),Ee=ge?.committed?.length,[Ze,tt]=C.useState(!1),[Se,it]=C.useState(null);C.useEffect(()=>{const te=o==="changes"||o==="chat"&&Le?"changes":o==="history"?"history":null;if(!re||!X||!te){i(null);return}return i({workspaceId:re,workingDir:X,tab:te}),()=>{i(null)}},[o,re,i,Le,X]);const xe=C.useMemo(()=>oe?.conflictOp&&oe.conflictedFiles.length>0?{conflictOp:oe.conflictOp,conflictedFiles:oe.conflictedFiles}:Se,[oe?.conflictOp,oe?.conflictedFiles,Se]),je=xe?.targetWorkspaceId??re,Ie=xe?.targetWorktreePath??V?.worktreePath,Pe=xe?.sourceBranch??se,Ne=xe?.targetBranch??pe,Me=V?.sessions??[],be=C.useCallback(te=>{it(te??null),tt(!0)},[]),ye=C.useCallback(()=>e?.id?B.invalidateQueries({queryKey:ie.workspaces.list(e.id)}):Promise.resolve(),[e?.id,B]),H=C.useCallback(async()=>B.fetchQuery({queryKey:ie.tasks.body(e.id),queryFn:()=>he.get(`/tasks/${e.id}/body`)}),[B,e.id]),G=C.useMemo(()=>{if(!D)return null;const te=D.filter(ze=>ze.status==="ACTIVE"&&Array.isArray(ze.sessions)).flatMap(ze=>ze.sessions??[]),me=ze=>{const Ht=ze.createdAt,Wt=ze.endedAt??ze.startedAt??Ht;if(!Wt)return 0;const Pt=Date.parse(Wt);return Number.isNaN(Pt)?0:Pt},Fe=ze=>{const Ht=te.filter(Wt=>ze.includes(Wt.status));return Ht.length===0?null:Ht.sort((Wt,Pt)=>me(Pt)-me(Wt))[0]??null},Oe=Fe([rt.RUNNING])??Fe([rt.PENDING])??Fe([rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Oe)return Oe;const pt=D.filter(ze=>(ze.status==="ABANDONED"||ze.status==="MERGED"||ze.status==="HIBERNATED")&&Array.isArray(ze.sessions)).flatMap(ze=>ze.sessions??[]).filter(ze=>[rt.COMPLETED,rt.FAILED,rt.CANCELLED].includes(ze.status));return pt.length===0?null:pt.sort((ze,Ht)=>me(Ht)-me(ze))[0]??null},[D]),Z=G?.id??"",ae=L?d??"":Z,de=C.useMemo(()=>{if(!d||!D)return null;for(const te of D){const me=te.sessions?.find(Fe=>Fe.id===d);if(me)return me}return null},[d,D]),fe=C.useMemo(()=>{if(!d||!L?.invocations)return null;const te=L.invocations.filter(me=>me.sessionId===d);return te.length===0?null:te.sort((me,Fe)=>{const Oe=Date.parse(me.updatedAt??me.createdAt??""),Ct=Date.parse(Fe.updatedAt??Fe.createdAt??"");return(Number.isNaN(Ct)?0:Ct)-(Number.isNaN(Oe)?0:Oe)})[0]??null},[d,L?.invocations]),Ve=C.useMemo(()=>!fe?.memberId||!L?.members?null:L.members.find(te=>te.id===fe.memberId)??null,[fe?.memberId,L?.members]),Te=d?de:G??null,He=Te?.status===rt.RUNNING||Te?.status===rt.PENDING,Re=C.useMemo(()=>!G||!D?!1:!D.some(me=>me.status==="ACTIVE"&&me.sessions?.some(Fe=>Fe.id===G.id)),[G,D]),{data:Ae}=sr(),[we,We]=C.useState(null),Ce=we?.sessionId===Z?we.providerId:G?.providerId??null,Je=C.useCallback(te=>{We({sessionId:Z,providerId:te})},[Z]),Ye=dc({agentType:G?.agentType,workingDir:X,input:u,setInput:c,textareaRef:w,minHeight:40,maxHeight:140}),qe=uc({agentType:G?.agentType,workingDir:X,input:u,setInput:c,textareaRef:w,minHeight:40,maxHeight:140}),Ge=X&&V?V.id:void 0,bt=Bn(),mt=kn(),ut=ec(),{isConnected:At,isLoadingSnapshot:wt,logs:Be,entries:Dt,attach:Lt}=Ma({sessionId:ae,sessionStatus:Te?.status,onExit:C.useCallback(()=>{B.invalidateQueries({queryKey:["workspaces"]})},[B])}),{todos:ms}=Ta(Dt),{files:oi,addFiles:et,removeFile:ps,clear:Ps,buildMarkdownLinks:Os,hasFiles:Xt,isUploading:as}=nn(),hr=C.useMemo(()=>sc(Te),[Te?.tokenUsage]),Is=Ra(Be,hr);C.useEffect(()=>{ae&&At&&Lt()},[ae,At,Lt]);const gs=C.useRef(null);C.useEffect(()=>{if(gs.current!==e.id&&R.current){const te=R.current;requestAnimationFrame(()=>{te.scrollTop=te.scrollHeight})}gs.current=e.id},[e.id,R]);const zt=C.useRef(!1),vs=C.useCallback(async()=>{if(!u.trim()&&!Xt||!Z||zt.current||as)return;zt.current=!0;const te=Os(),me=[u.trim(),te].filter(Boolean).join(`
|
|
80
|
+
`);n(""),Wt(),A.current&&(A.current.style.height="60px"),Os.mutate({id:Ce,message:le,providerId:we??void 0},{onSuccess:()=>{He()},onSettled:()=>{ui.current=!1}})},[i,Ce,Os,He,Pt,gr,Ht,Wt,we]),Ac=C.useCallback(async()=>{Ce&&(await di.mutateAsync(Ce),et.invalidateQueries({queryKey:["workspaces"]}))},[Ce,di,et]),Mc=C.useCallback(Q=>{const le=Q.target.files;le&&le.length>0&&pt(Array.from(le)),Q.target.value=""},[pt]),Tc=C.useCallback(Q=>{const le=Q.clipboardData.items,Ve=[];for(const yt of le)if(yt.kind==="file"){const gt=yt.getAsFile();gt&&Ve.push(gt)}Ve.length>0&&(Q.preventDefault(),pt(Ve))},[pt]),[$n,hi]=C.useState(!1),Dc=C.useCallback(Q=>{Q.preventDefault(),hi(!0)},[]),Lc=C.useCallback(Q=>{Q.preventDefault(),hi(!1)},[]),Pc=C.useCallback(Q=>{Q.preventDefault(),hi(!1);const le=Q.dataTransfer.files;le.length>0&&pt(Array.from(le))},[pt]),$t=C.useCallback(Q=>{const le=Z.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ve=le?Math.max(Ss,le-Di-k0-E0):Ss;return Math.max(Ss,Math.min(Math.round(Q),Ve))},[]),fi=C.useCallback(Q=>{const le=Q.clientX-K.current;N($t(re.current-le))},[$t]),mi=C.useCallback(()=>{X(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(z)return document.addEventListener("mousemove",fi),document.addEventListener("mouseup",mi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",fi),document.removeEventListener("mouseup",mi),document.body.style.cursor="",document.body.style.userSelect=""}},[mi,fi,z]);const Oc=C.useCallback(Q=>{Q.preventDefault(),K.current=Q.clientX,re.current=q,X(!0)},[q]);C.useEffect(()=>{!U||z||N(Q=>$t(Q))},[$t,U,z]),C.useEffect(()=>{if(!U)return;const Q=()=>{N(le=>$t(le))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[$t,U]);const Ic=C.useCallback(()=>{N(Q=>$t(Q)),W(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[$t]),Bc=C.useCallback(Q=>{n(Q.target.value);const le=Q.target;le.style.height="auto";const Ve=le.scrollHeight;le.style.height=`${Math.max(60,Math.min(Ve,300))}px`},[]),Un=Ne&&Be?t.jsx(lc,{workspaceId:Be,branchName:ut,targetBranch:wt,commitMessage:At,changes:bt,gitStatus:Re,isGitStatusLoading:ze,canRunGitOperations:Le,onOpenChanges:Ic,onRefreshCommitMessage:Ps,onConflict:xs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(N0,{status:e.status,onChangeStatus:!J&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:hr,disabled:!je||J,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(Kr,{size:16})}),(s||Ze)&&!J&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsx("button",{onClick:()=>E(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(Ia,{size:16})}),w&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[Ze&&t.jsxs("button",{onClick:()=>{g(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(es,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Ed,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{y(!0),E(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),Le&&Be&&Re&&t.jsx(t0,{workspaceId:Be,gitStatus:Re,onResolve:()=>xs()}),t.jsxs("div",{ref:Z,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:De&&xe?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ic,{session:oe,providers:ke,usage:zn,providerIdFallback:ne?.providerId,agentTypeFallback:oe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:mr,children:[t.jsx(Gs,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:I,className:"w-full max-w-4xl mx-auto",children:Yt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):te.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Y?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(jr,{logs:te})})}),!$&&t.jsxs("button",{onClick:()=>V(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Nr,{todos:Fe})})})]}):t.jsx(fl,{teamRun:xe,messages:ce??xe.messages??[],readOnly:J,readOnlyMessage:he,onSendMessage:ci,onViewInvocationSession:fr,changeSummaryBar:Un,centered:!0}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:I,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ge||Ae?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ge?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ae?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(rn,{urlTransform:C0,components:nn,children:Ae.body})}):null}),ve&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ve.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:ve.currentIndex,total:ve.totalCommands,command:ve.currentCommand})})]}),ve.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ve.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ve.error})})]}),!J&&p&&(_e||Xe)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ta,{state:p,onRetry:p.status==="failed"?Bs:void 0})}):null,_e?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):Xe?Yt?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):te.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Y?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(jr,{logs:te}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Ut,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(J?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:J?he:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!J&&p?t.jsx(ta,{state:p}):null,!J&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Te,{onClick:Bs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),Ze&&t.jsxs(Te,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(es,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>V(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Nr,{todos:Fe})})}),J?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:he})})}):pe?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:Bs,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Dc,onDragLeave:Lc,onDrop:Pc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Un,t.jsxs("div",{ref:F,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${$n?"border-info bg-info/5":"border-border"}`,children:[t.jsx(cn,{files:Ct,onRemove:$e}),t.jsx("textarea",{ref:A,value:i,onChange:Bc,onPaste:Tc,onKeyDown:Q=>{qe.handleKeyDown(Q)||Je.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),Hn())},rows:1,placeholder:v($n?"Drop files here...":Xe&&!Y?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:O,type:"file",multiple:!0,className:"hidden",onChange:Mc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>O.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(hn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Pe&&ke&&t.jsx(Aa,{providers:ke,currentProviderId:we,agentType:Pe.agentType,onSelect:Ee}),t.jsx(un,{usage:zn}),Y&&!i.trim()&&!Pt?t.jsx("button",{onClick:Ac,disabled:di.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Rs,{size:14})}):t.jsx("button",{onClick:Hn,disabled:!i.trim()&&!Pt||gr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Pt)&&!gr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(dn,{size:18})})]})]})]})]}),t.jsx(Wr,{open:Je.query!==null,anchorRef:F,commands:Je.filteredCommands,selectedIndex:Je.selectedIndex,query:Je.query??"",hasCatalog:Je.allCommands.length>0,onSelect:Je.applyCommand}),t.jsx(Wr,{open:qe.query!==null,anchorRef:F,commands:qe.filteredSkills,selectedIndex:qe.selectedIndex,query:qe.query??"",hasCatalog:qe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:qe.applySkill})]})]})}),U&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Oc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:U?Di+q:Di},children:t.jsx(ec,{sessionId:Xe||void 0,workspaceId:be,workingDir:je,projectId:e.projectId,readOnly:J,repoDeleted:ie,teamRun:xe,teamStatus:xe?t.jsx(_l,{teamRun:xe,workspaces:se,selectedWorkspaceId:be,onSelectWorkspace:T,onViewInvocationSession:fr}):void 0,workspaces:se,selectedWorkspaceId:be,onSelectWorkspace:T,variant:"rail",expanded:U,onExpandedChange:Q=>{Q&&N(le=>$t(le)),W(Q)},minContentWidth:Ss,tabRef:j,gitProps:Le&&Be?{branchName:ut,targetBranch:wt,commitMessage:At,canRunGitOperations:!0,onRefreshCommitMessage:Ps,onConflict:xs,onResolveConflicts:()=>xs()}:void 0})})]}),!J&&t.jsx(sc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Ae?.title??e.title,taskDescription:Ae?.body??"",taskPrompt:Ae?.prompt,onStarted:()=>m?.(e.id)}),Ze&&!J&&t.jsx(Jv,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),Le&&Dt&&We&&t.jsx(ac,{open:f,onOpenChange:Q=>{b(Q),Q||k(null)},workspaceId:Dt,conflictOp:We.conflictOp,conflictedFiles:We.conflictedFiles,sourceBranch:ms,targetBranch:oi,operation:Re?.operation,worktreePath:Lt,mergeAborted:We.mergeAborted,mergeStrategy:We.mergeStrategy,sourceWorkspaceId:We.sourceWorkspaceId,targetWorkspaceId:We.targetWorkspaceId,sourceWorktreePath:We.sourceWorktreePath,targetWorktreePath:We.targetWorktreePath,sessions:mt,currentSessionId:De?void 0:Xe,teamRunId:xe?.id}),t.jsx(Ur,{isOpen:x,onClose:()=>a(!1),onConfirm:ai,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Nn,{isOpen:_,onClose:()=>y(!1),onConfirm:li,taskId:e.id,taskTitle:e.title,workspaces:se,isLoading:r})]}):t.jsx(j0,{})}function Fn(e){switch(e){case It.TODO:return fe.Pending;case It.IN_PROGRESS:return fe.Running;case It.IN_REVIEW:return fe.Review;case It.DONE:return fe.Done;case It.CANCELLED:return fe.Cancelled}}function A0(e){switch(e){case fe.Pending:return It.TODO;case fe.Running:return It.IN_PROGRESS;case fe.Review:return It.IN_REVIEW;case fe.Done:return It.DONE;case fe.Cancelled:return It.CANCELLED}}function M0(e){switch(e){case Bt.CLAUDE_CODE:return"Claude Code";case Bt.GEMINI_CLI:return"Gemini CLI";case Bt.CURSOR_AGENT:return"Cursor Agent";case Bt.CODEX:return"Codex"}}const Hr=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function fc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function mc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function pc(e){return e?e.workspaceKind===ls.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function T0(e){return{id:e.id,name:e.name,color:e.color||Hr[fc(e.name,Hr.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function D0(e){const s=mc(e);if(!s)return{agent:"—",branch:"—"};const r=pc(s),o=s.sessions;if(o&&o.length>0){const p=o[o.length-1];return{agent:M0(p.agentType),branch:r}}return{agent:"—",branch:r}}function L0(e){const{agent:s,branch:r}=D0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Fn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function P0(e,s,r){const o=mc(e.workspaces,r),p=pc(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Hr[fc(s.name,Hr.length)],title:e.titlePreview??e.title,status:Fn(e.status),branch:p,mainBranch:o?.baseBranch??s.mainBranch??"main",description:e.description??"",projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const sa={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 O0(e){const s=e.split("/");return s[s.length-1]||e}function I0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function B0({workingDir:e,filePath:s,type:r}){const{t:o}=ue(),{data:p,isLoading:m,isError:v}=ql(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
81
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function F0({entry:e,type:s,workingDir:r}){const[o,p]=C.useState(!1),m=sa[e.status]||sa.M,v=I0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:ee("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:O0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(B0,{workingDir:r,filePath:e.path,type:s})]})}function ra({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ue(),[v,i]=C.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(n=>t.jsx(F0,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function z0({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:o,isError:p}=ii(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ye,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ts,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(ra,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(ra,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Li=50,ia={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 W0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?ft("{count}s ago",{count:r}):r<3600?ft("{count}m ago",{count:Math.floor(r/60)}):r<86400?ft("{count}h ago",{count:Math.floor(r/3600)}):r<604800?ft("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function H0(e){const s=e.split("/");return s[s.length-1]||e}function $0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function U0({workingDir:e,hash:s,filePath:r}){const{t:o}=ue(),{data:p,isLoading:m,isError:v}=On(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
82
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function q0({entry:e,workingDir:s,hash:r}){const[o,p]=C.useState(!1),m=ia[e.status]||ia.M,v=$0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:ee("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:H0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(U0,{workingDir:s,hash:r,filePath:e.path})]})}function K0({commit:e,workingDir:s}){const{t:r}=ue(),[o,p]=C.useState(!1),{data:m,isLoading:v}=Pn(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:ee("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:ee("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:W0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(xt,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>t.jsx(q0,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function X0({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=mn({queryKey:ae.git.log(e||""),queryFn:({pageParam:l=0})=>me.get("/git/log",{params:{workingDir:e||"",limit:String(Li),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Li?void 0:u.length*Li,enabled:!!e}),n=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ye,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):n.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(As,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(l=>t.jsx(K0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const V0="/api",Y0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${V0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function G0({status:e}){const s={[fe.Running]:"bg-blue-500",[fe.Review]:"bg-amber-500",[fe.Pending]:"bg-neutral-400",[fe.Done]:"bg-emerald-500",[fe.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Q0=[{key:"chat",label:"Chat",icon:qr},{key:"changes",label:"Changes",icon:Ts},{key:"history",label:"History",icon:As},{key:"workspace",label:"Workspace",icon:Xr}],Z0=[{key:"chat",label:"Team room",icon:qr},{key:"team-status",label:"Team Status",icon:us},{key:"changes",label:"Changes",icon:Ts},{key:"workspace",label:"Workspace",icon:Xr}];function na({state:e,onRetry:s}){const{t:r}=ue(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function J0({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),i=tn(te=>te.setVisibleContext),[n,l]=C.useState("chat"),[u,c]=C.useState(""),[g,_]=C.useState(!1),[y,x]=C.useState(!1),[a,h]=C.useState(!1),[d,f]=C.useState(null),[b,S]=C.useState(void 0),k=C.useRef(null),j=C.useRef(null),w=C.useRef(null),E=C.useRef(null),{scrollRef:R,contentRef:P,isAtBottom:M,scrollToBottom:T}=ln({resize:"smooth",initial:"instant"}),B=ot();C.useEffect(()=>{if(!a)return;const te=ge=>{j.current&&!j.current.contains(ge.target)&&h(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[a]);const{data:D,isLoading:F}=Cn(e.id),{data:H}=va(e.id),{data:A}=xa(H?.id??""),O=sn(H?.id??""),L=H??null,I=L?Z0:Q0,$=H===null,{data:V,isLoading:U}=_a(e.id,$),W=!!e.projectArchivedAt,q=!!e.projectRepoDeletedAt,N=v(q?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");C.useEffect(()=>{S(void 0),f(null)},[e.id]),C.useEffect(()=>{L&&n==="history"&&l("chat"),!L&&n==="team-status"&&l("chat")},[n,L]);const z=C.useMemo(()=>ml(D,L,b),[b,L,D]);C.useEffect(()=>{b&&!D?.some(te=>te.id===b)&&S(void 0)},[b,D]);const X=C.useMemo(()=>D?.find(te=>te.id===z),[z,D]),K=C.useMemo(()=>{if(D){if(X)return ts(X);for(const te of D)if(te.status==="ACTIVE"&&ts(te))return ts(te);return ts(D[0])}},[X,D]),re=X?.status===Et.ACTIVE?X.id:void 0,Z=pl(X,L),se=X?.branchName??"",_e=X?.commitMessage,ve=C.useMemo(()=>gl(X,D,e?.mainBranch??""),[X,e?.mainBranch,D]),Ie=!!(Z&&re&&K&&!W),{data:ce,isLoading:dt}=En(re??"",{enabled:Ie}),{data:xe}=ii(K,{enabled:Ie}),De=xe?.committed?.length,[Ze,tt]=C.useState(!1),[Ae,Ge]=C.useState(null);C.useEffect(()=>{const te=n==="changes"||n==="chat"&&Ie?"changes":n==="history"?"history":null;if(!re||!K||!te){i(null);return}return i({workspaceId:re,workingDir:K,tab:te}),()=>{i(null)}},[n,re,i,Ie,K]);const be=C.useMemo(()=>ce?.conflictOp&&ce.conflictedFiles.length>0?{conflictOp:ce.conflictOp,conflictedFiles:ce.conflictedFiles}:Ae,[ce?.conflictOp,ce?.conflictedFiles,Ae]),Me=be?.targetWorkspaceId??re,Be=be?.targetWorktreePath??X?.worktreePath,Le=be?.sourceBranch??se,Pe=be?.targetBranch??ve,Xe=X?.sessions??[],Ce=C.useCallback(te=>{Ge(te??null),tt(!0)},[]),ye=C.useCallback(()=>e?.id?B.invalidateQueries({queryKey:ae.workspaces.list(e.id)}):Promise.resolve(),[e?.id,B]),G=C.useCallback(async()=>B.fetchQuery({queryKey:ae.tasks.body(e.id),queryFn:()=>me.get(`/tasks/${e.id}/body`)}),[B,e.id]),ne=C.useMemo(()=>{if(!D)return null;const te=D.filter($e=>$e.status==="ACTIVE"&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]),ge=$e=>{const Wt=$e.createdAt,Ht=$e.endedAt??$e.startedAt??Wt;if(!Ht)return 0;const Pt=Date.parse(Ht);return Number.isNaN(Pt)?0:Pt},He=$e=>{const Wt=te.filter(Ht=>$e.includes(Ht.status));return Wt.length===0?null:Wt.sort((Ht,Pt)=>ge(Pt)-ge(Ht))[0]??null},Fe=He([rt.RUNNING])??He([rt.PENDING])??He([rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Fe)return Fe;const pt=D.filter($e=>($e.status==="ABANDONED"||$e.status==="MERGED"||$e.status==="HIBERNATED")&&Array.isArray($e.sessions)).flatMap($e=>$e.sessions??[]).filter($e=>[rt.COMPLETED,rt.FAILED,rt.CANCELLED].includes($e.status));return pt.length===0?null:pt.sort(($e,Wt)=>ge(Wt)-ge($e))[0]??null},[D]),oe=ne?.id??"",Y=L?d??"":oe,J=C.useMemo(()=>{if(!d||!D)return null;for(const te of D){const ge=te.sessions?.find(He=>He.id===d);if(ge)return ge}return null},[d,D]),ie=C.useMemo(()=>{if(!d||!L?.invocations)return null;const te=L.invocations.filter(ge=>ge.sessionId===d);return te.length===0?null:te.sort((ge,He)=>{const Fe=Date.parse(ge.updatedAt??ge.createdAt??""),Ct=Date.parse(He.updatedAt??He.createdAt??"");return(Number.isNaN(Ct)?0:Ct)-(Number.isNaN(Fe)?0:Fe)})[0]??null},[d,L?.invocations]),he=C.useMemo(()=>!ie?.memberId||!L?.members?null:L.members.find(te=>te.id===ie.memberId)??null,[ie?.memberId,L?.members]),ke=d?J:ne??null,we=ke?.status===rt.RUNNING||ke?.status===rt.PENDING,Ee=C.useMemo(()=>!ne||!D?!1:!D.some(ge=>ge.status==="ACTIVE"&&ge.sessions?.some(He=>He.id===ne.id)),[ne,D]),{data:pe}=sr(),[je,Je]=C.useState(null),qe=je?.sessionId===oe?je.providerId:ne?.providerId??null,it=C.useCallback(te=>{Je({sessionId:oe,providerId:te})},[oe]),Ne=uc({agentType:ne?.agentType,workingDir:K,input:u,setInput:c,textareaRef:w,minHeight:40,maxHeight:140}),Re=hc({agentType:ne?.agentType,workingDir:K,input:u,setInput:c,textareaRef:w,minHeight:40,maxHeight:140}),ze=K&&X?X.id:void 0,bt=Bn(),mt=kn(),ut=tc(),{isConnected:At,isLoadingSnapshot:wt,logs:We,entries:Dt,attach:Lt}=Ma({sessionId:Y,sessionStatus:ke?.status,onExit:C.useCallback(()=>{B.invalidateQueries({queryKey:["workspaces"]})},[B])}),{todos:ms}=Ta(Dt),{files:oi,addFiles:et,removeFile:ps,clear:Ps,buildMarkdownLinks:Os,hasFiles:Xt,isUploading:as}=an(),ur=C.useMemo(()=>rc(ke),[ke?.tokenUsage]),Is=Ra(We,ur);C.useEffect(()=>{Y&&At&&Lt()},[Y,At,Lt]);const gs=C.useRef(null);C.useEffect(()=>{if(gs.current!==e.id&&R.current){const te=R.current;requestAnimationFrame(()=>{te.scrollTop=te.scrollHeight})}gs.current=e.id},[e.id,R]);const zt=C.useRef(!1),vs=C.useCallback(async()=>{if(!u.trim()&&!Xt||!oe||zt.current||as)return;zt.current=!0;const te=Os(),ge=[u.trim(),te].filter(Boolean).join(`
|
|
83
83
|
|
|
84
|
-
`);c(""),Ps(),w.current&&(w.current.style.height="40px"),bt.mutate({id:Z,message:me,providerId:Ce??void 0},{onSuccess:()=>Lt(),onSettled:()=>{zt.current=!1}})},[u,Z,bt,Lt,Xt,as,Os,Ps,Ce]),ai=C.useCallback(async()=>{Z&&(await ut.mutateAsync(Z),B.invalidateQueries({queryKey:["workspaces"]}))},[Z,ut,B]),Bs=C.useCallback(te=>O.mutateAsync(te),[O]),fr=C.useCallback(te=>{f(te),l("chat"),requestAnimationFrame(()=>{T()})},[T]),li=C.useCallback(()=>{f(null)},[]),mr=C.useCallback(()=>{l("changes")},[]),pr=Le&&re?t.jsx(ac,{workspaceId:re,branchName:se,targetBranch:pe,commitMessage:ve,changes:ge,gitStatus:oe,isGitStatusLoading:dt,canRunGitOperations:J,onOpenChanges:mr,onRefreshCommitMessage:ye,onConflict:be,className:"mb-2"}):null,xs=C.useCallback(te=>{const me=te.target.files;me&&me.length>0&&et(Array.from(me)),te.target.value=""},[et]),ci=C.useCallback(te=>{const me=te.clipboardData.items,Fe=[];for(const Oe of me)if(Oe.kind==="file"){const Ct=Oe.getAsFile();Ct&&Fe.push(Ct)}Fe.length>0&&(te.preventDefault(),et(Fe))},[et]),Vt=C.useCallback(te=>{c(te.target.value);const me=te.target;me.style.height="auto",me.style.height=`${Math.max(40,Math.min(me.scrollHeight,140))}px`},[]),gr=C.useCallback(()=>{Ge&&mt.mutate({workspaceId:Ge})},[mt,Ge]),Yt=C.useRef(null);return C.useEffect(()=>{const te=window.visualViewport;if(!te)return;let me=!1;const Fe=()=>{Yt.current&&(Yt.current.style.height=`${te.height}px`,Yt.current.style.top=`${te.offsetTop}px`)},Oe=()=>Fe(),Ct=()=>{me||Fe()},pt=()=>{me=!0},ze=()=>{me=!1,requestAnimationFrame(Fe)};return te.addEventListener("resize",Oe),te.addEventListener("scroll",Ct),document.addEventListener("touchstart",pt,{passive:!0}),document.addEventListener("touchend",ze,{passive:!0}),document.addEventListener("touchcancel",ze,{passive:!0}),()=>{te.removeEventListener("resize",Oe),te.removeEventListener("scroll",Ct),document.removeEventListener("touchstart",pt),document.removeEventListener("touchend",ze),document.removeEventListener("touchcancel",ze)}},[]),C.useEffect(()=>{const te=Yt.current;if(!te)return;const me=Fe=>{let Oe=Fe.target;for(;Oe&&Oe!==te;){if(Oe.tagName==="TEXTAREA"){if(Oe.scrollHeight>Oe.clientHeight)return;Oe=Oe.parentElement;continue}const pt=window.getComputedStyle(Oe).overflowY;if((pt==="auto"||pt==="scroll")&&Oe.scrollHeight>Oe.clientHeight)return;Oe=Oe.parentElement}Fe.preventDefault()};return te.addEventListener("touchmove",me,{passive:!1}),()=>te.removeEventListener("touchmove",me)},[]),t.jsxs("div",{ref:Yt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Gs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Y0,{status:e.status}),t.jsx("button",{onClick:gr,disabled:!Ge||W,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(rr,{size:16})}),r&&!W&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>h(te=>!te),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Oa,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{x(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:I.map(({key:te,label:me,icon:Fe})=>t.jsxs("button",{onClick:()=>l(te),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${o===te?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Fe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(me)})]},te))})]}),o==="chat"&&(L?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(rc,{session:Te,providers:Ae,usage:Is,compact:!0,providerIdFallback:Ve?.providerId,agentTypeFallback:Te?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(ke,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:li,children:[t.jsx(Gs,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:P,children:wt?t.jsx(Pi,{label:v("Loading logs...")}):Be.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(He?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:Be})})}),!M&&t.jsxs("button",{onClick:()=>T(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Rr,{todos:ms,compact:!0})})]}):t.jsx(hl,{teamRun:L,messages:A??L.messages??[],readOnly:W,readOnlyMessage:N,onSendMessage:Bs,onViewInvocationSession:fr,changeSummaryBar:pr,compactComposer:!0})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:P,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:q?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):Y?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(un,{urlTransform:V0,components:hn,children:Y.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!W&&p&&(F||Z)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(na,{state:p,onRetry:p.status==="failed"?async()=>{await H(),_(!0)}:void 0})}):null,F?t.jsx(Pi,{label:"Loading..."}):Z?wt?t.jsx(Pi,{label:"Loading logs..."}):Be.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:He?"Waiting for agent output...":"No logs recorded."}):t.jsx(Nr,{logs:Be}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Ut,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:W?N:v("选择一个 Agent 来执行此任务")}),!W&&p?t.jsx(na,{state:p}):null,!W&&t.jsxs(ke,{onClick:async()=>{await H(),_(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!M&&t.jsxs("button",{onClick:()=>T(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(Ys,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Rr,{todos:ms,compact:!0})}),W?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:N})}):Re?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(ke,{size:"sm",onClick:async()=>{await H(),_(!0)},children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):Z&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[pr,t.jsxs("div",{ref:k,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(an,{files:oi,onRemove:ps}),t.jsx("textarea",{ref:w,value:u,onChange:Vt,onPaste:ci,onKeyDown:te=>{qe.handleKeyDown(te)||Ye.handleKeyDown(te)||te.key==="Enter"&&!te.shiftKey&&!te.repeat&&!te.nativeEvent.isComposing&&te.nativeEvent.keyCode!==229&&(te.preventDefault(),vs())},rows:1,placeholder:He?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:xs}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(dn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[G&&Ae&&t.jsx(Aa,{providers:Ae,currentProviderId:Ce,agentType:G.agentType,onSelect:Je}),t.jsx(cn,{usage:Is}),He&&!u.trim()&&!Xt?t.jsx("button",{onClick:ai,disabled:ut.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Rs,{size:12})}):t.jsx("button",{onClick:vs,disabled:!u.trim()&&!Xt||as,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Xt)&&!as?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(ln,{size:15})})]})]})]}),t.jsx(Wr,{open:Ye.query!==null,anchorRef:k,commands:Ye.filteredCommands,selectedIndex:Ye.selectedIndex,query:Ye.query??"",hasCatalog:Ye.allCommands.length>0,compact:!0,onSelect:Ye.applyCommand}),t.jsx(Wr,{open:qe.query!==null,anchorRef:k,commands:qe.filteredSkills,selectedIndex:qe.selectedIndex,query:qe.query??"",hasCatalog:qe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:qe.applySkill})]})]})),o==="team-status"&&L&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(xl,{teamRun:L,workspaces:D,selectedWorkspaceId:z,onSelectWorkspace:S,onViewInvocationSession:fr})}),o==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[D&&D.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Zl,{workspaces:D,teamRun:L,selectedWorkspaceId:z,onSelectWorkspace:S,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),J&&re&&t.jsx("div",{className:"shrink-0",children:t.jsx(Xl,{workspaceId:re,branchName:se,targetBranch:pe,commitMessage:ve,committedFileCount:Ee,onRefreshCommitMessage:ye,onConflict:be,onResolveConflicts:()=>be()})}),t.jsx(F0,{workingDir:X})]}),o==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(K0,{workingDir:X})}),o==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Jl,{sessionId:Z||void 0,workspaceId:z,workingDir:X,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:W,repoDeleted:K})}),!W&&t.jsx(tc,{isOpen:g,onClose:()=>_(!1),taskId:e.id,taskTitle:Y?.title??e.title,taskDescription:Y?.body??"",taskPrompt:Y?.prompt,onStarted:()=>m?.(e.id)}),t.jsx(Nn,{isOpen:y,onClose:()=>x(!1),onConfirm:()=>{r?.(e.id),x(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:n}),Ze&&xe&&je&&t.jsx(oc,{open:Ze,onOpenChange:te=>{tt(te),te||it(null)},workspaceId:je,conflictOp:xe.conflictOp,conflictedFiles:xe.conflictedFiles,sourceBranch:Pe,targetBranch:Ne,operation:oe?.operation,worktreePath:Ie,mergeAborted:xe.mergeAborted,mergeStrategy:xe.mergeStrategy,sourceWorkspaceId:xe.sourceWorkspaceId,targetWorkspaceId:xe.targetWorkspaceId,sourceWorktreePath:xe.sourceWorktreePath,targetWorktreePath:xe.targetWorktreePath,sessions:Me,currentSessionId:L?void 0:Z,teamRunId:L?.id})]})}function Pi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var J0=Object.defineProperty,Ur=Object.getOwnPropertySymbols,pc=Object.prototype.hasOwnProperty,gc=Object.prototype.propertyIsEnumerable,oa=(e,s,r)=>s in e?J0(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Zi=(e,s)=>{for(var r in s||(s={}))pc.call(s,r)&&oa(e,r,s[r]);if(Ur)for(var r of Ur(s))gc.call(s,r)&&oa(e,r,s[r]);return e},Ji=(e,s)=>{var r={};for(var n in e)pc.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ur)for(var n of Ur(e))s.indexOf(n)<0&&gc.call(e,n)&&(r[n]=e[n]);return r};var fs;(e=>{const s=class _e{constructor(o,l,u,c){if(this.version=o,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],o<_e.MIN_VERSION||o>_e.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=o*4+17;let g=[];for(let y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(u);if(this.drawCodewords(_),c==-1){let y=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<y&&(c=x,y=a),this.applyMask(x)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(o,l){const u=e.QrSegment.makeSegments(o);return _e.encodeSegments(u,l)}static encodeBinary(o,l){const u=e.QrSegment.makeBytes(o);return _e.encodeSegments([u],l)}static encodeSegments(o,l,u=1,c=40,g=-1,_=!0){if(!(_e.MIN_VERSION<=u&&u<=c&&c<=_e.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,x;for(y=u;;y++){const f=_e.getNumDataCodewords(y,l)*8,b=v.getTotalBits(o,y);if(b<=f){x=b;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[_e.Ecc.MEDIUM,_e.Ecc.QUARTILE,_e.Ecc.HIGH])_&&x<=_e.getNumDataCodewords(y,f)*8&&(l=f);let a=[];for(const f of o){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(y),a);for(const b of f.getData())a.push(b)}p(a.length==x);const h=_e.getNumDataCodewords(y,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,b)=>d[b>>>3]|=f<<7-(b&7)),new _e(y,l,d,g)}getModule(o,l){return 0<=o&&o<this.size&&0<=l&&l<this.size&&this.modules[l][o]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const o=this.getAlignmentPatternPositions(),l=o.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(o[u],o[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(o){const l=this.errorCorrectionLevel.formatBits<<3|o;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(c,g));this.setFunctionModule(8,7,n(c,6)),this.setFunctionModule(8,8,n(c,7)),this.setFunctionModule(7,8,n(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let o=this.version;for(let u=0;u<12;u++)o=o<<1^(o>>>11)*7973;const l=this.version<<12|o;p(l>>>18==0);for(let u=0;u<18;u++){const c=n(l,u),g=this.size-11+u%3,_=Math.floor(u/3);this.setFunctionModule(g,_,c),this.setFunctionModule(_,g,c)}}drawFinderPattern(o,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),_=o+c,y=l+u;0<=_&&_<this.size&&0<=y&&y<this.size&&this.setFunctionModule(_,y,g!=2&&g!=4)}}drawAlignmentPattern(o,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(o+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(o,l,u){this.modules[l][o]=u,this.isFunction[l][o]=!0}addEccAndInterleave(o){const l=this.version,u=this.errorCorrectionLevel;if(o.length!=_e.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=_e.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=_e.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],_=Math.floor(_e.getNumRawDataModules(l)/8),y=c-_%c,x=Math.floor(_/c);let a=[];const h=_e.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<c;f++){let S=o.slice(b,b+x-g+(f<y?0:1));b+=S.length;const k=_e.reedSolomonComputeRemainder(S,h);f<y&&S.push(0),a.push(S.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((b,S)=>{(f!=x-g||S>=y)&&d.push(b[f])});return p(d.length==_),d}drawCodewords(o){if(o.length!=Math.floor(_e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const _=u-g,x=(u+1&2)==0?this.size-1-c:c;!this.isFunction[x][_]&&l<o.length*8&&(this.modules[x][_]=n(o[l>>>3],7-(l&7)),l++)}}p(l==o.length*8)}applyMask(o){if(o<0||o>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(o){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let o=0;for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==_?(y++,y==5?o+=_e.PENALTY_N1:y>5&&o++):(this.finderPenaltyAddHistory(y,x),_||(o+=this.finderPenaltyCountPatterns(x)*_e.PENALTY_N3),_=this.modules[g][a],y=1);o+=this.finderPenaltyTerminateAndCount(_,y,x)*_e.PENALTY_N3}for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==_?(y++,y==5?o+=_e.PENALTY_N1:y>5&&o++):(this.finderPenaltyAddHistory(y,x),_||(o+=this.finderPenaltyCountPatterns(x)*_e.PENALTY_N3),_=this.modules[a][g],y=1);o+=this.finderPenaltyTerminateAndCount(_,y,x)*_e.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let _=0;_<this.size-1;_++){const y=this.modules[g][_];y==this.modules[g][_+1]&&y==this.modules[g+1][_]&&y==this.modules[g+1][_+1]&&(o+=_e.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((_,y)=>_+(y?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),o+=c*_e.PENALTY_N4,p(0<=o&&o<=2568888),o}getAlignmentPatternPositions(){if(this.version==1)return[];{const o=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(o*2-2))*2;let u=[6];for(let c=this.size-7;u.length<o;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(o){if(o<_e.MIN_VERSION||o>_e.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*o+128)*o+64;if(o>=2){const u=Math.floor(o/7)+2;l-=(25*u-10)*u-55,o>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(o,l){return Math.floor(_e.getNumRawDataModules(o)/8)-_e.ECC_CODEWORDS_PER_BLOCK[l.ordinal][o]*_e.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][o]}static reedSolomonComputeDivisor(o){if(o<1||o>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<o-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<o;c++){for(let g=0;g<l.length;g++)l[g]=_e.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=_e.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(o,l){let u=l.map(c=>0);for(const c of o){const g=c^u.shift();u.push(0),l.forEach((_,y)=>u[y]^=_e.reedSolomonMultiply(_,g))}return u}static reedSolomonMultiply(o,l){if(o>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*o;return p(u>>>8==0),u}finderPenaltyCountPatterns(o){const l=o[1];p(l<=this.size*3);const u=l>0&&o[2]==l&&o[3]==l*3&&o[4]==l&&o[5]==l;return(u&&o[0]>=l*4&&o[6]>=l?1:0)+(u&&o[6]>=l*4&&o[0]>=l?1:0)}finderPenaltyTerminateAndCount(o,l,u){return o&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(o,l){l[0]==0&&(o+=this.size),l.pop(),l.unshift(o)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(i,o,l){if(o<0||o>31||i>>>o)throw new RangeError("Value out of range");for(let u=o-1;u>=0;u--)l.push(i>>>u&1)}function n(i,o){return(i>>>o&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class st{constructor(o,l,u){if(this.mode=o,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(o){let l=[];for(const u of o)r(u,8,l);return new st(st.Mode.BYTE,o.length,l)}static makeNumeric(o){if(!st.isNumeric(o))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<o.length;){const c=Math.min(o.length-u,3);r(parseInt(o.substring(u,u+c),10),c*3+1,l),u+=c}return new st(st.Mode.NUMERIC,o.length,l)}static makeAlphanumeric(o){if(!st.isAlphanumeric(o))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=o.length;u+=2){let c=st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u))*45;c+=st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u+1)),r(c,11,l)}return u<o.length&&r(st.ALPHANUMERIC_CHARSET.indexOf(o.charAt(u)),6,l),new st(st.Mode.ALPHANUMERIC,o.length,l)}static makeSegments(o){return o==""?[]:st.isNumeric(o)?[st.makeNumeric(o)]:st.isAlphanumeric(o)?[st.makeAlphanumeric(o)]:[st.makeBytes(st.toUtf8ByteArray(o))]}static makeEci(o){let l=[];if(o<0)throw new RangeError("ECI assignment value out of range");if(o<128)r(o,8,l);else if(o<16384)r(2,2,l),r(o,14,l);else if(o<1e6)r(6,3,l),r(o,21,l);else throw new RangeError("ECI assignment value out of range");return new st(st.Mode.ECI,0,l)}static isNumeric(o){return st.NUMERIC_REGEX.test(o)}static isAlphanumeric(o){return st.ALPHANUMERIC_REGEX.test(o)}getData(){return this.bitData.slice()}static getTotalBits(o,l){let u=0;for(const c of o){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(o){o=encodeURI(o);let l=[];for(let u=0;u<o.length;u++)o.charAt(u)!="%"?l.push(o.charCodeAt(u)):(l.push(parseInt(o.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(fs||(fs={}));var Es=fs;var ex={L:Es.QrCode.Ecc.LOW,M:Es.QrCode.Ecc.MEDIUM,Q:Es.QrCode.Ecc.QUARTILE,H:Es.QrCode.Ecc.HIGH},vc=128,xc="L",_c="#FFFFFF",bc="#000000",yc=!1,Sc=1,tx=4,sx=0,rx=.1;function wc(e,s=0){const r=[];return e.forEach(function(n,p){let m=null;n.forEach(function(v,i){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===n.length-1){if(!v)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}v&&m===null&&(m=i)})}),r.join("")}function Cc(e,s){return e.slice().map((r,n)=>n<s.y||n>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function ix(e,s,r,n){if(n==null)return null;const p=e.length+r*2,m=Math.floor(s*rx),v=p/s,i=(n.width||m)*v,o=(n.height||m)*v,l=n.x==null?e.length/2-i/2:n.x*v,u=n.y==null?e.length/2-o/2:n.y*v,c=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let y=Math.floor(l),x=Math.floor(u),a=Math.ceil(i+l-y),h=Math.ceil(o+u-x);g={x:y,y:x,w:a,h}}const _=n.crossOrigin;return{x:l,y:u,h:o,w:i,excavation:g,opacity:c,crossOrigin:_}}function nx(e,s){return s!=null?Math.max(Math.floor(s),0):e?tx:sx}function kc({value:e,level:s,minVersion:r,includeMargin:n,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let o=le.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...Es.QrSegment.makeSegments(a)),x),[]);return Es.QrCode.encodeSegments(y,ex[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=le.useMemo(()=>{let _=o.getModules();const y=nx(n,p),x=_.length+y*2,a=ix(_,v,y,m);return{cells:_,margin:y,numCells:x,calculatedImageSettings:a}},[o,v,m,n,p]);return{qrcode:o,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var ox=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ax=le.forwardRef(function(s,r){const n=s,{value:p,size:m=vc,level:v=xc,bgColor:i=_c,fgColor:o=bc,includeMargin:l=yc,minVersion:u=Sc,boostLevel:c,marginSize:g,imageSettings:_}=n,x=Ji(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,h=Ji(x,["style"]),d=_?.src,f=le.useRef(null),b=le.useRef(null),S=le.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,j]=le.useState(!1),{margin:w,cells:E,numCells:R,calculatedImageSettings:P}=kc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:_,size:m});le.useEffect(()=>{if(f.current!=null){const B=f.current,D=B.getContext("2d");if(!D)return;let F=E;const $=b.current,A=P!=null&&$!==null&&$.complete&&$.naturalHeight!==0&&$.naturalWidth!==0;A&&P.excavation!=null&&(F=Cc(E,P.excavation));const O=window.devicePixelRatio||1;B.height=B.width=m*O;const L=m/R*O;D.scale(L,L),D.fillStyle=i,D.fillRect(0,0,R,R),D.fillStyle=o,ox?D.fill(new Path2D(wc(F,w))):E.forEach(function(I,U){I.forEach(function(Y,q){Y&&D.fillRect(q+w,U+w,1,1)})}),P&&(D.globalAlpha=P.opacity),A&&D.drawImage($,P.x+w,P.y+w,P.w,P.h)}}),le.useEffect(()=>{j(!1)},[d]);const M=Zi({height:m,width:m},a);let T=null;return d!=null&&(T=le.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:P?.crossOrigin})),le.createElement(le.Fragment,null,le.createElement("canvas",Zi({style:M,height:m,width:m,ref:S,role:"img"},h)),T)});ax.displayName="QRCodeCanvas";var Ec=le.forwardRef(function(s,r){const n=s,{value:p,size:m=vc,level:v=xc,bgColor:i=_c,fgColor:o=bc,includeMargin:l=yc,minVersion:u=Sc,boostLevel:c,title:g,marginSize:_,imageSettings:y}=n,x=Ji(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=kc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:_,imageSettings:y,size:m});let b=h,S=null;y!=null&&f!=null&&(f.excavation!=null&&(b=Cc(h,f.excavation)),S=le.createElement("image",{href:y.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=wc(b,a);return le.createElement("svg",Zi({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!g&&le.createElement("title",null,g),le.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),le.createElement("path",{fill:o,d:k,shapeRendering:"crispEdges"}),S)});Ec.displayName="QRCodeSVG";function jc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function lx(){return Rt({queryKey:ie.tunnel.status,queryFn:()=>he.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function cx(){const e=ot();return _t({mutationFn:()=>he.post("/tunnel/start",{port:jc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ie.tunnel.status})}})}function dx(){const e=ot();return _t({mutationFn:()=>he.post("/tunnel/regenerate",{port:jc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ie.tunnel.status})}})}function ux(){const e=ot();return _t({mutationFn:()=>he.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ie.tunnel.status})}})}function hx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function fx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function mx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function aa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const n=Math.round(r/60);if(n<60)return`${n}m ago`;const p=Math.round(n/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function Ws(e){const s=e?.trim();return s||null}function px(e){if(!e)return"";const s=[Ws(e.lastLocalError),Ws(e.lastRemoteError),Ws(e.lastError)].filter(p=>p!==null),r=Ws(e.lastProcessOutput),n=!!r&&(e.status==="error"||e.status==="exited"||!!Ws(e.lastError));return r&&n&&s.push(r),s.join(`
|
|
85
|
-
`)}function la(){const{t:e}=ce(),{data:s}=lx(),r=cx(),n=ux(),p=dx(),[m,v]=C.useState(!1),[i,o]=C.useState(null),l=C.useRef(null),[u,c]=C.useState({top:0,right:0}),[g,_]=C.useState(!1),[y,x]=C.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,b=s?.token,S=hx(s),k=fx(s),j=px(s);C.useEffect(()=>{if(m&&l.current){const B=l.current.getBoundingClientRect();c({top:B.bottom+8,right:window.innerWidth-B.right})}},[m]);const w=C.useCallback(()=>{v(!0)},[a]),E=C.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=C.useCallback(()=>{f&&(navigator.clipboard.writeText(f),o("url"),setTimeout(()=>o(null),2e3))},[f]),P=C.useCallback(()=>{b&&(navigator.clipboard.writeText(b),o("token"),setTimeout(()=>o(null),2e3))},[b]),M=C.useCallback(()=>{n.mutate(),v(!1),_(!1),x(!1)},[n]),T=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{x(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:w,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?t.jsx(Xe,{size:16,className:"animate-spin"}):S.icon==="warn"?t.jsx(tr,{size:16}):t.jsx(ro,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),m&&!a&&Jt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(ro,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(is,{size:14})})]}),t.jsxs("button",{onClick:E,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Xe,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&Jt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(mx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(is,{size:14})})]}),b&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(gd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Ec,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:B=>B.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(eo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:aa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:aa(s?.lastHealthyAt)})]})]}),j&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:j}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>_(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:b}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(eo,{size:14})})]})]}),y&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:T,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!y&&t.jsxs("button",{onClick:()=>x(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(ir,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:M,disabled:n.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:n.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Oi({isOpen:e,onClose:s}){const{t:r}=ce(),n=bd(),[p,m]=C.useState(""),[v,i]=C.useState(""),[o,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(!1),y=p.trim(),x=v.trim(),a=u||n.isPending,h=C.useMemo(()=>!!(y&&x&&!a),[y,x,a]),d=C.useCallback(()=>{m(""),i(""),l(null),_(!1)},[]),f=C.useCallback(()=>{a||(d(),s())},[a,s,d]);C.useEffect(()=>{e||d()},[e,d]);const b=C.useCallback(async j=>{try{await n.mutateAsync({name:y,repoPath:x,initEmptyRepo:j}),d(),s()}catch(w){const E=w instanceof Error?w.message:r("Failed to create project");l(E),ct.error(E)}},[n,s,d,r,y,x]),S=C.useCallback(async()=>{if(!(!y||!x||a)){l(null),c(!0);try{const j=await he.get("/filesystem/validate",{params:{path:x}});if(j.valid){await b(!1);return}if(j.reason==="no_git"&&j.isEmpty){_(!0);return}if(j.reason==="no_git"){l(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}l(j.error??r("Selected path is not a valid directory"))}catch(j){l(j instanceof Error?j.message:r("Could not check repository path"))}finally{c(!1)}}},[b,a,r,y,x]),k=C.useCallback(()=>{_(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(Ms,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:S,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):n.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:j=>m(j.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),t.jsx(yd,{value:v,onChange:i,validationMode:"directory"})]}),o&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:o})]})}),t.jsx(qr,{isOpen:g,onClose:()=>{n.isPending||_(!1)},onConfirm:k,title:r("Initialize Git repository?"),description:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:n.isPending})]})}function ca({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:n,className:p}){const{t:m}=ce(),[v,i]=C.useState(!1),o=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:ee("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Ns,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(xt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Ns,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(qt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:o.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(qt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),n()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(es,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function da(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const gx=260,vx=600,ua=400,xx=100,kr=1e3;function _x(e,s){return e&&(e.data.findIndex(n=>n.id===s.id)>=0?{...e,data:e.data.map(n=>n.id===s.id?{...n,...s}:n)}:{...e,data:[s,...e.data],total:e.total+1})}function Xx(){const{t:e,locale:s}=ce(),[r,n]=C.useState(null),[p,m]=C.useState(null),[v,i]=C.useState(ua),[o,l]=C.useState(!1),[u,c]=C.useState("idle"),[g,_]=C.useState({}),y=C.useRef(!1),x=C.useRef(0),a=C.useRef(ua),h=C.useRef(null),d=ot(),{data:f,isLoading:b}=sr(),{data:S,isLoading:k}=Sd({limit:xx}),j=C.useMemo(()=>S?.data??[],[S?.data]),w=C.useMemo(()=>j.map(M0),[j]),E=p&&j.some(H=>H.id===p)?p:null,{data:R,isLoading:P}=cd(E??"",{limit:kr}),M=Rd({queries:E?[]:j.map(H=>({queryKey:ie.tasks.list(H.id,{limit:kr}),queryFn:()=>he.get(`/projects/${H.id}/tasks`,{params:{limit:String(kr)}})}))}),T=!E&&M.some(H=>H.isLoading),B=C.useMemo(()=>{if(E)return R?.data??[];const H=[];for(const G of M)G.data?.data&&H.push(...G.data.data);return H},[E,R,M]),[D,F]=C.useState([]),$=C.useMemo(()=>{if(D.length===0)return B;const H=new Set(B.map(G=>G.id));return[...D.filter(G=>!H.has(G.id)),...B]},[B,D]),[A,O]=C.useState(null),L=C.useMemo(()=>r&&$.some(H=>H.id===r)?r:A&&r===A?A:null,[r,$,A]);C.useEffect(()=>{A&&$.some(H=>H.id===A)&&O(null)},[A,$]),C.useEffect(()=>{if(D.length===0)return;const H=new Set(B.map(G=>G.id));D.some(G=>H.has(G.id))&&F(G=>G.filter(Z=>!H.has(Z.id)))},[B,D]);const I=C.useMemo(()=>{const H=new Map;for(const G of $){const Z=G.createdAt?new Date(G.createdAt).getTime():0,ae=H.get(G.projectId)??0;Z>ae&&H.set(G.projectId,Z)}return[...j].sort((G,Z)=>{const ae=H.get(G.id)??(G.createdAt?new Date(G.createdAt).getTime():0);return(H.get(Z.id)??(Z.createdAt?new Date(Z.createdAt).getTime():0))-ae})},[j,$]),U=C.useMemo(()=>I.filter(H=>!H.archivedAt),[I]),Y=C.useMemo(()=>{if(!f)return[];const H=localStorage.getItem("providerUsageCount"),G=H?JSON.parse(H):{};return[...f].sort((Z,ae)=>{const de=Z.availability.type!=="NOT_FOUND",fe=ae.availability.type!=="NOT_FOUND";if(de!==fe)return de?-1:1;const Ve=G[Z.provider.id]??0;return(G[ae.provider.id]??0)-Ve})},[f]),q=C.useMemo(()=>$.map(D0),[$]),W=C.useMemo(()=>new Set,[]),K=C.useMemo(()=>{if(!L)return null;const H=$.find(Z=>Z.id===L);if(!H)return null;const G=j.find(Z=>Z.id===H.projectId);if(!G){const Z=hs(H.workspaces?.find(ae=>ae.status==="ACTIVE")??H.workspaces?.[0]);return{id:H.id,projectId:H.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:H.title,status:Fn(H.status),branch:Z,mainBranch:"main",description:H.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return L0(H,G)},[L,$,j]),N=ga(),z=dd(),V=ud(),X=In(),re=C.useCallback(H=>{F(G=>G.some(Z=>Z.id===H.id)?G.map(Z=>Z.id===H.id?{...Z,...H}:Z):[H,...G]),d.setQueryData(ie.tasks.list(H.projectId,{limit:kr}),G=>_x(G,H)),d.setQueryData(ie.tasks.detail(H.id),H),O(H.id),n(H.id)},[d]),J=C.useCallback((H,G,Z)=>{const ae=H.id,de=[H.title,H.description].filter(Boolean).join(`
|
|
84
|
+
`);c(""),Ps(),w.current&&(w.current.style.height="40px"),bt.mutate({id:oe,message:ge,providerId:qe??void 0},{onSuccess:()=>Lt(),onSettled:()=>{zt.current=!1}})},[u,oe,bt,Lt,Xt,as,Os,Ps,qe]),ai=C.useCallback(async()=>{oe&&(await ut.mutateAsync(oe),B.invalidateQueries({queryKey:["workspaces"]}))},[oe,ut,B]),Bs=C.useCallback(te=>O.mutateAsync(te),[O]),hr=C.useCallback(te=>{f(te),l("chat"),requestAnimationFrame(()=>{T()})},[T]),li=C.useCallback(()=>{f(null)},[]),fr=C.useCallback(()=>{l("changes")},[]),mr=Ie&&re?t.jsx(lc,{workspaceId:re,branchName:se,targetBranch:ve,commitMessage:_e,changes:xe,gitStatus:ce,isGitStatusLoading:dt,canRunGitOperations:Z,onOpenChanges:fr,onRefreshCommitMessage:ye,onConflict:Ce,className:"mb-2"}):null,xs=C.useCallback(te=>{const ge=te.target.files;ge&&ge.length>0&&et(Array.from(ge)),te.target.value=""},[et]),ci=C.useCallback(te=>{const ge=te.clipboardData.items,He=[];for(const Fe of ge)if(Fe.kind==="file"){const Ct=Fe.getAsFile();Ct&&He.push(Ct)}He.length>0&&(te.preventDefault(),et(He))},[et]),Vt=C.useCallback(te=>{c(te.target.value);const ge=te.target;ge.style.height="auto",ge.style.height=`${Math.max(40,Math.min(ge.scrollHeight,140))}px`},[]),pr=C.useCallback(()=>{ze&&mt.mutate({workspaceId:ze})},[mt,ze]),Yt=C.useRef(null);return C.useEffect(()=>{const te=window.visualViewport;if(!te)return;let ge=!1;const He=()=>{Yt.current&&(Yt.current.style.height=`${te.height}px`,Yt.current.style.top=`${te.offsetTop}px`)},Fe=()=>He(),Ct=()=>{ge||He()},pt=()=>{ge=!0},$e=()=>{ge=!1,requestAnimationFrame(He)};return te.addEventListener("resize",Fe),te.addEventListener("scroll",Ct),document.addEventListener("touchstart",pt,{passive:!0}),document.addEventListener("touchend",$e,{passive:!0}),document.addEventListener("touchcancel",$e,{passive:!0}),()=>{te.removeEventListener("resize",Fe),te.removeEventListener("scroll",Ct),document.removeEventListener("touchstart",pt),document.removeEventListener("touchend",$e),document.removeEventListener("touchcancel",$e)}},[]),C.useEffect(()=>{const te=Yt.current;if(!te)return;const ge=He=>{let Fe=He.target;for(;Fe&&Fe!==te;){if(Fe.tagName==="TEXTAREA"){if(Fe.scrollHeight>Fe.clientHeight)return;Fe=Fe.parentElement;continue}const pt=window.getComputedStyle(Fe).overflowY;if((pt==="auto"||pt==="scroll")&&Fe.scrollHeight>Fe.clientHeight)return;Fe=Fe.parentElement}He.preventDefault()};return te.addEventListener("touchmove",ge,{passive:!1}),()=>te.removeEventListener("touchmove",ge)},[]),t.jsxs("div",{ref:Yt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Gs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(G0,{status:e.status}),t.jsx("button",{onClick:pr,disabled:!ze||W,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Kr,{size:16})}),r&&!W&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>h(te=>!te),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Ia,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{x(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(fn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:I.map(({key:te,label:ge,icon:He})=>t.jsxs("button",{onClick:()=>l(te),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${n===te?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(He,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(ge)})]},te))})]}),n==="chat"&&(L?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(ic,{session:ke,providers:pe,usage:Is,compact:!0,providerIdFallback:he?.providerId,agentTypeFallback:ke?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:li,children:[t.jsx(Gs,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:P,children:wt?t.jsx(Pi,{label:v("Loading logs...")}):We.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(we?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(jr,{logs:We})})}),!M&&t.jsxs("button",{onClick:()=>T(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(Ys,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Nr,{todos:ms,compact:!0})})]}):t.jsx(fl,{teamRun:L,messages:A??L.messages??[],readOnly:W,readOnlyMessage:N,onSendMessage:Bs,onViewInvocationSession:hr,changeSummaryBar:mr,compactComposer:!0})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:P,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:U?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):V?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(rn,{urlTransform:Y0,components:nn,children:V.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!W&&p&&(F||oe)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(na,{state:p,onRetry:p.status==="failed"?async()=>{await G(),_(!0)}:void 0})}):null,F?t.jsx(Pi,{label:"Loading..."}):oe?wt?t.jsx(Pi,{label:"Loading logs..."}):We.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:we?"Waiting for agent output...":"No logs recorded."}):t.jsx(jr,{logs:We}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Ut,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:W?N:v("选择一个 Agent 来执行此任务")}),!W&&p?t.jsx(na,{state:p}):null,!W&&t.jsxs(Te,{onClick:async()=>{await G(),_(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!M&&t.jsxs("button",{onClick:()=>T(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(Ys,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ms.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Nr,{todos:ms,compact:!0})}),W?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:N})}):Ee?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:async()=>{await G(),_(!0)},children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):oe&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[mr,t.jsxs("div",{ref:k,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(cn,{files:oi,onRemove:ps}),t.jsx("textarea",{ref:w,value:u,onChange:Vt,onPaste:ci,onKeyDown:te=>{Re.handleKeyDown(te)||Ne.handleKeyDown(te)||te.key==="Enter"&&!te.shiftKey&&!te.repeat&&!te.nativeEvent.isComposing&&te.nativeEvent.keyCode!==229&&(te.preventDefault(),vs())},rows:1,placeholder:we?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:xs}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(hn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ne&&pe&&t.jsx(Aa,{providers:pe,currentProviderId:qe,agentType:ne.agentType,onSelect:it}),t.jsx(un,{usage:Is}),we&&!u.trim()&&!Xt?t.jsx("button",{onClick:ai,disabled:ut.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Rs,{size:12})}):t.jsx("button",{onClick:vs,disabled:!u.trim()&&!Xt||as,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Xt)&&!as?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(dn,{size:15})})]})]})]}),t.jsx(Wr,{open:Ne.query!==null,anchorRef:k,commands:Ne.filteredCommands,selectedIndex:Ne.selectedIndex,query:Ne.query??"",hasCatalog:Ne.allCommands.length>0,compact:!0,onSelect:Ne.applyCommand}),t.jsx(Wr,{open:Re.query!==null,anchorRef:k,commands:Re.filteredSkills,selectedIndex:Re.selectedIndex,query:Re.query??"",hasCatalog:Re.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Re.applySkill})]})]})),n==="team-status"&&L&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(_l,{teamRun:L,workspaces:D,selectedWorkspaceId:z,onSelectWorkspace:S,onViewInvocationSession:hr})}),n==="changes"&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[D&&D.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Jl,{workspaces:D,teamRun:L,selectedWorkspaceId:z,onSelectWorkspace:S,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),Z&&re&&t.jsx("div",{className:"shrink-0",children:t.jsx(Vl,{workspaceId:re,branchName:se,targetBranch:ve,commitMessage:_e,committedFileCount:De,onRefreshCommitMessage:ye,onConflict:Ce,onResolveConflicts:()=>Ce()})}),t.jsx(z0,{workingDir:K})]}),n==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(X0,{workingDir:K})}),n==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ec,{sessionId:oe||void 0,workspaceId:z,workingDir:K,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:W,repoDeleted:q})}),!W&&t.jsx(sc,{isOpen:g,onClose:()=>_(!1),taskId:e.id,taskTitle:V?.title??e.title,taskDescription:V?.body??"",taskPrompt:V?.prompt,onStarted:()=>m?.(e.id)}),t.jsx(Nn,{isOpen:y,onClose:()=>x(!1),onConfirm:()=>{r?.(e.id),x(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:o}),Ze&&be&&Me&&t.jsx(ac,{open:Ze,onOpenChange:te=>{tt(te),te||Ge(null)},workspaceId:Me,conflictOp:be.conflictOp,conflictedFiles:be.conflictedFiles,sourceBranch:Le,targetBranch:Pe,operation:ce?.operation,worktreePath:Be,mergeAborted:be.mergeAborted,mergeStrategy:be.mergeStrategy,sourceWorkspaceId:be.sourceWorkspaceId,targetWorkspaceId:be.targetWorkspaceId,sourceWorktreePath:be.sourceWorktreePath,targetWorktreePath:be.targetWorktreePath,sessions:Xe,currentSessionId:L?void 0:oe,teamRunId:L?.id})]})}function Pi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var ex=Object.defineProperty,$r=Object.getOwnPropertySymbols,gc=Object.prototype.hasOwnProperty,vc=Object.prototype.propertyIsEnumerable,oa=(e,s,r)=>s in e?ex(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Zi=(e,s)=>{for(var r in s||(s={}))gc.call(s,r)&&oa(e,r,s[r]);if($r)for(var r of $r(s))vc.call(s,r)&&oa(e,r,s[r]);return e},Ji=(e,s)=>{var r={};for(var o in e)gc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&$r)for(var o of $r(e))s.indexOf(o)<0&&vc.call(e,o)&&(r[o]=e[o]);return r};var fs;(e=>{const s=class Se{constructor(n,l,u,c){if(this.version=n,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(u);if(this.drawCodewords(_),c==-1){let y=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<y&&(c=x,y=a),this.applyMask(x)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(n,l){const u=e.QrSegment.makeSegments(n);return Se.encodeSegments(u,l)}static encodeBinary(n,l){const u=e.QrSegment.makeBytes(n);return Se.encodeSegments([u],l)}static encodeSegments(n,l,u=1,c=40,g=-1,_=!0){if(!(Se.MIN_VERSION<=u&&u<=c&&c<=Se.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,x;for(y=u;;y++){const f=Se.getNumDataCodewords(y,l)*8,b=v.getTotalBits(n,y);if(b<=f){x=b;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])_&&x<=Se.getNumDataCodewords(y,f)*8&&(l=f);let a=[];for(const f of n){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(y),a);for(const b of f.getData())a.push(b)}p(a.length==x);const h=Se.getNumDataCodewords(y,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,b)=>d[b>>>3]|=f<<7-(b&7)),new Se(y,l,d,g)}getModule(n,l){return 0<=n&&n<this.size&&0<=l&&l<this.size&&this.modules[l][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),l=n.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(n[u],n[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const l=this.errorCorrectionLevel.formatBits<<3|n;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let u=0;u<12;u++)n=n<<1^(n>>>11)*7973;const l=this.version<<12|n;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,_=Math.floor(u/3);this.setFunctionModule(g,_,c),this.setFunctionModule(_,g,c)}}drawFinderPattern(n,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),_=n+c,y=l+u;0<=_&&_<this.size&&0<=y&&y<this.size&&this.setFunctionModule(_,y,g!=2&&g!=4)}}drawAlignmentPattern(n,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(n+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(n,l,u){this.modules[l][n]=u,this.isFunction[l][n]=!0}addEccAndInterleave(n){const l=this.version,u=this.errorCorrectionLevel;if(n.length!=Se.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=Se.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=Se.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],_=Math.floor(Se.getNumRawDataModules(l)/8),y=c-_%c,x=Math.floor(_/c);let a=[];const h=Se.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<c;f++){let S=n.slice(b,b+x-g+(f<y?0:1));b+=S.length;const k=Se.reedSolomonComputeRemainder(S,h);f<y&&S.push(0),a.push(S.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((b,S)=>{(f!=x-g||S>=y)&&d.push(b[f])});return p(d.length==_),d}drawCodewords(n){if(n.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const _=u-g,x=(u+1&2)==0?this.size-1-c:c;!this.isFunction[x][_]&&l<n.length*8&&(this.modules[x][_]=o(n[l>>>3],7-(l&7)),l++)}}p(l==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(n){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==_?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,x),_||(n+=this.finderPenaltyCountPatterns(x)*Se.PENALTY_N3),_=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(_,y,x)*Se.PENALTY_N3}for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==_?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,x),_||(n+=this.finderPenaltyCountPatterns(x)*Se.PENALTY_N3),_=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(_,y,x)*Se.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let _=0;_<this.size-1;_++){const y=this.modules[g][_];y==this.modules[g][_+1]&&y==this.modules[g+1][_]&&y==this.modules[g+1][_+1]&&(n+=Se.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((_,y)=>_+(y?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),n+=c*Se.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let u=[6];for(let c=this.size-7;u.length<n;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(n){if(n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*n+128)*n+64;if(n>=2){const u=Math.floor(n/7)+2;l-=(25*u-10)*u-55,n>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(n,l){return Math.floor(Se.getNumRawDataModules(n)/8)-Se.ECC_CODEWORDS_PER_BLOCK[l.ordinal][n]*Se.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<n-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<n;c++){for(let g=0;g<l.length;g++)l[g]=Se.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=Se.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(n,l){let u=l.map(c=>0);for(const c of n){const g=c^u.shift();u.push(0),l.forEach((_,y)=>u[y]^=Se.reedSolomonMultiply(_,g))}return u}static reedSolomonMultiply(n,l){if(n>>>8||l>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(l>>>c&1)*n;return p(u>>>8==0),u}finderPenaltyCountPatterns(n){const l=n[1];p(l<=this.size*3);const u=l>0&&n[2]==l&&n[3]==l*3&&n[4]==l&&n[5]==l;return(u&&n[0]>=l*4&&n[6]>=l?1:0)+(u&&n[6]>=l*4&&n[0]>=l?1:0)}finderPenaltyTerminateAndCount(n,l,u){return n&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(n,l){l[0]==0&&(n+=this.size),l.pop(),l.unshift(n)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(i,n,l){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let u=n-1;u>=0;u--)l.push(i>>>u&1)}function o(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class st{constructor(n,l,u){if(this.mode=n,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(n){let l=[];for(const u of n)r(u,8,l);return new st(st.Mode.BYTE,n.length,l)}static makeNumeric(n){if(!st.isNumeric(n))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<n.length;){const c=Math.min(n.length-u,3);r(parseInt(n.substring(u,u+c),10),c*3+1,l),u+=c}return new st(st.Mode.NUMERIC,n.length,l)}static makeAlphanumeric(n){if(!st.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=n.length;u+=2){let c=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u))*45;c+=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u+1)),r(c,11,l)}return u<n.length&&r(st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u)),6,l),new st(st.Mode.ALPHANUMERIC,n.length,l)}static makeSegments(n){return n==""?[]:st.isNumeric(n)?[st.makeNumeric(n)]:st.isAlphanumeric(n)?[st.makeAlphanumeric(n)]:[st.makeBytes(st.toUtf8ByteArray(n))]}static makeEci(n){let l=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,l);else if(n<16384)r(2,2,l),r(n,14,l);else if(n<1e6)r(6,3,l),r(n,21,l);else throw new RangeError("ECI assignment value out of range");return new st(st.Mode.ECI,0,l)}static isNumeric(n){return st.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return st.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,l){let u=0;for(const c of n){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(n){n=encodeURI(n);let l=[];for(let u=0;u<n.length;u++)n.charAt(u)!="%"?l.push(n.charCodeAt(u)):(l.push(parseInt(n.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(fs||(fs={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(fs||(fs={}));var Es=fs;var tx={L:Es.QrCode.Ecc.LOW,M:Es.QrCode.Ecc.MEDIUM,Q:Es.QrCode.Ecc.QUARTILE,H:Es.QrCode.Ecc.HIGH},xc=128,_c="L",bc="#FFFFFF",yc="#000000",Sc=!1,wc=1,sx=4,rx=0,ix=.1;function Cc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,i){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===o.length-1){if(!v)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}v&&m===null&&(m=i)})}),r.join("")}function kc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function nx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*ix),v=p/s,i=(o.width||m)*v,n=(o.height||m)*v,l=o.x==null?e.length/2-i/2:o.x*v,u=o.y==null?e.length/2-n/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let y=Math.floor(l),x=Math.floor(u),a=Math.ceil(i+l-y),h=Math.ceil(n+u-x);g={x:y,y:x,w:a,h}}const _=o.crossOrigin;return{x:l,y:u,h:n,w:i,excavation:g,opacity:c,crossOrigin:_}}function ox(e,s){return s!=null?Math.max(Math.floor(s),0):e?sx:rx}function Ec({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let n=de.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...Es.QrSegment.makeSegments(a)),x),[]);return Es.QrCode.encodeSegments(y,tx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=de.useMemo(()=>{let _=n.getModules();const y=ox(o,p),x=_.length+y*2,a=nx(_,v,y,m);return{cells:_,margin:y,numCells:x,calculatedImageSettings:a}},[n,v,m,o,p]);return{qrcode:n,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var ax=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),lx=de.forwardRef(function(s,r){const o=s,{value:p,size:m=xc,level:v=_c,bgColor:i=bc,fgColor:n=yc,includeMargin:l=Sc,minVersion:u=wc,boostLevel:c,marginSize:g,imageSettings:_}=o,x=Ji(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,h=Ji(x,["style"]),d=_?.src,f=de.useRef(null),b=de.useRef(null),S=de.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,j]=de.useState(!1),{margin:w,cells:E,numCells:R,calculatedImageSettings:P}=Ec({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:_,size:m});de.useEffect(()=>{if(f.current!=null){const B=f.current,D=B.getContext("2d");if(!D)return;let F=E;const H=b.current,A=P!=null&&H!==null&&H.complete&&H.naturalHeight!==0&&H.naturalWidth!==0;A&&P.excavation!=null&&(F=kc(E,P.excavation));const O=window.devicePixelRatio||1;B.height=B.width=m*O;const L=m/R*O;D.scale(L,L),D.fillStyle=i,D.fillRect(0,0,R,R),D.fillStyle=n,ax?D.fill(new Path2D(Cc(F,w))):E.forEach(function(I,$){I.forEach(function(V,U){V&&D.fillRect(U+w,$+w,1,1)})}),P&&(D.globalAlpha=P.opacity),A&&D.drawImage(H,P.x+w,P.y+w,P.w,P.h)}}),de.useEffect(()=>{j(!1)},[d]);const M=Zi({height:m,width:m},a);let T=null;return d!=null&&(T=de.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:P?.crossOrigin})),de.createElement(de.Fragment,null,de.createElement("canvas",Zi({style:M,height:m,width:m,ref:S,role:"img"},h)),T)});lx.displayName="QRCodeCanvas";var jc=de.forwardRef(function(s,r){const o=s,{value:p,size:m=xc,level:v=_c,bgColor:i=bc,fgColor:n=yc,includeMargin:l=Sc,minVersion:u=wc,boostLevel:c,title:g,marginSize:_,imageSettings:y}=o,x=Ji(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Ec({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:_,imageSettings:y,size:m});let b=h,S=null;y!=null&&f!=null&&(f.excavation!=null&&(b=kc(h,f.excavation)),S=de.createElement("image",{href:y.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=Cc(b,a);return de.createElement("svg",Zi({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!g&&de.createElement("title",null,g),de.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),de.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),S)});jc.displayName="QRCodeSVG";function Nc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function cx(){return Rt({queryKey:ae.tunnel.status,queryFn:()=>me.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function dx(){const e=ot();return _t({mutationFn:()=>me.post("/tunnel/start",{port:Nc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function ux(){const e=ot();return _t({mutationFn:()=>me.post("/tunnel/regenerate",{port:Nc()}),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function hx(){const e=ot();return _t({mutationFn:()=>me.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ae.tunnel.status})}})}function fx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function mx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function px(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function aa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function Hs(e){const s=e?.trim();return s||null}function gx(e){if(!e)return"";const s=[Hs(e.lastLocalError),Hs(e.lastRemoteError),Hs(e.lastError)].filter(p=>p!==null),r=Hs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Hs(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
85
|
+
`)}function la(){const{t:e}=ue(),{data:s}=cx(),r=dx(),o=hx(),p=ux(),[m,v]=C.useState(!1),[i,n]=C.useState(null),l=C.useRef(null),[u,c]=C.useState({top:0,right:0}),[g,_]=C.useState(!1),[y,x]=C.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,b=s?.token,S=fx(s),k=mx(s),j=gx(s);C.useEffect(()=>{if(m&&l.current){const B=l.current.getBoundingClientRect();c({top:B.bottom+8,right:window.innerWidth-B.right})}},[m]);const w=C.useCallback(()=>{v(!0)},[a]),E=C.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=C.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),P=C.useCallback(()=>{b&&(navigator.clipboard.writeText(b),n("token"),setTimeout(()=>n(null),2e3))},[b]),M=C.useCallback(()=>{o.mutate(),v(!1),_(!1),x(!1)},[o]),T=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{x(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:w,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?t.jsx(Ye,{size:16,className:"animate-spin"}):S.icon==="warn"?t.jsx(tr,{size:16}):t.jsx(ro,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),m&&!a&&Jt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(ro,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(is,{size:14})})]}),t.jsxs("button",{onClick:E,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Ye,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&Jt.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(px(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(is,{size:14})})]}),b&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(xd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(jc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:B=>B.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(eo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:aa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:aa(s?.lastHealthyAt)})]})]}),j&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:j}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>_(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:b}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(eo,{size:14})})]})]}),y&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>x(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:T,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!y&&t.jsxs("button",{onClick:()=>x(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(rr,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:M,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Oi({isOpen:e,onClose:s}){const{t:r}=ue(),o=Sd(),[p,m]=C.useState(""),[v,i]=C.useState(""),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(!1),y=p.trim(),x=v.trim(),a=u||o.isPending,h=C.useMemo(()=>!!(y&&x&&!a),[y,x,a]),d=C.useCallback(()=>{m(""),i(""),l(null),_(!1)},[]),f=C.useCallback(()=>{a||(d(),s())},[a,s,d]);C.useEffect(()=>{e||d()},[e,d]);const b=C.useCallback(async j=>{try{await o.mutateAsync({name:y,repoPath:x,initEmptyRepo:j}),d(),s()}catch(w){const E=w instanceof Error?w.message:r("Failed to create project");l(E),ct.error(E)}},[o,s,d,r,y,x]),S=C.useCallback(async()=>{if(!(!y||!x||a)){l(null),c(!0);try{const j=await me.get("/filesystem/validate",{params:{path:x}});if(j.valid){await b(!1);return}if(j.reason==="no_git"&&j.isEmpty){_(!0);return}if(j.reason==="no_git"){l(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}l(j.error??r("Selected path is not a valid directory"))}catch(j){l(j instanceof Error?j.message:r("Could not check repository path"))}finally{c(!1)}}},[b,a,r,y,x]),k=C.useCallback(()=>{_(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(Ms,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:S,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:j=>m(j.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),t.jsx(wd,{value:v,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(Ur,{isOpen:g,onClose:()=>{o.isPending||_(!1)},onConfirm:k,title:r("Initialize Git repository?"),description:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:o.isPending})]})}function ca({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ue(),[v,i]=C.useState(!1),n=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:ee("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Ns,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(xt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Ns,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(qt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:n.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(qt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(es,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function da(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const vx=260,xx=600,ua=400,_x=100,Cr=1e3;function bx(e,s){return e&&(e.data.findIndex(o=>o.id===s.id)>=0?{...e,data:e.data.map(o=>o.id===s.id?{...o,...s}:o)}:{...e,data:[s,...e.data],total:e.total+1})}function Yx(){const{t:e,locale:s}=ue(),[r,o]=C.useState(null),[p,m]=C.useState(null),[v,i]=C.useState(ua),[n,l]=C.useState(!1),[u,c]=C.useState("idle"),[g,_]=C.useState({}),y=C.useRef(!1),x=C.useRef(0),a=C.useRef(ua),h=C.useRef(null),d=ot(),{data:f,isLoading:b}=sr(),{data:S,isLoading:k}=Cd({limit:_x}),j=C.useMemo(()=>S?.data??[],[S?.data]),w=C.useMemo(()=>j.map(T0),[j]),E=p&&j.some(Y=>Y.id===p)?p:null,{data:R,isLoading:P}=dd(E??"",{limit:Cr}),M=Ad({queries:E?[]:j.map(Y=>({queryKey:ae.tasks.list(Y.id,{limit:Cr}),queryFn:()=>me.get(`/projects/${Y.id}/tasks`,{params:{limit:String(Cr)}})}))}),T=!E&&M.some(Y=>Y.isLoading),B=C.useMemo(()=>{if(E)return R?.data??[];const Y=[];for(const J of M)J.data?.data&&Y.push(...J.data.data);return Y},[E,R,M]),[D,F]=C.useState([]),H=C.useMemo(()=>{if(D.length===0)return B;const Y=new Set(B.map(J=>J.id));return[...D.filter(J=>!Y.has(J.id)),...B]},[B,D]),[A,O]=C.useState(null),L=C.useMemo(()=>r&&H.some(Y=>Y.id===r)?r:A&&r===A?A:null,[r,H,A]);C.useEffect(()=>{A&&H.some(Y=>Y.id===A)&&O(null)},[A,H]),C.useEffect(()=>{if(D.length===0)return;const Y=new Set(B.map(J=>J.id));D.some(J=>Y.has(J.id))&&F(J=>J.filter(ie=>!Y.has(ie.id)))},[B,D]);const I=C.useMemo(()=>{const Y=new Map;for(const J of H){const ie=J.createdAt?new Date(J.createdAt).getTime():0,he=Y.get(J.projectId)??0;ie>he&&Y.set(J.projectId,ie)}return[...j].sort((J,ie)=>{const he=Y.get(J.id)??(J.createdAt?new Date(J.createdAt).getTime():0);return(Y.get(ie.id)??(ie.createdAt?new Date(ie.createdAt).getTime():0))-he})},[j,H]),$=C.useMemo(()=>I.filter(Y=>!Y.archivedAt),[I]),V=C.useMemo(()=>{if(!f)return[];const Y=localStorage.getItem("providerUsageCount"),J=Y?JSON.parse(Y):{};return[...f].sort((ie,he)=>{const ke=ie.availability.type!=="NOT_FOUND",we=he.availability.type!=="NOT_FOUND";if(ke!==we)return ke?-1:1;const Ee=J[ie.provider.id]??0;return(J[he.provider.id]??0)-Ee})},[f]),U=C.useMemo(()=>H.map(L0),[H]),W=C.useMemo(()=>new Set,[]),q=C.useMemo(()=>{if(!L)return null;const Y=H.find(ie=>ie.id===L);if(!Y)return null;const J=j.find(ie=>ie.id===Y.projectId);if(!J){const ie=hs(Y.workspaces?.find(he=>he.status==="ACTIVE")??Y.workspaces?.[0]);return{id:Y.id,projectId:Y.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:Y.title,status:Fn(Y.status),branch:ie,mainBranch:"main",description:Y.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return P0(Y,J)},[L,H,j]),N=ga(),z=ud(),X=hd(),K=In(),re=C.useCallback(Y=>{F(J=>J.some(ie=>ie.id===Y.id)?J.map(ie=>ie.id===Y.id?{...ie,...Y}:ie):[Y,...J]),d.setQueryData(ae.tasks.list(Y.projectId,{limit:Cr}),J=>bx(J,Y)),d.setQueryData(ae.tasks.detail(Y.id),Y),O(Y.id),o(Y.id)},[d]),Z=C.useCallback((Y,J,ie)=>{const he=Y.id,ke=[Y.title,Y.description].filter(Boolean).join(`
|
|
86
86
|
|
|
87
|
-
`);_(
|
|
87
|
+
`);_(we=>({...we,[he]:{status:"creating-workspace"}})),(async()=>{try{const we=await me.post(`/tasks/${he}/workspaces`,{workspaceKind:ie});_(pe=>({...pe,[he]:{status:"creating-session"}}));const Ee=await me.post(`/workspaces/${we.id}/sessions`,{providerId:J,prompt:ke});_(pe=>({...pe,[he]:{status:"starting-session"}})),await K.mutateAsync(Ee.id),await d.invalidateQueries({queryKey:ae.workspaces.list(he)}),await d.invalidateQueries({queryKey:ae.tasks.all}),_(pe=>{const{[he]:je,...Je}=pe;return Je})}catch(we){const Ee=we instanceof Error?we.message:e("启动 Agent 失败");_(pe=>({...pe,[he]:{status:"failed",error:Ee}})),ct.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ae.workspaces.list(he)}),d.invalidateQueries({queryKey:ae.tasks.all})}})()},[d,K,e]),se=C.useCallback(Y=>{_(J=>{const{[Y]:ie,...he}=J;return he}),d.invalidateQueries({queryKey:ae.workspaces.list(Y)}),d.invalidateQueries({queryKey:ae.tasks.all})},[d]),_e=C.useCallback(Y=>{z.mutate(Y,{onSuccess:()=>{L===Y&&o(null),_(J=>{const{[Y]:ie,...he}=J;return he}),F(J=>J.filter(ie=>ie.id!==Y)),d.invalidateQueries({queryKey:ae.tasks.all})},onError:()=>{ct.error(e("删除任务失败"))}})},[z,L,d,e]),ve=C.useCallback((Y,J)=>{X.mutate({id:Y,status:A0(J)},{onError:()=>{ct.error(e("状态变更失败,该操作不被允许"))}})},[X,e]),Ie=C.useCallback(Y=>{Y.preventDefault(),y.current=!0,x.current=Y.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);C.useEffect(()=>{const Y=ie=>{if(!y.current)return;const he=ie.clientX-x.current,ke=Math.max(vx,Math.min(xx,a.current+he));i(ke)},J=()=>{y.current&&(y.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",J)}},[]);const ce=C.useCallback(()=>{l(!0)},[]),dt=C.useCallback(()=>{if($.length===0){ct.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[$,e]),xe=C.useCallback(()=>{l(!1)},[]),De=C.useCallback(async Y=>{const{title:J,description:ie,projectId:he,providerId:ke,mode:we,workspaceMode:Ee,teamRunMode:pe,teamTemplateId:je,memberPresetIds:Je,attachmentLinks:qe}=Y,it=[ie,qe].filter(Boolean).join(`
|
|
88
88
|
|
|
89
|
-
`);let
|
|
89
|
+
`);let Ne=null;try{if(c("creating-task"),Ne=await me.post(`/projects/${he}/tasks`,{title:J,description:it||void 0}),localStorage.setItem("lastSelectedProjectId",he),we==="SOLO"&&ke){localStorage.setItem("lastSelectedProviderId",ke);const Re=localStorage.getItem("providerUsageCount"),ze=Re?JSON.parse(Re):{};ze[ke]=(ze[ke]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ze))}we==="TEAM"?(c("creating-teamrun"),await N.mutateAsync({taskId:Ne.id,mode:pe,...je?{teamTemplateId:je}:{},...Je.length>0?{memberPresetIds:Je}:{}})):ke&&Z(Ne,ke,Ee),E&&he!==E&&m(null),re(Ne),c("idle"),d.invalidateQueries({queryKey:ae.tasks.all}),d.invalidateQueries({queryKey:ae.projects.all})}catch(Re){if(c("idle"),Ne&&we==="TEAM"){try{await z.mutateAsync(Ne.id)}catch{}throw ct.error(e("TeamRun 创建失败,请检查团队配置后重试")),Re}else if(Ne)E&&he!==E&&m(null),re(Ne),d.invalidateQueries({queryKey:ae.tasks.all}),d.invalidateQueries({queryKey:ae.projects.all});else throw ct.error(Re instanceof Error?Re.message:e("Failed to create task")),Re}},[N,Z,z,d,e,E,re]),Ze=k||P||T,tt=C.useMemo(()=>$.map(Y=>({id:Y.id,name:Y.name,color:w.find(J=>J.id===Y.id)?.color})),[$,w]),Ae=C.useMemo(()=>V.map(({provider:Y,availability:J})=>({id:Y.id,name:Y.name,agentType:Y.agentType,available:J.type!=="NOT_FOUND"})),[V]),Ge=C.useMemo(()=>{if(E&&$.find(J=>J.id===E))return E;const Y=localStorage.getItem("lastSelectedProjectId");return Y&&$.find(J=>J.id===Y)?Y:$[0]?.id??""},[$,E]),[be,Me]=C.useState(Ge);C.useEffect(()=>{Me(Ge)},[Ge]);const Be=C.useMemo(()=>$.find(Y=>Y.id===be)?.name??$.find(Y=>Y.id===Ge)?.name??e("Project"),[$,be,Ge,e]),Le=s==="zh-CN"?`你需要在 ${Be} 中做点什么?`:`What do you need to do in ${Be}?`,Pe=C.useMemo(()=>{const Y=localStorage.getItem("lastSelectedProviderId");return Y&&V.find(ie=>ie.provider.id===Y&&ie.availability.type!=="NOT_FOUND")?Y:V.find(ie=>ie.availability.type!=="NOT_FOUND")?.provider.id??""},[V]),Xe=nl(),[Ce,ye]=C.useState(!1),G=C.useMemo(()=>{if(typeof window>"u")return!1;const Y=new URLSearchParams(window.location.search);return Y.get("desktop")==="1"&&Y.get("desktopTitlebar")==="integrated"},[]),ne=C.useCallback(()=>{if($.length===0){ct.error(e("没有可用项目,请先创建或恢复项目"));return}ye(!0)},[$,e]),oe=C.useCallback(async Y=>{await De(Y),ye(!1)},[De]);return Xe?Ce?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>ye(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Le}),t.jsx(Qn,{projects:tt,providers:Ae,isProvidersLoading:b,onSubmit:oe,defaultProjectId:Ge,defaultProviderId:Pe,onProjectChange:Me,createStep:u})]})]}):L&&q?t.jsxs(t.Fragment,{children:[t.jsx(J0,{task:q,onBack:()=>o(null),onDeleteTask:q.projectArchivedAt?void 0:_e,isDeleting:z.isPending,autoStartState:g[q.id]??null,onAutoStartRecovered:se}),t.jsx(Oi,{isOpen:n,onClose:xe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Zn,{}),t.jsx(Jn,{}),t.jsx(ca,{projects:w,filterProjectId:E,setFilterProjectId:m,onCreateProject:ce})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(la,{}),t.jsx("button",{onClick:()=>Yn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Vn,{size:16})})]})]}),Ze&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(da,{})}):t.jsx(vo,{tasks:U,projects:w,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:"100%",onCreateTask:ne,onCreateProject:ce,activeTaskIds:W,onTaskStatusChange:ve})]}),t.jsx(Oi,{isOpen:n,onClose:xe})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:ee("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",G&&"app-region-drag"),children:[t.jsxs("div",{className:ee("flex items-center gap-2 min-w-0",G&&"pl-[72px]"),children:[t.jsx(Zn,{}),t.jsx(Jn,{}),t.jsx(ca,{projects:w,filterProjectId:E,setFilterProjectId:m,onCreateProject:ce,className:G?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:ee("flex items-center gap-1",G&&"app-region-no-drag"),children:[t.jsx("div",{className:G?"app-region-no-drag":void 0,children:t.jsx(la,{})}),t.jsx("button",{onClick:()=>Yn.getState().openSettings(),className:ee("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",G&&"app-region-no-drag"),children:t.jsx(Vn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ze&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(da,{})}):t.jsx(vo,{tasks:U,projects:w,selectedTaskId:L,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:v,onCreateTask:dt,onCreateProject:ce,isCreateActive:!L,activeTaskIds:W,onTaskStatusChange:ve,onDeleteTask:_e}),t.jsx("div",{onMouseDown:Ie,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:L&&q?t.jsx(R0,{task:q,onDeleteTask:q.projectArchivedAt?void 0:_e,isDeleting:z.isPending,onTaskStatusChange:q.projectArchivedAt?void 0:ve,autoStartState:g[q.id]??null,onAutoStartRecovered:se}):L&&!q?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Le}),t.jsx(Qn,{projects:tt,providers:Ae,isProvidersLoading:b,onSubmit:De,defaultProjectId:Ge,defaultProviderId:Pe,onProjectChange:Me,createStep:u})]})})})]}),t.jsx(Oi,{isOpen:n,onClose:xe})]})}export{Yx as ProjectKanbanPage};
|