@markus-global/cli 0.12.4 → 0.12.5-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/background-maintenance.d.ts +25 -0
  2. package/dist/background-maintenance.d.ts.map +1 -1
  3. package/dist/background-maintenance.js +61 -0
  4. package/dist/background-maintenance.js.map +1 -1
  5. package/dist/commands/im-inbound-origin.d.ts +38 -0
  6. package/dist/commands/im-inbound-origin.d.ts.map +1 -0
  7. package/dist/commands/im-inbound-origin.js +48 -0
  8. package/dist/commands/im-inbound-origin.js.map +1 -0
  9. package/dist/commands/start.d.ts.map +1 -1
  10. package/dist/commands/start.js +211 -46
  11. package/dist/commands/start.js.map +1 -1
  12. package/dist/markus.mjs +18520 -9886
  13. package/dist/web-ui/assets/{AsyncState-BTLUPIr1.js → AsyncState-ByYn1wrM.js} +1 -1
  14. package/dist/web-ui/assets/ChatComponents-Bwh8SlUV.js +14 -0
  15. package/dist/web-ui/assets/{ContentRenderer-BZXRiKE3.js → ContentRenderer-GLgoGp2a.js} +6 -6
  16. package/dist/web-ui/assets/DeliverableShareModal-CRfnRuR3.js +1 -0
  17. package/dist/web-ui/assets/{Deliverables-3Y3zjT_1.js → Deliverables-EFsnf6kU.js} +2 -2
  18. package/dist/web-ui/assets/MarkdownMessage-CaLBeMto.js +4 -0
  19. package/dist/web-ui/assets/{Search-BI3hk-5j.js → Search-COiaXUNr.js} +1 -1
  20. package/dist/web-ui/assets/{SendToChat-D_5zHO-k.js → SendToChat-DleryIlc.js} +1 -1
  21. package/dist/web-ui/assets/Settings-CzY8z2Yh.js +8 -0
  22. package/dist/web-ui/assets/{Store-B8ksRjHF.js → Store-C4VpQCM_.js} +1 -1
  23. package/dist/web-ui/assets/Switch-ByogYoGH.js +1 -0
  24. package/dist/web-ui/assets/Team-Cutq2J24.js +93 -0
  25. package/dist/web-ui/assets/Work-BO-mz-na.js +142 -0
  26. package/dist/web-ui/assets/{arc-VmvI7TpW.js → arc-mYv67jdD.js} +1 -1
  27. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CTUtPasm.js → architectureDiagram-3BPJPVTR-Bzpz_1r6.js} +1 -1
  28. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-xeYAqtZJ.js → blockDiagram-GPEHLZMM-BBrLiivl.js} +1 -1
  29. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BiFgoGY5.js → c4Diagram-AAUBKEIU-BwDUoXA_.js} +1 -1
  30. package/dist/web-ui/assets/channel-Bx09lbhA.js +1 -0
  31. package/dist/web-ui/assets/{chunk-2J33WTMH-DueHBqOn.js → chunk-2J33WTMH-DCSfJ-S9.js} +1 -1
  32. package/dist/web-ui/assets/{chunk-4BX2VUAB-B8zgDfSV.js → chunk-4BX2VUAB-CI0n1b2H.js} +1 -1
  33. package/dist/web-ui/assets/{chunk-55IACEB6-DieD55CP.js → chunk-55IACEB6-DqlSWLrm.js} +1 -1
  34. package/dist/web-ui/assets/{chunk-727SXJPM-Do4Z9LQ0.js → chunk-727SXJPM-BtmAfGYV.js} +1 -1
  35. package/dist/web-ui/assets/{chunk-AQP2D5EJ-qrYsW5ml.js → chunk-AQP2D5EJ-BgkA4lpQ.js} +1 -1
  36. package/dist/web-ui/assets/{chunk-FMBD7UC4-BSz3QT1q.js → chunk-FMBD7UC4-DCSr1JH4.js} +1 -1
  37. package/dist/web-ui/assets/{chunk-ND2GUHAM-utDWSydt.js → chunk-ND2GUHAM-CETYBRRm.js} +1 -1
  38. package/dist/web-ui/assets/{chunk-QZHKN3VN-Cd86CYHV.js → chunk-QZHKN3VN-C58yD7lH.js} +1 -1
  39. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGZqU3iA.js +1 -0
  40. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGZqU3iA.js +1 -0
  41. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc6cP9WW.js → cose-bilkent-S5V4N54A-BpvdK03m.js} +1 -1
  42. package/dist/web-ui/assets/{dagre-BM42HDAG-4b0Wf_6D.js → dagre-BM42HDAG-CZ1K-KD5.js} +1 -1
  43. package/dist/web-ui/assets/{diagram-2AECGRRQ-zS_j1Kf4.js → diagram-2AECGRRQ-D136Ok1V.js} +1 -1
  44. package/dist/web-ui/assets/{diagram-5GNKFQAL-CPo-_Ime.js → diagram-5GNKFQAL-Ji6qPYYV.js} +1 -1
  45. package/dist/web-ui/assets/{diagram-KO2AKTUF-CjHOA4_j.js → diagram-KO2AKTUF-B-s2RC-f.js} +1 -1
  46. package/dist/web-ui/assets/{diagram-LMA3HP47-CalZRF6K.js → diagram-LMA3HP47-COWaps70.js} +1 -1
  47. package/dist/web-ui/assets/{diagram-OG6HWLK6-DnLAhsLX.js → diagram-OG6HWLK6-bh6MvwWn.js} +1 -1
  48. package/dist/web-ui/assets/{docx-preview-uRVPnxwM.js → docx-preview-BRynUqJd.js} +1 -1
  49. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-L0nzlMSn.js → erDiagram-TEJ5UH35-DOPh2LlL.js} +1 -1
  50. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bdc3UwtW.js → flowDiagram-I6XJVG4X-B_kxDHIp.js} +1 -1
  51. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CFRmj_qc.js → ganttDiagram-6RSMTGT7-DYBKHOkK.js} +1 -1
  52. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B5hZwcoJ.js → gitGraphDiagram-PVQCEYII-D8_0BxLC.js} +1 -1
  53. package/dist/web-ui/assets/index-9SXWNIl0.css +1 -0
  54. package/dist/web-ui/assets/index-TAHyKznL.js +867 -0
  55. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DVT4RgPd.js → infoDiagram-5YYISTIA-DayJP7Ws.js} +1 -1
  56. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Bf7pvUY_.js → ishikawaDiagram-YF4QCWOH-vzxCYVSq.js} +1 -1
  57. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-NVRjJlnd.js → journeyDiagram-JHISSGLW-B-Fud82o.js} +1 -1
  58. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Co7BKMut.js → kanban-definition-UN3LZRKU-DzuKdB65.js} +1 -1
  59. package/dist/web-ui/assets/{mermaid.core-CCf28Hq6.js → mermaid.core-D4ql87kI.js} +5 -5
  60. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DepMhVEb.js → mindmap-definition-RKZ34NQL-DosvXt2g.js} +1 -1
  61. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-Cq9ANaI0.js → pieDiagram-4H26LBE5-DhXtMWhr.js} +1 -1
  62. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CUY0BWhQ.js → quadrantDiagram-W4KKPZXB-D33pLLOq.js} +1 -1
  63. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-D9fU5rCm.js → requirementDiagram-4Y6WPE33-B-iIz-XM.js} +1 -1
  64. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CMHhuSQF.js → sankeyDiagram-5OEKKPKP-BMd9AFEW.js} +1 -1
  65. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-Bjx53SID.js → sequenceDiagram-3UESZ5HK-CI1MIdwo.js} +1 -1
  66. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DVvatKnO.js → stateDiagram-AJRCARHV-Bq6FKPW2.js} +1 -1
  67. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-8nMhmWY5.js +1 -0
  68. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-9I80LG9m.js → timeline-definition-PNZ67QCA-BDdmmSRo.js} +1 -1
  69. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B82Deutq.js → vennDiagram-CIIHVFJN-DP2q5vY2.js} +1 -1
  70. package/dist/web-ui/assets/{wardley-L42UT6IY-BKXtp57W.js → wardley-L42UT6IY-Bw3fjszD.js} +1 -1
  71. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DzqTzfYa.js → wardleyDiagram-YWT4CUSO-37bQUocJ.js} +1 -1
  72. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-TowyDWYu.js → xychartDiagram-2RQKCTM6-DnLDZyNC.js} +1 -1
  73. package/dist/web-ui/index.html +2 -2
  74. package/docs/README.md +50 -16
  75. package/docs/api/guides/websocket.md +43 -0
  76. package/docs/api/reference.md +657 -0
  77. package/docs/architecture/a2a-communication.md +303 -0
  78. package/docs/architecture/agent-runtime.md +145 -28
  79. package/docs/architecture/architecture.md +30 -11
  80. package/docs/architecture/cognitive-architecture.md +189 -15
  81. package/docs/architecture/concurrent-processing.md +190 -31
  82. package/docs/architecture/context-assembly.md +264 -0
  83. package/docs/architecture/derived-views.md +463 -0
  84. package/docs/architecture/desktop-auto-update.md +185 -0
  85. package/docs/architecture/facts.md +406 -0
  86. package/docs/architecture/learning-loop.md +11 -0
  87. package/docs/architecture/limits.md +79 -0
  88. package/docs/architecture/mailbox-system.md +786 -668
  89. package/docs/architecture/memory-system.md +1 -1
  90. package/docs/architecture/messaging-gateway.md +7 -0
  91. package/docs/architecture/notification-delivery.md +221 -0
  92. package/docs/architecture/notification-sounds.md +177 -0
  93. package/docs/architecture/prompt-engineering.md +171 -700
  94. package/docs/{design/remote-access-contract.md → architecture/remote-access.md} +4 -0
  95. package/docs/architecture/state-machines.md +288 -5
  96. package/docs/architecture/tool-loop-harness.md +362 -0
  97. package/docs/architecture/tool-system.md +40 -16
  98. package/docs/design/background-callback-in-turn-delivery-2026-11-22.md +95 -0
  99. package/docs/design/c10-0b-pick-identity-leak-2026-11-22.md +233 -0
  100. package/docs/design/c10-a-identity-columns-2026-11-22.md +182 -0
  101. package/docs/design/c10-c-trust-boundary-2026-11-23.md +222 -0
  102. package/docs/design/c10-external-adapters-plan-2026-11-19.md +448 -0
  103. package/docs/design/c8-residual-mechanisms-2026-11-15.md +984 -0
  104. package/docs/design/external-signal-decision-loop-2026-11-25.md +579 -0
  105. package/docs/guides/development.md +1 -1
  106. package/docs/{architecture → guides}/mailbox-audit-checklist.md +7 -0
  107. package/docs/guides/remote-access.md +1 -1
  108. package/docs/{design/agent-stop-intent-audit.md → records/agent-stop-intent-audit-2026-11-08.md} +4 -0
  109. package/docs/records/c10-l5-gate-verification-2026-11-26.md +72 -0
  110. package/docs/records/c10-l5-live-verification-2026-11-25.md +117 -0
  111. package/docs/records/cut6-c4-verification-2026-11-12.md +268 -0
  112. package/docs/records/cut6-mailbox-address-envelope-design-2026-11-12.md +871 -0
  113. package/docs/records/cut7-c7a-red-green-evidence-2026-11-13.md +105 -0
  114. package/docs/records/cut7-c7a-workunit-implementation-2026-11-13.md +116 -0
  115. package/docs/records/cut7-c7b-verification-2026-11-14.md +90 -0
  116. package/docs/records/cut7-live-verification-2026-11-14.md +33 -0
  117. package/docs/records/cut7-wiring-negative-cache-2026-11-14.md +64 -0
  118. package/docs/records/cut7-workunit-execution-plan-2026-11-13.md +206 -0
  119. package/docs/records/cut8-a-entity-keys-design-2026-11-14.md +377 -0
  120. package/docs/records/cut8-b-turn-delta-injection-2026-11-14.md +362 -0
  121. package/docs/records/cut8-c-single-clock-2026-11-14.md +119 -0
  122. package/docs/records/cut8-c-single-clock-design-2026-11-14.md +150 -0
  123. package/docs/records/cut8-d-2026-11-14.md +231 -0
  124. package/docs/records/cut8-live-verification-2026-11-14.md +1018 -0
  125. package/docs/records/cut9-adjacent-identity-paths-2026-11-15.md +200 -0
  126. package/docs/records/cut9-identity-declaration-2026-11-15.md +163 -0
  127. package/docs/records/cut9-inbox-dual-run-diff-2026-11-15.md +117 -0
  128. package/docs/records/cut9-live-verification-2026-11-15.md +222 -0
  129. package/docs/records/cut9-runtime-probe-2026-11-19.md +520 -0
  130. package/docs/{design/deliverable-sharing.md → records/deliverable-sharing-2026-08-12.md} +10 -3
  131. package/docs/records/identity-backlog-disposition-2026-11-22.md +143 -0
  132. package/docs/records/marketplace-orphan-freeze-2026-11-22.md +239 -0
  133. package/docs/{architecture/notify-user-context-truth.md → records/notify-user-context-truth-2026-10-28.md} +6 -0
  134. package/docs/{handoff → records}/remote-access-handoff.md +1 -1
  135. package/package.json +1 -1
  136. package/templates/roles/HANDBOOK.md +1 -1
  137. package/templates/skills/agent-building/SKILL.md +1 -1
  138. package/dist/web-ui/assets/ChatComponents-DTB3H_n2.js +0 -12
  139. package/dist/web-ui/assets/DeliverableShareModal-BwZP39nd.js +0 -1
  140. package/dist/web-ui/assets/MarkdownMessage-DVfFMzM9.js +0 -4
  141. package/dist/web-ui/assets/Settings-DTUjLhJY.js +0 -8
  142. package/dist/web-ui/assets/Switch-RmZHA47D.js +0 -1
  143. package/dist/web-ui/assets/Team-BRgI1zM9.js +0 -85
  144. package/dist/web-ui/assets/Work-nah0UYFz.js +0 -142
  145. package/dist/web-ui/assets/channel-s7K3KXLr.js +0 -1
  146. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2mHhFY8.js +0 -1
  147. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2mHhFY8.js +0 -1
  148. package/dist/web-ui/assets/index-CzHSs0Vd.css +0 -1
  149. package/dist/web-ui/assets/index-TPf50ZeO.js +0 -867
  150. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-92MmE2MZ.js +0 -1
  151. package/docs/api/api.md +0 -353
  152. package/docs/architecture/llm-provider-timeouts.md +0 -60
  153. package/docs/architecture/state-ownership.md +0 -83
  154. /package/docs/architecture/{frontend/team-chat.md → team-chat.md} +0 -0
  155. /package/docs/{analysis → records}/2026-10-29-a2a-cache-hit-rate.md +0 -0
  156. /package/docs/{fixes → records}/2026-11-12-session-expiry-and-mention-thinking.md +0 -0
  157. /package/docs/{handoff → records}/approval-tri-state-handoff.md +0 -0
  158. /package/docs/{design → records}/overview-attention-redesign.md +0 -0
  159. /package/docs/{remote-access/fast-path-plan.md → records/remote-access-fast-path-plan-2026-10-17.md} +0 -0
@@ -0,0 +1,93 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-CaLBeMto.js","assets/index-TAHyKznL.js","assets/index-9SXWNIl0.css"])))=>i.map(i=>d[i]);
2
+ import{r as w,a1 as xl,u as Tt,aD as sp,j as c,U as Rt,aE as Cs,k as ne,aF as uC,$ as uc,a as rp,b as ip,P as Ut,c as zo,aG as uh,X as fC,A as Is,n as gr,a7 as qo,i as np,aH as mC,aI as op,aJ as pC,aK as Kv,aL as EO,aM as AO,aN as gC,aO as OC,aP as Jv,aQ as ey,aR as xC,aS as bC,aT as vC,aU as MO,aV as yC,aW as SC,aX as wC,a5 as fc,V as LO,Z as _C,Y as kC,h as ap,aY as mu,aZ as CC,a_ as PC,d as TC,a$ as ty,b0 as QC,b1 as Df,aA as sy,b2 as $C,b3 as NO,b4 as jC,b5 as RC,b6 as EC,a6 as AC,_ as ry,a9 as DO,b7 as MC,ax as LC,b8 as NC,b9 as IO,R as BO,Q as WO,ba as DC,bb as IC,bc as pu,bd as BC,be as WC,bf as XO,E as zO,bg as XC,bh as zC,bi as qC,y as ZC,W as VC,bj as FC,bk as iy}from"./index-TAHyKznL.js";import{MarkdownMessage as Hi}from"./MarkdownMessage-CaLBeMto.js";import{t as lp,f as cp,s as UC,L as ny,a as fh,i as qO,E as HC,l as YC,P as oy,g as GC,d as mh,b as KC,c as gu,p as JC,r as e2,e as ZO,h as VO,j as FO,k as _a,m as UO,n as t2,o as HO,q as Bn,u as Vc,v as Fc,w as s2,x as r2,y as i2,z as YO,A as n2,B as o2,C as a2,D as Ou,F as GO,G as l2,H as xu,I as bu,J as c2,K as mc,M as KO,N as h2,O as d2,Q as JO,R as u2,S as f2,T as m2,U as p2,V as g2,W as O2,X as e0,Y as x2,Z as b2,_ as v2,$ as y2,a0 as S2}from"./ChatComponents-Bwh8SlUV.js";import{P as ay,E as w2,L as ly,S as _2}from"./AsyncState-ByYn1wrM.js";import{c as k2,C as cy,o as If,p as C2,a as P2,b as T2}from"./chatChips-DVIRVTpT.js";import{i as Q2,S as t0,n as s0,o as $2}from"./Switch-ByogYoGH.js";import{ContentRenderer as Bf,resolveFormat as j2}from"./ContentRenderer-GLgoGp2a.js";import{a as R2,c as E2,D as A2}from"./DeliverableShareModal-CRfnRuR3.js";function mo(s,e,t){let r=t.initialDeps??[],i,n=!0;function a(){var o,l,h;let u;t.key&&((o=t.debug)!=null&&o.call(t))&&(u=Date.now());const d=s();if(!(d.length!==r.length||d.some((v,b)=>r[b]!==v)))return i;r=d;let p;if(t.key&&((l=t.debug)!=null&&l.call(t))&&(p=Date.now()),i=e(...d),t.key&&((h=t.debug)!=null&&h.call(t))){const v=Math.round((Date.now()-u)*100)/100,b=Math.round((Date.now()-p)*100)/100,O=b/16,g=(m,x)=>{for(m=String(m);m.length<x;)m=" "+m;return m};console.info(`%c⏱ ${g(b,5)} /${g(v,5)} ms`,`
3
+ font-size: .6rem;
4
+ font-weight: bold;
5
+ color: hsl(${Math.max(0,Math.min(120-120*O,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(n&&t.skipInitialOnChange)&&t.onChange(i),n=!1,i}return a.updateDeps=o=>{r=o},a}function r0(s,e){if(s===void 0)throw new Error("Unexpected undefined");return s}const M2=(s,e)=>Math.abs(s-e)<1.01,L2=(s,e,t)=>{let r;return function(...i){s.clearTimeout(r),r=s.setTimeout(()=>e.apply(this,i),t)}},i0=s=>{const{offsetWidth:e,offsetHeight:t}=s;return{width:e,height:t}},N2=s=>s,D2=s=>{const e=Math.max(s.startIndex-s.overscan,0),t=Math.min(s.endIndex+s.overscan,s.count-1),r=[];for(let i=e;i<=t;i++)r.push(i);return r},I2=(s,e)=>{const t=s.scrollElement;if(!t)return;const r=s.targetWindow;if(!r)return;const i=a=>{const{width:o,height:l}=a;e({width:Math.round(o),height:Math.round(l)})};if(i(i0(t)),!r.ResizeObserver)return()=>{};const n=new r.ResizeObserver(a=>{const o=()=>{const l=a[0];if(l?.borderBoxSize){const h=l.borderBoxSize[0];if(h){i({width:h.inlineSize,height:h.blockSize});return}}i(i0(t))};s.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return n.observe(t,{box:"border-box"}),()=>{n.unobserve(t)}},n0={passive:!0},o0=typeof window>"u"?!0:"onscrollend"in window,B2=(s,e)=>{const t=s.scrollElement;if(!t)return;const r=s.targetWindow;if(!r)return;let i=0;const n=s.options.useScrollendEvent&&o0?()=>{}:L2(r,()=>{e(i,!1)},s.options.isScrollingResetDelay),a=u=>()=>{const{horizontal:d,isRtl:f}=s.options;i=d?t.scrollLeft*(f&&-1||1):t.scrollTop,n(),e(i,u)},o=a(!0),l=a(!1);t.addEventListener("scroll",o,n0);const h=s.options.useScrollendEvent&&o0;return h&&t.addEventListener("scrollend",l,n0),()=>{t.removeEventListener("scroll",o),h&&t.removeEventListener("scrollend",l)}},W2=(s,e,t)=>{if(e?.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[t.options.horizontal?"inlineSize":"blockSize"])}return s[t.options.horizontal?"offsetWidth":"offsetHeight"]},X2=(s,{adjustments:e=0,behavior:t},r)=>{var i,n;const a=s+e;(n=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||n.call(i,{[r.options.horizontal?"left":"top"]:a,behavior:t})};class z2{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,r,i;return((i=(r=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let t=null;const r=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(i=>{i.forEach(n=>{const a=()=>{const o=n.target,l=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(o,n,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),t=null},observe:i=>{var n;return(n=r())==null?void 0:n.observe(i,{box:"border-box"})},unobserve:i=>{var n;return(n=r())==null?void 0:n.unobserve(i)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([r,i])=>{typeof i>"u"&&delete t[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:N2,rangeExtractor:D2,onChange:()=>{},measureElement:W2,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,t)},this.maybeNotify=mo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,n)=>{this.scrollAdjustments=0,this.scrollDirection=n?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=n,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,r)=>{const i=new Map,n=new Map;for(let a=r-1;a>=0;a--){const o=t[a];if(i.has(o.lane))continue;const l=n.get(o.lane);if(l==null||o.end>l.end?n.set(o.lane,o):o.end<l.end&&i.set(o.lane,!0),i.size===this.options.lanes)break}return n.size===this.options.lanes?Array.from(n.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=mo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,r,i,n,a,o,l)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:r,scrollMargin:i,getItemKey:n,enabled:a,lanes:o,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=mo(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:r,scrollMargin:i,getItemKey:n,enabled:a,lanes:o,laneAssignmentMode:l},h)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),f=new Array(o).fill(void 0);for(let p=0;p<u;p++){const v=d[p];v&&(f[v.lane]=p)}for(let p=u;p<t;p++){const v=n(p),b=this.laneAssignments.get(p);let O,g;const m=l==="estimate"||h.has(v);if(b!==void 0&&this.options.lanes>1){O=b;const C=f[O],P=C!==void 0?d[C]:void 0;g=P?P.end+this.options.gap:r+i}else{const C=this.options.lanes===1?d[p-1]:this.getFurthestMeasurement(d,p);g=C?C.end+this.options.gap:r+i,O=C?C.lane:p%this.options.lanes,this.options.lanes>1&&m&&this.laneAssignments.set(p,O)}const x=h.get(v),y=typeof x=="number"?x:this.options.estimateSize(p),k=g+y;d[p]={index:p,start:g,size:y,end:k,key:v,lane:O},f[O]=p}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=mo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,r,i,n)=>this.range=t.length>0&&r>0?q2({measurements:t,outerSize:r,scrollOffset:i,lanes:n}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=mo(()=>{let t=null,r=null;const i=this.calculateRange();return i&&(t=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,r]},(t,r,i,n,a)=>n===null||a===null?[]:t({startIndex:n,endIndex:a,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const r=this.options.indexAttribute,i=t.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,i-n),o=Math.min(this.options.count-1,i+n);return t>=a&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}const r=this.indexFromElement(t),i=this.options.getItemKey(r),n=this.elementsCache.get(i);n!==t&&(n&&this.observer.unobserve(n),this.observer.observe(t),this.elementsCache.set(i,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,r)=>{var i;const n=this.measurementsCache[t];if(!n)return;const a=this.itemSizeCache.get(n.key)??n.size,o=r-a;o!==0&&(((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,o,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,r)),this.notify(!1))},this.getVirtualItems=mo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,r)=>{const i=[];for(let n=0,a=t.length;n<a;n++){const o=t[n],l=r[o];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const r=this.getMeasurements();if(r.length!==0)return r0(r[hy(0,r.length-1,i=>r0(r[i]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,r,i=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=t>=a+n?"end":"start"),r==="center"?t+=(i-n)/2:r==="end"&&(t-=n);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,r="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getSize(),n=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(r==="auto")if(a.end>=n+i-this.options.scrollPaddingEnd)r="end";else if(a.start<=n+this.options.scrollPaddingStart)r="start";else return[n,r];if(r==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),r];const o=r==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,r,a.size),r]},this.scrollToOffset=(t,{align:r="start",behavior:i="auto"}={})=>{const n=this.getOffsetForAlignment(t,r),a=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:a,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:r="auto",behavior:i="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getOffsetForIndex(t,r);if(!n)return;const[a,o]=n,l=this.now();this.scrollState={index:t,align:o,behavior:i,startedAt:l,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+t,n=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:n,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1)i=((t=r[r.length-1])==null?void 0:t.end)??0;else{const n=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&n.some(o=>o===null);){const o=r[a];n[o.lane]===null&&(n[o.lane]=o.end),a--}i=Math.max(...n.filter(o=>o!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:r,behavior:i})=>{this.options.scrollToFn(t,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,n=1,a=i!==this.scrollState.lastTargetOffset;if(!a&&M2(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=n){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=i,this.scrollState.behavior="auto",this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const hy=(s,e,t,r)=>{for(;s<=e;){const i=(s+e)/2|0,n=t(i);if(n<r)s=i+1;else if(n>r)e=i-1;else return i}return s>0?s-1:0};function q2({measurements:s,outerSize:e,scrollOffset:t,lanes:r}){const i=s.length-1,n=l=>s[l].start;if(s.length<=r)return{startIndex:0,endIndex:i};let a=hy(0,i,n,t),o=a;if(r===1)for(;o<i&&s[o].end<t+e;)o++;else if(r>1){const l=Array(r).fill(0);for(;o<i&&l.some(u=>u<t+e);){const u=s[o];l[u.lane]=u.end,o++}const h=Array(r).fill(t+e);for(;a>=0&&h.some(u=>u>=t);){const u=s[a];h[u.lane]=u.start,a--}a=Math.max(0,a-a%r),o=Math.min(i,o+(r-1-o%r))}return{startIndex:a,endIndex:o}}const a0=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Z2({useFlushSync:s=!0,...e}){const t=w.useReducer(()=>({}),{})[1],r={...e,onChange:(n,a)=>{var o;s&&a?xl.flushSync(t):t(),(o=e.onChange)==null||o.call(e,n,a)}},[i]=w.useState(()=>new z2(r));return i.setOptions(r),a0(()=>i._didMount(),[]),a0(()=>i._willUpdate()),i}function V2(s){return Z2({observeElementRect:I2,observeElementOffset:B2,scrollToFn:X2,...s})}function F2(s){return s.questions&&s.questions.length>0?s.questions:s.options&&s.options.length>0?[{id:"q1",prompt:s.description||s.title,inputType:"choice",options:s.options,allowMultiple:!1,allowFreeform:s.allowFreeform}]:[{id:"q1",prompt:s.description||s.title,inputType:"text",allowFreeform:!0}]}function U2({approval:s,submitting:e,readOnly:t,onClose:r,onSubmit:i}){const{t:n}=Tt(["team","common"]);sp(!0);const a=w.useMemo(()=>F2(s),[s]),[o,l]=w.useState(0),[h,u]=w.useState(()=>{if(t&&s.answers&&s.answers.length>0){const C={};for(const P of s.answers)C[P.questionId]={selectedOptionIds:P.selectedOptionIds??[],text:P.text??""};return C}return{}}),d=a[o],f=o===a.length-1,p=a.length>1,v=C=>h[C]??{selectedOptionIds:[],text:""},b=(C,P)=>{u(_=>({..._,[C]:{...v(C),...P}}))},O=(C,P)=>{const _=v(C.id);if(C.allowMultiple){const Q=_.selectedOptionIds.includes(P);b(C.id,{selectedOptionIds:Q?_.selectedOptionIds.filter(E=>E!==P):[..._.selectedOptionIds,P],text:Q?_.text:""})}else{const Q=_.selectedOptionIds.includes(P);b(C.id,{selectedOptionIds:Q?[]:[P],text:Q?_.text:""})}},g=C=>{const P=v(C.id);return C.inputType==="choice"?P.selectedOptionIds.length>0?(C.options??[]).some(Q=>Q.id&&P.selectedOptionIds.includes(Q.id)&&Q.requiresFreeform)?P.text.trim().length>0:!0:!!(C.allowFreeform&&P.text.trim()):P.text.trim().length>0},m=a.every(g),x=(d.options??[]).some(C=>C.id&&v(d.id).selectedOptionIds.includes(C.id)&&C.requiresFreeform),y=()=>a.map(C=>{const P=v(C.id),_={questionId:C.id};return P.selectedOptionIds.length>0&&(_.selectedOptionIds=P.selectedOptionIds),P.text.trim()&&(_.text=P.text.trim()),_}),k=()=>{const C=y();let P=!0,_;if(!s.questions?.length&&s.options?.length){const E=C[0];_=E?.selectedOptionIds?.[0]??(E?.text?"custom":void 0),P=_!=="reject"&&_!=="request_changes"}const Q=C.map(E=>E.text).filter(Boolean).join(`
6
+ `)||void 0;i({approved:P,comment:Q,selectedOption:_,answers:C})};return xl.createPortal(c.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:C=>{C.target===C.currentTarget&&r()},children:c.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),c.jsx("path",{d:"M12 8v4"}),c.jsx("path",{d:"M12 16h.01"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:s.title}),c.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[c.jsx("p",{className:"text-xs text-fg-tertiary",children:s.agentName}),t&&c.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6L9 17l-5-5"})}),n("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),c.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:n("common:close"),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 6L6 18"}),c.jsx("path",{d:"M6 6l12 12"})]})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[p&&c.jsx("div",{className:"flex items-center gap-2",children:a.map((C,P)=>c.jsx("button",{onClick:()=>l(P),className:`h-1.5 flex-1 rounded-full transition-colors ${P===o?"bg-brand-500":g(C)?"bg-green-500/60":"bg-border-default"}`,title:`${P+1}. ${C.prompt.slice(0,40)}`},C.id))}),p&&c.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:n("team:userInput.questionProgress",{current:o+1,total:a.length,defaultValue:`Question ${o+1} of ${a.length}`})}),c.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:c.jsx(Hi,{content:d.prompt})}),d.inputType==="choice"&&d.options&&c.jsx("div",{className:"space-y-2",children:d.options.map((C,P)=>{const _=v(d.id).selectedOptionIds.includes(C.id);return c.jsxs("button",{onClick:t?void 0:()=>O(d,C.id),disabled:t,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${_?"border-brand-500 bg-brand-500/10":`border-border-default ${t?"":"hover:bg-surface-overlay"}`} ${t?"cursor-default":""} ${t&&!_?"opacity-50":""}`,children:[c.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${_?"bg-brand-600 text-on-brand":"bg-surface-overlay text-fg-tertiary"}`,children:_?c.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+P)}),c.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[c.jsx(Hi,{content:C.label}),C.description&&c.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:c.jsx(Hi,{content:C.description})}),C.requiresFreeform&&c.jsx("span",{className:"block text-[11px] text-amber-600 mt-1",children:n("team:userInput.requiresFreeform",{defaultValue:"This choice needs the text below — picking it alone is not an answer."})})]})]},C.id)})}),(d.inputType==="text"||d.allowFreeform||x)&&(!t||v(d.id).text)&&c.jsx("textarea",{rows:d.inputType==="text"?4:2,readOnly:t,placeholder:d.inputType==="text"?n("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):n("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:v(d.id).text,onChange:C=>{const P=C.target.value;b(d.id,{text:P,selectedOptionIds:P.trim()&&d.inputType==="choice"?[]:v(d.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${t?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),c.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[c.jsx("div",{children:p&&o>0&&c.jsx("button",{onClick:()=>l(C=>Math.max(0,C-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:n("team:userInput.previous",{defaultValue:"Previous"})})}),c.jsx("div",{className:"flex items-center gap-2",children:p&&!f?c.jsx("button",{disabled:!t&&!g(d),onClick:()=>l(C=>Math.min(a.length-1,C+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:n("team:userInput.next",{defaultValue:"Next"})}):t?c.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:n("common:close",{defaultValue:"Close"})}):c.jsxs("button",{disabled:e||!m,onClick:k,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-on-brand rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[e&&c.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function H2({approval:s,submitting:e,readOnly:t,onClose:r,onDecision:i}){const{t:n}=Tt(["team","common"]);sp(!0);const[a,o]=w.useState(""),l=typeof s.details?.command=="string"?s.details.command:"",h=typeof s.details?.toolName=="string"?s.details.toolName:"",u=d=>{t||e||i(d,a.trim()||void 0)};return xl.createPortal(c.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:d=>{d.target===d.currentTarget&&r()},children:c.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),c.jsx("path",{d:"M12 9v4"}),c.jsx("path",{d:"M12 17h.01"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug break-words",children:s.title||n("team:toolApproval.defaultTitle",{defaultValue:"Tool execution needs approval"})}),c.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[c.jsxs("p",{className:"text-xs text-fg-tertiary",children:[s.agentName,h?` · ${h}`:""]}),t&&c.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6L9 17l-5-5"})}),n("team:toolApproval.resolved",{defaultValue:"Resolved"})]})]})]}),c.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:n("common:close"),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 6L6 18"}),c.jsx("path",{d:"M6 6l12 12"})]})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[c.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:n("team:toolApproval.lead",{defaultValue:"The agent is paused until you approve or reject this action."})}),s.description&&c.jsx("div",{className:"text-xs text-fg-secondary leading-relaxed [&_p]:my-0 [&_p]:text-xs",children:c.jsx(Hi,{content:s.description.replace(/\s*Command:[\s\S]*$/,""),className:"text-xs [&_p]:text-xs [&_li]:text-xs"})}),l&&c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary uppercase tracking-wide",children:n("team:toolApproval.commandLabel",{defaultValue:"Command"})}),c.jsx("pre",{className:"text-xs text-fg-primary bg-surface-overlay border border-border-default rounded-xl px-3 py-2.5 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed",children:l})]}),!t&&c.jsx("textarea",{rows:2,value:a,onChange:d=>o(d.target.value),placeholder:n("team:toolApproval.commentPlaceholder",{defaultValue:"Optional note (e.g. why you reject)…"}),className:"w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50 resize-y"})]}),c.jsx("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-border-default shrink-0",children:t?c.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:n("common:close",{defaultValue:"Close"})}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{disabled:e,onClick:()=>u(!1),className:"px-5 py-2 text-sm font-medium bg-red-600/85 text-white rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 6L6 18"}),c.jsx("path",{d:"M6 6l12 12"})]}),n("common:reject",{defaultValue:"Reject"})]}),c.jsxs("button",{disabled:e,onClick:()=>u(!0),className:"px-5 py-2 text-sm font-medium bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[e&&c.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n("common:approve",{defaultValue:"Approve"})]})]})})]})}),document.body)}const l0={urgent:"bg-red-500/15 text-red-500",high:"bg-amber-500/15 text-amber-600",normal:"bg-blue-500/15 text-blue-500",low:"bg-surface-overlay text-fg-tertiary"};function Y2({notification:s,agentName:e,acknowledging:t,index:r=0,total:i=1,onClose:n,onAcknowledge:a}){const{t:o,i18n:l}=Tt(["team","common"]);sp(!0);const h=lp(s.createdAt,o),u=cp(s.createdAt,l.language),d=s.priority||"normal",f=s.metadata??{},p=e||(typeof f.agentName=="string"?f.agentName:void 0),v=i>1,b=r>=i-1,O=Math.max(0,i-r-1);return xl.createPortal(c.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:g=>{g.target===g.currentTarget&&n()},children:c.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[c.jsx("div",{className:"w-9 h-9 rounded-lg bg-blue-500/15 text-blue-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),c.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:s.title}),c.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[p&&c.jsx("p",{className:"text-xs text-fg-tertiary",children:p}),d!=="normal"&&c.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ${l0[d]??l0.normal}`,children:d}),v&&c.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-surface-overlay text-fg-secondary tabular-nums",children:o("page.notifyReviewProgress",{ns:"team",defaultValue:"{{current}} / {{total}}",current:r+1,total:i})}),(h||u)&&c.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-fg-tertiary tabular-nums",title:u,children:[c.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"9"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),h,h&&u&&c.jsx("span",{className:"text-fg-muted",children:"·"}),u]})]})]}),c.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:o("common:close"),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 6L6 18"}),c.jsx("path",{d:"M6 6l12 12"})]})})]}),v&&c.jsx("div",{className:"h-0.5 w-full bg-surface-overlay shrink-0",children:c.jsx("div",{className:"h-full bg-blue-500 transition-[width] duration-200",style:{width:`${(r+1)/i*100}%`}})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:c.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:c.jsx(Hi,{content:s.body||""})})}),c.jsxs("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[c.jsx("button",{onClick:n,className:"px-3.5 py-2 text-sm text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:o("common:close")}),c.jsx("button",{onClick:()=>{a()},disabled:t,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 disabled:opacity-50 rounded-lg transition-colors",children:t?o("common:loading"):b?o("page.notifyUserGotIt",{ns:"team",defaultValue:"Got it"}):o("page.notifyReviewNext",{ns:"team",defaultValue:"Next",count:O})})]})]})}),document.body)}function dy({kind:s,label:e,title:t,onRemove:r,removeLabel:i,tone:n="solid"}){const{t:a}=Tt(["team"]),o=a(k2(s),{ns:"team",defaultValue:s}),l=n==="solid"?"bg-brand-500/10 text-brand-500 border-brand-500/20":"bg-surface-secondary text-fg-secondary border-border-default";return c.jsxs("span",{className:`inline-flex items-center gap-1 max-w-[260px] pl-2 pr-1 py-0.5 rounded-lg border text-xs ${l}`,title:t,"data-chip-kind":s,children:[c.jsx("span",{"aria-hidden":!0,className:"shrink-0 leading-none",children:cy[s]}),c.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-wide opacity-80",children:o}),c.jsx("span",{className:"truncate min-w-0",children:e}),r&&c.jsx("button",{type:"button",onClick:r,className:"w-4 h-4 flex items-center justify-center rounded hover:bg-brand-500/20 shrink-0","aria-label":i,children:c.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function G2(s){return`[${cy[s.kind]} ${If(s.label)}]`}function Wf(s,e,t){return Math.min(Math.max(s,e),t)}function bl(s,e){const t=[...e].map(i=>{const n=Wf(i.start,0,s.length),a=Wf(i.end,n,s.length);return{...i,start:n,end:a}}).filter(i=>i.end>i.start).sort((i,n)=>i.start-n.start),r=[];for(const i of t){const n=r[r.length-1];n&&i.start<n.end||r.push(i)}return r}function hp(s,e,t){const r=Wf(t,0,s.text.length),i=s.chips.find(p=>r>p.start&&r<p.end);if(i){const p=Xf(s,i.id);return hp(p.draft,e,p.caret)}const n=`${G2(e)}`,a=r>0&&!/\s/.test(s.text[r-1]??"")?" ":"",o=s.text[r],l=r>=s.text.length||o!==void 0&&!/\s/.test(o)?" ":"",h=`${a}${n}${l}`,u=s.text.slice(0,r)+h+s.text.slice(r),d=r+a.length,f=s.chips.map(p=>p.start>=r?{...p,start:p.start+h.length,end:p.end+h.length}:p);return f.push({...e,start:d,end:d+n.length}),{draft:{text:u,chips:bl(u,f)},caret:r+h.length}}function Xf(s,e){const t=s.chips.find(a=>a.id===e);if(!t)return{draft:s,caret:s.text.length};const r=t.end-t.start,i=s.text.slice(0,t.start)+s.text.slice(t.end),n=s.chips.filter(a=>a.id!==e).map(a=>a.start>=t.end?{...a,start:a.start-r,end:a.end-r}:a);return{draft:{text:i,chips:bl(i,n)},caret:t.start}}function K2(s,e){const t=Math.min(s.length,e.length);let r=0;for(;r<t&&s[r]===e[r];)r++;return r}function J2(s,e,t){let r=0;for(;r<t&&s[s.length-1-r]===e[e.length-1-r];)r++;return r}function eP(s,e){if(e===s.text)return s;const t=s.text,r=K2(t,e),i=Math.min(t.length-r,e.length-r),n=J2(t,e,i),a=r,o=t.length-n,h=e.length-r-n-(o-a),u=[];for(const d of s.chips)d.start<o&&d.end>a||(d.start>=o?u.push({...d,start:d.start+h,end:d.end+h}):u.push(d));return{text:e,chips:bl(e,u)}}function tP(s){const e=bl(s.text,s.chips);let t="",r="",i=0;const n=[];for(const o of e){const l=s.text.slice(i,o.start);r+=l,n.push({kind:o.kind,label:o.label,offset:t.length+l.length,length:o.content.length}),t+=l+o.content,i=o.end}const a=s.text.slice(i);return r+=a,t+=a,{text:t,titleSource:r.replace(/[ \t]{2,}/g," ").replace(/\n{3,}/g,`
7
+
8
+ `).trim(),chips:n}}function sP(s){const e=s.text,t=e.length-e.trimStart().length,r=e.trimEnd().length;if(t===0&&r===e.length)return s;const i=e.slice(t,r),n=s.chips.flatMap(a=>{const o=a.start-t,l=a.end-t;return o<0||l>i.length?[]:[{...a,start:o,end:l}]});return{text:i,chips:bl(i,n)}}function rP(s){return tP(sP(s))}function iP(s,e){if(!e||e.length===0)return null;const t=[...e].filter(n=>Number.isFinite(n.offset)&&Number.isFinite(n.length)&&n.length>0).sort((n,a)=>n.offset-a.offset),r=[];let i=0;for(const n of t){if(n.offset<i||n.offset+n.length>s.length)return null;n.offset>i&&r.push({type:"text",text:s.slice(i,n.offset)}),r.push({type:"chip",chip:n}),i=n.offset+n.length}return i<s.length&&r.push({type:"text",text:s.slice(i)}),r}function nP(s,e){let t=s,r=t.text.length;for(const i of e){t.text.length>0&&!t.text.endsWith(`
9
+ `)&&(t={text:`${t.text}
10
+ `,chips:t.chips});const a=hp(t,i,t.text.length);t=a.draft,r=a.caret}return{draft:t,caret:r}}function oP({text:s,chips:e,renderText:t,className:r}){const i=iP(s,e);return i?c.jsx("span",{className:r,"data-chips-rendered":i.filter(n=>n.type==="chip").length,children:i.map((n,a)=>n.type==="text"?c.jsx("span",{children:t(n.text)},`t${a}`):c.jsx(dy,{kind:n.chip.kind,label:n.chip.label,title:s.slice(n.chip.offset,n.chip.offset+n.chip.length),tone:"ghost"},`c${a}`))}):c.jsx("span",{className:r,children:t(s)})}function aP(s,e){if(e.at<0)return!1;const t=`@${e.fragment}`;return s.slice(e.at,e.at+t.length)===t}function lP(s,e,t){if(e&&aP(s,e)){const n=e.at+1+e.fragment.length;return s.slice(0,e.at)+s.slice(n)}const r=Math.min(Math.max(t,0),s.length),i=s.slice(0,r).lastIndexOf("@");return i<0?s:s.slice(0,i)+s.slice(r)}const uy=12,vu=400,cP=4,hP=350;function fy(s){return Math.max(0,s.scrollHeight-s.clientHeight)}function c0(s){return fy(s)>1}function Uc(s){return fy(s)-s.scrollTop}function dP(s){return Uc(s)<=uy}function uP(s,e){return Math.abs(e)<=Math.abs(s)?"none":e<0?"up":e>0?"down":"none"}const fP=new Set(["ArrowUp","PageUp","Home"]),mP=new Set(["ArrowDown","PageDown","End"]);function pP(s){return fP.has(s)?"up":mP.has(s)?"down":"none"}function gP(s,e){return s==null?"none":e>s+1?"up":e<s-1?"down":"none"}function OP(s){return s.scrollable?s.takeover?s.gestureDirection==="up"||s.intentPending?"hold":s.distance<=uy?"resume":"hold":s.gestureDirection==="up"&&s.gestureActive||!s.programmatic&&s.deltaScrollTop<-4?"handover":"follow":s.takeover?"resume":"follow"}function xP(s){return!s.takeover&&!s.gestureActive}function bP(s,e){return e&&s==="up"}function po(s,e){return`${s||"_"}::${e??""}`}function vP(s,e){let t=null;for(const r of s)r.start>e+1||(!t||r.start>t.start)&&(t=r);return t??s[0]??null}function yP(s,e){if(dP(e))return{kind:"bottom"};const t=vP(s,e.scrollTop);return t?{kind:"row",id:t.id,delta:e.scrollTop-t.start}:{kind:"bottom"}}function SP(s,e){return s+e}const wP=12;function h0(s,e=wP){return{kind:"row",id:s,delta:-e}}function d0(s){const e=s.getBoundingClientRect().top,t=s.scrollTop,r=[];for(const i of Array.from(s.querySelectorAll("[data-index]"))){const a=i.querySelector('[id^="msg-"]')?.id?.slice(4);a&&r.push({id:a,start:t+(i.getBoundingClientRect().top-e)})}return r.sort((i,n)=>i.start-n.start),r}function _P(s,e,t,r){const i=s.find(n=>n.id===t);return i?SP(i.start-e.scrollTop,r):null}class kP{constructor(e=120){this.capacity=e}entries=new Map;save(e,t){if(e)for(this.entries.delete(e),this.entries.set(e,t);this.entries.size>this.capacity;){const r=this.entries.keys().next();if(r.done)break;this.entries.delete(r.value)}}get(e){if(!e)return null;const t=this.entries.get(e);return t?(this.entries.delete(e),this.entries.set(e,t),t):null}delete(e){this.entries.delete(e)}clear(){this.entries.clear()}get size(){return this.entries.size}}const u0=new kP,f0={jump:3,prepend:2,restore:1};function CP(s,e){return!s||s.key!==e.key?!0:f0[e.priority]>=f0[s.priority]}const PP=1e4,m0=300;function TP(s,e){return e-s>PP}function p0(s,e){return s&&e===!0}function QP(s){return s.rendered?s.stable?"apply":"refine":s.stale?s.priority==="restore"?"release-bottom":"release-hold":!s.absent||s.canLoadMore?"keep":s.priority==="restore"?"release-bottom":"release-hold"}function yu(s){return s!=="prepend"}const Su=Object.freeze({text:"",images:[],context:[],replyTo:null});function g0(s){return s.text===""&&s.images.length===0&&s.context.length===0&&s.replyTo===null}function $P(s){return{text:s.text,images:s.images,context:s.context,replyTo:s.replyTo}}class jP{constructor(e=120){this.capacity=e}entries=new Map;save(e,t){if(!e)return;this.entries.delete(e);const r=$P(t);if(!g0(r))for(this.entries.set(e,r);this.entries.size>this.capacity;){const i=this.entries.keys().next().value;if(i===void 0)break;this.entries.delete(i)}}get(e){const t=this.peek(e);return g0(t)?Su:(this.entries.delete(e),this.entries.set(e,t),t)}peek(e){return e?this.entries.get(e)??Su:Su}size(){return this.entries.size}clear(){this.entries.clear()}}const ka=new jP;function O0(s){return s.aborted||s.sawTerminal?"finalize":s.serverStatus==="streaming"||s.serverStatus===null?"reattach":"finalize"}function x0(s){switch(s){case"streaming":case"done":case"error":case"stopped":case"idle":case"not_found":return s;default:return null}}function RP(s){if(!s.liveStreamForView)return!1;const e=s.liveBubbleId;return e?s.msgId===e:s.msgIsStreaming}function EP(s){const e=s?.payload;return!e||typeof e.sessionId!="string"||typeof e.streaming!="boolean"?null:{agentId:typeof e.agentId=="string"?e.agentId:"",sessionId:e.sessionId,streaming:e.streaming,messageId:typeof e.messageId=="string"&&e.messageId.length>0?e.messageId:null,status:typeof e.status=="string"?e.status:void 0}}let b0=!1;function AP(){b0||(b0=!0,Rt.on("session:stream_state",s=>{const e=EP(s);if(!e)return;const t=Date.parse(s.timestamp??"")||Date.now();Cs.applyServerState(e.agentId,e.sessionId,e.streaming,t,e.messageId,e.status)}))}async function MP(s,e){if(!(!s||e.length===0)){try{const t=await ne.sessions.streamStatusBatch(s,e);Cs.reconcileFromServer(s,t.streaming??{},t.at)}catch{}Cs.prune()}}function LP(s,e){return!s||s.mode!=="direct"||e.chatMode!=="direct"||!s.sessionId&&!s.preferMain?!1:!!s.agentId&&s.agentId===e.agentId}function Ua({children:s,onClose:e,title:t,width:r="w-[440px]"}){const i=c.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:e,children:c.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${r} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:n=>n.stopPropagation(),children:[c.jsx("h3",{className:"text-base font-semibold mb-5",children:t}),s]})});return typeof document<"u"?xl.createPortal(i,document.body):i}function wo({label:s,children:e}){return c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:s}),e]})}function NP({onClose:s,onCreate:e}){const{t}=Tt(["team","common"]),[r,i]=w.useState(""),[n,a]=w.useState("");return c.jsx(Ua,{onClose:s,title:t("team:modals.createTeam.title"),children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(wo,{label:t("team:modals.createTeam.teamName"),children:c.jsx("input",{value:r,onChange:o=>i(o.target.value),placeholder:t("team:modals.createTeam.teamNamePlaceholder"),className:"input",autoFocus:!0,onKeyDown:o=>{o.key==="Enter"&&r.trim()&&e(r.trim(),n.trim()||void 0)}})}),c.jsx(wo,{label:t("team:modals.createTeam.description"),children:c.jsx("textarea",{value:n,onChange:o=>a(o.target.value),placeholder:t("team:modals.createTeam.descriptionPlaceholder"),className:"input",rows:2})}),c.jsx("div",{className:"text-xs text-fg-tertiary",children:t("team:modals.createTeam.hint")}),c.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:c.jsx(uC,{i18nKey:"modals.createTeam.tipTrans",ns:"team",components:{0:c.jsx("span",{className:"text-brand-400 font-medium"}),1:c.jsx("span",{className:"text-brand-400"})}})}),c.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[c.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),c.jsx("button",{onClick:()=>r.trim()&&e(r.trim(),n.trim()||void 0),disabled:!r.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-on-brand",children:t("team:modals.createTeam.createTeam")})]})]})})}function DP({onClose:s,onAdd:e}){const{t}=Tt(["team","common"]),[r,i]=w.useState(""),[n,a]=w.useState("member"),[o,l]=w.useState(""),[h,u]=w.useState(""),[d,f]=w.useState(!1),[p,v]=w.useState(null),[b,O]=w.useState(!1),g=p?.inviteToken?`${window.location.origin}/#invite?token=${p.inviteToken}`:null,m=async()=>{if(u(""),!r.trim()){u(t("team:modals.addHuman.nameRequired"));return}if(!o.trim()){u(t("team:modals.addHuman.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim())){u(t("team:modals.addHuman.invalidEmail"));return}f(!0);try{const y=await e(r.trim(),n,o.trim());v({...y,userName:r.trim()})}catch(y){u(y instanceof Error?y.message:String(y))}finally{f(!1)}},x=()=>{g&&(navigator.clipboard.writeText(g),O(!0),setTimeout(()=>O(!1),2e3))};return p?c.jsxs(Ua,{onClose:s,title:t("team:modals.addHuman.title"),width:"w-[460px]",children:[c.jsxs("div",{className:"text-center py-4",children:[c.jsx("div",{className:"w-12 h-12 rounded-full bg-green-600/20 flex items-center justify-center mx-auto mb-3",children:c.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-green-500",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})})}),c.jsx("div",{className:"text-base font-medium mb-1",children:t("team:modals.addHuman.memberCreated",{name:p.userName})}),g?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-xs text-fg-secondary mt-1 mb-4",children:t("team:modals.addHuman.inviteHint")}),c.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-lg p-3 text-left mb-3",children:[c.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase mb-1.5",children:t("team:modals.addHuman.inviteLink")}),c.jsx("div",{className:"text-xs text-fg-primary break-all font-mono select-all",children:g})]}),c.jsx("button",{onClick:x,className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${b?"bg-green-600 text-on-brand":"bg-brand-700 hover:bg-brand-600 text-on-brand"}`,children:t(b?"common:copied":"team:modals.addHuman.copyInviteLink")})]}):c.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:t("team:modals.addHuman.memberCreatedNoInvite")})]}),c.jsx("div",{className:"flex justify-end pt-3",children:c.jsx("button",{onClick:s,className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:t("common:done")})})]}):c.jsx(Ua,{onClose:s,title:t("team:modals.addHuman.title"),width:"w-[460px]",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"text-xs text-fg-secondary bg-surface-primary border border-border-default rounded-lg px-3 py-2.5 leading-relaxed",children:[c.jsx("div",{className:"font-semibold text-fg-primary mb-1",children:t("team:modals.addHuman.sharedInstanceTitle")}),t("team:modals.addHuman.sharedInstanceDesc"),c.jsxs("div",{className:"mt-1.5 text-fg-tertiary",children:[t("team:modals.addHuman.orgHint")," ",c.jsx("a",{href:"#settings/organization",className:"text-brand-500 hover:text-brand-400 underline",children:t("team:modals.addHuman.orgLink")})]})]}),c.jsx(wo,{label:t("team:modals.addHuman.name"),children:c.jsx("input",{value:r,onChange:y=>i(y.target.value),placeholder:t("team:modals.addHuman.namePlaceholder"),className:"input",autoFocus:!0})}),c.jsx(wo,{label:t("team:modals.addHuman.role"),children:c.jsxs("select",{value:n,onChange:y=>a(y.target.value),className:"input",children:[c.jsx("option",{value:"owner",children:t("common:role.owner")}),c.jsx("option",{value:"admin",children:t("common:role.admin")}),c.jsx("option",{value:"member",children:t("common:role.member")}),c.jsx("option",{value:"guest",children:t("common:role.guest")})]})}),c.jsx(wo,{label:t("team:modals.addHuman.emailRequired"),children:c.jsx("input",{value:o,onChange:y=>l(y.target.value),type:"email",placeholder:t("team:modals.addHuman.emailPlaceholder"),className:"input"})}),c.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:t("team:modals.addHuman.inviteFlowHint")}),h&&c.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:h}),c.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[c.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),c.jsx("button",{onClick:m,disabled:d,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 disabled:opacity-50 rounded-lg text-white",children:t(d?"common:saving":"team:modals.addHuman.addMember")})]})]})})}function IP({teamId:s,ungrouped:e,onClose:t,onAdd:r}){const{t:i}=Tt(["team","common"]);return c.jsx(Ua,{onClose:t,title:i("team:modals.addExisting.title"),children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-xs text-fg-tertiary",children:i("team:modals.addExisting.hint")}),e.length===0?c.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:i("team:modals.addExisting.allInTeam")}):c.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:e.map(n=>c.jsxs("button",{onClick:()=>r(n.id,n.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[c.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-on-brand ${n.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:n.name.charAt(0)}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"font-medium text-sm",children:n.name}),c.jsxs("div",{className:"text-xs text-fg-tertiary",children:[n.role," · ",n.type==="agent"?i("team:modals.addExisting.typeAgent"):i("team:modals.addExisting.typeHuman")]})]}),n.status&&c.jsx("span",{className:`w-2 h-2 rounded-full ${n.status==="idle"?"bg-green-400":n.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},n.id))}),c.jsx("div",{className:"flex justify-end pt-2",children:c.jsx("button",{onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:i("common:close")})})]})})}function BP({onClose:s,onConnected:e}){const{t}=Tt(["team","common"]),[r,i]=w.useState(""),[n,a]=w.useState(""),[o,l]=w.useState(!1),[h,u]=w.useState(null),[d,f]=w.useState(null),p=async()=>{if(!r.trim()){a(t("team:modals.openClaw.agentNameRequired"));return}const b=r.trim().toLowerCase().replace(/\s+/g,"-");l(!0),a("");try{const O=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:b,agentName:r.trim(),orgId:"default",capabilities:["general"]})});if(!O.ok){const m=await O.json().catch(()=>({}));throw new Error(m.error??`HTTP ${O.status}`)}const g=await O.json();u({externalAgentId:b,markusAgentId:g.registration?.markusAgentId,token:g.token,gatewayUrl:g.gatewayUrl})}catch(O){a(String(O))}l(!1)},v=(b,O)=>{navigator.clipboard.writeText(b),f(O),setTimeout(()=>f(null),2e3)};return c.jsx(Ua,{onClose:s,title:t("team:modals.openClaw.title"),width:"w-[560px]",children:h?(()=>{const b=h.gatewayUrl??`${window.location.origin}/api/gateway`,O=h.token?t("team:modals.openClaw.bearerTokenLine",{token:h.token}):"",g=t("team:modals.openClaw.connectionPromptBody",{gwUrl:b,externalAgentId:h.externalAgentId,tokenSection:O});return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"text-center py-6",children:[c.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),c.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:t("team:modals.openClaw.agentRegistered")}),c.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:c.jsx("strong",{children:r})})]}),c.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[c.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:t("team:modals.openClaw.copyInstruction")}),c.jsx("button",{onClick:()=>v(g,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${d==="prompt"?"bg-green-600 text-on-brand":"bg-brand-700 hover:bg-brand-600 text-on-brand"}`,children:t(d==="prompt"?"common:copied":"team:modals.openClaw.copyPrompt")})]}),c.jsx("div",{className:"flex justify-end pt-5",children:c.jsx("button",{onClick:()=>{e()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:t("team:modals.openClaw.done")})})]})})():c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:t("team:modals.openClaw.description")}),c.jsxs("div",{className:"space-y-4",children:[c.jsx(wo,{label:t("team:modals.openClaw.agentName"),children:c.jsx("input",{className:"input",placeholder:t("team:modals.openClaw.agentNamePlaceholder"),value:r,onChange:b=>i(b.target.value),autoFocus:!0})}),n&&c.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:n}),c.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[c.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),c.jsx("button",{onClick:p,disabled:o,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-on-brand disabled:opacity-50",children:t(o?"team:modals.openClaw.connecting":"team:modals.openClaw.importAgent")})]})]})]})})}function my(s){return`group:${s}`}function WP(s){const{chatMode:e,agentTeamId:t,channelTeamId:r,knownTeamIds:i}=s,n=e==="direct"?t:e==="channel"?r:null;return n&&(i instanceof Set?i.has(n):Array.from(i).includes(n))?`team/t/${n}`:"team"}function XP(s,e){return s&&typeof s.tokensUsedToday=="number"&&Number.isFinite(s.tokensUsedToday)?s.tokensUsedToday:typeof e=="number"&&Number.isFinite(e)?e:0}function pc(s){return s?s.filter(e=>e&&typeof e.size=="number"&&e.size>0).slice().sort((e,t)=>t.size-e.size||e.name.localeCompare(t.name)):[]}const zP=new Set(["workspace","sessions","tool-outputs","daily-logs","role","subagent-logs","worktrees"]);function qP(s){return zP.has(s)?`agent:profilePage.overview.storageBuckets.${s}`:null}const zf={idle:{tone:"ok",dotClass:"bg-green-400",running:!0,chipClass:"bg-green-500/10 border border-green-500/20",textClass:"text-green-600",labelKey:"common:status.idle"},working:{tone:"busy",dotClass:"bg-blue-400 animate-pulse",running:!0,chipClass:"bg-blue-500/10 border border-blue-500/20",textClass:"text-blue-500",labelKey:"common:status.working"},error:{tone:"danger",dotClass:"bg-red-400 animate-pulse",running:!0,chipClass:"bg-red-500/10 border border-red-500/20",textClass:"text-red-500",labelKey:"common:status.error"},paused:{tone:"warn",dotClass:"bg-amber-400",running:!1,chipClass:"bg-amber-500/10 border border-amber-500/20",textClass:"text-amber-600",labelKey:"common:status.paused"},offline:{tone:"muted",dotClass:"bg-gray-400",running:!1,chipClass:"bg-gray-500/10 border border-border-default",textClass:"text-fg-tertiary",labelKey:"common:status.offline"}};function vl(s){const e=s?zf[s]:void 0;return e||{...zf.offline,labelKey:null}}const ZP=zf.working;function yl(s,e){const t=vl(s);return!e||!t.running||t.tone==="danger"||t.tone==="busy"?t:ZP}const VP=5;function v0(s,e=VP){const t=Array.isArray(s)?s:[];return{shown:t.slice().sort((i,n)=>Date.parse(n.startedAt)-Date.parse(i.startedAt)).slice(0,Math.max(0,e)),total:t.length}}const FP=100;function UP(s){const e=Array.isArray(s)?s:[];return{heartbeats:e.filter(t=>t.type==="heartbeat"),comms:e.filter(t=>t.type==="a2a")}}const dp=["run","memory","settings"],HP=dp[0];function y0(s,e){return e?"run":dp.find(r=>r===s)??HP}function YP(s){return s?s.startsWith("channel:loop_")?"♻️":s.startsWith("task:")?"☑️":s.startsWith("requirement:")?"🎯":s.startsWith("channel:")?"💬":"":""}function S0(s){if(!s)return"";const[e,...t]=s.split(":"),r=t.join(":"),i=r.length>14?`${r.slice(0,12)}…`:r;return e==="task"?uc.t("agent:profilePage.mind.unitTask",{id:i}):e==="requirement"?uc.t("agent:profilePage.mind.unitRequirement",{id:i}):e==="channel"&&r.startsWith("loop_")?uc.t("agent:profilePage.mind.unitLoop"):e==="channel"?uc.t("agent:profilePage.mind.unitConversation",{id:i}):`${e} ${i}`}function GP(s){return s?"right-panel":"page"}let gc=new Map;function KP({agents:s,humans:e,authUser:t,onClose:r,onCreate:i}){const{t:n}=Tt(["team","common"]),[a,o]=w.useState(""),[l,h]=w.useState(new Set),[u,d]=w.useState(""),[f,p]=w.useState(!1),v=w.useMemo(()=>{const m=[];for(const x of s)m.push({id:x.id,name:x.name,type:"agent",subtitle:x.role||"Agent"});for(const x of e)x.id!==t?.id&&m.push({id:x.id,name:x.name,type:"human",subtitle:x.email||x.role||"Human"});return m},[s,e,t]),b=w.useMemo(()=>{if(!u)return v;const m=u.toLowerCase();return v.filter(x=>x.name.toLowerCase().includes(m)||x.subtitle.toLowerCase().includes(m))},[v,u]),O=m=>{h(x=>{const y=new Set(x);return y.has(m)?y.delete(m):y.add(m),y})},g=async()=>{if(!a.trim()||l.size===0)return;p(!0);const m=[...l],x={},y={};for(const k of m){const C=v.find(P=>P.id===k);C&&(x[k]=C.type,y[k]=C.name)}await i(a.trim(),m,x,y),p(!1)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:r,children:c.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] max-h-[80vh] flex flex-col",onClick:m=>m.stopPropagation(),children:[c.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[c.jsx("h3",{className:"text-sm font-semibold",children:n("modals.createGroupChat.title")}),c.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:n("modals.createGroupChat.subtitle")})]}),c.jsx("div",{className:"px-5 py-3 border-b border-border-default",children:c.jsx("input",{value:a,onChange:m=>o(m.target.value),placeholder:n("modals.createGroupChat.groupNamePlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50",autoFocus:!0})}),c.jsx("div",{className:"px-5 py-2 border-b border-border-default",children:c.jsx("input",{value:u,onChange:m=>d(m.target.value),placeholder:n("modals.createGroupChat.searchPlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-1.5 text-xs text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50"})}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 min-h-0 max-h-[300px]",children:[b.length===0&&c.jsx("p",{className:"text-xs text-fg-tertiary px-2 py-4 text-center",children:n("modals.createGroupChat.noMembersFound")}),b.map(m=>c.jsxs("button",{onClick:()=>O(m.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${l.has(m.id)?"bg-brand-500/10 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[c.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center shrink-0 transition-colors ${l.has(m.id)?"bg-brand-500 border-brand-500":"border-border-default"}`,children:l.has(m.id)&&c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})})}),c.jsx(Is,{name:m.name,size:20,bgClass:m.type==="agent"?"bg-brand-500/15 text-brand-500":"bg-green-500/15 text-green-600"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("span",{className:"truncate text-[11px] font-medium block",children:m.name}),c.jsx("span",{className:"text-[9px] text-fg-tertiary",children:m.subtitle})]}),c.jsx("span",{className:`text-[8px] px-1.5 py-0.5 rounded-full font-medium ${m.type==="agent"?"bg-brand-500/10 text-brand-500":"bg-green-500/10 text-green-600"}`,children:m.type==="agent"?n("modals.addExisting.typeAgent"):n("modals.addExisting.typeHuman")})]},m.id))]}),c.jsxs("div",{className:"px-5 py-3 border-t border-border-default flex items-center justify-between",children:[c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:n("modals.createGroupChat.selected",{count:l.size})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:r,className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:n("common:cancel")}),c.jsx("button",{onClick:g,disabled:!a.trim()||l.size===0||f,className:"px-4 py-1.5 text-xs font-medium text-on-brand bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors disabled:opacity-50 disabled:pointer-events-none",children:n(f?"modals.createGroupChat.creating":"modals.createGroupChat.create")})]})]})]})})}const JP=w.memo(function({authUser:e,agents:t,teams:r,humans:i,tasks:n,externalAgents:a,groupChats:o,chatMode:l,selectedAgent:h,activeChannel:u,activeDmUserId:d,onSelectAgent:f,onSelectChannel:p,onSelectDm:v,onSelectTeam:b,selectedTeamId:O,onRefreshTeams:g,onRefreshAgents:m,onRefreshHumans:x,onRefreshGroupChats:y,onViewProfile:k,onManageGroupMembers:C,unreadByAgent:P,unreadByChannel:_,width:Q,onResizeStart:E,hidden:A,onCollapse:N,initialLoading:R,previewMode:W,focused:H,l2Available:Z}){const{t:B}=Tt(["team","common"]),K=rp(),$=ip(Ut.TEAM),I=zo(),X=e?.role==="owner"||e?.role==="admin",q=w.useMemo(()=>new Set(a.map(z=>z.markusAgentId).filter(Boolean)),[a]);uh();const ie=Cs.streamingAgentIds(),[pe,$e]=w.useState([]),[re,U]=w.useState(new Set),[M,te]=w.useState(!1),[Y,ae]=w.useState(!1),[ee,me]=w.useState(null),[Re,_e]=w.useState(!1),[De,Te]=w.useState(!1),[Fe,Ue]=w.useState(null),[ve,V]=w.useState(null),[Xe,Ke]=w.useState(null),[ft,mt]=w.useState(!1),[_t,Xt]=w.useState(""),[dt,Dt]=w.useState(null),[Me,jt]=w.useState(null),[ye,ze]=w.useState(null),[Ie,ce]=w.useState(!1),et=w.useRef(null),[xe,gt]=w.useState(null),He=w.useRef(null),Ct=w.useRef(null),[vt,de]=w.useState(null),we=(z,Oe="success")=>{de({message:z,type:Oe}),setTimeout(()=>de(null),3e3)};w.useEffect(()=>{if(!W)return;const z=setTimeout(()=>{const Oe=Ct.current,le=He.current;Oe&&le&&le.scrollTo({top:Oe.offsetTop-le.offsetTop-8,behavior:"instant"})},100);return()=>clearTimeout(z)},[W]);const[oe,st]=w.useState(null),ue=(z,Oe,le,Be,rt)=>{st({title:z,message:Oe,onConfirm:le,confirmLabel:Be,checkboxes:rt})},[Le,ke]=w.useState(null),[nt,Ye]=w.useState(null),Je=w.useRef(null),J=w.useRef(null),[je,Qe]=w.useState(!1),[be,Pe]=w.useState(null),[tt,pt]=w.useState(""),Pt=w.useCallback((z,Oe=176,le=220)=>{const Be=window.innerWidth,rt=window.innerHeight,ot=8;let ut=z.clientX,Lt=z.clientY;return ut+Oe>Be-ot&&(ut=Math.max(ot,Be-Oe-ot)),Lt+le>rt-ot&&(Lt=Math.max(ot,rt-le-ot)),ut=Math.max(ot,Math.min(ut,Be-Oe-ot)),Lt=Math.max(ot,Math.min(Lt,rt-le-ot)),{x:ut,y:Lt}},[]),[kt,Ot]=w.useState(gc),At=w.useMemo(()=>t.map(z=>z.id).sort().join(","),[t]);w.useEffect(()=>{if(!t.length||!$)return;let z=!1;(async()=>{const ut=[];await Promise.allSettled(t.map(async Lt=>{if(!gc.has(Lt.id))try{const{sessions:St}=await ne.sessions.listByAgent(Lt.id,1);if(!St.length)return;const{messages:ss}=await ne.sessions.getMessages(St[0].id,1);if(ss.length){const gs=ss[0],rr=gs.metadata?.segments;let ni=gs.content;if(rr&&rr.length>0){const xr=[...rr].reverse().find(us=>us.type==="text");xr&&xr.type==="text"&&(ni=xr.content)}const Br=ni.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80);Br&&ut.push([Lt.id,Br])}}catch{}})),!z&&ut.length&&Ot(Lt=>{const St=new Map(Lt);for(const[ss,gs]of ut)St.set(ss,gs);return gc=St,St})})();const le=new Set(t.map(ut=>ut.id)),Be=ut=>UC(ut).replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80),rt=(ut,Lt)=>{if(!ut||!Lt||!le.has(ut))return;const St=Be(Lt);St&&Ot(ss=>{const gs=new Map(ss);return gs.set(ut,St),gc=gs,gs})},ot=Rt.on("chat:proactive_message",ut=>{const Lt=ut.payload;rt(Lt.agentId??"",Lt.message??"")});return()=>{z=!0,ot()}},[At,$]);const js=w.useCallback(()=>{W||ne.teams.list().then(z=>$e(z.ungrouped)).catch(()=>{})},[W]);w.useEffect(()=>{js()},[js]),w.useEffect(()=>{if(!$)return;const z=Rt.on("team:update",js),Oe=Rt.on("agent:removed",js);return()=>{z(),Oe()}},[js,$]),w.useEffect(()=>{if(!ve&&!Xe&&!dt&&!Ie&&!ye)return;const z=()=>{V(null),Ke(null),Dt(null),ze(null),ce(!1)},Oe=setTimeout(()=>document.addEventListener("click",z),0);return()=>{clearTimeout(Oe),document.removeEventListener("click",z)}},[ve,Xe,dt,Ie,ye]);const he=(z,Oe)=>{ue(`${B("common:delete")} "${Oe}"?`,B("modals.deleteTeam.message"),async le=>{const Be=le?.deleteMembers??!0,rt=le?.purgeFiles??!1;await ne.teams.delete(z,Be,{purgeFiles:rt}),g(),js(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},B("contextMenu.deleteTeam"),[{id:"deleteMembers",label:B("modals.deleteTeam.deleteMembers"),defaultChecked:!0},{id:"purgeFiles",label:B("modals.deleteTeam.purgeFiles"),defaultChecked:!1}])},Mt=async(z,Oe)=>{try{const Be=await(Oe==="start"?ne.teams.startAll:ne.teams.stopAll)(z),rt=Be.success?.length??0,ot=Be.failed?.length??0;ot>0?we(B("batchAction.failed",{action:B(`batchAction.operation.${Oe}`),ok:rt,fail:ot}),"error"):rt>0&&we(B("batchAction.succeeded",{count:rt,action:B(`batchAction.past.${Oe}`)}),"success"),m()}catch(le){we(B("batchAction.failedToRun",{action:B(`batchAction.operation.${Oe}`),error:le instanceof Error?le.message:String(le)}),"error")}},ge=async(z,Oe,le)=>{await ne.teams.update(z,{managerId:Oe,managerType:le}),g()},Xs=async z=>{if(!tt.trim()){Pe(null);return}await ne.teams.update(z,{name:tt.trim()}),Pe(null),g()},yt=async(z,Oe)=>{if(Oe==="offline"){await ne.agents.start(z),m();return}ue(B("modals.stopAgent.title"),B("modals.stopAgent.message"),async()=>{await ne.agents.stop(z),m()},B("contextMenu.stop"))},zs=(z,Oe)=>{ue(B("modals.removeFromTeam.title"),B("modals.removeFromTeam.message"),async()=>{await ne.teams.removeMember(z,Oe),g(),js()},B("common:remove"))},Zt=(z,Oe,le,Be)=>{ue(`${B("common:remove")} "${Oe}"?`,B(le==="agent"?"modals.removeAgent.message":"modals.removeHuman.message"),async rt=>{if(le==="agent"&&Be){const ot=o.find(ut=>ut.type==="team"&&ut.teamId===Be);ot?.channelKey&&localStorage.setItem("markus_nav_after_remove","channel:"+ot.channelKey)}if(le==="agent"){const ot=rt?.purgeFiles??!1;await ne.agents.remove(z,{purgeFiles:ot})}else await ne.users.remove(z);m(),g(),x?.(),js(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},B("common:remove"),le==="agent"?[{id:"purgeFiles",label:B("modals.removeAgent.purgeFiles"),defaultChecked:!1}]:void 0)},Ti=z=>{if(z.isOrgSecretary||z.protected)return!0;if(z.teamId)return!1;const Oe=(z.role??"").toLowerCase().trim(),le=(z.name??"").trim();return le==="Secretary"||le==="秘书"||Oe==="secretary"||Oe.startsWith("secretary")},Rl=(z,Oe,le)=>{const Be=t.find(rt=>rt.id===Oe);Be&&Ti(Be)||(J.current={x:z.clientX,y:z.clientY},Je.current=setTimeout(()=>{ke({agentId:Oe,fromTeamId:le}),Qe(!0)},200))},ln=z=>{if(!J.current||!Je.current)return;const Oe=Math.abs(z.clientX-J.current.x),le=Math.abs(z.clientY-J.current.y);(Oe>5||le>5)&&(je||(clearTimeout(Je.current),Je.current=null))},fd=async()=>{if(Je.current&&(clearTimeout(Je.current),Je.current=null),J.current=null,je&&Le&&nt){const z=nt==="_ungrouped"?void 0:nt;try{if(Le.fromTeamId&&Le.fromTeamId!==z&&await ne.teams.removeMember(Le.fromTeamId,Le.agentId),z&&z!==Le.fromTeamId){const Oe=t.find(le=>le.id===Le.agentId);await ne.teams.addMember(z,Le.agentId,"agent")}g(),m(),js()}catch(Oe){we(B("batchAction.moveFailed",{error:Oe instanceof Error?Oe.message:String(Oe)}),"error")}}ke(null),Ye(null),Qe(!1)},cn=w.useMemo(()=>new Map(r.map(z=>[z.id,z])),[r]),zt=w.useMemo(()=>{const z=new Map,Oe=[];for(const le of t)if(le.teamId&&cn.has(le.teamId)){const Be=z.get(le.teamId)??[];Be.push(le),z.set(le.teamId,Be)}else Oe.push(le);return{byTeam:z,ungrouped:Oe}},[t,cn]),ns=(z,Oe)=>{const le=l==="direct"&&h===z.id,Be=q.has(z.id),rt=z.status==="offline",ot=yl(z.status,!rt&&ie.has(z.id)),ut=ot.tone==="busy",Lt=ot.dotClass,ss=(void 0)?.managerId===z.id,gs=z.role?.toLowerCase().replace(/[-_]/g," ").trim(),rr=z.name.toLowerCase().trim(),ni=gs&&gs!==rr,Br=kt.get(z.id)||z.currentActivity?.label?.slice(0,60)||"",xr=ut?B("common:status.working"):z.status==="error"?B("common:status.error"):B(rt?"common:status.offline":"common:status.online");return c.jsx("div",{className:`relative mb-0.5 ${je&&Le?.agentId===z.id?"opacity-40":""}`,onPointerDown:us=>Rl(us,z.id,Oe),onPointerMove:ln,onPointerUp:fd,children:c.jsxs("button",{"data-l1-nav-id":`agent:${z.id}`,onClick:()=>{je||f(z.id)},onContextMenu:us=>{if(!X)return;us.preventDefault();const ji=Pt(us);mt(!1),Xt(""),Ke({agentId:z.id,teamId:Oe,...ji})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors select-none ${K?"":"touch-none"} ${rt?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${$i(le)}`,children:[c.jsx(Is,{name:z.name,avatarUrl:z.avatarUrl,size:28,bgClass:rt?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:z.name}),ni&&c.jsxs("span",{className:"text-[9px] text-fg-secondary shrink-0 truncate max-w-[80px]",children:["(",z.role,")"]}),ss&&c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:c.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),Be&&c.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-brand-500/20 text-brand-400 font-medium shrink-0 leading-relaxed",children:"EXT"}),rt&&c.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:B("common:status.offline")})]}),c.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:Br||" "})]}),c.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[(P?.get(z.id)??0)>0&&c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:P.get(z.id)}),z.mailboxDepth!=null&&z.mailboxDepth>0&&c.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:z.mailboxDepth}),c.jsx("span",{title:xr,onClick:us=>{us.stopPropagation(),k(z.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${Lt}`}),K&&X&&c.jsx("span",{role:"button",tabIndex:0,onClick:us=>{if(us.stopPropagation(),Xe?.agentId===z.id)Ke(null);else{const ji=Pt(us);mt(!1),Xt(""),Ke({agentId:z.id,teamId:Oe,...ji})}},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors",title:B("chat.moreOptions"),children:c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"1"}),c.jsx("circle",{cx:"12",cy:"5",r:"1"}),c.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]})]})},z.id)},Rs=(z,Oe,le,Be)=>{const rt=je&&nt===z&&Le?.fromTeamId!==z,ot=xe===z,ut=O===z,Lt=P?(zt.byTeam.get(z)??[]).reduce((Kt,fn)=>Kt+(P.get(fn.id)??0),0):0,ss=o.find(Kt=>Kt.type==="team"&&Kt.teamId===z)?.channelKey??my(z),gs=_?_[ss]??0:0,rr=Lt+gs,ni=zt.byTeam.get(z)??[],Br=ni.filter(Kt=>Kt.status==="offline").length,xr=ni.length,us=xr>0&&Br===xr,ji=Br>0&&!us,md=us?"bg-gray-500":ji?"bg-amber-500":"bg-green-500";return c.jsxs("div",{"data-team-id":z,className:`mb-0.5 rounded-lg transition-all duration-500 ${rt?"ring-1 ring-brand-500/50 bg-brand-500/5":""} ${ot?"ring-2 ring-brand-500 bg-brand-500/10":""}`,onPointerEnter:()=>{je&&Ye(z)},onPointerLeave:()=>{je&&nt===z&&Ye(null)},children:[c.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[c.jsxs("button",{"data-l1-nav-id":`team:${z}`,onClick:()=>{b&&z!=="_ungrouped"&&b(z)},onContextMenu:Kt=>{if(!X||!Oe)return;Kt.preventDefault();const fn=Pt(Kt);V({teamId:z,...fn})},className:`flex-1 flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors min-w-0 ${us?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${$i(ut)}`,children:[c.jsxs("div",{className:`w-7 h-7 rounded-full flex items-center justify-center shrink-0 relative ${us?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}`,children:[Oe?.avatarUrl?c.jsx("img",{src:Oe.avatarUrl,alt:Be,className:"w-full h-full rounded-full object-cover",onError:Kt=>{Kt.target.style.display="none",Kt.target.nextElementSibling?.classList.remove("hidden")}}):null,c.jsxs("svg",{className:`w-3 h-3 ${Oe?.avatarUrl?"hidden":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),xr>0&&c.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-surface-primary ${md}`})]}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[be===z?c.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-primary text-[12px] font-medium outline-none w-full",value:tt,onChange:Kt=>pt(Kt.target.value),onBlur:()=>Xs(z),onKeyDown:Kt=>{Kt.key==="Enter"&&Xs(z),Kt.key==="Escape"&&Pe(null)},onClick:Kt=>Kt.stopPropagation(),autoFocus:!0}):c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:Be}),c.jsxs("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5 flex items-center gap-1.5",children:[B("chat.members_other",{count:le}),us&&c.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium leading-relaxed",children:B("common:status.offline")}),ji&&c.jsxs("span",{className:"text-[8px] px-1 py-0 rounded bg-amber-500/20 text-amber-500 font-medium leading-relaxed",children:[Br,"/",xr]})]})]}),rr>0&&c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:rr}),c.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:c.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})]}),X&&Oe&&c.jsx("button",{onClick:Kt=>{if(Kt.stopPropagation(),ve?.teamId===z)V(null);else{const fn=Pt(Kt);V({teamId:z,...fn})}},className:"w-7 h-7 flex items-center justify-center text-fg-muted hover:text-fg-primary rounded-md hover:bg-white/[0.08] transition-colors shrink-0",title:B("chat.moreOptions"),children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"1"}),c.jsx("circle",{cx:"12",cy:"5",r:"1"}),c.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]}),rt&&je&&c.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:B("chat.dropHere")})]},z)},hs=w.useMemo(()=>{const z=new Map,Oe=[],le=[],Be=[];for(const rt of o)if(rt.channelKey.startsWith("dm:a2a:"))Be.push(rt);else if(rt.type==="custom")le.push(rt);else if(rt.teamId){const ot=z.get(rt.teamId)??[];ot.push(rt),z.set(rt.teamId,ot)}else{const ot=r.find(ut=>rt.name.toLowerCase().includes(ut.name.toLowerCase())||ut.name.toLowerCase().includes(rt.name.toLowerCase()));if(ot){const ut=z.get(ot.id)??[];ut.push(rt),z.set(ot.id,ut)}else Oe.push(rt)}return{byTeam:z,unmatched:Oe,custom:le,dmChannels:Be}},[o,r]),Qi=w.useMemo(()=>{const z=new Map;let Oe=0;for(const rt of zt.ungrouped)z.set(rt.id,Oe++);for(const rt of r)for(const ot of zt.byTeam.get(rt.id)??[])z.set(ot.id,Oe++);const le=Number.MAX_SAFE_INTEGER,Be=rt=>{const ot=rt.split(":");return ot.length<4?[]:[ot[2],ot[3]].map(ut=>z.get(ut)??le).sort((ut,Lt)=>ut-Lt)};return[...hs.dmChannels].sort((rt,ot)=>{const ut=Be(rt.channelKey),Lt=Be(ot.channelKey),St=ut[0]??le,ss=ut[1]??le,gs=Lt[0]??le,rr=Lt[1]??le;return St!==gs?St-gs:ss!==rr?ss-rr:rt.channelKey.localeCompare(ot.channelKey)})},[hs.dmChannels,zt,r]),[hn,dn]=w.useState(!1),un=l==="channel"&&hs.dmChannels.some(z=>z.channelKey===u);w.useEffect(()=>{un&&dn(!0)},[un]);const Gn=w.useMemo(()=>{const z=[];e&&z.push({kind:"dm",id:`dm:${e.id}`,userId:e.id});for(const le of i)le.id!==e?.id&&z.push({kind:"dm",id:`dm:${le.id}`,userId:le.id});for(const le of hs.custom)z.push({kind:"channel",id:`channel:${le.channelKey}`,channelKey:le.channelKey});for(const le of hs.unmatched)z.push({kind:"channel",id:`channel:${le.channelKey}`,channelKey:le.channelKey});const Oe=zt.ungrouped.length>0?zt.ungrouped:r.length===0?t:[];for(const le of Oe)z.push({kind:"agent",id:`agent:${le.id}`,agentId:le.id});for(const le of r)z.push({kind:"team",id:`team:${le.id}`,teamId:le.id});if(hn)for(const le of Qi)z.push({kind:"channel",id:`channel:${le.channelKey}`,channelKey:le.channelKey});return z},[e,i,hs,zt,r,t,hn]),Yo=w.useRef(Gn);Yo.current=Gn;const Hs=w.useCallback(z=>{z.kind==="dm"?v(z.userId):z.kind==="channel"?p(z.channelKey):z.kind==="agent"?f(z.agentId):z.kind==="team"&&b?.(z.teamId),requestAnimationFrame(()=>{document.querySelector(`[data-l1-nav-id="${z.id}"]`)?.scrollIntoView({block:"nearest"})})},[v,p,f,b]);w.useEffect(()=>{if(W||K||!$||A)return;const z=Oe=>{const le=I?.keyboardPane??"content";if(le==="l0"||le==="l2"||Oe.metaKey||Oe.ctrlKey||Oe.altKey||np(Oe.target))return;const Be=Oe.key.length===1?Oe.key.toLowerCase():Oe.key;if(Be==="h"||Be==="ArrowLeft"){if(le!=="l1")return;Oe.preventDefault(),Oe.stopPropagation(),I?.setL0FocusPageId(Ut.TEAM),I?.setLeftCollapsed(!1),I?.setKeyboardPane("l0");return}if(Be==="l"||Be==="ArrowRight"){if(le!=="l1")return;Oe.preventDefault(),Oe.stopPropagation(),Z&&I?.setKeyboardPane("l2");return}if(le!=="l1"&&!(H&&(Be==="j"||Be==="k"||Be==="ArrowDown"||Be==="ArrowUp")))return;const rt=Be==="j"||Be==="ArrowDown"?1:Be==="k"||Be==="ArrowUp"?-1:0;if(!rt)return;Oe.preventDefault(),Oe.stopPropagation(),I?.setKeyboardPane("l1");const ot=Yo.current;if(ot.length===0)return;let ut=-1;if(l==="dm"){const St=d||e?.id;St&&(ut=ot.findIndex(ss=>ss.kind==="dm"&&ss.userId===St))}else l==="direct"?ut=ot.findIndex(St=>St.kind==="agent"&&St.agentId===h):l==="channel"&&(ut=ot.findIndex(St=>St.kind==="channel"&&St.channelKey===u),ut<0&&O&&(ut=ot.findIndex(St=>St.kind==="team"&&St.teamId===O)));ut<0&&(ut=rt>0?-1:0);const Lt=Math.max(0,Math.min(ot.length-1,ut+rt));Hs(ot[Lt])};return document.addEventListener("keydown",z,!0),()=>document.removeEventListener("keydown",z,!0)},[W,K,$,A,I,H,Z,l,d,e?.id,h,u,O,Hs]);const $i=z=>z?H?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-surface-overlay":"hover:bg-surface-overlay/60";return c.jsxs(c.Fragment,{children:[c.jsxs("div",{"data-keyboard-pane":"l1",className:`bg-surface-primary flex flex-col ${Q!=null?"shrink-0":"flex-1 min-w-0"} ${H?"ring-1 ring-inset ring-brand-500/30":""}`,style:A?{display:"none"}:Q!=null?{width:Q}:void 0,children:[c.jsxs("div",{"data-electron-drag":!0,className:"px-4 h-14 flex items-center shrink-0 gap-2",children:[K&&c.jsx(fC,{}),!K&&N&&c.jsx("button",{onClick:N,className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),c.jsx("h2",{className:"text-lg font-semibold",children:B("chat.title")}),X&&c.jsxs("div",{"data-no-drag":!0,className:"ml-auto relative",ref:et,children:[c.jsxs("button",{onClick:()=>ce(!Ie),className:"flex items-center gap-1.5 px-3.5 py-1.5 text-xs font-semibold text-on-brand bg-brand-600 hover:bg-brand-700 rounded-lg shadow-sm transition-colors",children:[c.jsx("span",{className:"opacity-70",children:"+"})," ",B("chat.manage"),c.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${Ie?"rotate-180":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:c.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),Ie&&c.jsxs("div",{ref:z=>{if(!z)return;const Oe=z.getBoundingClientRect(),le=window.innerWidth,Be=8;Oe.right>le-Be&&(z.style.left="auto",z.style.right="0"),Oe.left<Be&&(z.style.left="0",z.style.right="auto")},className:"absolute right-0 top-full mt-1 w-48 max-w-[calc(100vw-1rem)] bg-surface-elevated border border-border-default rounded-lg shadow-xl z-50 overflow-hidden",children:[c.jsxs("button",{onClick:()=>{ce(!1),Ue("agent")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated transition-colors",children:[c.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),c.jsx("circle",{cx:"12",cy:"5",r:"2"}),c.jsx("path",{d:"M12 7v4"}),c.jsx("circle",{cx:"9",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"15",cy:"16",r:"1",fill:"currentColor",stroke:"none"})]}),B("chat.addAgent")]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:B("chat.addAgentDesc")})]}),c.jsxs("button",{onClick:()=>{ce(!1),Ue("team")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[c.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("line",{x1:"19",y1:"8",x2:"19",y2:"14"}),c.jsx("line",{x1:"22",y1:"11",x2:"16",y2:"11"})]}),B("chat.newTeam")]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:B("chat.newTeamDesc")})]}),c.jsxs("button",{onClick:()=>{ce(!1),ae(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[c.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M20 8v6"}),c.jsx("path",{d:"M23 11h-6"})]}),B("chat.addHuman")]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:B("chat.addHumanDesc")})]}),c.jsxs("button",{onClick:()=>{ce(!1),Te(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[c.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),c.jsx("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),B("chat.newGroupChat")]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:B("chat.newGroupChatDesc")})]})]})]})]}),c.jsxs("div",{ref:He,className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:B("chat.people")}),e&&c.jsxs("button",{"data-l1-nav-id":`dm:${e.id}`,onClick:()=>v(e.id),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${$i(l==="dm"&&(d===e.id||!d))}`,children:[c.jsx(Is,{name:e.name,avatarUrl:e.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-400"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:e.name}),c.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:B("chat.myNotes")})]}),c.jsx("span",{className:"text-fg-secondary shrink-0",children:c.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),c.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),i.filter(z=>z.id!==e?.id).map(z=>{const Oe=e?.id?`dm:${[e.id,z.id].sort().join(":")}`:"",le=Oe&&_?_[Oe]??0:0;return c.jsxs("button",{"data-l1-nav-id":`dm:${z.id}`,onClick:()=>v(z.id),onContextMenu:Be=>{if(!X||z.id===e?.id)return;Be.preventDefault();const rt=Pt(Be);Dt({userId:z.id,...rt})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${l==="dm"&&d===z.id?H?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-green-500/15":"hover:bg-surface-overlay/60"}`,children:[c.jsx(Is,{name:z.name,avatarUrl:z.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:z.name}),c.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:z.email||z.role})]}),le>0?c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:le}):c.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},z.id)})]}),hs.custom.length>0&&c.jsxs("div",{className:"mb-2",children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-2.5",children:B("chat.groups")}),hs.custom.map(z=>{const Oe=l==="channel"&&u===z.channelKey;return c.jsxs("button",{"data-l1-nav-id":`channel:${z.channelKey}`,onClick:()=>p(z.channelKey),onContextMenu:le=>{le.preventDefault();const Be=Pt(le);ze({gcId:z.id,...Be})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${$i(Oe)}`,children:[c.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:z.name}),c.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:B("chat.members_other",{count:z.memberCount??0})})]})]},z.id)})]}),R?c.jsx("div",{className:"space-y-3 px-1 mb-2",children:[...Array(6)].map((z,Oe)=>c.jsxs("div",{className:"flex items-center gap-2.5 animate-pulse",children:[c.jsx("div",{className:"w-6 h-6 rounded-lg bg-surface-overlay shrink-0"}),c.jsxs("div",{className:"flex-1 space-y-1.5",children:[c.jsx("div",{className:"h-2.5 bg-surface-overlay rounded w-24"}),c.jsx("div",{className:"h-2 bg-surface-overlay rounded w-36"})]}),c.jsx("div",{className:"w-2 h-2 rounded-full bg-surface-overlay shrink-0"})]},Oe))}):t.length===0&&r.length===0?c.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:B("chat.noAgentsYet")}):null,hs.unmatched.map(z=>{const Oe=_?.[z.channelKey]??0;return c.jsxs("button",{"data-l1-nav-id":`channel:${z.channelKey}`,onClick:()=>p(z.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${$i(l==="channel"&&u===z.channelKey)}`,children:[c.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:z.name}),c.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:B("chat.groupChat")})]}),Oe>0?c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:Oe}):z.memberCount!==void 0&&z.memberCount>0?c.jsx("span",{className:"text-[9px] text-fg-secondary shrink-0",children:z.memberCount}):null]},z.id)}),zt.ungrouped.length>0&&c.jsxs("div",{className:"mb-2",children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:B("chat.agents")}),zt.ungrouped.map(z=>ns(z))]}),r.length>0&&c.jsxs("div",{className:"mb-2",ref:Ct,children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:B("chat.teams")}),r.map(z=>{const Oe=zt.byTeam.get(z.id)??[],le=z.members?.length||Oe.length;return Rs(z.id,z,le,z.name)})]}),r.length===0&&zt.ungrouped.length===0&&t.length>0&&t.map(z=>ns(z)),Qi.length>0&&c.jsxs("div",{className:"mb-2",children:[c.jsxs("button",{onClick:()=>dn(z=>!z),className:"w-full flex items-center gap-1.5 px-2.5 py-1 text-[10px] font-semibold text-fg-muted uppercase tracking-wider hover:text-fg-secondary transition-colors",children:[c.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${hn?"rotate-90":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:c.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),B("chat.agentDMs"),c.jsx("span",{className:"ml-auto text-[9px] font-normal text-fg-tertiary",children:Qi.length})]}),hn&&Qi.map(z=>{const Oe=l==="channel"&&u===z.channelKey,le=_?.[z.channelKey]??0,Be=z.name.replace(/^DM:\s*/,"");return c.jsxs("button",{"data-l1-nav-id":`channel:${z.channelKey}`,onClick:()=>p(z.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 pl-5 py-1.5 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${$i(Oe)}`,children:[c.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center shrink-0 bg-surface-overlay/60 text-fg-tertiary text-[9px]",children:c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),c.jsx("span",{className:"flex-1 min-w-0 text-left truncate text-[11px] text-fg-secondary",children:Be}),le>0&&c.jsx("span",{className:"min-w-[14px] h-[14px] flex items-center justify-center text-[8px] font-semibold text-white bg-red-500 rounded-full px-0.5 leading-none",children:le})]},z.id)})]})]})]}),E&&c.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:E,children:c.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),ve&&(()=>{const z=zt.byTeam.get(ve.teamId)??[],Oe=z.some(Be=>Be.status==="offline"),le=z.some(Be=>Be.status!=="offline");return c.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:ve.x,top:ve.y},onClick:Be=>Be.stopPropagation(),children:[c.jsxs("button",{onClick:()=>{const Be=cn.get(ve.teamId);Be&&(Pe(ve.teamId),pt(Be.name)),V(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),c.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),B("contextMenu.renameTeam")]}),Oe&&c.jsxs("button",{onClick:()=>{Mt(ve.teamId,"start"),V(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),B("contextMenu.startAll")]}),le&&c.jsxs("button",{onClick:()=>{Mt(ve.teamId,"stop"),V(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),B("contextMenu.stopAll")]}),c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{onClick:()=>{V(null),gr.navigate(Ut.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),c.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),B("chat.addAgent")]}),pe.length>0&&c.jsxs("button",{onClick:()=>{V(null),me(ve.teamId)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),c.jsx("polyline",{points:"17 11 19 13 23 9"})]}),B("contextMenu.addExisting")]}),c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{onClick:()=>{const Be=cn.get(ve.teamId);Be&&he(ve.teamId,Be.name),V(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"3 6 5 6 21 6"}),c.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),B("contextMenu.deleteTeam")]})]})})(),Xe&&(()=>{const z=t.find(ot=>ot.id===Xe.agentId);if(!z||!X)return null;const le=(Xe.teamId?cn.get(Xe.teamId):void 0)?.managerId===z.id,Be=z.id===e?.id,rt=Ti(z);return c.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-48 max-w-[calc(100vw-1rem)] overflow-y-auto",style:{left:Xe.x,top:Xe.y,maxHeight:Math.max(160,window.innerHeight-Xe.y-8)},onClick:ot=>ot.stopPropagation(),children:[rt&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-2 text-[10px] leading-snug text-fg-secondary font-medium",children:B("contextMenu.orgSecretaryProtected")}),c.jsx("div",{className:"border-t border-border-default/50 my-1"})]}),c.jsxs("button",{onClick:()=>{Ke(null),k(z.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),B("contextMenu.viewProfile")]}),z.status==="offline"?c.jsxs("button",{onClick:()=>{yt(z.id,"offline"),Ke(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),B("contextMenu.start")]}):c.jsxs("button",{onClick:()=>{yt(z.id,z.status??"idle"),Ke(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),B("contextMenu.stop")]}),!rt&&Xe.teamId&&!le&&c.jsxs("button",{onClick:()=>{ge(Xe.teamId,z.id,"agent"),Ke(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),B("contextMenu.setAsManager")]}),!rt&&Xe.teamId&&c.jsxs("button",{onClick:()=>{zs(Xe.teamId,z.id),Ke(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"9 14 4 9 9 4"}),c.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),B("contextMenu.removeFromTeam")]}),!rt&&(()=>{const ot=r.filter(St=>St.id!==Xe.teamId);if(ot.length===0)return null;const ut=_t.trim().toLowerCase(),Lt=ut?ot.filter(St=>St.name.toLowerCase().includes(ut)):ot;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{type:"button",onClick:()=>mt(St=>!St),className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M5 12h14"}),c.jsx("path",{d:"M12 5l7 7-7 7"})]}),c.jsx("span",{className:"flex-1",children:B("contextMenu.moveTo")}),c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-tertiary transition-transform ${ft?"rotate-180":""}`,children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),ft&&c.jsxs("div",{className:"px-2 pb-1.5",onClick:St=>St.stopPropagation(),children:[c.jsx("input",{autoFocus:!0,value:_t,onChange:St=>Xt(St.target.value),onKeyDown:St=>St.stopPropagation(),placeholder:B("contextMenu.moveToSearch"),className:"w-full mb-1 px-2 py-1.5 text-xs rounded-md bg-surface-overlay border border-border-default text-fg-primary placeholder:text-fg-tertiary outline-none focus:border-brand-500/50"}),c.jsx("div",{className:"max-h-36 overflow-y-auto rounded-md",children:Lt.length===0?c.jsx("div",{className:"px-2 py-2 text-[10px] text-fg-tertiary",children:B("contextMenu.moveToEmpty")}):Lt.map(St=>c.jsx("button",{type:"button",onClick:async()=>{Xe.teamId&&await ne.teams.removeMember(Xe.teamId,z.id),await ne.teams.addMember(St.id,z.id,"agent"),g(),m(),js(),Ke(null)},className:"w-full text-left px-2 py-1.5 text-xs hover:bg-surface-overlay text-fg-secondary rounded truncate",title:St.name,children:St.name},St.id))})]})]})})(),!rt&&!Be&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{onClick:()=>{Zt(z.id,z.name,"agent",Xe.teamId),Ke(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"3 6 5 6 21 6"}),c.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),B("contextMenu.removeFromOrg")]})]})]})})(),dt&&(()=>{const z=i.find(Oe=>Oe.id===dt.userId);return!z||!X?null:c.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:dt.x,top:dt.y},onClick:Oe=>Oe.stopPropagation(),children:c.jsxs("button",{onClick:()=>{Zt(z.id,z.name,"human"),Dt(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"3 6 5 6 21 6"}),c.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),B("contextMenu.removeFromOrg")]})})})(),M&&c.jsx(NP,{onClose:()=>te(!1),onCreate:async(z,Oe)=>{try{const{team:le}=await ne.teams.create(z,Oe);te(!1),g(),gt(le.id),setTimeout(()=>{document.querySelector(`[data-team-id="${le.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},300),setTimeout(()=>gt(null),3e3)}catch(le){we(B("chat.failedToCreateTeam",{message:le instanceof Error?le.message:String(le)}),"error")}}}),Y&&c.jsx(DP,{onClose:()=>{ae(!1),x?.()},onAdd:async(z,Oe,le)=>{const{inviteToken:Be}=await ne.users.create(z,Oe,void 0,le);return x?.(),{inviteToken:Be}}}),ee!==null&&c.jsx(IP,{teamId:ee,ungrouped:pe,onClose:()=>me(null),onAdd:async(z,Oe)=>{await ne.teams.addMember(ee,z,Oe),me(null),g(),js()}}),Re&&c.jsx(BP,{onClose:()=>_e(!1),onConnected:()=>{_e(!1),m(),g()}}),ye&&(()=>{const z=o.find(Oe=>Oe.id===ye.gcId);return z?c.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:ye.x,top:ye.y},onClick:Oe=>Oe.stopPropagation(),children:[z.type==="custom"&&c.jsxs("button",{onClick:()=>{ze(null),C?C(z.channelKey):p(z.channelKey)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),B("contextMenu.manageMembers")]}),c.jsxs("button",{onClick:async()=>{ze(null),ue(B("modals.deleteGroupChat.title"),B("modals.deleteGroupChat.message",{name:z.name}),async()=>{await ne.groupChats.delete(z.id),y()},B("modals.deleteGroupChat.confirm"))},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"3 6 5 6 21 6"}),c.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),B("modals.deleteGroupChat.menuLabel")]})]}):null})(),De&&c.jsx(KP,{agents:t,humans:i,authUser:e,onClose:()=>Te(!1),onCreate:async(z,Oe,le,Be)=>{await ne.groupChats.create({name:z,memberIds:Oe,memberTypes:le,memberNames:Be,creatorId:e?.id,creatorName:e?.name}),Te(!1),y()}}),Fe&&c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:()=>Ue(null),children:c.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[340px] max-w-[90vw] overflow-hidden",onClick:z=>z.stopPropagation(),children:[c.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[c.jsx("h3",{className:"text-sm font-semibold",children:B(Fe==="agent"?"chat.addAgent":"chat.newTeam")}),c.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:B("chat.methodChoiceSubtitle")})]}),c.jsxs("div",{className:"p-3 space-y-2",children:[c.jsxs("button",{onClick:()=>{const z=Fe;Ue(null);const Oe=t.find(le=>le.role==="secretary")??t.find(le=>le.name?.toLowerCase().includes("secretary"));Oe?(f(Oe.id),gr.navigate(Ut.TEAM,{agentId:Oe.id,prefillMessage:B(z==="agent"?"chat.addAgentPrefill":"chat.newTeamPrefill")})):z==="agent"?gr.navigate(Ut.STORE):te(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-brand-500/30 bg-brand-500/5 hover:bg-brand-500/10 transition-colors text-left",children:[c.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-500/15 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-brand-500",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"}),c.jsx("path",{d:"M20 3v4"}),c.jsx("path",{d:"M22 5h-4"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-xs font-medium text-brand-500",children:B("chat.methodSecretary")}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:B("chat.methodSecretaryDesc")})]}),c.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-brand-500/10 text-brand-500 font-medium shrink-0",children:B("chat.recommended")})]}),c.jsxs("button",{onClick:()=>{const z=Fe;Ue(null),z==="agent"?gr.navigate(Ut.STORE):te(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:bg-surface-overlay transition-colors text-left",children:[c.jsx("div",{className:"w-8 h-8 rounded-full bg-surface-overlay flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-fg-secondary",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-xs font-medium text-fg-secondary",children:B("chat.methodManual")}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:B(Fe==="agent"?"chat.methodManualAgentDesc":"chat.methodManualTeamDesc")})]})]})]}),c.jsx("div",{className:"px-5 py-3 border-t border-border-default flex justify-end",children:c.jsx("button",{onClick:()=>Ue(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:B("common:cancel")})})]})}),oe&&c.jsx(qo,{title:oe.title,message:oe.message,confirmLabel:oe.confirmLabel,checkboxes:oe.checkboxes,onConfirm:z=>{oe.onConfirm(z),st(null)},onCancel:()=>st(null)}),vt&&c.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2.5 rounded-lg shadow-xl text-sm font-medium ${vt.type==="error"?"bg-red-500/10 text-red-500 border border-red-500/30":"bg-surface-elevated/95 text-fg-primary border border-border-default/50"}`,children:vt.message})]})});function w0({team:s,agents:e,humans:t,authUser:r,groupChat:i,chatMode:n,selectedAgent:a,activeChannel:o,activeDmUserId:l,teams:h,onSelectAgent:u,onSelectChannel:d,onSelectDm:f,onBack:p,onViewProfile:v,onRefreshAgents:b,onRefreshTeams:O,unreadByAgent:g,width:m,onResizeStart:x,focused:y}){const{t:k}=Tt(["team","common"]),C=zo(),P=ip(Ut.TEAM),_=r?.role==="owner"||r?.role==="admin";uh();const Q=w.useMemo(()=>e.filter(Y=>Y.teamId===s.id),[e,s.id]),E=w.useMemo(()=>{const Y=new Set((s.members??[]).filter(ae=>ae.type==="human").map(ae=>ae.id));return t.filter(ae=>Y.has(ae.id))},[s.members,t]),A=i&&n==="channel"&&o===i.channelKey,N=w.useMemo(()=>{const Y=[];i&&Y.push({kind:"channel",id:`channel:${i.channelKey}`,channelKey:i.channelKey});for(const ae of Q)Y.push({kind:"agent",id:`agent:${ae.id}`,agentId:ae.id});for(const ae of E)Y.push({kind:"dm",id:`dm:${ae.id}`,userId:ae.id});return Y},[i,Q,E]),R=w.useRef(N);R.current=N;const W=w.useCallback(Y=>{Y.kind==="channel"?d(Y.channelKey):Y.kind==="agent"?u(Y.agentId):f(Y.userId),requestAnimationFrame(()=>{document.querySelector(`[data-l2-nav-id="${Y.id}"]`)?.scrollIntoView({block:"nearest"})})},[d,u,f]);w.useEffect(()=>{if(!P)return;const Y=ae=>{if((C?.keyboardPane??"content")!=="l2"||ae.metaKey||ae.ctrlKey||ae.altKey||np(ae.target))return;const me=ae.key.length===1?ae.key.toLowerCase():ae.key;if(me==="h"||me==="ArrowLeft"){ae.preventDefault(),ae.stopPropagation(),C?.setKeyboardPane("l1");return}if(me==="l"||me==="ArrowRight"){ae.preventDefault(),ae.stopPropagation();return}const Re=me==="j"||me==="ArrowDown"?1:me==="k"||me==="ArrowUp"?-1:0;if(!Re)return;ae.preventDefault(),ae.stopPropagation();const _e=R.current;if(_e.length===0)return;let De=-1;n==="channel"?De=_e.findIndex(Fe=>Fe.kind==="channel"&&Fe.channelKey===o):n==="direct"?De=_e.findIndex(Fe=>Fe.kind==="agent"&&Fe.agentId===a):n==="dm"&&l&&(De=_e.findIndex(Fe=>Fe.kind==="dm"&&Fe.userId===l)),De<0&&(De=Re>0?-1:0);const Te=Math.max(0,Math.min(_e.length-1,De+Re));W(_e[Te])};return document.addEventListener("keydown",Y,!0),()=>document.removeEventListener("keydown",Y,!0)},[P,C,n,o,a,l,W]);const H=Y=>Y?y?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-surface-overlay":"hover:bg-surface-overlay/60",[Z,B]=w.useState(null),[K,$]=w.useState(!1),[I,X]=w.useState(""),[q,ie]=w.useState(null),pe=(Y,ae,ee,me,Re)=>{ie({title:Y,message:ae,onConfirm:ee,confirmLabel:me,checkboxes:Re})},$e=w.useCallback((Y,ae=176,ee=220)=>{const me=window.innerWidth,Re=window.innerHeight,_e=8;let De=Y.clientX,Te=Y.clientY;return De+ae>me-_e&&(De=Math.max(_e,me-ae-_e)),Te+ee>Re-_e&&(Te=Math.max(_e,Re-ee-_e)),De=Math.max(_e,Math.min(De,me-ae-_e)),Te=Math.max(_e,Math.min(Te,Re-ee-_e)),{x:De,y:Te}},[]);w.useEffect(()=>{if(!Z)return;const Y=()=>B(null),ae=setTimeout(()=>document.addEventListener("click",Y),0);return()=>{clearTimeout(ae),document.removeEventListener("click",Y)}},[Z]);const re=w.useCallback(async(Y,ae)=>{if(ae==="offline"){await ne.agents.start(Y),b();return}pe(k("modals.stopAgent.title"),k("modals.stopAgent.message"),async()=>{await ne.agents.stop(Y),b()},k("contextMenu.stop"))},[b,pe,k]),U=w.useCallback(async Y=>{await ne.teams.update(s.id,{managerId:Y,managerType:"agent"}),O()},[s.id,O]),M=w.useCallback(async Y=>{await ne.teams.removeMember(s.id,Y),O(),b()},[s.id,O,b]),te=w.useCallback(async(Y,ae)=>{await ne.teams.removeMember(s.id,Y),await ne.teams.addMember(ae,Y,"agent"),O(),b()},[s.id,O,b]);return c.jsxs(c.Fragment,{children:[c.jsxs("div",{"data-keyboard-pane":"l2",className:`bg-surface-primary flex flex-col shrink-0 ${y?"ring-1 ring-inset ring-brand-500/30":""}`,style:m!=null?{width:m}:{width:260},children:[c.jsxs("div",{className:"px-3 h-14 flex items-center gap-2 shrink-0",children:[c.jsx("button",{onClick:p,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-brand-500/15 text-brand-500 transition-colors shrink-0",title:k("common:back",{defaultValue:"Back"}),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"truncate font-semibold text-sm",children:s.name}),s.description&&c.jsx("div",{className:"truncate text-[10px] text-fg-tertiary",children:s.description})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[i&&c.jsxs("div",{className:"mb-3",children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:k("chat.groupChat",{defaultValue:"Group Chat"})}),c.jsxs("button",{"data-l2-nav-id":`channel:${i.channelKey}`,onClick:()=>d(i.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors text-fg-primary ${H(!!A)}`,children:[c.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:s.name}),c.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:k("chat.members_other",{count:i.memberCount||Q.length+E.length})})]})]})]}),Q.length>0&&c.jsxs("div",{className:"mb-3",children:[c.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[k("chat.agents",{defaultValue:"Agents"}),c.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:Q.length})]}),Q.map(Y=>{const ae=n==="direct"&&a===Y.id,ee=s.managerId===Y.id,me=Y.status==="offline",Re=yl(Y.status,Cs.isAgentStreaming(Y.id)).dotClass;return c.jsxs("button",{"data-l2-nav-id":`agent:${Y.id}`,onClick:()=>u(Y.id),onContextMenu:_e=>{if(!_)return;_e.preventDefault();const De=$e(_e);$(!1),X(""),B({agentId:Y.id,...De})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors ${me?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${H(ae)}`,children:[c.jsx(Is,{name:Y.name,avatarUrl:Y.avatarUrl,size:28,bgClass:me?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:Y.name}),ee&&c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:c.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),me&&c.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:k("common:status.offline")})]}),c.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:Y.role||" "})]}),(g?.get(Y.id)??0)>0&&c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:g.get(Y.id)}),c.jsx("span",{title:Y.status,onClick:_e=>{_e.stopPropagation(),v(Y.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] shrink-0 ${Re}`})]},Y.id)})]}),E.length>0&&c.jsxs("div",{className:"mb-3",children:[c.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[k("chat.people"),c.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:E.length})]}),E.map(Y=>{const ae=Y.id===r?.id,ee=n==="dm"&&l===Y.id;return c.jsxs("button",{"data-l2-nav-id":`dm:${Y.id}`,onClick:()=>f(Y.id),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${H(ee)}`,children:[c.jsx(Is,{name:Y.name,avatarUrl:Y.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsxs("div",{className:"truncate font-medium text-[12px] leading-tight",children:[Y.name,ae?` (${k("chat.you",{defaultValue:"You"})})`:""]}),c.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:Y.email||Y.role})]}),c.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},Y.id)})]}),Q.length===0&&E.length===0&&c.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6 px-2",children:k("chat.noMembers",{defaultValue:"No members in this team yet."})})]})]}),x&&c.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:x,children:c.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),Z&&(()=>{const Y=Q.find(ee=>ee.id===Z.agentId);if(!Y||!_)return null;const ae=s.managerId===Y.id;return c.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-48 max-w-[calc(100vw-1rem)] overflow-y-auto",style:{left:Z.x,top:Z.y,maxHeight:Math.max(160,window.innerHeight-Z.y-8)},onClick:ee=>ee.stopPropagation(),children:[c.jsxs("button",{onClick:()=>{B(null),v(Y.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),k("contextMenu.viewProfile")]}),Y.status==="offline"?c.jsxs("button",{onClick:()=>{re(Y.id,"offline"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),k("contextMenu.start")]}):c.jsxs("button",{onClick:()=>{re(Y.id,Y.status??"idle"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),k("contextMenu.stop")]}),!ae&&c.jsxs("button",{onClick:()=>{U(Y.id),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),k("contextMenu.setAsManager")]}),c.jsxs("button",{onClick:()=>{M(Y.id),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"9 14 4 9 9 4"}),c.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),k("contextMenu.removeFromTeam")]}),(()=>{const ee=h.filter(_e=>_e.id!==s.id);if(ee.length===0)return null;const me=I.trim().toLowerCase(),Re=me?ee.filter(_e=>_e.name.toLowerCase().includes(me)):ee;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{type:"button",onClick:()=>$(_e=>!_e),className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M5 12h14"}),c.jsx("path",{d:"M12 5l7 7-7 7"})]}),c.jsx("span",{className:"flex-1",children:k("contextMenu.moveTo")}),c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-tertiary transition-transform ${K?"rotate-180":""}`,children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),K&&c.jsxs("div",{className:"px-2 pb-1.5",onClick:_e=>_e.stopPropagation(),children:[c.jsx("input",{autoFocus:!0,value:I,onChange:_e=>X(_e.target.value),onKeyDown:_e=>_e.stopPropagation(),placeholder:k("contextMenu.moveToSearch"),className:"w-full mb-1 px-2 py-1.5 text-xs rounded-md bg-surface-overlay border border-border-default text-fg-primary placeholder:text-fg-tertiary outline-none focus:border-brand-500/50"}),c.jsx("div",{className:"max-h-36 overflow-y-auto rounded-md",children:Re.length===0?c.jsx("div",{className:"px-2 py-2 text-[10px] text-fg-tertiary",children:k("contextMenu.moveToEmpty")}):Re.map(_e=>c.jsx("button",{type:"button",onClick:()=>{te(Y.id,_e.id),B(null)},className:"w-full text-left px-2 py-1.5 text-xs hover:bg-surface-overlay text-fg-secondary rounded truncate",title:_e.name,children:_e.name},_e.id))})]})]})})(),c.jsx("div",{className:"border-t border-border-default/50 my-1"}),c.jsxs("button",{onClick:()=>{pe(`${k("common:remove")} "${Y.name}"?`,k("modals.removeAgent.message"),async ee=>{const me=ee?.purgeFiles??!1;i?.channelKey&&localStorage.setItem("markus_nav_after_remove","channel:"+i.channelKey),await ne.agents.remove(Y.id,{purgeFiles:me}),b(),B(null)},k("common:remove"),[{id:"purgeFiles",label:k("modals.removeAgent.purgeFiles"),defaultChecked:!1}])},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"3 6 5 6 21 6"}),c.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),k("contextMenu.removeFromOrg")]})]})})(),q&&c.jsx(qo,{title:q.title,message:q.message,confirmLabel:q.confirmLabel,checkboxes:q.checkboxes,onConfirm:Y=>{q.onConfirm(Y),ie(null)},onCancel:()=>ie(null)})]})}function qf(){return qf=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},qf.apply(null,arguments)}function eT(s,e){if(s==null)return{};var t={};for(var r in s)if({}.hasOwnProperty.call(s,r)){if(e.indexOf(r)!==-1)continue;t[r]=s[r]}return t}let Zf=[],py=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?py:Zf).push(t=t+s[e])})();function tT(s){if(s<768)return!1;for(let e=0,t=Zf.length;;){let r=e+t>>1;if(s<Zf[r])t=r;else if(s>=py[r])e=r+1;else return!0;if(e==t)return!1}}function _0(s){return s>=127462&&s<=127487}const k0=8205;function sT(s,e,t=!0,r=!0){return(t?gy:rT)(s,e,r)}function gy(s,e,t){if(e==s.length)return e;e&&Oy(s.charCodeAt(e))&&xy(s.charCodeAt(e-1))&&e--;let r=wu(s,e);for(e+=C0(r);e<s.length;){let i=wu(s,e);if(r==k0||i==k0||t&&tT(i))e+=C0(i),r=i;else if(_0(i)){let n=0,a=e-2;for(;a>=0&&_0(wu(s,a));)n++,a-=2;if(n%2==0)break;e+=2}else break}return e}function rT(s,e,t){for(;e>1;){let r=gy(s,e-2,t);if(r<e)return r;e--}return 0}function wu(s,e){let t=s.charCodeAt(e);if(!xy(t)||e+1==s.length)return t;let r=s.charCodeAt(e+1);return Oy(r)?(t-55296<<10)+(r-56320)+65536:t}function Oy(s){return s>=56320&&s<57344}function xy(s){return s>=55296&&s<56320}function C0(s){return s<65536?1:2}let It=class by{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,r){[e,t]=Eo(this,e,t);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(t,this.length,i,1),Ur.from(i,this.length-(t-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Eo(this,e,t);let r=[];return this.decompose(e,t,r,0),Ur.from(r,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Ia(this),n=new Ia(e);for(let a=t,o=t;;){if(i.next(a),n.next(a),a=0,i.lineBreak!=n.lineBreak||i.done!=n.done||i.value!=n.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(e=1){return new Ia(this,e)}iterRange(e,t=this.length){return new vy(this,e,t)}iterLines(e,t){let r;if(e==null)r=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new yy(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?by.empty:e.length<=32?new cs(e):Ur.from(cs.split(e,[]))}};class cs extends It{constructor(e,t=iT(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,r,i){for(let n=0;;n++){let a=this.text[n],o=i+a.length;if((t?r:o)>=e)return new nT(i,o,r,a);i=o+1,r++}}decompose(e,t,r,i){let n=e<=0&&t>=this.length?this:new cs(P0(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let a=r.pop(),o=Hc(n.text,a.text.slice(),0,n.length);if(o.length<=32)r.push(new cs(o,a.length+n.length));else{let l=o.length>>1;r.push(new cs(o.slice(0,l)),new cs(o.slice(l)))}}else r.push(n)}replace(e,t,r){if(!(r instanceof cs))return super.replace(e,t,r);[e,t]=Eo(this,e,t);let i=Hc(this.text,Hc(r.text,P0(this.text,0,e)),t),n=this.length+r.length-(t-e);return i.length<=32?new cs(i,n):Ur.from(cs.split(i,[]),n)}sliceString(e,t=this.length,r=`
11
+ `){[e,t]=Eo(this,e,t);let i="";for(let n=0,a=0;n<=t&&a<this.text.length;a++){let o=this.text[a],l=n+o.length;n>e&&a&&(i+=r),e<l&&t>n&&(i+=o.slice(Math.max(0,e-n),t-n)),n=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let r=[],i=-1;for(let n of e)r.push(n),i+=n.length+1,r.length==32&&(t.push(new cs(r,i)),r=[],i=-1);return i>-1&&t.push(new cs(r,i)),t}}class Ur extends It{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,t,r,i){for(let n=0;;n++){let a=this.children[n],o=i+a.length,l=r+a.lines-1;if((t?l:o)>=e)return a.lineInner(e,t,r,i);i=o+1,r=l+1}}decompose(e,t,r,i){for(let n=0,a=0;a<=t&&n<this.children.length;n++){let o=this.children[n],l=a+o.length;if(e<=l&&t>=a){let h=i&((a<=e?1:0)|(l>=t?2:0));a>=e&&l<=t&&!h?r.push(o):o.decompose(e-a,t-a,r,h)}a=l+1}}replace(e,t,r){if([e,t]=Eo(this,e,t),r.lines<this.lines)for(let i=0,n=0;i<this.children.length;i++){let a=this.children[i],o=n+a.length;if(e>=n&&t<=o){let l=a.replace(e-n,t-n,r),h=this.lines-a.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let u=this.children.slice();return u[i]=l,new Ur(u,this.length-(t-e)+r.length)}return super.replace(n,o,l)}n=o+1}return super.replace(e,t,r)}sliceString(e,t=this.length,r=`
12
+ `){[e,t]=Eo(this,e,t);let i="";for(let n=0,a=0;n<this.children.length&&a<=t;n++){let o=this.children[n],l=a+o.length;a>e&&n&&(i+=r),e<l&&t>a&&(i+=o.sliceString(e-a,t-a,r)),a=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ur))return 0;let r=0,[i,n,a,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,n+=t){if(i==a||n==o)return r;let l=this.children[i],h=e.children[n];if(l!=h)return r+l.scanIdentical(h,t);r+=l.length+1}}static from(e,t=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let p of e)r+=p.lines;if(r<32){let p=[];for(let v of e)v.flatten(p);return new cs(p,t)}let i=Math.max(32,r>>5),n=i<<1,a=i>>1,o=[],l=0,h=-1,u=[];function d(p){let v;if(p.lines>n&&p instanceof Ur)for(let b of p.children)d(b);else p.lines>a&&(l>a||!l)?(f(),o.push(p)):p instanceof cs&&l&&(v=u[u.length-1])instanceof cs&&p.lines+v.lines<=32?(l+=p.lines,h+=p.length+1,u[u.length-1]=new cs(v.text.concat(p.text),v.length+1+p.length)):(l+p.lines>i&&f(),l+=p.lines,h+=p.length+1,u.push(p))}function f(){l!=0&&(o.push(u.length==1?u[0]:Ur.from(u,h)),h=-1,l=u.length=0)}for(let p of e)d(p);return f(),o.length==1?o[0]:new Ur(o,t)}}It.empty=new cs([""],0);function iT(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Hc(s,e,t=0,r=1e9){for(let i=0,n=0,a=!0;n<s.length&&i<=r;n++){let o=s[n],l=i+o.length;l>=t&&(l>r&&(o=o.slice(0,r-i)),i<t&&(o=o.slice(t-i)),a?(e[e.length-1]+=o,a=!1):e.push(o)),i=l+1}return e}function P0(s,e,t){return Hc(s,[""],e,t)}class Ia{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof cs?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],n=this.offsets[r],a=n>>1,o=i instanceof cs?i.text.length:i.children.length;if(a==(t>0?o:0)){if(r==0)return this.done=!0,this.value="",this;t>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(t>0?0:1)){if(this.offsets[r]+=t,e==0)return this.lineBreak=!0,this.value=`
13
+ `,this;e--}else if(i instanceof cs){let l=i.text[a+(t<0?-1:0)];if(this.offsets[r]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[a+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=t):(t<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof cs?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class vy{constructor(e,t,r){this.value="",this.done=!1,this.cursor=new Ia(e,t>r?-1:1),this.pos=t>r?e.length:0,this.from=Math.min(t,r),this.to=Math.max(t,r)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let r=t<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=r?i:t<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class yy{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:r,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(It.prototype[Symbol.iterator]=function(){return this.iter()},Ia.prototype[Symbol.iterator]=vy.prototype[Symbol.iterator]=yy.prototype[Symbol.iterator]=function(){return this});let nT=class{constructor(e,t,r,i){this.from=e,this.to=t,this.number=r,this.text=i}get length(){return this.to-this.from}};function Eo(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function ys(s,e,t=!0,r=!0){return sT(s,e,t,r)}function oT(s){return s>=56320&&s<57344}function aT(s){return s>=55296&&s<56320}function Ks(s,e){let t=s.charCodeAt(e);if(!aT(t)||e+1==s.length)return t;let r=s.charCodeAt(e+1);return oT(r)?(t-55296<<10)+(r-56320)+65536:t}function up(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function Hr(s){return s<65536?1:2}const Vf=/\r\n?|\n/;var Ts=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(Ts||(Ts={}));class ti{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let r=this.sections[t+1];e+=r<0?this.sections[t]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,r=0,i=0;t<this.sections.length;){let n=this.sections[t++],a=this.sections[t++];a<0?(e(r,i,n),i+=n):i+=a,r+=n}}iterChangedRanges(e,t=!1){Ff(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let r=this.sections[t++],i=this.sections[t++];i<0?e.push(r,i):e.push(i,r)}return new ti(e)}composeDesc(e){return this.empty?e:e.empty?this:Sy(this,e)}mapDesc(e,t=!1){return e.empty?this:Uf(this,e,t)}mapPos(e,t=-1,r=Ts.Simple){let i=0,n=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],h=i+o;if(l<0){if(h>e)return n+(e-i);n+=o}else{if(r!=Ts.Simple&&h>=e&&(r==Ts.TrackDel&&i<e&&h>e||r==Ts.TrackBefore&&i<e||r==Ts.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!o)return e==i||t<0?n:n+l;n+=l}i=h}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return n}touchesRange(e,t=e){for(let r=0,i=0;r<this.sections.length&&i<=t;){let n=this.sections[r++],a=this.sections[r++],o=i+n;if(a>=0&&i<=t&&o>=e)return i<e&&o>t?"cover":!0;i=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let r=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ti(e)}static create(e){return new ti(e)}}class fs extends ti{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ff(this,(t,r,i,n,a)=>e=e.replace(i,i+(r-t),a),!1),e}mapDesc(e,t=!1){return Uf(this,e,t,!0)}invert(e){let t=this.sections.slice(),r=[];for(let i=0,n=0;i<t.length;i+=2){let a=t[i],o=t[i+1];if(o>=0){t[i]=o,t[i+1]=a;let l=i>>1;for(;r.length<l;)r.push(It.empty);r.push(a?e.slice(n,n+a):It.empty)}n+=a}return new fs(t,r)}compose(e){return this.empty?e:e.empty?this:Sy(this,e,!0)}map(e,t=!1){return e.empty?this:Uf(this,e,t,!0)}iterChanges(e,t=!1){Ff(this,e,t)}get desc(){return ti.create(this.sections)}filter(e){let t=[],r=[],i=[],n=new Ha(this);e:for(let a=0,o=0;;){let l=a==e.length?1e9:e[a++];for(;o<l||o==l&&n.len==0;){if(n.done)break e;let u=Math.min(n.len,l-o);Ds(i,u,-1);let d=n.ins==-1?-1:n.off==0?n.ins:0;Ds(t,u,d),d>0&&Ui(r,t,n.text),n.forward(u),o+=u}let h=e[a++];for(;o<h;){if(n.done)break e;let u=Math.min(n.len,h-o);Ds(t,u,-1),Ds(i,u,n.ins==-1?-1:n.off==0?n.ins:0),n.forward(u),o+=u}}return{changes:new fs(t,r),filtered:ti.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let r=this.sections[t],i=this.sections[t+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,r){let i=[],n=[],a=0,o=null;function l(u=!1){if(!u&&!i.length)return;a<t&&Ds(i,t-a,-1);let d=new fs(i,n);o=o?o.compose(d.map(o)):d,i=[],n=[],a=0}function h(u){if(Array.isArray(u))for(let d of u)h(d);else if(u instanceof fs){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);l(),o=o?o.compose(u.map(o)):u}else{let{from:d,to:f=d,insert:p}=u;if(d>f||d<0||f>t)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${t})`);let v=p?typeof p=="string"?It.of(p.split(r||Vf)):p:It.empty,b=v.length;if(d==f&&b==0)return;d<a&&l(),d>a&&Ds(i,d-a,-1),Ds(i,f-d,b),Ui(n,i,v),a=f}}return h(e),l(!o),o}static empty(e){return new fs(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],r=[];for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="number")t.push(n,-1);else{if(!Array.isArray(n)||typeof n[0]!="number"||n.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(n.length==1)t.push(n[0],0);else{for(;r.length<i;)r.push(It.empty);r[i]=It.of(n.slice(1)),t.push(n[0],r[i].length)}}}return new fs(t,r)}static createSet(e,t){return new fs(e,t)}}function Ds(s,e,t,r=!1){if(e==0&&t<=0)return;let i=s.length-2;i>=0&&t<=0&&t==s[i+1]?s[i]+=e:i>=0&&e==0&&s[i]==0?s[i+1]+=t:r?(s[i]+=e,s[i+1]+=t):s.push(e,t)}function Ui(s,e,t){if(t.length==0)return;let r=e.length-2>>1;if(r<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<r;)s.push(It.empty);s.push(t)}}function Ff(s,e,t){let r=s.inserted;for(let i=0,n=0,a=0;a<s.sections.length;){let o=s.sections[a++],l=s.sections[a++];if(l<0)i+=o,n+=o;else{let h=i,u=n,d=It.empty;for(;h+=o,u+=l,l&&r&&(d=d.append(r[a-2>>1])),!(t||a==s.sections.length||s.sections[a+1]<0);)o=s.sections[a++],l=s.sections[a++];e(i,h,n,u,d),i=h,n=u}}}function Uf(s,e,t,r=!1){let i=[],n=r?[]:null,a=new Ha(s),o=new Ha(e);for(let l=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let h=Math.min(a.len,o.len);Ds(i,h,-1),a.forward(h),o.forward(h)}else if(o.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!t))){let h=o.len;for(Ds(i,o.ins,-1);h;){let u=Math.min(a.len,h);a.ins>=0&&l<a.i&&a.len<=u&&(Ds(i,0,a.ins),n&&Ui(n,i,a.text),l=a.i),a.forward(u),h-=u}o.next()}else if(a.ins>=0){let h=0,u=a.len;for(;u;)if(o.ins==-1){let d=Math.min(u,o.len);h+=d,u-=d,o.forward(d)}else if(o.ins==0&&o.len<u)u-=o.len,o.next();else break;Ds(i,h,l<a.i?a.ins:0),n&&l<a.i&&Ui(n,i,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&o.done)return n?fs.createSet(i,n):ti.create(i);throw new Error("Mismatched change set lengths")}}}function Sy(s,e,t=!1){let r=[],i=t?[]:null,n=new Ha(s),a=new Ha(e);for(let o=!1;;){if(n.done&&a.done)return i?fs.createSet(r,i):ti.create(r);if(n.ins==0)Ds(r,n.len,0,o),n.next();else if(a.len==0&&!a.done)Ds(r,0,a.ins,o),i&&Ui(i,r,a.text),a.next();else{if(n.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(n.len2,a.len),h=r.length;if(n.ins==-1){let u=a.ins==-1?-1:a.off?0:a.ins;Ds(r,l,u,o),i&&u&&Ui(i,r,a.text)}else a.ins==-1?(Ds(r,n.off?0:n.len,l,o),i&&Ui(i,r,n.textBit(l))):(Ds(r,n.off?0:n.len,a.off?0:a.ins,o),i&&!a.off&&Ui(i,r,a.text));o=(n.ins>l||a.ins>=0&&a.len>l)&&(o||r.length>h),n.forward2(l),a.forward(l)}}}}class Ha{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?It.empty:e[t]}textBit(e){let{inserted:t}=this.set,r=this.i-2>>1;return r>=t.length&&!e?It.empty:t[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Vi{constructor(e,t,r,i){this.from=e,this.to=t,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,t):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new Vi(r,i,this.flags,this.goalColumn)}extend(e,t=e,r=0){if(e<=this.anchor&&t>=this.anchor)return fe.range(e,t,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return fe.range(this.anchor,i,void 0,void 0,r)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return fe.range(e.anchor,e.head)}static create(e,t,r,i){return new Vi(e,t,r,i)}}class fe{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:fe.create(this.ranges.map(r=>r.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new fe([this.main],0)}addRange(e,t=!0){return fe.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let r=this.ranges.slice();return r[t]=e,fe.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new fe(e.ranges.map(t=>Vi.fromJSON(t)),e.main)}static single(e,t=e){return new fe([fe.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let n=e[i];if(n.empty?n.from<=r:n.from<r)return fe.normalized(e.slice(),t);r=n.to}return new fe(e,t)}static cursor(e,t=0,r,i){return Vi.create(e,e,(t==0?0:t<0?8:16)|(r==null?7:Math.min(6,r)),i)}static range(e,t,r,i,n){let a=i==null?7:Math.min(6,i);return!n&&e!=t&&(n=t<e?1:-1),n&&(a|=n<0?8:16),t<e?Vi.create(t,e,a|32,r):Vi.create(e,t,a,r)}static undirectionalRange(e,t){return Vi.create(e,t,64,void 0)}static normalized(e,t=0){let r=e[t];e.sort((i,n)=>i.from-n.from),t=e.indexOf(r);for(let i=1;i<e.length;i++){let n=e[i],a=e[i-1];if(n.empty?n.from<=a.to:n.from<a.to){let o=a.from,l=Math.max(n.to,a.to);i<=t&&t--,e.splice(--i,2,n.anchor>n.head?fe.range(l,o):fe.range(o,l))}}return new fe(e,t)}}function wy(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let fp=0;class Ge{constructor(e,t,r,i,n){this.combine=e,this.compareInput=t,this.compare=r,this.isStatic=i,this.id=fp++,this.default=e([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(e={}){return new Ge(e.combine||(t=>t),e.compareInput||((t,r)=>t===r),e.compare||(e.combine?(t,r)=>t===r:mp),!!e.static,e.enables)}of(e){return new Yc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Yc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Yc(e,this,2,t)}from(e,t){return t||(t=r=>r),this.compute([e],r=>t(r.field(e)))}}function mp(s,e){return s==e||s.length==e.length&&s.every((t,r)=>t===e[r])}class Yc{constructor(e,t,r,i){this.dependencies=e,this.facet=t,this.type=r,this.value=i,this.id=fp++}dynamicSlot(e){var t;let r=this.value,i=this.facet.compareInput,n=this.id,a=e[n]>>1,o=this.type==2,l=!1,h=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?h=!0:(((t=e[d.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[a]=r(d),1},update(d,f){if(l&&f.docChanged||h&&(f.docChanged||f.selection)||Hf(d,u)){let p=r(d);if(o?!T0(p,d.values[a],i):!i(p,d.values[a]))return d.values[a]=p,1}return 0},reconfigure:(d,f)=>{let p,v=f.config.address[n];if(v!=null){let b=gh(f,v);if(this.dependencies.every(O=>O instanceof Ge?f.facet(O)===d.facet(O):O instanceof $s?f.field(O,!1)==d.field(O,!1):!0)||(o?T0(p=r(d),b,i):i(p=r(d),b)))return d.values[a]=b,0}else p=r(d);return d.values[a]=p,1}}}get extension(){return this}}function T0(s,e,t){if(s.length!=e.length)return!1;for(let r=0;r<s.length;r++)if(!t(s[r],e[r]))return!1;return!0}function Hf(s,e){let t=!1;for(let r of e)Ba(s,r)&1&&(t=!0);return t}function lT(s,e,t){let r=t.map(l=>s[l.id]),i=t.map(l=>l.type),n=r.filter(l=>!(l&1)),a=s[e.id]>>1;function o(l){let h=[];for(let u=0;u<r.length;u++){let d=gh(l,r[u]);if(i[u]==2)for(let f of d)h.push(f);else h.push(d)}return e.combine(h)}return{create(l){for(let h of r)Ba(l,h);return l.values[a]=o(l),1},update(l,h){if(!Hf(l,n))return 0;let u=o(l);return e.compare(u,l.values[a])?0:(l.values[a]=u,1)},reconfigure(l,h){let u=Hf(l,r),d=h.config.facets[e.id],f=h.facet(e);if(d&&!u&&mp(t,d))return l.values[a]=f,0;let p=o(l);return e.compare(p,f)?(l.values[a]=f,0):(l.values[a]=p,1)}}}const Oc=Ge.define({static:!0});class $s{constructor(e,t,r,i,n){this.id=e,this.createF=t,this.updateF=r,this.compareF=i,this.spec=n,this.provides=void 0}static define(e){let t=new $s(fp++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Oc).find(r=>r.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:r=>(r.values[t]=this.create(r),1),update:(r,i)=>{let n=r.values[t],a=this.updateF(n,i);return this.compareF(n,a)?0:(r.values[t]=a,1)},reconfigure:(r,i)=>{let n=r.facet(Oc),a=i.facet(Oc),o;return(o=n.find(l=>l.field==this))&&o!=a.find(l=>l.field==this)?(r.values[t]=o.create(r),1):i.config.address[this.id]!=null?(r.values[t]=i.field(this),0):(r.values[t]=this.create(r),1)}}}init(e){return[this,Oc.of({field:this,create:e})]}get extension(){return this}}const Nn={lowest:4,low:3,default:2,high:1,highest:0};function Ca(s){return e=>new _y(e,s)}const ki={highest:Ca(Nn.highest),high:Ca(Nn.high),default:Ca(Nn.default),low:Ca(Nn.low),lowest:Ca(Nn.lowest)};class _y{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Hh{of(e){return new Yf(this,e)}reconfigure(e){return Hh.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Yf{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class ph{constructor(e,t,r,i,n,a){for(this.base=e,this.compartments=t,this.dynamicSlots=r,this.address=i,this.staticValues=n,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,r){let i=[],n=Object.create(null),a=new Map;for(let f of cT(e,t,a))f instanceof $s?i.push(f):(n[f.facet.id]||(n[f.facet.id]=[])).push(f);let o=Object.create(null),l=[],h=[];for(let f of i)o[f.id]=h.length<<1,h.push(p=>f.slot(p));let u=r?.config.facets;for(let f in n){let p=n[f],v=p[0].facet,b=u&&u[f]||[];if(p.every(O=>O.type==0))if(o[v.id]=l.length<<1|1,mp(b,p))l.push(r.facet(v));else{let O=v.combine(p.map(g=>g.value));l.push(r&&v.compare(O,r.facet(v))?r.facet(v):O)}else{for(let O of p)O.type==0?(o[O.id]=l.length<<1|1,l.push(O.value)):(o[O.id]=h.length<<1,h.push(g=>O.dynamicSlot(g)));o[v.id]=h.length<<1,h.push(O=>lT(O,v,p))}}let d=h.map(f=>f(o));return new ph(e,a,d,o,l,n)}}function cT(s,e,t){let r=[[],[],[],[],[]],i=new Map;function n(a,o){let l=i.get(a);if(l!=null){if(l<=o)return;let h=r[l].indexOf(a);h>-1&&r[l].splice(h,1),a instanceof Yf&&t.delete(a.compartment)}if(i.set(a,o),Array.isArray(a))for(let h of a)n(h,o);else if(a instanceof Yf){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(a.compartment)||a.inner;t.set(a.compartment,h),n(h,o)}else if(a instanceof _y)n(a.inner,a.prec);else if(a instanceof $s)r[o].push(a),a.provides&&n(a.provides,o);else if(a instanceof Yc)r[o].push(a),a.facet.extensions&&n(a.facet.extensions,Nn.default);else{let h=a.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(h==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(h,o)}}return n(s,Nn.default),r.reduce((a,o)=>a.concat(o))}function Ba(s,e){if(e&1)return 2;let t=e>>1,r=s.status[t];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;s.status[t]=4;let i=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|i}function gh(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const ky=Ge.define(),Gf=Ge.define({combine:s=>s.some(e=>e),static:!0}),Cy=Ge.define({combine:s=>s.length?s[0]:void 0,static:!0}),Py=Ge.define(),Ty=Ge.define(),Qy=Ge.define(),$y=Ge.define({combine:s=>s.length?s[0]:!1});class ri{constructor(e,t){this.type=e,this.value=t}static define(){return new hT}}class hT{of(e){return new ri(this,e)}}class dT{constructor(e){this.map=e}of(e){return new xt(this,e)}}class xt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new xt(this.type,t)}is(e){return this.type==e}static define(e={}){return new dT(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let r=[];for(let i of e){let n=i.map(t);n&&r.push(n)}return r}}xt.reconfigure=xt.define();xt.appendConfig=xt.define();class ds{constructor(e,t,r,i,n,a){this.startState=e,this.changes=t,this.selection=r,this.effects=i,this.annotations=n,this.scrollIntoView=a,this._doc=null,this._state=null,r&&wy(r,t.newLength),n.some(o=>o.type==ds.time)||(this.annotations=n.concat(ds.time.of(Date.now())))}static create(e,t,r,i,n,a){return new ds(e,t,r,i,n,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ds.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ds.time=ri.define();ds.userEvent=ri.define();ds.addToHistory=ri.define();ds.remote=ri.define();function uT(s,e){let t=[];for(let r=0,i=0;;){let n,a;if(r<s.length&&(i==e.length||e[i]>=s[r]))n=s[r++],a=s[r++];else if(i<e.length)n=e[i++],a=e[i++];else return t;!t.length||t[t.length-1]<n?t.push(n,a):t[t.length-1]<a&&(t[t.length-1]=a)}}function jy(s,e,t){var r;let i,n,a;return t?(i=e.changes,n=fs.empty(e.changes.length),a=s.changes.compose(e.changes)):(i=e.changes.map(s.changes),n=s.changes.mapDesc(e.changes,!0),a=s.changes.compose(i)),{changes:a,selection:e.selection?e.selection.map(n):(r=s.selection)===null||r===void 0?void 0:r.map(i),effects:xt.mapEffects(s.effects,i).concat(xt.mapEffects(e.effects,n)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Kf(s,e,t){let r=e.selection,i=_o(e.annotations);return e.userEvent&&(i=i.concat(ds.userEvent.of(e.userEvent))),{changes:e.changes instanceof fs?e.changes:fs.of(e.changes||[],t,s.facet(Cy)),selection:r&&(r instanceof fe?r:fe.single(r.anchor,r.head)),effects:_o(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function Ry(s,e,t){let r=Kf(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let n=1;n<e.length;n++){e[n].filter===!1&&(t=!1);let a=!!e[n].sequential;r=jy(r,Kf(s,e[n],a?r.changes.newLength:s.doc.length),a)}let i=ds.create(s,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return mT(t?fT(i):i)}function fT(s){let e=s.startState,t=!0;for(let i of e.facet(Py)){let n=i(s);if(n===!1){t=!1;break}Array.isArray(n)&&(t=t===!0?n:uT(t,n))}if(t!==!0){let i,n;if(t===!1)n=s.changes.invertedDesc,i=fs.empty(e.doc.length);else{let a=s.changes.filter(t);i=a.changes,n=a.filtered.mapDesc(a.changes).invertedDesc}s=ds.create(e,i,s.selection&&s.selection.map(n),xt.mapEffects(s.effects,n),s.annotations,s.scrollIntoView)}let r=e.facet(Ty);for(let i=r.length-1;i>=0;i--){let n=r[i](s);n instanceof ds?s=n:Array.isArray(n)&&n.length==1&&n[0]instanceof ds?s=n[0]:s=Ry(e,_o(n),!1)}return s}function mT(s){let e=s.startState,t=e.facet(Qy),r=s;for(let i=t.length-1;i>=0;i--){let n=t[i](s);n&&Object.keys(n).length&&(r=jy(r,Kf(e,n,s.changes.newLength),!0))}return r==s?s:ds.create(e,s.changes,s.selection,r.effects,r.annotations,r.scrollIntoView)}const pT=[];function _o(s){return s==null?pT:Array.isArray(s)?s:[s]}var Jt=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(Jt||(Jt={}));const gT=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Jf;try{Jf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function OT(s){if(Jf)return Jf.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||gT.test(t)))return!0}return!1}function xT(s){return e=>{if(!/\S/.test(e))return Jt.Space;if(OT(e))return Jt.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Jt.Word;return Jt.Other}}class $t{constructor(e,t,r,i,n,a){this.config=e,this.doc=t,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=n,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)Ba(this,o<<1);this.computeSlot=null}field(e,t=!0){let r=this.config.address[e.id];if(r==null){if(t)throw new RangeError("Field is not present in this state");return}return Ba(this,r),gh(this,r)}update(...e){return Ry(this,e,!0)}applyTransaction(e){let t=this.config,{base:r,compartments:i}=t;for(let o of e.effects)o.is(Hh.reconfigure)?(t&&(i=new Map,t.compartments.forEach((l,h)=>i.set(h,l)),t=null),i.set(o.value.compartment,o.value.extension)):o.is(xt.reconfigure)?(t=null,r=o.value):o.is(xt.appendConfig)&&(t=null,r=_o(r).concat(o.value));let n;t?n=e.startState.values.slice():(t=ph.resolve(r,i,this),n=new $t(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values);let a=e.startState.facet(Gf)?e.newSelection:e.newSelection.asSingle();new $t(t,e.newDoc,a,n,(o,l)=>l.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:fe.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,r=e(t.ranges[0]),i=this.changes(r.changes),n=[r.range],a=_o(r.effects);for(let o=1;o<t.ranges.length;o++){let l=e(t.ranges[o]),h=this.changes(l.changes),u=h.map(i);for(let f=0;f<o;f++)n[f]=n[f].map(u);let d=i.mapDesc(h,!0);n.push(l.range.map(d)),i=i.compose(u),a=xt.mapEffects(a,u).concat(xt.mapEffects(_o(l.effects),d))}return{changes:i,selection:fe.create(n,t.mainIndex),effects:a}}changes(e=[]){return e instanceof fs?e:fs.of(e,this.doc.length,this.facet($t.lineSeparator))}toText(e){return It.of(e.split(this.facet($t.lineSeparator)||Vf))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ba(this,t),gh(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof $s&&this.config.address[i.id]!=null&&(t[r]=i.spec.toJSON(this.field(e[r]),this))}return t}static fromJSON(e,t={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let n in r)if(Object.prototype.hasOwnProperty.call(e,n)){let a=r[n],o=e[n];i.push(a.init(l=>a.spec.fromJSON(o,l)))}}return $t.create({doc:e.doc,selection:fe.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=ph.resolve(e.extensions||[],new Map),r=e.doc instanceof It?e.doc:It.of((e.doc||"").split(t.staticFacet($t.lineSeparator)||Vf)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return wy(i,r.length),t.staticFacet(Gf)||(i=i.asSingle()),new $t(t,r,i,t.dynamicSlots.map(()=>null),(n,a)=>a.create(n),null)}get tabSize(){return this.facet($t.tabSize)}get lineBreak(){return this.facet($t.lineSeparator)||`
14
+ `}get readOnly(){return this.facet($y)}phrase(e,...t){for(let r of this.facet($t.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let n=+(i||1);return!n||n>t.length?r:t[n-1]})),e}languageDataAt(e,t,r=-1){let i=[];for(let n of this.facet(ky))for(let a of n(this,t,r))Object.prototype.hasOwnProperty.call(a,e)&&i.push(a[e]);return i}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return xT(t.length?t[0]:"")}wordAt(e){let{text:t,from:r,length:i}=this.doc.lineAt(e),n=this.charCategorizer(e),a=e-r,o=e-r;for(;a>0;){let l=ys(t,a,!1);if(n(t.slice(l,a))!=Jt.Word)break;a=l}for(;o<i;){let l=ys(t,o);if(n(t.slice(o,l))!=Jt.Word)break;o=l}return a==o?null:fe.range(a+r,o+r)}}$t.allowMultipleSelections=Gf;$t.tabSize=Ge.define({combine:s=>s.length?s[0]:4});$t.lineSeparator=Cy;$t.readOnly=$y;$t.phrases=Ge.define({compare(s,e){let t=Object.keys(s),r=Object.keys(e);return t.length==r.length&&t.every(i=>s[i]==e[i])}});$t.languageData=ky;$t.changeFilter=Py;$t.transactionFilter=Ty;$t.transactionExtender=Qy;Hh.reconfigure=xt.define();function ii(s,e,t={}){let r={};for(let i of s)for(let n of Object.keys(i)){let a=i[n],o=r[n];if(o===void 0)r[n]=a;else if(!(o===a||a===void 0))if(Object.hasOwnProperty.call(t,n))r[n]=t[n](o,a);else throw new Error("Config merge conflict for field "+n)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class Gi{eq(e){return this==e}range(e,t=e){return em.create(e,t,this)}}Gi.prototype.startSide=Gi.prototype.endSide=0;Gi.prototype.point=!1;Gi.prototype.mapMode=Ts.TrackDel;function pp(s,e){return s==e||s.constructor==e.constructor&&s.eq(e)}let em=class Ey{constructor(e,t,r){this.from=e,this.to=t,this.value=r}static create(e,t,r){return new Ey(e,t,r)}};function tm(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class gp{constructor(e,t,r,i){this.from=e,this.to=t,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,t,r,i=0){let n=r?this.to:this.from;for(let a=i,o=n.length;;){if(a==o)return a;let l=a+o>>1,h=n[l]-e||(r?this.value[l].endSide:this.value[l].startSide)-t;if(l==a)return h>=0?a:o;h>=0?o=l:a=l+1}}between(e,t,r,i){for(let n=this.findIndex(t,-1e9,!0),a=this.findIndex(r,1e9,!1,n);n<a;n++)if(i(this.from[n]+e,this.to[n]+e,this.value[n])===!1)return!1}map(e,t){let r=[],i=[],n=[],a=-1,o=-1;for(let l=0;l<this.value.length;l++){let h=this.value[l],u=this.from[l]+e,d=this.to[l]+e,f,p;if(u==d){let v=t.mapPos(u,h.startSide,h.mapMode);if(v==null||(f=p=v,h.startSide!=h.endSide&&(p=t.mapPos(u,h.endSide),p<f)))continue}else if(f=t.mapPos(u,h.startSide),p=t.mapPos(d,h.endSide),f>p||f==p&&h.startSide>0&&h.endSide<=0)continue;(p-f||h.endSide-h.startSide)<0||(a<0&&(a=f),h.point&&(o=Math.max(o,p-f)),r.push(h),i.push(f-a),n.push(p-a))}return{mapped:r.length?new gp(i,n,r,o):null,pos:a}}}class Qt{constructor(e,t,r,i){this.chunkPos=e,this.chunk=t,this.nextLayer=r,this.maxPoint=i}static create(e,t,r,i){return new Qt(e,t,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:r=!1,filterFrom:i=0,filterTo:n=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(r&&(t=t.slice().sort(tm)),this.isEmpty)return t.length?Qt.of(t):this;let o=new Ay(this,null,-1).goto(0),l=0,h=[],u=new vi;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let d=t[l++];u.addInner(d.from,d.to,d.value)||h.push(d)}else o.rangeIndex==1&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!a||i>this.chunkEnd(o.chunkIndex)||n<this.chunkPos[o.chunkIndex])&&u.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!a||i>o.to||n<o.from||a(o.from,o.to,o.value))&&(u.addInner(o.from,o.to,o.value)||h.push(em.create(o.from,o.to,o.value))),o.next());return u.finishInner(this.nextLayer.isEmpty&&!h.length?Qt.empty:this.nextLayer.update({add:h,filter:a,filterFrom:i,filterTo:n}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],r=[],i=-1;for(let a=0;a<this.chunk.length;a++){let o=this.chunkPos[a],l=this.chunk[a],h=e.touchesRange(o,o+l.length);if(h===!1)i=Math.max(i,l.maxPoint),t.push(l),r.push(e.mapPos(o));else if(h===!0){let{mapped:u,pos:d}=l.map(o,e);u&&(i=Math.max(i,u.maxPoint),t.push(u),r.push(d))}}let n=this.nextLayer.map(e);return t.length==0?n:new Qt(r,t,n||Qt.empty,i)}between(e,t,r){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let n=this.chunkPos[i],a=this.chunk[i];if(t>=n&&e<=n+a.length&&a.between(n,e-n,t-n,r)===!1)return}this.nextLayer.between(e,t,r)}}iter(e=0){return Ya.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ya.from(e).goto(t)}static compare(e,t,r,i,n=-1){let a=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=n),o=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=n),l=Q0(a,o,r),h=new Pa(a,l,n),u=new Pa(o,l,n);r.iterGaps((d,f,p)=>$0(h,d,u,f,p,i)),r.empty&&r.length==0&&$0(h,0,u,0,0,i)}static eq(e,t,r=0,i){i==null&&(i=999999999);let n=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),a=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(n.length!=a.length)return!1;if(!n.length)return!0;let o=Q0(n,a),l=new Pa(n,o,0).goto(r),h=new Pa(a,o,0).goto(r);for(;;){if(l.to!=h.to||!sm(l.active,h.active)||l.point&&(!h.point||!pp(l.point,h.point)))return!1;if(l.to>i)return!0;l.next(),h.next()}}static spans(e,t,r,i,n=-1){let a=new Pa(e,null,n).goto(t),o=t,l=a.openStart;for(;;){let h=Math.min(a.to,r);if(a.point){let u=a.activeForPoint(a.to),d=a.pointFrom<t?u.length+1:a.point.startSide<0?u.length:Math.min(u.length,l);i.point(o,h,a.point,u,d,a.pointRank),l=Math.min(a.openEnd(h),u.length)}else h>o&&(i.span(o,h,a.active,l),l=a.openEnd(h));if(a.to>r)return l+(a.point&&a.to>r?1:0);o=a.to,a.next()}}static of(e,t=!1){let r=new vi;for(let i of e instanceof em?[e]:t?bT(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Qt.empty;let t=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Qt.empty;i=i.nextLayer)t=new Qt(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}}Qt.empty=new Qt([],[],null,-1);function bT(s){if(s.length>1)for(let e=s[0],t=1;t<s.length;t++){let r=s[t];if(tm(e,r)>0)return s.slice().sort(tm);e=r}return s}Qt.empty.nextLayer=Qt.empty;class vi{finishChunk(e){this.chunks.push(new gp(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,r){this.addInner(e,t,r)||(this.nextLayer||(this.nextLayer=new vi)).add(e,t,r)}addInner(e,t,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=t,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let r=t.value.length-1;return this.last=t.value[r],this.lastFrom=t.from[r]+e,this.lastTo=t.to[r]+e,!0}finish(){return this.finishInner(Qt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Qt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Q0(s,e,t){let r=new Map;for(let n of s)for(let a=0;a<n.chunk.length;a++)n.chunk[a].maxPoint<=0&&r.set(n.chunk[a],n.chunkPos[a]);let i=new Set;for(let n of e)for(let a=0;a<n.chunk.length;a++){let o=r.get(n.chunk[a]);o!=null&&(t?t.mapPos(o):o)==n.chunkPos[a]&&!t?.touchesRange(o,o+n.chunk[a].length)&&i.add(n.chunk[a])}return i}class Ay{constructor(e,t,r,i=0){this.layer=e,this.skip=t,this.minPoint=r,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,r){for(;this.chunkIndex<this.layer.chunk.length;){let i=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(i)||this.layer.chunkEnd(this.chunkIndex)<e||i.maxPoint<this.minPoint))break;this.chunkIndex++,r=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!r||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],r=e+t.from[this.rangeIndex];if(this.from=r,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Ya{constructor(e){this.heap=e}static from(e,t=null,r=-1){let i=[];for(let n=0;n<e.length;n++)for(let a=e[n];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new Ay(a,t,r,n));return i.length==1?i[0]:new Ya(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let r of this.heap)r.goto(e,t);for(let r=this.heap.length>>1;r>=0;r--)_u(this.heap,r);return this.next(),this}forward(e,t){for(let r of this.heap)r.forward(e,t);for(let r=this.heap.length>>1;r>=0;r--)_u(this.heap,r);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),_u(this.heap,0)}}}function _u(s,e){for(let t=s[e];;){let r=(e<<1)+1;if(r>=s.length)break;let i=s[r];if(r+1<s.length&&i.compare(s[r+1])>=0&&(i=s[r+1],r++),t.compare(i)<0)break;s[r]=t,s[e]=i,e=r}}class Pa{constructor(e,t,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ya.from(e,t,r)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){xc(this.active,e),xc(this.activeTo,e),xc(this.activeRank,e),this.minActive=j0(this.active,this.activeTo)}addActive(e){let t=0,{value:r,to:i,rank:n}=this.cursor;for(;t<this.activeRank.length&&(n-this.activeRank[t]||i-this.activeTo[t])>0;)t++;bc(this.active,t,r),bc(this.activeTo,t,i),bc(this.activeRank,t,n),e&&bc(e,t,this.cursor.from),this.minActive=j0(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&xc(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let n=this.cursor.value;if(!n.point)this.addActive(r),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=n,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=n.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(r){this.openStart=0;for(let i=r.length-1;i>=0&&r[i]<e;i--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let r=this.active.length-1;r>=0&&!(this.activeRank[r]<this.pointRank);r--)(this.activeTo[r]>e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&t.push(this.active[r]);return t.reverse()}openEnd(e){let t=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)t++;return t}}function $0(s,e,t,r,i,n){s.goto(e),t.goto(r);let a=r+i,o=r,l=r-e,h=!!n.boundChange;for(let u=!1;;){let d=s.to+l-t.to,f=d||s.endSide-t.endSide,p=f<0?s.to+l:t.to,v=Math.min(p,a);if(s.point||t.point?(s.point&&t.point&&pp(s.point,t.point)&&sm(s.activeForPoint(s.to),t.activeForPoint(t.to))||n.comparePoint(o,v,s.point,t.point),u=!1):(u&&n.boundChange(o),v>o&&!sm(s.active,t.active)&&n.compareRange(o,v,s.active,t.active),h&&v<a&&(d||s.openEnd(p)!=t.openEnd(p))&&(u=!0)),p>a)break;o=p,f<=0&&s.next(),f>=0&&t.next()}}function sm(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!=e[t]&&!pp(s[t],e[t]))return!1;return!0}function xc(s,e){for(let t=e,r=s.length-1;t<r;t++)s[t]=s[t+1];s.pop()}function bc(s,e,t){for(let r=s.length-1;r>=e;r--)s[r+1]=s[r];s[e]=t}function j0(s,e){let t=-1,r=1e9;for(let i=0;i<e.length;i++)(e[i]-r||s[i].endSide-s[t].endSide)<0&&(t=i,r=e[i]);return t}function Mr(s,e,t=s.length){let r=0;for(let i=0;i<t&&i<s.length;)s.charCodeAt(i)==9?(r+=e-r%e,i++):(r++,i=ys(s,i));return r}function rm(s,e,t,r){for(let i=0,n=0;;){if(n>=e)return i;if(i==s.length)break;n+=s.charCodeAt(i)==9?t-n%t:1,i=ys(s,i)}return r===!0?-1:s.length}const im="ͼ",R0=typeof Symbol>"u"?"__"+im:Symbol.for(im),nm=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),E0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ki{constructor(e,t){this.rules=[];let{finish:r}=t||{};function i(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function n(a,o,l,h){let u=[],d=/^@(\w+)\b/.exec(a[0]),f=d&&d[1]=="keyframes";if(d&&o==null)return l.push(a[0]+";");for(let p in o){let v=o[p];if(/&/.test(p))n(p.split(/,\s*/).map(b=>a.map(O=>b.replace(/&/,O))).reduce((b,O)=>b.concat(O)),v,l);else if(v&&typeof v=="object"){if(!d)throw new RangeError("The value of a property ("+p+") should be a primitive value.");n(i(p),v,u,f)}else v!=null&&u.push(p.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+v+";")}(u.length||f)&&l.push((r&&!d&&!h?a.map(r):a).join(", ")+" {"+u.join(" ")+"}")}for(let a in e)n(i(a),e[a],this.rules)}getRules(){return this.rules.join(`
15
+ `)}static newName(){let e=E0[R0]||1;return E0[R0]=e+1,im+e.toString(36)}static mount(e,t,r){let i=e[nm],n=r&&r.nonce;i?n&&i.setNonce(n):i=new vT(e,n),i.mount(Array.isArray(t)?t:[t],e)}}let A0=new Map;class vT{constructor(e,t){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let n=A0.get(r);if(n)return e[nm]=n;this.sheet=new i.CSSStyleSheet,A0.set(r,this)}else this.styleTag=r.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[nm]=this}mount(e,t){let r=this.sheet,i=0,n=0;for(let a=0;a<e.length;a++){let o=e[a],l=this.modules.indexOf(o);if(l<n&&l>-1&&(this.modules.splice(l,1),n--,l=-1),l==-1){if(this.modules.splice(n++,0,o),r)for(let h=0;h<o.rules.length;h++)r.insertRule(o.rules[h],i++)}else{for(;n<l;)i+=this.modules[n++].rules.length;i+=o.rules.length,n++}}if(r)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let a="";for(let l=0;l<this.modules.length;l++)a+=this.modules[l].getRules()+`
16
+ `;this.styleTag.textContent=a;let o=t.head||t;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Ji={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ga={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yT=typeof navigator<"u"&&/Mac/.test(navigator.platform),ST=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ps=0;Ps<10;Ps++)Ji[48+Ps]=Ji[96+Ps]=String(Ps);for(var Ps=1;Ps<=24;Ps++)Ji[Ps+111]="F"+Ps;for(var Ps=65;Ps<=90;Ps++)Ji[Ps]=String.fromCharCode(Ps+32),Ga[Ps]=String.fromCharCode(Ps);for(var ku in Ji)Ga.hasOwnProperty(ku)||(Ga[ku]=Ji[ku]);function wT(s){var e=yT&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||ST&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?Ga:Ji)[s.keyCode]||s.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Ft(){var s=arguments[0];typeof s=="string"&&(s=document.createElement(s));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=t[r];typeof i=="string"?s.setAttribute(r,i):i!=null&&(s[r]=i)}e++}for(;e<arguments.length;e++)My(s,arguments[e]);return s}function My(s,e){if(typeof e=="string")s.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)s.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)My(s,e[t]);else throw new RangeError("Unsupported child node: "+e)}let Vs=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},om=typeof document<"u"?document:{documentElement:{style:{}}};const am=/Edge\/(\d+)/.exec(Vs.userAgent),Ly=/MSIE \d/.test(Vs.userAgent),lm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vs.userAgent),Yh=!!(Ly||lm||am),M0=!Yh&&/gecko\/(\d+)/i.test(Vs.userAgent),Cu=!Yh&&/Chrome\/(\d+)/.exec(Vs.userAgent),L0="webkitFontSmoothing"in om.documentElement.style,cm=!Yh&&/Apple Computer/.test(Vs.vendor),N0=cm&&(/Mobile\/\w+/.test(Vs.userAgent)||Vs.maxTouchPoints>2);var Ve={mac:N0||/Mac/.test(Vs.platform),windows:/Win/.test(Vs.platform),linux:/Linux|X11/.test(Vs.platform),ie:Yh,ie_version:Ly?om.documentMode||6:lm?+lm[1]:am?+am[1]:0,gecko:M0,gecko_version:M0?+(/Firefox\/(\d+)/.exec(Vs.userAgent)||[0,0])[1]:0,chrome:!!Cu,chrome_version:Cu?+Cu[1]:0,ios:N0,android:/Android\b/.test(Vs.userAgent),webkit:L0,webkit_version:L0?+(/\bAppleWebKit\/(\d+)/.exec(Vs.userAgent)||[0,0])[1]:0,safari:cm,safari_version:cm?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Vs.userAgent)||[0,0])[1]:0,tabSize:om.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Op(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const Oh=Object.create(null);function xp(s,e,t){if(s==e)return!0;s||(s=Oh),e||(e=Oh);let r=Object.keys(s),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let n of r)if(n!=t&&(i.indexOf(n)==-1||s[n]!==e[n]))return!1;return!0}function _T(s,e){for(let t=s.attributes.length-1;t>=0;t--){let r=s.attributes[t].name;e[r]==null&&s.removeAttribute(r)}for(let t in e){let r=e[t];t=="style"?s.style.cssText=r:s.getAttribute(t)!=r&&s.setAttribute(t,r)}}function D0(s,e,t){let r=!1;if(e)for(let i in e)t&&i in t||(r=!0,i=="style"?s.style.cssText="":s.removeAttribute(i));if(t)for(let i in t)e&&e[i]==t[i]||(r=!0,i=="style"?s.style.cssText=t[i]:s.setAttribute(i,t[i]));return r}function kT(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let r=s.attributes[t];e[r.name]=r.value}return e}class Nr{eq(e){return!1}updateDOM(e,t,r){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,r){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Qs=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(Qs||(Qs={}));class ht extends Gi{constructor(e,t,r,i){super(),this.startSide=e,this.endSide=t,this.widget=r,this.spec=i}get heightRelevant(){return!1}static mark(e){return new Sl(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),r=!!e.block;return t+=r&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Vn(e,t,t,r,e.widget||null,!1)}static replace(e){let t=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:n,end:a}=Ny(e,t);r=(n?t?-3e8:-1:5e8)-1,i=(a?t?2e8:1:-6e8)+1}return new Vn(e,r,i,t,e.widget||null,!0)}static line(e){return new wl(e)}static set(e,t=!1){return Qt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ht.none=Qt.empty;class Sl extends ht{constructor(e){let{start:t,end:r}=Ny(e);super(t?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Op(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Oh}eq(e){return this==e||e instanceof Sl&&this.tagName==e.tagName&&xp(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Sl.prototype.point=!1;class wl extends ht{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof wl&&this.spec.class==e.spec.class&&xp(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}wl.prototype.mapMode=Ts.TrackBefore;wl.prototype.point=!0;class Vn extends ht{constructor(e,t,r,i,n,a){super(t,r,n,e),this.block=i,this.isReplace=a,this.mapMode=i?t<=0?Ts.TrackBefore:Ts.TrackAfter:Ts.TrackDel}get type(){return this.startSide!=this.endSide?Qs.WidgetRange:this.startSide<=0?Qs.WidgetBefore:Qs.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Vn&&CT(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Vn.prototype.point=!0;function Ny(s,e=!1){let{inclusiveStart:t,inclusiveEnd:r}=s;return t==null&&(t=s.inclusive),r==null&&(r=s.inclusive),{start:t??e,end:r??e}}function CT(s,e){return s==e||!!(s&&e&&s.compare(e))}function ko(s,e,t,r=0){let i=t.length-1;i>=0&&t[i]+r>=s?t[i]=Math.max(t[i],e):t.push(s,e)}class Ka extends Gi{constructor(e,t,r){super(),this.tagName=e,this.attributes=t,this.rank=r}eq(e){return e==this||e instanceof Ka&&this.tagName==e.tagName&&xp(this.attributes,e.attributes)}static create(e){return new Ka(e.tagName,e.attributes||Oh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return Qt.of(e,t)}}Ka.prototype.startSide=Ka.prototype.endSide=-1;function Ja(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function hm(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Wa(s,e){if(!e.anchorNode)return!1;try{return hm(s,e.anchorNode)}catch{return!1}}function Xa(s){return s.nodeType==3?tl(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function za(s,e,t,r){return t?I0(s,e,t,r,-1)||I0(s,e,t,r,1):!1}function en(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function xh(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function I0(s,e,t,r,i){for(;;){if(s==t&&e==r)return!0;if(e==(i<0?0:yi(s))){if(s.nodeName=="DIV")return!1;let n=s.parentNode;if(!n||n.nodeType!=1)return!1;e=en(s)+(i<0?0:1),s=n}else if(s.nodeType==1){if(s=s.childNodes[e+(i<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=i<0?yi(s):0}else return!1}}function yi(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function el(s,e){let{left:t,right:r}=s;if(t==r)return s;let i=e?t:r;return{left:i,right:i,top:s.top,bottom:s.bottom}}function PT(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function Dy(s,e){let t=e.width/s.offsetWidth,r=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-s.offsetHeight)<1)&&(r=1),{scaleX:t,scaleY:r}}function TT(s,e,t,r,i,n,a,o){let l=s.ownerDocument,h=l.defaultView||window;for(let u=s,d=!1;u&&!d;)if(u.nodeType==1){let f,p=u==l.body,v=1,b=1;if(p)f=PT(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let m=u.getBoundingClientRect();({scaleX:v,scaleY:b}=Dy(u,m)),f={left:m.left,right:m.left+u.clientWidth*v,top:m.top,bottom:m.top+u.clientHeight*b}}let O=0,g=0;if(i=="nearest")e.top<f.top+a?(g=e.top-(f.top+a),t>0&&e.bottom>f.bottom+g&&(g=e.bottom-f.bottom+a)):e.bottom>f.bottom-a&&(g=e.bottom-f.bottom+a,t<0&&e.top-g<f.top&&(g=e.top-(f.top+a)));else{let m=e.bottom-e.top,x=f.bottom-f.top;g=(i=="center"&&m<=x?e.top+m/2-x/2:i=="start"||i=="center"&&t<0?e.top-a:e.bottom-x+a)-f.top}if(r=="nearest"?e.left<f.left+n?(O=e.left-(f.left+n),t>0&&e.right>f.right+O&&(O=e.right-f.right+n)):e.right>f.right-n&&(O=e.right-f.right+n,t<0&&e.left<f.left+O&&(O=e.left-(f.left+n))):O=(r=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:r=="start"==o?e.left-n:e.right-(f.right-f.left)+n)-f.left,O||g)if(p)h.scrollBy(O,g);else{let m=0,x=0;if(g){let y=u.scrollTop;u.scrollTop+=g/b,x=(u.scrollTop-y)*b}if(O){let y=u.scrollLeft;u.scrollLeft+=O/v,m=(u.scrollLeft-y)*v}e={left:e.left-m,top:e.top-x,right:e.right-m,bottom:e.bottom-x},m&&Math.abs(m-O)<1&&(r="nearest"),x&&Math.abs(x-g)<1&&(i="nearest")}if(p)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Iy(s,e=!0){let t=s.ownerDocument,r=null,i=null;for(let n=s.parentNode;n&&!(n==t.body||(!e||r)&&i);)if(n.nodeType==1)!i&&n.scrollHeight>n.clientHeight&&(i=n),e&&!r&&n.scrollWidth>n.clientWidth&&(r=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:r,y:i}}class QT{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:r}=e;this.set(t,Math.min(e.anchorOffset,t?yi(t):0),r,Math.min(e.focusOffset,r?yi(r):0))}set(e,t,r,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=i}}let Ln=null;Ve.safari&&Ve.safari_version>=26&&(Ln=!1);function By(s){if(s.setActive)return s.setActive();if(Ln)return s.focus(Ln);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(Ln==null?{get preventScroll(){return Ln={preventScroll:!0},!0}}:void 0),!Ln){Ln=!1;for(let t=0;t<e.length;){let r=e[t++],i=e[t++],n=e[t++];r.scrollTop!=i&&(r.scrollTop=i),r.scrollLeft!=n&&(r.scrollLeft=n)}}}let B0;function tl(s,e,t=e){let r=B0||(B0=document.createRange());return r.setEnd(s,t),r.setStart(s,e),r}function Co(s,e,t,r){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let n=new KeyboardEvent("keydown",i);n.synthetic=!0,s.dispatchEvent(n);let a=new KeyboardEvent("keyup",i);return a.synthetic=!0,s.dispatchEvent(a),n.defaultPrevented||a.defaultPrevented}function $T(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function jT(s,e){let t=e.focusNode,r=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=r)return!1;for(r=Math.min(r,yi(t));;)if(r){if(t.nodeType!=1)return!1;let i=t.childNodes[r-1];i.contentEditable=="false"?r--:(t=i,r=yi(t))}else{if(t==s)return!0;r=en(t),t=t.parentNode}}function Wy(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function Xy(s,e){for(let t=s,r=e;;){if(t.nodeType==3&&r>0)return{node:t,offset:r};if(t.nodeType==1&&r>0){if(t.contentEditable=="false")return null;t=t.childNodes[r-1],r=yi(t)}else if(t.parentNode&&!xh(t))r=en(t),t=t.parentNode;else return null}}function zy(s,e){for(let t=s,r=e;;){if(t.nodeType==3&&r<t.nodeValue.length)return{node:t,offset:r};if(t.nodeType==1&&r<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[r],r=0}else if(t.parentNode&&!xh(t))r=en(t)+1,t=t.parentNode;else return null}}class Ar{constructor(e,t,r=!0){this.node=e,this.offset=t,this.precise=r}static before(e,t){return new Ar(e.parentNode,en(e),t)}static after(e,t){return new Ar(e.parentNode,en(e)+1,t)}}var Yt=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(Yt||(Yt={}));const Fn=Yt.LTR,bp=Yt.RTL;function qy(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const RT=qy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ET=qy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),dm=Object.create(null),qr=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);dm[e]=t,dm[t]=-e}function Zy(s){return s<=247?RT[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?ET[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const AT=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Gr{get dir(){return this.level%2?bp:Fn}constructor(e,t,r){this.from=e,this.to=t,this.level=r}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,r,i){let n=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==r)return a;(n<0||(i!=0?i<0?o.from<t:o.to>t:e[n].level>o.level))&&(n=a)}}if(n<0)throw new RangeError("Index out of range");return n}}function Vy(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let r=s[t],i=e[t];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Vy(r.inner,i.inner))return!1}return!0}const Ht=[];function MT(s,e,t,r,i){for(let n=0;n<=r.length;n++){let a=n?r[n-1].to:e,o=n<r.length?r[n].from:t,l=n?256:i;for(let h=a,u=l,d=l;h<o;h++){let f=Zy(s.charCodeAt(h));f==512?f=u:f==8&&d==4&&(f=16),Ht[h]=f==4?2:f,f&7&&(d=f),u=f}for(let h=a,u=l,d=l;h<o;h++){let f=Ht[h];if(f==128)h<o-1&&u==Ht[h+1]&&u&24?f=Ht[h]=u:Ht[h]=256;else if(f==64){let p=h+1;for(;p<o&&Ht[p]==64;)p++;let v=h&&u==8||p<t&&Ht[p]==8?d==1?1:8:256;for(let b=h;b<p;b++)Ht[b]=v;h=p-1}else f==8&&d==1&&(Ht[h]=1);u=f,f&7&&(d=f)}}}function LT(s,e,t,r,i){let n=i==1?2:1;for(let a=0,o=0,l=0;a<=r.length;a++){let h=a?r[a-1].to:e,u=a<r.length?r[a].from:t;for(let d=h,f,p,v;d<u;d++)if(p=dm[f=s.charCodeAt(d)])if(p<0){for(let b=o-3;b>=0;b-=3)if(qr[b+1]==-p){let O=qr[b+2],g=O&2?i:O&4?O&1?n:i:0;g&&(Ht[d]=Ht[qr[b]]=g),o=b;break}}else{if(qr.length==189)break;qr[o++]=d,qr[o++]=f,qr[o++]=l}else if((v=Ht[d])==2||v==1){let b=v==i;l=b?0:1;for(let O=o-3;O>=0;O-=3){let g=qr[O+2];if(g&2)break;if(b)qr[O+2]|=2;else{if(g&4)break;qr[O+2]|=4}}}}}function NT(s,e,t,r){for(let i=0,n=r;i<=t.length;i++){let a=i?t[i-1].to:s,o=i<t.length?t[i].from:e;for(let l=a;l<o;){let h=Ht[l];if(h==256){let u=l+1;for(;;)if(u==o){if(i==t.length)break;u=t[i++].to,o=i<t.length?t[i].from:e}else if(Ht[u]==256)u++;else break;let d=n==1,f=(u<e?Ht[u]:r)==1,p=d==f?d?1:2:r;for(let v=u,b=i,O=b?t[b-1].to:s;v>l;)v==O&&(v=t[--b].from,O=b?t[b-1].to:s),Ht[--v]=p;l=u}else n=h,l++}}}function um(s,e,t,r,i,n,a){let o=r%2?2:1;if(r%2==i%2)for(let l=e,h=0;l<t;){let u=!0,d=!1;if(h==n.length||l<n[h].from){let b=Ht[l];b!=o&&(u=!1,d=b==16)}let f=!u&&o==1?[]:null,p=u?r:r+1,v=l;e:for(;;)if(h<n.length&&v==n[h].from){if(d)break e;let b=n[h];if(!u)for(let O=b.to,g=h+1;;){if(O==t)break e;if(g<n.length&&n[g].from==O)O=n[g++].to;else{if(Ht[O]==o)break e;break}}if(h++,f)f.push(b);else{b.from>l&&a.push(new Gr(l,b.from,p));let O=b.direction==Fn!=!(p%2);fm(s,O?r+1:r,i,b.inner,b.from,b.to,a),l=b.to}v=b.to}else{if(v==t||(u?Ht[v]!=o:Ht[v]==o))break;v++}f?um(s,l,v,r+1,i,f,a):l<v&&a.push(new Gr(l,v,p)),l=v}else for(let l=t,h=n.length;l>e;){let u=!0,d=!1;if(!h||l>n[h-1].to){let b=Ht[l-1];b!=o&&(u=!1,d=b==16)}let f=!u&&o==1?[]:null,p=u?r:r+1,v=l;e:for(;;)if(h&&v==n[h-1].to){if(d)break e;let b=n[--h];if(!u)for(let O=b.from,g=h;;){if(O==e)break e;if(g&&n[g-1].to==O)O=n[--g].from;else{if(Ht[O-1]==o)break e;break}}if(f)f.push(b);else{b.to<l&&a.push(new Gr(b.to,l,p));let O=b.direction==Fn!=!(p%2);fm(s,O?r+1:r,i,b.inner,b.from,b.to,a),l=b.from}v=b.from}else{if(v==e||(u?Ht[v-1]!=o:Ht[v-1]==o))break;v--}f?um(s,v,l,r+1,i,f,a):v<l&&a.push(new Gr(v,l,p)),l=v}}function fm(s,e,t,r,i,n,a){let o=e%2?2:1;MT(s,i,n,r,o),LT(s,i,n,r,o),NT(i,n,r,o),um(s,i,n,e,t,r,a)}function DT(s,e,t){if(!s)return[new Gr(0,0,e==bp?1:0)];if(e==Fn&&!t.length&&!AT.test(s))return Fy(s.length);if(t.length)for(;s.length>Ht.length;)Ht[Ht.length]=256;let r=[],i=e==Fn?0:1;return fm(s,i,i,t,0,s.length,r),r}function Fy(s){return[new Gr(0,s,0)]}let Uy="";function IT(s,e,t,r,i){var n;let a=r.head-s.from,o=Gr.find(e,a,(n=r.bidiLevel)!==null&&n!==void 0?n:-1,r.assoc),l=e[o],h=l.side(i,t);if(a==h){let f=o+=i?1:-1;if(f<0||f>=e.length)return null;l=e[o=f],a=l.side(!i,t),h=l.side(i,t)}let u=ys(s.text,a,l.forward(i,t));(u<l.from||u>l.to)&&(u=h),Uy=s.text.slice(Math.min(a,u),Math.max(a,u));let d=o==(i?e.length-1:0)?null:e[o+(i?1:-1)];return d&&u==h&&d.level+(i?0:1)<l.level?fe.cursor(d.side(!i,t)+s.from,d.forward(i,t)?1:-1,d.level):fe.cursor(u+s.from,l.forward(i,t)?-1:1,l.level)}function BT(s,e,t){for(let r=e;r<t;r++){let i=Zy(s.charCodeAt(r));if(i==1)return Fn;if(i==2||i==4)return bp}return Fn}const Hy=Ge.define(),Yy=Ge.define(),Gy=Ge.define(),Ky=Ge.define(),mm=Ge.define(),Jy=Ge.define(),e1=Ge.define(),vp=Ge.define(),yp=Ge.define(),t1=Ge.define({combine:s=>s.some(e=>e)}),s1=Ge.define({combine:s=>s.some(e=>e)}),r1=Ge.define();class Po{constructor(e,t,r,i,n,a=!1){this.range=e,this.y=t,this.x=r,this.yMargin=i,this.xMargin=n,this.isSnapshot=a}map(e){return e.empty?this:new Po(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Po(fe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const vc=xt.define({map:(s,e)=>s.map(e)}),i1=xt.define();function tr(s,e,t){let r=s.facet(Ky);r.length?r[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Oi=Ge.define({combine:s=>s.length?s[0]:!0});let WT=0;const vo=Ge.define({combine(s){return s.filter((e,t)=>{for(let r=0;r<t;r++)if(s[r].plugin==e.plugin)return!1;return!0})}});class is{constructor(e,t,r,i,n){this.id=e,this.create=t,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(vo.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(vo.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:r,eventObservers:i,provide:n,decorations:a}=t||{};return new is(WT++,e,r,i,o=>{let l=[];return a&&l.push(Gh.of(h=>{let u=h.plugin(o);return u?a(u):ht.none})),n&&l.push(n(o)),l})}static fromClass(e,t){return is.define((r,i)=>new e(r,i),t)}}class Pu{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(r){if(tr(t.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){tr(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(r){tr(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const n1=Ge.define(),Sp=Ge.define(),Gh=Ge.define(),o1=Ge.define(),wp=Ge.define(),_l=Ge.define(),a1=Ge.define();function W0(s,e){let t=s.state.facet(a1);if(!t.length)return t;let r=t.map(n=>n instanceof Function?n(s):n),i=[];return Qt.spans(r,e.from,e.to,{point(){},span(n,a,o,l){let h=n-e.from,u=a-e.from,d=i;for(let f=o.length-1;f>=0;f--,l--){let p=o[f].spec.bidiIsolate,v;if(p==null&&(p=BT(e.text,h,u)),l>0&&d.length&&(v=d[d.length-1]).to==h&&v.direction==p)v.to=u,d=v.inner;else{let b={from:h,to:u,direction:p,inner:[]};d.push(b),d=b.inner}}}}),i}const l1=Ge.define();function _p(s){let e=0,t=0,r=0,i=0;for(let n of s.state.facet(l1)){let a=n(s);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(t=Math.max(t,a.right)),a.top!=null&&(r=Math.max(r,a.top)),a.bottom!=null&&(i=Math.max(i,a.bottom)))}return{left:e,right:t,top:r,bottom:i}}const Ma=Ge.define();class Sr{constructor(e,t,r,i){this.fromA=e,this.toA=t,this.fromB=r,this.toB=i}join(e){return new Sr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,r=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>r.toA)){if(i.toA<r.fromA)break;r=r.join(i),e.splice(t-1,1)}}return e.splice(t,0,r),e}static extendWithRanges(e,t){if(t.length==0)return e;let r=[];for(let i=0,n=0,a=0;;){let o=i<e.length?e[i].fromB:1e9,l=n<t.length?t[n]:1e9,h=Math.min(o,l);if(h==1e9)break;let u=h+a,d=h,f=u;for(;;)if(n<t.length&&t[n]<=d){let p=t[n+1];n+=2,d=Math.max(d,p);for(let v=i;v<e.length&&e[v].fromB<=d;v++)a=e[v].toA-e[v].toB;f=Math.max(f,p+a)}else if(i<e.length&&e[i].fromB<=d){let p=e[i++];d=Math.max(d,p.toB),f=Math.max(f,p.toA),a=p.toA-p.toB}else break;r.push(new Sr(u,f,h,d))}return r}}class bh{constructor(e,t,r){this.view=e,this.state=t,this.transactions=r,this.flags=0,this.startState=e.state,this.changes=fs.empty(this.startState.doc.length);for(let n of r)this.changes=this.changes.compose(n.changes);let i=[];this.changes.iterChangedRanges((n,a,o,l)=>i.push(new Sr(n,a,o,l))),this.changedRanges=i}static create(e,t,r){return new bh(e,t,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const XT=[];class rs{constructor(e,t,r=0){this.dom=e,this.length=t,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return XT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&_T(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let r=t;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,r){return null}domPosFor(e,t){let r=en(this.dom),i=this.length?e>0:t>0;return new Ar(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Jh)return e;return null}static get(e){return e.cmTile}}class Kh extends rs{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,r=null,i,n=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,i=r?r.nextSibling:t.firstChild,n&&i!=o.dom&&(n.written=!0),o.dom.parentNode==t)for(;i&&i!=o.dom;)i=X0(i);else t.insertBefore(o.dom,i);r=o.dom}for(i=r?r.nextSibling:t.firstChild,n&&i&&(n.written=!0);i;)i=X0(i);this.length=a}}function X0(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class Jh extends Kh{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=rs.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],r=this,i=0,n=0;;)if(i==r.children.length){if(!t.length)return;r=r.parent,r.breakAfter&&n++,i=t.pop()}else{let a=r.children[i++];if(a instanceof xi)t.push(i),r=a,i=0;else{let o=n+a.length,l=e(a,n);if(l!==void 0)return l;n=o+a.breakAfter}}}resolveBlock(e,t){let r,i=-1,n,a=-1;if(this.blockTiles((o,l)=>{let h=l+o.length;if(e>=l&&e<=h){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(r=void 0)}(l<e||e==h&&(t<-1?o.length:o.covers(1)))&&(!r||!o.isWidget()&&r.isWidget())&&(r=o,i=e-l),(h>e||e==l&&(t>1?o.length:o.covers(-1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,a=e-l)}}),!r&&!n)throw new Error("No tile at position "+e);return r&&t<0||!n?{tile:r,offset:i}:{tile:n,offset:a}}}class xi extends Kh{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let r=new xi(t||document.createElement(e.tagName),e);return t||(r.flags|=4),r}}class Ao extends Kh{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,r){let i=new Ao(t||document.createElement("div"),e);return(!t||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,r){let i=null,n=-1,a=null,o=-1;function l(u,d){for(let f=0,p=0;f<u.children.length&&p<=d;f++){let v=u.children[f],b=p+v.length;b>=d&&(v.isComposite()?l(v,d-p):(!a||a.isHidden&&(t>0&&!(a.flags&32)||r&&qT(a,v)))&&(b>d||v.flags&32&&t<=1)?(a=v,o=d-p):(p<d||v.flags&16&&!v.isHidden&&t>=-1)&&(i=v,n=d-p)),p=b}}l(this,e);let h=(t<0?i:a)||i||a;return h?{tile:h,offset:h==i?n:o}:null}coordsIn(e,t,r){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t,r):zT(this)}domIn(e,t){let r=this.resolveInline(e,t);if(r){let{tile:i,offset:n}=r;if(this.dom.contains(i.dom))return i.isText()?new Ar(i.dom,Math.min(i.dom.nodeValue.length,n)):i.domPosFor(n,i.flags&16?1:i.flags&32?-1:t);let a=r.tile.parent,o=!1;for(let l of a.children){if(o)return new Ar(l.dom,0);l==r.tile&&(o=!0)}}return new Ar(this.dom,0)}}function zT(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=Xa(e);return t[t.length-1]||null}function qT(s,e){let t=s.coordsIn(0,1),r=e.coordsIn(0,1);return t&&r&&r.top<t.bottom}class er extends Kh{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let r=new er(t||document.createElement(e.tagName),e);return t||(r.flags|=4),r}}class Wn extends rs{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,r){let i=this.dom.nodeValue.length;e>i&&(e=i);let n=e,a=e,o=0;e==0&&t<0||e==i&&t>=0?Ve.chrome||Ve.gecko||(e?(n--,o=1):a<i&&(a++,o=-1)):t<0?n--:a<i&&a++;let l=tl(this.dom,n,a).getClientRects();if(!l.length)return null;let h=l[(o?o<0:t>=0)?0:l.length-1];return Ve.safari&&!o&&h.width==0&&(h=Array.prototype.find.call(l,u=>u.width)||h),r==null?h:el(h,(o?o>0:t<0)==r)}static of(e,t){let r=new Wn(t||document.createTextNode(e),e);return t||(r.flags|=2),r}}class Un extends rs{constructor(e,t,r,i){super(e,t,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,r){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;if(r)return el(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let n=this.dom.getClientRects(),a=null;if(!n.length)return null;let o=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=o?n.length-1:0;a=n[l],!(e>0?l==0:l==n.length-1||a.top<a.bottom);l+=o?-1:1);return el(a,!o)}}get overrideDOMText(){if(!this.length)return It.empty;let{root:e}=this;if(!e)return It.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,r,i,n){return n||(n=e.toDOM(t),e.editable||(n.contentEditable="false")),new Un(n,r,e,i)}}class vh extends rs{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return It.empty}coordsIn(e,t,r){let i=this.dom.getBoundingClientRect();return r==null?i:el(i,t>0==r)}}class ZT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,r){let{tile:i,index:n,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(i.isComposite())if(a){if(!e)break;r&&r.break(),e--,a=!1}else if(n==i.children.length){if(!e&&!o.length)break;r&&r.leave(i),a=!!i.breakAfter,{tile:i,index:n}=o.pop(),n++}else{let l=i.children[n],h=l.breakAfter;(t>0?l.length<=e:l.length<e)&&(!r||r.skip(l,0,l.length)!==!1||!l.isComposite)?(a=!!h,n++,e-=l.length):(o.push({tile:i,index:n}),i=l,n=0,r&&l.isComposite()&&r.enter(l))}else{let l=i.length;if(n<l&&e){let h=Math.min(e,l-n);r&&r.skip(i,n,n+h),e-=h,n+=h}if(n==l)a=!!i.breakAfter,{tile:i,index:n}=o.pop(),n++;else if(!e)break}return this.tile=i,this.index=n,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class VT{constructor(e,t,r,i){this.from=e,this.to=t,this.wrapper=r,this.rank=i}}class FT{constructor(e,t,r){this.cache=e,this.root=t,this.blockWrappers=r,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,r,i){var n;this.flushBuffer();let a=this.ensureMarks(t,r),o=a.lastChild;if(o&&o.isText()&&!(o.flags&8)&&o.length+e.length<512){this.cache.reused.set(o,2);let l=a.children[a.children.length-1]=new Wn(o.dom,o.text+e);l.parent=a}else a.append(i||Wn.of(e,(n=this.cache.find(Wn))===null||n===void 0?void 0:n.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let r=this.curLine;r.dom!=t.line.dom&&(r.setDOM(this.cache.reused.has(t.line)?Tu(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let i=r;for(let o=t.marks.length-1;o>=0;o--){let l=t.marks[o],h=i.lastChild;if(h instanceof er&&h.mark.eq(l.mark))h.dom!=l.dom&&h.setDOM(Tu(l.dom)),i=h;else{if(this.cache.reused.get(l)){let d=rs.get(l.dom);d&&d.setDOM(Tu(l.dom))}let u=er.of(l.mark,l.dom);i.append(u),i=u}this.cache.reused.set(l,2)}let n=rs.get(e.text);n&&this.cache.reused.set(n,2);let a=new Wn(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,i.append(a)}addInlineWidget(e,t,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let n=this.ensureMarks(t,r);!i&&!(e.flags&16)&&n.append(this.getBuffer(1)),n.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,r){this.flushBuffer(),this.ensureMarks(t,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var r;e||(e=c1);let i=Ao.start(e,t||((r=this.cache.find(Ao))===null||r===void 0?void 0:r.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var r;let i=this.curLine;for(let n=e.length-1;n>=0;n--){let a=e[n],o;if(t>0&&(o=i.lastChild)&&o instanceof er&&o.mark.eq(a))i=o,t--;else{let l=er.of(a,(r=this.cache.find(er,h=>h.mark.eq(a)))===null||r===void 0?void 0:r.dom);i.append(l),i=l,t=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!z0(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ve.ios&&z0(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Qu,0,32)||new Un(Qu.toDOM(),0,Qu,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,r=new VT(e.from,e.to,e.value,t),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let r of this.wrappers){let i=t.lastChild;if(r.from<this.pos&&i instanceof xi&&i.wrapper.eq(r.wrapper))t=i;else{let n=xi.of(r.wrapper,(e=this.cache.find(xi,a=>a.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);t.append(n),t=n}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),r=this.cache.find(vh,void 0,1);return r&&(r.flags=t),r||new vh(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class UT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:n,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=i;let o=this.textOff=Math.min(e,i.length);return n?null:i.slice(0,o)}let t=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,t);return this.textOff=t,r}}const yh=[Un,Ao,Wn,er,vh,xi,Jh];for(let s=0;s<yh.length;s++)yh[s].bucket=s;class HT{constructor(e){this.view=e,this.buckets=yh.map(()=>[]),this.index=yh.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,r=this.buckets[t];r.length<6?r.push(e):r[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,r=2){let i=e.bucket,n=this.buckets[i],a=this.index[i];for(let o=0;o<n.length;o++){let l=(o+a)%n.length,h=n[l];if((!t||t(h))&&!this.reused.has(h))return n.splice(l,1),l<a&&this.index[i]--,this.reused.set(h,r),h}return null}findWidget(e,t,r){let i=this.buckets[0];if(i.length)for(let n=0,a=0;;n++){if(n==i.length){if(a)return null;a=1,n=0}let o=i[n];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return i.splice(n,1),n<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==r?(this.reused.set(o,1),o):(this.reused.set(o,2),new Un(o.dom,t,e,o.flags&-498|r))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class YT{constructor(e,t,r,i,n){this.view=e,this.decorations=i,this.disallowBlockEffectsFor=n,this.openWidget=!1,this.openMarks=0,this.cache=new HT(e),this.text=new UT(e.state.doc),this.builder=new FT(this.cache,new Jh(e,e.contentDOM),Qt.iter(r)),this.cache.reused.set(t,2),this.old=new ZT(t),this.reuseWalker={skip:(a,o,l)=>{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let r=t&&this.getCompositionContext(t.text);for(let i=0,n=0,a=0;;){let o=a<e.length?e[a++]:null,l=o?o.fromA:this.old.root.length;if(l>i){let h=l-i;this.preserve(h,!a,!o),i=l,n+=h}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(n,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,r),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(n,o.toB)),n=o.toB,i=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,r){let i=JT(this.old),n=this.openMarks;this.old.advance(e,r?1:-1,{skip:(a,o,l)=>{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(l-o);else{let h=l>0||o<a.length?Un.of(a.widget,this.view,l-o,a.flags&496,this.cache.maybeReuse(a)):this.cache.reuse(a);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,i,n),n=i.length)}else if(a.isText())this.builder.ensureLine(null),!o&&l==a.length&&!this.cache.reused.has(a)?this.builder.addText(a.text,i,n,this.cache.reuse(a)):(this.cache.add(a),this.builder.addText(a.text.slice(o,l),i,n)),n=i.length;else if(a.isLine())a.flags&=-2,this.cache.reused.set(a,1),this.builder.addLine(a);else if(a instanceof vh)this.cache.add(a);else if(a instanceof er)this.builder.ensureLine(null),this.builder.addMark(a,i,n),this.cache.reused.set(a,1),n=i.length;else return!1;this.openWidget=!1},enter:a=>{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof er&&i.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?i.length&&(i.length=n=0):a instanceof er&&(i.shift(),n=Math.min(n,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let r=null,i=this.builder,n=-1,a=Qt.spans(this.decorations,e,t,{point:(o,l,h,u,d,f)=>{if(h instanceof Vn){if(this.disallowBlockEffectsFor[f]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=u.length,d>u.length)i.continueWidget(l-o);else{let p=h.widget||(h.block?Mo.block:Mo.inline),v=GT(h),b=this.cache.findWidget(p,l-o,v)||Un.of(p,this.view,l-o,v);h.block?(h.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(b)):(i.ensureLine(r),i.addInlineWidget(b,u,d))}r=null}else r=KT(r,h);l>o&&this.text.skip(l-o)},span:(o,l,h,u)=>{for(let d=o;d<l;){let f=this.text.next(Math.min(512,l-d));f==null?(i.addLineStartIfNotCovered(r),i.addBreak(),d++):(i.ensureLine(r),i.addText(f,h,d==o?u:h.length),d+=f.length),r=null}n=h.length}});n>-1&&(this.openWidget=a>n),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=a}forward(e,t,r=1){t-e<=10?this.old.advance(t-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let t=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let n=rs.get(i);if(i==this.view.contentDOM)break;n instanceof er?t.push(n):n?.isLine()?r=n:n instanceof xi||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Ao(i,c1):r||t.push(er.of(new Sl({tagName:i.nodeName.toLowerCase(),attributes:kT(i)}),i)))}return{line:r,marks:t}}}function z0(s,e){let t=r=>{for(let i of r.children)if((e?i.isText():i.length)||t(i))return!0;return!1};return t(s)}function GT(s){let e=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(e|=256),e}const c1={class:"cm-line"};function KT(s,e){let t=e.spec.attributes,r=e.spec.class;return!t&&!r||(s||(s={class:"cm-line"}),t&&Op(t,s),r&&(s.class+=" "+r)),s}function JT(s){let e=[];for(let t=s.parents.length;t>1;t--){let r=t==s.parents.length?s.tile:s.parents[t].tile;r instanceof er&&e.push(r.mark)}return e}function Tu(s){let e=rs.get(s);return e&&e.setDOM(s.cloneNode()),s}class Mo extends Nr{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Mo.inline=new Mo("span");Mo.block=new Mo("div");const Qu=new class extends Nr{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class q0{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ht.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Jh(e,e.contentDOM),this.updateInner([new Sr(0,0,0,e.state.doc.length)],null)}update(e){var t;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:u,toA:d})=>d<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?i=this.domChanged.newSel.head:!lQ(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let n=i>-1?tQ(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:d}=this.hasComposition;r=new Sr(u,d,e.changes.mapPos(u,-1),e.changes.mapPos(d,1)).addToSet(r.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(Ve.ie||Ve.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,o=this.blockWrappers;this.updateDeco();let l=iQ(a,this.decorations,e.changes);l.length&&(r=Sr.extendWithRanges(r,l));let h=oQ(o,this.blockWrappers,e.changes);return h.length&&(r=Sr.extendWithRanges(r,h)),n&&!r.some(u=>u.fromA<=n.range.fromA&&u.toA>=n.range.toA)&&(r=n.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(t||e.length){let a=this.tile,o=new YT(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&rs.get(t.text)&&o.cache.reused.set(rs.get(t.text),2),this.tile=o.run(e,t),pm(a,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=Ve.chrome||Ve.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||r.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let n of this.tile.children)n.isWidget()&&n.widget instanceof $u&&i.push(n.dom);r.updateGaps(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let r of t.effects)r.is(i1)&&(this.editContextFormatting=r.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:r}=this.tile,i=this.view.root.activeElement,n=i==r,a=!n&&!(this.view.state.facet(Oi)||r.tabIndex>-1)&&Wa(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(n||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,h,u;if(l.empty?u=h=this.inlineDOMNearPos(l.anchor,l.assoc||1):(u=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),h=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),Ve.gecko&&l.empty&&!this.hasComposition&&eQ(h)){let f=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(f,h.node.childNodes[h.offset]||null)),h=u=new Ar(f,0),o=!0}let d=this.view.observer.selectionRange;(o||!d.focusNode||(!za(h.node,h.offset,d.anchorNode,d.anchorOffset)||!za(u.node,u.offset,d.focusNode,d.focusOffset))&&!this.suppressWidgetCursorChange(d,l))&&(this.view.observer.ignore(()=>{Ve.android&&Ve.chrome&&r.contains(d.focusNode)&&aQ(d.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let f=Ja(this.view.root);if(f)if(l.empty){if(Ve.gecko){let p=sQ(h.node,h.offset);if(p&&p!=3){let v=(p==1?Xy:zy)(h.node,h.offset);v&&(h=new Ar(v.node,v.offset))}}f.collapse(h.node,h.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(h.node,h.offset);try{f.extend(u.node,u.offset)}catch{}}else{let p=document.createRange();l.anchor>l.head&&([h,u]=[u,h]),p.setEnd(u.node,u.offset),p.setStart(h.node,h.offset),f.removeAllRanges(),f.addRange(p)}a&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(h,u)),this.impreciseAnchor=h.precise?null:new Ar(d.anchorNode,d.anchorOffset),this.impreciseHead=u.precise?null:new Ar(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&za(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,r=Ja(e.root),{anchorNode:i,anchorOffset:n}=e.observer.selectionRange;if(!r||!t.empty||!t.assoc||!r.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let l=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!l||!h||l.bottom>h.top)return;let u=this.domAtPos(t.head+t.assoc,t.assoc);r.collapse(u.node,u.offset),r.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=t.from&&r.collapse(i,n)}posFromDOM(e,t){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let n;if(e==r.dom)n=r.dom.childNodes[t];else{let a=yi(e)==0?0:t==0?-1:1;for(;;){let o=e.parentNode;if(o==r.dom)break;a==0&&o.firstChild!=o.lastChild&&(e==o.firstChild?a=-1:a=1),e=o}a<0?n=e:n=e.nextSibling}if(n==r.dom.firstChild)return i;for(;n&&!rs.get(n);)n=n.nextSibling;if(!n)return i+r.length;for(let a=0,o=i;;a++){let l=r.children[a];if(l.dom==n)return o;o+=l.length+l.breakAfter}}else return r.isText()?e==r.dom?i+t:i+(t?r.length:0):i}domAtPos(e,t){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.domPosFor(i,t):r.domIn(i,t)}inlineDOMNearPos(e,t){let r,i=-1,n=!1,a,o=-1,l=!1;return this.tile.blockTiles((h,u)=>{if(h.isWidget()){if(h.flags&32&&u>=e)return!0;h.flags&16&&(n=!0)}else{let d=u+h.length;if(u<=e&&(r=h,i=e-u,n=d<e),d>=e&&!a&&(a=h,o=e-u,l=u>e),u>e&&a)return!0}}),!r&&!a?this.domAtPos(e,t):(n&&a?r=null:l&&r&&(a=null),r&&t<0||!a?r.domIn(i,t):a.domIn(o,t))}coordsAt(e,t,r){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof $u?null:i.coordsInWidget(n,t,!0):i.coordsIn(n,t,r)}lineAt(e,t){let{tile:r}=this.tile.resolveBlock(e,t);return r.isLine()?r:null}coordsForChar(e){let{tile:t,offset:r}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function i(n,a){if(n.isComposite())for(let o of n.children){if(o.length>=a){let l=i(o,a);if(l)return l}if(a-=o.length,a<0)break}else if(n.isText()&&a<n.length){let o=ys(n.text,a);if(o==a)return null;let l=tl(n.dom,a,o).getClientRects();for(let h=0;h<l.length;h++){let u=l[h];if(h==l.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}return i(t,r)}measureVisibleLineHeights(e){let t=[],{from:r,to:i}=e,n=this.view.contentDOM.clientWidth,a=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==Yt.LTR,h=0,u=(d,f,p)=>{for(let v=0;v<d.children.length&&!(f>i);v++){let b=d.children[v],O=f+b.length,g=b.dom.getBoundingClientRect(),{height:m}=g;if(p&&!v&&(h+=g.top-p.top),b instanceof xi)O>r&&u(b,f,g);else if(f>=r&&(h>0&&t.push(-h),t.push(m+h),h=0,a)){let x=b.dom.lastChild,y=x?Xa(x):[];if(y.length){let k=y[y.length-1],C=l?k.right-g.left:g.right-k.left;C>o&&(o=C,this.minWidth=n,this.minWidthFrom=f,this.minWidthTo=O)}}p&&v==d.children.length-1&&(h+=p.bottom-g.bottom),f=O+b.breakAfter}};return u(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Yt.RTL:Yt.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let o=0,l;for(let h of a.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let u=Xa(h.dom);if(u.length!=1)return;o+=u[0].width,l=u[0].height}if(o)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:o/a.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),r,i,n;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let a=Xa(t.firstChild)[0];r=t.getBoundingClientRect().height,i=a&&a.width?a.width/27:7,n=a&&a.height?a.height:r,t.remove()}),{lineHeight:r,charWidth:i,textHeight:n}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let r=0,i=0;;i++){let n=i==t.viewports.length?null:t.viewports[i],a=n?n.from-1:this.view.state.doc.length;if(a>r){let o=(t.lineBlockAt(a).bottom-t.lineBlockAt(r).top)/this.view.scaleY;e.push(ht.replace({widget:new $u(o),block:!0,inclusive:!0,isBlockGap:!0}).range(r,a))}if(!n)break;r=n.to+1}return ht.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Gh).map(n=>(this.dynamicDecorationMap[e++]=typeof n=="function")?n(this.view):n),r=!1,i=this.view.state.facet(wp).map((n,a)=>{let o=typeof n=="function";return o&&(r=!0),o?n(this.view):n});for(i.length&&(this.dynamicDecorationMap[e++]=r,t.push(Qt.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(o1).map(n=>typeof n=="function"?n(this.view):n)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(r1))try{if(h(this.view,e.range,e))return!0}catch(u){tr(this.view.state,u,"scroll handler")}let{range:t}=e,r=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),i;if(!r)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let n=_p(this.view),a={left:r.left-n.left,top:r.top-n.top,right:r.right+n.right,bottom:r.bottom+n.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;if(TT(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Yt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=r=>r.isWidget()||r.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){pm(this.tile)}}function pm(s,e){let t=e?.get(s);if(t!=1){t==null&&s.destroy();for(let r of s.children)pm(r,e)}}function eQ(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function h1(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let r=Xy(t.focusNode,t.focusOffset),i=zy(t.focusNode,t.focusOffset),n=r||i;if(i&&r&&i.node!=r.node){let o=rs.get(i.node);if(!o||o.isText()&&o.text!=i.node.nodeValue)n=i;else if(s.docView.lastCompositionAfterCursor){let l=rs.get(r.node);!l||l.isText()&&l.text!=r.node.nodeValue||(n=i)}}if(s.docView.lastCompositionAfterCursor=n!=r,!n)return null;let a=e-n.offset;return{from:a,to:a+n.node.nodeValue.length,node:n.node}}function tQ(s,e,t){let r=h1(s,t);if(!r)return null;let{node:i,from:n,to:a}=r,o=i.nodeValue;if(/[\n\r]/.test(o)||s.state.doc.sliceString(r.from,r.to)!=o)return null;let l=e.invertedDesc;return{range:new Sr(l.mapPos(n),l.mapPos(a),n,a),text:i}}function sQ(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let rQ=class{constructor(){this.changes=[]}compareRange(e,t){ko(e,t,this.changes)}comparePoint(e,t){ko(e,t,this.changes)}boundChange(e){ko(e,e,this.changes)}};function iQ(s,e,t){let r=new rQ;return Qt.compare(s,e,t,r),r.changes}class nQ{constructor(){this.changes=[]}compareRange(e,t){ko(e,t,this.changes)}comparePoint(){}boundChange(e){ko(e,e,this.changes)}}function oQ(s,e,t){let r=new nQ;return Qt.compare(s,e,t,r),r.changes}function aQ(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function lQ(s,e){let t=!1;return e&&s.iterChangedRanges((r,i)=>{r<e.to&&i>e.from&&(t=!0)}),t}class $u extends Nr{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function cQ(s,e,t=1){let r=s.charCategorizer(e),i=s.doc.lineAt(e),n=e-i.from;if(i.length==0)return fe.cursor(e);n==0?t=1:n==i.length&&(t=-1);let a=n,o=n;t<0?a=ys(i.text,n,!1):o=ys(i.text,n);let l=r(i.text.slice(a,o));for(;a>0;){let h=ys(i.text,a,!1);if(r(i.text.slice(h,a))!=l)break;a=h}for(;o<i.length;){let h=ys(i.text,o);if(r(i.text.slice(o,h))!=l)break;o=h}return fe.undirectionalRange(a+i.from,o+i.from)}function hQ(s,e,t,r,i){let n=Math.round((r-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let o=s.viewState.heightOracle.textHeight,l=Math.floor((i-t.top-(s.defaultLineHeight-o)*.5)/o);n+=l*s.viewState.heightOracle.lineLength}let a=s.state.sliceDoc(t.from,t.to);return t.from+rm(a,n,s.state.tabSize)}function gm(s,e,t){let r=s.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let n of r.type){if(n.from>e)break;if(!(n.to<e)){if(n.from<e&&n.to>e)return n;(!i||n.type==Qs.Text&&(i.type!=n.type||(t<0?n.from<e:n.to>e)))&&(i=n)}}return i||r}return r}function dQ(s,e,t,r){let i=gm(s,e.head,e.assoc||-1),n=!r||i.type!=Qs.Text||!(s.lineWrapping||i.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(n){let a=s.dom.getBoundingClientRect(),o=s.textDirectionAt(i.from),l=s.posAtCoords({x:t==(o==Yt.LTR)?a.right-1:a.left+1,y:(n.top+n.bottom)/2});if(l!=null)return fe.cursor(l,t?-1:1)}return fe.cursor(t?i.to:i.from,t?-1:1)}function Z0(s,e,t,r){let i=s.state.doc.lineAt(e.head),n=s.bidiSpans(i),a=s.textDirectionAt(i.from);for(let o=e,l=null;;){let h=IT(i,n,a,o,t),u=Uy;if(!h){if(i.number==(t?s.state.doc.lines:1))return o;u=`
17
+ `,i=s.state.doc.line(i.number+(t?1:-1)),n=s.bidiSpans(i),h=s.visualLineSide(i,!t)}if(l){if(!l(u))return o}else{if(!r)return h;l=r(u)}o=h}}function uQ(s,e,t){let r=s.state.charCategorizer(e),i=r(t);return n=>{let a=r(n);return i==Jt.Space&&(i=a),i==a}}function fQ(s,e,t,r){let i=e.head,n=t?1:-1;if(i==(t?s.state.doc.length:0))return fe.cursor(i,e.assoc);let a=e.goalColumn,o,l=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(i,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),u=s.documentTop;if(h)a==null&&(a=h.left-l.left),o=n<0?h.top:h.bottom;else{let v=s.viewState.lineBlockAt(i);a==null&&(a=Math.min(l.right-l.left,s.defaultCharacterWidth*(i-v.from))),o=(n<0?v.top:v.bottom)+u}let d=l.left+a,f=s.viewState.heightOracle.textHeight>>1,p=r??f;for(let v=0;;v+=f){let b=o+(p+v)*n,O=Om(s,{x:d,y:b},!1,n);if(t?b>l.bottom:b<l.top)return fe.cursor(O.pos,O.assoc);let g=s.coordsAtPos(O.pos,O.assoc),m=g?(g.top+g.bottom)/2:0;if(!g||(t?m>o:m<o))return fe.cursor(O.pos,O.assoc,void 0,a)}}function qa(s,e,t){for(;;){let r=0;for(let i of s)i.between(e-1,e+1,(n,a,o)=>{if(e>n&&e<a){let l=r||t||(e-n<a-e?-1:1);e=l<0?n:a,r=l}});if(!r)return e}}function d1(s,e){let t=null;for(let r=0;r<e.ranges.length;r++){let i=e.ranges[r],n=null;if(i.empty){let a=qa(s,i.from,0);a!=i.from&&(n=fe.cursor(a,-1))}else{let a=qa(s,i.from,-1),o=qa(s,i.to,1);(a!=i.from||o!=i.to)&&(i.undirectional?n=fe.undirectionalRange(i.from,i.to):n=fe.range(i.from==i.anchor?a:o,i.from==i.head?a:o))}n&&(t||(t=e.ranges.slice()),t[r]=n)}return t?fe.create(t,e.mainIndex):e}function ju(s,e,t){let r=qa(s.state.facet(_l).map(i=>i(s)),t.from,e.head>t.from?-1:1);return r==t.from?t:fe.cursor(r,r<t.from?1:-1)}class Yr{constructor(e,t){this.pos=e,this.assoc=t}}function Om(s,e,t,r){let i=s.contentDOM.getBoundingClientRect(),n=i.top+s.viewState.paddingTop,{x:a,y:o}=e,l=o-n,h;for(;;){if(l<0)return new Yr(0,1);if(l>s.viewState.docHeight)return new Yr(s.state.doc.length,-1);if(h=s.elementAtHeight(l),r==null)break;if(h.type==Qs.Text){if(r<0?h.to<s.viewport.from:h.from>s.viewport.to)break;let f=s.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(f&&(r<0?f.top<=l+n:f.bottom>=l+n))break}let d=s.viewState.heightOracle.textHeight/2;l=r>0?h.bottom+d:h.top-d}if(s.viewport.from>=h.to||s.viewport.to<=h.from){if(t)return null;if(h.type==Qs.Text){let d=hQ(s,i,h,a,o);return new Yr(d,d==h.from?1:-1)}}if(h.type!=Qs.Text)return l<(h.top+h.bottom)/2?new Yr(h.from,1):new Yr(h.to,-1);let u=s.docView.lineAt(h.from,2);return(!u||u.length!=h.length)&&(u=s.docView.lineAt(h.from,-2)),new mQ(s,a,o,s.textDirectionAt(h.from)).scanTile(u,h.from)}class mQ{constructor(e,t,r,i){this.view=e,this.x=t,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:r,spans:i}=this.bidiSpansAt(e);return i[Gr.find(i,e-r.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:r,spans:i}=this.bidiSpansAt(e);return i[Gr.find(i,e-r.from,-1,t)].dir}bidiIn(e,t){let{spans:r,line:i}=this.bidiSpansAt(e);return r.length>1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from<t)}scan(e,t,r=!1){let i=0,n=e.length-1,a=new Set,o=this.bidiIn(e[0],e[n]),l,h,u=-1,d=1e9,f;e:for(;i<n;){let v=n-i,b=i+n>>1;t:if(a.has(b)){let g=i+Math.floor(Math.random()*v);for(let m=0;m<v;m++){if(!a.has(g)){b=g;break t}g++,g==n&&(g=i)}break e}a.add(b);let O=t(b);if(O)for(let g=0;g<O.length;g++){let m=O[g],x=0;if(!(m.width==0&&O.length>1)){if(m.bottom<this.y)(!l||l.bottom<m.bottom)&&(l=m),x=1;else if(m.top>this.y)(!h||h.top>m.top)&&(h=m),x=-1;else{let y=m.left>this.x?this.x-m.left:m.right<this.x?this.x-m.right:0,k=Math.abs(y);k<d&&(u=b,d=k,f=m),y&&(x=y<0==(this.baseDir==Yt.LTR)?-1:1)}x==-1&&(!o||this.baseDirAt(e[b],1))?n=b:x==1&&(!o||this.baseDirAt(e[b+1],-1))&&(i=b+1)}}}if(!f){if(!h&&!l)return{i:e[0],after:!1};let v=l&&(!h||this.y-l.bottom<h.top-this.y)?l:h;return this.y=(v.top+v.bottom)/2,this.scan(e,t,!0)}if(d&&!r){let{top:v,bottom:b}=f;if(l&&l.bottom>(v+v+b)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(h&&h.top<(v+b+b)/3)return this.y=h.top+1,this.scan(e,t,!0)}let p=(o?this.dirAt(e[u],1):this.baseDir)==Yt.LTR;return{i:u,after:this.x>(f.left+f.right)/2==p}}scanText(e,t){let r=[];for(let n=0;n<e.length;n=ys(e.text,n))r.push(t+n);r.push(t+e.length);let i=this.scan(r,n=>{let a=r[n]-t,o=r[n+1]-t;return tl(e.dom,a,o).getClientRects()});return i.after?new Yr(r[i.i+1],-1):new Yr(r[i.i],1)}scanTile(e,t){if(!e.length)return new Yr(t,1);if(e.children.length==1){let o=e.children[0];if(o.isText())return this.scanText(o,t);if(o.isComposite())return this.scanTile(o,t)}let r=[t];for(let o=0,l=t;o<e.children.length;o++)r.push(l+=e.children[o].length);let i=this.scan(r,o=>{let l=e.children[o];return l.flags&48?null:(l.dom.nodeType==1?l.dom:tl(l.dom,0,l.length)).getClientRects()}),n=e.children[i.i],a=r[i.i];return n.isText()?this.scanText(n,a):n.isComposite()?this.scanTile(n,a):i.after?new Yr(r[i.i+1],-1):new Yr(a,1)}}const Oo="￿";class pQ{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Oo}readRange(e,t){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let n=this.text.length;this.readNode(i);let a=rs.get(i),o=i.nextSibling;if(o==t){a?.breakAfter&&!o&&r!=this.view.contentDOM&&this.lineBreak();break}let l=rs.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:xh(i))||xh(o)&&(i.nodeName!="BR"||a?.isWidget())&&this.text.length>n)&&!OQ(o,t)&&this.lineBreak(),i=o}return this.findPointBefore(r,t),this}readTextNode(e){let t=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,t.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,a=1,o;if(this.lineSeparator?(n=t.indexOf(this.lineSeparator,r),a=this.lineSeparator.length):(o=i.exec(t))&&(n=o.index,a=o[0].length),this.append(t.slice(r,n<0?t.length:n)),n<0)break;if(this.lineBreak(),a>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=a-1);r=n+a}}readNode(e){let t=rs.get(e),r=t&&t.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==t&&(r.pos=this.text.length)}findPointInside(e,t){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(gQ(e,r.node,r.offset)?t:0))}}function gQ(s,e,t){for(;;){if(!e||t<yi(e))return!1;if(e==s)return!0;t=en(e)+1,e=e.parentNode}}function OQ(s,e){let t;for(;!(s==e||!s);s=s.nextSibling){let r=rs.get(s);if(!r?.isWidget())return!1;r&&(t||(t=[])).push(r)}if(t)for(let r of t){let i=r.overrideDOMText;if(i?.length)return!1}return!0}class V0{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class xQ{constructor(e,t,r,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:n,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=u1(e.docView.tile,t,r,0))){let l=n||a?[]:vQ(e),h=new pQ(l,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=yQ(l,this.bounds.from)}else{let l=e.observer.selectionRange,h=n&&n.node==l.focusNode&&n.offset==l.focusOffset||!hm(e.contentDOM,l.focusNode)?o.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=a&&a.node==l.anchorNode&&a.offset==l.anchorOffset||!hm(e.contentDOM,l.anchorNode)?o.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),d=e.viewport;if((Ve.ios||Ve.chrome)&&h!=u&&Math.min(h,u)<=o.main.from&&Math.max(h,u)>=o.main.to&&(d.from>0||d.to<e.state.doc.length)){let f=Math.min(h,u),p=Math.max(h,u),v=d.from-f,b=d.to-p;(v==0||v==1||f==0)&&(b==0||b==-1||p==e.state.doc.length)&&(h=0,u=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(fe.range(u,h));else if(e.lineWrapping&&u==h&&!(o.main.empty&&o.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(h,-1),p=0;f&&(p=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=fe.create([fe.cursor(h,p)])}else this.newSel=fe.single(u,h)}}}function u1(s,e,t,r){if(s.isComposite()){let i=-1,n=-1,a=-1,o=-1;for(let l=0,h=r,u=r;l<s.children.length;l++){let d=s.children[l],f=h+d.length;if(h<e&&f>t)return u1(d,e,t,h);if(f>=e&&i==-1&&(i=l,n=h),h>t&&d.dom.parentNode==s.dom){a=l,o=u;break}u=f,h=f+d.breakAfter}return{from:n,to:o<0?r+s.length:o,startDOM:(i?s.children[i-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:a<s.children.length&&a>=0?s.children[a].dom:null}}else return s.isText()?{from:r,to:r+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function f1(s,e){let t,{newSel:r}=e,{state:i}=s,n=i.selection.main,a=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,h=n.from,u=null;(a===8||Ve.android&&e.text.length<l-o)&&(h=n.to,u="end");let d=i.doc.sliceString(o,l,Oo),f,p;!n.empty&&n.from>=o&&n.to<=l&&(e.typeOver||d!=e.text)&&d.slice(0,n.from-o)==e.text.slice(0,n.from-o)&&d.slice(n.to-o)==e.text.slice(f=e.text.length-(d.length-(n.to-o)))?t={from:n.from,to:n.to,insert:It.of(e.text.slice(n.from-o,f).split(Oo))}:(p=m1(d,e.text,h-o,u))&&(Ve.chrome&&a==13&&p.toB==p.from+2&&e.text.slice(p.from,p.toB)==Oo+Oo&&p.toB--,t={from:o+p.from,to:o+p.toA,insert:It.of(e.text.slice(p.from,p.toB).split(Oo))})}else r&&(!s.hasFocus&&i.facet(Oi)||Sh(r,n))&&(r=null);if(!t&&!r)return!1;if((Ve.mac||Ve.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(r&&t.insert.length==2&&(r=fe.single(r.main.anchor-1,r.main.head-1)),t={from:t.from,to:t.to,insert:It.of([t.insert.toString().replace("."," ")])}):i.doc.lineAt(n.from).to<n.to&&s.docView.lineHasWidget(n.to)&&s.inputState.insertingTextAt>Date.now()-50?t={from:n.from,to:n.to,insert:i.toText(s.inputState.insertingText)}:Ve.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`
18
+ `&&s.lineWrapping&&(r&&(r=fe.single(r.main.anchor-1,r.main.head-1)),t={from:n.from,to:n.to,insert:It.of([" "])}),t)return kp(s,t,r,a);if(r&&!Sh(r,n)){let o=!1,l="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(o=!0),l=s.inputState.lastSelectionOrigin,l=="select.pointer"&&(r=d1(i.facet(_l).map(h=>h(s)),r))),s.dispatch({selection:r,scrollIntoView:o,userEvent:l}),!0}else return!1}function kp(s,e,t,r=-1){if(Ve.ios&&s.inputState.flushIOSKey(e))return!0;let i=s.state.selection.main;if(Ve.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&s.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Co(s.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.length<e.to-e.from&&e.to>i.head)&&Co(s.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Co(s.contentDOM,"Delete",46)))return!0;let n=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let a,o=()=>a||(a=bQ(s,e,t));return s.state.facet(Jy).some(l=>l(s,e.from,e.to,n,o))||s.dispatch(o()),!0}function bQ(s,e,t){let r,i=s.state,n=i.selection.main,a=-1;if(e.from==e.to&&e.from<n.from||e.from>n.to){let l=e.from<n.from?-1:1,h=l<0?n.from:n.to,u=qa(i.facet(_l).map(d=>d(s)),h,l);e.from==u&&(a=u)}if(a>-1)r={changes:e,selection:fe.cursor(e.from+e.insert.length,-1)};else if(e.from>=n.from&&e.to<=n.to&&e.to-e.from>=(n.to-n.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let l=n.from<e.from?i.sliceDoc(n.from,e.from):"",h=n.to>e.to?i.sliceDoc(e.to,n.to):"";r=i.replaceSelection(s.state.toText(l+e.insert.sliceString(0,void 0,s.state.lineBreak)+h))}else{let l=i.changes(e),h=t&&t.main.to<=l.newLength?t.main:void 0;if(i.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&e.to<=n.to+10&&e.to>=n.to-10){let u=s.state.sliceDoc(e.from,e.to),d,f=t&&h1(s,t.main.head);if(f){let v=e.insert.length-(e.to-e.from);d={from:f.from,to:f.to-v}}else d=s.state.doc.lineAt(n.head);let p=n.to-e.to;r=i.changeByRange(v=>{if(v.from==n.from&&v.to==n.to)return{changes:l,range:h||v.map(l)};let b=v.to-p,O=b-u.length;if(s.state.sliceDoc(O,b)!=u||b>=d.from&&O<=d.to)return{range:v};let g=i.changes({from:O,to:b,insert:e.insert}),m=v.to-n.to;return{changes:g,range:h?fe.range(Math.max(0,h.anchor+m),Math.max(0,h.head+m)):v.map(g)}})}else r={changes:l,selection:h&&i.selection.replaceRange(h)}}let o="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,o+=".compose",s.inputState.compositionFirstChange&&(o+=".start",s.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:o,scrollIntoView:!0})}function m1(s,e,t,r){let i=Math.min(s.length,e.length),n=0;for(;n<i&&s.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==i&&s.length==e.length)return null;let a=s.length,o=e.length;for(;a>0&&o>0&&s.charCodeAt(a-1)==e.charCodeAt(o-1);)a--,o--;if(r=="end"){let l=Math.max(0,n-Math.min(a,o));t-=a+l-n}if(a<n&&s.length<e.length){let l=t<=n&&t>=a?n-t:0;n-=l,o=n+(o-a),a=n}else if(o<n){let l=t<=n&&t>=o?n-t:0;n-=l,a=n+(a-o),o=n}return{from:n,toA:a,toB:o}}function vQ(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:n}=s.observer.selectionRange;return t&&(e.push(new V0(t,r)),(i!=t||n!=r)&&e.push(new V0(i,n))),e}function yQ(s,e){if(s.length==0)return null;let t=s[0].pos,r=s.length==2?s[1].pos:t;return t>-1&&r>-1?fe.single(t+e,r+e):null}function Sh(s,e){return e.head==s.main.head&&e.anchor==s.main.anchor}class SQ{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ve.safari&&e.contentDOM.addEventListener("input",()=>null),Ve.gecko&&DQ(e.contentDOM.ownerDocument)}handleEvent(e){!jQ(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,t);for(let i of r.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_Q(e),r=this.handlers,i=this.view.contentDOM;for(let n in t)if(n!="scroll"){let a=!t[n].handlers.length,o=r[n];o&&a!=!o.handlers.length&&(i.removeEventListener(n,this.handleEvent),o=null),o||i.addEventListener(n,this.handleEvent,{passive:a})}for(let n in r)n!="scroll"&&!t[n]&&i.removeEventListener(n,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&g1.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ve.android&&Ve.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Ve.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(p1.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||kQ.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&Ve.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&wQ(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Co(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ve.safari&&!Ve.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function wQ(s){return s.visualViewport?s.visualViewport.height*s.visualViewport.scale/s.document.documentElement.clientHeight<.85:!1}function F0(s,e){return(t,r)=>{try{return e.call(s,r,t)}catch(i){tr(t.state,i)}}}function _Q(s){let e=Object.create(null);function t(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of s){let i=r.spec,n=i&&i.plugin.domEventHandlers,a=i&&i.plugin.domEventObservers;if(n)for(let o in n){let l=n[o];l&&t(o).handlers.push(F0(r.value,l))}if(a)for(let o in a){let l=a[o];l&&t(o).observers.push(F0(r.value,l))}}for(let r in Lr)t(r).handlers.push(Lr[r]);for(let r in Us)t(r).observers.push(Us[r]);return e}const p1=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],kQ="dthko",g1=[16,17,18,20,91,92,224,225],yc=6;function Sc(s){return Math.max(0,s)*.7+8}function CQ(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class PQ{constructor(e,t,r,i){this.view=e,this.startEvent=t,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Iy(e.contentDOM),this.atoms=e.state.facet(_l).map(a=>a(e));let n=e.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet($t.allowMultipleSelections)&&TQ(e,t),this.dragging=$Q(e,t)&&b1(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&CQ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,r=0,i=0,n=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:n,bottom:o}=this.scrollParents.y.getBoundingClientRect());let l=_p(this.view);e.clientX-l.left<=i+yc?t=-Sc(i-e.clientX):e.clientX+l.right>=a-yc&&(t=Sc(e.clientX-a)),e.clientY-l.top<=n+yc?r=-Sc(n-e.clientY):e.clientY+l.bottom>=o-yc&&(r=Sc(e.clientY-o)),this.setScrollSpeed(t,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,r=d1(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function TQ(s,e){let t=s.state.facet(Hy);return t.length?t[0](e):Ve.mac?e.metaKey:e.ctrlKey}function QQ(s,e){let t=s.state.facet(Yy);return t.length?t[0](e):Ve.mac?!e.altKey:!e.ctrlKey}function $Q(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let r=Ja(s.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let n=0;n<i.length;n++){let a=i[n];if(a.left<=e.clientX&&a.right>=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function jQ(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,r;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(r=rs.get(t))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Lr=Object.create(null),Us=Object.create(null),O1=Ve.ie&&Ve.ie_version<15||Ve.ios&&Ve.webkit_version<604;function RQ(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),x1(s,t.value)},50)}function ed(s,e,t){for(let r of s.facet(e))t=r(t,s);return t}function x1(s,e){e=ed(s.state,vp,e);let{state:t}=s,r,i=1,n=t.toText(e),a=n.lines==t.selection.ranges.length;if(xm!=null&&t.selection.ranges.every(l=>l.empty)&&xm==n.toString()){let l=-1;r=t.changeByRange(h=>{let u=t.doc.lineAt(h.from);if(u.from==l)return{range:h};l=u.from;let d=t.toText((a?n.line(i++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:d},range:fe.cursor(h.from+d.length)}})}else a?r=t.changeByRange(l=>{let h=n.line(i++);return{changes:{from:l.from,to:l.to,insert:h.text},range:fe.cursor(l.from+h.length)}}):r=t.replaceSelection(n);s.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Us.scroll=s=>{let e=s.inputState;e.lastScrollTop=s.scrollDOM.scrollTop,e.lastScrollLeft=s.scrollDOM.scrollLeft,Ve.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Us.wheel=Us.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};Lr.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);Us.touchstart=(s,e)=>{let t=s.inputState,r=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),r&&(t.lastTouchX=r.clientX,t.lastTouchY=r.clientY),t.setSelectionOrigin("select.pointer")};Us.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};Us.touchend=(s,e)=>{s.inputState.touchActive=!1};Lr.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let r of s.state.facet(Gy))if(t=r(s,e),t)break;if(!t&&e.button==0&&(t=AQ(s,e)),t){let r=!s.hasFocus;s.inputState.startMouseSelection(new PQ(s,e,t,r)),r&&s.observer.ignore(()=>{By(s.contentDOM);let n=s.root.activeElement;n&&!n.contains(s.contentDOM)&&n.blur()});let i=s.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function U0(s,e,t,r){if(r==1)return fe.cursor(e,t);if(r==2)return cQ(s.state,e,t);{let i=s.docView.lineAt(e,t),n=s.state.doc.lineAt(i?i.posAtEnd:e),a=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<s.state.doc.length&&o==n.to&&o++,fe.undirectionalRange(a,o)}}const EQ=Ve.ie&&Ve.ie_version<=11;let H0=null,Y0=0,G0=0;function b1(s){if(!EQ)return s.detail;let e=H0,t=G0;return H0=s,G0=Date.now(),Y0=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(Y0+1)%3:1}function AQ(s,e){let t=s.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=b1(e),i=s.state.selection;return{update(n){n.docChanged&&(t.pos=n.changes.mapPos(t.pos),i=i.map(n.changes))},get(n,a,o){let l=s.posAndSideAtCoords({x:n.clientX,y:n.clientY},!1),h,u=U0(s,l.pos,l.assoc,r);if(t.pos!=l.pos&&!a){let d=U0(s,t.pos,t.assoc,r),f=Math.min(d.from,u.from),p=Math.max(d.to,u.to);u=f<u.from?fe.range(f,p,u.assoc):fe.range(p,f,u.assoc)}return a?i.replaceRange(i.main.extend(u.from,u.to,u.assoc)):o&&r==1&&i.ranges.length>1&&(h=MQ(i,l.pos))?h:o?i.addRange(u):fe.create([u])}}}function MQ(s,e){for(let t=0;t<s.ranges.length;t++){let{from:r,to:i}=s.ranges[t];if(r<=e&&i>=e)return fe.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}Lr.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let i=s.docView.tile.nearest(e.target);if(i&&i.isWidget()){let n=i.posAtStart,a=n+i.length;(n>=t.to||a<=t.from)&&(t=fe.undirectionalRange(n,a))}}let{inputState:r}=s;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ed(s.state,yp,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Lr.dragend=s=>(s.inputState.draggedContent=null,!1);function K0(s,e,t,r){if(t=ed(s.state,vp,t),!t)return;let i=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:n}=s.inputState,a=r&&n&&QQ(s,e)?{from:n.from,to:n.to}:null,o={from:i,insert:t},l=s.state.changes(a?[a,o]:o);s.focus(),s.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:a?"move.drop":"input.drop"}),s.inputState.draggedContent=null}Lr.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let r=Array(t.length),i=0,n=()=>{++i==t.length&&K0(s,e,r.filter(a=>a!=null).join(s.state.lineBreak),!1)};for(let a=0;a<t.length;a++){let o=new FileReader;o.onerror=n,o.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(o.result)||(r[a]=o.result),n()},o.readAsText(t[a])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return K0(s,e,r,!0),!0}return!1};Lr.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=O1?null:e.clipboardData;return t?(x1(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(RQ(s),!1)};function LQ(s,e){let t=s.dom.parentNode;if(!t)return;let r=t.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),s.focus()},50)}function NQ(s){let e=[],t=[],r=!1;for(let i of s.selection.ranges)i.empty||(e.push(s.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:n}of s.selection.ranges){let a=s.doc.lineAt(n);a.number>i&&(e.push(a.text),t.push({from:a.from,to:Math.min(s.doc.length,a.to+1)})),i=a.number}r=!0}return{text:ed(s,yp,e.join(s.lineBreak)),ranges:t,linewise:r}}let xm=null;Lr.copy=Lr.cut=(s,e)=>{if(!Wa(s.contentDOM,s.observer.selectionRange))return!1;let{text:t,ranges:r,linewise:i}=NQ(s.state);if(!t&&!i)return!1;xm=i?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let n=O1?null:e.clipboardData;return n?(n.clearData(),n.setData("text/plain",t),!0):(LQ(s,t),!1)};const v1=ri.define();function y1(s,e){let t=[];for(let r of s.facet(e1)){let i=r(s,e);i&&t.push(i)}return t.length?s.update({effects:t,annotations:v1.of(!0)}):null}function S1(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=y1(s.state,e);t?s.dispatch(t):s.update([])}},10)}Us.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),S1(s)};Us.blur=s=>{s.observer.clearSelectionRange(),S1(s)};Us.compositionstart=Us.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};Us.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,Ve.chrome&&Ve.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};Us.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};Lr.beforeinput=(s,e)=>{var t,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(s.inputState.insertingText=e.data,s.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&s.observer.editContext){let n=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(n&&a.length){let o=a[0],l=s.posAtDOM(o.startContainer,o.startOffset),h=s.posAtDOM(o.endContainer,o.endOffset);return kp(s,{from:l,to:h,insert:s.state.toText(n)},null),!0}}let i;if(Ve.chrome&&Ve.android&&(i=p1.find(n=>n.inputType==e.inputType))&&(s.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let n=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>n+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return Ve.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),Ve.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>Us.compositionend(s,e),20),!1};const J0=new Set;function DQ(s){J0.has(s)||(J0.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const ex=["pre-wrap","normal","pre-line","break-spaces"];let Lo=!1;function tx(){Lo=!1}class IQ{constructor(e){this.lineWrapping=e,this.doc=It.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let r=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((t-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ex.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let r=0;r<e.length;r++){let i=e[r];i<0?r++:this.heightSamples[Math.floor(i*10)]||(t=!0,this.heightSamples[Math.floor(i*10)]=!0)}return t}refresh(e,t,r,i,n,a){let o=ex.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=r,this.textHeight=i,this.lineLength=n,l){this.heightSamples={};for(let h=0;h<a.length;h++){let u=a[h];u<0?h++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class BQ{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Er{constructor(e,t,r,i,n){this.from=e,this.length=t,this.top=r,this.height=i,this._content=n}get type(){return typeof this._content=="number"?Qs.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Vn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Er(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Gt=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(Gt||(Gt={}));const Gc=.001;class Fs{constructor(e,t,r=2){this.length=e,this.height=t,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Gc&&(Lo=!0),this.height=e)}replace(e,t,r){return Fs.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,r,i){let n=this,a=r.doc;for(let o=i.length-1;o>=0;o--){let{fromA:l,toA:h,fromB:u,toB:d}=i[o],f=n.lineAt(l,Gt.ByPosNoHeight,r.setDoc(t),0,0),p=f.to>=h?f:n.lineAt(h,Gt.ByPosNoHeight,r,0,0);for(d+=p.to-h,h=p.to;o>0&&f.from<=i[o-1].toA;)l=i[o-1].fromA,u=i[o-1].fromB,o--,l<f.from&&(f=n.lineAt(l,Gt.ByPosNoHeight,r,0,0));u+=f.from-l,l=f.from;let v=Cp.build(r.setDoc(a),e,u,d);n=wh(n,n.replace(l,h,v))}return n.updateHeight(r,0)}static empty(){return new ur(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,r=e.length,i=0,n=0;for(;;)if(t==r)if(i>n*2){let o=e[t-1];o.break?e.splice(--t,1,o.left,null,o.right):e.splice(--t,1,o.left,o.right),r+=1+o.break,i-=o.size}else if(n>i*2){let o=e[r];o.break?e.splice(r,1,o.left,null,o.right):e.splice(r,1,o.left,o.right),r+=2+o.break,n-=o.size}else break;else if(i<n){let o=e[t++];o&&(i+=o.size)}else{let o=e[--r];o&&(n+=o.size)}let a=0;return e[t-1]==null?(a=1,t--):e[t]==null&&(a=1,r++),new XQ(Fs.of(e.slice(0,t)),a,Fs.of(e.slice(r)))}}function wh(s,e){return s==e?s:(s.constructor!=e.constructor&&(Lo=!0),e)}Fs.prototype.size=1;const WQ=ht.replace({});class w1 extends Fs{constructor(e,t,r){super(e,t),this.deco=r,this.spaceAbove=0}mainBlock(e,t){return new Er(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,r,i){return this.spaceAbove&&e<r+this.spaceAbove?new Er(i,0,r,this.spaceAbove,WQ):this.mainBlock(r,i)}lineAt(e,t,r,i,n){let a=this.mainBlock(i,n);return this.spaceAbove?this.blockAt(0,r,i,n).join(a):a}forEachLine(e,t,r,i,n,a){e<=n+this.length&&t>=n&&a(this.lineAt(0,Gt.ByPos,r,i,n))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ur extends w1{constructor(e,t,r){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,t){return new Er(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,r){let i=r[0];return r.length==1&&(i instanceof ur||i instanceof ks&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ks?i=new ur(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Fs.of(r)}updateHeight(e,t=0,r=!1,i){return i&&i.from<=t&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ks extends Fs{constructor(e){super(e,0)}heightMetrics(e,t){let r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,n=i-r+1,a,o=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*n);a=l/n,this.length>n+1&&(o=(this.height-l)/(this.length-n-1))}else a=this.height/n;return{firstLine:r,lastLine:i,perLine:a,perChar:o}}blockAt(e,t,r,i){let{firstLine:n,lastLine:a,perLine:o,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let h=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-r)/this.height))*this.length)),u=t.doc.lineAt(h),d=o+u.length*l,f=Math.max(r,e-d/2);return new Er(u.from,u.length,f,d,0)}else{let h=Math.max(0,Math.min(a-n,Math.floor((e-r)/o))),{from:u,length:d}=t.doc.line(n+h);return new Er(u,d,r+o*h,o,0)}}lineAt(e,t,r,i,n){if(t==Gt.ByHeight)return this.blockAt(e,r,i,n);if(t==Gt.ByPosNoHeight){let{from:p,to:v}=r.doc.lineAt(e);return new Er(p,v-p,0,0,0)}let{firstLine:a,perLine:o,perChar:l}=this.heightMetrics(r,n),h=r.doc.lineAt(e),u=o+h.length*l,d=h.number-a,f=i+o*d+l*(h.from-n-d);return new Er(h.from,h.length,Math.max(i,Math.min(f,i+this.height-u)),u,0)}forEachLine(e,t,r,i,n,a){e=Math.max(e,n),t=Math.min(t,n+this.length);let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(r,n);for(let u=e,d=i;u<=t;){let f=r.doc.lineAt(u);if(u==e){let v=f.number-o;d+=l*v+h*(e-n-v)}let p=l+h*f.length;a(new Er(f.from,f.length,d,p,0)),d+=p,u=f.to+1}}replace(e,t,r){let i=this.length-t;if(i>0){let n=r[r.length-1];n instanceof ks?r[r.length-1]=new ks(n.length+i):r.push(null,new ks(i-1))}if(e>0){let n=r[0];n instanceof ks?r[0]=new ks(e+n.length):r.unshift(new ks(e-1),null)}return Fs.of(r)}decomposeLeft(e,t){t.push(new ks(e-1),null)}decomposeRight(e,t){t.push(null,new ks(this.length-e-1))}updateHeight(e,t=0,r=!1,i){let n=t+this.length;if(i&&i.from<=t+this.length&&i.more){let a=[],o=Math.max(t,i.from),l=-1;for(i.from>t&&a.push(new ks(i.from-t-1).updateHeight(e,t));o<=n&&i.more;){let u=e.doc.lineAt(o).length;a.length&&a.push(null);let d=i.heights[i.index++],f=0;d<0&&(f=-d,d=i.heights[i.index++]),l==-1?l=d:Math.abs(d-l)>=Gc&&(l=-2);let p=new ur(u,d,f);p.outdated=!1,a.push(p),o+=u+1}o<=n&&a.push(null,new ks(n-o).updateHeight(e,o));let h=Fs.of(a);return(l<0||Math.abs(h.height-this.height)>=Gc||Math.abs(l-this.heightMetrics(e,t).perLine)>=Gc)&&(Lo=!0),wh(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class XQ extends Fs{constructor(e,t,r){super(e.length+t+r.length,e.height+r.height,t|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,t,r,i){let n=r+this.left.height;return e<n?this.left.blockAt(e,t,r,i):this.right.blockAt(e,t,n,i+this.left.length+this.break)}lineAt(e,t,r,i,n){let a=i+this.left.height,o=n+this.left.length+this.break,l=t==Gt.ByHeight?e<a:e<o,h=l?this.left.lineAt(e,t,r,i,n):this.right.lineAt(e,t,r,a,o);if(this.break||(l?h.to<o:h.from>o))return h;let u=t==Gt.ByPosNoHeight?Gt.ByPosNoHeight:Gt.ByPos;return l?h.join(this.right.lineAt(o,u,r,a,o)):this.left.lineAt(o,u,r,i,n).join(h)}forEachLine(e,t,r,i,n,a){let o=i+this.left.height,l=n+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,r,i,n,a),t>=l&&this.right.forEachLine(e,t,r,o,l,a);else{let h=this.lineAt(l,Gt.ByPos,r,i,n);e<h.from&&this.left.forEachLine(e,h.from-1,r,i,n,a),h.to>=e&&h.from<=t&&a(h),t>h.to&&this.right.forEachLine(h.to+1,t,r,o,l,a)}}replace(e,t,r){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,r),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,r));let n=[];e>0&&this.decomposeLeft(e,n);let a=n.length;for(let o of r)n.push(o);if(e>0&&sx(n,a-1),t<this.length){let o=n.length;this.decomposeRight(t,n),sx(n,o)}return Fs.of(n)}decomposeLeft(e,t){let r=this.left.length;if(e<=r)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(r++,e>=r&&t.push(null)),e>r&&this.right.decomposeLeft(e-r,t)}decomposeRight(e,t){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<r&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Fs.of(this.break?[e,null,t]:[e,t]):(this.left=wh(this.left,e),this.right=wh(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,r=!1,i){let{left:n,right:a}=this,o=t+n.length+this.break,l=null;return i&&i.from<=t+n.length&&i.more?l=n=n.updateHeight(e,t,r,i):n.updateHeight(e,t,r),i&&i.from<=o+a.length&&i.more?l=a=a.updateHeight(e,o,r,i):a.updateHeight(e,o,r),l?this.balanced(n,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function sx(s,e){let t,r;s[e]==null&&(t=s[e-1])instanceof ks&&(r=s[e+1])instanceof ks&&s.splice(e-1,3,new ks(t.length+1+r.length))}const zQ=5;class Cp{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let r=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof ur?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new ur(r-this.pos,-1,0)),this.writtenTo=r,t>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,r){if(e<t||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,n=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let a=t-e;r.block?this.addBlock(new w1(a,i,r)):(a||n||i>=zQ)&&this.addLineDeco(i,n,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ur(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let r=new ks(t-e);return this.oracle.doc.lineAt(e).to==t&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ur)return e;let t=new ur(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+r}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ur)&&!this.isCovered?this.nodes.push(new ur(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=e;for(let i of this.nodes)i instanceof ur&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,t,r,i){let n=new Cp(r,e);return Qt.spans(t,r,i,n,0),n.finish(r)}}function qQ(s,e,t){let r=new ZQ;return Qt.compare(s,e,t,r,0),r.changes}class ZQ{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,r,i){(e<t||r&&r.heightRelevant||i&&i.heightRelevant)&&ko(e,t,this.changes,5)}}function VQ(s,e){let t=s.getBoundingClientRect(),r=s.ownerDocument,i=r.defaultView||window,n=Math.max(0,t.left),a=Math.min(i.innerWidth,t.right),o=Math.max(0,t.top),l=Math.min(i.innerHeight,t.bottom);for(let h=s.parentNode;h&&h!=r.body;)if(h.nodeType==1){let u=h,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let f=u.getBoundingClientRect();n=Math.max(n,f.left),a=Math.min(a,f.right),o=Math.max(o,f.top),l=Math.min(h==s.parentNode?i.innerHeight:l,f.bottom)}h=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:n-t.left,right:Math.max(n,a)-t.left,top:o-(t.top+e),bottom:Math.max(o,l)-(t.top+e)}}function FQ(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function UQ(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ru{constructor(e,t,r,i){this.from=e,this.to=t,this.size=r,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++){let i=e[r],n=t[r];if(i.from!=n.from||i.to!=n.to||i.size!=n.size)return!1}return!0}draw(e,t){return ht.replace({widget:new HQ(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class HQ extends Nr{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class rx{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ix,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Yt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let r=t.facet(Sp).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new IQ(r),this.stateDeco=nx(t),this.heightMap=Fs.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle.setDoc(t.doc),[new Sr(0,0,0,t.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ht.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let r=0;r<=1;r++){let i=r?t.head:t.anchor;if(!e.some(({from:n,to:a})=>i>=n&&i<=a)){let{from:n,to:a}=this.lineBlockAt(i);e.push(new wc(n,a))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?ix:new Pp(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(La(e,this.scaler))})}update(e,t=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=nx(this.state);let i=e.changedRanges,n=Sr.extendWithRanges(i,qQ(r,this.stateDeco,e?e.changes:fs.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);tx(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=a||Lo)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let l=n.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let h=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(s1)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,r=window.getComputedStyle(t),i=this.heightOracle,n=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Yt.RTL:Yt.LTR;let a=this.heightOracle.mustRefreshForWrapping(n)||this.mustMeasureContent==="refresh",o=t.getBoundingClientRect(),l=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let h=0,u=0;if(o.width&&o.height){let{scaleX:k,scaleY:C}=Dy(t,o);(k>.005&&Math.abs(this.scaleX-k)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=k,this.scaleY=C,h|=16,a=l=!0)}let d=(parseInt(r.paddingTop)||0)*this.scaleY,f=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,this.paddingBottom=f,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let p=Iy(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let v=this.getScrollOffset();this.scrollOffset!=v&&(this.scrollAnchorHeight=-1,this.scrollOffset=v),this.scrolledToBottom=Wy(this.scrollParent||e.win);let b=(this.printing?UQ:VQ)(t,this.paddingTop),O=b.top-this.pixelViewport.top,g=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget&&!FQ(e.dom))return 0;let x=o.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(k)&&(a=!0),a||i.lineWrapping&&Math.abs(x-this.contentDOMWidth)>i.charWidth){let{lineHeight:C,charWidth:P,textHeight:_}=e.docView.measureTextSize();a=C>0&&i.refresh(n,C,P,_,Math.max(5,x/P),k),a&&(e.docView.minWidth=0,h|=16)}O>0&&g>0?u=Math.max(O,g):O<0&&g<0&&(u=Math.min(O,g)),tx();for(let C of this.viewports){let P=C.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(C);this.heightMap=(a?Fs.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle,[new Sr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,a,new BQ(C.from,P))}Lo&&(h|=2)}let y=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),h|=this.updateForViewport()),(h&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,n=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,l=new wc(i.lineAt(a-r*1e3,Gt.ByHeight,n,0,0).from,i.lineAt(o+(1-r)*1e3,Gt.ByHeight,n,0,0).to);if(t){let{head:h}=t.range;if(h<l.from||h>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=i.lineAt(h,Gt.ByPos,n,0,0),f;t.y=="center"?f=(d.top+d.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&h<l.from?f=d.top:f=d.bottom-u,l=new wc(i.lineAt(f-1e3/2,Gt.ByHeight,n,0,0).from,i.lineAt(f+u+1e3/2,Gt.ByHeight,n,0,0).to)}}return l}mapViewport(e,t){let r=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new wc(this.heightMap.lineAt(r,Gt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,Gt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},r=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,Gt.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(t,Gt.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||i<=a-Math.max(10,Math.min(-r,250)))&&(t==this.state.doc.length||n>=o+Math.max(10,Math.min(r,250)))&&i>a-2*1e3&&n<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let r=[];for(let i of e)t.touchesRange(i.from,i.to)||r.push(new Ru(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return r}ensureLineGaps(e,t){let r=this.heightOracle.lineWrapping,i=r?1e4:2e3,n=i>>1,a=i<<1;if(this.defaultTextDirection!=Yt.LTR&&!r)return[];let o=[],l=(u,d,f,p)=>{if(d-u<n)return;let v=this.state.selection.main,b=[v.from];v.empty||b.push(v.to);for(let g of b)if(g>u&&g<d){l(u,g-10,f,p),l(g+10,d,f,p);return}let O=GQ(e,g=>g.from>=f.from&&g.to<=f.to&&Math.abs(g.from-u)<n&&Math.abs(g.to-d)<n&&!b.some(m=>g.from<m&&g.to>m));if(!O){if(d<f.to&&t&&r&&t.visibleRanges.some(x=>x.from<=d&&x.to>=d)){let x=t.moveToLineBoundary(fe.cursor(d),!1,!0).head;x>u&&(d=x)}let g=this.gapSize(f,u,d,p),m=r||g<2e6?g:2e6;O=new Ru(u,d,g,m)}o.push(O)},h=u=>{if(u.length<a||u.type!=Qs.Text)return;let d=YQ(u.from,u.to,this.stateDeco);if(d.total<a)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,p,v;if(r){let b=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,O,g;if(f!=null){let m=kc(d,f),x=((this.visibleBottom-this.visibleTop)/2+b)/u.height;O=m-x,g=m+x}else O=(this.visibleTop-u.top-b)/u.height,g=(this.visibleBottom-u.top+b)/u.height;p=_c(d,O),v=_c(d,g)}else{let b=d.total*this.heightOracle.charWidth,O=i*this.heightOracle.charWidth,g=0;if(b>2e6)for(let C of e)C.from>=u.from&&C.from<u.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=C.size-C.displaySize);let m=this.pixelViewport.left+g,x=this.pixelViewport.right+g,y,k;if(f!=null){let C=kc(d,f),P=((x-m)/2+O)/b;y=C-P,k=C+P}else y=(m-O)/b,k=(x+O)/b;p=_c(d,y),v=_c(d,k)}p>u.from&&l(u.from,p,u,d),v<u.to&&l(v,u.to,u,d)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(h):h(u);return o}gapSize(e,t,r,i){let n=kc(i,r)-kc(i,t);return this.heightOracle.lineWrapping?e.height*n:i.total*this.heightOracle.charWidth*n}updateLineGaps(e){Ru.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ht.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let r=[];Qt.spans(t,this.viewport.from,this.viewport.to,{span(n,a){r.push({from:n,to:a})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let n=0;n<r.length&&!(i&8);n++){let a=this.visibleRanges[n],o=r[n];(a.from!=o.from||a.to!=o.to)&&(i|=4,e&&e.mapPos(a.from,-1)==o.from&&e.mapPos(a.to,1)==o.to||(i|=8))}return this.visibleRanges=r,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||La(this.heightMap.lineAt(e,Gt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||La(this.heightMap.lineAt(this.scaler.fromDOM(e),Gt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return La(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,t){this.from=e,this.to=t}}function YQ(s,e,t){let r=[],i=s,n=0;return Qt.spans(t,s,e,{span(){},point(a,o){a>i&&(r.push({from:i,to:a}),n+=a-i),i=o}},20),i<e&&(r.push({from:i,to:e}),n+=e-i),{total:n,ranges:r}}function _c({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let r=Math.floor(s*t);for(let i=0;;i++){let{from:n,to:a}=e[i],o=a-n;if(r<=o)return n+r;r-=o}}function kc(s,e){let t=0;for(let{from:r,to:i}of s.ranges){if(e<=i){t+=e-r;break}t+=i-r}return t/s.total}function GQ(s,e){for(let t of s)if(e(t))return t}const ix={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function nx(s){let e=s.facet(Gh).filter(r=>typeof r!="function"),t=s.facet(wp).filter(r=>typeof r!="function");return t.length&&e.push(Qt.join(t)),e}class Pp{constructor(e,t,r){let i=0,n=0,a=0;this.viewports=r.map(({from:o,to:l})=>{let h=t.lineAt(o,Gt.ByPos,e,0,0).top,u=t.lineAt(l,Gt.ByPos,e,0,0).bottom;return i+=u-h,{from:o,to:l,top:h,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let o of this.viewports)o.domTop=a+(o.top-n)*this.scale,a=o.domBottom=o.domTop+(o.bottom-o.top),n=o.bottom}toDOM(e){for(let t=0,r=0,i=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.top)return i+(e-r)*this.scale;if(e<=n.bottom)return n.domTop+(e-n.top);r=n.bottom,i=n.domBottom}}fromDOM(e){for(let t=0,r=0,i=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.domTop)return r+(e-i)/this.scale;if(e<=n.domBottom)return n.top+(e-n.domTop);r=n.bottom,i=n.domBottom}}eq(e){return e instanceof Pp?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,r)=>t.from==e.viewports[r].from&&t.to==e.viewports[r].to):!1}}function La(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),r=e.toDOM(s.bottom);return new Er(s.from,s.length,t,r-t,Array.isArray(s._content)?s._content.map(i=>La(i,e)):s._content)}const Cc=Ge.define({combine:s=>s.join(" ")}),bm=Ge.define({combine:s=>s.indexOf(!0)>-1}),vm=Ki.newName(),_1=Ki.newName(),k1=Ki.newName(),C1={"&light":"."+_1,"&dark":"."+k1};function ym(s,e,t){return new Ki(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return s;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):s+" "+r}})}const KQ=ym("."+vm,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},C1),JQ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Eu=Ve.ie&&Ve.ie_version<=11;class e5{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new QT,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let r of t)this.queue.push(r);(Ve.ie&&Ve.ie_version<=11||Ve.ios&&e.composing)&&t.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ve.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ve.chrome&&Ve.chrome_version<126)&&(this.editContext=new s5(e),e.state.facet(Oi)&&(e.contentDOM.editContext=this.editContext.editContext)),Eu&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,r)=>t!=e[r]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Oi)?r.root.activeElement!=this.dom:!Wa(this.dom,i))return;let n=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(n&&n.isWidget()&&n.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Ve.ie&&Ve.ie_version<=11||Ve.android&&Ve.chrome)&&!r.state.selection.main.empty&&i.focusNode&&za(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ja(e.root);if(!t)return!1;let r=Ve.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&t5(this.view,t)||t;if(!r||this.selectionRange.eq(r))return!1;let i=Wa(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&jT(this.dom,r)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(r),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let r=this.dom;r;)if(r.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==r?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);for(let r of this.scrollTargets=t)r.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,JQ),Eu&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Eu&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var r;if(!this.delayedAndroidKey){let i=()=>{let n=this.delayedAndroidKey;n&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=n.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&n.force&&Co(this.dom,n.key,n.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((r=this.delayedAndroidKey)===null||r===void 0)&&r.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,r=-1,i=!1;for(let n of e){let a=this.readMutation(n);a&&(a.typeOver&&(i=!0),t==-1?{from:t,to:r}=a:(t=Math.min(a.from,t),r=Math.max(a.to,r)))}return{from:t,to:r,typeOver:i}}readChange(){let{from:e,to:t,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Wa(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new xQ(this.view,e,t,r);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let r=this.view.state,i=f1(this.view,t);return this.view.state==r&&(t.domChanged||t.newSel&&!Sh(this.view.state.selection,t.newSel.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let r=ox(t,e.previousSibling||e.target.previousSibling,-1),i=ox(t,e.nextSibling||e.target.nextSibling,1);return{from:r?t.posAfter(r):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Oi)!=e.state.facet(Oi)&&(e.view.contentDOM.editContext=e.state.facet(Oi)?this.editContext.editContext:null))}destroy(){var e,t,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ox(s,e,t){for(;e;){let r=rs.get(e);if(r&&r.parent==s)return r;let i=e.parentNode;e=i!=s.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function ax(s,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,n=e.endOffset,a=s.docView.domAtPos(s.state.selection.main.anchor,1);return za(a.node,a.offset,i,n)&&([t,r,i,n]=[i,n,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:n}}function t5(s,e){if(e.getComposedRanges){let i=e.getComposedRanges(s.root)[0];if(i)return ax(s,i)}let t=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",r,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",r,!0),t?ax(s,t):null}class s5{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:n,head:a}=i,o=this.toEditorPos(r.updateRangeStart),l=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:o,drifted:!1});let h=l-o>r.text.length;o==this.from&&n<this.from?o=n:l==this.to&&n>this.to&&(l=n);let u=m1(e.state.sliceDoc(o,l),r.text,(h?i.from:i.to)-o,h?"end":null);if(!u){let f=fe.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Sh(f,i)||e.dispatch({selection:f,userEvent:"select"});return}let d={from:u.from+o,to:u.toA+o,insert:It.of(r.text.slice(u.from,u.toB).split(`
19
+ `))};if((Ve.mac||Ve.android)&&d.from==a-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(d={from:o,to:l,insert:It.of([r.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let f=this.to-this.from+(d.to-d.from+d.insert.length);kp(e,d,fe.single(this.toEditorPos(r.selectionStart,f),this.toEditorPos(r.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from<d.to&&!d.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(t.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],n=null;for(let a=this.toEditorPos(r.rangeStart),o=this.toEditorPos(r.rangeEnd);a<o;a++){let l=e.coordsForChar(a);n=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||n||new DOMRect,i.push(n)}t.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let n of r.getTextFormats()){let a=n.underlineStyle,o=n.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(o)){let l=this.toEditorPos(n.rangeStart),h=this.toEditorPos(n.rangeEnd);if(l<h){let u=`text-decoration: underline ${/^[a-z]/.test(a)?a+" ":a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${/thin/i.test(o)?1:2}px`;i.push(ht.mark({attributes:{style:u}}).range(l,h))}}}e.dispatch({effects:i1.of(ht.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)t.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Ja(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((n,a,o,l,h)=>{if(r)return;let u=h.length-(a-n);if(i&&a>=i.to)if(i.from==n&&i.to==a&&i.insert.eq(h)){i=this.pendingContextChange=null,t+=u,this.to+=u;return}else i=null,this.revertPending(e.state);if(n+=t,a+=t,a<=this.from)this.from+=u,this.to+=u;else if(n<this.to){if(n<this.from||a>this.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(a),h.toString()),this.to+=u}t+=u}),i&&!r&&this.revertPending(e.state),!r}update(e){let t=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class We{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(n=>r(n,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||$T(e.parent)||document,this.viewState=new rx(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(vc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(vo).map(i=>new Pu(i));for(let i of this.plugins)i.update(this);this.observer=new e5(this),this.inputState=new SQ(this),this.inputState.ensureHandlers(this.plugins),this.docView=new q0(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ds?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,r=!1,i,n=this.state;for(let f of e){if(f.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=f.state}if(this.destroyed){this.viewState.state=n;return}let a=this.hasFocus,o=0,l=null;e.some(f=>f.annotation(v1))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=y1(n,a),l||(o=1));let h=this.observer.delayedAndroidKey,u=null;if(h?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(u=null)):this.observer.clear(),n.facet($t.phrases)!=this.state.facet($t.phrases))return this.setState(n);i=bh.create(this,n,e),i.flags|=o;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection,{x:v,y:b}=this.state.facet(We.cursorScrollMargin);d=new Po(p.empty?p:fe.cursor(p.head,p.head>p.anchor?-1:1),"nearest","nearest",b,v)}for(let p of f.effects)p.is(vc)&&(d=p.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=_h.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Cc)!=i.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(t||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let f of this.state.facet(mm))try{f(i)}catch(p){tr(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!f1(this,u)&&h.force&&Co(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new rx(this,e),this.plugins=e.facet(vo).map(r=>new Pu(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new q0(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(vo),r=e.state.facet(vo);if(t!=r){let i=[];for(let n of r){let a=t.indexOf(n);if(a<0)i.push(new Pu(n));else{let o=this.plugins[a];o.mustUpdate=e,i.push(o)}}for(let n of this.plugins)n.mustUpdate!=e&&n.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);t!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(r){tr(this.state,r,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:a}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(Wy(r||this.win))n=-1,a=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);n=p.from,a=p.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];l&4||([this.measureRequests,h]=[h,this.measureRequests]);let u=h.map(p=>{try{return p.read(this)}catch(v){return tr(this.state,v),lx}}),d=bh.create(this,this.state,[]),f=!1;d.flags|=l,t?t.flags|=l:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d),f&&this.docViewUpdate());for(let p=0;p<h.length;p++)if(u[p]!=lx)try{let v=h[p];v.write&&v.write(u[p],this)}catch(v){tr(this.state,v)}if(f&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let v=((n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)-a)/this.scaleY;if((v>1||v<-1)&&!(Ve.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+v,r?r.scrollTop+=v:this.win.scrollBy(0,v),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let o of this.state.facet(mm))o(t)}get themeClasses(){return vm+" "+(this.state.facet(bm)?k1:_1)+" "+this.state.facet(Cc)}updateAttrs(){let e=cx(this,n1,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Oi)?"true":"false",class:"cm-content",style:`${Ve.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),cx(this,Sp,t);let r=this.observer.ignore(()=>{let i=D0(this.contentDOM,this.contentAttrs,t),n=D0(this.dom,this.editorAttrs,e);return i||n});return this.editorAttrs=e,this.contentAttrs=t,r}showAnnouncements(e){let t=!0;for(let r of e)for(let i of r.effects)if(i.is(We.announce)){t&&(this.announceDOM.textContent=""),t=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(We.cspNonce);Ki.mount(this.root,this.styleModules.concat(KQ).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(r=>r.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,r){return ju(this,e,Z0(this,e,t,r))}moveByGroup(e,t){return ju(this,e,Z0(this,e,t,r=>uQ(this,e.head,r)))}visualLineSide(e,t){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),n=r[t?r.length-1:0];return fe.cursor(n.side(t,i)+e.from,n.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,r=!0){return dQ(this,e,t,r)}moveVertically(e,t,r){return ju(this,e,fQ(this,e,t,r))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let r=Om(this,e,t);return r&&r.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Om(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),n=i[Gr.find(i,e-r.from,-1,t)];return this.docView.coordsAt(e,t,n.dir==Yt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(t1)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>r5)return Fy(e.length);let t=this.textDirectionAt(e.from),r;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==t&&(n.fresh||Vy(n.isolates,r=W0(this,e))))return n.order;r||(r=W0(this,e));let i=DT(e.text,t,r);return this.bidiCache.push(new _h(e.from,e.to,t,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ve.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{By(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var r,i,n,a;return vc.of(new Po(typeof e=="number"?fe.cursor(e):e,(r=t.y)!==null&&r!==void 0?r:"nearest",(i=t.x)!==null&&i!==void 0?i:"nearest",(n=t.yMargin)!==null&&n!==void 0?n:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return vc.of(new Po(fe.cursor(r.from),"start","start",r.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return is.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return is.define(()=>({}),{eventObservers:e})}static theme(e,t){let r=Ki.newName(),i=[Cc.of(r),Ma.of(ym(`.${r}`,e))];return t&&t.dark&&i.push(bm.of(!0)),i}static baseTheme(e){return ki.lowest(Ma.of(ym("."+vm,e,C1)))}static findFromDOM(e){var t;let r=e.querySelector(".cm-content"),i=r&&rs.get(r)||rs.get(e);return((t=i?.root)===null||t===void 0?void 0:t.view)||null}}We.styleModule=Ma;We.inputHandler=Jy;We.clipboardInputFilter=vp;We.clipboardOutputFilter=yp;We.scrollHandler=r1;We.focusChangeEffect=e1;We.perLineTextDirection=t1;We.exceptionSink=Ky;We.updateListener=mm;We.editable=Oi;We.mouseSelectionStyle=Gy;We.dragMovesSelection=Yy;We.clickAddsSelectionRange=Hy;We.decorations=Gh;We.blockWrappers=o1;We.outerDecorations=wp;We.atomicRanges=_l;We.bidiIsolatedRanges=a1;We.cursorScrollMargin=Ge.define({combine:s=>{let e=5,t=5;for(let r of s)typeof r=="number"?e=t=r:{x:e,y:t}=r;return{x:e,y:t}}});We.scrollMargins=l1;We.darkTheme=bm;We.cspNonce=Ge.define({combine:s=>s.length?s[0]:""});We.contentAttributes=Sp;We.editorAttributes=n1;We.lineWrapping=We.contentAttributes.of({class:"cm-lineWrapping"});We.announce=xt.define();const r5=4096,lx={};class _h{constructor(e,t,r,i,n,a){this.from=e,this.to=t,this.dir=r,this.isolates=i,this.fresh=n,this.order=a}static update(e,t){if(t.empty&&!e.some(n=>n.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:Yt.LTR;for(let n=Math.max(0,e.length-10);n<e.length;n++){let a=e[n];a.dir==i&&!t.touchesRange(a.from,a.to)&&r.push(new _h(t.mapPos(a.from,1),t.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return r}}function cx(s,e,t){for(let r=s.state.facet(e),i=r.length-1;i>=0;i--){let n=r[i],a=typeof n=="function"?n(s):n;a&&Op(a,t)}return t}const i5=Ve.mac?"mac":Ve.windows?"win":Ve.linux?"linux":"key";function n5(s,e){const t=s.split(/-(?!$)/);let r=t[t.length-1];r=="Space"&&(r=" ");let i,n,a,o;for(let l=0;l<t.length-1;++l){const h=t[l];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))i=!0;else if(/^(c|ctrl|control)$/i.test(h))n=!0;else if(/^s(hift)?$/i.test(h))a=!0;else if(/^mod$/i.test(h))e=="mac"?o=!0:n=!0;else throw new Error("Unrecognized modifier name: "+h)}return i&&(r="Alt-"+r),n&&(r="Ctrl-"+r),o&&(r="Meta-"+r),a&&(r="Shift-"+r),r}function Pc(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const o5=ki.default(We.domEventHandlers({keydown(s,e){return T1(P1(e.state),s,e,"editor")}})),Zo=Ge.define({enables:o5}),hx=new WeakMap;function P1(s){let e=s.facet(Zo),t=hx.get(e);return t||hx.set(e,t=c5(e.reduce((r,i)=>r.concat(i),[]))),t}function a5(s,e,t){return T1(P1(s.state),e,s,t)}let Fi=null;const l5=4e3;function c5(s,e=i5){let t=Object.create(null),r=Object.create(null),i=(a,o)=>{let l=r[a];if(l==null)r[a]=o;else if(l!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},n=(a,o,l,h,u)=>{var d,f;let p=t[a]||(t[a]=Object.create(null)),v=o.split(/ (?!$)/).map(g=>n5(g,e));for(let g=1;g<v.length;g++){let m=v.slice(0,g).join(" ");i(m,!0),p[m]||(p[m]={preventDefault:!0,stopPropagation:!1,run:[x=>{let y=Fi={view:x,prefix:m,scope:a};return setTimeout(()=>{Fi==y&&(Fi=null)},l5),!0}]})}let b=v.join(" ");i(b,!1);let O=p[b]||(p[b]={preventDefault:!1,stopPropagation:!1,run:((f=(d=p._any)===null||d===void 0?void 0:d.run)===null||f===void 0?void 0:f.slice())||[]});l&&O.run.push(l),h&&(O.preventDefault=!0),u&&(O.stopPropagation=!0)};for(let a of s){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let h of o){let u=t[h]||(t[h]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=a;for(let f in u)u[f].run.push(p=>d(p,Sm))}let l=a[e]||a.key;if(l)for(let h of o)n(h,l,a.run,a.preventDefault,a.stopPropagation),a.shift&&n(h,"Shift-"+l,a.shift,a.preventDefault,a.stopPropagation)}return t}let Sm=null;function T1(s,e,t,r){Sm=e;let i=wT(e),n=Ks(i,0),a=Hr(n)==i.length&&i!=" ",o="",l=!1,h=!1,u=!1;Fi&&Fi.view==t&&Fi.scope==r&&(o=Fi.prefix+" ",g1.indexOf(e.keyCode)<0&&(h=!0,Fi=null));let d=new Set,f=O=>{if(O){for(let g of O.run)if(!d.has(g)&&(d.add(g),g(t)))return O.stopPropagation&&(u=!0),!0;O.preventDefault&&(O.stopPropagation&&(u=!0),h=!0)}return!1},p=s[r],v,b;return p&&(f(p[o+Pc(i,e,!a)])?l=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ve.windows&&e.ctrlKey&&e.altKey)&&!(Ve.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(v=Ji[e.keyCode])&&v!=i?(f(p[o+Pc(v,e,!0)])||e.shiftKey&&(b=Ga[e.keyCode])!=i&&b!=v&&f(p[o+Pc(b,e,!1)]))&&(l=!0):a&&e.shiftKey&&f(p[o+Pc(i,e,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),h&&(l=!0),l&&u&&e.stopPropagation(),Sm=null,l}class qn{constructor(e,t,r,i,n){this.className=e,this.left=t,this.top=r,this.width=i,this.height=n}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,r){if(r.empty){let i=e.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let n=Q1(e);return[new qn(t,i.left-n.left,i.top-n.top,null,i.bottom-i.top)]}else return h5(e,t,r)}}function Q1(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==Yt.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function dx(s,e,t,r){let i=s.coordsAtPos(e,t*2);if(!i)return r;let n=s.dom.getBoundingClientRect(),a=(i.top+i.bottom)/2,o=s.posAtCoords({x:n.left+1,y:a}),l=s.posAtCoords({x:n.right-1,y:a});return o==null||l==null?r:{from:Math.max(r.from,Math.min(o,l)),to:Math.min(r.to,Math.max(o,l))}}function h5(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let r=Math.max(t.from,s.viewport.from),i=Math.min(t.to,s.viewport.to),n=s.textDirection==Yt.LTR,a=s.contentDOM,o=a.getBoundingClientRect(),l=Q1(s),h=a.querySelector(".cm-line"),u=h&&window.getComputedStyle(h),d=o.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=o.right-(u?parseInt(u.paddingRight):0),p=gm(s,r,1),v=gm(s,i,-1),b=p.type==Qs.Text?p:null,O=v.type==Qs.Text?v:null;if(b&&(s.lineWrapping||p.widgetLineBreaks)&&(b=dx(s,r,1,b)),O&&(s.lineWrapping||v.widgetLineBreaks)&&(O=dx(s,i,-1,O)),b&&O&&b.from==O.from&&b.to==O.to)return m(x(t.from,t.to,b));{let k=b?x(t.from,null,b):y(p,!1),C=O?x(null,t.to,O):y(v,!0),P=[];return(b||p).to<(O||v).from-(b&&O?1:0)||p.widgetLineBreaks>1&&k.bottom+s.defaultLineHeight/2<C.top?P.push(g(d,k.bottom,f,C.top)):k.bottom<C.top&&s.elementAtHeight((k.bottom+C.top)/2).type==Qs.Text&&(k.bottom=C.top=(k.bottom+C.top)/2),m(k).concat(P).concat(m(C))}function g(k,C,P,_){return new qn(e,k-l.left,C-l.top,Math.max(0,P-k),_-C)}function m({top:k,bottom:C,horizontal:P}){let _=[];for(let Q=0;Q<P.length;Q+=2)_.push(g(P[Q],k,P[Q+1],C));return _}function x(k,C,P){let _=1e9,Q=-1e9,E=[];function A(W,H,Z,B,K){let $=s.coordsAtPos(W,W==P.to?-2:2),I=s.coordsAtPos(Z,Z==P.from?2:-2);!$||!I||(_=Math.min($.top,I.top,_),Q=Math.max($.bottom,I.bottom,Q),K==Yt.LTR?E.push(n&&H?d:$.left,n&&B?f:I.right):E.push(!n&&B?d:I.left,!n&&H?f:$.right))}let N=k??P.from,R=C??P.to;for(let W of s.visibleRanges)if(W.to>N&&W.from<R)for(let H=Math.max(W.from,N),Z=Math.min(W.to,R);;){let B=s.state.doc.lineAt(H);for(let K of s.bidiSpans(B)){let $=K.from+B.from,I=K.to+B.from;if($>=Z)break;I>H&&A(Math.max($,H),k==null&&$<=N,Math.min(I,Z),C==null&&I>=R,K.dir)}if(H=B.to+1,H>=Z)break}return E.length==0&&A(N,k==null,R,C==null,s.textDirection),{top:_,bottom:Q,horizontal:E}}function y(k,C){let P=o.top+(C?k.top:k.bottom);return{top:P,bottom:P,horizontal:[]}}}function d5(s,e){return s.constructor==e.constructor&&s.eq(e)}class u5{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Kc)!=e.state.facet(Kc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,r=e.facet(Kc);for(;t<r.length&&r[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,r)=>!d5(t,this.drawn[r]))){let t=this.dom.firstChild,r=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[r].constructor&&i.update(t,this.drawn[r])?(t=t.nextSibling,r++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e,Ve.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Kc=Ge.define();function $1(s){return[is.define(e=>new u5(e,s)),Kc.of(s)]}const No=Ge.define({combine(s){return ii(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function f5(s={}){return[No.of(s),m5,p5,O5,s1.of(!0)]}function j1(s){return s.startState.facet(No)!=s.state.facet(No)}const m5=$1({above:!0,markers(s){let{state:e}=s,t=e.facet(No),r=[];for(let i of e.selection.ranges){let n=i==e.selection.main;if(i.empty||t.drawRangeCursor&&!(n&&Ve.ios&&t.iosSelectionHandles)){let a=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=i.empty?i:fe.cursor(i.head,i.assoc);for(let l of qn.forRange(s,a,o))r.push(l)}}return r},update(s,e){s.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=j1(s);return t&&ux(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){ux(e.state,s)},class:"cm-cursorLayer"});function ux(s,e){e.style.animationDuration=s.facet(No).cursorBlinkRate+"ms"}const p5=$1({above:!1,markers(s){let e=[],{main:t,ranges:r}=s.state.selection;for(let i of r)if(!i.empty)for(let n of qn.forRange(s,"cm-selectionBackground",i))e.push(n);if(Ve.ios&&!t.empty&&s.state.facet(No).iosSelectionHandles){for(let i of qn.forRange(s,"cm-selectionHandle cm-selectionHandle-start",fe.cursor(t.from,1)))e.push(i);for(let i of qn.forRange(s,"cm-selectionHandle cm-selectionHandle-end",fe.cursor(t.to,1)))e.push(i)}return e},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||j1(s)},class:"cm-selectionLayer"}),g5=Ve.gecko&&Ve.gecko_version>=153?"#ffffff01":"transparent",O5=ki.highest(We.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${g5} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),R1=xt.define({map(s,e){return s==null?null:e.mapPos(s)}}),Na=$s.define({create(){return null},update(s,e){return s!=null&&(s=e.changes.mapPos(s)),e.effects.reduce((t,r)=>r.is(R1)?r.value:t,s)}}),x5=is.fromClass(class{constructor(s){this.view=s,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(s){var e;let t=s.state.field(Na);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(s.startState.field(Na)!=t||s.docChanged||s.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:s}=this,e=s.state.field(Na),t=e!=null&&s.coordsAtPos(e);if(!t)return null;let r=s.scrollDOM.getBoundingClientRect();return{left:t.left-r.left+s.scrollDOM.scrollLeft*s.scaleX,top:t.top-r.top+s.scrollDOM.scrollTop*s.scaleY,height:t.bottom-t.top}}drawCursor(s){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;s?(this.cursor.style.left=s.left/e+"px",this.cursor.style.top=s.top/t+"px",this.cursor.style.height=s.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(s){this.view.state.field(Na)!=s&&this.view.dispatch({effects:R1.of(s)})}},{eventObservers:{dragover(s){this.setDropPos(this.view.posAtCoords({x:s.clientX,y:s.clientY}))},dragleave(s){(s.target==this.view.contentDOM||!this.view.contentDOM.contains(s.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function b5(){return[Na,x5]}function fx(s,e,t,r,i){e.lastIndex=0;for(let n=s.iterRange(t,r),a=t,o;!n.next().done;a+=n.value.length)if(!n.lineBreak)for(;o=e.exec(n.value);)i(a+o.index,o)}function v5(s,e){let t=s.visibleRanges;if(t.length==1&&t[0].from==s.viewport.from&&t[0].to==s.viewport.to)return t;let r=[];for(let{from:i,to:n}of t)i=Math.max(s.state.doc.lineAt(i).from,i-e),n=Math.min(s.state.doc.lineAt(n).to,n+e),r.length&&r[r.length-1].to>=i?r[r.length-1].to=n:r.push({from:i,to:n});return r}class y5{constructor(e){const{regexp:t,decoration:r,decorate:i,boundary:n,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(o,l,h,u)=>i(u,h,h+o[0].length,o,l);else if(typeof r=="function")this.addMatch=(o,l,h,u)=>{let d=r(o,l,h);d&&u(h,h+o[0].length,d)};else if(r)this.addMatch=(o,l,h,u)=>u(h,h+o[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=n,this.maxLength=a}createDeco(e){let t=new vi,r=t.add.bind(t);for(let{from:i,to:n}of v5(e,this.maxLength))fx(e.state.doc,this.regexp,i,n,(a,o)=>this.addMatch(o,e,a,r));return t.finish()}updateDeco(e,t){let r=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((n,a,o,l)=>{l>=e.view.viewport.from&&o<=e.view.viewport.to&&(r=Math.min(o,r),i=Math.max(l,i))}),e.viewportMoved||i-r>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),r,i):t}updateRange(e,t,r,i){for(let n of e.visibleRanges){let a=Math.max(n.from,r),o=Math.min(n.to,i);if(o>=a){let l=e.state.doc.lineAt(a),h=l.to<o?e.state.doc.lineAt(o):l,u=Math.max(n.from,l.from),d=Math.min(n.to,h.to);if(this.boundary){for(;a>l.from;a--)if(this.boundary.test(l.text[a-1-l.from])){u=a;break}for(;o<h.to;o++)if(this.boundary.test(h.text[o-h.from])){d=o;break}}let f=[],p,v=(b,O,g)=>f.push(g.range(b,O));if(l==h)for(this.regexp.lastIndex=u-l.from;(p=this.regexp.exec(l.text))&&p.index<d-l.from;)this.addMatch(p,e,p.index+l.from,v);else fx(e.state.doc,this.regexp,u,d,(b,O)=>this.addMatch(O,e,b,v));t=t.update({filterFrom:u,filterTo:d,filter:(b,O)=>b<u||O>d,add:f})}}return t}}const wm=/x/.unicode!=null?"gu":"g",S5=new RegExp(`[\0-\b
20
+ --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,wm),w5={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Au=null;function _5(){var s;if(Au==null&&typeof document<"u"&&document.body){let e=document.body.style;Au=((s=e.tabSize)!==null&&s!==void 0?s:e.MozTabSize)!=null}return Au||!1}const Jc=Ge.define({combine(s){let e=ii(s,{render:null,specialChars:S5,addSpecialChars:null});return(e.replaceTabs=!_5())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,wm)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,wm)),e}});function k5(s={}){return[Jc.of(s),C5()]}let mx=null;function C5(){return mx||(mx=is.fromClass(class{constructor(s){this.view=s,this.decorations=ht.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(Jc)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new y5({regexp:s.specialChars,decoration:(e,t,r)=>{let{doc:i}=t.state,n=Ks(e[0],0);if(n==9){let a=i.lineAt(r),o=t.state.tabSize,l=Mr(a.text,o,r-a.from);return ht.replace({widget:new $5((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[n]||(this.decorationCache[n]=ht.replace({widget:new Q5(s,n)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let e=s.state.facet(Jc);s.startState.facet(Jc)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const P5="•";function T5(s){return s>=32?P5:s==10?"␤":String.fromCharCode(9216+s)}class Q5 extends Nr{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=T5(this.code),r=e.state.phrase("Control character")+" "+(w5[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,t);if(i)return i;let n=document.createElement("span");return n.textContent=t,n.title=r,n.setAttribute("aria-label",r),n.className="cm-specialChar",n}ignoreEvent(){return!1}}class $5 extends Nr{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function j5(){return E5}const R5=ht.line({class:"cm-activeLine"}),E5=is.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.docChanged||s.selectionSet)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=-1,t=[];for(let r of s.state.selection.ranges){let i=s.lineBlockAt(r.head);i.from>e&&(t.push(R5.range(i.from)),e=i.from)}return ht.set(t)}},{decorations:s=>s.decorations});class A5 extends Nr{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Xa(e.firstChild):[];if(!t.length)return null;let r=window.getComputedStyle(e.parentNode),i=el(t[0],r.direction!="rtl"),n=parseInt(r.lineHeight);return i.bottom-i.top>n*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+n}:i}ignoreEvent(){return!1}}function M5(s){let e=is.fromClass(class{constructor(t){this.view=t,this.placeholder=s?ht.set([ht.widget({widget:new A5(s),side:1}).range(0)]):ht.none}get decorations(){return this.view.state.doc.length?ht.none:this.placeholder}},{decorations:t=>t.decorations});return typeof s=="string"?[e,We.contentAttributes.of({"aria-placeholder":s})]:e}const _m=2e3;function L5(s,e,t){let r=Math.min(e.line,t.line),i=Math.max(e.line,t.line),n=[];if(e.off>_m||t.off>_m||e.col<0||t.col<0){let a=Math.min(e.off,t.off),o=Math.max(e.off,t.off);for(let l=r;l<=i;l++){let h=s.doc.line(l);h.length<=o&&n.push(fe.range(h.from+a,h.to+o))}}else{let a=Math.min(e.col,t.col),o=Math.max(e.col,t.col);for(let l=r;l<=i;l++){let h=s.doc.line(l),u=rm(h.text,a,s.tabSize,!0);if(u<0)n.push(fe.cursor(h.to));else{let d=rm(h.text,o,s.tabSize);n.push(fe.range(h.from+u,h.from+d))}}}return n}function N5(s,e){let t=s.coordsAtPos(s.viewport.from);return t?Math.round(Math.abs((t.left-e)/s.defaultCharacterWidth)):-1}function px(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1),r=s.state.doc.lineAt(t),i=t-r.from,n=i>_m?-1:i==r.length?N5(s,e.clientX):Mr(r.text,s.state.tabSize,t-r.from);return{line:r.number,col:n,off:i}}function D5(s,e){let t=px(s,e),r=s.state.selection;return t?{update(i){if(i.docChanged){let n=i.changes.mapPos(i.startState.doc.line(t.line).from),a=i.state.doc.lineAt(n);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},r=r.map(i.changes)}},get(i,n,a){let o=px(s,i);if(!o)return r;let l=L5(s.state,t,o);return l.length?a?fe.create(l.concat(r.ranges)):fe.create(l):r}}:null}function I5(s){let e=(t=>t.altKey&&t.button==0);return We.mouseSelectionStyle.of((t,r)=>e(r)?D5(t,r):null)}const B5={Alt:[18,s=>!!s.altKey],Control:[17,s=>!!s.ctrlKey],Shift:[16,s=>!!s.shiftKey],Meta:[91,s=>!!s.metaKey]},W5={style:"cursor: crosshair"};function X5(s={}){let[e,t]=B5[s.key||"Alt"],r=is.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||t(i))},keyup(i){(i.keyCode==e||!t(i))&&this.set(!1)},mousemove(i){this.set(t(i))}}});return[r,We.contentAttributes.of(i=>{var n;return!((n=i.plugin(r))===null||n===void 0)&&n.isDown?W5:null})]}const Tc="-10000px";class E1{constructor(e,t,r,i){this.facet=t,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let n=null;this.tooltipViews=this.tooltips.map(a=>n=r(a,n))}update(e,t){var r;let i=e.state.facet(this.facet),n=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let a=[],o=t?[]:null;for(let l=0;l<n.length;l++){let h=n[l],u=-1;if(h){for(let d=0;d<this.tooltips.length;d++){let f=this.tooltips[d];f&&f.create==h.create&&(u=d)}if(u<0)a[l]=this.createTooltipView(h,l?a[l-1]:null),o&&(o[l]=!!h.above);else{let d=a[l]=this.tooltipViews[u];o&&(o[l]=t[u]),d.update&&d.update(e)}}}for(let l of this.tooltipViews)a.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return t&&(o.forEach((l,h)=>t[h]=l),t.length=o.length),this.input=i,this.tooltips=n,this.tooltipViews=a,!0}}function z5(s){let e=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Mu=Ge.define({combine:s=>{var e,t,r;return{position:Ve.ios?"absolute":((e=s.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=s.find(i=>i.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((r=s.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||z5}}}),gx=new WeakMap,Tp=is.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=s.state.facet(Mu);this.position=e.position,this.parent=e.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new E1(s,Qp,(t,r)=>this.createTooltip(t,r),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(s,this.above);e&&this.observeIntersection();let t=e||s.geometryChanged,r=s.state.facet(Mu);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;t=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(s,e){let t=s.create(this.view),r=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",t.dom.appendChild(i)}return t.dom.style.position=this.position,t.dom.style.top=Tc,t.dom.style.left="0px",this.container.insertBefore(t.dom,r),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var s,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(s=r.destroy)===null||s===void 0||s.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(Ve.safari){let a=n.getBoundingClientRect();t=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else t=!!n.offsetParent&&n.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(s=n.width/this.parent.offsetWidth,e=n.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=_p(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((n,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(Mu).tooltipSpace(this.view),scaleX:s,scaleY:e,makeAbsolute:t}}writeMeasure(s){var e;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:t,space:r,scaleX:i,scaleY:n}=s,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],h=this.manager.tooltipViews[o],{dom:u}=h,d=s.pos[o],f=s.size[o];if(!d||l.clip!==!1&&(d.bottom<=Math.max(t.top,r.top)||d.top>=Math.min(t.bottom,r.bottom)||d.right<Math.max(t.left,r.left)-.1||d.left>Math.min(t.right,r.right)+.1)){u.style.top=Tc;continue}let p=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,v=p?7:0,b=f.right-f.left,O=(e=gx.get(h))!==null&&e!==void 0?e:f.bottom-f.top,g=h.offset||Z5,m=this.view.textDirection==Yt.LTR,x=f.width>r.right-r.left?m?r.left:r.right-f.width:m?Math.max(r.left,Math.min(d.left-(p?14:0)+g.x,r.right-b)):Math.min(Math.max(r.left,d.left-b+(p?14:0)-g.x),r.right-b),y=this.above[o];!l.strictSide&&(y?d.top-O-v-g.y<r.top:d.bottom+O+v+g.y>r.bottom)&&y==r.bottom-d.bottom>d.top-r.top&&(y=this.above[o]=!y);let k=(y?d.top-r.top:r.bottom-d.bottom)-v;if(k<O&&h.resize!==!1){if(k<this.view.defaultLineHeight){u.style.top=Tc;continue}gx.set(h,O),u.style.height=(O=k)/n+"px"}else u.style.height&&(u.style.height="");let C=y?d.top-O-v-g.y:d.bottom+v+g.y,P=x+b;if(h.overlap!==!0)for(let _ of a)_.left<P&&_.right>x&&_.top<C+O&&_.bottom>C&&(C=y?_.top-O-2-v:_.bottom+v+2);if(this.position=="absolute"?(u.style.top=(C-s.parent.top)/n+"px",Ox(u,(x-s.parent.left)/i)):(u.style.top=C/n+"px",Ox(u,x/i)),p){let _=d.left+(m?g.x:-g.x)-(x+14-7);p.style.left=_/i+"px"}h.overlap!==!0&&a.push({left:x,top:C,right:P,bottom:C+O}),u.classList.toggle("cm-tooltip-above",y),u.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.positioned(s.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let s of this.manager.tooltipViews)s.dom.style.top=Tc}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ox(s,e){let t=parseInt(s.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(s.style.left=e+"px")}const q5=We.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Z5={x:0,y:0},Qp=Ge.define({enables:[Tp,q5]}),kh=Ge.define({combine:s=>s.reduce((e,t)=>e.concat(t),[])});class td{static create(e){return new td(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new E1(e,kh,(t,r)=>this.createHostedView(t,r),t=>t.dom.remove())}createHostedView(e,t){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(t===void 0)t=i;else if(t!==i)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const V5=Qp.compute([kh],s=>{let e=s.facet(kh);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var r;return(r=t.end)!==null&&r!==void 0?r:t.pos})),create:td.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),A1=Ge.define();class F5{constructor(e,t,r,i,n,a){this.view=e,this.source=t,this.field=r,this.locked=i,this.setHover=n,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,r=e.docView.tile.nearest(t.target);if(!r)return;let i,n=1;if(r.isWidget())i=r.posAtStart;else{if(i=e.posAtCoords(t),i==null)return;let a=e.coordsAtPos(i);if(!a||t.y<a.top||t.y>a.bottom||t.x<a.left-e.defaultCharacterWidth||t.x>a.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(i)).find(h=>h.from<=i&&h.to>=i),l=o&&o.dir==Yt.RTL?-1:1;n=t.x<a.left?-l:l}this.activateHover(e,i,n)}activateHover(e,t,r,i){let n=this.source(e,t,r),a=o=>{if(o&&!(Array.isArray(o)&&!o.length)){let l=Array.isArray(o)?o:[o];i&&this.locked.set(l,i),e.dispatch({effects:this.setHover.of(l)})}};if(n&&"then"in n){let o=this.pending={pos:t};n.then(l=>{this.pending==o&&(this.pending=null,a(l))},l=>tr(e.state,l,"hover tooltip"))}else a(n)}get tooltip(){let e=this.view.plugin(Tp),t=e?e.manager.tooltips.findIndex(r=>r.create==td.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:n}=this;if(i.length&&!this.locked.has(i)&&n&&!U5(n.dom,e)||this.pending){let{pos:a}=i[0]||this.pending,o=(r=(t=i[0])===null||t===void 0?void 0:t.end)!==null&&r!==void 0?r:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!H5(this.view,a,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=r=>{e.removeEventListener("mouseleave",t);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Qc=4;function U5(s,e){let{left:t,right:r,top:i,bottom:n}=s.getBoundingClientRect(),a;if(a=s.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();i=Math.min(o.top,i),n=Math.max(o.bottom,n)}return e.clientX>=t-Qc&&e.clientX<=r+Qc&&e.clientY>=i-Qc&&e.clientY<=n+Qc}function H5(s,e,t,r,i,n){let a=s.scrollDOM.getBoundingClientRect(),o=s.documentTop+s.documentPadding.top+s.contentHeight;if(a.left>r||a.right<r||a.top>i||Math.min(a.bottom,o)<i)return!1;let l=s.posAtCoords({x:r,y:i},!1);return l>=e&&l<=t}function Y5(s,e={}){let t=xt.define(),r=new WeakMap,i=$s.define({create(){return[]},update(a,o){let l=r.get(a);if(a.length&&(e.hideOnChange&&(o.docChanged||o.selection)?a=[]:l&&l(o)?a=[]:e.hideOn&&(a=a.filter(h=>!e.hideOn(o,h)))),o.docChanged&&a.length){let h=[];for(let u of a){let d=o.changes.mapPos(u.pos,-1,Ts.TrackDel);if(d!=null){let f=Object.assign(Object.create(null),u);f.pos=d,f.end!=null&&(f.end=o.changes.mapPos(f.end)),h.push(f)}}a=h}for(let h of o.effects)h.is(t)&&(a=h.value,l=void 0),(h.is(K5)&&!h.value||h.value==i)&&(a=[]);return a.length&&l&&r.set(a,l),a},provide:a=>kh.from(a)});const n=is.define(a=>new F5(a,s,i,r,t,e.hoverTime||300));return{active:i,extension:[i,n,A1.of(n),V5]}}function G5(s,e,t,r={}){var i;let n=s.state.facet(A1).map(a=>s.plugin(a)).filter(a=>!!a);if(r.tooltip&&r.tooltip.active){let a=n.find(o=>o.field==r.tooltip.active);a&&(n=[a])}for(let a of n)a.activateHover(s,e,t,(i=r.until)!==null&&i!==void 0?i:(()=>!1))}function M1(s,e){let t=s.plugin(Tp);if(!t)return null;let r=t.manager.tooltips.indexOf(e);return r<0?null:t.manager.tooltipViews[r]}const K5=xt.define(),xx=Ge.define({combine(s){let e,t;for(let r of s)e=e||r.topContainer,t=t||r.bottomContainer;return{topContainer:e,bottomContainer:t}}});function $p(s,e){let t=s.plugin(L1),r=t?t.specs.indexOf(e):-1;return r>-1?t.panels[r]:null}const L1=is.fromClass(class{constructor(s){this.input=s.state.facet(sl),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(xx);this.top=new $c(s,!0,e.topContainer),this.bottom=new $c(s,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(s){let e=s.state.facet(xx);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new $c(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new $c(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(sl);if(t!=this.input){let r=t.filter(l=>l),i=[],n=[],a=[],o=[];for(let l of r){let h=this.specs.indexOf(l),u;h<0?(u=l(s.view),o.push(u)):(u=this.panels[h],u.update&&u.update(s)),i.push(u),(u.top?n:a).push(u)}this.specs=r,this.panels=i,this.top.sync(n),this.bottom.sync(a);for(let l of o)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>We.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class $c{constructor(e,t,r){this.view=e,this.top=t,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=bx(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=bx(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function bx(s){let e=s.nextSibling;return s.remove(),e}const sl=Ge.define({enables:L1});function J5(s,e){let t,r=new Promise(a=>t=a),i=a=>e$(a,e,t);s.state.field(Lu,!1)?s.dispatch({effects:N1.of(i)}):s.dispatch({effects:xt.appendConfig.of(Lu.init(()=>[i]))});let n=D1.of(i);return{close:n,result:r.then(a=>((s.win.queueMicrotask||(l=>s.win.setTimeout(l,10)))(()=>{s.state.field(Lu).indexOf(i)>-1&&s.dispatch({effects:n})}),a))}}const Lu=$s.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(N1)?s=[t.value].concat(s):t.is(D1)&&(s=s.filter(r=>r!=t.value));return s},provide:s=>sl.computeN([s],e=>e.field(s))}),N1=xt.define(),D1=xt.define();function e$(s,e,t){let r=e.content?e.content(s,()=>a(null)):null;if(!r){if(r=Ft("form"),e.input){let o=Ft("input",e.input);/^(text|password|number|email|tel|url)$/.test(o.type)&&o.classList.add("cm-textfield"),o.name||(o.name="input"),r.appendChild(Ft("label",(e.label||"")+": ",o))}else r.appendChild(document.createTextNode(e.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Ft("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let o=0;o<i.length;o++){let l=i[o];l.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),a(null)):h.keyCode==13&&(h.preventDefault(),a(l))}),l.addEventListener("submit",h=>{h.preventDefault(),a(l)})}let n=Ft("div",r,Ft("button",{onclick:()=>a(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(n.className=e.class),n.classList.add("cm-dialog");function a(o){n.contains(n.ownerDocument.activeElement)&&s.focus(),t(o)}return{dom:n,top:e.top,mount:()=>{if(e.focus){let o;typeof e.focus=="string"?o=r.querySelector(e.focus):o=r.querySelector("input")||r.querySelector("button"),o&&"select"in o?o.select():o&&"focus"in o&&o.focus()}}}}class Si extends Gi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Si.prototype.elementClass="";Si.prototype.toDOM=void 0;Si.prototype.mapMode=Ts.TrackBefore;Si.prototype.startSide=Si.prototype.endSide=-1;Si.prototype.point=!0;const eh=Ge.define(),t$=Ge.define(),s$={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Qt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Za=Ge.define();function r$(s){return[I1(),Za.of({...s$,...s})]}const vx=Ge.define({combine:s=>s.some(e=>e)});function I1(s){return[i$]}const i$=is.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=s.state.facet(Za).map(e=>new Sx(s,e)),this.fixed=!s.state.facet(vx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),s.scrollDOM.insertBefore(this.dom,s.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,r=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(r<(t.to-t.from)*.8)}if(s.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(vx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=Qt.iter(this.view.state.facet(eh),this.view.viewport.from),r=[],i=this.gutters.map(n=>new n$(n,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(n.type)){let a=!0;for(let o of n.type)if(o.type==Qs.Text&&a){km(t,r,o.from);for(let l of i)l.line(this.view,o,r);a=!1}else if(o.widget)for(let l of i)l.widget(this.view,o)}else if(n.type==Qs.Text){km(t,r,n.from);for(let a of i)a.line(this.view,n,r)}else if(n.widget)for(let a of i)a.widget(this.view,n);for(let n of i)n.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(Za),t=s.state.facet(Za),r=s.docChanged||s.heightChanged||s.viewportChanged||!Qt.eq(s.startState.facet(eh),s.state.facet(eh),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(s)&&(r=!0);else{r=!0;let i=[];for(let n of t){let a=e.indexOf(n);a<0?i.push(new Sx(this.view,n)):(this.gutters[a].update(s),i.push(this.gutters[a]))}for(let n of this.gutters)n.dom.remove(),i.indexOf(n)<0&&n.destroy();for(let n of i)n.config.side=="after"?this.getDOMAfter().appendChild(n.dom):this.dom.appendChild(n.dom);this.gutters=i}return r}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>We.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let r=t.dom.offsetWidth*e.scaleX,i=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Yt.LTR?{left:r,right:i}:{right:r,left:i}})});function yx(s){return Array.isArray(s)?s:[s]}function km(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class n${constructor(e,t,r){this.gutter=e,this.height=r,this.i=0,this.cursor=Qt.iter(e.markers,t.from)}addElement(e,t,r){let{gutter:i}=this,n=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==i.elements.length){let o=new B1(e,a,n,r);i.elements.push(o),i.dom.appendChild(o.dom)}else i.elements[this.i].update(e,a,n,r);this.height=t.bottom,this.i++}line(e,t,r){let i=[];km(this.cursor,i,t.from),r.length&&(i=i.concat(r));let n=this.gutter.config.lineMarker(e,t,i);n&&i.unshift(n);let a=this.gutter;i.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let r=this.gutter.config.widgetMarker(e,t.widget,t),i=r?[r]:null;for(let n of e.state.facet(t$)){let a=n(e,t.widget,t);a&&(i||(i=[])).push(a)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Sx{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in t.domEventHandlers)this.dom.addEventListener(r,i=>{let n=i.target,a;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let l=n.getBoundingClientRect();a=(l.top+l.bottom)/2}else a=i.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[r](e,o,i)&&i.preventDefault()});this.markers=yx(t.markers(e)),t.initialSpacer&&(this.spacer=new B1(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=yx(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!Qt.eq(this.markers,t,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class B1{constructor(e,t,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,r,i)}update(e,t,r,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),o$(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let r="cm-gutterElement",i=this.dom.firstChild;for(let n=0,a=0;;){let o=a,l=n<t.length?t[n++]:null,h=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let d=a;d<this.markers.length;d++)if(this.markers[d].compare(l)){o=d,h=!0;break}}else o=this.markers.length;for(;a<o;){let u=this.markers[a++];if(u.toDOM){u.destroy(i);let d=i.nextSibling;i.remove(),i=d}}if(!l)break;l.toDOM&&(h?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),h&&a++}this.dom.className=r,this.markers=t}destroy(){this.setMarkers(null,[])}}function o$(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const a$=Ge.define(),l$=Ge.define(),yo=Ge.define({combine(s){return ii(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let r=Object.assign({},e);for(let i in t){let n=r[i],a=t[i];r[i]=n?(o,l,h)=>n(o,l,h)||a(o,l,h):a}return r}})}});class Nu extends Si{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Du(s,e){return s.state.facet(yo).formatNumber(e,s.state)}const c$=Za.compute([yo],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(a$)},lineMarker(e,t,r){return r.some(i=>i.toDOM)?null:new Nu(Du(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,r)=>{for(let i of e.state.facet(l$)){let n=i(e,t,r);if(n)return n}return null},lineMarkerChange:e=>e.startState.facet(yo)!=e.state.facet(yo),initialSpacer(e){return new Nu(Du(e,wx(e.state.doc.lines)))},updateSpacer(e,t){let r=Du(t.view,wx(t.view.state.doc.lines));return r==e.number?e:new Nu(r)},domEventHandlers:s.facet(yo).domEventHandlers,side:"before"}));function h$(s={}){return[yo.of(s),I1(),c$]}function wx(s){let e=9;for(;e<s;)e=e*10+9;return e}const d$=new class extends Si{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},u$=eh.compute(["selection"],s=>{let e=[],t=-1;for(let r of s.selection.ranges){let i=s.doc.lineAt(r.head).from;i>t&&(t=i,e.push(d$.range(i)))}return Qt.of(e)});function f$(){return u$}const W1=1024;let m$=0;class wr{constructor(e,t){this.from=e,this.to=t}}class bt{constructor(e={}){this.id=m$++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ms.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}}bt.closedBy=new bt({deserialize:s=>s.split(" ")});bt.openedBy=new bt({deserialize:s=>s.split(" ")});bt.group=new bt({deserialize:s=>s.split(" ")});bt.isolate=new bt({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});bt.contextHash=new bt({perNode:!0});bt.lookAhead=new bt({perNode:!0});bt.mounted=new bt({perNode:!0});class To{constructor(e,t,r,i=!1){this.tree=e,this.overlay=t,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[bt.mounted.id]}}const p$=Object.create(null);class ms{constructor(e,t,r,i=0){this.name=e,this.props=t,this.id=r,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):p$,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new ms(e.name||"",t,e.id,r);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(bt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let i of r.split(" "))t[i]=e[r];return r=>{for(let i=r.prop(bt.group),n=-1;n<(i?i.length:0);n++){let a=t[n<0?r.name:i[n]];if(a)return a}}}}ms.none=new ms("",Object.create(null),0,8);class kl{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let i=null;for(let n of e){let a=n(r);if(a){i||(i=Object.assign({},r.props));let o=a[1],l=a[0];l.combine&&l.id in i&&(o=l.combine(i[l.id],o)),i[l.id]=o}}t.push(i?new ms(r.name,i,r.id,r.flags):r)}return new kl(t)}}const jc=new WeakMap,_x=new WeakMap;var Bt;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(Bt||(Bt={}));class Wt{constructor(e,t,r,i,n){if(this.type=e,this.children=t,this.positions=r,this.length=i,this.props=null,n&&n.length){this.props=Object.create(null);for(let[a,o]of n)this.props[typeof a=="number"?a:a.id]=o}}toString(){let e=To.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let i=r.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ch(this.topNode,e)}cursorAt(e,t=0,r=0){let i=jc.get(this)||this.topNode,n=new Ch(i);return n.moveTo(e,t),jc.set(this,n._tree),n}get topNode(){return new Bs(this,0,0,null)}resolve(e,t=0){let r=rl(jc.get(this)||this.topNode,e,t,!1);return jc.set(this,r),r}resolveInner(e,t=0){let r=rl(_x.get(this)||this.topNode,e,t,!0);return _x.set(this,r),r}resolveStack(e,t=0){return x$(this,e,t)}iterate(e){let{enter:t,leave:r,from:i=0,to:n=this.length}=e,a=e.mode||0,o=(a&Bt.IncludeAnonymous)>0;for(let l=this.cursor(a|Bt.IncludeAnonymous);;){let h=!1;if(l.from<=n&&l.to>=i&&(!o&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;h=!0}for(;h&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ep(ms.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,i)=>new Wt(this.type,t,r,i,this.propValues),e.makeTree||((t,r,i)=>new Wt(ms.none,t,r,i)))}static build(e){return b$(e)}}Wt.empty=new Wt(ms.none,[],[],0);class jp{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new jp(this.buffer,this.index)}}class tn{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return ms.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],i=this.set.types[t],n=i.name;if(/\W/.test(n)&&!i.isError&&(n=JSON.stringify(n)),e+=4,r==e)return n;let a=[];for(;e<r;)a.push(this.childString(e)),e=this.buffer[e+3];return n+"("+a.join(",")+")"}findChild(e,t,r,i,n){let{buffer:a}=this,o=-1;for(let l=e;l!=t&&!(X1(n,i,a[l+1],a[l+2])&&(o=l,r>0));l=a[l+3]);return o}slice(e,t,r){let i=this.buffer,n=new Uint16Array(t-e),a=0;for(let o=e,l=0;o<t;){n[l++]=i[o++],n[l++]=i[o++]-r;let h=n[l++]=i[o++]-r;n[l++]=i[o++]-e,a=Math.max(a,h)}return new tn(n,a,this.set)}}function X1(s,e,t,r){switch(s){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function rl(s,e,t,r){for(var i;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let a=!r&&s instanceof Bs&&s.index<0?null:s.parent;if(!a)return s;s=a}let n=r?0:Bt.IgnoreOverlays;if(r)for(let a=s,o=a.parent;o;a=o,o=a.parent)a instanceof Bs&&a.index<0&&((i=o.enter(e,t,n))===null||i===void 0?void 0:i.from)!=a.from&&(s=o);for(;;){let a=s.enter(e,t,n);if(!a)return s;s=a}}class z1{cursor(e=0){return new Ch(this,e)}getChild(e,t=null,r=null){let i=kx(this,e,t,r);return i.length?i[0]:null}getChildren(e,t=null,r=null){return kx(this,e,t,r)}resolve(e,t=0){return rl(this,e,t,!1)}resolveInner(e,t=0){return rl(this,e,t,!0)}matchContext(e){return Cm(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(r=t,t=i.prevSibling):t=i}return r}get node(){return this}get next(){return this.parent}}class Bs extends z1{constructor(e,t,r,i){super(),this._tree=e,this.from=t,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,i,n=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,h=t>0?o.length:-1;e!=h;e+=t){let u=o[e],d=l[e]+a.from,f;if(!(!(n&Bt.EnterBracketed&&u instanceof Wt&&(f=To.get(u))&&!f.overlay&&f.bracketed&&r>=d&&r<=d+u.length)&&!X1(i,r,d,d+u.length))){if(u instanceof tn){if(n&Bt.ExcludeBuffers)continue;let p=u.findChild(0,u.buffer.length,t,r-d,i);if(p>-1)return new Kr(new g$(a,u,e,d),null,p)}else if(n&Bt.IncludeAnonymous||!u.type.isAnonymous||Rp(u)){let p;if(!(n&Bt.IgnoreMounts)&&(p=To.get(u))&&!p.overlay)return new Bs(p.tree,d,e,a);let v=new Bs(u,d,e,a);return n&Bt.IncludeAnonymous||!v.type.isAnonymous?v:v.nextChild(t<0?u.children.length-1:0,t,r,i,n)}}}if(n&Bt.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,r=0){let i;if(!(r&Bt.IgnoreOverlays)&&(i=To.get(this._tree))&&i.overlay){let n=e-this.from,a=r&Bt.EnterBracketed&&i.bracketed;for(let{from:o,to:l}of i.overlay)if((t>0||a?o<=n:o<n)&&(t<0||a?l>=n:l>n))return new Bs(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function kx(s,e,t,r){let i=s.cursor(),n=[];if(!i.firstChild())return n;if(t!=null){for(let a=!1;!a;)if(a=i.type.is(t),!i.nextSibling())return n}for(;;){if(r!=null&&i.type.is(r))return n;if(i.type.is(e)&&n.push(i.node),!i.nextSibling())return r==null?n:[]}}function Cm(s,e,t=e.length-1){for(let r=s;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}class g${constructor(e,t,r,i){this.parent=e,this.buffer=t,this.index=r,this.start=i}}class Kr extends z1{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,r);return n<0?null:new Kr(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,r=0){if(r&Bt.ExcludeBuffers)return null;let{buffer:i}=this.context,n=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new Kr(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Kr(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Kr(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,i=this.index+4,n=r.buffer[this.index+3];if(n>i){let a=r.buffer[this.index+1];e.push(r.slice(i,n,a)),t.push(0)}return new Wt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function q1(s){if(!s.length)return null;let e=0,t=s[0];for(let n=1;n<s.length;n++){let a=s[n];(a.from>t.from||a.to<t.to)&&(t=a,e=n)}let r=t instanceof Bs&&t.index<0?null:t.parent,i=s.slice();return r?i[e]=r:i.splice(e,1),new O$(i,t)}class O${constructor(e,t){this.heads=e,this.node=t}get next(){return q1(this.heads)}}function x$(s,e,t){let r=s.resolveInner(e,t),i=null;for(let n=r instanceof Bs?r:r.context.parent;n;n=n.parent)if(n.index<0){let a=n.parent;(i||(i=[r])).push(a.resolve(e,t)),n=a}else{let a=To.get(n.tree);if(a&&a.overlay&&a.overlay[0].from<=e&&a.overlay[a.overlay.length-1].to>=e){let o=new Bs(a.tree,a.overlay[0].from+n.from,-1,n);(i||(i=[r])).push(rl(o,e,t,!1))}}return i?q1(i):r}class Ch{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Bt.EnterBracketed,e instanceof Bs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Bs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:i}=this.buffer,n=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,r);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?r&Bt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Bt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Bt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(i.buffer.buffer[n+3]<this.index)return!1;({index:t,parent:r}=i)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let n=t+e,a=e<0?-1:r._tree.children.length;n!=a;n+=e){let o=r._tree.children[n];if(this.mode&Bt.IncludeAnonymous||o instanceof tn||!o.type.isAnonymous||Rp(o))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,n=this.stack.length;n>=0;){for(let a=e;a;a=a._parent)if(a.index==i){if(i==this.index)return a;t=a,r=n+1;break e}i=this.stack[--n]}for(let i=r;i<this.stack.length;i++)t=new Kr(this.buffer,t,this.stack[i]);return this.bufferNode=new Kr(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return Cm(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let i=e.length-1,n=this.stack.length-1;i>=0;n--){if(n<0)return Cm(this._tree,e,i);let a=r[t.buffer[this.stack[n]]];if(!a.isAnonymous){if(e[i]&&e[i]!=a.name)return!1;i--}}return!0}}function Rp(s){return s.children.some(e=>e instanceof tn||!e.type.isAnonymous||Rp(e))}function b$(s){var e;let{buffer:t,nodeSet:r,maxBufferLength:i=W1,reused:n=[],minRepeatType:a=r.types.length}=s,o=Array.isArray(t)?new jp(t,t.length):t,l=r.types,h=0,u=0;function d(k,C,P,_,Q,E){let{id:A,start:N,end:R,size:W}=o,H=u,Z=h;if(W<0)if(o.next(),W==-1){let X=n[A];P.push(X),_.push(N-k);return}else if(W==-3){h=A;return}else if(W==-4){u=A;return}else throw new RangeError(`Unrecognized record size: ${W}`);let B=l[A],K,$,I=N-k;if(R-N<=i&&($=O(o.pos-C,Q))){let X=new Uint16Array($.size-$.skip),q=o.pos-$.size,ie=X.length;for(;o.pos>q;)ie=g($.start,X,ie);K=new tn(X,R-$.start,r),I=$.start-k}else{let X=o.pos-W;o.next();let q=[],ie=[],pe=A>=a?A:-1,$e=0,re=R;for(;o.pos>X;)pe>=0&&o.id==pe&&o.size>=0?(o.end<=re-i&&(v(q,ie,N,$e,o.end,re,pe,H,Z),$e=q.length,re=o.end),o.next()):E>2500?f(N,X,q,ie):d(N,X,q,ie,pe,E+1);if(pe>=0&&$e>0&&$e<q.length&&v(q,ie,N,$e,N,re,pe,H,Z),q.reverse(),ie.reverse(),pe>-1&&$e>0){let U=p(B,Z);K=Ep(B,q,ie,0,q.length,0,R-N,U,U)}else K=b(B,q,ie,R-N,H-R,Z)}P.push(K),_.push(I)}function f(k,C,P,_){let Q=[],E=0,A=-1;for(;o.pos>C;){let{id:N,start:R,end:W,size:H}=o;if(H>4)o.next();else{if(A>-1&&R<A)break;A<0&&(A=W-i),Q.push(N,R,W),E++,o.next()}}if(E){let N=new Uint16Array(E*4),R=Q[Q.length-2];for(let W=Q.length-3,H=0;W>=0;W-=3)N[H++]=Q[W],N[H++]=Q[W+1]-R,N[H++]=Q[W+2]-R,N[H++]=H;P.push(new tn(N,Q[2]-R,r)),_.push(R-k)}}function p(k,C){return(P,_,Q)=>{let E=0,A=P.length-1,N,R;if(A>=0&&(N=P[A])instanceof Wt){if(!A&&N.type==k&&N.length==Q)return N;(R=N.prop(bt.lookAhead))&&(E=_[A]+N.length+R)}return b(k,P,_,Q,E,C)}}function v(k,C,P,_,Q,E,A,N,R){let W=[],H=[];for(;k.length>_;)W.push(k.pop()),H.push(C.pop()+P-Q);k.push(b(r.types[A],W,H,E-Q,N-E,R)),C.push(Q-P)}function b(k,C,P,_,Q,E,A){if(E){let N=[bt.contextHash,E];A=A?[N].concat(A):[N]}if(Q>25){let N=[bt.lookAhead,Q];A=A?[N].concat(A):[N]}return new Wt(k,C,P,_,A)}function O(k,C){let P=o.fork(),_=0,Q=0,E=0,A=P.end-i,N={size:0,start:0,skip:0};e:for(let R=P.pos-k;P.pos>R;){let W=P.size;if(P.id==C&&W>=0){N.size=_,N.start=Q,N.skip=E,E+=4,_+=4,P.next();continue}let H=P.pos-W;if(W<0||H<R||P.start<A)break;let Z=P.id>=a?4:0,B=P.start;for(P.next();P.pos>H;){if(P.size<0)if(P.size==-3||P.size==-4)Z+=4;else break e;else P.id>=a&&(Z+=4);P.next()}Q=B,_+=W,E+=Z}return(C<0||_==k)&&(N.size=_,N.start=Q,N.skip=E),N.size>4?N:void 0}function g(k,C,P){let{id:_,start:Q,end:E,size:A}=o;if(o.next(),A>=0&&_<a){let N=P;if(A>4){let R=o.pos-(A-4);for(;o.pos>R;)P=g(k,C,P)}C[--P]=N,C[--P]=E-k,C[--P]=Q-k,C[--P]=_}else A==-3?h=_:A==-4&&(u=_);return P}let m=[],x=[];for(;o.pos>0;)d(s.start||0,s.bufferStart||0,m,x,-1,0);let y=(e=s.length)!==null&&e!==void 0?e:m.length?x[0]+m[0].length:0;return new Wt(l[s.topID],m.reverse(),x.reverse(),y)}const Cx=new WeakMap;function th(s,e){if(!s.isAnonymous||e instanceof tn||e.type!=s)return 1;let t=Cx.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=s||!(r instanceof Wt)){t=1;break}t+=th(s,r)}Cx.set(e,t)}return t}function Ep(s,e,t,r,i,n,a,o,l){let h=0;for(let v=r;v<i;v++)h+=th(s,e[v]);let u=Math.ceil(h*1.5/8),d=[],f=[];function p(v,b,O,g,m){for(let x=O;x<g;){let y=x,k=b[x],C=th(s,v[x]);for(x++;x<g;x++){let P=th(s,v[x]);if(C+P>=u)break;C+=P}if(x==y+1){if(C>u){let P=v[y];p(P.children,P.positions,0,P.children.length,b[y]+m);continue}d.push(v[y])}else{let P=b[x-1]+v[x-1].length-k;d.push(Ep(s,v,b,y,x,k,P,null,l))}f.push(k+m-n)}}return p(e,t,r,i,0),(o||l)(d,f,a)}class Ap{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof Kr?this.setBuffer(e.context.buffer,e.index,t):e instanceof Bs&&this.map.set(e.tree,t)}get(e){return e instanceof Kr?this.getBuffer(e.context.buffer,e.index):e instanceof Bs?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class bi{constructor(e,t,r,i,n=!1,a=!1){this.from=e,this.to=t,this.tree=r,this.offset=i,this.open=(n?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let i=[new bi(0,e.length,e,0,!1,r)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t,r=128){if(!t.length)return e;let i=[],n=1,a=e.length?e[0]:null;for(let o=0,l=0,h=0;;o++){let u=o<t.length?t[o]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;a&&a.from<d;){let f=a;if(l>=f.from||d<=f.to||h){let p=Math.max(f.from,l)-h,v=Math.min(f.to,d)-h;f=p>=v?null:new bi(p,v,f.tree,f.offset+h,o>0,!!u)}if(f&&i.push(f),a.to>d)break;a=n<e.length?e[n++]:null}if(!u)break;l=u.toA,h=u.toA-u.toB}return i}}class Mp{startParse(e,t,r){return typeof e=="string"&&(e=new v$(e)),r=r?r.length?r.map(i=>new wr(i.from,i.to)):[new wr(0,0)]:[new wr(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let i=this.startParse(e,t,r);for(;;){let n=i.advance();if(n)return n}}}class v${constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Z1(s){return(e,t,r,i)=>new S$(e,s,t,r,i)}class Px{constructor(e,t,r,i,n,a){this.parser=e,this.parse=t,this.overlay=r,this.bracketed=i,this.target=n,this.from=a}}function Tx(s){if(!s.length||s.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}class y${constructor(e,t,r,i,n,a,o,l){this.parser=e,this.predicate=t,this.mounts=r,this.index=i,this.start=n,this.bracketed=a,this.target=o,this.prev=l,this.depth=0,this.ranges=[]}}const Pm=new bt({perNode:!0});class S${constructor(e,t,r,i,n){this.nest=t,this.input=r,this.fragments=i,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new Wt(r.type,r.children,r.positions,r.length,r.propValues.concat([[Pm,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[bt.mounted.id]=new To(t,e.overlay,e.parser,e.bracketed),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new k$(this.fragments),t=null,r=null,i=new Ch(new Bs(this.baseTree,this.ranges[0].from,0,null),Bt.IncludeAnonymous|Bt.IgnoreMounts);e:for(let n,a;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(e.hasNode(i)){if(t){let h=t.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(h)for(let u of h.mount.overlay){let d=u.from+h.pos,f=u.to+h.pos;d>=i.from&&f<=i.to&&!t.ranges.some(p=>p.from<f&&p.to>d)&&t.ranges.push({from:d,to:f})}}o=!1}else if(r&&(a=w$(r.ranges,i.from,i.to)))o=a!=2;else if(!i.type.isAnonymous&&(n=this.nest(i,this.input))&&(i.from<i.to||!n.overlay)){i.tree||(_$(i),t&&t.depth++,r&&r.depth++);let h=e.findMounts(i.from,n.parser);if(typeof n.overlay=="function")t=new y$(n.parser,n.overlay,h,this.inner.length,i.from,!!n.bracketed,i.tree,t);else{let u=jx(this.ranges,n.overlay||(i.from<i.to?[new wr(i.from,i.to)]:[]));u.length&&Tx(u),(u.length||!n.overlay)&&this.inner.push(new Px(n.parser,u.length?n.parser.startParse(this.input,Rx(h,u),u):n.parser.startParse(""),n.overlay?n.overlay.map(d=>new wr(d.from-i.from,d.to-i.from)):null,!!n.bracketed,i.tree,u.length?u[0].from:i.from)),n.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(t&&(l=t.predicate(i))&&(l===!0&&(l=new wr(i.from,i.to)),l.from<l.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==l.from?t.ranges[h]={from:t.ranges[h].from,to:l.to}:t.ranges.push(l)}if(o&&i.firstChild())t&&t.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(t&&!--t.depth){let h=jx(this.ranges,t.ranges);h.length&&(Tx(h),this.inner.splice(t.index,0,new Px(t.parser,t.parser.startParse(this.input,Rx(t.mounts,h),h),t.ranges.map(u=>new wr(u.from-t.start,u.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}r&&!--r.depth&&(r=r.prev)}}}}function w$(s,e,t){for(let r of s){if(r.from>=t)break;if(r.to>e)return r.from<=e&&r.to>=t?2:1}return 0}function Qx(s,e,t,r,i,n){if(e<t){let a=s.buffer[e+1];r.push(s.slice(e,t,a)),i.push(a-n)}}function _$(s){let{node:e}=s,t=[],r=e.context.buffer;do t.push(s.index),s.parent();while(!s.tree);let i=s.tree,n=i.children.indexOf(r),a=i.children[n],o=a.buffer,l=[n];function h(u,d,f,p,v,b){let O=t[b],g=[],m=[];Qx(a,u,O,g,m,p);let x=o[O+1],y=o[O+2];l.push(g.length);let k=b?h(O+4,o[O+3],a.set.types[o[O]],x,y-x,b-1):e.toTree();return g.push(k),m.push(x-p),Qx(a,o[O+3],d,g,m,p),new Wt(f,g,m,v)}i.children[n]=h(0,o.length,ms.none,0,a.length,t.length-1);for(let u of l){let d=s.tree.children[u],f=s.tree.positions[u];s.yield(new Bs(d,f+s.from,u,s._tree))}}class $x{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(Bt.IncludeAnonymous|Bt.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)if(!(t.to>=e&&t.enter(r,1,Bt.IgnoreOverlays|Bt.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Wt)t=t.children[0];else break}return!1}}let k$=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(Pm))!==null&&t!==void 0?t:r.to,this.inner=new $x(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Pm))!==null&&e!==void 0?e:t.to,this.inner=new $x(t.tree,-t.offset)}}findMounts(e,t){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let a=(r=n.tree)===null||r===void 0?void 0:r.prop(bt.mounted);if(a&&a.parser==t)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=n.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:n.from-l.offset,mount:a})}}}return i}};function jx(s,e){let t=null,r=e;for(let i=1,n=0;i<s.length;i++){let a=s[i-1].to,o=s[i].from;for(;n<r.length;n++){let l=r[n];if(l.from>=o)break;l.to<=a||(t||(r=t=e.slice()),l.from<a?(t[n]=new wr(l.from,a),l.to>o&&t.splice(n+1,0,new wr(o,l.to))):l.to>o?t[n--]=new wr(o,l.to):t.splice(n--,1))}}return r}function C$(s,e,t,r){let i=0,n=0,a=!1,o=!1,l=-1e9,h=[];for(;;){let u=i==s.length?1e9:a?s[i].to:s[i].from,d=n==e.length?1e9:o?e[n].to:e[n].from;if(a!=o){let f=Math.max(l,t),p=Math.min(u,d,r);f<p&&h.push(new wr(f,p))}if(l=Math.min(u,d),l==1e9)break;u==l&&(a?(a=!1,i++):a=!0),d==l&&(o?(o=!1,n++):o=!0)}return h}function Rx(s,e){let t=[];for(let{pos:r,mount:i,frag:n}of s){let a=r+(i.overlay?i.overlay[0].from:0),o=a+i.tree.length,l=Math.max(n.from,a),h=Math.min(n.to,o);if(i.overlay){let u=i.overlay.map(f=>new wr(f.from+r,f.to+r)),d=C$(e,u,l,h);for(let f=0,p=l;;f++){let v=f==d.length,b=v?h:d[f].from;if(b>p&&t.push(new bi(p,b,i.tree,-a,n.from>=p||n.openStart,n.to<=b||n.openEnd)),v)break;p=d[f].to}}else t.push(new bi(l,h,i.tree,-a,n.from>=a||n.openStart,n.to<=o||n.openEnd))}return t}let P$=0;class mr{constructor(e,t,r,i){this.name=e,this.set=t,this.base=r,this.modified=i,this.id=P$++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let r=typeof e=="string"?e:"?";if(e instanceof mr&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let i=new mr(r,[],null,[]);if(i.set.push(i),t)for(let n of t.set)i.set.push(n);return i}static defineModifier(e){let t=new Ph(e);return r=>r.modified.indexOf(t)>-1?r:Ph.get(r.base||r,r.modified.concat(t).sort((i,n)=>i.id-n.id))}}let T$=0;class Ph{constructor(e){this.name=e,this.instances=[],this.id=T$++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(o=>o.base==e&&Q$(t,o.modified));if(r)return r;let i=[],n=new mr(e.name,i,e,t);for(let o of t)o.instances.push(n);let a=$$(t);for(let o of e.set)if(!o.modified.length)for(let l of a)i.push(Ph.get(o,l));return n}}function Q$(s,e){return s.length==e.length&&s.every((t,r)=>t==e[r])}function $$(s){let e=[[]];for(let t=0;t<s.length;t++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(s[t]));return e.sort((t,r)=>r.length-t.length)}function Ci(s){let e=Object.create(null);for(let t in s){let r=s[t];Array.isArray(r)||(r=[r]);for(let i of t.split(" "))if(i){let n=[],a=2,o=i;for(let d=0;;){if(o=="..."&&d>0&&d+3==i.length){a=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!f)throw new RangeError("Invalid path: "+i);if(n.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==i.length)break;let p=i[d++];if(d==i.length&&p=="!"){a=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);o=i.slice(d)}let l=n.length-1,h=n[l];if(!h)throw new RangeError("Invalid path: "+i);let u=new il(r,a,l>0?n.slice(0,l):null);e[h]=u.sort(e[h])}}return V1.add(e)}const V1=new bt({combine(s,e){let t,r,i;for(;s||e;){if(!s||e&&s.depth>=e.depth?(i=e,e=e.next):(i=s,s=s.next),t&&t.mode==i.mode&&!i.context&&!t.context)continue;let n=new il(i.tags,i.mode,i.context);t?t.next=n:r=n,t=n}return r}});class il{constructor(e,t,r,i){this.tags=e,this.mode=t,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}il.empty=new il([],2,null);function F1(s,e){let t=Object.create(null);for(let n of s)if(!Array.isArray(n.tag))t[n.tag.id]=n.class;else for(let a of n.tag)t[a.id]=n.class;let{scope:r,all:i=null}=e||{};return{style:n=>{let a=i;for(let o of n)for(let l of o.set){let h=t[l.id];if(h){a=a?a+" "+h:h;break}}return a},scope:r}}function j$(s,e){let t=null;for(let r of s){let i=r.style(e);i&&(t=t?t+" "+i:i)}return t}function R$(s,e,t,r=0,i=s.length){let n=new E$(r,Array.isArray(e)?e:[e],t);n.highlightRange(s.cursor(),r,i,"",n.highlighters),n.flush(i)}class E${constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,r,i,n){let{type:a,from:o,to:l}=e;if(o>=r||l<=t)return;a.isTop&&(n=this.highlighters.filter(p=>!p.scope||p.scope(a)));let h=i,u=A$(e)||il.empty,d=j$(n,u.tags);if(d&&(h&&(h+=" "),h+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(t,o),h),u.opaque)return;let f=e.tree&&e.tree.prop(bt.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+o,1),v=this.highlighters.filter(O=>!O.scope||O.scope(f.tree.type)),b=e.firstChild();for(let O=0,g=o;;O++){let m=O<f.overlay.length?f.overlay[O]:null,x=m?m.from+o:l,y=Math.max(t,g),k=Math.min(r,x);if(y<k&&b)for(;e.from<k&&(this.highlightRange(e,y,k,i,n),this.startSpan(Math.min(k,e.to),h),!(e.to>=x||!e.nextSibling())););if(!m||x>r)break;g=m.to+o,g>t&&(this.highlightRange(p.cursor(),Math.max(t,m.from+o),Math.min(r,g),"",v),this.startSpan(Math.min(r,g),h))}b&&e.parent()}else if(e.firstChild()){f&&(i="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,i,n),this.startSpan(Math.min(r,e.to),h)}while(e.nextSibling());e.parent()}}}function A$(s){let e=s.type.prop(V1);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const qe=mr.define,Rc=qe(),qi=qe(),Ex=qe(qi),Ax=qe(qi),Zi=qe(),Ec=qe(Zi),Iu=qe(Zi),Fr=qe(),Mn=qe(Fr),Zr=qe(),Vr=qe(),Tm=qe(),Ta=qe(Tm),Ac=qe(),L={comment:Rc,lineComment:qe(Rc),blockComment:qe(Rc),docComment:qe(Rc),name:qi,variableName:qe(qi),typeName:Ex,tagName:qe(Ex),propertyName:Ax,attributeName:qe(Ax),className:qe(qi),labelName:qe(qi),namespace:qe(qi),macroName:qe(qi),literal:Zi,string:Ec,docString:qe(Ec),character:qe(Ec),attributeValue:qe(Ec),number:Iu,integer:qe(Iu),float:qe(Iu),bool:qe(Zi),regexp:qe(Zi),escape:qe(Zi),color:qe(Zi),url:qe(Zi),keyword:Zr,self:qe(Zr),null:qe(Zr),atom:qe(Zr),unit:qe(Zr),modifier:qe(Zr),operatorKeyword:qe(Zr),controlKeyword:qe(Zr),definitionKeyword:qe(Zr),moduleKeyword:qe(Zr),operator:Vr,derefOperator:qe(Vr),arithmeticOperator:qe(Vr),logicOperator:qe(Vr),bitwiseOperator:qe(Vr),compareOperator:qe(Vr),updateOperator:qe(Vr),definitionOperator:qe(Vr),typeOperator:qe(Vr),controlOperator:qe(Vr),punctuation:Tm,separator:qe(Tm),bracket:Ta,angleBracket:qe(Ta),squareBracket:qe(Ta),paren:qe(Ta),brace:qe(Ta),content:Fr,heading:Mn,heading1:qe(Mn),heading2:qe(Mn),heading3:qe(Mn),heading4:qe(Mn),heading5:qe(Mn),heading6:qe(Mn),contentSeparator:qe(Fr),list:qe(Fr),quote:qe(Fr),emphasis:qe(Fr),strong:qe(Fr),link:qe(Fr),monospace:qe(Fr),strikethrough:qe(Fr),inserted:qe(),deleted:qe(),changed:qe(),invalid:qe(),meta:Ac,documentMeta:qe(Ac),annotation:qe(Ac),processingInstruction:qe(Ac),definition:mr.defineModifier("definition"),constant:mr.defineModifier("constant"),function:mr.defineModifier("function"),standard:mr.defineModifier("standard"),local:mr.defineModifier("local"),special:mr.defineModifier("special")};for(let s in L){let e=L[s];e instanceof mr&&(e.name=s)}F1([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var Bu;const Xn=new bt;function Lp(s){return Ge.define({combine:s?e=>e.concat(s):void 0})}const Np=new bt;class _r{constructor(e,t,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return qt(this)}}),this.parser=t,this.extension=[sn.of(this),$t.languageData.of((n,a,o)=>{let l=Mx(n,a,o),h=l.type.prop(Xn);if(!h)return[];let u=n.facet(h),d=l.type.prop(Np);if(d){let f=l.resolve(a-l.from,o);for(let p of d)if(p.test(f,n)){let v=n.facet(p.facet);return p.type=="replace"?v:v.concat(u)}}return u})].concat(r)}isActiveAt(e,t,r=-1){return Mx(e,t,r).type.prop(Xn)==this.data}findRegions(e){let t=e.facet(sn);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],i=(n,a)=>{if(n.prop(Xn)==this.data){r.push({from:a,to:a+n.length});return}let o=n.prop(bt.mounted);if(o){if(o.tree.prop(Xn)==this.data){if(o.overlay)for(let l of o.overlay)r.push({from:l.from+a,to:l.to+a});else r.push({from:a,to:a+n.length});return}else if(o.overlay){let l=r.length;if(i(o.tree,o.overlay[0].from+a),r.length>l)return}}for(let l=0;l<n.children.length;l++){let h=n.children[l];h instanceof Wt&&i(h,n.positions[l]+a)}};return i(qt(e),0),r}get allowsNesting(){return!0}}_r.setState=xt.define();function Mx(s,e,t){let r=s.facet(sn),i=qt(s).topNode;if(!r||r.allowsNesting)for(let n=i;n;n=n.enter(e,t,Bt.ExcludeBuffers|Bt.EnterBracketed))n.type.isTop&&(i=n);return i}class wi extends _r{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=Lp(e.languageData);return new wi(t,e.parser.configure({props:[Xn.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new wi(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function qt(s){let e=s.field(_r.state,!1);return e?e.tree:Wt.empty}class M${constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let Qa=null;class nl{constructor(e,t,r=[],i,n,a,o,l){this.parser=e,this.state=t,this.fragments=r,this.tree=i,this.treeLen=n,this.viewport=a,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new nl(e,t,[],Wt.empty,0,r,[],null)}startParse(){return this.parser.startParse(new M$(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Wt.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(bi.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(bi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Qa;Qa=this;try{return e()}finally{Qa=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Lx(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:i,treeLen:n,viewport:a,skipped:o}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((h,u,d,f)=>l.push({fromA:h,toA:u,fromB:d,toB:f})),r=bi.applyChanges(r,l),i=Wt.empty,n=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){o=[];for(let h of this.skipped){let u=e.mapPos(h.from,1),d=e.mapPos(h.to,-1);u<d&&o.push({from:u,to:d})}}}return new nl(this.parser,t,r,i,n,a,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:n}=this.skipped[r];i<e.to&&n>e.from&&(this.fragments=Lx(this.fragments,i,n),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Mp{createParse(t,r,i){let n=i[0].from,a=i[i.length-1].to;return{parsedPos:n,advance(){let l=Qa;if(l){for(let h of i)l.tempSkipped.push(h);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=a,new Wt(ms.none,[],[],a-n)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Qa}}function Lx(s,e,t){return bi.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class Do{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new Do(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=nl.create(e.facet(sn).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new Do(r)}}_r.state=$s.define({create:Do.init,update(s,e){for(let t of e.effects)if(t.is(_r.setState))return t.value;return e.startState.facet(sn)!=e.state.facet(sn)?Do.init(e.state):s.apply(e)}});let U1=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(U1=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Wu=typeof navigator<"u"&&(!((Bu=navigator.scheduling)===null||Bu===void 0)&&Bu.isInputPending)?()=>navigator.scheduling.isInputPending():null,L$=is.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(_r.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(_r.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=U1(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,n=r.field(_r.state);if(n.tree==n.context.tree&&n.context.isDone(i+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Wu?Math.max(25,e.timeRemaining()-5):1e9),o=n.context.treeLen<i&&r.doc.length>i+1e3,l=n.context.work(()=>Wu&&Wu()||Date.now()>a,i+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:_r.setState.of(new Do(n.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>tr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),sn=Ge.define({combine(s){return s.length?s[0]:null},enables:s=>[_r.state,L$,We.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class rn{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Th{constructor(e,t,r,i,n,a=void 0){this.name=e,this.alias=t,this.extensions=r,this.filename=i,this.loadFunc=n,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:r}=e;if(!t){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(r)}return new Th(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,t,r)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let r=/\.([^.]+)$/.exec(t);if(r){for(let i of e)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(e,t,r=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some(n=>n==t))return i;if(r)for(let i of e)for(let n of i.alias){let a=t.indexOf(n);if(a>-1&&(n.length>2||!/\w/.test(t[a-1])&&!/\w/.test(t[a+n.length])))return i}return null}}const N$=Ge.define(),Vo=Ge.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function Qh(s){let e=s.facet(Vo);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function ol(s,e){let t="",r=s.tabSize,i=s.facet(Vo)[0];if(i==" "){for(;e>=r;)t+=" ",e-=r;i=" "}for(let n=0;n<e;n++)t+=i;return t}function Dp(s,e){s instanceof $t&&(s=new sd(s));for(let r of s.state.facet(N$)){let i=r(s,e);if(i!==void 0)return i}let t=qt(s.state);return t.length>=e?D$(s,t,e):null}class sd{constructor(e,t={}){this.state=e,this.options=t,this.unit=Qh(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:n}=this.options;return i!=null&&i>=r.from&&i<=r.to?n&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,t);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,t=1){let{text:r,from:i}=this.lineAt(e,t),n=this.countColumn(r,e-i),a=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return a>-1&&(n+=a-this.countColumn(r,r.search(/\S|$/))),n}countColumn(e,t=e.length){return Mr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:i}=this.lineAt(e,t),n=this.options.overrideIndentation;if(n){let a=n(i);if(a>-1)return a}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const on=new bt;function D$(s,e,t){let r=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=r.node){let n=[];for(let a=i;a&&!(a.from<r.node.from||a.to>r.node.to||a.from==r.node.from&&a.type==r.node.type);a=a.parent)n.push(a);for(let a=n.length-1;a>=0;a--)r={node:n[a],next:r}}return H1(r,s,t)}function H1(s,e,t){for(let r=s;r;r=r.next){let i=B$(r.node);if(i)return i(Ip.create(e,t,r))}return 0}function I$(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function B$(s){let e=s.type.prop(on);if(e)return e;let t=s.firstChild,r;if(t&&(r=t.type.prop(bt.closedBy))){let i=s.lastChild,n=i&&r.indexOf(i.name)>-1;return a=>Y1(a,!0,1,void 0,n&&!I$(a)?i.from:void 0)}return s.parent==null?W$:null}function W$(){return 0}class Ip extends sd{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new Ip(e,t,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(X$(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return H1(this.context.next,this.base,this.pos)}}function X$(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function z$(s){let e=s.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let i=s.options.simulateBreak,n=s.state.doc.lineAt(t.from),a=i==null||i<=n.from?n.to:Math.min(n.to,i);for(let o=t.to;;){let l=e.childAfter(o);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=a)return null;let h=/^ */.exec(n.text.slice(t.to-n.from))[0].length;return{from:t.from,to:t.to+h}}o=l.to}}function sh({closing:s,align:e=!0,units:t=1}){return r=>Y1(r,e,t,s)}function Y1(s,e,t,r,i){let n=s.textAfter,a=n.match(/^\s*/)[0].length,o=r&&n.slice(a,a+r.length)==r||i==s.pos+a,l=e?z$(s):null;return l?o?s.column(l.from):s.column(l.to):s.baseIndent+(o?0:s.unit*t)}const q$=s=>s.baseIndent;function Qo({except:s,units:e=1}={}){return t=>{let r=s&&s.test(t.textAfter);return t.baseIndent+(r?0:e*t.unit)}}const Z$=200;function V$(){return $t.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let e=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!e.length)return s;let t=s.newDoc,{head:r}=s.newSelection.main,i=t.lineAt(r);if(r>i.from+Z$)return s;let n=t.sliceString(i.from,r);if(!e.some(h=>h.test(n)))return s;let{state:a}=s,o=-1,l=[];for(let{head:h}of a.selection.ranges){let u=a.doc.lineAt(h);if(u.from==o)continue;o=u.from;let d=Dp(a,u.from);if(d==null)continue;let f=/^\s*/.exec(u.text)[0],p=ol(a,d);f!=p&&l.push({from:u.from,to:u.from+f.length,insert:p})}return l.length?[s,{changes:l,sequential:!0}]:s})}const G1=Ge.define(),Pi=new bt;function rd(s){let e=s.firstChild,t=s.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?s.to:t.from}:null}function F$(s,e,t){let r=qt(s);if(r.length<t)return null;let i=r.resolveStack(t,1),n=null;for(let a=i;a;a=a.next){let o=a.node;if(o.to<=t||o.from>t)continue;if(n&&o.from<e)break;let l=o.type.prop(Pi);if(l&&(o.to<r.length-50||r.length==s.doc.length||!U$(o))){let h=l(o,s);h&&h.from<=t&&h.from>=e&&h.to>t&&(n=h)}}return n}function U$(s){let e=s.lastChild;return e&&e.to==s.to&&e.type.isError}function $h(s,e,t){for(let r of s.facet(G1)){let i=r(s,e,t);if(i)return i}return F$(s,e,t)}function K1(s,e){let t=e.mapPos(s.from,1),r=e.mapPos(s.to,-1);return t>=r?void 0:{from:t,to:r}}const id=xt.define({map:K1}),Cl=xt.define({map:K1});function J1(s){let e=[];for(let{head:t}of s.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(s.lineBlockAt(t));return e}const Hn=$s.define({create(){return ht.none},update(s,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((r,i)=>s=Nx(s,r,i)),s=s.map(e.changes);let t=[];for(let r of e.effects)r.is(id)&&!H$(s,r.value.from,r.value.to)?t.push(r.value):r.is(Cl)&&(s=s.update({filter:(i,n)=>r.value.from!=i||r.value.to!=n,filterFrom:r.value.from,filterTo:r.value.to}));if(t.length){let{preparePlaceholder:r}=e.state.facet(sS),i=t.map(n=>(r?ht.replace({widget:new sj(r(e.state,n))}):Dx).range(n.from,n.to));s=s.update({add:i})}return e.selection&&(s=Nx(s,e.selection.main.head)),s},provide:s=>We.decorations.from(s),toJSON(s,e){let t=[];return s.between(0,e.doc.length,(r,i)=>{t.push(r,i)}),t},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<s.length;){let r=s[t++],i=s[t++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(Dx.range(r,i))}return ht.set(e,!0)}});function Nx(s,e,t=e){let r=!1;return s.between(e,t,(i,n)=>{i<t&&n>e&&(r=!0)}),r?s.update({filterFrom:e,filterTo:t,filter:(i,n)=>i>=t||n<=e}):s}function jh(s,e,t){var r;let i=null;return(r=s.field(Hn,!1))===null||r===void 0||r.between(e,t,(n,a)=>{(!i||i.from>n)&&(i={from:n,to:a})}),i}function H$(s,e,t){let r=!1;return s.between(e,e,(i,n)=>{i==e&&n==t&&(r=!0)}),r}function eS(s,e){return s.field(Hn,!1)?e:e.concat(xt.appendConfig.of(rS()))}const Y$=s=>{for(let e of J1(s)){let t=$h(s.state,e.from,e.to);if(t)return s.dispatch({effects:eS(s.state,[id.of(t),tS(s,t)])}),!0}return!1},G$=s=>{if(!s.state.field(Hn,!1))return!1;let e=[];for(let t of J1(s)){let r=jh(s.state,t.from,t.to);r&&e.push(Cl.of(r),tS(s,r,!1))}return e.length&&s.dispatch({effects:e}),e.length>0};function tS(s,e,t=!0){let r=s.state.doc.lineAt(e.from).number,i=s.state.doc.lineAt(e.to).number;return We.announce.of(`${s.state.phrase(t?"Folded lines":"Unfolded lines")} ${r} ${s.state.phrase("to")} ${i}.`)}const K$=s=>{let{state:e}=s,t=[];for(let r=0;r<e.doc.length;){let i=s.lineBlockAt(r),n=$h(e,i.from,i.to);n&&t.push(id.of(n)),r=(n?s.lineBlockAt(n.to):i).to+1}return t.length&&s.dispatch({effects:eS(s.state,t)}),!!t.length},J$=s=>{let e=s.state.field(Hn,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,s.state.doc.length,(r,i)=>{t.push(Cl.of({from:r,to:i}))}),s.dispatch({effects:t}),!0},ej=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Y$},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:G$},{key:"Ctrl-Alt-[",run:K$},{key:"Ctrl-Alt-]",run:J$}],tj={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},sS=Ge.define({combine(s){return ii(s,tj)}});function rS(s){return[Hn,nj]}function iS(s,e){let{state:t}=s,r=t.facet(sS),i=a=>{let o=s.lineBlockAt(s.posAtDOM(a.target)),l=jh(s.state,o.from,o.to);l&&s.dispatch({effects:Cl.of(l)}),a.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(s,i,e);let n=document.createElement("span");return n.textContent=r.placeholderText,n.setAttribute("aria-label",t.phrase("folded code")),n.title=t.phrase("unfold"),n.className="cm-foldPlaceholder",n.onclick=i,n}const Dx=ht.replace({widget:new class extends Nr{toDOM(s){return iS(s,null)}}});class sj extends Nr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return iS(e,this.value)}}const rj={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Xu extends Si{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function ij(s={}){let e={...rj,...s},t=new Xu(e,!0),r=new Xu(e,!1),i=is.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(sn)!=a.state.facet(sn)||a.startState.field(Hn,!1)!=a.state.field(Hn,!1)||qt(a.startState)!=qt(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new vi;for(let l of a.viewportLineBlocks){let h=jh(a.state,l.from,l.to)?r:$h(a.state,l.from,l.to)?t:null;h&&o.add(l.from,l.from,h)}return o.finish()}}),{domEventHandlers:n}=e;return[i,r$({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(i))===null||o===void 0?void 0:o.markers)||Qt.empty},initialSpacer(){return new Xu(e,!1)},domEventHandlers:{...n,click:(a,o,l)=>{if(n.click&&n.click(a,o,l))return!0;let h=jh(a.state,o.from,o.to);if(h)return a.dispatch({effects:Cl.of(h)}),!0;let u=$h(a.state,o.from,o.to);return u?(a.dispatch({effects:id.of(u)}),!0):!1}}}),rS()]}const nj=We.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Pl{constructor(e,t){this.specs=e;let r;function i(o){let l=Ki.newName();return(r||(r=Object.create(null)))["."+l]=o,l}const n=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,a=t.scope;this.scope=a instanceof _r?o=>o.prop(Xn)==a.data:a?o=>o==a:void 0,this.style=F1(e.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:n}).style,this.module=r?new Ki(r):null,this.themeType=t.themeType}static define(e,t){return new Pl(e,t||{})}}const Qm=Ge.define(),nS=Ge.define({combine(s){return s.length?[s[0]]:null}});function zu(s){let e=s.facet(Qm);return e.length?e:s.facet(nS)}function oS(s,e){let t=[aj],r;return s instanceof Pl&&(s.module&&t.push(We.styleModule.of(s.module)),r=s.themeType),e?.fallback?t.push(nS.of(s)):r?t.push(Qm.computeN([We.darkTheme],i=>i.facet(We.darkTheme)==(r=="dark")?[s]:[])):t.push(Qm.of(s)),t}class oj{constructor(e){this.markCache=Object.create(null),this.tree=qt(e.state),this.decorations=this.buildDeco(e,zu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=qt(e.state),r=zu(e.state),i=r!=zu(e.startState),{viewport:n}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<n.to&&!i&&t.type==this.tree.type&&a>=n.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=n.to)}buildDeco(e,t){if(!t||!this.tree.length)return ht.none;let r=new vi;for(let{from:i,to:n}of e.visibleRanges)R$(this.tree,t,(a,o,l)=>{r.add(a,o,this.markCache[l]||(this.markCache[l]=ht.mark({class:l})))},i,n);return r.finish()}}const aj=ki.high(is.fromClass(oj,{decorations:s=>s.decorations})),lj=Pl.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),cj=We.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),aS=1e4,lS="()[]{}",cS=Ge.define({combine(s){return ii(s,{afterCursor:!0,brackets:lS,maxScanDistance:aS,renderMatch:uj})}}),hj=ht.mark({class:"cm-matchingBracket"}),dj=ht.mark({class:"cm-nonmatchingBracket"});function uj(s){let e=[],t=s.matched?hj:dj;return e.push(t.range(s.start.from,s.start.to)),s.end&&e.push(t.range(s.end.from,s.end.to)),e}function Ix(s){let e=[],t=s.facet(cS);for(let r of s.selection.ranges){if(!r.empty)continue;let i=Jr(s,r.head,-1,t)||r.head>0&&Jr(s,r.head-1,1,t)||t.afterCursor&&(Jr(s,r.head,1,t)||r.head<s.doc.length&&Jr(s,r.head+1,-1,t));i&&(e=e.concat(t.renderMatch(i,s)))}return ht.set(e,!0)}const fj=is.fromClass(class{constructor(s){this.paused=!1,this.decorations=Ix(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=Ix(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),mj=[fj,cj];function pj(s={}){return[cS.of(s),mj]}const Bp=new bt;function $m(s,e,t){let r=s.prop(e<0?bt.openedBy:bt.closedBy);if(r)return r;if(s.name.length==1){let i=t.indexOf(s.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function jm(s){let e=s.type.prop(Bp);return e?e(s.node):s}function Jr(s,e,t,r={}){let i=r.maxScanDistance||aS,n=r.brackets||lS,a=qt(s),o=a.resolveInner(e,t);for(let l=o;l;l=l.parent){let h=$m(l.type,t,n);if(h&&l.from<l.to){let u=jm(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return gj(s,e,t,l,u,h,n)}}return Oj(s,e,t,a,o.type,i,n)}function gj(s,e,t,r,i,n,a){let o=r.parent,l={from:i.from,to:i.to},h=0,u=o?.cursor();if(u&&(t<0?u.childBefore(r.from):u.childAfter(r.to)))do if(t<0?u.to<=r.from:u.from>=r.to){if(h==0&&n.indexOf(u.type.name)>-1&&u.from<u.to){let d=jm(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if($m(u.type,t,a))h++;else if($m(u.type,-t,a)){if(h==0){let d=jm(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}h--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function Oj(s,e,t,r,i,n,a){if(t<0?!e:e==s.doc.length)return null;let o=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),l=a.indexOf(o);if(l<0||l%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},u=s.doc.iterRange(e,t>0?s.doc.length:0),d=0;for(let f=0;!u.next().done&&f<=n;){let p=u.value;t<0&&(f+=p.length);let v=e+f*t;for(let b=t>0?0:p.length-1,O=t>0?p.length:-1;b!=O;b+=t){let g=a.indexOf(p[b]);if(!(g<0||r.resolveInner(v+b,1).type!=i))if(g%2==0==t>0)d++;else{if(d==1)return{start:h,end:{from:v+b,to:v+b+1},matched:g>>1==l>>1};d--}}t>0&&(f+=p.length)}return u.done?{start:h,matched:!1}:null}const xj=Object.create(null),Bx=[ms.none],Wx=[],Xx=Object.create(null),bj=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])bj[s]=vj(xj,e);function qu(s,e){Wx.indexOf(s)>-1||(Wx.push(s),console.warn(e))}function vj(s,e){let t=[];for(let o of e.split(" ")){let l=[];for(let h of o.split(".")){let u=s[h]||L[h];u?typeof u=="function"?l.length?l=l.map(u):qu(h,`Modifier ${h} used at start of tag`):l.length?qu(h,`Tag ${h} used as modifier`):l=Array.isArray(u)?u:[u]:qu(h,`Unknown highlighting tag ${h}`)}for(let h of l)t.push(h)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+t.map(o=>o.id),n=Xx[i];if(n)return n.id;let a=Xx[i]=ms.define({id:Bx.length,name:r,props:[Ci({[r]:t})]});return Bx.push(a),a.id}Yt.RTL,Yt.LTR;const yj=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),r=Xp(s.state,t.from);return r.line?Sj(s):r.block?_j(s):!1};function Wp(s,e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let i=s(e,t);return i?(r(t.update(i)),!0):!1}}const Sj=Wp(Pj,0),wj=Wp(hS,0),_j=Wp((s,e)=>hS(s,e,Cj(e)),0);function Xp(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const $a=50;function kj(s,{open:e,close:t},r,i){let n=s.sliceDoc(r-$a,r),a=s.sliceDoc(i,i+$a),o=/\s*$/.exec(n)[0].length,l=/^\s*/.exec(a)[0].length,h=n.length-o;if(n.slice(h-e.length,h)==e&&a.slice(l,l+t.length)==t)return{open:{pos:r-o,margin:o&&1},close:{pos:i+l,margin:l&&1}};let u,d;i-r<=2*$a?u=d=s.sliceDoc(r,i):(u=s.sliceDoc(r,r+$a),d=s.sliceDoc(i-$a,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,v=d.length-p-t.length;return u.slice(f,f+e.length)==e&&d.slice(v,v+t.length)==t?{open:{pos:r+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:i-p-t.length,margin:/\s/.test(d.charAt(v-1))?1:0}}:null}function Cj(s){let e=[];for(let t of s.selection.ranges){let r=s.doc.lineAt(t.from),i=t.to<=r.to?r:s.doc.lineAt(t.to);i.from>r.from&&i.from==t.to&&(i=t.to==r.to+1?r:s.doc.lineAt(t.to-1));let n=e.length-1;n>=0&&e[n].to>r.from?e[n].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function hS(s,e,t=e.selection.ranges){let r=t.map(n=>Xp(e,n.from).block);if(!r.every(n=>n))return null;let i=t.map((n,a)=>kj(e,r[a],n.from,n.to));if(s!=2&&!i.every(n=>n))return{changes:e.changes(t.map((n,a)=>i[a]?[]:[{from:n.from,insert:r[a].open+" "},{from:n.to,insert:" "+r[a].close}]))};if(s!=1&&i.some(n=>n)){let n=[];for(let a=0,o;a<i.length;a++)if(o=i[a]){let l=r[a],{open:h,close:u}=o;n.push({from:h.pos-l.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:n}}return null}function Pj(s,e,t=e.selection.ranges){let r=[],i=-1;e:for(let{from:n,to:a}of t){let o=r.length,l=1e9,h;for(let u=n;u<=a;){let d=e.doc.lineAt(u);if(h==null&&(h=Xp(e,d.from).line,!h))continue e;if(d.from>i&&(n==a||a>d.from)){i=d.from;let f=/^\s*/.exec(d.text)[0].length,p=f==d.length,v=d.text.slice(f,f+h.length)==h?f:-1;f<d.text.length&&f<l&&(l=f),r.push({line:d,comment:v,token:h,indent:f,empty:p,single:!1})}u=d.to+1}if(l<1e9)for(let u=o;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==o+1&&(r[o].single=!0)}if(s!=2&&r.some(n=>n.comment<0&&(!n.empty||n.single))){let n=[];for(let{line:o,token:l,indent:h,empty:u,single:d}of r)(d||!u)&&n.push({from:o.from+h,insert:l+" "});let a=e.changes(n);return{changes:a,selection:e.selection.map(a,1)}}else if(s!=1&&r.some(n=>n.comment>=0)){let n=[];for(let{line:a,comment:o,token:l}of r)if(o>=0){let h=a.from+o,u=h+l.length;a.text[u-a.from]==" "&&u++,n.push({from:h,to:u})}return{changes:n}}return null}const Rm=ri.define(),Tj=ri.define(),Qj=Ge.define(),dS=Ge.define({combine(s){return ii(s,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(r,i)=>e(r,i)||t(r,i)})}}),uS=$s.define({create(){return ei.empty},update(s,e){let t=e.state.facet(dS),r=e.annotation(Rm);if(r){let l=sr.fromTransaction(e,r.selection),h=r.side,u=h==0?s.undone:s.done;return l?u=Rh(u,u.length,t.minDepth,l):u=pS(u,e.startState.selection),new ei(h==0?r.rest:u,h==0?u:r.rest)}let i=e.annotation(Tj);if((i=="full"||i=="before")&&(s=s.isolate()),e.annotation(ds.addToHistory)===!1)return e.changes.empty?s:s.addMapping(e.changes.desc);let n=sr.fromTransaction(e),a=e.annotation(ds.time),o=e.annotation(ds.userEvent);return n?s=s.addChanges(n,a,o,t,e):e.selection&&(s=s.addSelection(e.startState.selection,a,o,t.newGroupDelay)),(i=="full"||i=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(e=>e.toJSON()),undone:s.undone.map(e=>e.toJSON())}},fromJSON(s){return new ei(s.done.map(sr.fromJSON),s.undone.map(sr.fromJSON))}});function $j(s={}){return[uS,dS.of(s),We.domEventHandlers({beforeinput(e,t){let r=e.inputType=="historyUndo"?fS:e.inputType=="historyRedo"?Em:null;return r?(e.preventDefault(),r(t)):!1}})]}function nd(s,e){return function({state:t,dispatch:r}){if(!e&&t.readOnly)return!1;let i=t.field(uS,!1);if(!i)return!1;let n=i.pop(s,t,e);return n?(r(n),!0):!1}}const fS=nd(0,!1),Em=nd(1,!1),jj=nd(0,!0),Rj=nd(1,!0);class sr{constructor(e,t,r,i,n){this.changes=e,this.effects=t,this.mapped=r,this.startSelection=i,this.selectionsAfter=n}setSelAfter(e){return new sr(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new sr(e.changes&&fs.fromJSON(e.changes),[],e.mapped&&ti.fromJSON(e.mapped),e.startSelection&&fe.fromJSON(e.startSelection),e.selectionsAfter.map(fe.fromJSON))}static fromTransaction(e,t){let r=kr;for(let i of e.startState.facet(Qj)){let n=i(e);n.length&&(r=r.concat(n))}return!r.length&&e.changes.empty?null:new sr(e.changes.invert(e.startState.doc),r,void 0,t||e.startState.selection,kr)}static selection(e){return new sr(void 0,kr,void 0,void 0,e)}}function Rh(s,e,t,r){let i=e+1>t+20?e-t-1:0,n=s.slice(i,e);return n.push(r),n}function Ej(s,e){let t=[],r=!1;return s.iterChangedRanges((i,n)=>t.push(i,n)),e.iterChangedRanges((i,n,a,o)=>{for(let l=0;l<t.length;){let h=t[l++],u=t[l++];o>=h&&a<=u&&(r=!0)}}),r}function Aj(s,e){return s.ranges.length==e.ranges.length&&s.ranges.filter((t,r)=>t.empty!=e.ranges[r].empty).length===0}function mS(s,e){return s.length?e.length?s.concat(e):s:e}const kr=[],Mj=200;function pS(s,e){if(s.length){let t=s[s.length-1],r=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Mj));return r.length&&r[r.length-1].eq(e)?s:(r.push(e),Rh(s,s.length-1,1e9,t.setSelAfter(r)))}else return[sr.selection([e])]}function Lj(s){let e=s[s.length-1],t=s.slice();return t[s.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Zu(s,e){if(!s.length)return s;let t=s.length,r=kr;for(;t;){let i=Nj(s[t-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let n=s.slice(0,t);return n[t-1]=i,n}else e=i.mapped,t--,r=i.selectionsAfter}return r.length?[sr.selection(r)]:kr}function Nj(s,e,t){let r=mS(s.selectionsAfter.length?s.selectionsAfter.map(o=>o.map(e)):kr,t);if(!s.changes)return sr.selection(r);let i=s.changes.map(e),n=e.mapDesc(s.changes,!0),a=s.mapped?s.mapped.composeDesc(n):n;return new sr(i,xt.mapEffects(s.effects,e),a,s.startSelection.map(n),r)}const Dj=/^(input\.type|delete)($|\.)/;class ei{constructor(e,t,r=0,i=void 0){this.done=e,this.undone=t,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new ei(this.done,this.undone):this}addChanges(e,t,r,i,n){let a=this.done,o=a[a.length-1];return o&&o.changes&&!o.changes.empty&&e.changes&&(!r||Dj.test(r))&&(!o.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(n,Ej(o.changes,e.changes))||r=="input.type.compose")?a=Rh(a,a.length-1,i.minDepth,new sr(e.changes.compose(o.changes),mS(xt.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,kr)):a=Rh(a,a.length,i.minDepth,e),new ei(a,kr,t,r)}addSelection(e,t,r,i){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:kr;return n.length>0&&t-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Aj(n[n.length-1],e)?this:new ei(pS(this.done,e),this.undone,t,r)}addMapping(e){return new ei(Zu(this.done,e),Zu(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let n=i[i.length-1],a=n.selectionsAfter[0]||(n.startSelection?n.startSelection.map(n.changes.invertedDesc,1):t.selection);if(r&&n.selectionsAfter.length)return t.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:Rm.of({side:e,rest:Lj(i),selection:a}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let o=i.length==1?kr:i.slice(0,i.length-1);return n.mapped&&(o=Zu(o,n.mapped)),t.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:Rm.of({side:e,rest:o,selection:a}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}ei.empty=new ei(kr,kr);const Ij=[{key:"Mod-z",run:fS,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Em,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Em,preventDefault:!0},{key:"Mod-u",run:jj,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Rj,preventDefault:!0}];function Fo(s,e){return fe.create(s.ranges.map(e),s.mainIndex)}function Dr(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ir({state:s,dispatch:e},t){let r=Fo(s.selection,t);return r.eq(s.selection,!0)?!1:(e(Dr(s,r)),!0)}function od(s,e){return fe.cursor(e?s.to:s.from)}function gS(s,e){return Ir(s,t=>t.empty?s.moveByChar(t,e):od(t,e))}function Ws(s){return s.textDirectionAt(s.state.selection.main.head)==Yt.LTR}const OS=s=>gS(s,!Ws(s)),xS=s=>gS(s,Ws(s));function bS(s,e){return Ir(s,t=>t.empty?s.moveByGroup(t,e):od(t,e))}const Bj=s=>bS(s,!Ws(s)),Wj=s=>bS(s,Ws(s));function Xj(s,e,t){if(e.type.prop(t))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function ad(s,e,t){let r=qt(s).resolveInner(e.head),i=t?bt.closedBy:bt.openedBy;for(let l=e.head;;){let h=t?r.childAfter(l):r.childBefore(l);if(!h)break;Xj(s,h,i)?r=h:l=t?h.to:h.from}let n=r.type.prop(i),a,o;return n&&(a=t?Jr(s,r.from,1):Jr(s,r.to,-1))&&a.matched?o=t?a.end.to:a.end.from:o=t?r.to:r.from,fe.cursor(o,t?-1:1)}const zj=s=>Ir(s,e=>ad(s.state,e,!Ws(s))),qj=s=>Ir(s,e=>ad(s.state,e,Ws(s)));function vS(s,e){return Ir(s,t=>{if(!t.empty)return od(t,e);let r=s.moveVertically(t,e);return r.head!=t.head?r:s.moveToLineBoundary(t,e)})}const yS=s=>vS(s,!1),SS=s=>vS(s,!0);function wS(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,r=0,i;if(e){for(let n of s.state.facet(We.scrollMargins)){let a=n(s);a?.top&&(t=Math.max(a?.top,t)),a?.bottom&&(r=Math.max(a?.bottom,r))}i=s.scrollDOM.clientHeight-t-r}else i=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:r,selfScroll:e,height:Math.max(s.defaultLineHeight,i-5)}}function _S(s,e){let t=wS(s),{state:r}=s,i=Fo(r.selection,a=>a.empty?s.moveVertically(a,e,t.height):od(a,e));if(i.eq(r.selection))return!1;let n;if(t.selfScroll){let a=s.coordsAtPos(r.selection.main.head),o=s.scrollDOM.getBoundingClientRect(),l=o.top+t.marginTop,h=o.bottom-t.marginBottom;a&&a.top>l&&a.bottom<h&&(n=We.scrollIntoView(i.main.head,{y:"start",yMargin:a.top-l}))}return s.dispatch(Dr(r,i),{effects:n}),!0}const zx=s=>_S(s,!1),Am=s=>_S(s,!0);function an(s,e,t){let r=s.lineBlockAt(e.head),i=s.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?r.to:r.from)&&(i=s.moveToLineBoundary(e,t,!1)),!t&&i.head==r.from&&r.length){let n=/^\s*/.exec(s.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&e.head!=r.from+n&&(i=fe.cursor(r.from+n))}return i}const Zj=s=>Ir(s,e=>an(s,e,!0)),Vj=s=>Ir(s,e=>an(s,e,!1)),Fj=s=>Ir(s,e=>an(s,e,!Ws(s))),Uj=s=>Ir(s,e=>an(s,e,Ws(s))),Hj=s=>Ir(s,e=>fe.cursor(s.lineBlockAt(e.head).from,1)),Yj=s=>Ir(s,e=>fe.cursor(s.lineBlockAt(e.head).to,-1));function Gj(s,e,t){let r=!1,i=Fo(s.selection,n=>{let a=Jr(s,n.head,-1)||Jr(s,n.head,1)||n.head>0&&Jr(s,n.head-1,1)||n.head<s.doc.length&&Jr(s,n.head+1,-1);if(!a||!a.end)return n;r=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return fe.cursor(o)});return r?(e(Dr(s,i)),!0):!1}const Kj=({state:s,dispatch:e})=>Gj(s,e);function Pr(s,e,t){let r=Fo(s.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=fe.range(i.head,i.anchor));let n=t(i);return fe.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return r.eq(s.state.selection)?!1:(s.dispatch(Dr(s.state,r)),!0)}function kS(s,e){return Pr(s,e,t=>s.moveByChar(t,e))}const CS=s=>kS(s,!Ws(s)),PS=s=>kS(s,Ws(s));function TS(s,e){return Pr(s,e,t=>s.moveByGroup(t,e))}const Jj=s=>TS(s,!Ws(s)),eR=s=>TS(s,Ws(s)),tR=s=>{let e=!Ws(s);return Pr(s,e,t=>ad(s.state,t,e))},sR=s=>{let e=Ws(s);return Pr(s,e,t=>ad(s.state,t,e))};function QS(s,e){return Pr(s,e,t=>s.moveVertically(t,e))}const $S=s=>QS(s,!1),jS=s=>QS(s,!0);function RS(s,e){return Pr(s,e,t=>s.moveVertically(t,e,wS(s).height))}const qx=s=>RS(s,!1),Zx=s=>RS(s,!0),rR=s=>Pr(s,!0,e=>an(s,e,!0)),iR=s=>Pr(s,!1,e=>an(s,e,!1)),nR=s=>{let e=!Ws(s);return Pr(s,e,t=>an(s,t,e))},oR=s=>{let e=Ws(s);return Pr(s,e,t=>an(s,t,e))},aR=s=>Pr(s,!1,e=>fe.cursor(s.lineBlockAt(e.head).from)),lR=s=>Pr(s,!0,e=>fe.cursor(s.lineBlockAt(e.head).to)),Vx=({state:s,dispatch:e})=>(e(Dr(s,{anchor:0})),!0),Fx=({state:s,dispatch:e})=>(e(Dr(s,{anchor:s.doc.length})),!0),Ux=({state:s,dispatch:e})=>(e(Dr(s,{anchor:s.selection.main.anchor,head:0})),!0),Hx=({state:s,dispatch:e})=>(e(Dr(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),cR=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),hR=({state:s,dispatch:e})=>{let t=ld(s).map(({from:r,to:i})=>fe.range(r,Math.min(i+1,s.doc.length)));return e(s.update({selection:fe.create(t),userEvent:"select"})),!0},dR=({state:s,dispatch:e})=>{let t=Fo(s.selection,r=>{let i=qt(s),n=i.resolveStack(r.from,1);if(r.empty){let a=i.resolveStack(r.from,-1);a.node.from>=n.node.from&&a.node.to<=n.node.to&&(n=a)}for(let a=n;a;a=a.next){let{node:o}=a;if((o.from<r.from&&o.to>=r.to||o.to>r.to&&o.from<=r.from)&&a.next)return fe.range(o.to,o.from)}return r});return t.eq(s.selection)?!1:(e(Dr(s,t)),!0)};function ES(s,e){let{state:t}=s,r=t.selection,i=t.selection.ranges.slice();for(let n of t.selection.ranges){let a=t.doc.lineAt(n.head);if(e?a.to<s.state.doc.length:a.from>0)for(let o=n;;){let l=s.moveVertically(o,e);if(l.head<a.from||l.head>a.to){i.some(h=>h.head==l.head)||i.push(l);break}else{if(l.head==o.head)break;o=l}}}return i.length==r.ranges.length?!1:(s.dispatch(Dr(t,fe.create(i,i.length-1))),!0)}const uR=s=>ES(s,!1),fR=s=>ES(s,!0),mR=({state:s,dispatch:e})=>{let t=s.selection,r=null;return t.ranges.length>1?r=fe.create([t.main]):t.main.empty||(r=fe.create([fe.cursor(t.main.head)])),r?(e(Dr(s,r)),!0):!1};function Tl(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:r}=s,i=r.changeByRange(n=>{let{from:a,to:o}=n;if(a==o){let l=e(n);l<a?(t="delete.backward",l=Mc(s,l,!1)):l>a&&(t="delete.forward",l=Mc(s,l,!0)),a=Math.min(a,l),o=Math.max(o,l)}else a=Mc(s,a,!1),o=Mc(s,o,!0);return a==o?{range:n}:{changes:{from:a,to:o},range:fe.cursor(a,a<n.head?-1:1)}});return i.changes.empty?!1:(s.dispatch(r.update(i,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?We.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Mc(s,e,t){if(s instanceof We)for(let r of s.state.facet(We.atomicRanges).map(i=>i(s)))r.between(e,e,(i,n)=>{i<e&&n>e&&(e=t?n:i)});return e}const AS=(s,e,t)=>Tl(s,r=>{let i=r.from,{state:n}=s,a=n.doc.lineAt(i),o,l;if(t&&!e&&i>a.from&&i<a.from+200&&!/[^ \t]/.test(o=a.text.slice(0,i-a.from))){if(o[o.length-1]==" ")return i-1;let h=Mr(o,n.tabSize),u=h%Qh(n)||Qh(n);for(let d=0;d<u&&o[o.length-1-d]==" ";d++)i--;l=i}else l=ys(a.text,i-a.from,e,e)+a.from,l==i&&a.number!=(e?n.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(l-a.from,i-a.from))&&(l=ys(a.text,l-a.from,!1,!1)+a.from);return l}),Mm=s=>AS(s,!1,!0),MS=s=>AS(s,!0,!1),LS=(s,e)=>Tl(s,t=>{let r=t.head,{state:i}=s,n=i.doc.lineAt(r),a=i.charCategorizer(r);for(let o=null;;){if(r==(e?n.to:n.from)){r==t.head&&n.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let l=ys(n.text,r-n.from,e)+n.from,h=n.text.slice(Math.min(r,l)-n.from,Math.max(r,l)-n.from),u=a(h);if(o!=null&&u!=o)break;(h!=" "||r!=t.head)&&(o=u),r=l}return r}),NS=s=>LS(s,!1),pR=s=>LS(s,!0),gR=s=>Tl(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),OR=s=>Tl(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),xR=s=>Tl(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),bR=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:It.of(["",""])},range:fe.cursor(r.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},vR=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(r=>{if(!r.empty||r.from==0||r.from==s.doc.length)return{range:r};let i=r.from,n=s.doc.lineAt(i),a=i==n.from?i-1:ys(n.text,i-n.from,!1)+n.from,o=i==n.to?i+1:ys(n.text,i-n.from,!0)+n.from;return{changes:{from:a,to:o,insert:s.doc.slice(i,o).append(s.doc.slice(a,i))},range:fe.cursor(o)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ld(s){let e=[],t=-1;for(let r of s.selection.ranges){let i=s.doc.lineAt(r.from),n=s.doc.lineAt(r.to);if(!r.empty&&r.to==n.from&&(n=s.doc.lineAt(r.to-1)),t>=i.number){let a=e[e.length-1];a.to=n.to,a.ranges.push(r)}else e.push({from:i.from,to:n.to,ranges:[r]});t=n.number+1}return e}function DS(s,e,t){if(s.readOnly)return!1;let r=[],i=[];for(let n of ld(s)){if(t?n.to==s.doc.length:n.from==0)continue;let a=s.doc.lineAt(t?n.to+1:n.from-1),o=a.length+1;if(t){r.push({from:n.to,to:a.to},{from:n.from,insert:a.text+s.lineBreak});for(let l of n.ranges)i.push(fe.range(Math.min(s.doc.length,l.anchor+o),Math.min(s.doc.length,l.head+o)))}else{r.push({from:a.from,to:n.from},{from:n.to,insert:s.lineBreak+a.text});for(let l of n.ranges)i.push(fe.range(l.anchor-o,l.head-o))}}return r.length?(e(s.update({changes:r,scrollIntoView:!0,selection:fe.create(i,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const yR=({state:s,dispatch:e})=>DS(s,e,!1),SR=({state:s,dispatch:e})=>DS(s,e,!0);function IS(s,e,t){if(s.readOnly)return!1;let r=[];for(let n of ld(s))t?r.push({from:n.from,insert:s.doc.slice(n.from,n.to)+s.lineBreak}):r.push({from:n.to,insert:s.lineBreak+s.doc.slice(n.from,n.to)});let i=s.changes(r);return e(s.update({changes:i,selection:s.selection.map(i,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const wR=({state:s,dispatch:e})=>IS(s,e,!1),_R=({state:s,dispatch:e})=>IS(s,e,!0),kR=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(ld(e).map(({from:i,to:n})=>(i>0?i--:n<e.doc.length&&n++,{from:i,to:n}))),r=Fo(e.selection,i=>{let n;if(s.lineWrapping){let a=s.lineBlockAt(i.head),o=s.coordsAtPos(i.head,i.assoc||1);o&&(n=a.bottom+s.documentTop-o.bottom+s.defaultLineHeight/2)}return s.moveVertically(i,!0,n)}).map(t);return s.dispatch({changes:t,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function CR(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=qt(s).resolveInner(e),r=t.childBefore(e),i=t.childAfter(e),n;return r&&i&&r.to<=e&&i.from>=e&&(n=r.type.prop(bt.closedBy))&&n.indexOf(i.name)>-1&&s.doc.lineAt(r.to).from==s.doc.lineAt(i.from).from&&!/\S/.test(s.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const Yx=BS(!1),PR=BS(!0);function BS(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:n,to:a}=i,o=e.doc.lineAt(n),l=!s&&n==a&&CR(e,n);s&&(n=a=(a<=o.to?o:e.doc.lineAt(a)).to);let h=new sd(e,{simulateBreak:n,simulateDoubleBreak:!!l}),u=Dp(h,n);for(u==null&&(u=Mr(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));a<o.to&&/\s/.test(o.text[a-o.from]);)a++;l?{from:n,to:a}=l:n>o.from&&n<o.from+100&&!/\S/.test(o.text.slice(0,n))&&(n=o.from);let d=["",ol(e,u)];return l&&d.push(ol(e,h.lineIndent(o.from,-1))),{changes:{from:n,to:a,insert:It.of(d)},range:fe.cursor(n+1+d[1].length)}});return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function zp(s,e){let t=-1;return s.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=s.doc.lineAt(a);o.number>t&&(r.empty||r.to>o.from)&&(e(o,i,r),t=o.number),a=o.to+1}let n=s.changes(i);return{changes:i,range:fe.range(n.mapPos(r.anchor,1),n.mapPos(r.head,1))}})}const TR=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),r=new sd(s,{overrideIndentation:n=>{let a=t[n];return a??-1}}),i=zp(s,(n,a,o)=>{let l=Dp(r,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let h=/^\s*/.exec(n.text)[0],u=ol(s,l);(h!=u||o.from<n.from+h.length)&&(t[n.from]=l,a.push({from:n.from,to:n.from+h.length,insert:u}))});return i.changes.empty||e(s.update(i,{userEvent:"indent"})),!0},WS=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(zp(s,(t,r)=>{r.push({from:t.from,insert:s.facet(Vo)})}),{userEvent:"input.indent"})),!0),XS=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(zp(s,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let n=Mr(i,s.tabSize),a=0,o=ol(s,Math.max(0,n-Qh(s)));for(;a<i.length&&a<o.length&&i.charCodeAt(a)==o.charCodeAt(a);)a++;r.push({from:t.from+a,to:t.from+i.length,insert:o.slice(a)})}),{userEvent:"delete.dedent"})),!0),QR=s=>(s.setTabFocusMode(),!0),$R=[{key:"Ctrl-b",run:OS,shift:CS,preventDefault:!0},{key:"Ctrl-f",run:xS,shift:PS},{key:"Ctrl-p",run:yS,shift:$S},{key:"Ctrl-n",run:SS,shift:jS},{key:"Ctrl-a",run:Hj,shift:aR},{key:"Ctrl-e",run:Yj,shift:lR},{key:"Ctrl-d",run:MS},{key:"Ctrl-h",run:Mm},{key:"Ctrl-k",run:gR},{key:"Ctrl-Alt-h",run:NS},{key:"Ctrl-o",run:bR},{key:"Ctrl-t",run:vR},{key:"Ctrl-v",run:Am}],jR=[{key:"ArrowLeft",run:OS,shift:CS,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Bj,shift:Jj,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Fj,shift:nR,preventDefault:!0},{key:"ArrowRight",run:xS,shift:PS,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Wj,shift:eR,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Uj,shift:oR,preventDefault:!0},{key:"ArrowUp",run:yS,shift:$S,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Vx,shift:Ux},{mac:"Ctrl-ArrowUp",run:zx,shift:qx},{key:"ArrowDown",run:SS,shift:jS,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Fx,shift:Hx},{mac:"Ctrl-ArrowDown",run:Am,shift:Zx},{key:"PageUp",run:zx,shift:qx},{key:"PageDown",run:Am,shift:Zx},{key:"Home",run:Vj,shift:iR,preventDefault:!0},{key:"Mod-Home",run:Vx,shift:Ux},{key:"End",run:Zj,shift:rR,preventDefault:!0},{key:"Mod-End",run:Fx,shift:Hx},{key:"Enter",run:Yx,shift:Yx},{key:"Mod-a",run:cR},{key:"Backspace",run:Mm,shift:Mm,preventDefault:!0},{key:"Delete",run:MS,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:NS,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:pR,preventDefault:!0},{mac:"Mod-Backspace",run:OR,preventDefault:!0},{mac:"Mod-Delete",run:xR,preventDefault:!0}].concat($R.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),RR=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:zj,shift:tR},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qj,shift:sR},{key:"Alt-ArrowUp",run:yR},{key:"Shift-Alt-ArrowUp",run:wR},{key:"Alt-ArrowDown",run:SR},{key:"Shift-Alt-ArrowDown",run:_R},{key:"Mod-Alt-ArrowUp",run:uR},{key:"Mod-Alt-ArrowDown",run:fR},{key:"Escape",run:mR},{key:"Mod-Enter",run:PR},{key:"Alt-l",mac:"Ctrl-l",run:hR},{key:"Mod-i",run:dR,preventDefault:!0},{key:"Mod-[",run:XS},{key:"Mod-]",run:WS},{key:"Mod-Alt-\\",run:TR},{key:"Shift-Mod-k",run:kR},{key:"Shift-Mod-\\",run:Kj},{key:"Mod-/",run:yj},{key:"Alt-A",run:wj},{key:"Ctrl-m",mac:"Shift-Alt-m",run:QR}].concat(jR),ER={key:"Tab",run:WS,shift:XS},Gx=typeof String.prototype.normalize=="function"?s=>s.normalize("NFKD"):s=>s;class Io{constructor(e,t,r=0,i=e.length,n,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=n?o=>n(Gx(o)):Gx,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ks(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=up(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Hr(e);let i=this.normalize(t);if(i.length)for(let n=0,a=r,o=!0;;n++){let l=i.charCodeAt(n),h=this.match(l,a,o,this.bufferPos+this.bufferStart,n==i.length-1);if(h)return this.value=h,this;if(n==i.length-1)break;o&&n<t.length&&t.charCodeAt(n)==l?a++:o=!1}}}match(e,t,r,i,n){let a=null;for(let o=0;o<this.matches.length;){let l=this.matches[o],h=!1;this.query.charCodeAt(l.index)==e&&(l.index==this.query.length-1?a={from:l.from,to:i,precise:n&&l.precise}:(l.index++,h=!0)),h?o++:this.matches.splice(o,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:i,precise:r&&n}:this.matches.push({from:t,index:1,precise:r})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}}typeof Symbol<"u"&&(Io.prototype[Symbol.iterator]=function(){return this});const zS={from:-1,to:-1,match:/.*/.exec(""),precise:!0},qp="gm"+(/x/.unicode==null?"":"u");class qS{constructor(e,t,r,i=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=zS,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new ZS(e,t,r,i,n);this.re=new RegExp(t,qp+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter();let a=e.lineAt(i);this.curLineStart=a.from,this.matchPos=Eh(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let r=this.curLineStart+t.index,i=r+t[0].length;if(this.matchPos=Eh(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Vu=new WeakMap;class $o{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,r){let i=Vu.get(e);if(!i||i.from>=r||i.to<=t){let o=new $o(t,e.sliceString(t,r));return Vu.set(e,o),o}if(i.from==t&&i.to==r)return i;let{text:n,from:a}=i;return a>t&&(n=e.sliceString(t,a)+n,a=t),i.to<r&&(n+=e.sliceString(i.to,r)),Vu.set(e,new $o(a,n)),new $o(t,n.slice(t-a,r-a))}}class ZS{constructor(e,t,r,i,n){this.text=e,this.to=n,this.done=!1,this.value=zS,this.matchPos=Eh(e,i),this.re=new RegExp(t,qp+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=$o.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let r=this.flat.from+t.index,i=r+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,precise:!0,match:t},this.matchPos=Eh(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=$o.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(qS.prototype[Symbol.iterator]=ZS.prototype[Symbol.iterator]=function(){return this});function AR(s){try{return new RegExp(s,qp),!0}catch{return!1}}function Eh(s,e){if(e>=s.length)return e;let t=s.lineAt(e),r;for(;e<t.to&&(r=t.text.charCodeAt(e-t.from))>=56320&&r<57344;)e++;return e}const MR=s=>{let{state:e}=s,t=String(e.doc.lineAt(s.state.selection.main.head).number),{close:r,result:i}=J5(s,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return i.then(n=>{let a=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!a){s.dispatch({effects:r});return}let o=e.doc.lineAt(e.selection.main.head),[,l,h,u,d]=a,f=u?+u.slice(1):0,p=h?+h:o.number;if(h&&d){let O=p/100;l&&(O=O*(l=="-"?-1:1)+o.number/e.doc.lines),p=Math.round(e.doc.lines*O)}else h&&l&&(p=p*(l=="-"?-1:1)+o.number);let v=e.doc.line(Math.max(1,Math.min(e.doc.lines,p))),b=fe.cursor(v.from+Math.max(0,Math.min(f,v.length)));s.dispatch({effects:[r,We.scrollIntoView(b.from,{y:"center"})],selection:b})}),!0},LR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},NR=Ge.define({combine(s){return ii(s,LR,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function DR(s){return[zR,XR]}const IR=ht.mark({class:"cm-selectionMatch"}),BR=ht.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Kx(s,e,t,r){return(t==0||s(e.sliceDoc(t-1,t))!=Jt.Word)&&(r==e.doc.length||s(e.sliceDoc(r,r+1))!=Jt.Word)}function WR(s,e,t,r){return s(e.sliceDoc(t,t+1))==Jt.Word&&s(e.sliceDoc(r-1,r))==Jt.Word}const XR=is.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.selectionSet||s.docChanged||s.viewportChanged)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=s.state.facet(NR),{state:t}=s,r=t.selection;if(r.ranges.length>1)return ht.none;let i=r.main,n,a=null;if(i.empty){if(!e.highlightWordAroundCursor)return ht.none;let l=t.wordAt(i.head);if(!l)return ht.none;a=t.charCategorizer(i.head),n=t.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return ht.none;if(e.wholeWords){if(n=t.sliceDoc(i.from,i.to),a=t.charCategorizer(i.head),!(Kx(a,t,i.from,i.to)&&WR(a,t,i.from,i.to)))return ht.none}else if(n=t.sliceDoc(i.from,i.to),!n)return ht.none}let o=[];for(let l of s.visibleRanges){let h=new Io(t.doc,n,l.from,l.to);for(;!h.next().done;){let{from:u,to:d}=h.value;if((!a||Kx(a,t,u,d))&&(i.empty&&u<=i.from&&d>=i.to?o.push(BR.range(u,d)):(u>=i.to||d<=i.from)&&o.push(IR.range(u,d)),o.length>e.maxMatches))return ht.none}}return ht.set(o)}},{decorations:s=>s.decorations}),zR=We.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),qR=({state:s,dispatch:e})=>{let{selection:t}=s,r=fe.create(t.ranges.map(i=>s.wordAt(i.head)||fe.cursor(i.head)),t.mainIndex);return r.eq(t)?!1:(e(s.update({selection:r})),!0)};function ZR(s,e){let{main:t,ranges:r}=s.selection,i=s.wordAt(t.head),n=i&&i.from==t.from&&i.to==t.to;for(let a=!1,o=new Io(s.doc,e,r[r.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new Io(s.doc,e,0,Math.max(0,r[r.length-1].from-1)),a=!0}else{if(a&&r.some(l=>l.from==o.value.from))continue;if(n){let l=s.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const VR=({state:s,dispatch:e})=>{let{ranges:t}=s.selection;if(t.some(n=>n.from===n.to))return qR({state:s,dispatch:e});let r=s.sliceDoc(t[0].from,t[0].to);if(s.selection.ranges.some(n=>s.sliceDoc(n.from,n.to)!=r))return!1;let i=ZR(s,r);return i?(e(s.update({selection:s.selection.addRange(fe.range(i.from,i.to),!1),effects:We.scrollIntoView(i.to)})),!0):!1},Uo=Ge.define({combine(s){return ii(s,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new oE(e),scrollToMatch:e=>We.scrollIntoView(e)})}});class VS{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||AR(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,r)=>r=="n"?`
21
+ `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new KR(this):new HR(this)}getCursor(e,t=0,r){let i=e.doc?e:$t.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?bo(this,i,t,r):xo(this,i,t,r)}}class FS{constructor(e){this.spec=e}}function FR(s,e,t){return(r,i,n,a)=>{if(t&&!t(r,i,n,a))return!1;let o=r>=a&&i<=a+n.length?n.slice(r-a,i-a):e.doc.sliceString(r,i);return s(o,e,r,i)}}function xo(s,e,t,r){let i;return s.wholeWord&&(i=UR(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(i=FR(s.test,e,i)),new Io(e.doc,s.unquoted,t,r,s.caseSensitive?void 0:n=>n.toLowerCase(),i)}function UR(s,e){return(t,r,i,n)=>((n>t||n+i.length<r)&&(n=Math.max(0,t-2),i=s.sliceString(n,Math.min(s.length,r+2))),(e(Ah(i,t-n))!=Jt.Word||e(Mh(i,t-n))!=Jt.Word)&&(e(Mh(i,r-n))!=Jt.Word||e(Ah(i,r-n))!=Jt.Word))}class HR extends FS{constructor(e){super(e)}nextMatch(e,t,r){let i=xo(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=xo(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),a=xo(this.spec,e,n,i),o=null;for(;!a.nextOverlapping().done;)o=a.value;if(o)return o;if(n==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=r)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=xo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=xo(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)i(n.value.from,n.value.to)}}function YR(s,e,t){return(r,i,n)=>(!t||t(r,i,n))&&s(n[0],e,r,i)}function bo(s,e,t,r){let i;return s.wholeWord&&(i=GR(e.charCategorizer(e.selection.main.head))),s.test&&(i=YR(s.test,e,i)),new qS(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:i},t,r)}function Ah(s,e){return s.slice(ys(s,e,!1),e)}function Mh(s,e){return s.slice(e,ys(s,e))}function GR(s){return(e,t,r)=>!r[0].length||(s(Ah(r.input,r.index))!=Jt.Word||s(Mh(r.input,r.index))!=Jt.Word)&&(s(Mh(r.input,r.index+r[0].length))!=Jt.Word||s(Ah(r.input,r.index+r[0].length))!=Jt.Word)}class KR extends FS{nextMatch(e,t,r){let i=bo(this.spec,e,r,e.doc.length).next();return i.done&&(i=bo(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let n=Math.max(t,r-i*1e4),a=bo(this.spec,e,n,r),o=null;for(;!a.next().done;)o=a.value;if(o&&(n==t||o.from>n+10))return o;if(n==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let n=+r.slice(0,i);if(n>0&&n<e.match.length)return e.match[n]+r.slice(i)}return t})}matchAll(e,t){let r=bo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=bo(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!n.next().done;)i(n.value.from,n.value.to)}}const al=xt.define(),Zp=xt.define(),Yi=$s.define({create(s){return new Fu(Lm(s).create(),null)},update(s,e){for(let t of e.effects)t.is(al)?s=new Fu(t.value.create(),s.panel):t.is(Zp)&&(s=new Fu(s.query,t.value?Vp:null));return s},provide:s=>sl.from(s,e=>e.panel)});class Fu{constructor(e,t){this.query=e,this.panel=t}}const JR=ht.mark({class:"cm-searchMatch"}),eE=ht.mark({class:"cm-searchMatch cm-searchMatch-selected"}),tE=is.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(Yi))}update(s){let e=s.state.field(Yi);(e!=s.startState.field(Yi)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return ht.none;let{view:t}=this,r=new vi;for(let i=0,n=t.visibleRanges,a=n.length;i<a;i++){let{from:o,to:l}=n[i];for(;i<a-1&&l>n[i+1].from-500;)l=n[++i].to;s.highlight(t.state,o,l,(h,u)=>{let d=t.state.selection.ranges.some(f=>f.from==h&&f.to==u);r.add(h,u,d?eE:JR)})}return r.finish()}},{decorations:s=>s.decorations});function Ql(s){return e=>{let t=e.state.field(Yi,!1);return t&&t.query.spec.valid?s(e,t):YS(e)}}const Lh=Ql((s,{query:e})=>{let{to:t}=s.state.selection.main,r=e.nextMatch(s.state,t,t);if(!r)return!1;let i=fe.single(r.from,r.to),n=s.state.facet(Uo);return s.dispatch({selection:i,effects:[Fp(s,r),n.scrollToMatch(i.main,s)],userEvent:"select.search"}),HS(s),!0}),Nh=Ql((s,{query:e})=>{let{state:t}=s,{from:r}=t.selection.main,i=e.prevMatch(t,r,r);if(!i)return!1;let n=fe.single(i.from,i.to),a=s.state.facet(Uo);return s.dispatch({selection:n,effects:[Fp(s,i),a.scrollToMatch(n.main,s)],userEvent:"select.search"}),HS(s),!0}),sE=Ql((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:fe.create(t.map(r=>fe.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),rE=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:r,to:i}=t.main,n=[],a=0;for(let o=new Io(s.doc,s.sliceDoc(r,i));!o.next().done;){if(n.length>1e3)return!1;o.value.from==r&&(a=n.length),n.push(fe.range(o.value.from,o.value.to))}return e(s.update({selection:fe.create(n,a),userEvent:"select.search.matches"})),!0},Jx=Ql((s,{query:e})=>{let{state:t}=s,{from:r,to:i}=t.selection.main;if(t.readOnly)return!1;let n=e.nextMatch(t,r,r);if(!n)return!1;let a=n,o=[],l,h,u=[];a.precise?a.from==r&&a.to==i&&(h=t.toText(e.getReplacement(a)),o.push({from:a.from,to:a.to,insert:h}),a=e.nextMatch(t,a.from,a.to),u.push(We.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(r).number)+"."))):a=e.nextMatch(t,a.from,a.to);let d=s.state.changes(o);return a&&(l=fe.single(a.from,a.to).map(d),u.push(Fp(s,a)),u.push(t.facet(Uo).scrollToMatch(l.main,s))),s.dispatch({changes:d,selection:l,effects:u,userEvent:"input.replace"}),!0}),iE=Ql((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let i of e.matchAll(s.state,1e9)){let{from:n,to:a,precise:o}=i;o&&t.push({from:n,to:a,insert:e.getReplacement(i)})}if(!t.length)return!1;let r=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:We.announce.of(r),userEvent:"input.replace.all"}),!0});function Vp(s){return s.state.facet(Uo).createPanel(s)}function Lm(s,e){var t,r,i,n,a;let o=s.selection.main,l=o.empty||o.to>o.from+100?"":s.sliceDoc(o.from,o.to);if(e&&!l)return e;let h=s.facet(Uo);return new VS({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e?.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:h.literal,regexp:(n=e?.regexp)!==null&&n!==void 0?n:h.regexp,wholeWord:(a=e?.wholeWord)!==null&&a!==void 0?a:h.wholeWord})}function US(s){let e=$p(s,Vp);return e&&e.dom.querySelector("[main-field]")}function HS(s){let e=US(s);e&&e==s.root.activeElement&&e.select()}const YS=s=>{let e=s.state.field(Yi,!1);if(e&&e.panel){let t=US(s);if(t&&t!=s.root.activeElement){let r=Lm(s.state,e.query.spec);r.valid&&s.dispatch({effects:al.of(r)}),t.focus(),t.select()}}else s.dispatch({effects:[Zp.of(!0),e?al.of(Lm(s.state,e.query.spec)):xt.appendConfig.of(lE)]});return!0},GS=s=>{let e=s.state.field(Yi,!1);if(!e||!e.panel)return!1;let t=$p(s,Vp);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:Zp.of(!1)}),!0},nE=[{key:"Mod-f",run:YS,scope:"editor search-panel"},{key:"F3",run:Lh,shift:Nh,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Lh,shift:Nh,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:GS,scope:"editor search-panel"},{key:"Mod-Shift-l",run:rE},{key:"Mod-Alt-g",run:MR},{key:"Mod-d",run:VR,preventDefault:!0}];class oE{constructor(e){this.view=e;let t=this.query=e.state.field(Yi).query.spec;this.commit=this.commit.bind(this),this.searchField=Ft("input",{value:t.search,placeholder:cr(e,"Find"),"aria-label":cr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ft("input",{value:t.replace,placeholder:cr(e,"Replace"),"aria-label":cr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ft("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ft("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ft("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(i,n,a){return Ft("button",{class:"cm-button",name:i,onclick:n,type:"button"},a)}this.dom=Ft("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>Lh(e),[cr(e,"next")]),r("prev",()=>Nh(e),[cr(e,"previous")]),r("select",()=>sE(e),[cr(e,"all")]),Ft("label",null,[this.caseField,cr(e,"match case")]),Ft("label",null,[this.reField,cr(e,"regexp")]),Ft("label",null,[this.wordField,cr(e,"by word")]),...e.state.readOnly?[]:[Ft("br"),this.replaceField,r("replace",()=>Jx(e),[cr(e,"replace")]),r("replaceAll",()=>iE(e),[cr(e,"replace all")])],Ft("button",{name:"close",onclick:()=>GS(e),"aria-label":cr(e,"close"),type:"button"},["×"])])}commit(){let e=new VS({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:al.of(e)}))}keydown(e){a5(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Nh:Lh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Jx(this.view))}update(e){for(let t of e.transactions)for(let r of t.effects)r.is(al)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Uo).top}}function cr(s,e){return s.state.phrase(e)}const Lc=30,Nc=/[\s\.,:;?!]/;function Fp(s,{from:e,to:t}){let r=s.state.doc.lineAt(e),i=s.state.doc.lineAt(t).to,n=Math.max(r.from,e-Lc),a=Math.min(i,t+Lc),o=s.state.sliceDoc(n,a);if(n!=r.from){for(let l=0;l<Lc;l++)if(!Nc.test(o[l+1])&&Nc.test(o[l])){o=o.slice(l);break}}if(a!=i){for(let l=o.length-1;l>o.length-Lc;l--)if(!Nc.test(o[l-1])&&Nc.test(o[l])){o=o.slice(0,l);break}}return We.announce.of(`${s.state.phrase("current match")}. ${o} ${s.state.phrase("on line")} ${r.number}.`)}const aE=We.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),lE=[Yi,ki.low(tE),aE];class Up{constructor(e,t,r,i){this.state=e,this.pos=t,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=qt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),r=Math.max(t.from,this.pos-250),i=t.text.slice(r-t.from,this.pos-t.from),n=i.search(JS(e,!1));return n<0?null:{from:r+n,to:this.pos,text:i.slice(n)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,r){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function eb(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function cE(s){let e=Object.create(null),t=Object.create(null);for(let{label:i}of s){e[i[0]]=!0;for(let n=1;n<i.length;n++)t[i[n]]=!0}let r=eb(e)+eb(t)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Hp(s){let e=s.map(i=>typeof i=="string"?{label:i}:i),[t,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:cE(e);return i=>{let n=i.matchBefore(r);return n||i.explicit?{from:n?n.from:i.pos,options:e,validFor:t}:null}}function KS(s,e){return t=>{for(let r=qt(t.state).resolveInner(t.pos,-1);r;r=r.parent){if(s.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(t)}}class tb{constructor(e,t,r,i){this.completion=e,this.source=t,this.match=r,this.score=i}}function Zn(s){return s.selection.main.from}function JS(s,e){var t;let{source:r}=s,i=e&&r[0]!="^",n=r[r.length-1]!="$";return!i&&!n?s:new RegExp(`${i?"^":""}(?:${r})${n?"$":""}`,(t=s.flags)!==null&&t!==void 0?t:s.ignoreCase?"i":"")}const Yp=ri.define();function hE(s,e,t,r){let{main:i}=s.selection,n=t-i.from,a=r-i.from;return{...s.changeByRange(o=>{if(o!=i&&t!=r&&s.sliceDoc(o.from+n,o.from+a)!=s.sliceDoc(t,r))return{range:o};let l=s.toText(e);return{changes:{from:o.from+n,to:r==i.from?o.to:o.from+a,insert:l},range:fe.cursor(o.from+n+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const sb=new WeakMap;function dE(s){if(!Array.isArray(s))return s;let e=sb.get(s);return e||sb.set(s,e=Hp(s)),e}const Dh=xt.define(),ll=xt.define();class uE{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let r=Ks(e,t),i=Hr(r);this.chars.push(r);let n=e.slice(t,t+i),a=n.toUpperCase();this.folded.push(Ks(a==n?n.toLowerCase():a,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:r,any:i,precise:n,byWord:a}=this;if(t.length==1){let m=Ks(e,0),x=Hr(m),y=x==e.length?0:-100;if(m!=t[0])if(m==r[0])y+=-200;else return null;return this.ret(y,[0,x])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,h=0;if(o<0){for(let m=0,x=Math.min(e.length,200);m<x&&h<l;){let y=Ks(e,m);(y==t[h]||y==r[h])&&(i[h++]=m),m+=Hr(y)}if(h<l)return null}let u=0,d=0,f=!1,p=0,v=-1,b=-1,O=/[a-z]/.test(e),g=!0;for(let m=0,x=Math.min(e.length,200),y=0;m<x&&d<l;){let k=Ks(e,m);o<0&&(u<l&&k==t[u]&&(n[u++]=m),p<l&&(k==t[p]||k==r[p]?(p==0&&(v=m),b=m+1,p++):p=0));let C,P=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(C=up(k))!=C.toLowerCase()?1:C!=C.toUpperCase()?2:0;(!m||P==1&&O||y==0&&P!=0)&&(t[d]==k||r[d]==k&&(f=!0)?a[d++]=m:a.length&&(g=!1)),y=P,m+=Hr(k)}return d==l&&a[0]==0&&g?this.result(-100+(f?-200:0),a,e):p==l&&v==0?this.ret(-200-e.length+(b==e.length?0:-100),[0,b]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):p==l?this.ret(-900-e.length,[v,b]):d==l?this.result(-100+(f?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,r){let i=[],n=0;for(let a of t){let o=a+(this.astral?Hr(Ks(r,a)):1);n&&i[n-1]==a?i[n-1]=o:(i[n++]=a,i[n++]=o)}return this.ret(e-r.length,i)}}class fE{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),r=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,t.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const vs=Ge.define({combine(s){return ii(s,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:mE,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>r=>rb(e(r),t(r)),optionClass:(e,t)=>r=>rb(e(r),t(r)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function rb(s,e){return s?e?s+" "+e:s:e}function mE(s,e,t,r,i,n){let a=s.textDirection==Yt.RTL,o=a,l=!1,h="top",u,d,f=e.left-i.left,p=i.right-e.right,v=r.right-r.left,b=r.bottom-r.top;if(o&&f<Math.min(v,p)?o=!1:!o&&p<Math.min(v,f)&&(o=!0),v<=(o?f:p))u=Math.max(i.top,Math.min(t.top,i.bottom-b))-e.top,d=Math.min(400,o?f:p);else{l=!0,d=Math.min(400,(a?e.right:i.right-e.left)-30);let m=i.bottom-e.bottom;m>=b||m>e.top?u=t.bottom-e.top:(h="bottom",u=e.bottom-t.top)}let O=(e.bottom-e.top)/n.offsetHeight,g=(e.right-e.left)/n.offsetWidth;return{style:`${h}: ${u/O}px; max-width: ${d/g}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}const Gp=xt.define();function pE(s){let e=s.addToOptions.slice();return s.icons&&e.push({render(t){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),t.type&&r.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(t,r,i,n){let a=document.createElement("span");a.className="cm-completionLabel";let o=t.displayLabel||t.label,l=0;for(let h=0;h<n.length;){let u=n[h++],d=n[h++];u>l&&a.appendChild(document.createTextNode(o.slice(l,u)));let f=a.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(u,d))),f.className="cm-completionMatchedText",l=d}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},position:50},{render(t){if(!t.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=t.detail,r},position:80}),e.sort((t,r)=>t.position-r.position).map(t=>t.render)}function Uu(s,e,t){if(s<=t)return{from:0,to:s};if(e<0&&(e=0),e<=s>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let r=Math.ceil((s-e)/t);return{from:s-r*t,to:s-(r-1)*t}}class gE{constructor(e,t,r){this.view=e,this.stateField=t,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:n,selected:a}=i.open,o=e.state.facet(vs);this.optionContent=pE(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Uu(n.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:h}=e.state.field(t).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<h.length){this.applyCompletion(e,h[+d[1]]),l.preventDefault();return}if(l.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:Gp.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(vs).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:ll.of(null)})}),this.showOptions(n,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:n,selected:a,disabled:o}=r.open;(!i.open||i.open.options!=n)&&(this.range=Uu(n.length,a,e.state.facet(vs).maxRenderedOptions),this.showOptions(n,r.id)),this.updateSel(),o!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of t.split(" "))r&&this.dom.classList.add(r);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Uu(t.options.length,t.selected,this.view.state.facet(vs).maxRenderedOptions),this.showOptions(t.options,e.id));let r=this.updateSelectedOption(t.selected);if(r){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:n}=i;if(!n)return;let a=typeof n=="string"?document.createTextNode(n):n(i);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>tr(this.view.state,o,"completion info")):(this.addInfoPane(a,i),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:n}=e;r.appendChild(i),this.infoDestroy=n||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),t=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return t&&xE(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),n=this.space;if(!n){let a=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(n.bottom,t.bottom)-10||i.bottom<Math.max(n.top,t.top)+10?null:this.view.state.facet(vs).positionInfo(this.view,t,i,r,n,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,r){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",a=>{a.target==i&&a.preventDefault()});let n=null;for(let a=r.from;a<r.to;a++){let{completion:o,match:l}=e[a],{section:h}=o;if(h){let f=typeof h=="string"?h:h.name;if(f!=n&&(a>r.from||r.from==0))if(n=f,typeof h!="string"&&h.header)i.appendChild(h.header(h));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=f}}const u=i.appendChild(document.createElement("li"));u.id=t+"-"+a,u.setAttribute("role","option");let d=this.optionClass(o);d&&(u.className=d);for(let f of this.optionContent){let p=f(o,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function OE(s,e){return t=>new gE(t,s,e)}function xE(s,e){let t=s.getBoundingClientRect(),r=e.getBoundingClientRect(),i=t.height/s.offsetHeight;r.top<t.top?s.scrollTop-=(t.top-r.top)/i:r.bottom>t.bottom&&(s.scrollTop+=(r.bottom-t.bottom)/i)}function ib(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function bE(s,e){let t=[],r=null,i=null,n=u=>{t.push(u);let{section:d}=u.completion;if(d){r||(r=[]);let f=typeof d=="string"?d:d.name;r.some(p=>p.name==f)||r.push(typeof d=="string"?{name:f}:d)}},a=e.facet(vs);for(let u of s)if(u.hasResult()){let d=u.result.getMatch;if(u.result.filter===!1)for(let f of u.result.options)n(new tb(f,u.source,d?d(f):[],1e9-t.length));else{let f=e.sliceDoc(u.from,u.to),p,v=a.filterStrict?new fE(f):new uE(f);for(let b of u.result.options)if(p=v.match(b.label)){let O=b.displayLabel?d?d(b,p.matched):[]:p.matched,g=p.score+(b.boost||0);if(n(new tb(b,u.source,O,g)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:m}=b.section;i||(i=Object.create(null)),i[m]=Math.max(g,i[m]||-1e9)}}}}if(r){let u=Object.create(null),d=0,f=(p,v)=>(p.rank==="dynamic"&&v.rank==="dynamic"?i[v.name]-i[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof v.rank=="number"?v.rank:1e9)||(p.name<v.name?-1:1);for(let p of r.sort(f))d-=1e5,u[p.name]=d;for(let p of t){let{section:v}=p.completion;v&&(p.score+=u[typeof v=="string"?v:v.name])}}let o=[],l=null,h=a.compareCompletions;for(let u of t.sort((d,f)=>f.score-d.score||h(d.completion,f.completion))){let d=u.completion;!l||l.label!=d.label||l.detail!=d.detail||l.type!=null&&d.type!=null&&l.type!=d.type||l.apply!=d.apply||l.boost!=d.boost?o.push(u):ib(u.completion)>ib(l)&&(o[o.length-1]=u),l=u.completion}return o}class So{constructor(e,t,r,i,n,a){this.options=e,this.attrs=t,this.tooltip=r,this.timestamp=i,this.selected=n,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new So(this.options,nb(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,r,i,n,a){if(i&&!a&&e.some(h=>h.isPending))return i.setDisabled();let o=bE(e,t);if(!o.length)return i&&e.some(h=>h.isPending)?i.setDisabled():null;let l=t.facet(vs).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let h=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==h){l=u;break}}return new So(o,nb(r,l),{pos:e.reduce((h,u)=>u.hasResult()?Math.min(h,u.from):h,1e8),create:kE,above:n.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new So(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new So(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ih{constructor(e,t,r){this.active=e,this.id=t,this.open=r}static start(){return new Ih(wE,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,r=t.facet(vs),n=(r.override||t.languageDataAt("autocomplete",Zn(t)).map(dE)).map(l=>(this.active.find(u=>u.source==l)||new Cr(l,this.active.some(u=>u.state!=0)?1:0)).update(e,r));n.length==this.active.length&&n.every((l,h)=>l==this.active[h])&&(n=this.active);let a=this.open,o=e.effects.some(l=>l.is(Kp));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||n.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!vE(n,this.active)||o?a=So.build(n,t,this.id,a,r,o):a&&a.disabled&&!n.some(l=>l.isPending)&&(a=null),!a&&n.every(l=>!l.isPending)&&n.some(l=>l.hasResult())&&(n=n.map(l=>l.hasResult()?new Cr(l.source,0):l));for(let l of e.effects)l.is(Gp)&&(a=a&&a.setSelected(l.value,this.id));return n==this.active&&a==this.open?this:new Ih(n,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?yE:SE}}function vE(s,e){if(s==e)return!0;for(let t=0,r=0;;){for(;t<s.length&&!s[t].hasResult();)t++;for(;r<e.length&&!e[r].hasResult();)r++;let i=t==s.length,n=r==e.length;if(i||n)return i==n;if(s[t++].result!=e[r++].result)return!1}}const yE={"aria-autocomplete":"list"},SE={};function nb(s,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return e>-1&&(t["aria-activedescendant"]=s+"-"+e),t}const wE=[];function ew(s,e){if(s.isUserEvent("input.complete")){let r=s.annotation(Yp);if(r&&e.activateOnCompletion(r))return 12}let t=s.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:s.isUserEvent("delete.backward")?2:s.selection?8:s.docChanged?16:0}class Cr{constructor(e,t,r=!1){this.source=e,this.state=t,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let r=ew(e,t),i=this;(r&8||r&16&&this.touches(e))&&(i=new Cr(i.source,0)),r&4&&i.state==0&&(i=new Cr(this.source,1)),i=i.updateFor(e,r);for(let n of e.effects)if(n.is(Dh))i=new Cr(i.source,1,n.value);else if(n.is(ll))i=new Cr(i.source,0);else if(n.is(Kp))for(let a of n.value)a.source==i.source&&(i=a);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Zn(e.state))}}class jo extends Cr{constructor(e,t,r,i,n,a){super(e,3,t),this.limit=r,this.result=i,this.from=n,this.to=a}hasResult(){return!0}updateFor(e,t){var r;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let n=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),o=Zn(e.state);if(o>a||!i||t&2&&(Zn(e.startState)==this.from||o<this.limit))return new Cr(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return _E(i.validFor,e.state,n,a)?new jo(this.source,this.explicit,l,i,n,a):i.update&&(i=i.update(i,n,a,new Up(e.state,o,!1)))?new jo(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Zn(e.state)):new Cr(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new jo(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Cr(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function _E(s,e,t,r){if(!s)return!1;let i=e.sliceDoc(t,r);return typeof s=="function"?s(i,t,r,e):JS(s,!0).test(i)}const Kp=xt.define({map(s,e){return s.map(t=>t.map(e))}}),Js=$s.define({create(){return Ih.start()},update(s,e){return s.update(e)},provide:s=>[Qp.from(s,e=>e.tooltip),We.contentAttributes.from(s,e=>e.attrs)]});function Jp(s,e){const t=e.completion.apply||e.completion.label;let r=s.state.field(Js).active.find(i=>i.source==e.source);return r instanceof jo?(typeof t=="string"?s.dispatch({...hE(s.state,t,r.from,r.to),annotations:Yp.of(e.completion)}):t(s,e.completion,r.from,r.to),!0):!1}const kE=OE(Js,Jp);function Dc(s,e="option"){return t=>{let r=t.state.field(Js,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<t.state.facet(vs).interactionDelay)return!1;let i=1,n;e=="page"&&(n=M1(t,r.open.tooltip))&&(i=Math.max(2,Math.floor(n.dom.offsetHeight/n.dom.querySelector("li").offsetHeight)-1));let{length:a}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(s?1:-1):s?0:a-1;return o<0?o=e=="page"?0:a-1:o>=a&&(o=e=="page"?a-1:0),t.dispatch({effects:Gp.of(o)}),!0}}const CE=s=>{let e=s.state.field(Js,!1);return s.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<s.state.facet(vs).interactionDelay?!1:Jp(s,e.open.options[e.open.selected])},Hu=s=>s.state.field(Js,!1)?(s.dispatch({effects:Dh.of(!0)}),!0):!1,PE=s=>{let e=s.state.field(Js,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(s.dispatch({effects:ll.of(null)}),!0)};class TE{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const QE=50,$E=1e3,jE=is.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of s.state.field(Js).active)e.isPending&&this.startQuery(e)}update(s){let e=s.state.field(Js),t=s.state.facet(vs);if(!s.selectionSet&&!s.docChanged&&s.startState.field(Js)==e)return;let r=s.transactions.some(n=>{let a=ew(n,t);return a&8||(n.selection||n.docChanged)&&!(a&3)});for(let n=0;n<this.running.length;n++){let a=this.running[n];if(r||a.context.abortOnDocChange&&s.docChanged||a.updates.length+s.transactions.length>QE&&Date.now()-a.time>$E){for(let o of a.context.abortListeners)try{o()}catch(l){tr(this.view.state,l)}a.context.abortListeners=null,this.running.splice(n--,1)}else a.updates.push(...s.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),s.transactions.some(n=>n.effects.some(a=>a.is(Dh)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(n=>n.isPending&&!this.running.some(a=>a.active.source==n.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let n of s.transactions)n.isUserEvent("input.type")?this.composing=2:this.composing==2&&n.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:s}=this.view,e=s.field(Js);for(let t of e.active)t.isPending&&!this.running.some(r=>r.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(vs).updateSyncTime))}startQuery(s){let{state:e}=this.view,t=Zn(e),r=new Up(e,t,s.explicit,this.view),i=new TE(s,r);this.running.push(i),Promise.resolve(s.source(r)).then(n=>{i.context.aborted||(i.done=n||null,this.scheduleAccept())},n=>{this.view.dispatch({effects:ll.of(null)}),tr(this.view.state,n)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(vs).updateSyncTime))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(vs),r=this.view.state.field(Js);for(let i=0;i<this.running.length;i++){let n=this.running[i];if(n.done===void 0)continue;if(this.running.splice(i--,1),n.done){let o=Zn(n.updates.length?n.updates[0].startState:this.view.state),l=Math.min(o,n.done.from+(n.active.explicit?0:1)),h=new jo(n.active.source,n.active.explicit,l,n.done,n.done.from,(s=n.done.to)!==null&&s!==void 0?s:o);for(let u of n.updates)h=h.update(u,t);if(h.hasResult()){e.push(h);continue}}let a=r.active.find(o=>o.source==n.active.source);if(a&&a.isPending)if(n.done==null){let o=new Cr(n.active.source,0);for(let l of n.updates)o=o.update(l,t);o.isPending||e.push(o)}else this.startQuery(a)}(e.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:Kp.of(e)})}},{eventHandlers:{blur(s){let e=this.view.state.field(Js,!1);if(e&&e.tooltip&&this.view.state.facet(vs).closeOnBlur){let t=e.open&&M1(this.view,e.open.tooltip);(!t||!t.dom.contains(s.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ll.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Dh.of(!1)}),20),this.composing=0}}}),RE=typeof navigator=="object"&&/Win/.test(navigator.platform),EE=ki.highest(We.domEventHandlers({keydown(s,e){let t=e.state.field(Js,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||s.key.length>1||s.ctrlKey&&!(RE&&s.altKey)||s.metaKey)return!1;let r=t.open.options[t.open.selected],i=t.active.find(a=>a.source==r.source),n=r.completion.commitCharacters||i.result.commitCharacters;return n&&n.indexOf(s.key)>-1&&Jp(e,r),!1}})),tw=We.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class AE{constructor(e,t,r,i){this.field=e,this.line=t,this.from=r,this.to=i}}class eg{constructor(e,t,r){this.field=e,this.from=t,this.to=r}map(e){let t=e.mapPos(this.from,-1,Ts.TrackDel),r=e.mapPos(this.to,1,Ts.TrackDel);return t==null||r==null?null:new eg(this.field,t,r)}}let ME=class sw{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let r=[],i=[t],n=e.doc.lineAt(t),a=/^\s*/.exec(n.text)[0];for(let l of this.lines){if(r.length){let h=a,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)h+=e.facet(Vo);i.push(t+h.length-u),l=h+l.slice(u)}r.push(l),t+=l.length+1}let o=this.fieldPositions.map(l=>new eg(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(e){let t=[],r=[],i=[],n;for(let a of e.split(/\r\n?|\n/)){for(;n=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(a);){let o=n[1]?+n[1]:null,l=n[2]||n[3]||"",h=-1;o===0&&(o=1e9);let u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<t.length;d++)(o!=null?t[d].seq==o:u&&t[d].name==u)&&(h=d);if(h<0){let d=0;for(;d<t.length&&(o==null||t[d].seq!=null&&t[d].seq<o);)d++;t.splice(d,0,{seq:o,name:u}),h=d;for(let f of i)f.field>=h&&f.field++}for(let d of i)if(d.line==r.length&&d.from>n.index){let f=n[2]?3+(n[1]||"").length:2;d.from-=f,d.to-=f}i.push(new AE(h,r.length,n.index,n.index+u.length)),a=a.slice(0,n.index)+l+a.slice(n.index+n[0].length)}a=a.replace(/\\([{}])/g,(o,l,h)=>{for(let u of i)u.line==r.length&&u.from>h&&(u.from--,u.to--);return l}),r.push(a)}return new sw(r,i)}},LE=ht.widget({widget:new class extends Nr{toDOM(){let s=document.createElement("span");return s.className="cm-snippetFieldPosition",s}ignoreEvent(){return!1}}}),NE=ht.mark({class:"cm-snippetField"});class Ho{constructor(e,t){this.ranges=e,this.active=t,this.deco=ht.set(e.map(r=>(r.from==r.to?LE:NE).range(r.from,r.to)),!0)}map(e){let t=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;t.push(i)}return new Ho(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(r=>r.field==this.active&&r.from<=t.from&&r.to>=t.to))}}const $l=xt.define({map(s,e){return s&&s.map(e)}}),DE=xt.define(),cl=$s.define({create(){return null},update(s,e){for(let t of e.effects){if(t.is($l))return t.value;if(t.is(DE)&&s)return new Ho(s.ranges,t.value)}return s&&e.docChanged&&(s=s.map(e.changes)),s&&e.selection&&!s.selectionInsideField(e.selection)&&(s=null),s},provide:s=>We.decorations.from(s,e=>e?e.deco:ht.none)});function tg(s,e){return fe.create(s.filter(t=>t.field==e).map(t=>fe.range(t.from,t.to)))}function IE(s){let e=ME.parse(s);return(t,r,i,n)=>{let{text:a,ranges:o}=e.instantiate(t.state,i),{main:l}=t.state.selection,h={changes:{from:i,to:n==l.from?l.to:n,insert:It.of(a)},scrollIntoView:!0,annotations:r?[Yp.of(r),ds.userEvent.of("input.complete")]:void 0};if(o.length&&(h.selection=tg(o,0)),o.some(u=>u.field>0)){let u=new Ho(o,0),d=h.effects=[$l.of(u)];t.state.field(cl,!1)===void 0&&d.push(xt.appendConfig.of([cl,qE,ZE,tw]))}t.dispatch(t.state.update(h))}}function rw(s){return({state:e,dispatch:t})=>{let r=e.field(cl,!1);if(!r||s<0&&r.active==0)return!1;let i=r.active+s,n=s>0&&!r.ranges.some(a=>a.field==i+s);return t(e.update({selection:tg(r.ranges,i),effects:$l.of(n?null:new Ho(r.ranges,i)),scrollIntoView:!0})),!0}}const BE=({state:s,dispatch:e})=>s.field(cl,!1)?(e(s.update({effects:$l.of(null)})),!0):!1,WE=rw(1),XE=rw(-1),zE=[{key:"Tab",run:WE,shift:XE},{key:"Escape",run:BE}],ob=Ge.define({combine(s){return s.length?s[0]:zE}}),qE=ki.highest(Zo.compute([ob],s=>s.facet(ob)));function ts(s,e){return{...e,apply:IE(s)}}const ZE=We.domEventHandlers({mousedown(s,e){let t=e.state.field(cl,!1),r;if(!t||(r=e.posAtCoords({x:s.clientX,y:s.clientY}))==null)return!1;let i=t.ranges.find(n=>n.from<=r&&n.to>=r);return!i||i.field==t.active?!1:(e.dispatch({selection:tg(t.ranges,i.field),effects:$l.of(t.ranges.some(n=>n.field>i.field)?new Ho(t.ranges,i.field):null),scrollIntoView:!0}),!0)}}),hl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zn=xt.define({map(s,e){let t=e.mapPos(s,-1,Ts.TrackAfter);return t??void 0}}),sg=new class extends Gi{};sg.startSide=1;sg.endSide=-1;const iw=$s.define({create(){return Qt.empty},update(s,e){if(s=s.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);s=s.update({filter:r=>r>=t.from&&r<=t.to})}for(let t of e.effects)t.is(zn)&&(s=s.update({add:[sg.range(t.value,t.value+1)]}));return s}});function VE(){return[UE,iw]}const Yu="()[]{}<>«»»«[]{}";function nw(s){for(let e=0;e<Yu.length;e+=2)if(Yu.charCodeAt(e)==s)return Yu.charAt(e+1);return up(s<128?s:s+1)}function ow(s,e){return s.languageDataAt("closeBrackets",e)[0]||hl}const FE=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),UE=We.inputHandler.of((s,e,t,r)=>{if((FE?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let i=s.state.selection.main;if(r.length>2||r.length==2&&Hr(Ks(r,0))==1||e!=i.from||t!=i.to)return!1;let n=GE(s.state,r);return n?(s.dispatch(n),!0):!1}),HE=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let r=ow(s,s.selection.main.head).brackets||hl.brackets,i=null,n=s.changeByRange(a=>{if(a.empty){let o=KE(s.doc,a.head);for(let l of r)if(l==o&&cd(s.doc,a.head)==nw(Ks(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:fe.cursor(a.head-l.length)}}return{range:i=a}});return i||e(s.update(n,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},YE=[{key:"Backspace",run:HE}];function GE(s,e){let t=ow(s,s.selection.main.head),r=t.brackets||hl.brackets;for(let i of r){let n=nw(Ks(i,0));if(e==i)return n==i?tA(s,i,r.indexOf(i+i+i)>-1,t):JE(s,i,n,t.before||hl.before);if(e==n&&aw(s,s.selection.main.from))return eA(s,i,n)}return null}function aw(s,e){let t=!1;return s.field(iw).between(0,s.doc.length,r=>{r==e&&(t=!0)}),t}function cd(s,e){let t=s.sliceString(e,e+2);return t.slice(0,Hr(Ks(t,0)))}function KE(s,e){let t=s.sliceString(e-2,e);return Hr(Ks(t,0))==t.length?t:t.slice(1)}function JE(s,e,t,r){let i=null,n=s.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:zn.of(a.to+e.length),range:fe.range(a.anchor+e.length,a.head+e.length)};let o=cd(s.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:e+t,from:a.head},effects:zn.of(a.head+e.length),range:fe.cursor(a.head+e.length)}:{range:i=a}});return i?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function eA(s,e,t){let r=null,i=s.changeByRange(n=>n.empty&&cd(s.doc,n.head)==t?{changes:{from:n.head,to:n.head+t.length,insert:t},range:fe.cursor(n.head+t.length)}:r={range:n});return r?null:s.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function tA(s,e,t,r){let i=r.stringPrefixes||hl.stringPrefixes,n=null,a=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:zn.of(o.to+e.length),range:fe.range(o.anchor+e.length,o.head+e.length)};let l=o.head,h=cd(s.doc,l),u;if(h==e){if(ab(s,l))return{changes:{insert:e+e,from:l},effects:zn.of(l+e.length),range:fe.cursor(l+e.length)};if(aw(s,l)){let f=t&&s.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:fe.cursor(l+f.length)}}}else{if(t&&s.sliceDoc(l-2*e.length,l)==e+e&&(u=lb(s,l-2*e.length,i))>-1&&ab(s,u))return{changes:{insert:e+e+e+e,from:l},effects:zn.of(l+e.length),range:fe.cursor(l+e.length)};if(s.charCategorizer(l)(h)!=Jt.Word&&lb(s,l,i)>-1&&!sA(s,l,e,i))return{changes:{insert:e+e,from:l},effects:zn.of(l+e.length),range:fe.cursor(l+e.length)}}return{range:n=o}});return n?null:s.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function ab(s,e){let t=qt(s).resolveInner(e+1);return t.parent&&t.from==e}function sA(s,e,t,r){let i=qt(s).resolveInner(e,-1),n=r.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=s.sliceDoc(i.from,Math.min(i.to,i.from+t.length+n)),l=o.indexOf(t);if(!l||l>-1&&r.indexOf(o.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>t.length+l;){if(s.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let h=i.to==e&&i.parent;if(!h)break;i=h}return!1}function lb(s,e,t){let r=s.charCategorizer(e);if(r(s.sliceDoc(e-1,e))!=Jt.Word)return e;for(let i of t){let n=e-i.length;if(s.sliceDoc(n,e)==i&&r(s.sliceDoc(n-1,n))!=Jt.Word)return n}return-1}function rA(s={}){return[EE,Js,vs.of(s),jE,iA,tw]}const lw=[{key:"Ctrl-Space",run:Hu},{mac:"Alt-`",run:Hu},{mac:"Alt-i",run:Hu},{key:"Escape",run:PE},{key:"ArrowDown",run:Dc(!0)},{key:"ArrowUp",run:Dc(!1)},{key:"PageDown",run:Dc(!0,"page")},{key:"PageUp",run:Dc(!1,"page")},{key:"Enter",run:CE}],iA=ki.highest(Zo.computeN([vs],s=>s.facet(vs).defaultKeymap?[lw]:[]));class cb{constructor(e,t,r){this.from=e,this.to=t,this.diagnostic=r}}class Dn{constructor(e,t,r){this.diagnostics=e,this.panel=t,this.selected=r}static init(e,t,r){let i=r.facet(dl).markerFilter;i&&(e=i(e,r));let n=e.slice().sort((p,v)=>p.from-v.from||p.to-v.to),a=new vi,o=[],l=0,h=r.doc.iter(),u=0,d=r.doc.length;for(let p=0;;){let v=p==n.length?null:n[p];if(!v&&!o.length)break;let b,O;if(o.length)b=l,O=o.reduce((x,y)=>Math.min(x,y.to),v&&v.from>b?v.from:1e8);else{if(b=v.from,b>d)break;O=v.to,o.push(v),p++}for(;p<n.length;){let x=n[p];if(x.from==b&&(x.to>x.from||x.to==b))o.push(x),p++,O=Math.min(x.to,O);else{O=Math.min(x.from,O);break}}O=Math.min(O,d);let g=!1;if(o.some(x=>x.from==b&&(x.to==O||O==d))&&(g=b==O,!g&&O-b<10)){let x=b-(u+h.value.length);x>0&&(h.next(x),u=b);for(let y=b;;){if(y>=O){g=!0;break}if(!h.lineBreak&&u+h.value.length>y)break;y=u+h.value.length,u+=h.value.length,h.next()}}let m=OA(o);if(g)a.add(b,b,ht.widget({widget:new fA(m),diagnostics:o.slice()}));else{let x=o.reduce((y,k)=>k.markClass?y+" "+k.markClass:y,"");a.add(b,O,ht.mark({class:"cm-lintRange cm-lintRange-"+m+x,diagnostics:o.slice(),inclusiveEnd:o.some(y=>y.to>O)}))}if(l=O,l==d)break;for(let x=0;x<o.length;x++)o[x].to<=l&&o.splice(x--,1)}let f=a.finish();return new Dn(f,t,nn(f))}}function nn(s,e=null,t=0){let r=null;return s.between(t,1e9,(i,n,{spec:a})=>{if(!(e&&a.diagnostics.indexOf(e)<0))if(!r)r=new cb(i,n,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new cb(r.from,n,r.diagnostic)}}),r}function nA(s,e){let t=e.pos,r=e.end||t,i=s.state.facet(dl).hideOn(s,t,r);if(i!=null)return i;let n=s.startState.doc.lineAt(e.pos);return!!(s.effects.some(a=>a.is(cw))||s.changes.touchesRange(n.from,Math.max(n.to,r)))}function oA(s,e){return s.field(Or,!1)?e:e.concat(xt.appendConfig.of(xA))}const cw=xt.define(),rg=xt.define(),hw=xt.define(),Or=$s.define({create(){return new Dn(ht.none,null,null)},update(s,e){if(e.docChanged&&s.diagnostics.size){let t=s.diagnostics.map(e.changes),r=null,i=s.panel;if(s.selected){let n=e.changes.mapPos(s.selected.from,1);r=nn(t,s.selected.diagnostic,n)||nn(t,null,n)}!t.size&&i&&e.state.facet(dl).autoPanel&&(i=null),s=new Dn(t,i,r)}for(let t of e.effects)if(t.is(cw)){let r=e.state.facet(dl).autoPanel?t.value.length?ul.open:null:s.panel;s=Dn.init(t.value,r,e.state)}else t.is(rg)?s=new Dn(s.diagnostics,t.value?ul.open:null,s.selected):t.is(hw)&&(s=new Dn(s.diagnostics,s.panel,t.value));return s},provide:s=>[sl.from(s,e=>e.panel),We.decorations.from(s,e=>e.diagnostics)]}),aA=ht.mark({class:"cm-lintRange cm-lintRange-active"});function lA(s,e,t){let{diagnostics:r}=s.state.field(Or),i,n=-1,a=-1;r.between(e-(t<0?1:0),e+(t>0?1:0),(l,h,{spec:u})=>{if(e>=l&&e<=h&&(l==h||(e>l||t>0)&&(e<h||t<0)))return i=u.diagnostics,n=l,a=h,!1});let o=s.state.facet(dl).tooltipFilter;return i&&o&&(i=o(i,s.state)),i?{pos:n,end:a,above:!0,create(){return{dom:cA(s,i)}}}:null}function cA(s,e){return Ft("ul",{class:"cm-tooltip-lint"},e.map(t=>uw(s,t,!1)))}const hA=s=>{let e=s.state.field(Or,!1);(!e||!e.panel)&&s.dispatch({effects:oA(s.state,[rg.of(!0)])});let t=$p(s,ul.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},hb=s=>{let e=s.state.field(Or,!1);return!e||!e.panel?!1:(s.dispatch({effects:rg.of(!1)}),!0)},dA=s=>{let e=s.state.field(Or,!1);if(!e)return!1;let t=s.state.selection.main,r=nn(e.diagnostics,null,t.to+1);return!r&&(r=nn(e.diagnostics,null,0),!r||r.from==t.from&&r.to==t.to)?!1:(s.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),G5(s,r.from,1,{tooltip:fw,until:i=>i.docChanged||i.newSelection.main.head<r.from||i.newSelection.main.head>r.to}),!0)},uA=[{key:"Mod-Shift-m",run:hA,preventDefault:!0},{key:"F8",run:dA}],dl=Ge.define({combine(s){return{sources:s.map(e=>e.source).filter(e=>e!=null),...ii(s.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:db,tooltipFilter:db,needsRefresh:(e,t)=>e?t?r=>e(r)||t(r):e:t,hideOn:(e,t)=>e?t?(r,i,n)=>e(r,i,n)||t(r,i,n):e:t,autoPanel:(e,t)=>e||t})}}});function db(s,e){return s?e?(t,r)=>e(s(t,r),r):s:e}function dw(s){let e=[];if(s)e:for(let{name:t}of s){for(let r=0;r<t.length;r++){let i=t[r];if(/[a-zA-Z]/.test(i)&&!e.some(n=>n.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function uw(s,e,t){var r;let i=t?dw(e.actions):[];return Ft("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ft("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(s):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((n,a)=>{let o=!1,l=p=>{if(p.preventDefault(),o)return;o=!0;let v=nn(s.state.field(Or).diagnostics,e);v&&n.apply(s,v.from,v.to)},{name:h}=n,u=i[a]?h.indexOf(i[a]):-1,d=u<0?h:[h.slice(0,u),Ft("u",h.slice(u,u+1)),h.slice(u+1)],f=n.markClass?" "+n.markClass:"";return Ft("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${u<0?"":` (access key "${i[a]})"`}.`},d)}),e.source&&Ft("div",{class:"cm-diagnosticSource"},e.source))}class fA extends Nr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Ft("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ub{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=uw(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ul{constructor(e){this.view=e,this.items=[];let t=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)hb(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],a=dw(n.actions);for(let o=0;o<a.length;o++)if(a[o].toUpperCase().charCodeAt(0)==i.keyCode){let l=nn(this.view.state.field(Or).diagnostics,n);l&&n.actions[o].apply(e,l.from,l.to)}}else return;i.preventDefault()}},r=i=>{for(let n=0;n<this.items.length;n++)this.items[n].dom.contains(i.target)&&this.moveSelection(n)};this.list=Ft("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:r}),this.dom=Ft("div",{class:"cm-panel-lint"},this.list,Ft("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>hb(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Or).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Or),r=0,i=!1,n=null,a=new Set;for(e.between(0,this.view.state.doc.length,(o,l,{spec:h})=>{for(let u of h.diagnostics){if(a.has(u))continue;a.add(u);let d=-1,f;for(let p=r;p<this.items.length;p++)if(this.items[p].diagnostic==u){d=p;break}d<0?(f=new ub(this.view,u),this.items.splice(r,0,f),i=!0):(f=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),n=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new ub(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let h=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/h:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)t();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Or),r=nn(t.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:hw.of(r)})}static open(e){return new ul(e)}}function mA(s,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(s)}</svg>')`}function Ic(s){return mA(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const pA=We.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ic("#f11")},".cm-lintRange-warning":{backgroundImage:Ic("orange")},".cm-lintRange-info":{backgroundImage:Ic("#999")},".cm-lintRange-hint":{backgroundImage:Ic("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function gA(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function OA(s){let e="hint",t=1;for(let r of s){let i=gA(r.severity);i>t&&(t=i,e=r.severity)}return e}const fw=Y5(lA,{hideOn:nA}),xA=[Or,We.decorations.compute([Or],s=>{let{selected:e,panel:t}=s.field(Or);return!e||!t||e.from==e.to?ht.none:ht.set([aA.range(e.from,e.to)])}),fw,pA];var fb=function(e){e===void 0&&(e={});var t=e,r=t.crosshairCursor,i=r===void 0?!1:r,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(YE)),e.defaultKeymap!==!1&&(n=n.concat(RR)),e.searchKeymap!==!1&&(n=n.concat(nE)),e.historyKeymap!==!1&&(n=n.concat(Ij)),e.foldKeymap!==!1&&(n=n.concat(ej)),e.completionKeymap!==!1&&(n=n.concat(lw)),e.lintKeymap!==!1&&(n=n.concat(uA));var a=[];return e.lineNumbers!==!1&&a.push(h$()),e.highlightActiveLineGutter!==!1&&a.push(f$()),e.highlightSpecialChars!==!1&&a.push(k5()),e.history!==!1&&a.push($j()),e.foldGutter!==!1&&a.push(ij()),e.drawSelection!==!1&&a.push(f5()),e.dropCursor!==!1&&a.push(b5()),e.allowMultipleSelections!==!1&&a.push($t.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&a.push(V$()),e.syntaxHighlighting!==!1&&a.push(oS(lj,{fallback:!0})),e.bracketMatching!==!1&&a.push(pj()),e.closeBrackets!==!1&&a.push(VE()),e.autocompletion!==!1&&a.push(rA()),e.rectangularSelection!==!1&&a.push(I5()),i!==!1&&a.push(X5()),e.highlightActiveLine!==!1&&a.push(j5()),e.highlightSelectionMatches!==!1&&a.push(DR()),e.tabSize&&typeof e.tabSize=="number"&&a.push(Vo.of(" ".repeat(e.tabSize))),a.concat([Zo.of(n.flat())]).filter(Boolean)};const bA="#e5c07b",mb="#e06c75",vA="#56b6c2",yA="#ffffff",rh="#abb2bf",Nm="#7d8799",SA="#61afef",wA="#98c379",pb="#d19a66",_A="#c678dd",kA="#21252b",gb="#2c313a",Ob="#282c34",Gu="#353a42",CA="#3E4451",xb="#528bff",PA=We.theme({"&":{color:rh,backgroundColor:Ob},".cm-content":{caretColor:xb},".cm-cursor, .cm-dropCursor":{borderLeftColor:xb},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:CA},".cm-panels":{backgroundColor:kA,color:rh},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ob,color:Nm,border:"none"},".cm-activeLineGutter":{backgroundColor:gb},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Gu},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Gu,borderBottomColor:Gu},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:gb,color:rh}}},{dark:!0}),TA=Pl.define([{tag:L.keyword,color:_A},{tag:[L.name,L.deleted,L.character,L.propertyName,L.macroName],color:mb},{tag:[L.function(L.variableName),L.labelName],color:SA},{tag:[L.color,L.constant(L.name),L.standard(L.name)],color:pb},{tag:[L.definition(L.name),L.separator],color:rh},{tag:[L.typeName,L.className,L.number,L.changed,L.annotation,L.modifier,L.self,L.namespace],color:bA},{tag:[L.operator,L.operatorKeyword,L.url,L.escape,L.regexp,L.link,L.special(L.string)],color:vA},{tag:[L.meta,L.comment],color:Nm},{tag:L.strong,fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.link,color:Nm,textDecoration:"underline"},{tag:L.heading,fontWeight:"bold",color:mb},{tag:[L.atom,L.bool,L.special(L.variableName)],color:pb},{tag:[L.processingInstruction,L.string,L.inserted],color:wA},{tag:L.invalid,color:yA}]),mw=[PA,oS(TA)];var QA=We.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),$A=function(e){e===void 0&&(e={});var t=e,r=t.indentWithTab,i=r===void 0?!0:r,n=t.editable,a=n===void 0?!0:n,o=t.readOnly,l=o===void 0?!1:o,h=t.theme,u=h===void 0?"light":h,d=t.placeholder,f=d===void 0?"":d,p=t.basicSetup,v=p===void 0?!0:p,b=[];switch(i&&b.unshift(Zo.of([ER])),v&&(typeof v=="boolean"?b.unshift(fb()):b.unshift(fb(v))),f&&b.unshift(M5(f)),u){case"light":b.push(QA);break;case"dark":b.push(mw);break;case"none":break;default:b.push(u);break}return a===!1&&b.push(We.editable.of(!1)),l&&b.push($t.readOnly.of(!0)),[...b]},jA=s=>({line:s.state.doc.lineAt(s.state.selection.main.from),lineCount:s.state.doc.lines,lineBreak:s.state.lineBreak,length:s.state.doc.length,readOnly:s.state.readOnly,tabSize:s.state.tabSize,selection:s.state.selection,selectionAsSingle:s.state.selection.asSingle().main,ranges:s.state.selection.ranges,selectionCode:s.state.sliceDoc(s.state.selection.main.from,s.state.selection.main.to),selections:s.state.selection.ranges.map(e=>s.state.sliceDoc(e.from,e.to)),selectedText:s.state.selection.ranges.some(e=>!e.empty)});class RA{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class bb{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Ku=null,EA=()=>typeof window>"u"?new bb:(Ku||(Ku=new bb),Ku),AA=We.theme({"& .cm-scroller":{height:"100% !important"}}),vb=null,Ju=null;function MA(s,e,t,r,i,n){if(!s&&!e&&!t&&!r&&!i&&!n)return null;var a=JSON.stringify({height:s,minHeight:e,maxHeight:t,width:r,minWidth:i,maxWidth:n});return a===vb||(vb=a,Ju=We.theme({"&":{height:s,minHeight:e,maxHeight:t,width:r,minWidth:i,maxWidth:n}})),Ju}var yb=ri.define(),LA=200,NA=[];function DA(s){var e=s.value,t=s.selection,r=s.onChange,i=s.onStatistics,n=s.onCreateEditor,a=s.onUpdate,o=s.extensions,l=o===void 0?NA:o,h=s.autoFocus,u=s.theme,d=u===void 0?"light":u,f=s.height,p=f===void 0?null:f,v=s.minHeight,b=v===void 0?null:v,O=s.maxHeight,g=O===void 0?null:O,m=s.width,x=m===void 0?null:m,y=s.minWidth,k=y===void 0?null:y,C=s.maxWidth,P=C===void 0?null:C,_=s.placeholder,Q=_===void 0?"":_,E=s.editable,A=E===void 0?!0:E,N=s.readOnly,R=N===void 0?!1:N,W=s.indentWithTab,H=W===void 0?!0:W,Z=s.basicSetup,B=Z===void 0?!0:Z,K=s.root,$=s.initialState,I=w.useState(),X=I[0],q=I[1],ie=w.useState(),pe=ie[0],$e=ie[1],re=w.useState(),U=re[0],M=re[1],te=w.useState(()=>({current:null}))[0],Y=w.useState(()=>({current:null}))[0],ae=MA(p,b,g,x,k,P),ee=We.updateListener.of(_e=>{if(_e.docChanged&&typeof r=="function"&&!_e.transactions.some(Fe=>Fe.annotation(yb))){te.current?te.current.reset():(te.current=new RA(()=>{if(Y.current){var Fe=Y.current;Y.current=null,Fe()}te.current=null},LA),EA().add(te.current));var De=_e.state.doc,Te=De.toString();r(Te,_e)}i&&i(jA(_e))}),me=$A({theme:d,editable:A,readOnly:R,placeholder:Q,indentWithTab:H,basicSetup:B}),Re=[ee,...ae?[ae]:[],AA,...me];return a&&typeof a=="function"&&Re.push(We.updateListener.of(a)),Re=Re.concat(l),w.useLayoutEffect(()=>{if(X&&!U){var _e={doc:e,selection:t,extensions:Re},De=$?$t.fromJSON($.json,_e,$.fields):$t.create(_e);if(M(De),!pe){var Te=new We({state:De,parent:X,root:K});$e(Te),n&&n(Te,De)}}return()=>{pe&&(M(void 0),$e(void 0))}},[X,U]),w.useEffect(()=>{s.container&&q(s.container)},[s.container]),w.useEffect(()=>()=>{pe&&(pe.destroy(),$e(void 0)),te.current&&(te.current.cancel(),te.current=null)},[pe]),w.useEffect(()=>{h&&pe&&pe.focus()},[h,pe]),w.useEffect(()=>{pe&&pe.dispatch({effects:xt.reconfigure.of(Re)})},[d,l,p,b,g,x,k,P,Q,A,R,H,B,r,a]),w.useEffect(()=>{if(e!==void 0){var _e=pe?pe.state.doc.toString():"";if(pe&&e!==_e){var De=te.current&&!te.current.isDone,Te=()=>{pe&&e!==pe.state.doc.toString()&&pe.dispatch({changes:{from:0,to:pe.state.doc.toString().length,insert:e||""},annotations:[yb.of(!0)]})};De?Y.current=Te:Te()}}},[e,pe]),{state:U,setState:M,view:pe,setView:$e,container:X,setContainer:q}}var IA=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],pw=w.forwardRef((s,e)=>{var t=s.className,r=s.value,i=r===void 0?"":r,n=s.selection,a=s.extensions,o=a===void 0?[]:a,l=s.onChange,h=s.onStatistics,u=s.onCreateEditor,d=s.onUpdate,f=s.autoFocus,p=s.theme,v=p===void 0?"light":p,b=s.height,O=s.minHeight,g=s.maxHeight,m=s.width,x=s.minWidth,y=s.maxWidth,k=s.basicSetup,C=s.placeholder,P=s.indentWithTab,_=s.editable,Q=s.readOnly,E=s.root,A=s.initialState,N=eT(s,IA),R=w.useRef(null),W=DA({root:E,value:i,autoFocus:f,theme:v,height:b,minHeight:O,maxHeight:g,width:m,minWidth:x,maxWidth:y,basicSetup:k,placeholder:C,indentWithTab:P,editable:_,readOnly:Q,selection:n,onChange:l,onStatistics:h,onCreateEditor:u,onUpdate:d,extensions:o,initialState:A}),H=W.state,Z=W.view,B=W.container,K=W.setContainer;w.useImperativeHandle(e,()=>({editor:R.current,state:H,view:Z}),[R,B,H,Z]);var $=w.useCallback(X=>{R.current=X,K(X)},[K]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var I=typeof v=="string"?"cm-theme-"+v:"cm-theme";return c.jsx("div",qf({ref:$,className:""+I+(t?" "+t:"")},N))});pw.displayName="CodeMirror";var Sb={};class Bh{constructor(e,t,r,i,n,a,o,l,h,u=0,d){this.p=e,this.stack=t,this.state=r,this.reducePos=i,this.pos=n,this.score=a,this.buffer=o,this.bufferBase=l,this.curContext=h,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,r=0){let i=e.parser.context;return new Bh(e,[],t,r,r,0,[],0,i?new wb(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let r=e>>19,i=e&65535,{parser:n}=this.p,a=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),o=n.dynamicPrecedence(i);if(o&&(this.score+=o),r==0){i<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,i,!0),this.reducePos),i<n.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,a?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from;i<n.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-h;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[i])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-d;if(i<n.minRepeatTerm||e&131072){let p=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,h,p,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let p=this.stack[l-3];this.state=n.getGoto(p,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,h)}storeNode(e,t,r,i=4,n=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let a=this.buffer.length;if(a>0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==r)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=r;return}}}if(!n||this.pos==r)this.buffer.push(e,t,r,i);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let o=!1;for(let l=a;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){o=!0;break}if(o)for(;a>0&&this.buffer[a-2]>r;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,i>4&&(i-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=r,this.buffer[a+3]=i}}shift(e,t,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let n=e,{parser:a}=this.p;this.pos=i;let o=a.stateFlag(n,1);!o&&(i>r||t<=a.maxNode)&&(this.reducePos=i),this.pushState(n,o?r:Math.min(r,this.reducePos)),this.shiftContext(t,r),t<=a.maxNode&&this.buffer.push(t,r,i,4)}else this.pos=i,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,i,4)}apply(e,t,r,i){e&65536?this.reduce(e):this.shift(e,t,r,i)}useNode(e,t){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let r=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new Bh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,r?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new BA(this);;){let r=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(r==0)return!1;if((r&65536)==0)return!0;t.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let n=0,a;n<t.length;n+=2)(a=t[n+1])!=this.state&&this.p.parser.hasAction(a,e)&&i.push(t[n],a);if(this.stack.length<120)for(let n=0;i.length<8&&n<t.length;n+=2){let a=t[n+1];i.some((o,l)=>l&1&&o==a)||i.push(t[n],a)}t=i}let r=[];for(let i=0;i<t.length&&r.length<4;i+=2){let n=t[i+1];if(n==this.state)continue;let a=this.split();a.pushState(n,this.pos),a.storeNode(0,a.pos,a.pos,4,!0),a.shiftContext(t[i],this.pos),a.reducePos=this.pos,a.score-=200,r.push(a)}return r}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let r=t>>19,i=t&65535,n=this.stack.length-r*3;if(n<0||e.getGoto(this.stack[n],i,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],r=(i,n)=>{if(!t.includes(i))return t.push(i),e.allActions(i,a=>{if(!(a&393216))if(a&65536){let o=(a>>19)-n;if(o>1){let l=a&65535,h=this.stack.length-o*3;if(h>=0&&e.getGoto(this.stack[h],l,!1)>=0)return o<<19|65536|l}}else{let o=r(a,n+1);if(o!=null)return o}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new wb(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class wb{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class BA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class Wh{constructor(e,t,r){this.stack=e,this.pos=t,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Wh(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Wh(this.stack,this.pos,this.index)}}function Da(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let r=0,i=0;r<s.length;){let n=0;for(;;){let a=s.charCodeAt(r++),o=!1;if(a==126){n=65535;break}a>=92&&a--,a>=34&&a--;let l=a-32;if(l>=46&&(l-=46,o=!0),n+=l,o)break;n*=46}t?t[i++]=n:t=new e(n)}return t}class ih{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const _b=new ih;class WA{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_b,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let r=this.range,i=this.rangeIndex,n=this.pos+e;for(;n<r.from;){if(!i)return null;let a=this.ranges[--i];n-=r.from-a.to,r=a}for(;t<0?n>r.to:n>=r.to;){if(i==this.ranges.length-1)return null;let a=this.ranges[++i];n+=a.from-r.to,r=a}return n}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,r,i;if(t>=0&&t<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(t);else{let n=this.resolveOffset(e,1);if(n==null)return-1;if(r=n,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let a=this.rangeIndex,o=this.range;for(;o.to<=r;)o=this.ranges[++a];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>o.to&&(this.chunk2=this.chunk2.slice(0,o.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,t=0){let r=t?this.resolveOffset(t,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=_b,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let r="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return r}}class Ro{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:r}=t.p;gw(this.data,e,t,this.id,r.data,r.tokenPrecTable)}}Ro.prototype.contextual=Ro.prototype.fallback=Ro.prototype.extend=!1;class Xh{constructor(e,t,r){this.precTable=t,this.elseToken=r,this.data=typeof e=="string"?Da(e):e}token(e,t){let r=e.pos,i=0;for(;;){let n=e.next<0,a=e.resolveOffset(1,1);if(gw(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||i++,a==null)break;e.reset(a,e.token)}i&&(e.reset(r,e.token),e.acceptToken(this.elseToken,i))}}Xh.prototype.contextual=Ro.prototype.fallback=Ro.prototype.extend=!1;class ps{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function gw(s,e,t,r,i,n){let a=0,o=1<<r,{dialect:l}=t.p.parser;e:for(;(o&s[a])!=0;){let h=s[a+1];for(let p=a+3;p<h;p+=2)if((s[p+1]&o)>0){let v=s[p];if(l.allows(v)&&(e.token.value==-1||e.token.value==v||XA(v,e.token.value,i,n))){e.acceptToken(v);break}}let u=e.next,d=0,f=s[a+2];if(e.next<0&&f>d&&s[h+f*3-3]==65535){a=s[h+f*3-1];continue e}for(;d<f;){let p=d+f>>1,v=h+p+(p<<1),b=s[v],O=s[v+1]||65536;if(u<b)f=p;else if(u>=O)d=p+1;else{a=s[v+2],e.advance();continue e}}break}}function kb(s,e,t){for(let r=e,i;(i=s[r])!=65535;r++)if(i==t)return r-e;return-1}function XA(s,e,t,r){let i=kb(t,r,e);return i<0||kb(t,r,s)<i}const hr=typeof process<"u"&&Sb&&/\bparse\b/.test(Sb.LOG);let ef=null;function Cb(s,e,t){let r=s.cursor(Bt.IncludeAnonymous);for(r.moveTo(e);;)if(!(t<0?r.childBefore(e):r.childAfter(e)))for(;;){if((t<0?r.to<e:r.from>e)&&!r.type.isError)return t<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(s.length,Math.max(r.from+1,e+25));if(t<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return t<0?0:s.length}}let zA=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Cb(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Cb(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let r=this.trees[t],i=this.index[t];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=r.children[i],a=this.start[t]+r.positions[i];if(a>e)return this.nextStart=a,null;if(n instanceof Wt){if(a==e){if(a<this.safeFrom)return null;let o=a+n.length;if(o<=this.safeTo){let l=n.prop(bt.lookAhead);if(!l||o+l<this.fragment.to)return n}}this.index[t]++,a+n.length>=Math.max(this.safeFrom,e)&&(this.trees.push(n),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+n.length}}};class qA{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new ih)}getActions(e){let t=0,r=null,{parser:i}=e.p,{tokenizers:n}=i,a=i.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,l=0;for(let h=0;h<n.length;h++){if((1<<h&a)==0)continue;let u=n[h],d=this.tokens[h];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=a||d.context!=o)&&(this.updateCachedToken(d,u,e),d.mask=a,d.context=o),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!u.extend&&(r=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new ih,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,t=this.addActions(e,r.value,r.end,t)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ih,{pos:r,p:i}=e;return t.start=r,t.end=Math.min(r+1,i.stream.end),t.value=r==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,r){let i=this.stream.clipPos(r.pos);if(t.token(this.stream.reset(i,e),r),e.value>-1){let{parser:n}=r.p;for(let a=0;a<n.specialized.length;a++)if(n.specialized[a]==e.value){let o=n.specializers[a](this.stream.read(e.start,e.end),r);if(o>=0&&r.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,r,i){for(let n=0;n<i;n+=3)if(this.actions[n]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=r,i}addActions(e,t,r,i){let{state:n}=e,{parser:a}=e.p,{data:o}=a;for(let l=0;l<2;l++)for(let h=a.stateSlot(n,l?2:1);;h+=3){if(o[h]==65535)if(o[h+1]==1)h=gi(o,h+2);else{i==0&&o[h+1]==2&&(i=this.putAction(gi(o,h+2),t,r,i));break}o[h]==t&&(i=this.putAction(gi(o,h+1),t,r,i))}return i}}class ZA{constructor(e,t,r,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new WA(t,i),this.tokens=new qA(e,this.stream),this.topTerm=e.top[1];let{from:n}=i[0];this.stacks=[Bh.start(this,e.top[0],n)],this.fragments=r.length&&this.stream.end-n>e.bufferLength*4?new zA(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,r=this.stacks=[],i,n;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)r.push(o);else{if(this.advanceStack(o,r,e))continue;{i||(i=[],n=[]),i.push(o);let l=this.tokens.getMainToken(o);n.push(l.value,l.end)}}break}}if(!r.length){let a=i&&FA(i);if(a)return hr&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw hr&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&i){let a=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,n,r);if(a)return hr&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(r.length>a)for(r.sort((o,l)=>l.score-o.score);r.length>a;)r.pop();r.some(o=>o.reducePos>t)&&this.recovering--}else if(r.length>1){e:for(let a=0;a<r.length-1;a++){let o=r[a];for(let l=a+1;l<r.length;l++){let h=r[l];if(o.sameState(h)||o.buffer.length>500&&h.buffer.length>500)if((o.score-h.score||o.buffer.length-h.buffer.length)>0)r.splice(l--,1);else{r.splice(a--,1);continue e}}}r.length>12&&(r.sort((a,o)=>o.score-a.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let a=1;a<r.length;a++)r[a].pos<this.minStackPos&&(this.minStackPos=r[a].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,r){let i=e.pos,{parser:n}=this,a=hr?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,u=h?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?n.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!h||(d.prop(bt.contextHash)||0)==u))return e.useNode(d,f),hr&&console.log(a+this.stackID(e)+` (via reuse of ${n.getName(d.type.id)})`),!0;if(!(d instanceof Wt)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof Wt&&d.positions[0]==0)d=p;else break}}let o=n.stateSlot(e.state,4);if(o>0)return e.reduce(o),hr&&console.log(a+this.stackID(e)+` (via always-reduce ${n.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let h=0;h<l.length;){let u=l[h++],d=l[h++],f=l[h++],p=h==l.length||!r,v=p?e:e.split(),b=this.tokens.mainToken;if(v.apply(u,d,b?b.start:v.pos,f),hr&&console.log(a+this.stackID(v)+` (via ${(u&65536)==0?"shift":`reduce of ${n.getName(u&65535)}`} for ${n.getName(d)} @ ${i}${v==e?"":", split"})`),p)return!0;v.pos>i?t.push(v):r.push(v)}return!1}advanceFully(e,t){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return Pb(e,t),!0}}runRecovery(e,t,r){let i=null,n=!1;for(let a=0;a<e.length;a++){let o=e[a],l=t[a<<1],h=t[(a<<1)+1],u=hr?this.stackID(o)+" -> ":"";if(o.deadEnd&&(n||(n=!0,o.restart(),hr&&console.log(u+this.stackID(o)+" (restarted)"),this.advanceFully(o,r))))continue;let d=o.split(),f=u;for(let p=0;p<10&&d.forceReduce()&&(hr&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));p++)hr&&(f=this.stackID(d)+" -> ");for(let p of o.recoverByInsert(l))hr&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,r);this.stream.end>o.pos?(h==o.pos&&(h++,l=0),o.recoverByDelete(l,h),hr&&console.log(u+this.stackID(o)+` (via recover-delete ${this.parser.getName(l)})`),Pb(o,r)):(!i||i.score<d.score)&&(i=d)}return i}stackToTree(e){return e.close(),Wt.build({buffer:Wh.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(ef||(ef=new WeakMap)).get(e);return t||ef.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Pb(s,e){for(let t=0;t<e.length;t++){let r=e[t];if(r.pos==s.pos&&r.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}class VA{constructor(e,t,r){this.source=e,this.flags=t,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}const tf=s=>s;class hd{constructor(e){this.start=e.start,this.shift=e.shift||tf,this.reduce=e.reduce||tf,this.reuse=e.reuse||tf,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class _i extends Mp{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let o=0;o<e.repeatNodeCount;o++)t.push("");let r=Object.keys(e.topRules).map(o=>e.topRules[o][1]),i=[];for(let o=0;o<t.length;o++)i.push([]);function n(o,l,h){i[o].push([l,l.deserialize(String(h))])}if(e.nodeProps)for(let o of e.nodeProps){let l=o[0];typeof l=="string"&&(l=bt[l]);for(let h=1;h<o.length;){let u=o[h++];if(u>=0)n(u,l,o[h++]);else{let d=o[h+-u];for(let f=-u;f>0;f--)n(o[h++],l,d);h++}}}this.nodeSet=new kl(t.map((o,l)=>ms.define({name:l>=this.minRepeatTerm?void 0:o,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=W1;let a=Da(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let o=0;o<this.specializerSpecs.length;o++)this.specialized[o]=this.specializerSpecs[o].term;this.specializers=this.specializerSpecs.map(Tb),this.states=Da(e.states,Uint32Array),this.data=Da(e.stateData),this.goto=Da(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(o=>typeof o=="number"?new Ro(a,o):o),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,r){let i=new ZA(this,e,t,r);for(let n of this.wrappers)i=n(i,e,t,r);return i}getGoto(e,t,r=!1){let i=this.goto;if(t>=i[0])return-1;for(let n=i[t+1];;){let a=i[n++],o=a&1,l=i[n++];if(o&&r)return l;for(let h=n+(a>>1);n<h;n++)if(i[n]==e)return l;if(o)return-1}}hasAction(e,t){let r=this.data;for(let i=0;i<2;i++)for(let n=this.stateSlot(e,i?2:1),a;;n+=3){if((a=r[n])==65535)if(r[n+1]==1)a=r[n=gi(r,n+2)];else{if(r[n+1]==2)return gi(r,n+2);break}if(a==t||a==0)return gi(r,n+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,r=>r==t?!0:null)}allActions(e,t){let r=this.stateSlot(e,4),i=r?t(r):void 0;for(let n=this.stateSlot(e,1);i==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=gi(this.data,n+2);else break;i=t(gi(this.data,n+1))}return i}nextStates(e){let t=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=gi(this.data,r+2);else break;if((this.data[r+2]&1)==0){let i=this.data[r+1];t.some((n,a)=>a&1&&n==i)||t.push(this.data[r],i)}}return t}configure(e){let t=Object.assign(Object.create(_i.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=r}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(n=>n.from==r);return i?i.to:r})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((r,i)=>{let n=e.specializers.find(o=>o.from==r.external);if(!n)return r;let a=Object.assign(Object.assign({},r),{external:n.to});return t.specializers[i]=Tb(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),r=t.map(()=>!1);if(e)for(let n of e.split(" ")){let a=t.indexOf(n);a>=0&&(r[a]=!0)}let i=null;for(let n=0;n<t.length;n++)if(!r[n])for(let a=this.dialects[t[n]],o;(o=this.data[a++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[o]=1;return new VA(e,r,i)}static deserialize(e){return new _i(e)}}function gi(s,e){return s[e]|s[e+1]<<16}function FA(s){let e=null;for(let t of s){let r=t.p.stoppedAt;(t.pos==t.p.stream.end||r!=null&&t.pos>r)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Tb(s){if(s.external){let e=s.extend?1:0;return(t,r)=>s.external(t,r)<<1|e}return s.get}const UA=316,HA=317,Qb=1,YA=2,GA=3,KA=4,JA=318,eM=320,tM=321,sM=5,rM=6,iM=0,Dm=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Ow=125,nM=59,Im=47,oM=42,aM=43,lM=45,cM=60,hM=44,dM=63,uM=46,fM=91,mM=new hd({start:!1,shift(s,e){return e==sM||e==rM||e==eM?s:e==tM},strict:!1}),pM=new ps((s,e)=>{let{next:t}=s;(t==Ow||t==-1||e.context)&&s.acceptToken(JA)},{contextual:!0,fallback:!0}),gM=new ps((s,e)=>{let{next:t}=s,r;Dm.indexOf(t)>-1||t==Im&&((r=s.peek(1))==Im||r==oM)||t!=Ow&&t!=nM&&t!=-1&&!e.context&&s.acceptToken(UA)},{contextual:!0}),OM=new ps((s,e)=>{s.next==fM&&!e.context&&s.acceptToken(HA)},{contextual:!0}),xM=new ps((s,e)=>{let{next:t}=s;if(t==aM||t==lM){if(s.advance(),t==s.next){s.advance();let r=!e.context&&e.canShift(Qb);s.acceptToken(r?Qb:YA)}}else t==dM&&s.peek(1)==uM&&(s.advance(),s.advance(),(s.next<48||s.next>57)&&s.acceptToken(GA))},{contextual:!0});function sf(s,e){return s>=65&&s<=90||s>=97&&s<=122||s==95||s>=192||!e&&s>=48&&s<=57}const bM=new ps((s,e)=>{if(s.next!=cM||!e.dialectEnabled(iM)||(s.advance(),s.next==Im))return;let t=0;for(;Dm.indexOf(s.next)>-1;)s.advance(),t++;if(sf(s.next,!0)){for(s.advance(),t++;sf(s.next,!1);)s.advance(),t++;for(;Dm.indexOf(s.next)>-1;)s.advance(),t++;if(s.next==hM)return;for(let r=0;;r++){if(r==7){if(!sf(s.next,!0))return;break}if(s.next!="extends".charCodeAt(r))break;s.advance(),t++}}s.acceptToken(KA,-t)}),vM=Ci({"get set async static":L.modifier,"for while do if else switch try catch finally return throw break continue default case defer":L.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":L.operatorKeyword,"let var const using function class extends":L.definitionKeyword,"import export from":L.moduleKeyword,"with debugger new":L.keyword,TemplateString:L.special(L.string),super:L.atom,BooleanLiteral:L.bool,this:L.self,null:L.null,Star:L.modifier,VariableName:L.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":L.function(L.variableName),VariableDefinition:L.definition(L.variableName),Label:L.labelName,PropertyName:L.propertyName,PrivatePropertyName:L.special(L.propertyName),"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),"FunctionDeclaration/VariableDefinition":L.function(L.definition(L.variableName)),"ClassDeclaration/VariableDefinition":L.definition(L.className),"NewExpression/VariableName":L.className,PropertyDefinition:L.definition(L.propertyName),PrivatePropertyDefinition:L.definition(L.special(L.propertyName)),UpdateOp:L.updateOperator,"LineComment Hashbang":L.lineComment,BlockComment:L.blockComment,Number:L.number,String:L.string,Escape:L.escape,ArithOp:L.arithmeticOperator,LogicOp:L.logicOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,RegExp:L.regexp,Equals:L.definitionOperator,Arrow:L.function(L.punctuation),": Spread":L.punctuation,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,"InterpolationStart InterpolationEnd":L.special(L.brace),".":L.derefOperator,", ;":L.separator,"@":L.meta,TypeName:L.typeName,TypeDefinition:L.definition(L.typeName),"type enum interface implements namespace module declare":L.definitionKeyword,"abstract global Privacy readonly override":L.modifier,"is keyof unique infer asserts":L.operatorKeyword,JSXAttributeValue:L.attributeValue,JSXText:L.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":L.angleBracket,"JSXIdentifier JSXNameSpacedName":L.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":L.attributeName,"JSXBuiltin/JSXIdentifier":L.standard(L.tagName)}),yM={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},SM={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},wM={__proto__:null,"<":193},_M=_i.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HO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X0rQ5c1SQ6u=OQ6{3QQ7Q3WQ7a3lQ7b=PQ7k=RQ7l=ZQ8k5wQ9X6sQ9]6|Q9g=[Q9m=eQ9n=fQ:o9_Q;W:ZQ;`:mQ<W#SR=v>SR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i<VR)f$dY!uQ'`-e1o5{Q'k!rS'u!v!yS'w!z5}S-t'l'mQ-v'nR3T-uT#kZ%eS#jZ%eS%km,oU(g#h#i#lS.Y(h(iQ.^(jQ0t+^Q3Y.ZU3Z.[.]._S7S3[3]R9`7Td#^W#W#Z%h(T(^*Y+Z.T/mr#gZm#h#i#l%e(h(i(j+^.Z.[.]._3[3]7TS*]$x*bQ/t*^Q2U,oQ2l-VQ4`/pQ6q2dQ7s4aQ9W6rT=m'X+[V#aW%h*YU#`W%h*YS(U#W(^U(Z#Z+Z/mS-['X+[T.O(T.TV'^!e%i*ZQ$lfR)x$qT)m$l)nR4V/UT*_$x*bT*h${*YQ0w+fQ1g,VQ3_.fQ5t1iQ6P1qQ7X3cQ8r6SQ9c7WQ:^8qQ:p9bQ;Z:`Q;c:rQ;n;[R;q;dnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&l!VR,h&itmOXst!U!V!Z#d%m&i&r&t&u&w,s,x2[2_R,o&oT%lm,oR1k,XR,g&gQ&U|S+}&V&WR1^,OR+s&PT&p!W&sT&q!W&sT2^,x2_",nodeNames:"⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:mM,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[vM],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&h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!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[gM,OM,xM,bM,2,3,4,5,6,7,8,9,10,11,12,13,14,pM,new Xh("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Xh("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:s=>yM[s]||-1},{term:343,get:s=>SM[s]||-1},{term:95,get:s=>wM[s]||-1}],tokenPrec:15201}),xw=[ts("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),ts("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),ts("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),ts("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),ts("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),ts(`try {
22
+ \${}
23
+ } catch (\${error}) {
24
+ \${}
25
+ }`,{label:"try",detail:"/ catch block",type:"keyword"}),ts("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),ts(`if (\${}) {
26
+ \${}
27
+ } else {
28
+ \${}
29
+ }`,{label:"if",detail:"/ else block",type:"keyword"}),ts(`class \${name} {
30
+ constructor(\${params}) {
31
+ \${}
32
+ }
33
+ }`,{label:"class",detail:"definition",type:"keyword"}),ts('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),ts('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],kM=xw.concat([ts("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),ts("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),ts("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),$b=new Ap,bw=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function ja(s){return(e,t)=>{let r=e.node.getChild("VariableDefinition");return r&&t(r,s),!0}}const CM=["FunctionDeclaration"],PM={FunctionDeclaration:ja("function"),ClassDeclaration:ja("class"),ClassExpression:()=>!0,EnumDeclaration:ja("constant"),TypeAliasDeclaration:ja("type"),NamespaceDeclaration:ja("namespace"),VariableDefinition(s,e){s.matchContext(CM)||e(s,"variable")},TypeDefinition(s,e){e(s,"type")},__proto__:null};function vw(s,e){let t=$b.get(e);if(t)return t;let r=[],i=!0;function n(a,o){let l=s.sliceString(a.from,a.to);r.push({label:l,type:o})}return e.cursor(Bt.IncludeAnonymous).iterate(a=>{if(i)i=!1;else if(a.name){let o=PM[a.name];if(o&&o(a,n)||bw.has(a.name))return!1}else if(a.to-a.from>8192){for(let o of vw(s,a.node))r.push(o);return!1}}),$b.set(e,r),r}const jb=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,yw=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function TM(s){let e=qt(s.state).resolveInner(s.pos,-1);if(yw.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&jb.test(s.state.sliceDoc(e.from,e.to));if(!t&&!s.explicit)return null;let r=[];for(let i=e;i;i=i.parent)bw.has(i.name)&&(r=r.concat(vw(s.state.doc,i)));return{options:r,from:t?e.from:s.pos,validFor:jb}}const si=wi.define({name:"javascript",parser:_M.configure({props:[on.add({IfStatement:Qo({except:/^\s*({|else\b)/}),TryStatement:Qo({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:q$,SwitchBody:s=>{let e=s.textAfter,t=/^\s*\}/.test(e),r=/^\s*(case|default)\b/.test(e);return s.baseIndent+(t?0:r?1:2)*s.unit},Block:sh({closing:"}"}),ArrowFunction:s=>s.baseIndent+s.unit,"TemplateString BlockComment":()=>null,"Statement Property":Qo({except:/^\s*{/}),JSXElement(s){let e=/^\s*<\//.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},JSXEscape(s){let e=/\s*\}/.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},"JSXOpenTag JSXSelfClosingTag"(s){return s.column(s.node.from)+s.unit}}),Pi.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":rd,BlockComment(s){return{from:s.from+2,to:s.to-2}},JSXElement(s){let e=s.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=s.lastChild;return{from:e.to,to:t.type.isError?s.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(s){var e;let t=(e=s.firstChild)===null||e===void 0?void 0:e.nextSibling,r=s.lastChild;return!t||t.type.isError?null:{from:t.to,to:r.type.isError?s.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Sw={test:s=>/^JSX/.test(s.name),facet:Lp({commentTokens:{block:{open:"{/*",close:"*/}"}}})},ww=si.configure({dialect:"ts"},"typescript"),_w=si.configure({dialect:"jsx",props:[Np.add(s=>s.isTop?[Sw]:void 0)]}),kw=si.configure({dialect:"jsx ts",props:[Np.add(s=>s.isTop?[Sw]:void 0)]},"typescript");let Cw=s=>({label:s,type:"keyword"});const Pw="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Cw),QM=Pw.concat(["declare","implements","private","protected","public"].map(Cw));function nh(s={}){let e=s.jsx?s.typescript?kw:_w:s.typescript?ww:si,t=s.typescript?kM.concat(QM):xw.concat(Pw);return new rn(e,[si.data.of({autocomplete:KS(yw,Hp(t))}),si.data.of({autocomplete:TM}),s.jsx?RM:[]])}function $M(s){for(;;){if(s.name=="JSXOpenTag"||s.name=="JSXSelfClosingTag"||s.name=="JSXFragmentTag")return s;if(s.name=="JSXEscape"||!s.parent)return null;s=s.parent}}function Rb(s,e,t=s.length){for(let r=e?.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return s.sliceString(r.from,Math.min(r.to,t));return""}const jM=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),RM=We.inputHandler.of((s,e,t,r,i)=>{if((jM?s.composing:s.compositionStarted)||s.state.readOnly||e!=t||r!=">"&&r!="/"||!si.isActiveAt(s.state,e,-1))return!1;let n=i(),{state:a}=n,o=a.changeByRange(l=>{var h;let{head:u}=l,d=qt(a).resolveInner(u-1,-1),f;if(d.name=="JSXStartTag"&&(d=d.parent),!(a.doc.sliceString(u-1,u)!=r||d.name=="JSXAttributeValue"&&d.to>u)){if(r==">"&&d.name=="JSXFragmentTag")return{range:l,changes:{from:u,insert:"</>"}};if(r=="/"&&d.name=="JSXStartCloseTag"){let p=d.parent,v=p.parent;if(v&&p.from==u-2&&((f=Rb(a.doc,v.firstChild,u))||((h=v.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let b=`${f}>`;return{range:fe.cursor(u+b.length,-1),changes:{from:u,insert:b}}}}else if(r==">"){let p=$M(d);if(p&&p.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(u,u+2))&&(f=Rb(a.doc,p,u)))return{range:l,changes:{from:u,insert:`</${f}>`}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),EM=Ci({String:L.string,Number:L.number,"True False":L.bool,PropertyName:L.propertyName,Null:L.null,", :":L.separator,"[ ]":L.squareBracket,"{ }":L.brace}),AM=_i.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[EM],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),MM=wi.define({name:"json",parser:AM.configure({props:[on.add({Object:Qo({except:/^\s*\}/}),Array:Qo({except:/^\s*\]/})}),Pi.add({"Object Array":rd})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function LM(){return new rn(MM)}const NM=1,Tw=194,Qw=195,DM=196,Eb=197,IM=198,BM=199,WM=200,XM=2,$w=3,Ab=201,zM=24,qM=25,ZM=49,VM=50,FM=55,UM=56,HM=57,YM=59,GM=60,KM=61,JM=62,eL=63,tL=65,sL=238,rL=71,iL=241,nL=242,oL=243,aL=244,lL=245,cL=246,hL=247,dL=248,jw=72,uL=249,fL=250,mL=251,pL=252,gL=253,OL=254,xL=255,bL=256,vL=73,yL=77,SL=263,wL=112,_L=130,kL=151,CL=152,PL=155,Yn=10,fl=13,ig=32,dd=9,ng=35,TL=40,QL=46,Bm=123,Mb=125,Rw=39,Ew=34,Lb=92,$L=111,jL=120,RL=78,EL=117,AL=85,ML=new Set([qM,ZM,VM,SL,tL,_L,UM,HM,sL,JM,eL,jw,vL,yL,GM,KM,kL,CL,PL,wL]);function rf(s){return s==Yn||s==fl}function nf(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}const LL=new ps((s,e)=>{let t;if(s.next<0)s.acceptToken(BM);else if(e.context.flags&oh)rf(s.next)&&s.acceptToken(IM,1);else if(((t=s.peek(-1))<0||rf(t))&&e.canShift(Eb)){let r=0;for(;s.next==ig||s.next==dd;)s.advance(),r++;(s.next==Yn||s.next==fl||s.next==ng)&&s.acceptToken(Eb,-r)}else rf(s.next)&&s.acceptToken(DM,1)},{contextual:!0}),NL=new ps((s,e)=>{let t=e.context;if(t.flags)return;let r=s.peek(-1);if(r==Yn||r==fl){let i=0,n=0;for(;;){if(s.next==ig)i++;else if(s.next==dd)i+=8-i%8;else break;s.advance(),n++}i!=t.indent&&s.next!=Yn&&s.next!=fl&&s.next!=ng&&(i<t.indent?s.acceptToken(Qw,-n):s.acceptToken(Tw))}}),oh=1,Aw=2,ui=4,fi=8,mi=16,pi=32;function ah(s,e,t){this.parent=s,this.indent=e,this.flags=t,this.hash=(s?s.hash+s.hash<<8:0)+e+(e<<4)+t+(t<<6)}const DL=new ah(null,0,0);function IL(s){let e=0;for(let t=0;t<s.length;t++)e+=s.charCodeAt(t)==dd?8-e%8:1;return e}const Nb=new Map([[iL,0],[nL,ui],[oL,fi],[aL,fi|ui],[lL,mi],[cL,mi|ui],[hL,mi|fi],[dL,mi|fi|ui],[uL,pi],[fL,pi|ui],[mL,pi|fi],[pL,pi|fi|ui],[gL,pi|mi],[OL,pi|mi|ui],[xL,pi|mi|fi],[bL,pi|mi|fi|ui]].map(([s,e])=>[s,e|Aw])),BL=new hd({start:DL,reduce(s,e,t,r){return s.flags&oh&&ML.has(e)||(e==rL||e==jw)&&s.flags&Aw?s.parent:s},shift(s,e,t,r){return e==Tw?new ah(s,IL(r.read(r.pos,t.pos)),0):e==Qw?s.parent:e==zM||e==FM||e==YM||e==$w?new ah(s,0,oh):Nb.has(e)?new ah(s,0,Nb.get(e)|s.flags&oh):s},hash(s){return s.hash}}),WL=new ps(s=>{for(let e=0;e<5;e++){if(s.next!="print".charCodeAt(e))return;s.advance()}if(!/\w/.test(String.fromCharCode(s.next)))for(let e=0;;e++){let t=s.peek(e);if(!(t==ig||t==dd)){t!=TL&&t!=QL&&t!=Yn&&t!=fl&&t!=ng&&s.acceptToken(NM);return}}}),XL=new ps((s,e)=>{let{flags:t}=e.context,r=t&ui?Ew:Rw,i=(t&fi)>0,n=!(t&mi),a=(t&pi)>0,o=s.pos;for(;!(s.next<0);)if(a&&s.next==Bm)if(s.peek(1)==Bm)s.advance(2);else{if(s.pos==o){s.acceptToken($w,1);return}break}else if(n&&s.next==Lb){if(s.pos==o){s.advance();let l=s.next;l>=0&&(s.advance(),zL(s,l)),s.acceptToken(XM);return}break}else if(s.next==Lb&&!n&&s.peek(1)>-1)s.advance(2);else if(s.next==r&&(!i||s.peek(1)==r&&s.peek(2)==r)){if(s.pos==o){s.acceptToken(Ab,i?3:1);return}break}else if(s.next==Yn){if(i)s.advance();else if(s.pos==o){s.acceptToken(Ab);return}break}else s.advance();s.pos>o&&s.acceptToken(WM)});function zL(s,e){if(e==$L)for(let t=0;t<2&&s.next>=48&&s.next<=55;t++)s.advance();else if(e==jL)for(let t=0;t<2&&nf(s.next);t++)s.advance();else if(e==EL)for(let t=0;t<4&&nf(s.next);t++)s.advance();else if(e==AL)for(let t=0;t<8&&nf(s.next);t++)s.advance();else if(e==RL&&s.next==Bm){for(s.advance();s.next>=0&&s.next!=Mb&&s.next!=Rw&&s.next!=Ew&&s.next!=Yn;)s.advance();s.next==Mb&&s.advance()}}const qL=Ci({'async "*" "**" FormatConversion FormatSpec':L.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":L.controlKeyword,"in not and or is del":L.operatorKeyword,"from def class global nonlocal lambda":L.definitionKeyword,import:L.moduleKeyword,"with as print":L.keyword,Boolean:L.bool,None:L.null,VariableName:L.variableName,"CallExpression/VariableName":L.function(L.variableName),"FunctionDefinition/VariableName":L.function(L.definition(L.variableName)),"ClassDefinition/VariableName":L.definition(L.className),PropertyName:L.propertyName,"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),Comment:L.lineComment,Number:L.number,String:L.string,FormatString:L.special(L.string),Escape:L.escape,UpdateOp:L.updateOperator,"ArithOp!":L.arithmeticOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,AssignOp:L.definitionOperator,Ellipsis:L.punctuation,At:L.meta,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,".":L.derefOperator,", ;":L.separator}),ZL={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},VL=_i.deserialize({version:14,states:"##jQ`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#En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zrR$TxQ%b!yQ%i!}Q%o#RQ'j${Q(V%eQ(Z%jQ(c%pQ(f%qQ*|(`Q,f*bQ-t,pQ.m-uR/].lQ$StQ(R%cR*s(SQ.l-sR/}/sR#QZR#V[R%Q!iQ%O!iV*c'm*d,g!Z!lQ!n#c#p$R$d$p$u$v$w$x$y$z%e%j%p%q&`'O'g(q(|)j*o*x+w,v0gR%T!kT#]^#_Q%x#[R,{+YQ(m%xS+_(n(oQ,}+`Q-x,{S.n-y-zR/^.oT+Z(k+]Q$`}Q&g$QQ)o'PR+{)pQ$XzQ)W&qR+i)XQ$XzQ&o$WQ)W&qR+i)XQ#khW$Vz$W&q)XQ$[{Q&r$ZZ)R&l)S+f+g-RR$^|R)c&wXlOn)t,PQ$f!RR'Q$gQ$m!UR'R$hR*X'_Q*V'_V-g,`-h.TQ.d-lQ/P.^R/Q._U.]-l.^._Q/U.aQ/b.tQ/g.zU/i.|/j/yQ/n/RQ/|/oQ0O/tU0Q/u0S0[Q0]0UQ0a0ZR0b0^R/T.`R/d.t",nodeNames:"⚠ print Escape { Comment Script AssignStatement * BinaryExpression BitOp BitOp BitOp BitOp ArithOp ArithOp @ ArithOp ** UnaryExpression ArithOp BitOp AwaitExpression await ) ( ParenthesizedExpression BinaryExpression or and CompareOp in not is UnaryExpression ConditionalExpression if else LambdaExpression lambda ParamList VariableName AssignOp , : NamedExpression AssignOp YieldExpression yield from TupleExpression ComprehensionExpression async for LambdaExpression ] [ ArrayExpression ArrayComprehensionExpression } { DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression CallExpression ArgList AssignOp MemberExpression . PropertyName Number String FormatString FormatReplacement FormatSelfDoc FormatConversion FormatSpec FormatReplacement FormatSelfDoc ContinuedString Ellipsis None Boolean TypeDef AssignOp UpdateStatement UpdateOp ExpressionStatement DeleteStatement del PassStatement pass BreakStatement break ContinueStatement continue ReturnStatement return YieldStatement PrintStatement RaiseStatement raise ImportStatement import as ScopeStatement global nonlocal AssertStatement assert TypeDefinition type TypeParamList TypeParam StatementGroup ; IfStatement Body elif WhileStatement while ForStatement TryStatement try except finally WithStatement with FunctionDefinition def ParamList AssignOp TypeDef ClassDefinition class DecoratedStatement Decorator At MatchStatement match MatchBody MatchClause case CapturePattern LiteralPattern ArithOp ArithOp AsPattern OrPattern LogicOp AttributePattern SequencePattern MappingPattern StarPattern ClassPattern PatternArgList KeywordPattern KeywordPattern Guard",maxTerm:277,context:BL,nodeProps:[["isolate",-5,4,71,72,73,77,""],["group",-15,6,85,87,88,90,92,94,96,98,99,100,102,105,108,110,"Statement Statement",-22,8,18,21,25,40,49,50,56,57,60,61,62,63,64,67,70,71,72,79,80,81,82,"Expression",-10,114,116,119,121,122,126,128,133,135,138,"Statement",-9,143,144,147,148,150,151,152,153,154,"Pattern"],["openedBy",23,"(",54,"[",58,"{"],["closedBy",24,")",55,"]",59,"}"]],propSources:[qL],skippedNodes:[0,4],repeatNodeCount:34,tokenData:"!2|~R!`OX%TXY%oY[%T[]%o]p%Tpq%oqr'ars)Yst*xtu%Tuv,dvw-hwx.Uxy/tyz0[z{0r{|2S|}2p}!O3W!O!P4_!P!Q:Z!Q!R;k!R![>_![!]Do!]!^Es!^!_FZ!_!`Gk!`!aHX!a!b%T!b!cIf!c!dJU!d!eK^!e!hJU!h!i!#f!i!tJU!t!u!,|!u!wJU!w!x!.t!x!}JU!}#O!0S#O#P&o#P#Q!0j#Q#R!1Q#R#SJU#S#T%T#T#UJU#U#VK^#V#YJU#Y#Z!#f#Z#fJU#f#g!,|#g#iJU#i#j!.t#j#oJU#o#p!1n#p#q!1s#q#r!2a#r#s!2f#s$g%T$g;'SJU;'S;=`KW<%lOJU`%YT&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T`%lP;=`<%l%To%v]&n`%c_OX%TXY%oY[%T[]%o]p%Tpq%oq#O%T#O#P&o#P#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To&tX&n`OY%TYZ%oZ]%T]^%o^#o%T#p#q%T#r;'S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~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[WL,NL,LL,XL,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:s=>ZL[s]||-1}],tokenPrec:7668}),Db=new Ap,Mw=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function Bc(s){return(e,t,r)=>{if(r)return!1;let i=e.node.getChild("VariableName");return i&&t(i,s),!0}}const FL={FunctionDefinition:Bc("function"),ClassDefinition:Bc("class"),ForStatement(s,e,t){if(t){for(let r=s.node.firstChild;r;r=r.nextSibling)if(r.name=="VariableName")e(r,"variable");else if(r.name=="in")break}},ImportStatement(s,e){var t,r;let{node:i}=s,n=((t=i.firstChild)===null||t===void 0?void 0:t.name)=="from";for(let a=i.getChild("import");a;a=a.nextSibling)a.name=="VariableName"&&((r=a.nextSibling)===null||r===void 0?void 0:r.name)!="as"&&e(a,n?"variable":"namespace")},AssignStatement(s,e){for(let t=s.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(s,e){for(let t=null,r=s.node.firstChild;r;r=r.nextSibling)r.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(r,"variable"),t=r},CapturePattern:Bc("variable"),AsPattern:Bc("variable"),__proto__:null};function Lw(s,e){let t=Db.get(e);if(t)return t;let r=[],i=!0;function n(a,o){let l=s.sliceString(a.from,a.to);r.push({label:l,type:o})}return e.cursor(Bt.IncludeAnonymous).iterate(a=>{if(a.name){let o=FL[a.name];if(o&&o(a,n,i)||!i&&Mw.has(a.name))return!1;i=!1}else if(a.to-a.from>8192){for(let o of Lw(s,a.node))r.push(o);return!1}}),Db.set(e,r),r}const Ib=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,Nw=["String","FormatString","Comment","PropertyName"];function UL(s){let e=qt(s.state).resolveInner(s.pos,-1);if(Nw.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Ib.test(s.state.sliceDoc(e.from,e.to));if(!t&&!s.explicit)return null;let r=[];for(let i=e;i;i=i.parent)Mw.has(i.name)&&(r=r.concat(Lw(s.state.doc,i)));return{options:r,from:t?e.from:s.pos,validFor:Ib}}const HL=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(s=>({label:s,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(s=>({label:s,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(s=>({label:s,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(s=>({label:s,type:"function"}))),YL=[ts("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),ts("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),ts("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),ts("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),ts(`if \${}:
34
+
35
+ `,{label:"if",detail:"block",type:"keyword"}),ts("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),ts("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),ts("import ${module}",{label:"import",detail:"statement",type:"keyword"}),ts("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],GL=KS(Nw,Hp(HL.concat(YL)));function of(s){let{node:e,pos:t}=s,r=s.lineIndent(t,-1),i=null;for(;;){let n=e.childBefore(t);if(n)if(n.name=="Comment")t=n.from;else if(n.name=="Body"||n.name=="MatchBody")s.baseIndentFor(n)+s.unit<=r&&(i=n),e=n;else if(n.name=="MatchClause")e=n;else if(n.type.is("Statement"))e=n;else break;else break}return i}function af(s,e){let t=s.baseIndentFor(e),r=s.lineAt(s.pos,-1),i=r.from+r.text.length;return/^\s*($|#)/.test(r.text)&&s.node.to<i+100&&!/\S/.test(s.state.sliceDoc(i,s.node.to))&&s.lineIndent(s.pos,-1)<=t||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(s.textAfter)&&s.lineIndent(s.pos,-1)>t?null:t+s.unit}const lf=wi.define({name:"python",parser:VL.configure({props:[on.add({Body:s=>{var e;let t=/^\s*(#|$)/.test(s.textAfter)&&of(s)||s.node;return(e=af(s,t))!==null&&e!==void 0?e:s.continue()},MatchBody:s=>{var e;let t=of(s);return(e=af(s,t||s.node))!==null&&e!==void 0?e:s.continue()},IfStatement:s=>/^\s*(else:|elif )/.test(s.textAfter)?s.baseIndent:s.continue(),"ForStatement WhileStatement":s=>/^\s*else:/.test(s.textAfter)?s.baseIndent:s.continue(),TryStatement:s=>/^\s*(except[ :]|finally:|else:)/.test(s.textAfter)?s.baseIndent:s.continue(),MatchStatement:s=>/^\s*case /.test(s.textAfter)?s.baseIndent+s.unit:s.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":sh({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":sh({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":sh({closing:"]"}),MemberExpression:s=>s.baseIndent+s.unit,"String FormatString":()=>null,Script:s=>{var e;let t=of(s);return(e=t&&af(s,t))!==null&&e!==void 0?e:s.continue()}}),Pi.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":rd,Body:(s,e)=>({from:s.from+1,to:s.to-(s.to==e.doc.length?0:1)}),"String FormatString":(s,e)=>({from:e.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function KL(){return new rn(lf,[lf.data.of({autocomplete:UL}),lf.data.of({autocomplete:GL})])}const JL=148,Bb=1,eN=149,tN=150,Dw=2,sN=151,rN=3,iN=4,Iw=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],nN=58,oN=40,Bw=95,aN=91,lh=45,lN=46,cN=35,hN=37,dN=38,uN=92,fN=10,mN=42;function ml(s){return s>=65&&s<=90||s>=97&&s<=122||s>=161}function og(s){return s>=48&&s<=57}function Wb(s){return og(s)||s>=97&&s<=102||s>=65&&s<=70}const Ww=(s,e,t)=>(r,i)=>{for(let n=!1,a=0,o=0;;o++){let{next:l}=r;if(ml(l)||l==lh||l==Bw||n&&og(l))!n&&(l!=lh||o>0)&&(n=!0),a===o&&l==lh&&a++,r.advance();else if(l==uN&&r.peek(1)!=fN){if(r.advance(),Wb(r.next)){do r.advance();while(Wb(r.next));r.next==32&&r.advance()}else r.next>-1&&r.advance();n=!0}else{n&&r.acceptToken(a==2&&i.canShift(Dw)?e:l==oN?t:s);break}}},pN=new ps(Ww(eN,Dw,tN),{contextual:!0}),gN=new ps(Ww(sN,rN,iN),{contextual:!0}),ON=new ps(s=>{if(Iw.includes(s.peek(-1))){let{next:e}=s;(ml(e)||e==Bw||e==cN||e==lN||e==mN||e==aN||e==nN&&ml(s.peek(1))||e==lh||e==dN)&&s.acceptToken(JL)}}),xN=new ps(s=>{if(!Iw.includes(s.peek(-1))){let{next:e}=s;if(e==hN&&(s.advance(),s.acceptToken(Bb)),ml(e)){do s.advance();while(ml(s.next)||og(s.next));s.acceptToken(Bb)}}}),bN=Ci({"AtKeyword import charset namespace keyframes media supports font-feature-values":L.definitionKeyword,"from to selector scope MatchFlag":L.keyword,NamespaceName:L.namespace,KeyframeName:L.labelName,KeyframeRangeName:L.operatorKeyword,TagName:L.tagName,ClassName:L.className,PseudoClassName:L.constant(L.className),IdName:L.labelName,"FeatureName PropertyName":L.propertyName,AttributeName:L.attributeName,NumberLiteral:L.number,KeywordQuery:L.keyword,UnaryQueryOp:L.operatorKeyword,"CallTag ValueName FontName":L.atom,VariableName:L.variableName,Callee:L.operatorKeyword,Unit:L.unit,"UniversalSelector NestingSelector":L.definitionOperator,"MatchOp CompareOp":L.compareOperator,"ChildOp SiblingOp, LogicOp":L.logicOperator,BinOp:L.arithmeticOperator,Important:L.modifier,Comment:L.blockComment,ColorLiteral:L.color,"ParenthesizedContent StringLiteral":L.string,":":L.punctuation,"PseudoOp #":L.derefOperator,"; , |":L.separator,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace}),vN={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:158,"url-prefix":158,domain:158,regexp:158},yN={__proto__:null,or:104,and:104,not:112,only:112,layer:212},SN={__proto__:null,selector:118,style:124,layer:208},wN={__proto__:null,"@import":204,"@media":216,"@charset":220,"@namespace":224,"@keyframes":230,"@supports":242,"@scope":246,"@font-feature-values":252},_N={__proto__:null,to:249},kN=_i.deserialize({version:14,states:"MrQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FqO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#ERO'dQdO'#ETO'oQdO'#E[O'oQdO'#E_OOQP'#Fq'#FqO)RQhO'#FQOOQS'#Fp'#FpOOQS'#FT'#FTQYQdOOO)YQdO'#EeO*iQhO'#EkO)YQdO'#EmO*pQdO'#EoO*{QdO'#ErO)}QhO'#ExO+TQdO'#EzO+`QdO'#E}O+eQaO'#CfO+lQ`O'#EbO+qQ`O'#F}O+|QdO'#F}QOQ`OOP,WO&jO'#CaPOOO)CA`)CA`OOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,cQdO,59YO'_QdO,5:mO'dQdO,5:oO'oQdO,5:vO'oQdO,5:xO'oQdO,5:yO'oQdO'#F[O,nQ`O,58}O,vQdO'#EaOOQS,58},58}OOQP'#Cq'#CqOOQO'#EP'#EPOOQP,59Y,59YO,}Q`O,59YO-SQ`O,59YOOQP'#ES'#ESOOQP,5:m,5:mO-XQpO'#EUO-dQdO'#EVO-iQ`O'#EVO-nQpO,5:oO.XQaO,5:vO.oQaO,5:yOOQW'#D^'#D^O/nQhO'#DgO0RQhO,5;lO)}QhO'#DeO0`Q`O'#DnO0eQhO'#D{OOQW'#Fw'#FwOOQS,5;l,5;lO0jQ`O'#DhO0oQ`O'#DkOOQS-E9R-E9ROOQ['#Cv'#CvO0tQdO'#CwO1[QdO'#C}O1rQdO'#DQO2YQ!pO'#DSO4fQ!jO,5;POOQO'#DX'#DXO-SQ`O'#DWO4vQ!nO'#F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Q$f!rR%}$g",nodeNames:"⚠ Unit VariableName VariableName QueryCallee Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NamespacedTagSelector NamespaceName TagName NestingSelector ClassSelector . ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue AtKeyword # ; ] [ BracketedValue } { BracedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee IfExpression if ArgList IfBranch KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp ComparisonQuery CompareOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector ParenthesizedSelector StyleQuery style ParenthesedQuery CallQuery ArgList ProperyName , ProperyName UnaryQuery ParenthesedQuery BinaryQuery ParenthesedQuery ParenthesedQuery StyleFeature ProperyName StyleRange PseudoQuery CallLiteral CallTag ParenthesizedContent PseudoClassName ArgList IdSelector IdName AttributeSelector AttributeName NamespacedAttribute NamespaceName AttributeName MatchOp MatchFlag ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp Block Declaration PropertyName Important ImportStatement import Layer layer LayerName layer MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports ScopeStatement scope to FontFeatureStatement font-feature-values FontName AtRule Styles",maxTerm:174,nodeProps:[["isolate",-2,5,39,""],["openedBy",23,"(",31,"[",34,"{"],["closedBy",24,")",32,"]",35,"}"]],propSources:[bN],skippedNodes:[0,5,130],repeatNodeCount:17,tokenData:"K`~R!bOX%ZX^&R^p%Zpq&Rqr)ers)vst+jtu2Xuv%Zvw3Rwx3dxy5Ryz5dz{5i{|6S|}:u}!O;W!O!P;u!P!Q<^!Q![=V![!]>Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#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`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!r`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!r`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!r`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!r`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!r`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$rQ!r`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$fUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#SQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[ON,xN,pN,gN,1,2,3,4,new Xh("m~RRYZ[z{a~~g~aO$b~~dP!P!Qg~lO$c~~",28,155)],topRules:{StyleSheet:[0,6],Styles:[1,129]},dynamicPrecedences:{97:1},specialized:[{term:150,get:s=>vN[s]||-1},{term:151,get:s=>yN[s]||-1},{term:4,get:s=>SN[s]||-1},{term:28,get:s=>wN[s]||-1},{term:149,get:s=>_N[s]||-1}],tokenPrec:2444});let cf=null;function hf(){if(!cf&&typeof document=="object"&&document.body){let{style:s}=document.body,e=[],t=new Set;for(let r in s)r!="cssText"&&r!="cssFloat"&&typeof s[r]=="string"&&(/[A-Z]/.test(r)&&(r=r.replace(/[A-Z]/g,i=>"-"+i.toLowerCase())),t.has(r)||(e.push(r),t.add(r)));cf=e.sort().map(r=>({type:"property",label:r,apply:r+": "}))}return cf||[]}const Xb=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(s=>({type:"class",label:s})),zb=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(s=>({type:"keyword",label:s})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(s=>({type:"constant",label:s}))),CN=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(s=>({type:"type",label:s})),PN=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(s=>({type:"keyword",label:s})),hi=/^(\w[\w-]*|-\w[\w-]*|)$/,TN=/^-(-[\w-]*)?$/;function QN(s,e){var t;if((s.name=="("||s.type.isError)&&(s=s.parent||s),s.name!="ArgList")return!1;let r=(t=s.parent)===null||t===void 0?void 0:t.firstChild;return r?.name!="Callee"?!1:e.sliceString(r.from,r.to)=="var"}const qb=new Ap,$N=["Declaration"];function jN(s){for(let e=s;;){if(e.type.isTop)return e;if(!(e=e.parent))return s}}function Xw(s,e,t){if(e.to-e.from>4096){let r=qb.get(e);if(r)return r;let i=[],n=new Set,a=e.cursor(Bt.IncludeAnonymous);if(a.firstChild())do for(let o of Xw(s,a.node,t))n.has(o.label)||(n.add(o.label),i.push(o));while(a.nextSibling());return qb.set(e,i),i}else{let r=[],i=new Set;return e.cursor().iterate(n=>{var a;if(t(n)&&n.matchContext($N)&&((a=n.node.nextSibling)===null||a===void 0?void 0:a.name)==":"){let o=s.sliceString(n.from,n.to);i.has(o)||(i.add(o),r.push({label:o,type:"variable"}))}}),r}}const RN=s=>e=>{let{state:t,pos:r}=e,i=qt(t).resolveInner(r,-1),n=i.type.isError&&i.from==i.to-1&&t.doc.sliceString(i.from,i.to)=="-";if(i.name=="PropertyName"||(n||i.name=="TagName")&&/^(Block|Styles)$/.test(i.resolve(i.to).name))return{from:i.from,options:hf(),validFor:hi};if(i.name=="ValueName")return{from:i.from,options:zb,validFor:hi};if(i.name=="PseudoClassName")return{from:i.from,options:Xb,validFor:hi};if(s(i)||(e.explicit||n)&&QN(i,t.doc))return{from:s(i)||n?i.from:r,options:Xw(t.doc,jN(i),s),validFor:TN};if(i.name=="TagName"){for(let{parent:l}=i;l;l=l.parent)if(l.name=="Block")return{from:i.from,options:hf(),validFor:hi};return{from:i.from,options:CN,validFor:hi}}if(i.name=="AtKeyword")return{from:i.from,options:PN,validFor:hi};if(!e.explicit)return null;let a=i.resolve(r),o=a.childBefore(r);return o&&o.name==":"&&a.name=="PseudoClassSelector"?{from:r,options:Xb,validFor:hi}:o&&o.name==":"&&a.name=="Declaration"||a.name=="ArgList"?{from:r,options:zb,validFor:hi}:a.name=="Block"||a.name=="Styles"?{from:r,options:hf(),validFor:hi}:null},EN=RN(s=>s.name=="VariableName"),zh=wi.define({name:"css",parser:kN.configure({props:[on.add({Declaration:Qo()}),Pi.add({"Block KeyframeList":rd})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function zw(){return new rn(zh,zh.data.of({autocomplete:EN}))}const AN=55,MN=1,LN=56,NN=2,DN=57,IN=3,Zb=4,BN=5,ag=6,qw=7,Zw=8,Vw=9,Fw=10,WN=11,XN=12,zN=13,df=58,qN=14,ZN=15,Vb=59,Uw=21,VN=23,Hw=24,FN=25,Wm=27,Yw=28,UN=29,HN=32,YN=35,GN=37,KN=38,JN=0,e4=1,t4={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},s4={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},Fb={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function r4(s){return s==45||s==46||s==58||s>=65&&s<=90||s==95||s>=97&&s<=122||s>=161}let Ub=null,Hb=null,Yb=0;function Xm(s,e){let t=s.pos+e;if(Yb==t&&Hb==s)return Ub;let r=s.peek(e),i="";for(;r4(r);)i+=String.fromCharCode(r),r=s.peek(++e);return Hb=s,Yb=t,Ub=i?i.toLowerCase():r==i4||r==n4?void 0:null}const Gw=60,qh=62,lg=47,i4=63,n4=33,o4=45;function Gb(s,e){this.name=s,this.parent=e}const a4=[ag,Fw,qw,Zw,Vw],l4=new hd({start:null,shift(s,e,t,r){return a4.indexOf(e)>-1?new Gb(Xm(r,1)||"",s):s},reduce(s,e){return e==Uw&&s?s.parent:s},reuse(s,e,t,r){let i=e.type.id;return i==ag||i==GN?new Gb(Xm(r,1)||"",s):s},strict:!1}),c4=new ps((s,e)=>{if(s.next!=Gw){s.next<0&&e.context&&s.acceptToken(df);return}s.advance();let t=s.next==lg;t&&s.advance();let r=Xm(s,0);if(r===void 0)return;if(!r)return s.acceptToken(t?ZN:qN);let i=e.context?e.context.name:null;if(t){if(r==i)return s.acceptToken(WN);if(i&&s4[i])return s.acceptToken(df,-2);if(e.dialectEnabled(JN))return s.acceptToken(XN);for(let n=e.context;n;n=n.parent)if(n.name==r)return;s.acceptToken(zN)}else{if(r=="script")return s.acceptToken(qw);if(r=="style")return s.acceptToken(Zw);if(r=="textarea")return s.acceptToken(Vw);if(t4.hasOwnProperty(r))return s.acceptToken(Fw);i&&Fb[i]&&Fb[i][r]?s.acceptToken(df,-1):s.acceptToken(ag)}},{contextual:!0}),h4=new ps(s=>{for(let e=0,t=0;;t++){if(s.next<0){t&&s.acceptToken(Vb);break}if(s.next==o4)e++;else if(s.next==qh&&e>=2){t>=3&&s.acceptToken(Vb,-2);break}else e=0;s.advance()}});function d4(s){for(;s;s=s.parent)if(s.name=="svg"||s.name=="math")return!0;return!1}const u4=new ps((s,e)=>{if(s.next==lg&&s.peek(1)==qh){let t=e.dialectEnabled(e4)||d4(e.context);s.acceptToken(t?BN:Zb,2)}else s.next==qh&&s.acceptToken(Zb,1)});function cg(s,e,t){let r=2+s.length;return new ps(i=>{for(let n=0,a=0,o=0;;o++){if(i.next<0){o&&i.acceptToken(e);break}if(n==0&&i.next==Gw||n==1&&i.next==lg||n>=2&&n<r&&i.next==s.charCodeAt(n-2))n++,a++;else if(n==r&&i.next==qh){o>a?i.acceptToken(e,-a):i.acceptToken(t,-(a-2));break}else if((i.next==10||i.next==13)&&o){i.acceptToken(e,1);break}else n=a=0;i.advance()}})}const f4=cg("script",AN,MN),m4=cg("style",LN,NN),p4=cg("textarea",DN,IN),g4=Ci({"Text RawText IncompleteTag IncompleteCloseTag":L.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":L.angleBracket,TagName:L.tagName,"MismatchedCloseTag/TagName":[L.tagName,L.invalid],AttributeName:L.attributeName,"AttributeValue UnquotedAttributeValue":L.attributeValue,Is:L.definitionOperator,"EntityReference CharacterReference":L.character,Comment:L.blockComment,ProcessingInst:L.processingInstruction,DoctypeDecl:L.documentMeta}),O4=_i.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59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gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:l4,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40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!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!<TXjSaP!b`!dpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",tokenizers:[f4,m4,p4,u4,c4,h4,0,1,2,3,4,5],topRules:{Document:[0,16]},dialects:{noMatch:0,selfClosing:515},tokenPrec:517});function Kw(s,e){let t=Object.create(null);for(let r of s.getChildren(Hw)){let i=r.getChild(FN),n=r.getChild(Wm)||r.getChild(Yw);i&&(t[e.read(i.from,i.to)]=n?n.type.id==Wm?e.read(n.from+1,n.to-1):e.read(n.from,n.to):"")}return t}function Kb(s,e){let t=s.getChild(VN);return t?e.read(t.from,t.to):" "}function uf(s,e,t){let r;for(let i of t)if(!i.attrs||i.attrs(r||(r=Kw(s.node.parent.firstChild,e))))return{parser:i.parser,bracketed:!0};return null}function Jw(s=[],e=[]){let t=[],r=[],i=[],n=[];for(let o of s)(o.tag=="script"?t:o.tag=="style"?r:o.tag=="textarea"?i:n).push(o);let a=e.length?Object.create(null):null;for(let o of e)(a[o.name]||(a[o.name]=[])).push(o);return Z1((o,l)=>{let h=o.type.id;if(h==UN)return uf(o,l,t);if(h==HN)return uf(o,l,r);if(h==YN)return uf(o,l,i);if(h==Uw&&n.length){let u=o.node,d=u.firstChild,f=d&&Kb(d,l),p;if(f){for(let v of n)if(v.tag==f&&(!v.attrs||v.attrs(p||(p=Kw(d,l))))){let b=u.lastChild,O=b.type.id==KN?b.from:u.to;if(O>d.to)return{parser:v.parser,overlay:[{from:d.to,to:O}]}}}}if(a&&h==Hw){let u=o.node,d;if(d=u.firstChild){let f=a[l.read(d.from,d.to)];if(f)for(let p of f){if(p.tagName&&p.tagName!=Kb(u.parent,l))continue;let v=u.lastChild;if(v.type.id==Wm){let b=v.from+1,O=v.lastChild,g=v.to-(O&&O.isError?0:1);if(g>b)return{parser:p.parser,overlay:[{from:b,to:g}],bracketed:!0}}else if(v.type.id==Yw)return{parser:p.parser,overlay:[{from:v.from,to:v.to}]}}}}return null})}const Ra=["_blank","_self","_top","_parent"],ff=["ascii","utf-8","utf-16","latin1","latin1"],mf=["get","post","put","delete"],pf=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],dr=["true","false"],at={},x4={a:{attrs:{href:null,ping:null,type:null,media:null,target:Ra,hreflang:null}},abbr:at,address:at,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:at,aside:at,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:at,base:{attrs:{href:null,target:Ra}},bdi:at,bdo:at,blockquote:{attrs:{cite:null}},body:at,br:at,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:pf,formmethod:mf,formnovalidate:["novalidate"],formtarget:Ra,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:at,center:at,cite:at,code:at,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:at,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:at,div:at,dl:at,dt:at,em:at,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:at,figure:at,footer:at,form:{attrs:{action:null,name:null,"accept-charset":ff,autocomplete:["on","off"],enctype:pf,method:mf,novalidate:["novalidate"],target:Ra}},h1:at,h2:at,h3:at,h4:at,h5:at,h6:at,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:at,hgroup:at,hr:at,html:{attrs:{manifest:null}},i:at,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:pf,formmethod:mf,formnovalidate:["novalidate"],formtarget:Ra,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:at,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:at,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:at,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:ff,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:at,noscript:at,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:at,param:{attrs:{name:null,value:null}},pre:at,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:at,rt:at,ruby:at,samp:at,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:ff}},section:at,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:at,source:{attrs:{src:null,type:null,media:null}},span:at,strong:at,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:at,summary:at,sup:at,table:at,tbody:at,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:at,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:at,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:at,time:{attrs:{datetime:null}},title:at,tr:at,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:at,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:at},e_={accesskey:null,class:null,contenteditable:dr,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:dr,autocorrect:dr,autocapitalize:dr,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":dr,"aria-autocomplete":["inline","list","both","none"],"aria-busy":dr,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":dr,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":dr,"aria-hidden":dr,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":dr,"aria-multiselectable":dr,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":dr,"aria-relevant":null,"aria-required":dr,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},t_="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(s=>"on"+s);for(let s of t_)e_[s]=null;class pl{constructor(e,t){this.tags={...x4,...e},this.globalAttrs={...e_,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}pl.default=new pl;function Bo(s,e,t=s.length){if(!e)return"";let r=e.firstChild,i=r&&r.getChild("TagName");return i?s.sliceString(i.from,Math.min(i.to,t)):""}function Wo(s,e=!1){for(;s;s=s.parent)if(s.name=="Element")if(e)e=!1;else return s;return null}function s_(s,e,t){let r=t.tags[Bo(s,Wo(e))];return r?.children||t.allTags}function hg(s,e){let t=[];for(let r=Wo(e);r&&!r.type.isTop;r=Wo(r.parent)){let i=Bo(s,r);if(i&&r.lastChild.name=="CloseTag")break;i&&t.indexOf(i)<0&&(e.name=="EndTag"||e.from>=r.firstChild.to)&&t.push(i)}return t}const r_=/^[:\-\.\w\u00b7-\uffff]*$/;function Jb(s,e,t,r,i){let n=/\s*>/.test(s.sliceDoc(i,i+5))?"":">",a=Wo(t,t.name=="StartTag"||t.name=="TagName");return{from:r,to:i,options:s_(s.doc,a,e).map(o=>({label:o,type:"type"})).concat(hg(s.doc,t).map((o,l)=>({label:"/"+o,apply:"/"+o+n,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function ev(s,e,t,r){let i=/\s*>/.test(s.sliceDoc(r,r+5))?"":">";return{from:t,to:r,options:hg(s.doc,e).map((n,a)=>({label:n,apply:n+i,type:"type",boost:99-a})),validFor:r_}}function b4(s,e,t,r){let i=[],n=0;for(let a of s_(s.doc,t,e))i.push({label:"<"+a,type:"type"});for(let a of hg(s.doc,t))i.push({label:"</"+a+">",type:"type",boost:99-n++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function v4(s,e,t,r,i){let n=Wo(t),a=n?e.tags[Bo(s.doc,n)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],l=a&&a.globalAttrs===!1?o:o.length?o.concat(e.globalAttrNames):e.globalAttrNames;return{from:r,to:i,options:l.map(h=>({label:h,type:"property"})),validFor:r_}}function y4(s,e,t,r,i){var n;let a=(n=t.parent)===null||n===void 0?void 0:n.getChild("AttributeName"),o=[],l;if(a){let h=s.sliceDoc(a.from,a.to),u=e.globalAttrs[h];if(!u){let d=Wo(t),f=d?e.tags[Bo(s.doc,d)]:null;u=f?.attrs&&f.attrs[h]}if(u){let d=s.sliceDoc(r,i).toLowerCase(),f='"',p='"';/^['"]/.test(d)?(l=d[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",p=s.sliceDoc(i,i+1)==d[0]?"":d[0],d=d.slice(1),r++):l=/^[^\s<>='"]*$/;for(let v of u)o.push({label:v,apply:f+v+p,type:"constant"})}}return{from:r,to:i,options:o,validFor:l}}function i_(s,e){let{state:t,pos:r}=e,i=qt(t).resolveInner(r,-1),n=i.resolve(r);for(let a=r,o;n==i&&(o=i.childBefore(a));){let l=o.lastChild;if(!l||!l.type.isError||l.from<l.to)break;n=i=o,a=l.from}return i.name=="TagName"?i.parent&&/CloseTag$/.test(i.parent.name)?ev(t,i,i.from,r):Jb(t,s,i,i.from,r):i.name=="StartTag"||i.name=="IncompleteTag"?Jb(t,s,i,r,r):i.name=="StartCloseTag"||i.name=="IncompleteCloseTag"?ev(t,i,r,r):i.name=="OpenTag"||i.name=="SelfClosingTag"||i.name=="AttributeName"?v4(t,s,i,i.name=="AttributeName"?i.from:r,r):i.name=="Is"||i.name=="AttributeValue"||i.name=="UnquotedAttributeValue"?y4(t,s,i,i.name=="Is"?r:i.from,r):e.explicit&&(n.name=="Element"||n.name=="Text"||n.name=="Document")?b4(t,s,i,r):null}function S4(s){return i_(pl.default,s)}function w4(s){let{extraTags:e,extraGlobalAttributes:t}=s,r=t||e?new pl(e,t):pl.default;return i=>i_(r,i)}const _4=si.parser.configure({top:"SingleExpression"}),n_=[{tag:"script",attrs:s=>s.type=="text/typescript"||s.lang=="ts",parser:ww.parser},{tag:"script",attrs:s=>s.type=="text/babel"||s.type=="text/jsx",parser:_w.parser},{tag:"script",attrs:s=>s.type=="text/typescript-jsx",parser:kw.parser},{tag:"script",attrs(s){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(s.type)},parser:_4},{tag:"script",attrs(s){return!s.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(s.type)},parser:si.parser},{tag:"style",attrs(s){return(!s.lang||s.lang=="css")&&(!s.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(s.type))},parser:zh.parser}],o_=[{name:"style",parser:zh.parser.configure({top:"Styles"})}].concat(t_.map(s=>({name:s,parser:si.parser}))),a_=wi.define({name:"html",parser:O4.configure({props:[on.add({Element(s){let e=/^(\s*)(<\/)?/.exec(s.textAfter);return s.node.to<=s.pos+e[0].length?s.continue():s.lineIndent(s.node.from)+(e[2]?0:s.unit)},"OpenTag CloseTag SelfClosingTag"(s){return s.column(s.node.from)+s.unit},Document(s){if(s.pos+/\s*/.exec(s.textAfter)[0].length<s.node.to)return s.continue();let e=null,t;for(let r=s.node;;){let i=r.lastChild;if(!i||i.name!="Element"||i.to!=r.to)break;e=r=i}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?s.lineIndent(e.from)+s.unit:null}}),Pi.add({Element(s){let e=s.firstChild,t=s.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:s.to}}}),Bp.add({"OpenTag CloseTag":s=>s.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),ch=a_.configure({wrap:Jw(n_,o_)});function l_(s={}){let e="",t;s.matchClosingTags===!1&&(e="noMatch"),s.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(s.nestedLanguages&&s.nestedLanguages.length||s.nestedAttributes&&s.nestedAttributes.length)&&(t=Jw((s.nestedLanguages||[]).concat(n_),(s.nestedAttributes||[]).concat(o_)));let r=t?a_.configure({wrap:t,dialect:e}):e?ch.configure({dialect:e}):ch;return new rn(r,[ch.data.of({autocomplete:w4(s)}),s.autoCloseTags!==!1?k4:[],nh().support,zw().support])}const tv=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),k4=We.inputHandler.of((s,e,t,r,i)=>{if(s.composing||s.state.readOnly||e!=t||r!=">"&&r!="/"||!ch.isActiveAt(s.state,e,-1))return!1;let n=i(),{state:a}=n,o=a.changeByRange(l=>{var h,u,d;let f=a.doc.sliceString(l.from-1,l.to)==r,{head:p}=l,v=qt(a).resolveInner(p,-1),b;if(f&&r==">"&&v.name=="EndTag"){let O=v.parent;if(((u=(h=O.parent)===null||h===void 0?void 0:h.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(b=Bo(a.doc,O.parent,p))&&!tv.has(b)){let g=p+(a.doc.sliceString(p,p+1)===">"?1:0),m=`</${b}>`;return{range:l,changes:{from:p,to:g,insert:m}}}}else if(f&&r=="/"&&v.name=="IncompleteCloseTag"){let O=v.parent;if(v.from==p-2&&((d=O.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=Bo(a.doc,O,p))&&!tv.has(b)){let g=p+(a.doc.sliceString(p,p+1)===">"?1:0),m=`${b}>`;return{range:fe.cursor(p+m.length,-1),changes:{from:p,to:g,insert:m}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});class Zh{static create(e,t,r,i,n){let a=i+(i<<8)+e+(t<<4)|0;return new Zh(e,t,r,a,n,[],[])}constructor(e,t,r,i,n,a,o){this.type=e,this.value=t,this.from=r,this.hash=i,this.end=n,this.children=a,this.positions=o,this.hashProp=[[bt.contextHash,i]]}addChild(e,t){e.prop(bt.contextHash)!=this.hash&&(e=new Wt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let r=this.children.length-1;return r>=0&&(t=Math.max(t,this.positions[r]+this.children[r].length+this.from)),new Wt(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(i,n,a)=>new Wt(ms.none,i,n,a,this.hashProp)})}}var Ae;(function(s){s[s.Document=1]="Document",s[s.CodeBlock=2]="CodeBlock",s[s.FencedCode=3]="FencedCode",s[s.Blockquote=4]="Blockquote",s[s.HorizontalRule=5]="HorizontalRule",s[s.BulletList=6]="BulletList",s[s.OrderedList=7]="OrderedList",s[s.ListItem=8]="ListItem",s[s.ATXHeading1=9]="ATXHeading1",s[s.ATXHeading2=10]="ATXHeading2",s[s.ATXHeading3=11]="ATXHeading3",s[s.ATXHeading4=12]="ATXHeading4",s[s.ATXHeading5=13]="ATXHeading5",s[s.ATXHeading6=14]="ATXHeading6",s[s.SetextHeading1=15]="SetextHeading1",s[s.SetextHeading2=16]="SetextHeading2",s[s.HTMLBlock=17]="HTMLBlock",s[s.LinkReference=18]="LinkReference",s[s.Paragraph=19]="Paragraph",s[s.CommentBlock=20]="CommentBlock",s[s.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",s[s.Escape=22]="Escape",s[s.Entity=23]="Entity",s[s.HardBreak=24]="HardBreak",s[s.Emphasis=25]="Emphasis",s[s.StrongEmphasis=26]="StrongEmphasis",s[s.Link=27]="Link",s[s.Image=28]="Image",s[s.InlineCode=29]="InlineCode",s[s.HTMLTag=30]="HTMLTag",s[s.Comment=31]="Comment",s[s.ProcessingInstruction=32]="ProcessingInstruction",s[s.Autolink=33]="Autolink",s[s.HeaderMark=34]="HeaderMark",s[s.QuoteMark=35]="QuoteMark",s[s.ListMark=36]="ListMark",s[s.LinkMark=37]="LinkMark",s[s.EmphasisMark=38]="EmphasisMark",s[s.CodeMark=39]="CodeMark",s[s.CodeText=40]="CodeText",s[s.CodeInfo=41]="CodeInfo",s[s.LinkTitle=42]="LinkTitle",s[s.LinkLabel=43]="LinkLabel",s[s.URL=44]="URL"})(Ae||(Ae={}));class C4{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class P4{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Va(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,r=0){for(let i=t;i<e;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(e){let t=0;for(let r=0;t<this.text.length&&r<e;t++)r+=this.text.charCodeAt(t)==9?4-r%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}}function sv(s,e,t){if(t.pos==t.text.length||s!=e.block&&t.indent>=e.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let r=(s.type==Ae.OrderedList?fg:ug)(t,e,!1);return r>0&&(s.type!=Ae.BulletList||dg(t,e,!1)<0)&&t.text.charCodeAt(t.pos+r-1)==s.value}const c_={[Ae.Blockquote](s,e,t){return t.next!=62?!1:(t.markers.push(Et(Ae.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1)),t.moveBase(t.pos+(Tr(t.text.charCodeAt(t.pos+1))?2:1)),s.end=e.lineStart+t.text.length,!0)},[Ae.ListItem](s,e,t){return t.indent<t.baseIndent+s.value&&t.next>-1?!1:(t.moveBaseColumn(t.baseIndent+s.value),!0)},[Ae.OrderedList]:sv,[Ae.BulletList]:sv,[Ae.Document](){return!0}};function Tr(s){return s==32||s==9||s==10||s==13}function Va(s,e=0){for(;e<s.length&&Tr(s.charCodeAt(e));)e++;return e}function rv(s,e,t){for(;e>t&&Tr(s.charCodeAt(e-1));)e--;return e}function h_(s){if(s.next!=96&&s.next!=126)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==s.next;)e++;if(e<s.pos+3)return-1;if(s.next==96){for(let t=e;t<s.text.length;t++)if(s.text.charCodeAt(t)==96)return-1}return e}function d_(s){return s.next!=62?-1:s.text.charCodeAt(s.pos+1)==32?2:1}function dg(s,e,t){if(s.next!=42&&s.next!=45&&s.next!=95)return-1;let r=1;for(let i=s.pos+1;i<s.text.length;i++){let n=s.text.charCodeAt(i);if(n==s.next)r++;else if(!Tr(n))return-1}return t&&s.next==45&&m_(s)>-1&&s.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(x_.SetextHeading)>-1||r<3?-1:1}function u_(s,e){for(let t=s.stack.length-1;t>=0;t--)if(s.stack[t].type==e)return!0;return!1}function ug(s,e,t){return(s.next==45||s.next==43||s.next==42)&&(s.pos==s.text.length-1||Tr(s.text.charCodeAt(s.pos+1)))&&(!t||u_(e,Ae.BulletList)||s.skipSpace(s.pos+2)<s.text.length)?1:-1}function fg(s,e,t){let r=s.pos,i=s.next;for(;i>=48&&i<=57;){r++;if(r==s.text.length)return-1;i=s.text.charCodeAt(r)}return r==s.pos||r>s.pos+9||i!=46&&i!=41||r<s.text.length-1&&!Tr(s.text.charCodeAt(r+1))||t&&!u_(e,Ae.OrderedList)&&(s.skipSpace(r+1)==s.text.length||r>s.pos+1||s.next!=49)?-1:r+1-s.pos}function f_(s){if(s.next!=35)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==35;)e++;if(e<s.text.length&&s.text.charCodeAt(e)!=32)return-1;let t=e-s.pos;return t>6?-1:t}function m_(s){if(s.next!=45&&s.next!=61||s.indent>=s.baseIndent+4)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==s.next;)e++;let t=e;for(;e<s.text.length&&Tr(s.text.charCodeAt(e));)e++;return e==s.text.length?t:-1}const zm=/^[ \t]*$/,p_=/-->/,g_=/\?>/,qm=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,p_],[/^\s*<\?/,g_],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,zm],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,zm]];function O_(s,e,t){if(s.next!=60)return-1;let r=s.text.slice(s.pos);for(let i=0,n=qm.length-(t?1:0);i<n;i++)if(qm[i][0].test(r))return i;return-1}function iv(s,e){let t=s.countIndent(e,s.pos,s.indent),r=s.skipSpace(e),i=s.countIndent(r,e,t);return i>=t+5||r==s.text.length?t+1:i}function Wi(s,e,t){let r=s.length-1;r>=0&&s[r].to==e&&s[r].type==Ae.CodeText?s[r].to=t:s.push(Et(Ae.CodeText,e,t))}const Wc={LinkReference:void 0,IndentedCode(s,e){let t=e.baseIndent+4;if(e.indent<t)return!1;let r=e.findColumn(t),i=s.lineStart+r,n=s.lineStart+e.text.length,a=[],o=[];for(Wi(a,i,n);s.nextLine()&&e.depth>=s.stack.length;)if(e.pos==e.text.length){Wi(o,s.lineStart-1,s.lineStart);for(let l of e.markers)o.push(l)}else{if(e.indent<t)break;{if(o.length){for(let h of o)h.type==Ae.CodeText?Wi(a,h.from,h.to):a.push(h);o=[]}Wi(a,s.lineStart-1,s.lineStart);for(let h of e.markers)a.push(h);n=s.lineStart+e.text.length;let l=s.lineStart+e.findColumn(e.baseIndent+4);l<n&&Wi(a,l,n)}}return o.length&&(o=o.filter(l=>l.type!=Ae.CodeText),o.length&&(e.markers=o.concat(e.markers))),s.addNode(s.buffer.writeElements(a,-i).finish(Ae.CodeBlock,n-i),i),!0},FencedCode(s,e){let t=h_(e);if(t<0)return!1;let r=s.lineStart+e.pos,i=e.next,n=t-e.pos,a=e.skipSpace(t),o=rv(e.text,e.text.length,a),l=[Et(Ae.CodeMark,r,r+n)];a<o&&l.push(Et(Ae.CodeInfo,s.lineStart+a,s.lineStart+o));for(let h=!0,u=!0,d=!1;s.nextLine()&&e.depth>=s.stack.length;h=!1){let f=e.pos;if(e.indent-e.baseIndent<4)for(;f<e.text.length&&e.text.charCodeAt(f)==i;)f++;if(f-e.pos>=n&&e.skipSpace(f)==e.text.length){for(let p of e.markers)l.push(p);u&&d&&Wi(l,s.lineStart-1,s.lineStart),l.push(Et(Ae.CodeMark,s.lineStart+e.pos,s.lineStart+f)),s.nextLine();break}else{d=!0,h||(Wi(l,s.lineStart-1,s.lineStart),u=!1);for(let b of e.markers)l.push(b);let p=s.lineStart+e.basePos,v=s.lineStart+e.text.length;p<v&&(Wi(l,p,v),u=!1)}}return s.addNode(s.buffer.writeElements(l,-r).finish(Ae.FencedCode,s.prevLineEnd()-r),r),!0},Blockquote(s,e){let t=d_(e);return t<0?!1:(s.startContext(Ae.Blockquote,e.pos),s.addNode(Ae.QuoteMark,s.lineStart+e.pos,s.lineStart+e.pos+1),e.moveBase(e.pos+t),null)},HorizontalRule(s,e){if(dg(e,s,!1)<0)return!1;let t=s.lineStart+e.pos;return s.nextLine(),s.addNode(Ae.HorizontalRule,t),!0},BulletList(s,e){let t=ug(e,s,!1);if(t<0)return!1;s.block.type!=Ae.BulletList&&s.startContext(Ae.BulletList,e.basePos,e.next);let r=iv(e,e.pos+1);return s.startContext(Ae.ListItem,e.basePos,r-e.baseIndent),s.addNode(Ae.ListMark,s.lineStart+e.pos,s.lineStart+e.pos+t),e.moveBaseColumn(r),null},OrderedList(s,e){let t=fg(e,s,!1);if(t<0)return!1;s.block.type!=Ae.OrderedList&&s.startContext(Ae.OrderedList,e.basePos,e.text.charCodeAt(e.pos+t-1));let r=iv(e,e.pos+t);return s.startContext(Ae.ListItem,e.basePos,r-e.baseIndent),s.addNode(Ae.ListMark,s.lineStart+e.pos,s.lineStart+e.pos+t),e.moveBaseColumn(r),null},ATXHeading(s,e){let t=f_(e);if(t<0)return!1;let r=e.pos,i=s.lineStart+r,n=rv(e.text,e.text.length,r),a=n;for(;a>r&&e.text.charCodeAt(a-1)==e.next;)a--;(a==n||a==r||!Tr(e.text.charCodeAt(a-1)))&&(a=e.text.length);let o=s.buffer.write(Ae.HeaderMark,0,t).writeElements(s.parser.parseInline(e.text.slice(r+t+1,a),i+t+1),-i);a<e.text.length&&o.write(Ae.HeaderMark,a-r,n-r);let l=o.finish(Ae.ATXHeading1-1+t,e.text.length-r);return s.nextLine(),s.addNode(l,i),!0},HTMLBlock(s,e){let t=O_(e,s,!1);if(t<0)return!1;let r=s.lineStart+e.pos,i=qm[t][1],n=[],a=i!=zm;for(;!i.test(e.text)&&s.nextLine();){if(e.depth<s.stack.length){a=!1;break}for(let h of e.markers)n.push(h)}a&&s.nextLine();let o=i==p_?Ae.CommentBlock:i==g_?Ae.ProcessingInstructionBlock:Ae.HTMLBlock,l=s.prevLineEnd();return s.addNode(s.buffer.writeElements(n,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class T4{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,r){if(this.stage==-1)return!1;let i=r.content+`
36
+ `+t.scrub(),n=this.advance(i);return n>-1&&n<i.length?this.complete(e,r,n):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Va(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,r){return e.addLeafElement(t,Et(Ae.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(P_(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Et(Ae.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(k_(e,Va(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Va(e,this.pos),r=0;if(t>this.pos){let i=C_(e,t,this.start);if(i){let n=gf(e,i.to-this.start);n>0&&(this.nextStage(i),r=n)}}return r||(r=gf(e,this.pos)),r>0&&r<e.length?r:-1}else return gf(e,this.pos)}}}function gf(s,e){for(;e<s.length;e++){let t=s.charCodeAt(e);if(t==10)break;if(!Tr(t))return-1}return e}class Q4{nextLine(e,t,r){let i=t.depth<e.stack.length?-1:m_(t),n=t.next;if(i<0)return!1;let a=Et(Ae.HeaderMark,e.lineStart+t.pos,e.lineStart+i);return e.nextLine(),e.addLeafElement(r,Et(n==61?Ae.SetextHeading1:Ae.SetextHeading2,r.start,e.prevLineEnd(),[...e.parser.parseInline(r.content,r.start),a])),!0}finish(){return!1}}const x_={LinkReference(s,e){return e.content.charCodeAt(0)==91?new T4(e):null},SetextHeading(){return new Q4}},$4=[(s,e)=>f_(e)>=0,(s,e)=>h_(e)>=0,(s,e)=>d_(e)>=0,(s,e)=>ug(e,s,!0)>=0,(s,e)=>fg(e,s,!0)>=0,(s,e)=>dg(e,s,!0)>=0,(s,e)=>O_(e,s,!0)>=0],j4={text:"",end:0};class R4{constructor(e,t,r,i){this.parser=e,this.input=t,this.ranges=i,this.line=new P4,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=Zh.create(Ae.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new M4(r,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let r=0;;){let i=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<e.markers.length&&(!i||e.markers[r].from<i.end);){let n=e.markers[r++];this.addNode(n.type,n.from,n.to)}if(!i)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,e);if(i!=!1){if(i==!0)return null;e.forward();continue e}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new C4(this.lineStart+e.pos,e.text.slice(e.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,t);i&&t.parsers.push(i)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,e,t))break e}for(let r of t.parsers)if(r.nextLine(this,e,t))return null;t.content+=`
37
+ `+e.scrub();for(let r of e.markers)t.marks.push(r)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=T_(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=j4;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<t.end;){i++;let n=this.ranges[i].from,a=this.lineChunkAt(n);t.end=n+a.length,t.text=t.text.slice(0,this.ranges[i-1].to-r)+a,r=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,e.reset(t);e.depth<this.stack.length;e.depth++){let i=this.stack[e.depth],n=this.parser.skipContextMarkup[i.type];if(!n)throw new Error("Unhandled block context "+Ae[i.type]);let a=this.line.markers.length;if(!n(i,this,e)){this.line.markers.length>a&&(i.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),r;if(this.input.lineChunks)r=t==`
38
+ `?"":t;else{let i=t.indexOf(`
39
+ `);r=i<0?t:t.slice(0,i)}return e+r.length>this.to?r.slice(0,this.to-e):r}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,r=0){this.block=Zh.create(e,r,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,r=0){this.startContext(this.parser.getNodeType(e),t,r)}addNode(e,t,r){typeof e=="number"&&(e=new Wt(this.parser.nodeSet.types[e],Xo,Xo,(r??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(Vm(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?b_(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let r of e.parsers)if(r.finish(this,e))return;let t=Vm(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(Ae.Paragraph,e.content.length),e.start)}elt(e,t,r,i){return typeof e=="string"?Et(this.parser.getNodeType(e),t,r,i):new S_(e,t)}get buffer(){return new y_(this.parser.nodeSet)}}function b_(s,e,t,r,i){let n=s[e].to,a=[],o=[],l=t.from+r;function h(u,d){for(;d?u>=n:u>n;){let f=s[e+1].from-n;r+=f,u+=f,e++,n=s[e].to}}for(let u=t.firstChild;u;u=u.nextSibling){h(u.from+r,!0);let d=u.from+r,f,p=i.get(u.tree);p?f=p:u.to+r>n?(f=b_(s,e,u,r,i),h(u.to+r,!1)):f=u.toTree(),a.push(f),o.push(d-l)}return h(t.to+r,!1),new Wt(t.type,a,o,t.to+r-l,t.tree?t.tree.propValues:void 0)}class ud extends Mp{constructor(e,t,r,i,n,a,o,l,h){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=r,this.blockNames=i,this.endLeafBlock=n,this.skipContextMarkup=a,this.inlineParsers=o,this.inlineNames=l,this.wrappers=h,this.nodeTypes=Object.create(null);for(let u of e.types)this.nodeTypes[u.name]=u.id}createParse(e,t,r){let i=new R4(this,e,t,r);for(let n of this.wrappers)i=n(i,e,t,r);return i}configure(e){let t=Zm(e);if(!t)return this;let{nodeSet:r,skipContextMarkup:i}=this,n=this.blockParsers.slice(),a=this.leafBlockParsers.slice(),o=this.blockNames.slice(),l=this.inlineParsers.slice(),h=this.inlineNames.slice(),u=this.endLeafBlock.slice(),d=this.wrappers;if(Ea(t.defineNodes)){i=Object.assign({},i);let f=r.types.slice(),p;for(let v of t.defineNodes){let{name:b,block:O,composite:g,style:m}=typeof v=="string"?{name:v}:v;if(f.some(k=>k.name==b))continue;g&&(i[f.length]=(k,C,P)=>g(C,P,k.value));let x=f.length,y=g?["Block","BlockContext"]:O?x>=Ae.ATXHeading1&&x<=Ae.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(ms.define({id:x,name:b,props:y&&[[bt.group,y]]})),m&&(p||(p={}),Array.isArray(m)||m instanceof mr?p[b]=m:Object.assign(p,m))}r=new kl(f),p&&(r=r.extend(Ci(p)))}if(Ea(t.props)&&(r=r.extend(...t.props)),Ea(t.remove))for(let f of t.remove){let p=this.blockNames.indexOf(f),v=this.inlineNames.indexOf(f);p>-1&&(n[p]=a[p]=void 0),v>-1&&(l[v]=void 0)}if(Ea(t.parseBlock))for(let f of t.parseBlock){let p=o.indexOf(f.name);if(p>-1)n[p]=f.parse,a[p]=f.leaf;else{let v=f.before?Xc(o,f.before):f.after?Xc(o,f.after)+1:o.length-1;n.splice(v,0,f.parse),a.splice(v,0,f.leaf),o.splice(v,0,f.name)}f.endLeaf&&u.push(f.endLeaf)}if(Ea(t.parseInline))for(let f of t.parseInline){let p=h.indexOf(f.name);if(p>-1)l[p]=f.parse;else{let v=f.before?Xc(h,f.before):f.after?Xc(h,f.after)+1:h.length-1;l.splice(v,0,f.parse),h.splice(v,0,f.name)}}return t.wrap&&(d=d.concat(t.wrap)),new ud(r,n,a,o,u,i,l,h,d)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let r=new mg(this,e,t);e:for(let i=t;i<r.end;){let n=r.char(i);for(let a of this.inlineParsers)if(a){let o=a(r,n,i);if(o>=0){i=o;continue e}}i++}return r.resolveMarkers(0)}}function Ea(s){return s!=null&&s.length>0}function Zm(s){if(!Array.isArray(s))return s;if(s.length==0)return null;let e=Zm(s[0]);if(s.length==1)return e;let t=Zm(s.slice(1));if(!t||!e)return e||t;let r=(a,o)=>(a||Xo).concat(o||Xo),i=e.wrap,n=t.wrap;return{props:r(e.props,t.props),defineNodes:r(e.defineNodes,t.defineNodes),parseBlock:r(e.parseBlock,t.parseBlock),parseInline:r(e.parseInline,t.parseInline),remove:r(e.remove,t.remove),wrap:i?n?(a,o,l,h)=>i(n(a,o,l,h),o,l,h):i:n}}function Xc(s,e){let t=s.indexOf(e);if(t<0)throw new RangeError(`Position specified relative to unknown parser ${e}`);return t}let v_=[ms.none];for(let s=1,e;e=Ae[s];s++)v_[s]=ms.define({id:s,name:e,props:s>=Ae.Escape?[]:[[bt.group,s in c_?["Block","BlockContext"]:["Block","LeafBlock"]]],top:e=="Document"});const Xo=[];class y_{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,r,i=0){return this.content.push(e,t,r,4+i*4),this}writeElements(e,t=0){for(let r of e)r.writeTo(this,t);return this}finish(e,t){return Wt.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}let gl=class{constructor(e,t,r,i=Xo){this.type=e,this.from=t,this.to=r,this.children=i}writeTo(e,t){let r=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-r)}toTree(e){return new y_(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}};class S_{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return Xo}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function Et(s,e,t,r){return new gl(s,e,t,r)}const w_={resolve:"Emphasis",mark:"EmphasisMark"},__={resolve:"Emphasis",mark:"EmphasisMark"},In={},Vh={};class fr{constructor(e,t,r,i){this.type=e,this.from=t,this.to=r,this.side=i}}const nv="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let Ol=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Ol=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}const Of={Escape(s,e,t){if(e!=92||t==s.end-1)return-1;let r=s.char(t+1);for(let i=0;i<nv.length;i++)if(nv.charCodeAt(i)==r)return s.append(Et(Ae.Escape,t,t+2));return-1},Entity(s,e,t){if(e!=38)return-1;let r=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(s.slice(t+1,t+31));return r?s.append(Et(Ae.Entity,t,t+1+r[0].length)):-1},InlineCode(s,e,t){if(e!=96||t&&s.char(t-1)==96)return-1;let r=t+1;for(;r<s.end&&s.char(r)==96;)r++;let i=r-t,n=0;for(;r<s.end;r++)if(s.char(r)==96){if(n++,n==i&&s.char(r+1)!=96)return s.append(Et(Ae.InlineCode,t,r+1,[Et(Ae.CodeMark,t,t+i),Et(Ae.CodeMark,r+1-i,r+1)]))}else n=0;return-1},HTMLTag(s,e,t){if(e!=60||t==s.end-1)return-1;let r=s.slice(t+1,s.end),i=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);if(i)return s.append(Et(Ae.Autolink,t,t+1+i[0].length,[Et(Ae.LinkMark,t,t+1),Et(Ae.URL,t+1,t+i[0].length),Et(Ae.LinkMark,t+i[0].length,t+1+i[0].length)]));let n=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);if(n)return s.append(Et(Ae.Comment,t,t+1+n[0].length));let a=/^\?[^]*?\?>/.exec(r);if(a)return s.append(Et(Ae.ProcessingInstruction,t,t+1+a[0].length));let o=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return o?s.append(Et(Ae.HTMLTag,t,t+1+o[0].length)):-1},Emphasis(s,e,t){if(e!=95&&e!=42)return-1;let r=t+1;for(;s.char(r)==e;)r++;let i=s.slice(t-1,t),n=s.slice(r,r+1),a=Ol.test(i),o=Ol.test(n),l=/\s|^$/.test(i),h=/\s|^$/.test(n),u=!h&&(!o||l||a),d=!l&&(!a||h||o),f=u&&(e==42||!d||a),p=d&&(e==42||!u||o);return s.append(new fr(e==95?w_:__,t,r,(f?1:0)|(p?2:0)))},HardBreak(s,e,t){if(e==92&&s.char(t+1)==10)return s.append(Et(Ae.HardBreak,t,t+2));if(e==32){let r=t+1;for(;s.char(r)==32;)r++;if(s.char(r)==10&&r>=t+2)return s.append(Et(Ae.HardBreak,t,r+1))}return-1},Link(s,e,t){return e==91?s.append(new fr(In,t,t+1,1)):-1},Image(s,e,t){return e==33&&s.char(t+1)==91?s.append(new fr(Vh,t,t+2,1)):-1},LinkEnd(s,e,t){if(e!=93)return-1;for(let r=s.parts.length-1;r>=0;r--){let i=s.parts[r];if(i instanceof fr&&(i.type==In||i.type==Vh)){if(!i.side||s.skipSpace(i.to)==t&&!/[(\[]/.test(s.slice(t+1,t+2)))return s.parts[r]=null,-1;let n=s.takeContent(r),a=s.parts[r]=E4(s,n,i.type==In?Ae.Link:Ae.Image,i.from,t+1);if(i.type==In)for(let o=0;o<r;o++){let l=s.parts[o];l instanceof fr&&l.type==In&&(l.side=0)}return a.to}}return-1}};function E4(s,e,t,r,i){let{text:n}=s,a=s.char(i),o=i;if(e.unshift(Et(Ae.LinkMark,r,r+(t==Ae.Image?2:1))),e.push(Et(Ae.LinkMark,i-1,i)),a==40){let l=s.skipSpace(i+1),h=k_(n,l-s.offset,s.offset),u;h&&(l=s.skipSpace(h.to),l!=h.to&&(u=C_(n,l-s.offset,s.offset),u&&(l=s.skipSpace(u.to)))),s.char(l)==41&&(e.push(Et(Ae.LinkMark,i,i+1)),o=l+1,h&&e.push(h),u&&e.push(u),e.push(Et(Ae.LinkMark,l,o)))}else if(a==91){let l=P_(n,i-s.offset,s.offset,!1);l&&(e.push(l),o=l.to)}return Et(t,r,o,e)}function k_(s,e,t){if(s.charCodeAt(e)==60){for(let i=e+1;i<s.length;i++){let n=s.charCodeAt(i);if(n==62)return Et(Ae.URL,e+t,i+1+t);if(n==60||n==10)return!1}return null}else{let i=0,n=e;for(let a=!1;n<s.length;n++){let o=s.charCodeAt(n);if(Tr(o))break;if(a)a=!1;else if(o==40)i++;else if(o==41){if(!i)break;i--}else o==92&&(a=!0)}return n>e?Et(Ae.URL,e+t,n+t):n==s.length?null:!1}}function C_(s,e,t){let r=s.charCodeAt(e);if(r!=39&&r!=34&&r!=40)return!1;let i=r==40?41:r;for(let n=e+1,a=!1;n<s.length;n++){let o=s.charCodeAt(n);if(a)a=!1;else{if(o==i)return Et(Ae.LinkTitle,e+t,n+1+t);o==92&&(a=!0)}}return null}function P_(s,e,t,r){for(let i=!1,n=e+1,a=Math.min(s.length,n+999);n<a;n++){let o=s.charCodeAt(n);if(i)i=!1;else{if(o==93)return r?!1:Et(Ae.LinkLabel,e+t,n+1+t);if(r&&!Tr(o)&&(r=!1),o==91)return!1;o==92&&(i=!0)}}return null}class mg{constructor(e,t,r){this.parser=e,this.text=t,this.offset=r,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,r,i,n){return this.append(new fr(e,t,r,(i?1:0)|(n?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof fr&&(t.type==In||t.type==Vh))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let r=e;r<this.parts.length;r++){let i=this.parts[r];if(!(i instanceof fr&&i.type.resolve&&i.side&2))continue;let n=i.type==w_||i.type==__,a=i.to-i.from,o,l=r-1;for(;l>=e;l--){let b=this.parts[l];if(b instanceof fr&&b.side&1&&b.type==i.type&&!(n&&(i.side&1||b.side&2)&&(b.to-b.from+a)%3==0&&((b.to-b.from)%3||a%3))){o=b;break}}if(!o)continue;let h=i.type.resolve,u=[],d=o.from,f=i.to;if(n){let b=Math.min(2,o.to-o.from,a);d=o.to-b,f=i.from+b,h=b==1?"Emphasis":"StrongEmphasis"}o.type.mark&&u.push(this.elt(o.type.mark,d,o.to));for(let b=l+1;b<r;b++)this.parts[b]instanceof gl&&u.push(this.parts[b]),this.parts[b]=null;i.type.mark&&u.push(this.elt(i.type.mark,i.from,f));let p=this.elt(h,d,f,u);this.parts[l]=n&&o.from!=d?new fr(o.type,o.from,d,o.side):null,(this.parts[r]=n&&i.to!=f?new fr(i.type,f,i.to,i.side):null)?this.parts.splice(r,0,p):this.parts[r]=p}let t=[];for(let r=e;r<this.parts.length;r++){let i=this.parts[r];i instanceof gl&&t.push(i)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let r=this.parts[t];if(r instanceof fr&&r.type==e&&r.side&1)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof fr?t:null}skipSpace(e){return Va(this.text,e-this.offset)+this.offset}elt(e,t,r,i){return typeof e=="string"?Et(this.parser.getNodeType(e),t,r,i):new S_(e,t)}}mg.linkStart=In;mg.imageStart=Vh;function Vm(s,e){if(!e.length)return s;if(!s.length)return e;let t=s.slice(),r=0;for(let i of e){for(;r<t.length&&t[r].to<i.to;)r++;if(r<t.length&&t[r].from<i.from){let n=t[r];n instanceof gl&&(t[r]=new gl(n.type,n.from,n.to,Vm(n.children,[i])))}else t.splice(r++,0,i)}return t}const A4=[Ae.CodeBlock,Ae.ListItem,Ae.OrderedList,Ae.BulletList];class M4{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let n=this.fragment.to;for(;n>0&&this.input.read(n-1,n)!=`
40
+ `;)n--;this.fragmentEnd=n?n-1:0}let r=this.cursor;r||(r=this.cursor=this.fragment.tree.cursor(),r.firstChild());let i=e+this.fragment.offset;for(;r.to<=i;)if(!r.parent())return!1;for(;;){if(r.from>=i)return this.fragment.from<=t;if(!r.childAfter(i))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(bt.contextHash)==e}takeNodes(e){let t=this.cursor,r=this.fragment.offset,i=this.fragmentEnd-(this.fragment.openEnd?1:0),n=e.absoluteLineStart,a=n,o=e.block.children.length,l=a,h=o;for(;;){if(t.to-r>i){if(t.type.isAnonymous&&t.firstChild())continue;break}let u=T_(t.from-r,e.ranges);if(t.to-r<=e.ranges[e.rangeI].to)e.addNode(t.tree,u);else{let d=new Wt(e.parser.nodeSet.types[Ae.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(d,t.tree),e.addNode(d,u)}if(t.type.is("Block")&&(A4.indexOf(t.type.id)<0?(a=t.to-r,o=e.block.children.length):(a=l,o=h),l=t.to-r,h=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return a-n}}function T_(s,e){let t=s;for(let r=1;r<e.length;r++){let i=e[r-1].to,n=e[r].from;i<s&&(t-=n-i)}return t}const L4=Ci({"Blockquote/...":L.quote,HorizontalRule:L.contentSeparator,"ATXHeading1/... SetextHeading1/...":L.heading1,"ATXHeading2/... SetextHeading2/...":L.heading2,"ATXHeading3/...":L.heading3,"ATXHeading4/...":L.heading4,"ATXHeading5/...":L.heading5,"ATXHeading6/...":L.heading6,"Comment CommentBlock":L.comment,Escape:L.escape,Entity:L.character,"Emphasis/...":L.emphasis,"StrongEmphasis/...":L.strong,"Link/... Image/...":L.link,"OrderedList/... BulletList/...":L.list,"BlockQuote/...":L.quote,"InlineCode CodeText":L.monospace,"URL Autolink":L.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":L.processingInstruction,"CodeInfo LinkLabel":L.labelName,LinkTitle:L.string,Paragraph:L.content}),N4=new ud(new kl(v_).extend(L4),Object.keys(Wc).map(s=>Wc[s]),Object.keys(Wc).map(s=>x_[s]),Object.keys(Wc),$4,c_,Object.keys(Of).map(s=>Of[s]),Object.keys(Of),[]);function D4(s,e,t){let r=[];for(let i=s.firstChild,n=e;;i=i.nextSibling){let a=i?i.from:t;if(a>n&&r.push({from:n,to:a}),!i)break;n=i.to}return r}function I4(s){let{codeParser:e,htmlParser:t}=s;return{wrap:Z1((i,n)=>{let a=i.type.id;if(e&&(a==Ae.CodeBlock||a==Ae.FencedCode)){let o="";if(a==Ae.FencedCode){let h=i.node.getChild(Ae.CodeInfo);h&&(o=n.read(h.from,h.to))}let l=e(o);if(l)return{parser:l,overlay:h=>h.type.id==Ae.CodeText,bracketed:a==Ae.FencedCode}}else if(t&&(a==Ae.HTMLBlock||a==Ae.HTMLTag||a==Ae.CommentBlock))return{parser:t,overlay:D4(i.node,i.from,i.to)};return null})}}const B4={resolve:"Strikethrough",mark:"StrikethroughMark"},W4={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":L.strikethrough}},{name:"StrikethroughMark",style:L.processingInstruction}],parseInline:[{name:"Strikethrough",parse(s,e,t){if(e!=126||s.char(t+1)!=126||s.char(t+2)==126)return-1;let r=s.slice(t-1,t),i=s.slice(t+2,t+3),n=/\s|^$/.test(r),a=/\s|^$/.test(i),o=Ol.test(r),l=Ol.test(i);return s.addDelimiter(B4,t,t+2,!a&&(!l||n||o),!n&&(!o||a||l))},after:"Emphasis"}]};function Fa(s,e,t=0,r,i=0){let n=0,a=!0,o=-1,l=-1,h=!1,u=()=>{r.push(s.elt("TableCell",i+o,i+l,s.parser.parseInline(e.slice(o,l),i+o)))};for(let d=t;d<e.length;d++){let f=e.charCodeAt(d);f==124&&!h?((!a||o>-1)&&n++,a=!1,r&&(o>-1&&u(),r.push(s.elt("TableDelimiter",d+i,d+i+1))),o=l=-1):(h||f!=32&&f!=9)&&(o<0&&(o=d),l=d+1),h=!h&&f==92}return o>-1&&(n++,r&&u()),n}function ov(s,e){for(let t=e;t<s.length;t++){let r=s.charCodeAt(t);if(r==124)return!0;r==92&&t++}return!1}const Q_=/^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class av{constructor(){this.rows=null}nextLine(e,t,r){if(this.rows==null){this.rows=!1;let i;if((t.next==45||t.next==58||t.next==124)&&Q_.test(i=t.text.slice(t.pos))){let n=[];Fa(e,r.content,0,n,r.start)==Fa(e,i,0)&&(this.rows=[e.elt("TableHeader",r.start,r.start+r.content.length,n),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let i=[];Fa(e,t.text,t.pos,i,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,i))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0):!1}}const X4={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":L.heading}},"TableRow",{name:"TableCell",style:L.content},{name:"TableDelimiter",style:L.processingInstruction}],parseBlock:[{name:"Table",leaf(s,e){return ov(e.content,0)?new av:null},endLeaf(s,e,t){if(t.parsers.some(i=>i instanceof av)||!ov(e.text,e.basePos))return!1;let r=s.peekLine();return Q_.test(r)&&Fa(s,e.text,e.basePos)==Fa(s,r,e.basePos)},before:"SetextHeading"}]};class z4{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const q4={defineNodes:[{name:"Task",block:!0,style:L.list},{name:"TaskMarker",style:L.atom}],parseBlock:[{name:"TaskList",leaf(s,e){return/^\[[ xX]\][ \t]/.test(e.content)&&s.parentType().name=="ListItem"?new z4:null},after:"SetextHeading"}]},lv=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,cv=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,Z4=/[\w-]+\.[\w-]+($|[/:])/,hv=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,dv=/\/[a-zA-Z\d@.]+/gy;function uv(s,e,t,r){let i=0;for(let n=e;n<t;n++)s[n]==r&&i++;return i}function V4(s,e){cv.lastIndex=e;let t=cv.exec(s);if(!t||Z4.exec(t[0])[0].indexOf("_")>-1)return-1;let r=e+t[0].length;for(;;){let i=s[r-1],n;if(/[?!.,:*_~]/.test(i)||i==")"&&uv(s,e,r,")")>uv(s,e,r,"("))r--;else if(i==";"&&(n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(s.slice(e,r))))r=e+n.index;else break}return r}function fv(s,e){hv.lastIndex=e;let t=hv.exec(s);if(!t)return-1;let r=t[0][t[0].length-1];return r=="_"||r=="-"?-1:e+t[0].length-(r=="."?1:0)}const F4={parseInline:[{name:"Autolink",parse(s,e,t){let r=t-s.offset;if(r&&/\w/.test(s.text[r-1]))return-1;lv.lastIndex=r;let i=lv.exec(s.text),n=-1;if(!i)return-1;if(i[1]||i[2]){if(n=V4(s.text,r+i[0].length),n>-1&&s.hasOpenLink){let a=/([^\[\]]|\[[^\]]*\])*/.exec(s.text.slice(r,n));n=r+a[0].length}}else i[3]?n=fv(s.text,r):(n=fv(s.text,r+i[0].length),n>-1&&i[0]=="xmpp:"&&(dv.lastIndex=n,i=dv.exec(s.text),i&&(n=i.index+i[0].length)));return n<0?-1:(s.addElement(s.elt("URL",t,n+s.offset)),n+s.offset)}}]},U4=[X4,q4,W4,F4];function $_(s,e,t){return(r,i,n)=>{if(i!=s||r.char(n+1)==s)return-1;let a=[r.elt(t,n,n+1)];for(let o=n+1;o<r.end;o++){let l=r.char(o);if(l==s)return r.addElement(r.elt(e,n,o+1,a.concat(r.elt(t,o,o+1))));if(l==92&&a.push(r.elt("Escape",o,o+++2)),Tr(l))break}return-1}}const H4={defineNodes:[{name:"Superscript",style:L.special(L.content)},{name:"SuperscriptMark",style:L.processingInstruction}],parseInline:[{name:"Superscript",parse:$_(94,"Superscript","SuperscriptMark")}]},Y4={defineNodes:[{name:"Subscript",style:L.special(L.content)},{name:"SubscriptMark",style:L.processingInstruction}],parseInline:[{name:"Subscript",parse:$_(126,"Subscript","SubscriptMark")}]},G4={defineNodes:[{name:"Emoji",style:L.character}],parseInline:[{name:"Emoji",parse(s,e,t){let r;return e!=58||!(r=/^[a-zA-Z_0-9]+:/.exec(s.slice(t+1,s.end)))?-1:s.addElement(s.elt("Emoji",t,t+1+r[0].length))}}]},j_=Lp({commentTokens:{block:{open:"<!--",close:"-->"}}}),R_=new bt,E_=N4.configure({props:[Pi.add(s=>!s.is("Block")||s.is("Document")||Fm(s)!=null||K4(s)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),R_.add(Fm),on.add({Document:()=>null}),Xn.add({Document:j_})]});function Fm(s){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return e?+e[1]:void 0}function K4(s){return s.name=="OrderedList"||s.name=="BulletList"}function J4(s,e){let t=s;for(;;){let r=t.nextSibling,i;if(!r||(i=Fm(r.type))!=null&&i<=e)break;t=r}return t.to}const eD=G1.of((s,e,t)=>{for(let r=qt(s).resolveInner(t,-1);r&&!(r.from<e);r=r.parent){let i=r.type.prop(R_);if(i==null)continue;let n=J4(r,i);if(n>t)return{from:t,to:n}}return null});function pg(s){return new _r(j_,s,[],"markdown")}const tD=pg(E_),sD=E_.configure([U4,Y4,H4,G4,{props:[Pi.add({Table:(s,e)=>({from:e.doc.lineAt(s.from).to,to:s.to})})]}]),Fh=pg(sD);function rD(s,e){return t=>{if(t&&s){let r=null;if(t=/\S*/.exec(t)[0],typeof s=="function"?r=s(t):r=Th.matchLanguageName(s,t,!0),r instanceof Th)return r.support?r.support.language.parser:nl.getSkippingParser(r.load());if(r)return r.parser}return e?e.parser:null}}class xf{constructor(e,t,r,i,n,a,o){this.node=e,this.from=t,this.to=r,this.spaceBefore=i,this.spaceAfter=n,this.type=a,this.item=o}blank(e,t=!0){let r=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;r.length<e;)r+=" ";return r}else{for(let i=this.to-this.from-r.length-this.spaceAfter.length;i>0;i--)r+=" ";return r+(t?this.spaceAfter:"")}}marker(e,t){let r=this.node.name=="OrderedList"?String(+M_(this.item,e)[2]+t):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function A_(s,e){let t=[],r=[];for(let i=s;i;i=i.parent){if(i.name=="FencedCode")return r;(i.name=="ListItem"||i.name=="Blockquote")&&t.push(i)}for(let i=t.length-1;i>=0;i--){let n=t[i],a,o=e.lineAt(n.from),l=n.from-o.from;if(n.name=="Blockquote"&&(a=/^ *>( ?)/.exec(o.text.slice(l))))r.push(new xf(n,l,l+a[0].length,"",a[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(l)))){let h=a[3],u=a[0].length;h.length>=4&&(h=h.slice(0,h.length-4),u-=4),r.push(new xf(n.parent,l,l+u,a[1],h,a[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(l)))){let h=a[4],u=a[0].length;h.length>4&&(h=h.slice(0,h.length-4),u-=4);let d=a[2];a[3]&&(d+=a[3].replace(/[xX]/," ")),r.push(new xf(n.parent,l,l+u,a[1],h,d,n))}}return r}function M_(s,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(s.from,s.from+10))}function bf(s,e,t,r=0){for(let i=-1,n=s;;){if(n.name=="ListItem"){let o=M_(n,e),l=+o[2];if(i>=0){if(l!=i+1)return;t.push({from:n.from+o[1].length,to:n.from+o[0].length,insert:String(i+2+r)})}i=l}let a=n.nextSibling;if(!a)break;n=a}}function gg(s,e){let t=/^[ \t]*/.exec(s)[0].length;if(!t||e.facet(Vo)!=" ")return s;let r=Mr(s,4,t),i="";for(let n=r;n>0;)n>=4?(i+=" ",n-=4):(i+=" ",n--);return i+s.slice(t)}const iD=(s={})=>({state:e,dispatch:t})=>{let r=qt(e),{doc:i}=e,n=null,a=e.changeByRange(o=>{if(!o.empty||!Fh.isActiveAt(e,o.from,-1)&&!Fh.isActiveAt(e,o.from,1))return n={range:o};let l=o.from,h=i.lineAt(l),u=A_(r.resolveInner(l,-1),i);for(;u.length&&u[u.length-1].from>l-h.from;)u.pop();if(!u.length)return n={range:o};let d=u[u.length-1];if(d.to-d.spaceAfter.length>l-h.from)return n={range:o};let f=l>=d.to-d.spaceAfter.length&&!/\S/.test(h.text.slice(d.to));if(d.item&&f){let g=d.node.firstChild,m=d.node.getChild("ListItem","ListItem");if(g.to>=l||m&&m.to<l||h.from>0&&!/[^\s>]/.test(i.lineAt(h.from-1).text)||s.nonTightLists===!1){let x=u.length>1?u[u.length-2]:null,y,k="";x&&x.item?(y=h.from+x.from,k=x.marker(i,1)):y=h.from+(x?x.to:0);let C=[{from:y,to:l,insert:k}];return d.node.name=="OrderedList"&&bf(d.item,i,C,-2),x&&x.node.name=="OrderedList"&&bf(x.item,i,C),{range:fe.cursor(y+k.length),changes:C}}else{let x=pv(u,e,h);return{range:fe.cursor(l+x.length+1),changes:{from:h.from,insert:x+e.lineBreak}}}}if(d.node.name=="Blockquote"&&f&&h.from){let g=i.lineAt(h.from-1),m=/>\s*$/.exec(g.text);if(m&&m.index==d.from){let x=e.changes([{from:g.from+m.index,to:g.to},{from:h.from+d.from,to:h.to}]);return{range:o.map(x),changes:x}}}let p=[];d.node.name=="OrderedList"&&bf(d.item,i,p);let v=d.item&&d.item.from<h.from,b="";if(!v||/^[\s\d.)\-+*>]*/.exec(h.text)[0].length>=d.to)for(let g=0,m=u.length-1;g<=m;g++)b+=g==m&&!v?u[g].marker(i,1):u[g].blank(g<m?Mr(h.text,4,u[g+1].from)-b.length:null);let O=l;for(;O>h.from&&/\s/.test(h.text.charAt(O-h.from-1));)O--;return b=gg(b,e),oD(d.node,e.doc)&&(b=pv(u,e,h)+e.lineBreak+b),p.push({from:O,to:l,insert:e.lineBreak+b}),{range:fe.cursor(O+b.length+1),changes:p}});return n?!1:(t(e.update(a,{scrollIntoView:!0,userEvent:"input"})),!0)},nD=iD();function mv(s){return s.name=="QuoteMark"||s.name=="ListMark"}function oD(s,e){if(s.name!="OrderedList"&&s.name!="BulletList")return!1;let t=s.firstChild,r=s.getChild("ListItem","ListItem");if(!r)return!1;let i=e.lineAt(t.to),n=e.lineAt(r.from),a=/^[\s>]*$/.test(i.text);return i.number+(a?0:1)<n.number}function pv(s,e,t){let r="";for(let i=0,n=s.length-2;i<=n;i++)r+=s[i].blank(i<n?Mr(t.text,4,s[i+1].from)-r.length:null,i<n);return gg(r,e)}function aD(s,e){let t=s.resolveInner(e,-1),r=e;mv(t)&&(r=t.from,t=t.parent);for(let i;i=t.childBefore(r);)if(mv(i))r=i.from;else if(i.name=="OrderedList"||i.name=="BulletList")t=i.lastChild,r=t.to;else break;return t}const lD=({state:s,dispatch:e})=>{let t=qt(s),r=null,i=s.changeByRange(n=>{let a=n.from,{doc:o}=s;if(n.empty&&Fh.isActiveAt(s,n.from)){let l=o.lineAt(a),h=A_(aD(t,a),o);if(h.length){let u=h[h.length-1],d=u.to-u.spaceAfter.length+(u.spaceAfter?1:0);if(a-l.from>d&&!/\S/.test(l.text.slice(d,a-l.from)))return{range:fe.cursor(l.from+d),changes:{from:l.from+d,to:a}};if(a-l.from==d&&(u.item&&l.from<=u.item.from||/^[\s>]*$/.test(l.text.slice(0,u.to)))){let f=l.from+u.from;if(u.item&&u.node.from<u.item.from&&/\S/.test(l.text.slice(u.from,u.to))){let p=u.blank(Mr(l.text,4,u.to)-Mr(l.text,4,u.from));return f==l.from&&(p=gg(p,s)),{range:fe.cursor(f+p.length),changes:{from:f,to:l.from+u.to,insert:p}}}if(f<a)return{range:fe.cursor(f),changes:{from:f,to:a}}}}}return r={range:n}});return r?!1:(e(s.update(i,{scrollIntoView:!0,userEvent:"delete"})),!0)},cD=[{key:"Enter",run:nD},{key:"Backspace",run:lD}],L_=l_({matchClosingTags:!1});function hD(s={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:r=!0,base:{parser:i}=tD,completeHTMLTags:n=!0,pasteURLAsLink:a=!0,htmlTagLanguage:o=L_}=s;if(!(i instanceof ud))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[o.support,eD],u;a&&h.push(mD),t instanceof rn?(h.push(t.support),u=t.language):t&&(u=t);let d=e||u?rD(e,u):void 0;l.push(I4({codeParser:d,htmlParser:o.language.parser})),r&&h.push(ki.high(Zo.of(cD)));let f=pg(i.configure(l));return n&&h.push(f.data.of({autocomplete:dD})),new rn(f,h)}function dD(s){let{state:e,pos:t}=s,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!r)return null;let i=qt(e).resolveInner(t,-1);for(;i&&!i.type.isTop;){if(i.name=="CodeBlock"||i.name=="FencedCode"||i.name=="ProcessingInstructionBlock"||i.name=="CommentBlock"||i.name=="Link"||i.name=="Image")return null;i=i.parent}return{from:t-r[0].length,to:t,options:uD(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let vf=null;function uD(){if(vf)return vf;let s=S4(new Up($t.create({extensions:L_}),0,!0));return vf=s?s.options:[]}const fD=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,mD=We.domEventHandlers({paste:(s,e)=>{var t;let{main:r}=e.state.selection;if(r.empty)return!1;let i=(t=s.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!i||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(i)||(/^www\./.test(i)&&(i="https://"+i),!Fh.isActiveAt(e.state,r.from,1)))return!1;let n=qt(e.state),a=!1;return n.iterate({from:r.from,to:r.to,enter:o=>{(o.from>r.from||fD.test(o.name))&&(a=!0)},leave:o=>{o.to<r.to&&(a=!0)}}),a?!1:(e.dispatch({changes:[{from:r.from,insert:"["},{from:r.to,insert:`](${i})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),Um=1,pD=2,gD=3,OD=4,xD=5,bD=36,vD=37,yD=38,SD=11,wD=13;function _D(s){return s==45||s==46||s==58||s>=65&&s<=90||s==95||s>=97&&s<=122||s>=161}function kD(s){return s==9||s==10||s==13||s==32}let gv=null,Ov=null,xv=0;function Hm(s,e){let t=s.pos+e;if(Ov==s&&xv==t)return gv;for(;kD(s.peek(e));)e++;let r="";for(;;){let i=s.peek(e);if(!_D(i))break;r+=String.fromCharCode(i),e++}return Ov=s,xv=t,gv=r||null}function bv(s,e){this.name=s,this.parent=e}const CD=new hd({start:null,shift(s,e,t,r){return e==Um?new bv(Hm(r,1)||"",s):s},reduce(s,e){return e==SD&&s?s.parent:s},reuse(s,e,t,r){let i=e.type.id;return i==Um||i==wD?new bv(Hm(r,1)||"",s):s},strict:!1}),PD=new ps((s,e)=>{if(s.next==60){if(s.advance(),s.next==47){s.advance();let t=Hm(s,0);if(!t)return s.acceptToken(xD);if(e.context&&t==e.context.name)return s.acceptToken(pD);for(let r=e.context;r;r=r.parent)if(r.name==t)return s.acceptToken(gD,-2);s.acceptToken(OD)}else if(s.next!=33&&s.next!=63)return s.acceptToken(Um)}},{contextual:!0});function Og(s,e){return new ps(t=>{let r=0,i=e.charCodeAt(0);e:for(;!(t.next<0);t.advance(),r++)if(t.next==i){for(let n=1;n<e.length;n++)if(t.peek(n)!=e.charCodeAt(n))continue e;break}r&&t.acceptToken(s)})}const TD=Og(bD,"-->"),QD=Og(vD,"?>"),$D=Og(yD,"]]>"),jD=Ci({Text:L.content,"StartTag StartCloseTag EndTag SelfCloseEndTag":L.angleBracket,TagName:L.tagName,"MismatchedCloseTag/TagName":[L.tagName,L.invalid],AttributeName:L.attributeName,AttributeValue:L.attributeValue,Is:L.definitionOperator,"EntityReference CharacterReference":L.character,Comment:L.blockComment,ProcessingInst:L.processingInstruction,DoctypeDecl:L.documentMeta,Cdata:L.special(L.string)}),RD=_i.deserialize({version:14,states:",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Ox]O~O^`Oz^O~OPQOQcOSVOTWOVWOWWOXWOyPO!QTO!SUO~ORdO~P!SOteO!PgO~OuhO!RjO~O^lOz^O~OvZOxoO~O^qOz^O~O[vO`sOdwOz^O~ORyO~P!SO^{Oz^O~OteO!P}O~OuhO!R!PO~O^!QOz^O~O[!SOz^O~O[!VO`sOd!WOz^O~Oa!YOz^O~Oz^O[mX`mXdmX~O[!VO`sOd!WO~O^!]Oz^O~O[!_Oz^O~O[!aOz^O~O[!cO`sOd!dOz^O~O[!cO`sOd!dO~Oa!eOz^O~Oz^O{!gO}!hO~Oz^O[ma`madma~O[!kOz^O~O[!lOz^O~O[!mO`sOd!nO~OW!qOX!qO{!sO|!qO~OW!tOX!tO}!sO!O!tO~O[!vOz^O~OW!qOX!qO{!yO|!qO~OW!tOX!tO}!yO!O!tO~O",goto:"%cxPPPPPPPPPPyyP!PP!VPP!`!jP!pyyyP!v!|#S$[$k$q$w$}%TPPPP%ZXWORYbXRORYb_t`qru!T!U!bQ!i!YS!p!e!fR!w!oQdRRybXSORYbQYORmYQ[PRn[Q_QQkVjp_krz!R!T!X!Z!^!`!f!j!oQr`QzcQ!RlQ!TqQ!XsQ!ZtQ!^{Q!`!QQ!f!YQ!j!]R!o!eQu`S!UqrU![u!U!bR!b!TQ!r!gR!x!rQ!u!hR!z!uQbRRxbQfTR|fQiUR!OiSXOYTaRb",nodeNames:"⚠ StartTag StartCloseTag MissingCloseTag StartCloseTag StartCloseTag Document Text EntityReference CharacterReference Cdata Element EndTag OpenTag TagName Attribute AttributeName Is AttributeValue CloseTag SelfCloseEndTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag DoctypeDecl",maxTerm:50,context:CD,nodeProps:[["closedBy",1,"SelfCloseEndTag EndTag",13,"CloseTag MissingCloseTag"],["openedBy",12,"StartTag StartCloseTag",19,"OpenTag",20,"StartTag"],["isolate",-6,13,18,19,21,22,24,""]],propSources:[jD],skippedNodes:[0],repeatNodeCount:9,tokenData:"!)v~R!YOX$q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;'S$q;'S;=`)c<%lO$qk!&kX!RQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk!'aZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_#P$q#P#Q!(S#Q;'S$q;'S;=`)c<%lO$qk!(]ZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a!)O!a;'S$q;'S;=`)c<%lO$qk!)ZXxQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$q",tokenizers:[PD,TD,QD,$D,0,1,2,3,4],topRules:{Document:[0,6]},tokenPrec:0});function hh(s,e){let t=e&&e.getChild("TagName");return t?s.sliceString(t.from,t.to):""}function yf(s,e){let t=e&&e.firstChild;return!t||t.name!="OpenTag"?"":hh(s,t)}function ED(s,e,t){let r=e&&e.getChildren("Attribute").find(n=>n.from<=t&&n.to>=t),i=r&&r.getChild("AttributeName");return i?s.sliceString(i.from,i.to):""}function Sf(s){for(let e=s&&s.parent;e;e=e.parent)if(e.name=="Element")return e;return null}function AD(s,e){var t;let r=qt(s).resolveInner(e,-1),i=null;for(let n=r;!i&&n.parent;n=n.parent)(n.name=="OpenTag"||n.name=="CloseTag"||n.name=="SelfClosingTag"||n.name=="MismatchedCloseTag")&&(i=n);if(i&&(i.to>e||i.lastChild.type.isError)){let n=i.parent;if(r.name=="TagName")return i.name=="CloseTag"||i.name=="MismatchedCloseTag"?{type:"closeTag",from:r.from,context:n}:{type:"openTag",from:r.from,context:Sf(n)};if(r.name=="AttributeName")return{type:"attrName",from:r.from,context:i};if(r.name=="AttributeValue")return{type:"attrValue",from:r.from,context:i};let a=r==i||r.name=="Attribute"?r.childBefore(e):r;return a?.name=="StartTag"?{type:"openTag",from:e,context:Sf(n)}:a?.name=="StartCloseTag"&&a.to<=e?{type:"closeTag",from:e,context:n}:a?.name=="Is"?{type:"attrValue",from:e,context:i}:a?{type:"attrName",from:e,context:i}:null}else if(r.name=="StartCloseTag")return{type:"closeTag",from:e,context:r.parent};for(;r.parent&&r.to==e&&!(!((t=r.lastChild)===null||t===void 0)&&t.type.isError);)r=r.parent;return r.name=="Element"||r.name=="Text"||r.name=="Document"?{type:"tag",from:e,context:r.name=="Element"?r:Sf(r)}:null}class MD{constructor(e,t,r){this.attrs=t,this.attrValues=r,this.children=[],this.name=e.name,this.completion=Object.assign(Object.assign({type:"type"},e.completion||{}),{label:this.name}),this.openCompletion=Object.assign(Object.assign({},this.completion),{label:"<"+this.name}),this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:"</"+this.name+">",boost:2}),this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+">"}),this.text=e.textContent?e.textContent.map(i=>({label:i,type:"text"})):[]}}const wf=/^[:\-\.\w\u00b7-\uffff]*$/;function vv(s){return Object.assign(Object.assign({type:"property"},s.completion||{}),{label:s.name})}function yv(s){return typeof s=="string"?{label:`"${s}"`,type:"constant"}:/^"/.test(s.label)?s:Object.assign(Object.assign({},s),{label:`"${s.label}"`})}function LD(s,e){let t=[],r=[],i=Object.create(null);for(let l of e){let h=vv(l);t.push(h),l.global&&r.push(h),l.values&&(i[l.name]=l.values.map(yv))}let n=[],a=[],o=Object.create(null);for(let l of s){let h=r,u=i;l.attributes&&(h=h.concat(l.attributes.map(f=>typeof f=="string"?t.find(p=>p.label==f)||{label:f,type:"property"}:(f.values&&(u==i&&(u=Object.create(u)),u[f.name]=f.values.map(yv)),vv(f)))));let d=new MD(l,h,u);o[d.name]=d,n.push(d),l.top&&a.push(d)}a.length||(a=n);for(let l=0;l<n.length;l++){let h=s[l],u=n[l];if(h.children)for(let d of h.children)o[d]&&u.children.push(o[d]);else u.children=n}return l=>{var h;let{doc:u}=l.state,d=AD(l.state,l.pos);if(!d||d.type=="tag"&&!l.explicit)return null;let{type:f,from:p,context:v}=d;if(f=="openTag"){let b=a,O=yf(u,v);if(O){let g=o[O];b=g?.children||n}return{from:p,options:b.map(g=>g.completion),validFor:wf}}else if(f=="closeTag"){let b=yf(u,v);return b?{from:p,to:l.pos+(u.sliceString(l.pos,l.pos+1)==">"?1:0),options:[((h=o[b])===null||h===void 0?void 0:h.closeNameCompletion)||{label:b+">",type:"type"}],validFor:wf}:null}else if(f=="attrName"){let b=o[hh(u,v)];return{from:p,options:b?.attrs||r,validFor:wf}}else if(f=="attrValue"){let b=ED(u,v,p);if(!b)return null;let O=o[hh(u,v)],g=(O?.attrValues||i)[b];return!g||!g.length?null:{from:p,to:l.pos+(u.sliceString(l.pos,l.pos+1)=='"'?1:0),options:g,validFor:/^"[^"]*"?$/}}else if(f=="tag"){let b=yf(u,v),O=o[b],g=[],m=v&&v.lastChild;b&&(!m||m.name!="CloseTag"||hh(u,m)!=b)&&g.push(O?O.closeCompletion:{label:"</"+b+">",type:"type",boost:2});let x=g.concat((O?.children||(v?n:a)).map(y=>y.openCompletion));if(v&&O?.text.length){let y=v.firstChild;y.to>l.pos-20&&!/\S/.test(l.state.sliceDoc(y.to,l.pos))&&(x=x.concat(O.text))}return{from:p,options:x,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}else return null}}const Ym=wi.define({name:"xml",parser:RD.configure({props:[on.add({Element(s){let e=/^\s*<\//.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},"OpenTag CloseTag SelfClosingTag"(s){return s.column(s.node.from)+s.unit}}),Pi.add({Element(s){let e=s.firstChild,t=s.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:s.to}}}),Bp.add({"OpenTag CloseTag":s=>s.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/$/}});function ND(s={}){let e=[Ym.data.of({autocomplete:LD(s.elements||[],s.attributes||[])})];return s.autoCloseTags!==!1&&e.push(DD),new rn(Ym,e)}function Sv(s,e,t=s.length){if(!e)return"";let r=e.firstChild,i=r&&r.getChild("TagName");return i?s.sliceString(i.from,Math.min(i.to,t)):""}const DD=We.inputHandler.of((s,e,t,r,i)=>{if(s.composing||s.state.readOnly||e!=t||r!=">"&&r!="/"||!Ym.isActiveAt(s.state,e,-1))return!1;let n=i(),{state:a}=n,o=a.changeByRange(l=>{var h,u,d;let{head:f}=l,p=a.doc.sliceString(f-1,f)==r,v=qt(a).resolveInner(f,-1),b;if(p&&r==">"&&v.name=="EndTag"){let O=v.parent;if(((u=(h=O.parent)===null||h===void 0?void 0:h.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(b=Sv(a.doc,O.parent,f))){let g=f+(a.doc.sliceString(f,f+1)===">"?1:0),m=`</${b}>`;return{range:l,changes:{from:f,to:g,insert:m}}}}else if(p&&r=="/"&&v.name=="StartCloseTag"){let O=v.parent;if(v.from==f-2&&((d=O.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=Sv(a.doc,O,f))){let g=f+(a.doc.sliceString(f,f+1)===">"?1:0),m=`${b}>`;return{range:fe.cursor(f+m.length,-1),changes:{from:f,to:g,insert:m}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function ID(){const s=()=>{const r=document.documentElement;return r.classList.contains("light")?!1:r.classList.contains("dark")||r.classList.contains("cyberpunk")||r.classList.contains("mono")?!0:window.matchMedia("(prefers-color-scheme: dark)").matches},[e,t]=w.useState(s);return w.useEffect(()=>{const r=new MutationObserver(()=>t(s()));r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const i=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>t(s());return i.addEventListener("change",n),()=>{r.disconnect(),i.removeEventListener("change",n)}},[]),e}function xg(s,e){if(e==="markdown")return"markdown";if(e==="html")return"html";if(e==="json")return"json";const t=s.split(/[/\\]/).pop()?.toLowerCase()||"";switch(t.includes(".")?t.split(".").pop():t){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"json":case"jsonc":return"json";case"py":return"python";case"css":case"scss":case"less":return"css";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"xml":case"svg":return"xml";default:return"text"}}function BD(s){switch(s){case"typescript":return[nh({typescript:!0})];case"tsx":return[nh({typescript:!0,jsx:!0})];case"javascript":return[nh({jsx:!0})];case"json":return[LM()];case"python":return[KL()];case"css":return[zw()];case"html":return[l_()];case"markdown":return[hD()];case"xml":return[ND()];default:return[]}}function N_({path:s,initialContent:e,language:t,hideToolbar:r=!1,onSaved:i,onDirtyChange:n,className:a=""}){const{t:o}=Tt("common"),l=ID(),h=t??xg(s),[u,d]=w.useState(e),[f,p]=w.useState(e),[v,b]=w.useState(!1),[O,g]=w.useState("idle"),[m,x]=w.useState(null),y=w.useRef(null),k=w.useRef(u),C=w.useRef(f);k.current=u,C.current=f;const P=u!==f;w.useEffect(()=>{d(e),p(e),g("idle"),x(null)},[s,e]),w.useEffect(()=>{n?.(P)},[P,n]);const _=w.useMemo(()=>{const N=[...BD(h),We.theme({"&":{height:"100%",fontSize:"13px"},".cm-scroller":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",lineHeight:"1.5"},".cm-content":{paddingBottom:"2rem"}})];return(h==="markdown"||h==="html")&&N.push(We.lineWrapping),N},[h]),Q=w.useCallback(async()=>{if(v)return;const N=k.current;if(N!==C.current){b(!0),x(null),g("idle");try{await ne.files.write(s,N),p(N),C.current=N,g("saved"),i?.(N),window.setTimeout(()=>g(R=>R==="saved"?"idle":R),1600)}catch(R){g("error"),x(R instanceof Error?R.message:String(R))}finally{b(!1)}}},[s,v,i]),E=w.useCallback(()=>{d(C.current),g("idle"),x(null)},[]);w.useEffect(()=>{const N=R=>{if(!(navigator.platform.toUpperCase().includes("MAC")?R.metaKey:R.ctrlKey)||R.altKey||R.shiftKey||R.key.toLowerCase()!=="s")return;const Z=y.current,B=document.activeElement;!Z||!(B instanceof Node)||!Z.contains(B)||(R.preventDefault(),Q())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[Q]);const A=s.split(/[/\\]/).pop()||s;return c.jsxs("div",{ref:y,className:`flex flex-col min-h-0 flex-1 ${a}`,children:[!r&&c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-2 py-1.5 border-b border-border-default bg-surface-elevated/60",children:[c.jsxs("span",{className:"text-xs text-fg-secondary truncate min-w-0 flex items-center gap-1.5",children:[P&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0",title:o("fileEditor.unsaved")}),c.jsx("span",{className:"truncate font-mono",children:A})]}),c.jsx("div",{className:"flex-1"}),O==="saved"&&c.jsx("span",{className:"text-[11px] text-green-600",children:o("fileEditor.saved")}),O==="error"&&c.jsx("span",{className:"text-[11px] text-red-500 truncate max-w-[40%]",title:m||void 0,children:o("fileEditor.saveFailed")}),P&&c.jsx("button",{type:"button",onClick:E,className:"px-2 py-1 text-[11px] rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o("fileEditor.revert")}),c.jsx("button",{type:"button",onClick:()=>{Q()},disabled:!P||v,className:"px-2.5 py-1 text-[11px] font-medium rounded-md bg-brand-600 text-on-brand hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:o(v?"saving":"save")})]}),r&&c.jsxs("div",{className:"shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border-default",children:[O==="saved"&&c.jsx("span",{className:"text-[11px] text-green-600",children:o("fileEditor.saved")}),O==="error"&&c.jsx("span",{className:"text-[11px] text-red-500",children:o("fileEditor.saveFailed")}),P&&c.jsx("button",{type:"button",onClick:E,className:"px-2 py-1 text-[11px] rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o("fileEditor.revert")}),c.jsx("button",{type:"button",onClick:()=>{Q()},disabled:!P||v,className:"px-2.5 py-1 text-[11px] font-medium rounded-md bg-brand-600 text-on-brand hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:o(v?"saving":"save")})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:c.jsx(pw,{value:u,height:"100%",theme:l?mw:"light",extensions:_,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1},onChange:N=>{d(N),(O==="saved"||O==="error")&&g("idle")},className:"h-full [&_.cm-editor]:h-full [&_.cm-editor]:outline-none"})})]})}function D_(s,e){return s?window.confirm(e):!0}function WD({path:s,content:e,format:t,basePath:r,onHtmlSelection:i,onDirtyChange:n,className:a="",copyVariant:o}){const{t:l}=Tt("common"),[h,u]=w.useState("preview"),[d,f]=w.useState(e),[p,v]=w.useState(e),[b,O]=w.useState(!1);w.useEffect(()=>{f(e),v(e),u("preview"),O(!1)},[s,e]),w.useEffect(()=>{n?.(b)},[b,n]);const g=w.useCallback(x=>{if(x!==h){if(h==="edit"&&x==="preview"){if(!D_(b,l("fileEditor.discardConfirm")))return;b&&(f(p),O(!1))}u(x)}},[h,b,l,p]),m=xg(s,t);return c.jsxs("div",{className:`flex flex-col min-h-0 flex-1 ${a}`,children:[c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-2 py-1.5 border-b border-border-default bg-surface-elevated/60",children:[c.jsxs("div",{className:"inline-flex rounded-md border border-border-default overflow-hidden text-[11px]",children:[c.jsx("button",{type:"button",onClick:()=>g("preview"),className:`px-2.5 py-1 transition-colors ${h==="preview"?"bg-brand-600/20 text-brand-500 font-medium":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,children:l("fileEditor.preview")}),c.jsx("button",{type:"button",onClick:()=>g("edit"),className:`px-2.5 py-1 border-l border-border-default transition-colors ${h==="edit"?"bg-brand-600/20 text-brand-500 font-medium":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,children:l("edit")})]}),b&&h==="edit"&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500",title:l("fileEditor.unsaved")}),c.jsx("div",{className:"flex-1"})]}),h==="preview"?c.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-1 py-2",children:c.jsx(Bf,{content:d,format:t,className:"text-fg-secondary text-sm",onHtmlSelection:i,basePath:r,copyVariant:o})}):c.jsx(N_,{path:s,initialContent:d,language:m,hideToolbar:!0,onDirtyChange:O,onSaved:x=>{f(x),v(x),O(!1)}})]})}const jl={bing:{id:"bing",name:"Bing",searchUrl:s=>`https://www.bing.com/search?q=${encodeURIComponent(s)}`},google:{id:"google",name:"Google",searchUrl:s=>`https://www.google.com/search?q=${encodeURIComponent(s)}`},duckduckgo:{id:"duckduckgo",name:"DuckDuckGo",searchUrl:s=>`https://duckduckgo.com/?q=${encodeURIComponent(s)}`},baidu:{id:"baidu",name:"Baidu",searchUrl:s=>`https://www.baidu.com/s?wd=${encodeURIComponent(s)}`},yandex:{id:"yandex",name:"Yandex",searchUrl:s=>`https://yandex.com/search/?text=${encodeURIComponent(s)}`},brave:{id:"brave",name:"Brave",searchUrl:s=>`https://search.brave.com/search?q=${encodeURIComponent(s)}`},sogou:{id:"sogou",name:"Sogou",searchUrl:s=>`https://www.sogou.com/web?query=${encodeURIComponent(s)}`},so360:{id:"so360",name:"360 Search",searchUrl:s=>`https://www.so.com/s?q=${encodeURIComponent(s)}`}},XD=Object.keys(jl),zD="bing",I_="markus:browser-search-engine";function B_(){try{const s=localStorage.getItem(I_);if(s&&jl[s])return s}catch{}return zD}function qD(s){if(jl[s])try{localStorage.setItem(I_,s)}catch{}}function ZD(s){const e=s.trim();return e?!!(e==="about:blank"||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||W_(e)||/^localhost(:\d+)?([/?#].*)?$/i.test(e)||FD(e)||!/\s/.test(e)&&UD(e)):!1}function VD(s,e){const t=s.trim();return t&&(ZD(t)?HD(t):jl[e??B_()].searchUrl(t))}function FD(s){return!!(/^\d{1,3}(\.\d{1,3}){3}(:\d+)?([/?#].*)?$/.test(s)||/^\[[0-9a-fA-F:.]+\](:\d+)?([/?#].*)?$/.test(s))}function UD(s){const e=s.split(/[/?#]/)[0].replace(/:\d+$/,"");return!e||e.split(".").length<2||/^v?\d/i.test(e)&&/^\d+(\.\d+)*$/.test(e.replace(/^v/i,""))?!1:/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i.test(e)}function HD(s){const e=s.trim();return!e||e==="about:blank"?e:YD(e)?`http://${e}`:/^[a-z][a-z0-9+.-]*:/i.test(e)?/^file:/i.test(e)?GD(e):e:e.startsWith("//")?`https:${e}`:W_(e)?X_(e):`https://${e}`}function YD(s){return!!(/^localhost(:\d+)?([/?#].*)?$/i.test(s)||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?([/?#].*)?$/.test(s)||/^\[[0-9a-fA-F:.]+\](:\d+)?([/?#].*)?$/.test(s))}function W_(s){return!!(s.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(s)||s.startsWith("\\\\"))}function X_(s){const e=s.replace(/\\/g,"/");return e.startsWith("//")?`file:${_f(e)}`:/^[a-zA-Z]:\//.test(e)?`file:///${_f(e)}`:`file://${_f(e)}`}function GD(s){try{return new URL(s).href}catch{let e=s.replace(/^file:/i,"").replace(/\\/g,"/");return e.startsWith("//")&&(e=e.replace(/^\/\/(localhost)?/i,""),!e.startsWith("/")&&!/^[a-zA-Z]:\//.test(e)&&(e=`/${e}`)),/^\/[a-zA-Z]:\//.test(e)&&(e=e.slice(1)),!e.startsWith("/")&&!/^[a-zA-Z]:\//.test(e)&&(e=`/${e}`),X_(e)}}function _f(s){return encodeURI(s).replace(/#/g,"%23")}async function z_(s,e){const{openPanel:t}=e;if(!t)return"skipped";if(s.kind==="url")return t({kind:"url",url:s.target,title:s.title}),"opened";if(s.kind==="file")return t({kind:"file",path:s.target,title:s.title}),"opened";const r=e.getDeliverable??ne.deliverables.get;try{const{deliverable:i}=await r(s.target);if(i)return t({kind:"deliverable",deliverable:i}),"opened"}catch{}return s.location?(t({kind:"file",path:s.location,title:s.title}),"opened"):"skipped"}function q_({items:s,query:e,activeIndex:t,onHover:r,onPick:i,onRemove:n,onClear:a,anchorClassName:o="left-0 right-0 top-full mt-1",keyboardHint:l=!0}){const{t:h}=Tt("common"),u=e.trim()?h("browserHistoryMatches",{defaultValue:"历史记录"}):h("browserHistoryRecent",{defaultValue:"最近访问"});return s.length===0?c.jsx("div",{role:"listbox",className:`absolute z-50 rounded-lg border border-border-default bg-surface-elevated shadow-xl overflow-hidden ${o}`,children:c.jsx("div",{className:"px-2.5 py-3 text-[11px] text-fg-tertiary text-center",children:e.trim()?h("browserHistoryEmpty",{defaultValue:"没有匹配的历史记录"}):h("browserHistoryNone",{defaultValue:"暂无浏览历史"})})}):c.jsxs("div",{role:"listbox","aria-label":u,className:`absolute z-50 rounded-lg border border-border-default bg-surface-elevated shadow-xl overflow-hidden ${o}`,children:[c.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[10px] uppercase tracking-wide text-fg-muted border-b border-border-default/60 select-none",children:[c.jsx("span",{children:u}),l&&c.jsx("span",{className:"ml-auto normal-case tracking-normal text-fg-tertiary/80 truncate",title:h("browserHistoryKeyboardHint",{defaultValue:"↑↓ 或 Ctrl+N/P 选择 · Enter 打开"}),children:h("browserHistoryKeyboardHint",{defaultValue:"↑↓ 或 Ctrl+N/P 选择 · Enter 打开"})})]}),c.jsx("ul",{className:"max-h-72 overflow-y-auto scrollbar-thin py-0.5",children:s.map((d,f)=>{const p=f===t,v=mC(d);return c.jsx("li",{children:c.jsxs("div",{role:"option","aria-selected":p,tabIndex:-1,className:`group flex items-center gap-2 pl-2.5 pr-1.5 py-1.5 cursor-pointer ${p?"bg-brand-500/15":"hover:bg-surface-overlay/60"}`,onMouseEnter:()=>r(f),onMouseDown:b=>{b.preventDefault(),b.button===0&&i(d)},children:[c.jsx(KD,{kind:d.kind,active:p}),c.jsxs("div",{className:"min-w-0 flex-1",children:[d.title&&c.jsx("div",{className:"text-[11px] text-fg-primary truncate leading-tight",children:d.title}),c.jsx("div",{className:`truncate leading-tight ${d.title?"text-[10px] text-fg-tertiary":"text-[11px] text-fg-secondary"}`,children:v})]}),c.jsx("button",{type:"button",title:h("browserHistoryRemove",{defaultValue:"从历史记录中移除"}),"aria-label":h("browserHistoryRemove",{defaultValue:"从历史记录中移除"}),className:"shrink-0 w-5 h-5 flex items-center justify-center rounded text-fg-muted opacity-0 group-hover:opacity-100 hover:text-fg-secondary hover:bg-surface-overlay transition-opacity",onMouseDown:b=>{b.preventDefault(),b.stopPropagation(),n(d)},children:c.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":!0,children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})},op(d))})}),c.jsx("button",{type:"button",className:"w-full px-2.5 py-1.5 text-[10px] text-fg-tertiary text-left border-t border-border-default/60 hover:bg-surface-overlay/60 hover:text-fg-secondary transition-colors",onMouseDown:d=>{d.preventDefault(),a()},children:h("browserHistoryClear",{defaultValue:"清除全部历史记录"})})]})}function KD({kind:s,active:e}){const t=e?"text-brand-500":"text-fg-muted";return s==="file"?c.jsxs("svg",{className:`shrink-0 ${t}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}):s==="deliverable"?c.jsxs("svg",{className:`shrink-0 ${t}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[c.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),c.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),c.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]}):c.jsxs("svg",{className:`shrink-0 ${t}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[c.jsx("circle",{cx:"12",cy:"12",r:"9"}),c.jsx("polyline",{points:"12 7 12 12 15.5 14"})]})}function JD({url:s,browserId:e,className:t,onMeta:r}){const{t:i}=Tt("common"),n=w.useId().replace(/:/g,""),a=e||`eb_${n}`,o=!e,l=w.useRef(null),h=w.useRef(null),u=w.useRef(null),[d,f]=w.useState(s==="about:blank"?"":s),[p,v]=w.useState(!1),[b,O]=w.useState(!1),[g,m]=w.useState(!1),[x,y]=w.useState(null),[k,C]=w.useState(null),[P,_]=w.useState(()=>B_()),[Q,E]=w.useState(!1),[A,N]=w.useState(!1),[R,W]=w.useState([]),[H,Z]=w.useState(-1),B=typeof window<"u"?window.markusDesktop?.browser:void 0,K=typeof window<"u"?window.markusDesktop?.platform:void 0,$=zo();u.current=k;const I=i(K==="darwin"?"browserFolderAppFinder":K==="win32"?"browserFolderAppExplorer":"browserFolderAppGeneric"),X=re=>{const U=EO(re,8);return W(U),U},q=()=>{N(!1),Z(-1)},ie=re=>{const U=X(re);N(U.length>0),Z(-1)},pe=(re,U)=>{const M=VD(re,P);M&&(q(),m(!0),y(null),C(null),f(M),B?.navigate(a,M),AO(M,U))},$e=re=>{if(re.kind==="url"){pe(re.target,re.title);return}q(),z_(re,{openPanel:$?.openRightPanel})};return w.useEffect(()=>{if(!B)return;let re=!1;return(async()=>{const U=await B.getState(a);if(re)return;if(U.ok)s&&U.url!==s&&!U.directoryPath?(m(!0),await B.navigate(a,s)):s&&U.directoryPath&&U.url!==s&&await B.navigate(a,s);else{m(!0);const te=await B.create(a,s);if(re||!te.ok){re&&o&&B.destroy(a);return}}if(re)return;const M=await B.getState(a);re||!M.ok||(document.activeElement!==h.current&&f(M.url&&M.url!=="about:blank"?M.url:s==="about:blank"?"":s),m(!!M.isLoading),y(M.loadError??null),C(M.directoryPath??null),(M.pageId!=null||M.url||M.title)&&r?.({pageId:M.pageId,url:M.url&&M.url!=="about:blank"?M.url:void 0,title:M.title||void 0}),s==="about:blank"&&requestAnimationFrame(()=>{re||(h.current?.focus({preventScroll:!0}),h.current?.select())}))})(),()=>{re=!0,o&&B.destroy(a)}},[B,a,s,o]),w.useEffect(()=>{if(s!=="about:blank")return;let re=!1;const U=()=>{if(re)return;const Y=h.current;Y&&(Y.focus({preventScroll:!0}),Y.select())};U();const M=[0,50,150,300].map(Y=>window.setTimeout(U,Y)),te=requestAnimationFrame(U);return()=>{re=!0,cancelAnimationFrame(te);for(const Y of M)clearTimeout(Y)}},[s,a]),w.useEffect(()=>{N(!1),Z(-1)},[s,a]),w.useEffect(()=>A?pC():void 0,[A]),w.useEffect(()=>{if(A)return Kv(()=>{W(EO(h.current?.value??"",8))})},[A]),w.useEffect(()=>{if(B?.onPageEvent)return B.onPageEvent(re=>{if(re.browserId===a){if(re.type==="directory"){C(re.directoryPath||null),m(!1),y(null),re.url&&document.activeElement!==h.current&&f(re.url);return}if(re.type==="loading"){m(!0),y(null),C(null);return}if(re.type==="loaded"){if(m(!1),u.current)return;re.url&&re.url!=="about:blank"&&AO(re.url,re.title),re.url&&document.activeElement!==h.current&&f(re.url==="about:blank"?"":re.url),window.dispatchEvent(new Event("markus:embedded-browser-resync"));return}if(re.type==="load-failed"){if(m(!1),u.current)return;y(re.error||"Load failed"),re.url&&document.activeElement!==h.current&&f(re.url==="about:blank"?"":re.url);return}re.type==="navigated"&&re.url&&document.activeElement!==h.current&&(u.current||f(re.url==="about:blank"?"":re.url))}})},[B,a]),w.useEffect(()=>{if(!B||!l.current)return;const re=l.current;let U=!0;const M=()=>{let me=re;for(;me;){const Re=getComputedStyle(me);if(Re.visibility==="hidden"||Re.display==="none")return!1;me=me.parentElement}return!0},te=()=>{if(!U)return;if(!bC()||!M()||xC()||u.current||s==="about:blank"){B.setBounds(a,{x:0,y:0,width:0,height:0},!1);return}const me=re.getBoundingClientRect();B.setBounds(a,{x:Math.round(me.left),y:Math.round(me.top),width:Math.round(me.width),height:Math.round(me.height)},me.width>2&&me.height>2)};te();const Y=new ResizeObserver(te);Y.observe(re),window.addEventListener("resize",te),window.addEventListener("scroll",te,!0),window.addEventListener("markus:embedded-browser-resync",te),window.addEventListener("markus:native-browser-overlay",te),window.addEventListener("markus:native-browser-page",te);const ae=setInterval(()=>{U&&B.getState(a).then(me=>{if(!U||!me.ok)return;const Re=me.directoryPath??null;C(Re),me.url&&document.activeElement!==h.current&&(Re||me.url!=="about:blank")&&f(me.url==="about:blank"?"":me.url),v(!!me.canGoBack),O(!!me.canGoForward),m(!!me.isLoading),me.loadError!==void 0&&y(Re?null:me.loadError??null)})},800),ee=()=>{B.setBounds(a,{x:0,y:0,width:0,height:0},!1)};return window.addEventListener("pagehide",ee),()=>{U=!1,Y.disconnect(),window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0),window.removeEventListener("markus:embedded-browser-resync",te),window.removeEventListener("markus:native-browser-overlay",te),window.removeEventListener("markus:native-browser-page",te),window.removeEventListener("pagehide",ee),clearInterval(ae),B.setBounds(a,{x:0,y:0,width:0,height:0},!1)}},[B,a,s]),w.useEffect(()=>{window.dispatchEvent(new Event("markus:embedded-browser-resync"))},[k,s]),B?c.jsxs("div",{className:`flex flex-col h-full min-h-0 min-w-0 w-full ${t??""}`,children:[c.jsxs("div",{className:"shrink-0 relative mb-2",children:[c.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border border-border-default rounded-lg bg-surface-elevated",children:[c.jsx("button",{disabled:!p,onClick:()=>{B.action(a,"back")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay disabled:opacity-30",title:i("back"),children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsx("button",{disabled:!b,onClick:()=>{B.action(a,"forward")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay disabled:opacity-30",title:i("forward"),children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}),c.jsx("button",{onClick:()=>{g?B.action(a,"stop"):B.action(a,"reload")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay",title:g?"Stop":"Reload",children:g?c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"animate-spin",children:c.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})}):c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),c.jsxs("form",{className:"flex-1 min-w-0 relative flex items-center gap-1",onSubmit:re=>{re.preventDefault(),pe(d)},children:[c.jsx("input",{ref:h,value:d,onChange:re=>{f(re.target.value),ie(re.target.value)},onFocus:()=>ie(h.current?.value??""),onBlur:()=>{window.setTimeout(q,120)},onKeyDown:re=>{const U=gC(re),M=re.key==="ArrowDown"?"next":re.key==="ArrowUp"?"prev":U;if(M){if(re.preventDefault(),!R.length){ie(d);return}N(!0),Z(te=>OC(te,R.length,M));return}if(re.key==="Enter"){const te=A&&H>=0?R[H]:void 0;te&&(re.preventDefault(),$e(te));return}if(re.key==="Escape"){if(A){re.preventDefault(),re.stopPropagation(),q();return}h.current?.blur()}},placeholder:i("browserUrlPlaceholder"),spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoFocus:s==="about:blank",className:"flex-1 min-w-0 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary outline-none focus:border-brand-500"}),c.jsx("select",{value:P,onChange:re=>{const U=re.target.value;qD(U),_(U)},title:i("browserSearchEngineLabel"),"aria-label":i("browserSearchEngineLabel"),className:"shrink-0 text-[10px] bg-surface-primary border border-border-default rounded-md text-fg-tertiary outline-none",children:XD.map(re=>c.jsx("option",{value:re,children:jl[re].name},re))}),A&&c.jsx(q_,{items:R,query:d,activeIndex:H,onHover:Z,onPick:$e,onRemove:re=>W(ey(op(re))),onClear:()=>{Jv(),q()}})]}),g&&c.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary px-1 select-none",children:i("browserLoading")}),B.openDevTools&&c.jsx("button",{type:"button",onClick:()=>{B.openDevTools?.(a)},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay shrink-0",title:i("browserGuestDevTools"),children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12 20h9"}),c.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]})})]}),c.jsx("div",{className:`absolute left-2 right-2 bottom-0 h-0.5 overflow-hidden rounded-full transition-opacity ${g?"opacity-100":"opacity-0"}`,"aria-hidden":!g,children:c.jsx("div",{className:"h-full w-1/3 bg-brand-500 animate-[browser-load_1.1s_ease-in-out_infinite]"})})]}),x&&!g&&!k&&c.jsx("div",{className:"shrink-0 mb-2 px-2.5 py-1.5 text-[11px] text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:x}),c.jsx("div",{ref:l,className:"flex-1 min-h-0 min-w-0 w-full rounded-lg border border-border-default bg-surface-elevated/30 overflow-hidden",children:k&&c.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-4 px-6 text-center",children:[c.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-elevated border border-border-default flex items-center justify-center text-fg-secondary",children:c.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:c.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",strokeLinejoin:"round"})})}),c.jsxs("div",{className:"space-y-1.5 max-w-md",children:[c.jsx("p",{className:"text-sm font-medium text-fg-primary",children:i("browserFolderTitle")}),c.jsx("p",{className:"text-xs text-fg-tertiary break-all",children:k})]}),c.jsx("button",{type:"button",disabled:Q,onClick:()=>{E(!0),ne.system.openPath(k).catch(()=>ne.files.reveal(k)).finally(()=>E(!1))},className:"px-3.5 py-2 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-on-brand transition-colors",children:Q?i("browserFolderOpening"):i("browserFolderOpen",{app:I})})]})}),c.jsx("style",{children:`
41
+ @keyframes browser-load {
42
+ 0% { transform: translateX(-120%); }
43
+ 100% { transform: translateX(360%); }
44
+ }
45
+ `})]}):c.jsxs("div",{className:`space-y-3 ${t??""}`,children:[c.jsx("p",{className:"text-sm text-fg-secondary break-all",children:s}),c.jsx("button",{onClick:()=>window.open(s,"_blank","noopener,noreferrer"),className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",children:i("openInBrowser")})]})}var kf={exports:{}},wv;function eI(){return wv||(wv=1,(function(s,e){(function(t,r){s.exports=r()})(globalThis,(()=>(()=>{var t={4567:function(a,o,l){var h=this&&this.__decorate||function(m,x,y,k){var C,P=arguments.length,_=P<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(m,x,y,k);else for(var Q=m.length-1;Q>=0;Q--)(C=m[Q])&&(_=(P<3?C(_):P>3?C(x,y,_):C(x,y))||_);return P>3&&_&&Object.defineProperty(x,y,_),_},u=this&&this.__param||function(m,x){return function(y,k){x(y,k,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const d=l(9042),f=l(9924),p=l(844),v=l(4725),b=l(2585),O=l(3656);let g=o.AccessibilityManager=class extends p.Disposable{constructor(m,x,y,k){super(),this._terminal=m,this._coreBrowserService=y,this._renderService=k,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,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=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new f.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((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
46
+ `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,O.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,p.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(m){for(let x=0;x<m;x++)this._handleChar(" ")}_handleChar(m){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==m&&(this._charsToAnnounce+=m):this._charsToAnnounce+=m,m===`
47
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=d.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(m){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(m)||this._charsToConsume.push(m)}_refreshRows(m,x){this._liveRegionDebouncer.refresh(m,x,this._terminal.rows)}_renderRows(m,x){const y=this._terminal.buffer,k=y.lines.length.toString();for(let C=m;C<=x;C++){const P=y.lines.get(y.ydisp+C),_=[],Q=P?.translateToString(!0,void 0,void 0,_)||"",E=(y.ydisp+C+1).toString(),A=this._rowElements[C];A&&(Q.length===0?(A.innerText=" ",this._rowColumns.set(A,[0,1])):(A.textContent=Q,this._rowColumns.set(A,_)),A.setAttribute("aria-posinset",E),A.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(m,x){const y=m.target,k=this._rowElements[x===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||m.relatedTarget!==k)return;let C,P;if(x===0?(C=y,P=this._rowElements.pop(),this._rowContainer.removeChild(P)):(C=this._rowElements.shift(),P=y,this._rowContainer.removeChild(C)),C.removeEventListener("focus",this._topBoundaryFocusListener),P.removeEventListener("focus",this._bottomBoundaryFocusListener),x===0){const _=this._createAccessibilityTreeNode();this._rowElements.unshift(_),this._rowContainer.insertAdjacentElement("afterbegin",_)}else{const _=this._createAccessibilityTreeNode();this._rowElements.push(_),this._rowContainer.appendChild(_)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),m.preventDefault(),m.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const m=document.getSelection();if(!m)return;if(m.isCollapsed)return void(this._rowContainer.contains(m.anchorNode)&&this._terminal.clearSelection());if(!m.anchorNode||!m.focusNode)return void console.error("anchorNode and/or focusNode are null");let x={node:m.anchorNode,offset:m.anchorOffset},y={node:m.focusNode,offset:m.focusOffset};if((x.node.compareDocumentPosition(y.node)&Node.DOCUMENT_POSITION_PRECEDING||x.node===y.node&&x.offset>y.offset)&&([x,y]=[y,x]),x.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(x={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(x.node))return;const k=this._rowElements.slice(-1)[0];if(y.node.compareDocumentPosition(k)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(y={node:k,offset:k.textContent?.length??0}),!this._rowContainer.contains(y.node))return;const C=({node:Q,offset:E})=>{const A=Q instanceof Text?Q.parentNode:Q;let N=parseInt(A?.getAttribute("aria-posinset"),10)-1;if(isNaN(N))return console.warn("row is invalid. Race condition?"),null;const R=this._rowColumns.get(A);if(!R)return console.warn("columns is null. Race condition?"),null;let W=E<R.length?R[E]:R.slice(-1)[0]+1;return W>=this._terminal.cols&&(++N,W=0),{row:N,column:W}},P=C(x),_=C(y);if(P&&_){if(P.row>_.row||P.row===_.row&&P.column>=_.column)throw new Error("invalid range");this._terminal.select(P.column,P.row,(_.row-P.row)*this._terminal.cols-P.column+_.column)}}_handleResize(m){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>m;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const m=this._coreBrowserService.mainDocument.createElement("div");return m.setAttribute("role","listitem"),m.tabIndex=-1,this._refreshRowDimensions(m),m}_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 m=0;m<this._terminal.rows;m++)this._refreshRowDimensions(this._rowElements[m])}}_refreshRowDimensions(m){m.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=g=h([u(1,b.IInstantiationService),u(2,v.ICoreBrowserService),u(3,v.IRenderService)],g)},3614:(a,o)=>{function l(f){return f.replace(/\r?\n/g,"\r")}function h(f,p){return p?"\x1B[200~"+f+"\x1B[201~":f}function u(f,p,v,b){f=h(f=l(f),v.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),v.triggerDataEvent(f,!0),p.value=""}function d(f,p,v){const b=v.getBoundingClientRect(),O=f.clientX-b.left-10,g=f.clientY-b.top-10;p.style.width="20px",p.style.height="20px",p.style.left=`${O}px`,p.style.top=`${g}px`,p.style.zIndex="1000",p.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=l,o.bracketTextForPaste=h,o.copyHandler=function(f,p){f.clipboardData&&f.clipboardData.setData("text/plain",p.selectionText),f.preventDefault()},o.handlePasteEvent=function(f,p,v,b){f.stopPropagation(),f.clipboardData&&u(f.clipboardData.getData("text/plain"),p,v,b)},o.paste=u,o.moveTextAreaUnderMouseCursor=d,o.rightClickHandler=function(f,p,v,b,O){d(f,p,v),O&&b.rightClickSelect(f),p.value=b.selectionText,p.select()}},7239:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const h=l(1505);o.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(u,d,f){this._css.set(u,d,f)}getCss(u,d){return this._css.get(u,d)}setColor(u,d,f){this._color.set(u,d,f)}getColor(u,d){return this._color.get(u,d)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(l,h,u,d){l.addEventListener(h,u,d);let f=!1;return{dispose:()=>{f||(f=!0,l.removeEventListener(h,u,d))}}}},3551:function(a,o,l){var h=this&&this.__decorate||function(g,m,x,y){var k,C=arguments.length,P=C<3?m:y===null?y=Object.getOwnPropertyDescriptor(m,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(g,m,x,y);else for(var _=g.length-1;_>=0;_--)(k=g[_])&&(P=(C<3?k(P):C>3?k(m,x,P):k(m,x))||P);return C>3&&P&&Object.defineProperty(m,x,P),P},u=this&&this.__param||function(g,m){return function(x,y){m(x,y,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const d=l(3656),f=l(8460),p=l(844),v=l(2585),b=l(4725);let O=o.Linkifier=class extends p.Disposable{get currentLink(){return this._currentLink}constructor(g,m,x,y,k){super(),this._element=g,this._mouseService=m,this._renderService=x,this._bufferService=y,this._linkProviderService=k,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new f.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new f.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,p.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,p.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,d.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,d.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(g){this._lastMouseEvent=g;const m=this._positionFromMouseEvent(g,this._element,this._mouseService);if(!m)return;this._isMouseOut=!1;const x=g.composedPath();for(let y=0;y<x.length;y++){const k=x[y];if(k.classList.contains("xterm"))break;if(k.classList.contains("xterm-hover"))return}this._lastBufferCell&&m.x===this._lastBufferCell.x&&m.y===this._lastBufferCell.y||(this._handleHover(m),this._lastBufferCell=m)}_handleHover(g){if(this._activeLine!==g.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(g,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,g)||(this._clearCurrentLink(),this._askForLink(g,!0))}_askForLink(g,m){this._activeProviderReplies&&m||(this._activeProviderReplies?.forEach((y=>{y?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=g.y);let x=!1;for(const[y,k]of this._linkProviderService.linkProviders.entries())m?this._activeProviderReplies?.get(y)&&(x=this._checkLinkProviderResult(y,g,x)):k.provideLinks(g.y,(C=>{if(this._isMouseOut)return;const P=C?.map((_=>({link:_})));this._activeProviderReplies?.set(y,P),x=this._checkLinkProviderResult(y,g,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(g.y,this._activeProviderReplies)}))}_removeIntersectingLinks(g,m){const x=new Set;for(let y=0;y<m.size;y++){const k=m.get(y);if(k)for(let C=0;C<k.length;C++){const P=k[C],_=P.link.range.start.y<g?0:P.link.range.start.x,Q=P.link.range.end.y>g?this._bufferService.cols:P.link.range.end.x;for(let E=_;E<=Q;E++){if(x.has(E)){k.splice(C--,1);break}x.add(E)}}}}_checkLinkProviderResult(g,m,x){if(!this._activeProviderReplies)return x;const y=this._activeProviderReplies.get(g);let k=!1;for(let C=0;C<g;C++)this._activeProviderReplies.has(C)&&!this._activeProviderReplies.get(C)||(k=!0);if(!k&&y){const C=y.find((P=>this._linkAtPosition(P.link,m)));C&&(x=!0,this._handleNewLink(C))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!x)for(let C=0;C<this._activeProviderReplies.size;C++){const P=this._activeProviderReplies.get(C)?.find((_=>this._linkAtPosition(_.link,m)));if(P){x=!0,this._handleNewLink(P);break}}return x}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(g){if(!this._currentLink)return;const m=this._positionFromMouseEvent(g,this._element,this._mouseService);m&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,m)&&this._currentLink.link.activate(g,this._currentLink.link.text)}_clearCurrentLink(g,m){this._currentLink&&this._lastMouseEvent&&(!g||!m||this._currentLink.link.range.start.y>=g&&this._currentLink.link.range.end.y<=m)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,p.disposeArray)(this._linkCacheDisposables))}_handleNewLink(g){if(!this._lastMouseEvent)return;const m=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);m&&this._linkAtPosition(g.link,m)&&(this._currentLink=g,this._currentLink.state={decorations:{underline:g.link.decorations===void 0||g.link.decorations.underline,pointerCursor:g.link.decorations===void 0||g.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,g.link,this._lastMouseEvent),g.link.decorations={},Object.defineProperties(g.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:x=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==x&&(this._currentLink.state.decorations.pointerCursor=x,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",x))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:x=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==x&&(this._currentLink.state.decorations.underline=x,this._currentLink.state.isHovered&&this._fireUnderlineEvent(g.link,x))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((x=>{if(!this._currentLink)return;const y=x.start===0?0:x.start+1+this._bufferService.buffer.ydisp,k=this._bufferService.buffer.ydisp+1+x.end;if(this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=k&&(this._clearCurrentLink(y,k),this._lastMouseEvent)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(g,m,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(m,!0),this._currentLink.state.decorations.pointerCursor&&g.classList.add("xterm-cursor-pointer")),m.hover&&m.hover(x,m.text)}_fireUnderlineEvent(g,m){const x=g.range,y=this._bufferService.buffer.ydisp,k=this._createLinkUnderlineEvent(x.start.x-1,x.start.y-y-1,x.end.x,x.end.y-y-1,void 0);(m?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(k)}_linkLeave(g,m,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(m,!1),this._currentLink.state.decorations.pointerCursor&&g.classList.remove("xterm-cursor-pointer")),m.leave&&m.leave(x,m.text)}_linkAtPosition(g,m){const x=g.range.start.y*this._bufferService.cols+g.range.start.x,y=g.range.end.y*this._bufferService.cols+g.range.end.x,k=m.y*this._bufferService.cols+m.x;return x<=k&&k<=y}_positionFromMouseEvent(g,m,x){const y=x.getCoords(g,m,this._bufferService.cols,this._bufferService.rows);if(y)return{x:y[0],y:y[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(g,m,x,y,k){return{x1:g,y1:m,x2:x,y2:y,cols:this._bufferService.cols,fg:k}}};o.Linkifier=O=h([u(1,b.IMouseService),u(2,b.IRenderService),u(3,v.IBufferService),u(4,b.ILinkProviderService)],O)},9042:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,o,l){var h=this&&this.__decorate||function(b,O,g,m){var x,y=arguments.length,k=y<3?O:m===null?m=Object.getOwnPropertyDescriptor(O,g):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(b,O,g,m);else for(var C=b.length-1;C>=0;C--)(x=b[C])&&(k=(y<3?x(k):y>3?x(O,g,k):x(O,g))||k);return y>3&&k&&Object.defineProperty(O,g,k),k},u=this&&this.__param||function(b,O){return function(g,m){O(g,m,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const d=l(511),f=l(2585);let p=o.OscLinkProvider=class{constructor(b,O,g){this._bufferService=b,this._optionsService=O,this._oscLinkService=g}provideLinks(b,O){const g=this._bufferService.buffer.lines.get(b-1);if(!g)return void O(void 0);const m=[],x=this._optionsService.rawOptions.linkHandler,y=new d.CellData,k=g.getTrimmedLength();let C=-1,P=-1,_=!1;for(let Q=0;Q<k;Q++)if(P!==-1||g.hasContent(Q)){if(g.loadCell(Q,y),y.hasExtendedAttrs()&&y.extended.urlId){if(P===-1){P=Q,C=y.extended.urlId;continue}_=y.extended.urlId!==C}else P!==-1&&(_=!0);if(_||P!==-1&&Q===k-1){const E=this._oscLinkService.getLinkData(C)?.uri;if(E){const A={start:{x:P+1,y:b},end:{x:Q+(_||Q!==k-1?0:1),y:b}};let N=!1;if(!x?.allowNonHttpProtocols)try{const R=new URL(E);["http:","https:"].includes(R.protocol)||(N=!0)}catch{N=!0}N||m.push({text:E,range:A,activate:(R,W)=>x?x.activate(R,W,A):v(0,W),hover:(R,W)=>x?.hover?.(R,W,A),leave:(R,W)=>x?.leave?.(R,W,A)})}_=!1,y.hasExtendedAttrs()&&y.extended.urlId?(P=Q,C=y.extended.urlId):(P=-1,C=-1)}}O(m)}};function v(b,O){if(confirm(`Do you want to navigate to ${O}?
48
+
49
+ WARNING: This link could potentially be dangerous`)){const g=window.open();if(g){try{g.opener=null}catch{}g.location.href=O}else console.warn("Opening link blocked as opener could not be cleared")}}o.OscLinkProvider=p=h([u(0,f.IBufferService),u(1,f.IOptionsService),u(2,f.IOscLinkService)],p)},6193:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.RenderDebouncer=void 0,o.RenderDebouncer=class{constructor(l,h){this._renderCallback=l,this._coreBrowserService=h,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(l){return this._refreshCallbacks.push(l),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(l,h,u){this._rowCount=u,l=l!==void 0?l:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.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 l=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const l of this._refreshCallbacks)l(0);this._refreshCallbacks=[]}}},3236:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Terminal=void 0;const h=l(3614),u=l(3656),d=l(3551),f=l(9042),p=l(3730),v=l(1680),b=l(3107),O=l(5744),g=l(2950),m=l(1296),x=l(428),y=l(4269),k=l(5114),C=l(8934),P=l(3230),_=l(9312),Q=l(4725),E=l(6731),A=l(8055),N=l(8969),R=l(8460),W=l(844),H=l(6114),Z=l(8437),B=l(2584),K=l(7399),$=l(5941),I=l(9074),X=l(2585),q=l(5435),ie=l(4567),pe=l(779);class $e extends N.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(U={}){super(U),this.browser=H,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new W.MutableDisposable),this._onCursorMove=this.register(new R.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new R.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new R.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new R.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new R.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new R.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new R.EventEmitter),this._onBlur=this.register(new R.EventEmitter),this._onA11yCharEmitter=this.register(new R.EventEmitter),this._onA11yTabEmitter=this.register(new R.EventEmitter),this._onWillOpen=this.register(new R.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(X.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(pe.LinkProviderService),this._instantiationService.setService(Q.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(p.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((M,te)=>this.refresh(M,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((M=>this._reportWindowsOptions(M)))),this.register(this._inputHandler.onColor((M=>this._handleColorEvent(M)))),this.register((0,R.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,R.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((M=>this._afterResize(M.cols,M.rows)))),this.register((0,W.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(U){if(this._themeService)for(const M of U){let te,Y="";switch(M.index){case 256:te="foreground",Y="10";break;case 257:te="background",Y="11";break;case 258:te="cursor",Y="12";break;default:te="ansi",Y="4;"+M.index}switch(M.type){case 0:const ae=A.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[M.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${B.C0.ESC}]${Y};${(0,$.toRgbString)(ae)}${B.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((ee=>ee.ansi[M.index]=A.channels.toColor(...M.color)));else{const ee=te;this._themeService.modifyColors((me=>me[ee]=A.channels.toColor(...M.color)))}break;case 2:this._themeService.restoreColor(M.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(U){U?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ie.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(U){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(B.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(B.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 U=this.buffer.ybase+this.buffer.y,M=this.buffer.lines.get(U);if(!M)return;const te=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,ae=M.getWidth(te),ee=this._renderService.dimensions.css.cell.width*ae,me=this.buffer.y*this._renderService.dimensions.css.cell.height,Re=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Re+"px",this.textarea.style.top=me+"px",this.textarea.style.width=ee+"px",this.textarea.style.height=Y+"px",this.textarea.style.lineHeight=Y+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(M=>{this.hasSelection()&&(0,h.copyHandler)(M,this._selectionService)})));const U=M=>(0,h.handlePasteEvent)(M,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",U)),this.register((0,u.addDisposableDomListener)(this.element,"paste",U)),H.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(M=>{M.button===2&&(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(M=>{(0,h.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),H.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(M=>{M.button===1&&(0,h.moveTextAreaUnderMouseCursor)(M,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(U=>this._keyUp(U)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(U=>this._keyDown(U)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(U=>this._keyPress(U)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(U=>this._compositionHelper.compositionupdate(U)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(U=>this._inputEvent(U)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(U){if(!U)throw new Error("Terminal requires a parent element.");if(U.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=U.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),U.appendChild(this.element);const M=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),M.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,u.addDisposableDomListener)(this.screenElement,"mousemove",(te=>this.updateCursorStyle(te)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),M.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",f.promptLabel),H.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.register(this._instantiationService.createInstance(k.CoreBrowserService,this.textarea,U.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Q.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(te=>this._handleTextAreaFocus(te)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(x.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(Q.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(E.ThemeService),this._instantiationService.setService(Q.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y.CharacterJoinerService),this._instantiationService.setService(Q.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(P.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(Q.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((te=>this._onRender.fire(te)))),this.onResize((te=>this._renderService.resize(te.cols,te.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(g.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(C.MouseService),this._instantiationService.setService(Q.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(d.Linkifier,this.screenElement)),this.element.appendChild(M);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(v.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((te=>this.scrollLines(te.amount,te.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(_.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(Q.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((te=>this.scrollLines(te.amount,te.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((te=>this._renderService.handleSelectionChanged(te.start,te.end,te.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((te=>{this.textarea.value=te,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((te=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(te=>this._selectionService.handleMouseDown(te)))),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(ie.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(te=>this._handleScreenReaderModeOptionChange(te)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(O.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(te=>{!this._overviewRulerRenderer&&te&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(O.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(m.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const U=this,M=this.element;function te(ee){const me=U._mouseService.getMouseReportCoords(ee,U.screenElement);if(!me)return!1;let Re,_e;switch(ee.overrideType||ee.type){case"mousemove":_e=32,ee.buttons===void 0?(Re=3,ee.button!==void 0&&(Re=ee.button<3?ee.button:3)):Re=1&ee.buttons?0:4&ee.buttons?1:2&ee.buttons?2:3;break;case"mouseup":_e=0,Re=ee.button<3?ee.button:3;break;case"mousedown":_e=1,Re=ee.button<3?ee.button:3;break;case"wheel":if(U._customWheelEventHandler&&U._customWheelEventHandler(ee)===!1||U.viewport.getLinesScrolled(ee)===0)return!1;_e=ee.deltaY<0?0:1,Re=4;break;default:return!1}return!(_e===void 0||Re===void 0||Re>4)&&U.coreMouseService.triggerMouseEvent({col:me.col,row:me.row,x:me.x,y:me.y,button:Re,action:_e,ctrl:ee.ctrlKey,alt:ee.altKey,shift:ee.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ae={mouseup:ee=>(te(ee),ee.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(ee)),wheel:ee=>(te(ee),this.cancel(ee,!0)),mousedrag:ee=>{ee.buttons&&te(ee)},mousemove:ee=>{ee.buttons||te(ee)}};this.register(this.coreMouseService.onProtocolChange((ee=>{ee?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ee)),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&ee?Y.mousemove||(M.addEventListener("mousemove",ae.mousemove),Y.mousemove=ae.mousemove):(M.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&ee?Y.wheel||(M.addEventListener("wheel",ae.wheel,{passive:!1}),Y.wheel=ae.wheel):(M.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&ee?Y.mouseup||(Y.mouseup=ae.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&ee?Y.mousedrag||(Y.mousedrag=ae.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(M,"mousedown",(ee=>{if(ee.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ee))return te(ee),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(ee)}))),this.register((0,u.addDisposableDomListener)(M,"wheel",(ee=>{if(!Y.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ee)===!1)return!1;if(!this.buffer.hasScrollback){const me=this.viewport.getLinesScrolled(ee);if(me===0)return;const Re=B.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ee.deltaY<0?"A":"B");let _e="";for(let De=0;De<Math.abs(me);De++)_e+=Re;return this.coreService.triggerDataEvent(_e,!0),this.cancel(ee,!0)}return this.viewport.handleWheel(ee)?this.cancel(ee):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(M,"touchstart",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ee),this.cancel(ee)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(M,"touchmove",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ee)?void 0:this.cancel(ee)}),{passive:!1}))}refresh(U,M){this._renderService?.refreshRows(U,M)}updateCursorStyle(U){this._selectionService?.shouldColumnSelect(U)?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(U,M,te=0){te===1?(super.scrollLines(U,M,te),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(U)}paste(U){(0,h.paste)(U,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(U){this._customKeyEventHandler=U}attachCustomWheelEventHandler(U){this._customWheelEventHandler=U}registerLinkProvider(U){return this._linkProviderService.registerLinkProvider(U)}registerCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const M=this._characterJoinerService.register(U);return this.refresh(0,this.rows-1),M}deregisterCharacterJoiner(U){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(U)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(U){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+U)}registerDecoration(U){return this._decorationService.registerDecoration(U)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(U,M,te){this._selectionService.setSelection(U,M,te)}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(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(U,M){this._selectionService?.selectLines(U,M)}_keyDown(U){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;const M=this.browser.isMac&&this.options.macOptionIsMeta&&U.altKey;if(!M&&!this._compositionHelper.keydown(U))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;M||U.key!=="Dead"&&U.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,K.evaluateKeyboardEvent)(U,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(U),te.type===3||te.type===2){const Y=this.rows-1;return this.scrollLines(te.type===2?-Y:Y),this.cancel(U,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,U)||(te.cancel&&this.cancel(U,!0),!te.key||!!(U.key&&!U.ctrlKey&&!U.altKey&&!U.metaKey&&U.key.length===1&&U.key.charCodeAt(0)>=65&&U.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(te.key!==B.C0.ETX&&te.key!==B.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||U.altKey||U.ctrlKey?this.cancel(U,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(U,M){const te=U.isMac&&!this.options.macOptionIsMeta&&M.altKey&&!M.ctrlKey&&!M.metaKey||U.isWindows&&M.altKey&&M.ctrlKey&&!M.metaKey||U.isWindows&&M.getModifierState("AltGraph");return M.type==="keypress"?te:te&&(!M.keyCode||M.keyCode>47)}_keyUp(U){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1||((function(M){return M.keyCode===16||M.keyCode===17||M.keyCode===18})(U)||this.focus(),this.updateCursorStyle(U),this._keyPressHandled=!1)}_keyPress(U){let M;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(U)===!1)return!1;if(this.cancel(U),U.charCode)M=U.charCode;else if(U.which===null||U.which===void 0)M=U.keyCode;else{if(U.which===0||U.charCode===0)return!1;M=U.which}return!(!M||(U.altKey||U.ctrlKey||U.metaKey)&&!this._isThirdLevelShift(this.browser,U)||(M=String.fromCharCode(M),this._onKey.fire({key:M,domEvent:U}),this._showCursor(),this.coreService.triggerDataEvent(M,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(U){if(U.data&&U.inputType==="insertText"&&(!U.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const M=U.data;return this.coreService.triggerDataEvent(M,!0),this.cancel(U),!0}return!1}resize(U,M){U!==this.cols||M!==this.rows?super.resize(U,M):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(U,M){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){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 U=1;U<this.rows;U++)this.buffer.lines.push(this.buffer.getBlankLine(Z.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(B.C0.ESC+"[I"):this.coreService.triggerDataEvent(B.C0.ESC+"[O")}_reportWindowsOptions(U){if(this._renderService)switch(U){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const M=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${B.C0.ESC}[4;${te};${M}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),ae=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${B.C0.ESC}[6;${ae};${Y}t`)}}cancel(U,M){if(this.options.cancelEvents||M)return U.preventDefault(),U.stopPropagation(),!1}}o.Terminal=$e},9924:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.TimeBasedDebouncer=void 0,o.TimeBasedDebouncer=class{constructor(l,h=1e3){this._renderCallback=l,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(l,h,u){this._rowCount=u,l=l!==void 0?l:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;const d=Date.now();if(d-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=d,this._innerRefresh();else if(!this._additionalRefreshRequested){const f=d-this._lastRefreshMs,p=this._debounceThresholdMS-f;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),p)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const l=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,h)}}},1680:function(a,o,l){var h=this&&this.__decorate||function(g,m,x,y){var k,C=arguments.length,P=C<3?m:y===null?y=Object.getOwnPropertyDescriptor(m,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(g,m,x,y);else for(var _=g.length-1;_>=0;_--)(k=g[_])&&(P=(C<3?k(P):C>3?k(m,x,P):k(m,x))||P);return C>3&&P&&Object.defineProperty(m,x,P),P},u=this&&this.__param||function(g,m){return function(x,y){m(x,y,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Viewport=void 0;const d=l(3656),f=l(4725),p=l(8460),v=l(844),b=l(2585);let O=o.Viewport=class extends v.Disposable{constructor(g,m,x,y,k,C,P,_){super(),this._viewportElement=g,this._scrollArea=m,this._bufferService=x,this._optionsService=y,this._charSizeService=k,this._renderService=C,this._coreBrowserService=P,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 p.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((Q=>this._activeBuffer=Q.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((Q=>this._renderDimensions=Q))),this._handleThemeChange(_.colors),this.register(_.onChangeColors((Q=>this._handleThemeChange(Q)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(g){this._viewportElement.style.backgroundColor=g.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(g){if(g)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._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const m=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==m&&(this._lastRecordedBufferHeight=m,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const g=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==g&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=g),this._refreshAnimationFrame=null}syncScrollArea(g=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(g);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(g)}_handleScroll(g){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 m=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:m,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const g=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(g*(this._smoothScrollState.target-this._smoothScrollState.origin)),g<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(g,m){const x=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(m<0&&this._viewportElement.scrollTop!==0||m>0&&x<this._lastRecordedBufferHeight)||(g.cancelable&&g.preventDefault(),!1)}handleWheel(g){const m=this._getPixelsScrolled(g);return m!==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+m:this._smoothScrollState.target+=m,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=m,this._bubbleScroll(g,m))}scrollLines(g){if(g!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const m=g*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+m,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:g,suppressScrollEvent:!1})}_getPixelsScrolled(g){if(g.deltaY===0||g.shiftKey)return 0;let m=this._applyScrollModifier(g.deltaY,g);return g.deltaMode===WheelEvent.DOM_DELTA_LINE?m*=this._currentRowHeight:g.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(m*=this._currentRowHeight*this._bufferService.rows),m}getBufferElements(g,m){let x,y="";const k=[],C=m??this._bufferService.buffer.lines.length,P=this._bufferService.buffer.lines;for(let _=g;_<C;_++){const Q=P.get(_);if(!Q)continue;const E=P.get(_+1)?.isWrapped;if(y+=Q.translateToString(!E),!E||_===P.length-1){const A=document.createElement("div");A.textContent=y,k.push(A),y.length>0&&(x=A),y=""}}return{bufferElements:k,cursorElement:x}}getLinesScrolled(g){if(g.deltaY===0||g.shiftKey)return 0;let m=this._applyScrollModifier(g.deltaY,g);return g.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(m/=this._currentRowHeight+0,this._wheelPartialScroll+=m,m=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):g.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(m*=this._bufferService.rows),m}_applyScrollModifier(g,m){const x=this._optionsService.rawOptions.fastScrollModifier;return x==="alt"&&m.altKey||x==="ctrl"&&m.ctrlKey||x==="shift"&&m.shiftKey?g*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:g*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(g){this._lastTouchY=g.touches[0].pageY}handleTouchMove(g){const m=this._lastTouchY-g.touches[0].pageY;return this._lastTouchY=g.touches[0].pageY,m!==0&&(this._viewportElement.scrollTop+=m,this._bubbleScroll(g,m))}};o.Viewport=O=h([u(2,b.IBufferService),u(3,b.IOptionsService),u(4,f.ICharSizeService),u(5,f.IRenderService),u(6,f.ICoreBrowserService),u(7,f.IThemeService)],O)},3107:function(a,o,l){var h=this&&this.__decorate||function(b,O,g,m){var x,y=arguments.length,k=y<3?O:m===null?m=Object.getOwnPropertyDescriptor(O,g):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(b,O,g,m);else for(var C=b.length-1;C>=0;C--)(x=b[C])&&(k=(y<3?x(k):y>3?x(O,g,k):x(O,g))||k);return y>3&&k&&Object.defineProperty(O,g,k),k},u=this&&this.__param||function(b,O){return function(g,m){O(g,m,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferDecorationRenderer=void 0;const d=l(4725),f=l(844),p=l(2585);let v=o.BufferDecorationRenderer=class extends f.Disposable{constructor(b,O,g,m,x){super(),this._screenElement=b,this._bufferService=O,this._coreBrowserService=g,this._decorationService=m,this._renderService=x,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(this._coreBrowserService.onDprChange((()=>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((y=>this._removeDecoration(y)))),this.register((0,f.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 b of this._decorationService.decorations)this._renderDecoration(b);this._dimensionsChanged=!1}_renderDecoration(b){this._refreshStyle(b),this._dimensionsChanged&&this._refreshXPosition(b)}_createElement(b){const O=this._coreBrowserService.mainDocument.createElement("div");O.classList.add("xterm-decoration"),O.classList.toggle("xterm-decoration-top-layer",b?.options?.layer==="top"),O.style.width=`${Math.round((b.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,O.style.height=(b.options.height||1)*this._renderService.dimensions.css.cell.height+"px",O.style.top=(b.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",O.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const g=b.options.x??0;return g&&g>this._bufferService.cols&&(O.style.display="none"),this._refreshXPosition(b,O),O}_refreshStyle(b){const O=b.marker.line-this._bufferService.buffers.active.ydisp;if(O<0||O>=this._bufferService.rows)b.element&&(b.element.style.display="none",b.onRenderEmitter.fire(b.element));else{let g=this._decorationElements.get(b);g||(g=this._createElement(b),b.element=g,this._decorationElements.set(b,g),this._container.appendChild(g),b.onDispose((()=>{this._decorationElements.delete(b),g.remove()}))),g.style.top=O*this._renderService.dimensions.css.cell.height+"px",g.style.display=this._altBufferIsActive?"none":"block",b.onRenderEmitter.fire(g)}}_refreshXPosition(b,O=b.element){if(!O)return;const g=b.options.x??0;(b.options.anchor||"left")==="right"?O.style.right=g?g*this._renderService.dimensions.css.cell.width+"px":"":O.style.left=g?g*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(b){this._decorationElements.get(b)?.remove(),this._decorationElements.delete(b),b.dispose()}};o.BufferDecorationRenderer=v=h([u(1,p.IBufferService),u(2,d.ICoreBrowserService),u(3,p.IDecorationService),u(4,d.IRenderService)],v)},5871:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorZoneStore=void 0,o.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(l){if(l.options.overviewRulerOptions){for(const h of this._zones)if(h.color===l.options.overviewRulerOptions.color&&h.position===l.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,l.marker.line))return;if(this._lineAdjacentToZone(h,l.marker.line,l.options.overviewRulerOptions.position))return void this._addLineToZone(h,l.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=l.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=l.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=l.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=l.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:l.options.overviewRulerOptions.color,position:l.options.overviewRulerOptions.position,startBufferLine:l.marker.line,endBufferLine:l.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(l){this._linePadding=l}_lineIntersectsZone(l,h){return h>=l.startBufferLine&&h<=l.endBufferLine}_lineAdjacentToZone(l,h,u){return h>=l.startBufferLine-this._linePadding[u||"full"]&&h<=l.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(l,h){l.startBufferLine=Math.min(l.startBufferLine,h),l.endBufferLine=Math.max(l.endBufferLine,h)}}},5744:function(a,o,l){var h=this&&this.__decorate||function(x,y,k,C){var P,_=arguments.length,Q=_<3?y:C===null?C=Object.getOwnPropertyDescriptor(y,k):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Q=Reflect.decorate(x,y,k,C);else for(var E=x.length-1;E>=0;E--)(P=x[E])&&(Q=(_<3?P(Q):_>3?P(y,k,Q):P(y,k))||Q);return _>3&&Q&&Object.defineProperty(y,k,Q),Q},u=this&&this.__param||function(x,y){return function(k,C){y(k,C,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OverviewRulerRenderer=void 0;const d=l(5871),f=l(4725),p=l(844),v=l(2585),b={full:0,left:0,center:0,right:0},O={full:0,left:0,center:0,right:0},g={full:0,left:0,center:0,right:0};let m=o.OverviewRulerRenderer=class extends p.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,y,k,C,P,_,Q){super(),this._viewportElement=x,this._screenElement=y,this._bufferService=k,this._decorationService=C,this._renderService=P,this._optionsService=_,this._coreBrowserService=Q,this._colorZoneStore=new d.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);const E=this._canvas.getContext("2d");if(!E)throw new Error("Ctx cannot be null");this._ctx=E,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,p.toDisposable)((()=>{this._canvas?.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(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const x=Math.floor(this._canvas.width/3),y=Math.ceil(this._canvas.width/3);O.full=this._canvas.width,O.left=x,O.center=y,O.right=x,this._refreshDrawHeightConstants(),g.full=0,g.left=0,g.center=O.left,g.right=O.left+O.center}_refreshDrawHeightConstants(){b.full=Math.round(2*this._coreBrowserService.dpr);const x=this._canvas.height/this._bufferService.buffer.lines.length,y=Math.round(Math.max(Math.min(x,12),6)*this._coreBrowserService.dpr);b.left=y,b.center=y,b.right=y}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.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._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.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 y of this._decorationService.decorations)this._colorZoneStore.addDecoration(y);this._ctx.lineWidth=1;const x=this._colorZoneStore.zones;for(const y of x)y.position!=="full"&&this._renderColorZone(y);for(const y of x)y.position==="full"&&this._renderColorZone(y);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(g[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-b[x.position||"full"]/2),O[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+b[x.position||"full"]))}_queueRefresh(x,y){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=y||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};o.OverviewRulerRenderer=m=h([u(2,v.IBufferService),u(3,v.IDecorationService),u(4,f.IRenderService),u(5,v.IOptionsService),u(6,f.ICoreBrowserService)],m)},2950:function(a,o,l){var h=this&&this.__decorate||function(b,O,g,m){var x,y=arguments.length,k=y<3?O:m===null?m=Object.getOwnPropertyDescriptor(O,g):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(b,O,g,m);else for(var C=b.length-1;C>=0;C--)(x=b[C])&&(k=(y<3?x(k):y>3?x(O,g,k):x(O,g))||k);return y>3&&k&&Object.defineProperty(O,g,k),k},u=this&&this.__param||function(b,O){return function(g,m){O(g,m,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CompositionHelper=void 0;const d=l(4725),f=l(2585),p=l(2584);let v=o.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,O,g,m,x,y){this._textarea=b,this._compositionView=O,this._bufferService=g,this._optionsService=m,this._coreService=x,this._renderService=y,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(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const O={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let g;this._isSendingComposition=!1,O.start+=this._dataAlreadySent.length,g=this._isComposing?this._textarea.value.substring(O.start,O.end):this._textarea.value.substring(O.start),g.length>0&&this._coreService.triggerDataEvent(g,!0)}}),0)}else{this._isSendingComposition=!1;const O=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(O,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const O=this._textarea.value,g=O.replace(b,"");this._dataAlreadySent=g,O.length>b.length?this._coreService.triggerDataEvent(g,!0):O.length<b.length?this._coreService.triggerDataEvent(`${p.C0.DEL}`,!0):O.length===b.length&&O!==b&&this._coreService.triggerDataEvent(O,!0)}}),0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const O=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),g=this._renderService.dimensions.css.cell.height,m=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,x=O*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=x+"px",this._compositionView.style.top=m+"px",this._compositionView.style.height=g+"px",this._compositionView.style.lineHeight=g+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const y=this._compositionView.getBoundingClientRect();this._textarea.style.left=x+"px",this._textarea.style.top=m+"px",this._textarea.style.width=Math.max(y.width,1)+"px",this._textarea.style.height=Math.max(y.height,1)+"px",this._textarea.style.lineHeight=y.height+"px"}b||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};o.CompositionHelper=v=h([u(2,f.IBufferService),u(3,f.IOptionsService),u(4,f.ICoreService),u(5,d.IRenderService)],v)},9806:(a,o)=>{function l(h,u,d){const f=d.getBoundingClientRect(),p=h.getComputedStyle(d),v=parseInt(p.getPropertyValue("padding-left")),b=parseInt(p.getPropertyValue("padding-top"));return[u.clientX-f.left-v,u.clientY-f.top-b]}Object.defineProperty(o,"__esModule",{value:!0}),o.getCoords=o.getCoordsRelativeToElement=void 0,o.getCoordsRelativeToElement=l,o.getCoords=function(h,u,d,f,p,v,b,O,g){if(!v)return;const m=l(h,u,d);return m?(m[0]=Math.ceil((m[0]+(g?b/2:0))/b),m[1]=Math.ceil(m[1]/O),m[0]=Math.min(Math.max(m[0],1),f+(g?1:0)),m[1]=Math.min(Math.max(m[1],1),p),m):void 0}},9504:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.moveToCellSequence=void 0;const h=l(2584);function u(O,g,m,x){const y=O-d(O,m),k=g-d(g,m),C=Math.abs(y-k)-(function(P,_,Q){let E=0;const A=P-d(P,Q),N=_-d(_,Q);for(let R=0;R<Math.abs(A-N);R++){const W=f(P,_)==="A"?-1:1;Q.buffer.lines.get(A+W*R)?.isWrapped&&E++}return E})(O,g,m);return b(C,v(f(O,g),x))}function d(O,g){let m=0,x=g.buffer.lines.get(O),y=x?.isWrapped;for(;y&&O>=0&&O<g.rows;)m++,x=g.buffer.lines.get(--O),y=x?.isWrapped;return m}function f(O,g){return O>g?"A":"B"}function p(O,g,m,x,y,k){let C=O,P=g,_="";for(;C!==m||P!==x;)C+=y?1:-1,y&&C>k.cols-1?(_+=k.buffer.translateBufferLineToString(P,!1,O,C),C=0,O=0,P++):!y&&C<0&&(_+=k.buffer.translateBufferLineToString(P,!1,0,O+1),C=k.cols-1,O=C,P--);return _+k.buffer.translateBufferLineToString(P,!1,O,C)}function v(O,g){const m=g?"O":"[";return h.C0.ESC+m+O}function b(O,g){O=Math.floor(O);let m="";for(let x=0;x<O;x++)m+=g;return m}o.moveToCellSequence=function(O,g,m,x){const y=m.buffer.x,k=m.buffer.y;if(!m.buffer.hasScrollback)return(function(_,Q,E,A,N,R){return u(Q,A,N,R).length===0?"":b(p(_,Q,_,Q-d(Q,N),!1,N).length,v("D",R))})(y,k,0,g,m,x)+u(k,g,m,x)+(function(_,Q,E,A,N,R){let W;W=u(Q,A,N,R).length>0?A-d(A,N):Q;const H=A,Z=(function(B,K,$,I,X,q){let ie;return ie=u($,I,X,q).length>0?I-d(I,X):K,B<$&&ie<=I||B>=$&&ie<I?"C":"D"})(_,Q,E,A,N,R);return b(p(_,W,E,H,Z==="C",N).length,v(Z,R))})(y,k,O,g,m,x);let C;if(k===g)return C=y>O?"D":"C",b(Math.abs(y-O),v(C,x));C=k>g?"D":"C";const P=Math.abs(k-g);return b((function(_,Q){return Q.cols-_})(k>g?O:y,m)+(P-1)*m.cols+1+((k>g?y:O)-1),v(C,x))}},1296:function(a,o,l){var h=this&&this.__decorate||function(R,W,H,Z){var B,K=arguments.length,$=K<3?W:Z===null?Z=Object.getOwnPropertyDescriptor(W,H):Z;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(R,W,H,Z);else for(var I=R.length-1;I>=0;I--)(B=R[I])&&($=(K<3?B($):K>3?B(W,H,$):B(W,H))||$);return K>3&&$&&Object.defineProperty(W,H,$),$},u=this&&this.__param||function(R,W){return function(H,Z){W(H,Z,R)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRenderer=void 0;const d=l(3787),f=l(2550),p=l(2223),v=l(6171),b=l(6052),O=l(4725),g=l(8055),m=l(8460),x=l(844),y=l(2585),k="xterm-dom-renderer-owner-",C="xterm-rows",P="xterm-fg-",_="xterm-bg-",Q="xterm-focus",E="xterm-selection";let A=1,N=o.DomRenderer=class extends x.Disposable{constructor(R,W,H,Z,B,K,$,I,X,q,ie,pe,$e){super(),this._terminal=R,this._document=W,this._element=H,this._screenElement=Z,this._viewportElement=B,this._helperContainer=K,this._linkifier2=$,this._charSizeService=X,this._optionsService=q,this._bufferService=ie,this._coreBrowserService=pe,this._themeService=$e,this._terminalClass=A++,this._rowElements=[],this._selectionRenderModel=(0,b.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new m.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,v.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((re=>this._injectCss(re)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(d.DomRendererRowFactory,document),this._element.classList.add(k+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((re=>this._handleLinkHover(re)))),this.register(this._linkifier2.onHideLinkUnderline((re=>this._handleLinkLeave(re)))),this.register((0,x.toDisposable)((()=>{this._element.classList.remove(k+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new f.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const H of this._rowElements)H.style.width=`${this.dimensions.css.canvas.width}px`,H.style.height=`${this.dimensions.css.cell.height}px`,H.style.lineHeight=`${this.dimensions.css.cell.height}px`,H.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const W=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=W,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(R){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let W=`${this._terminalSelector} .${C} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;W+=`${this._terminalSelector} .${C} .xterm-dim { color: ${g.color.multiplyOpacity(R.foreground,.5).css};}`,W+=`${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;}`;const H=`blink_underline_${this._terminalClass}`,Z=`blink_bar_${this._terminalClass}`,B=`blink_block_${this._terminalClass}`;W+=`@keyframes ${H} { 50% { border-bottom-style: hidden; }}`,W+=`@keyframes ${Z} { 50% { box-shadow: none; }}`,W+=`@keyframes ${B} { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,W+=`${this._terminalSelector} .${C}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${H} 1s step-end infinite;}${this._terminalSelector} .${C}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${C}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${B} 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${R.cursor.css} !important; color: ${R.cursorAccent.css} !important;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,W+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[K,$]of R.ansi.entries())W+=`${this._terminalSelector} .${P}${K} { color: ${$.css}; }${this._terminalSelector} .${P}${K}.xterm-dim { color: ${g.color.multiplyOpacity($,.5).css}; }${this._terminalSelector} .${_}${K} { background-color: ${$.css}; }`;W+=`${this._terminalSelector} .${P}${p.INVERTED_DEFAULT_COLOR} { color: ${g.color.opaque(R.background).css}; }${this._terminalSelector} .${P}${p.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${g.color.multiplyOpacity(g.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${_}${p.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=W}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,W){for(let H=this._rowElements.length;H<=W;H++){const Z=this._document.createElement("div");this._rowContainer.appendChild(Z),this._rowElements.push(Z)}for(;this._rowElements.length>W;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,W){this._refreshRowElements(R,W),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Q),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Q),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,W,H){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,W,H),this.renderRows(0,this._bufferService.rows-1),!R||!W)return;this._selectionRenderModel.update(this._terminal,R,W,H);const Z=this._selectionRenderModel.viewportStartRow,B=this._selectionRenderModel.viewportEndRow,K=this._selectionRenderModel.viewportCappedStartRow,$=this._selectionRenderModel.viewportCappedEndRow;if(K>=this._bufferService.rows||$<0)return;const I=this._document.createDocumentFragment();if(H){const X=R[0]>W[0];I.appendChild(this._createSelectionElement(K,X?W[0]:R[0],X?R[0]:W[0],$-K+1))}else{const X=Z===K?R[0]:0,q=K===B?W[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(K,X,q));const ie=$-K-1;if(I.appendChild(this._createSelectionElement(K+1,0,this._bufferService.cols,ie)),K!==$){const pe=B===$?W[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement($,0,pe))}}this._selectionContainer.appendChild(I)}_createSelectionElement(R,W,H,Z=1){const B=this._document.createElement("div"),K=W*this.dimensions.css.cell.width;let $=this.dimensions.css.cell.width*(H-W);return K+$>this.dimensions.css.canvas.width&&($=this.dimensions.css.canvas.width-K),B.style.height=Z*this.dimensions.css.cell.height+"px",B.style.top=R*this.dimensions.css.cell.height+"px",B.style.left=`${K}px`,B.style.width=`${$}px`,B}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,W){const H=this._bufferService.buffer,Z=H.ybase+H.y,B=Math.min(H.x,this._bufferService.cols-1),K=this._optionsService.rawOptions.cursorBlink,$=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=R;X<=W;X++){const q=X+H.ydisp,ie=this._rowElements[X],pe=H.lines.get(q);if(!ie||!pe)break;ie.replaceChildren(...this._rowFactory.createRow(pe,q,q===Z,$,I,B,K,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${k}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,W,H,Z,B,K){H<0&&(R=0),Z<0&&(W=0);const $=this._bufferService.rows-1;H=Math.max(Math.min(H,$),0),Z=Math.max(Math.min(Z,$),0),B=Math.min(B,this._bufferService.cols);const I=this._bufferService.buffer,X=I.ybase+I.y,q=Math.min(I.x,B-1),ie=this._optionsService.rawOptions.cursorBlink,pe=this._optionsService.rawOptions.cursorStyle,$e=this._optionsService.rawOptions.cursorInactiveStyle;for(let re=H;re<=Z;++re){const U=re+I.ydisp,M=this._rowElements[re],te=I.lines.get(U);if(!M||!te)break;M.replaceChildren(...this._rowFactory.createRow(te,U,U===X,pe,$e,q,ie,this.dimensions.css.cell.width,this._widthCache,K?re===H?R:0:-1,K?(re===Z?W:B)-1:-1))}}};o.DomRenderer=N=h([u(7,y.IInstantiationService),u(8,O.ICharSizeService),u(9,y.IOptionsService),u(10,y.IBufferService),u(11,O.ICoreBrowserService),u(12,O.IThemeService)],N)},3787:function(a,o,l){var h=this&&this.__decorate||function(C,P,_,Q){var E,A=arguments.length,N=A<3?P:Q===null?Q=Object.getOwnPropertyDescriptor(P,_):Q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,P,_,Q);else for(var R=C.length-1;R>=0;R--)(E=C[R])&&(N=(A<3?E(N):A>3?E(P,_,N):E(P,_))||N);return A>3&&N&&Object.defineProperty(P,_,N),N},u=this&&this.__param||function(C,P){return function(_,Q){P(_,Q,C)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRendererRowFactory=void 0;const d=l(2223),f=l(643),p=l(511),v=l(2585),b=l(8055),O=l(4725),g=l(4269),m=l(6171),x=l(3734);let y=o.DomRendererRowFactory=class{constructor(C,P,_,Q,E,A,N){this._document=C,this._characterJoinerService=P,this._optionsService=_,this._coreBrowserService=Q,this._coreService=E,this._decorationService=A,this._themeService=N,this._workCell=new p.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(C,P,_){this._selectionStart=C,this._selectionEnd=P,this._columnSelectMode=_}createRow(C,P,_,Q,E,A,N,R,W,H,Z){const B=[],K=this._characterJoinerService.getJoinedCharacters(P),$=this._themeService.colors;let I,X=C.getNoBgTrimmedLength();_&&X<A+1&&(X=A+1);let q=0,ie="",pe=0,$e=0,re=0,U=!1,M=0,te=!1,Y=0;const ae=[],ee=H!==-1&&Z!==-1;for(let me=0;me<X;me++){C.loadCell(me,this._workCell);let Re=this._workCell.getWidth();if(Re===0)continue;let _e=!1,De=me,Te=this._workCell;if(K.length>0&&me===K[0][0]){_e=!0;const ye=K.shift();Te=new g.JoinedCellData(this._workCell,C.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),De=ye[1]-1,Re=Te.getWidth()}const Fe=this._isCellInSelection(me,P),Ue=_&&me===A,ve=ee&&me>=H&&me<=Z;let V=!1;this._decorationService.forEachDecorationAtCell(me,P,void 0,(ye=>{V=!0}));let Xe=Te.getChars()||f.WHITESPACE_CELL_CHAR;if(Xe===" "&&(Te.isUnderline()||Te.isOverline())&&(Xe=" "),Y=Re*R-W.get(Xe,Te.isBold(),Te.isItalic()),I){if(q&&(Fe&&te||!Fe&&!te&&Te.bg===pe)&&(Fe&&te&&$.selectionForeground||Te.fg===$e)&&Te.extended.ext===re&&ve===U&&Y===M&&!Ue&&!_e&&!V){Te.isInvisible()?ie+=f.WHITESPACE_CELL_CHAR:ie+=Xe,q++;continue}q&&(I.textContent=ie),I=this._document.createElement("span"),q=0,ie=""}else I=this._document.createElement("span");if(pe=Te.bg,$e=Te.fg,re=Te.extended.ext,U=ve,M=Y,te=Fe,_e&&A>=me&&A<=De&&(A=me),!this._coreService.isCursorHidden&&Ue&&this._coreService.isCursorInitialized){if(ae.push("xterm-cursor"),this._coreBrowserService.isFocused)N&&ae.push("xterm-cursor-blink"),ae.push(Q==="bar"?"xterm-cursor-bar":Q==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(E)switch(E){case"outline":ae.push("xterm-cursor-outline");break;case"block":ae.push("xterm-cursor-block");break;case"bar":ae.push("xterm-cursor-bar");break;case"underline":ae.push("xterm-cursor-underline")}}if(Te.isBold()&&ae.push("xterm-bold"),Te.isItalic()&&ae.push("xterm-italic"),Te.isDim()&&ae.push("xterm-dim"),ie=Te.isInvisible()?f.WHITESPACE_CELL_CHAR:Te.getChars()||f.WHITESPACE_CELL_CHAR,Te.isUnderline()&&(ae.push(`xterm-underline-${Te.extended.underlineStyle}`),ie===" "&&(ie=" "),!Te.isUnderlineColorDefault()))if(Te.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${x.AttributeData.toColorRGB(Te.getUnderlineColor()).join(",")})`;else{let ye=Te.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Te.isBold()&&ye<8&&(ye+=8),I.style.textDecorationColor=$.ansi[ye].css}Te.isOverline()&&(ae.push("xterm-overline"),ie===" "&&(ie=" ")),Te.isStrikethrough()&&ae.push("xterm-strikethrough"),ve&&(I.style.textDecoration="underline");let Ke=Te.getFgColor(),ft=Te.getFgColorMode(),mt=Te.getBgColor(),_t=Te.getBgColorMode();const Xt=!!Te.isInverse();if(Xt){const ye=Ke;Ke=mt,mt=ye;const ze=ft;ft=_t,_t=ze}let dt,Dt,Me,jt=!1;switch(this._decorationService.forEachDecorationAtCell(me,P,void 0,(ye=>{ye.options.layer!=="top"&&jt||(ye.backgroundColorRGB&&(_t=50331648,mt=ye.backgroundColorRGB.rgba>>8&16777215,dt=ye.backgroundColorRGB),ye.foregroundColorRGB&&(ft=50331648,Ke=ye.foregroundColorRGB.rgba>>8&16777215,Dt=ye.foregroundColorRGB),jt=ye.options.layer==="top")})),!jt&&Fe&&(dt=this._coreBrowserService.isFocused?$.selectionBackgroundOpaque:$.selectionInactiveBackgroundOpaque,mt=dt.rgba>>8&16777215,_t=50331648,jt=!0,$.selectionForeground&&(ft=50331648,Ke=$.selectionForeground.rgba>>8&16777215,Dt=$.selectionForeground)),jt&&ae.push("xterm-decoration-top"),_t){case 16777216:case 33554432:Me=$.ansi[mt],ae.push(`xterm-bg-${mt}`);break;case 50331648:Me=b.channels.toColor(mt>>16,mt>>8&255,255&mt),this._addStyle(I,`background-color:#${k((mt>>>0).toString(16),"0",6)}`);break;default:Xt?(Me=$.foreground,ae.push(`xterm-bg-${d.INVERTED_DEFAULT_COLOR}`)):Me=$.background}switch(dt||Te.isDim()&&(dt=b.color.multiplyOpacity(Me,.5)),ft){case 16777216:case 33554432:Te.isBold()&&Ke<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ke+=8),this._applyMinimumContrast(I,Me,$.ansi[Ke],Te,dt,void 0)||ae.push(`xterm-fg-${Ke}`);break;case 50331648:const ye=b.channels.toColor(Ke>>16&255,Ke>>8&255,255&Ke);this._applyMinimumContrast(I,Me,ye,Te,dt,Dt)||this._addStyle(I,`color:#${k(Ke.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,Me,$.foreground,Te,dt,Dt)||Xt&&ae.push(`xterm-fg-${d.INVERTED_DEFAULT_COLOR}`)}ae.length&&(I.className=ae.join(" "),ae.length=0),Ue||_e||V?I.textContent=ie:q++,Y!==this.defaultSpacing&&(I.style.letterSpacing=`${Y}px`),B.push(I),me=De}return I&&q&&(I.textContent=ie),B}_applyMinimumContrast(C,P,_,Q,E,A){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,m.treatGlyphAsBackgroundColor)(Q.getCode()))return!1;const N=this._getContrastCache(Q);let R;if(E||A||(R=N.getColor(P.rgba,_.rgba)),R===void 0){const W=this._optionsService.rawOptions.minimumContrastRatio/(Q.isDim()?2:1);R=b.color.ensureContrastRatio(E||P,A||_,W),N.setColor((E||P).rgba,(A||_).rgba,R??null)}return!!R&&(this._addStyle(C,`color:${R.css}`),!0)}_getContrastCache(C){return C.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(C,P){C.setAttribute("style",`${C.getAttribute("style")||""}${P};`)}_isCellInSelection(C,P){const _=this._selectionStart,Q=this._selectionEnd;return!(!_||!Q)&&(this._columnSelectMode?_[0]<=Q[0]?C>=_[0]&&P>=_[1]&&C<Q[0]&&P<=Q[1]:C<_[0]&&P>=_[1]&&C>=Q[0]&&P<=Q[1]:P>_[1]&&P<Q[1]||_[1]===Q[1]&&P===_[1]&&C>=_[0]&&C<Q[0]||_[1]<Q[1]&&P===Q[1]&&C<Q[0]||_[1]<Q[1]&&P===_[1]&&C>=_[0])}};function k(C,P,_){for(;C.length<_;)C=P+C;return C}o.DomRendererRowFactory=y=h([u(1,O.ICharacterJoinerService),u(2,v.IOptionsService),u(3,O.ICoreBrowserService),u(4,v.ICoreService),u(5,v.IDecorationService),u(6,O.IThemeService)],y)},2550:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WidthCache=void 0,o.WidthCache=class{constructor(l,h){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=l.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=l.createElement("span");u.classList.add("xterm-char-measure-element");const d=l.createElement("span");d.classList.add("xterm-char-measure-element"),d.style.fontWeight="bold";const f=l.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontStyle="italic";const p=l.createElement("span");p.classList.add("xterm-char-measure-element"),p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[u,d,f,p],this._container.appendChild(u),this._container.appendChild(d),this._container.appendChild(f),this._container.appendChild(p),h.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(l,h,u,d){l===this._font&&h===this._fontSize&&u===this._weight&&d===this._weightBold||(this._font=l,this._fontSize=h,this._weight=u,this._weightBold=d,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${d}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${d}`,this.clear())}get(l,h,u){let d=0;if(!h&&!u&&l.length===1&&(d=l.charCodeAt(0))<256){if(this._flat[d]!==-9999)return this._flat[d];const v=this._measure(l,0);return v>0&&(this._flat[d]=v),v}let f=l;h&&(f+="B"),u&&(f+="I");let p=this._holey.get(f);if(p===void 0){let v=0;h&&(v|=1),u&&(v|=2),p=this._measure(l,v),p>0&&this._holey.set(f,p)}return p}_measure(l,h){const u=this._measureElements[h];return u.textContent=l.repeat(32),u.offsetWidth/32}}},2223:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.TEXT_BASELINE=o.DIM_OPACITY=o.INVERTED_DEFAULT_COLOR=void 0;const h=l(6114);o.INVERTED_DEFAULT_COLOR=257,o.DIM_OPACITY=.5,o.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(a,o)=>{function l(u){return 57508<=u&&u<=57558}function h(u){return u>=128512&&u<=128591||u>=127744&&u<=128511||u>=128640&&u<=128767||u>=9728&&u<=9983||u>=9984&&u<=10175||u>=65024&&u<=65039||u>=129280&&u<=129535||u>=127462&&u<=127487}Object.defineProperty(o,"__esModule",{value:!0}),o.computeNextVariantOffset=o.createRenderDimensions=o.treatGlyphAsBackgroundColor=o.allowRescaling=o.isEmoji=o.isRestrictedPowerlineGlyph=o.isPowerlineGlyph=o.throwIfFalsy=void 0,o.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},o.isPowerlineGlyph=l,o.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},o.isEmoji=h,o.allowRescaling=function(u,d,f,p){return d===1&&f>Math.ceil(1.5*p)&&u!==void 0&&u>255&&!h(u)&&!l(u)&&!(function(v){return 57344<=v&&v<=63743})(u)},o.treatGlyphAsBackgroundColor=function(u){return l(u)||(function(d){return 9472<=d&&d<=9631})(u)},o.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}}}},o.computeNextVariantOffset=function(u,d,f=0){return(u-(2*Math.round(d)-f))%(2*Math.round(d))}},6052:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createSelectionRenderModel=void 0;class l{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(u,d,f,p=!1){if(this.selectionStart=d,this.selectionEnd=f,!d||!f||d[0]===f[0]&&d[1]===f[1])return void this.clear();const v=u.buffers.active.ydisp,b=d[1]-v,O=f[1]-v,g=Math.max(b,0),m=Math.min(O,u.rows-1);g>=u.rows||m<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=p,this.viewportStartRow=b,this.viewportEndRow=O,this.viewportCappedStartRow=g,this.viewportCappedEndRow=m,this.startCol=d[0],this.endCol=f[0])}isCellSelected(u,d,f){return!!this.hasSelection&&(f-=u.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?d>=this.startCol&&f>=this.viewportCappedStartRow&&d<this.endCol&&f<=this.viewportCappedEndRow:d<this.startCol&&f>=this.viewportCappedStartRow&&d>=this.endCol&&f<=this.viewportCappedEndRow:f>this.viewportStartRow&&f<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&f===this.viewportStartRow&&d>=this.startCol&&d<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportEndRow&&d<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportStartRow&&d>=this.startCol)}}o.createSelectionRenderModel=function(){return new l}},456:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SelectionModel=void 0,o.SelectionModel=class{constructor(l){this._bufferService=l,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 l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?l%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)-1]:[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[l,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[Math.max(l,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const l=this.selectionStart,h=this.selectionEnd;return!(!l||!h)&&(l[1]>h[1]||l[1]===h[1]&&l[0]>h[0])}handleTrim(l){return this.selectionStart&&(this.selectionStart[1]-=l),this.selectionEnd&&(this.selectionEnd[1]-=l),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(a,o,l){var h=this&&this.__decorate||function(m,x,y,k){var C,P=arguments.length,_=P<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(m,x,y,k);else for(var Q=m.length-1;Q>=0;Q--)(C=m[Q])&&(_=(P<3?C(_):P>3?C(x,y,_):C(x,y))||_);return P>3&&_&&Object.defineProperty(x,y,_),_},u=this&&this.__param||function(m,x){return function(y,k){x(y,k,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharSizeService=void 0;const d=l(2585),f=l(8460),p=l(844);let v=o.CharSizeService=class extends p.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(m,x,y){super(),this._optionsService=y,this.width=0,this.height=0,this._onCharSizeChange=this.register(new f.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new g(this._optionsService))}catch{this._measureStrategy=this.register(new O(m,x,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const m=this._measureStrategy.measure();m.width===this.width&&m.height===this.height||(this.width=m.width,this.height=m.height,this._onCharSizeChange.fire())}};o.CharSizeService=v=h([u(2,d.IOptionsService)],v);class b extends p.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(x,y){x!==void 0&&x>0&&y!==void 0&&y>0&&(this._result.width=x,this._result.height=y)}}class O extends b{constructor(x,y,k){super(),this._document=x,this._parentElement=y,this._optionsService=k,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(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class g extends b{constructor(x){super(),this._optionsService=x,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const y=this._ctx.measureText("W");if(!("width"in y&&"fontBoundingBoxAscent"in y&&"fontBoundingBoxDescent"in y))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const x=this._ctx.measureText("W");return this._validateAndSet(x.width,x.fontBoundingBoxAscent+x.fontBoundingBoxDescent),this._result}}},4269:function(a,o,l){var h=this&&this.__decorate||function(g,m,x,y){var k,C=arguments.length,P=C<3?m:y===null?y=Object.getOwnPropertyDescriptor(m,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(g,m,x,y);else for(var _=g.length-1;_>=0;_--)(k=g[_])&&(P=(C<3?k(P):C>3?k(m,x,P):k(m,x))||P);return C>3&&P&&Object.defineProperty(m,x,P),P},u=this&&this.__param||function(g,m){return function(x,y){m(x,y,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharacterJoinerService=o.JoinedCellData=void 0;const d=l(3734),f=l(643),p=l(511),v=l(2585);class b extends d.AttributeData{constructor(m,x,y){super(),this.content=0,this.combinedData="",this.fg=m.fg,this.bg=m.bg,this.combinedData=x,this._width=y}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(m){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.JoinedCellData=b;let O=o.CharacterJoinerService=class Z_{constructor(m){this._bufferService=m,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new p.CellData}register(m){const x={id:this._nextCharacterJoinerId++,handler:m};return this._characterJoiners.push(x),x.id}deregister(m){for(let x=0;x<this._characterJoiners.length;x++)if(this._characterJoiners[x].id===m)return this._characterJoiners.splice(x,1),!0;return!1}getJoinedCharacters(m){if(this._characterJoiners.length===0)return[];const x=this._bufferService.buffer.lines.get(m);if(!x||x.length===0)return[];const y=[],k=x.translateToString(!0);let C=0,P=0,_=0,Q=x.getFg(0),E=x.getBg(0);for(let A=0;A<x.getTrimmedLength();A++)if(x.loadCell(A,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==Q||this._workCell.bg!==E){if(A-C>1){const N=this._getJoinedRanges(k,_,P,x,C);for(let R=0;R<N.length;R++)y.push(N[R])}C=A,_=P,Q=this._workCell.fg,E=this._workCell.bg}P+=this._workCell.getChars().length||f.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-C>1){const A=this._getJoinedRanges(k,_,P,x,C);for(let N=0;N<A.length;N++)y.push(A[N])}return y}_getJoinedRanges(m,x,y,k,C){const P=m.substring(x,y);let _=[];try{_=this._characterJoiners[0].handler(P)}catch(Q){console.error(Q)}for(let Q=1;Q<this._characterJoiners.length;Q++)try{const E=this._characterJoiners[Q].handler(P);for(let A=0;A<E.length;A++)Z_._mergeRanges(_,E[A])}catch(E){console.error(E)}return this._stringRangesToCellRanges(_,k,C),_}_stringRangesToCellRanges(m,x,y){let k=0,C=!1,P=0,_=m[k];if(_){for(let Q=y;Q<this._bufferService.cols;Q++){const E=x.getWidth(Q),A=x.getString(Q).length||f.WHITESPACE_CELL_CHAR.length;if(E!==0){if(!C&&_[0]<=P&&(_[0]=Q,C=!0),_[1]<=P){if(_[1]=Q,_=m[++k],!_)break;_[0]<=P?(_[0]=Q,C=!0):C=!1}P+=A}}_&&(_[1]=this._bufferService.cols)}}static _mergeRanges(m,x){let y=!1;for(let k=0;k<m.length;k++){const C=m[k];if(y){if(x[1]<=C[0])return m[k-1][1]=x[1],m;if(x[1]<=C[1])return m[k-1][1]=Math.max(x[1],C[1]),m.splice(k,1),m;m.splice(k,1),k--}else{if(x[1]<=C[0])return m.splice(k,0,x),m;if(x[1]<=C[1])return C[0]=Math.min(x[0],C[0]),m;x[0]<C[1]&&(C[0]=Math.min(x[0],C[0]),y=!0)}}return y?m[m.length-1][1]=x[1]:m.push(x),m}};o.CharacterJoinerService=O=h([u(0,v.IBufferService)],O)},5114:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreBrowserService=void 0;const h=l(844),u=l(8460),d=l(3656);class f extends h.Disposable{constructor(b,O,g){super(),this._textarea=b,this._window=O,this.mainDocument=g,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new p(this._window),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new u.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((m=>this._screenDprMonitor.setWindow(m)))),this.register((0,u.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(b){this._window!==b&&(this._window=b,this._onWindowChange.fire(this._window))}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}}o.CoreBrowserService=f;class p extends h.Disposable{constructor(b){super(),this._parentWindow=b,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new u.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(b){this._parentWindow=b,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,d.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.LinkProviderService=void 0;const h=l(844);class u extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(f){return this.linkProviders.push(f),{dispose:()=>{const p=this.linkProviders.indexOf(f);p!==-1&&this.linkProviders.splice(p,1)}}}}o.LinkProviderService=u},8934:function(a,o,l){var h=this&&this.__decorate||function(v,b,O,g){var m,x=arguments.length,y=x<3?b:g===null?g=Object.getOwnPropertyDescriptor(b,O):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,b,O,g);else for(var k=v.length-1;k>=0;k--)(m=v[k])&&(y=(x<3?m(y):x>3?m(b,O,y):m(b,O))||y);return x>3&&y&&Object.defineProperty(b,O,y),y},u=this&&this.__param||function(v,b){return function(O,g){b(O,g,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.MouseService=void 0;const d=l(4725),f=l(9806);let p=o.MouseService=class{constructor(v,b){this._renderService=v,this._charSizeService=b}getCoords(v,b,O,g,m){return(0,f.getCoords)(window,v,b,O,g,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,m)}getMouseReportCoords(v,b){const O=(0,f.getCoordsRelativeToElement)(window,v,b);if(this._charSizeService.hasValidSize)return O[0]=Math.min(Math.max(O[0],0),this._renderService.dimensions.css.canvas.width-1),O[1]=Math.min(Math.max(O[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(O[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(O[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(O[0]),y:Math.floor(O[1])}}};o.MouseService=p=h([u(0,d.IRenderService),u(1,d.ICharSizeService)],p)},3230:function(a,o,l){var h=this&&this.__decorate||function(m,x,y,k){var C,P=arguments.length,_=P<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(m,x,y,k);else for(var Q=m.length-1;Q>=0;Q--)(C=m[Q])&&(_=(P<3?C(_):P>3?C(x,y,_):C(x,y))||_);return P>3&&_&&Object.defineProperty(x,y,_),_},u=this&&this.__param||function(m,x){return function(y,k){x(y,k,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.RenderService=void 0;const d=l(6193),f=l(4725),p=l(8460),v=l(844),b=l(7226),O=l(2585);let g=o.RenderService=class extends v.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(m,x,y,k,C,P,_,Q){super(),this._rowCount=m,this._charSizeService=k,this._renderer=this.register(new v.MutableDisposable),this._pausedResizeTask=new b.DebouncedIdleTask,this._observerDisposable=this.register(new v.MutableDisposable),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 p.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new p.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new p.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new p.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new d.RenderDebouncer(((E,A)=>this._renderRows(E,A)),_),this.register(this._renderDebouncer),this.register(_.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(P.onResize((()=>this._fullRefresh()))),this.register(P.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(y.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(C.onDecorationRegistered((()=>this._fullRefresh()))),this.register(C.onDecorationRemoved((()=>this._fullRefresh()))),this.register(y.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(P.cols,P.rows),this._fullRefresh()}))),this.register(y.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(P.buffer.y,P.buffer.y,!0)))),this.register(Q.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(_.window,x),this.register(_.onWindowChange((E=>this._registerIntersectionObserver(E,x))))}_registerIntersectionObserver(m,x){if("IntersectionObserver"in m){const y=new m.IntersectionObserver((k=>this._handleIntersectionChange(k[k.length-1])),{threshold:0});y.observe(x),this._observerDisposable.value=(0,v.toDisposable)((()=>y.disconnect()))}}_handleIntersectionChange(m){this._isPaused=m.isIntersecting===void 0?m.intersectionRatio===0:!m.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(m,x,y=!1){this._isPaused?this._needsFullRefresh=!0:(y||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(m,x,this._rowCount))}_renderRows(m,x){this._renderer.value&&(m=Math.min(m,this._rowCount-1),x=Math.min(x,this._rowCount-1),this._renderer.value.renderRows(m,x),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:m,end:x}),this._onRender.fire({start:m,end:x}),this._isNextRenderRedrawOnly=!0)}resize(m,x){this._rowCount=x,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(m){this._renderer.value=m,this._renderer.value&&(this._renderer.value.onRequestRedraw((x=>this.refreshRows(x.start,x.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(m){return this._renderDebouncer.addRefreshCallback(m)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(m,x){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(m,x))):this._renderer.value.handleResize(m,x),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(m,x,y){this._selectionState.start=m,this._selectionState.end=x,this._selectionState.columnSelectMode=y,this._renderer.value?.handleSelectionChanged(m,x,y)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};o.RenderService=g=h([u(2,O.IOptionsService),u(3,f.ICharSizeService),u(4,O.IDecorationService),u(5,O.IBufferService),u(6,f.ICoreBrowserService),u(7,f.IThemeService)],g)},9312:function(a,o,l){var h=this&&this.__decorate||function(_,Q,E,A){var N,R=arguments.length,W=R<3?Q:A===null?A=Object.getOwnPropertyDescriptor(Q,E):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(_,Q,E,A);else for(var H=_.length-1;H>=0;H--)(N=_[H])&&(W=(R<3?N(W):R>3?N(Q,E,W):N(Q,E))||W);return R>3&&W&&Object.defineProperty(Q,E,W),W},u=this&&this.__param||function(_,Q){return function(E,A){Q(E,A,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.SelectionService=void 0;const d=l(9806),f=l(9504),p=l(456),v=l(4725),b=l(8460),O=l(844),g=l(6114),m=l(4841),x=l(511),y=l(2585),k=" ",C=new RegExp(k,"g");let P=o.SelectionService=class extends O.Disposable{constructor(_,Q,E,A,N,R,W,H,Z){super(),this._element=_,this._screenElement=Q,this._linkifier=E,this._bufferService=A,this._coreService=N,this._mouseService=R,this._optionsService=W,this._renderService=H,this._coreBrowserService=Z,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new x.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=B=>this._handleMouseMove(B),this._mouseUpListener=B=>this._handleMouseUp(B),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((B=>this._handleTrim(B))),this.register(this._bufferService.buffers.onBufferActivate((B=>this._handleBufferActivate(B)))),this.enable(),this._model=new p.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,O.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 _=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd;return!(!_||!Q||_[0]===Q[0]&&_[1]===Q[1])}get selectionText(){const _=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd;if(!_||!Q)return"";const E=this._bufferService.buffer,A=[];if(this._activeSelectionMode===3){if(_[0]===Q[0])return"";const N=_[0]<Q[0]?_[0]:Q[0],R=_[0]<Q[0]?Q[0]:_[0];for(let W=_[1];W<=Q[1];W++){const H=E.translateBufferLineToString(W,!0,N,R);A.push(H)}}else{const N=_[1]===Q[1]?Q[0]:void 0;A.push(E.translateBufferLineToString(_[1],!0,_[0],N));for(let R=_[1]+1;R<=Q[1]-1;R++){const W=E.lines.get(R),H=E.translateBufferLineToString(R,!0);W?.isWrapped?A[A.length-1]+=H:A.push(H)}if(_[1]!==Q[1]){const R=E.lines.get(Q[1]),W=E.translateBufferLineToString(Q[1],!0,0,Q[0]);R&&R.isWrapped?A[A.length-1]+=W:A.push(W)}}return A.map((N=>N.replace(C," "))).join(g.isWindows?`\r
50
+ `:`
51
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(_){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),g.isLinux&&_&&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(_){const Q=this._getMouseBufferCoords(_),E=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!!(E&&A&&Q)&&this._areCoordsInSelection(Q,E,A)}isCellInSelection(_,Q){const E=this._model.finalSelectionStart,A=this._model.finalSelectionEnd;return!(!E||!A)&&this._areCoordsInSelection([_,Q],E,A)}_areCoordsInSelection(_,Q,E){return _[1]>Q[1]&&_[1]<E[1]||Q[1]===E[1]&&_[1]===Q[1]&&_[0]>=Q[0]&&_[0]<E[0]||Q[1]<E[1]&&_[1]===E[1]&&_[0]<E[0]||Q[1]<E[1]&&_[1]===Q[1]&&_[0]>=Q[0]}_selectWordAtCursor(_,Q){const E=this._linkifier.currentLink?.link?.range;if(E)return this._model.selectionStart=[E.start.x-1,E.start.y-1],this._model.selectionStartLength=(0,m.getRangeLength)(E,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const A=this._getMouseBufferCoords(_);return!!A&&(this._selectWordAt(A,Q),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(_,Q){this._model.clearSelection(),_=Math.max(_,0),Q=Math.min(Q,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,_],this._model.selectionEnd=[this._bufferService.cols,Q],this.refresh(),this._onSelectionChange.fire()}_handleTrim(_){this._model.handleTrim(_)&&this.refresh()}_getMouseBufferCoords(_){const Q=this._mouseService.getCoords(_,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(Q)return Q[0]--,Q[1]--,Q[1]+=this._bufferService.buffer.ydisp,Q}_getMouseEventScrollAmount(_){let Q=(0,d.getCoordsRelativeToElement)(this._coreBrowserService.window,_,this._screenElement)[1];const E=this._renderService.dimensions.css.canvas.height;return Q>=0&&Q<=E?0:(Q>E&&(Q-=E),Q=Math.min(Math.max(Q,-50),50),Q/=50,Q/Math.abs(Q)+Math.round(14*Q))}shouldForceSelection(_){return g.isMac?_.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:_.shiftKey}handleMouseDown(_){if(this._mouseDownTimeStamp=_.timeStamp,(_.button!==2||!this.hasSelection)&&_.button===0){if(!this._enabled){if(!this.shouldForceSelection(_))return;_.stopPropagation()}_.preventDefault(),this._dragScrollAmount=0,this._enabled&&_.shiftKey?this._handleIncrementalClick(_):_.detail===1?this._handleSingleClick(_):_.detail===2?this._handleDoubleClick(_):_.detail===3&&this._handleTripleClick(_),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(_){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(_))}_handleSingleClick(_){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(_)?3:0,this._model.selectionStart=this._getMouseBufferCoords(_),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const Q=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);Q&&Q.length!==this._model.selectionStart[0]&&Q.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(_){this._selectWordAtCursor(_,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(_){const Q=this._getMouseBufferCoords(_);Q&&(this._activeSelectionMode=2,this._selectLineAt(Q[1]))}shouldColumnSelect(_){return _.altKey&&!(g.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(_){if(_.stopImmediatePropagation(),!this._model.selectionStart)return;const Q=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(_),!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(_),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const E=this._bufferService.buffer;if(this._model.selectionEnd[1]<E.lines.length){const A=E.lines.get(this._model.selectionEnd[1]);A&&A.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}Q&&Q[0]===this._model.selectionEnd[0]&&Q[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 _=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(_.ydisp+this._bufferService.rows,_.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=_.ydisp),this.refresh()}}_handleMouseUp(_){const Q=_.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&Q<500&&_.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const E=this._mouseService.getCoords(_,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(E&&E[0]!==void 0&&E[1]!==void 0){const A=(0,f.moveToCellSequence)(E[0]-1,E[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(A,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const _=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd,E=!(!_||!Q||_[0]===Q[0]&&_[1]===Q[1]);E?_&&Q&&(this._oldSelectionStart&&this._oldSelectionEnd&&_[0]===this._oldSelectionStart[0]&&_[1]===this._oldSelectionStart[1]&&Q[0]===this._oldSelectionEnd[0]&&Q[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(_,Q,E)):this._oldHasSelection&&this._fireOnSelectionChange(_,Q,E)}_fireOnSelectionChange(_,Q,E){this._oldSelectionStart=_,this._oldSelectionEnd=Q,this._oldHasSelection=E,this._onSelectionChange.fire()}_handleBufferActivate(_){this.clearSelection(),this._trimListener.dispose(),this._trimListener=_.activeBuffer.lines.onTrim((Q=>this._handleTrim(Q)))}_convertViewportColToCharacterIndex(_,Q){let E=Q;for(let A=0;Q>=A;A++){const N=_.loadCell(A,this._workCell).getChars().length;this._workCell.getWidth()===0?E--:N>1&&Q!==A&&(E+=N-1)}return E}setSelection(_,Q,E){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[_,Q],this._model.selectionStartLength=E,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(_){this._isClickInSelection(_)||(this._selectWordAtCursor(_,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(_,Q,E=!0,A=!0){if(_[0]>=this._bufferService.cols)return;const N=this._bufferService.buffer,R=N.lines.get(_[1]);if(!R)return;const W=N.translateBufferLineToString(_[1],!1);let H=this._convertViewportColToCharacterIndex(R,_[0]),Z=H;const B=_[0]-H;let K=0,$=0,I=0,X=0;if(W.charAt(H)===" "){for(;H>0&&W.charAt(H-1)===" ";)H--;for(;Z<W.length&&W.charAt(Z+1)===" ";)Z++}else{let pe=_[0],$e=_[0];R.getWidth(pe)===0&&(K++,pe--),R.getWidth($e)===2&&($++,$e++);const re=R.getString($e).length;for(re>1&&(X+=re-1,Z+=re-1);pe>0&&H>0&&!this._isCharWordSeparator(R.loadCell(pe-1,this._workCell));){R.loadCell(pe-1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===0?(K++,pe--):U>1&&(I+=U-1,H-=U-1),H--,pe--}for(;$e<R.length&&Z+1<W.length&&!this._isCharWordSeparator(R.loadCell($e+1,this._workCell));){R.loadCell($e+1,this._workCell);const U=this._workCell.getChars().length;this._workCell.getWidth()===2?($++,$e++):U>1&&(X+=U-1,Z+=U-1),Z++,$e++}}Z++;let q=H+B-K+I,ie=Math.min(this._bufferService.cols,Z-H+K+$-I-X);if(Q||W.slice(H,Z).trim()!==""){if(E&&q===0&&R.getCodePoint(0)!==32){const pe=N.lines.get(_[1]-1);if(pe&&R.isWrapped&&pe.getCodePoint(this._bufferService.cols-1)!==32){const $e=this._getWordAt([this._bufferService.cols-1,_[1]-1],!1,!0,!1);if($e){const re=this._bufferService.cols-$e.start;q-=re,ie+=re}}}if(A&&q+ie===this._bufferService.cols&&R.getCodePoint(this._bufferService.cols-1)!==32){const pe=N.lines.get(_[1]+1);if(pe?.isWrapped&&pe.getCodePoint(0)!==32){const $e=this._getWordAt([0,_[1]+1],!1,!1,!0);$e&&(ie+=$e.length)}}return{start:q,length:ie}}}_selectWordAt(_,Q){const E=this._getWordAt(_,Q);if(E){for(;E.start<0;)E.start+=this._bufferService.cols,_[1]--;this._model.selectionStart=[E.start,_[1]],this._model.selectionStartLength=E.length}}_selectToWordAt(_){const Q=this._getWordAt(_,!0);if(Q){let E=_[1];for(;Q.start<0;)Q.start+=this._bufferService.cols,E--;if(!this._model.areSelectionValuesReversed())for(;Q.start+Q.length>this._bufferService.cols;)Q.length-=this._bufferService.cols,E++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?Q.start:Q.start+Q.length,E]}}_isCharWordSeparator(_){return _.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(_.getChars())>=0}_selectLineAt(_){const Q=this._bufferService.buffer.getWrappedRangeForLine(_),E={start:{x:0,y:Q.first},end:{x:this._bufferService.cols-1,y:Q.last}};this._model.selectionStart=[0,Q.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,m.getRangeLength)(E,this._bufferService.cols)}};o.SelectionService=P=h([u(3,y.IBufferService),u(4,y.ICoreService),u(5,v.IMouseService),u(6,y.IOptionsService),u(7,v.IRenderService),u(8,v.ICoreBrowserService)],P)},4725:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ILinkProviderService=o.IThemeService=o.ICharacterJoinerService=o.ISelectionService=o.IRenderService=o.IMouseService=o.ICoreBrowserService=o.ICharSizeService=void 0;const h=l(8343);o.ICharSizeService=(0,h.createDecorator)("CharSizeService"),o.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),o.IMouseService=(0,h.createDecorator)("MouseService"),o.IRenderService=(0,h.createDecorator)("RenderService"),o.ISelectionService=(0,h.createDecorator)("SelectionService"),o.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),o.IThemeService=(0,h.createDecorator)("ThemeService"),o.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(a,o,l){var h=this&&this.__decorate||function(P,_,Q,E){var A,N=arguments.length,R=N<3?_:E===null?E=Object.getOwnPropertyDescriptor(_,Q):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(P,_,Q,E);else for(var W=P.length-1;W>=0;W--)(A=P[W])&&(R=(N<3?A(R):N>3?A(_,Q,R):A(_,Q))||R);return N>3&&R&&Object.defineProperty(_,Q,R),R},u=this&&this.__param||function(P,_){return function(Q,E){_(Q,E,P)}};Object.defineProperty(o,"__esModule",{value:!0}),o.ThemeService=o.DEFAULT_ANSI_COLORS=void 0;const d=l(7239),f=l(8055),p=l(8460),v=l(844),b=l(2585),O=f.css.toColor("#ffffff"),g=f.css.toColor("#000000"),m=f.css.toColor("#ffffff"),x=f.css.toColor("#000000"),y={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};o.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const P=[f.css.toColor("#2e3436"),f.css.toColor("#cc0000"),f.css.toColor("#4e9a06"),f.css.toColor("#c4a000"),f.css.toColor("#3465a4"),f.css.toColor("#75507b"),f.css.toColor("#06989a"),f.css.toColor("#d3d7cf"),f.css.toColor("#555753"),f.css.toColor("#ef2929"),f.css.toColor("#8ae234"),f.css.toColor("#fce94f"),f.css.toColor("#729fcf"),f.css.toColor("#ad7fa8"),f.css.toColor("#34e2e2"),f.css.toColor("#eeeeec")],_=[0,95,135,175,215,255];for(let Q=0;Q<216;Q++){const E=_[Q/36%6|0],A=_[Q/6%6|0],N=_[Q%6];P.push({css:f.channels.toCss(E,A,N),rgba:f.channels.toRgba(E,A,N)})}for(let Q=0;Q<24;Q++){const E=8+10*Q;P.push({css:f.channels.toCss(E,E,E),rgba:f.channels.toRgba(E,E,E)})}return P})());let k=o.ThemeService=class extends v.Disposable{get colors(){return this._colors}constructor(P){super(),this._optionsService=P,this._contrastCache=new d.ColorContrastCache,this._halfContrastCache=new d.ColorContrastCache,this._onChangeColors=this.register(new p.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:O,background:g,cursor:m,cursorAccent:x,selectionForeground:void 0,selectionBackgroundTransparent:y,selectionBackgroundOpaque:f.color.blend(g,y),selectionInactiveBackgroundTransparent:y,selectionInactiveBackgroundOpaque:f.color.blend(g,y),ansi:o.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(P={}){const _=this._colors;if(_.foreground=C(P.foreground,O),_.background=C(P.background,g),_.cursor=C(P.cursor,m),_.cursorAccent=C(P.cursorAccent,x),_.selectionBackgroundTransparent=C(P.selectionBackground,y),_.selectionBackgroundOpaque=f.color.blend(_.background,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundTransparent=C(P.selectionInactiveBackground,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundOpaque=f.color.blend(_.background,_.selectionInactiveBackgroundTransparent),_.selectionForeground=P.selectionForeground?C(P.selectionForeground,f.NULL_COLOR):void 0,_.selectionForeground===f.NULL_COLOR&&(_.selectionForeground=void 0),f.color.isOpaque(_.selectionBackgroundTransparent)&&(_.selectionBackgroundTransparent=f.color.opacity(_.selectionBackgroundTransparent,.3)),f.color.isOpaque(_.selectionInactiveBackgroundTransparent)&&(_.selectionInactiveBackgroundTransparent=f.color.opacity(_.selectionInactiveBackgroundTransparent,.3)),_.ansi=o.DEFAULT_ANSI_COLORS.slice(),_.ansi[0]=C(P.black,o.DEFAULT_ANSI_COLORS[0]),_.ansi[1]=C(P.red,o.DEFAULT_ANSI_COLORS[1]),_.ansi[2]=C(P.green,o.DEFAULT_ANSI_COLORS[2]),_.ansi[3]=C(P.yellow,o.DEFAULT_ANSI_COLORS[3]),_.ansi[4]=C(P.blue,o.DEFAULT_ANSI_COLORS[4]),_.ansi[5]=C(P.magenta,o.DEFAULT_ANSI_COLORS[5]),_.ansi[6]=C(P.cyan,o.DEFAULT_ANSI_COLORS[6]),_.ansi[7]=C(P.white,o.DEFAULT_ANSI_COLORS[7]),_.ansi[8]=C(P.brightBlack,o.DEFAULT_ANSI_COLORS[8]),_.ansi[9]=C(P.brightRed,o.DEFAULT_ANSI_COLORS[9]),_.ansi[10]=C(P.brightGreen,o.DEFAULT_ANSI_COLORS[10]),_.ansi[11]=C(P.brightYellow,o.DEFAULT_ANSI_COLORS[11]),_.ansi[12]=C(P.brightBlue,o.DEFAULT_ANSI_COLORS[12]),_.ansi[13]=C(P.brightMagenta,o.DEFAULT_ANSI_COLORS[13]),_.ansi[14]=C(P.brightCyan,o.DEFAULT_ANSI_COLORS[14]),_.ansi[15]=C(P.brightWhite,o.DEFAULT_ANSI_COLORS[15]),P.extendedAnsi){const Q=Math.min(_.ansi.length-16,P.extendedAnsi.length);for(let E=0;E<Q;E++)_.ansi[E+16]=C(P.extendedAnsi[E],o.DEFAULT_ANSI_COLORS[E+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(P){this._restoreColor(P),this._onChangeColors.fire(this.colors)}_restoreColor(P){if(P!==void 0)switch(P){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[P]=this._restoreColors.ansi[P]}else for(let _=0;_<this._restoreColors.ansi.length;++_)this._colors.ansi[_]=this._restoreColors.ansi[_]}modifyColors(P){P(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 C(P,_){if(P!==void 0)try{return f.css.toColor(P)}catch{}return _}o.ThemeService=k=h([u(0,b.IOptionsService)],k)},6349:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CircularList=void 0;const h=l(8460),u=l(844);class d extends u.Disposable{constructor(p){super(),this._maxLength=p,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.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(p){if(this._maxLength===p)return;const v=new Array(p);for(let b=0;b<Math.min(p,this.length);b++)v[b]=this._array[this._getCyclicIndex(b)];this._array=v,this._maxLength=p,this._startIndex=0}get length(){return this._length}set length(p){if(p>this._length)for(let v=this._length;v<p;v++)this._array[v]=void 0;this._length=p}get(p){return this._array[this._getCyclicIndex(p)]}set(p,v){this._array[this._getCyclicIndex(p)]=v}push(p){this._array[this._getCyclicIndex(this._length)]=p,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(p,v,...b){if(v){for(let O=p;O<this._length-v;O++)this._array[this._getCyclicIndex(O)]=this._array[this._getCyclicIndex(O+v)];this._length-=v,this.onDeleteEmitter.fire({index:p,amount:v})}for(let O=this._length-1;O>=p;O--)this._array[this._getCyclicIndex(O+b.length)]=this._array[this._getCyclicIndex(O)];for(let O=0;O<b.length;O++)this._array[this._getCyclicIndex(p+O)]=b[O];if(b.length&&this.onInsertEmitter.fire({index:p,amount:b.length}),this._length+b.length>this._maxLength){const O=this._length+b.length-this._maxLength;this._startIndex+=O,this._length=this._maxLength,this.onTrimEmitter.fire(O)}else this._length+=b.length}trimStart(p){p>this._length&&(p=this._length),this._startIndex+=p,this._length-=p,this.onTrimEmitter.fire(p)}shiftElements(p,v,b){if(!(v<=0)){if(p<0||p>=this._length)throw new Error("start argument out of range");if(p+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let g=v-1;g>=0;g--)this.set(p+g+b,this.get(p+g));const O=p+v+b-this._length;if(O>0)for(this._length+=O;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let O=0;O<v;O++)this.set(p+O+b,this.get(p+O))}}_getCyclicIndex(p){return(this._startIndex+p)%this._maxLength}}o.CircularList=d},1439:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.clone=void 0,o.clone=function l(h,u=5){if(typeof h!="object")return h;const d=Array.isArray(h)?[]:{};for(const f in h)d[f]=u<=1?h[f]:h[f]&&l(h[f],u-1);return d}},8055:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.contrastRatio=o.toPaddedHex=o.rgba=o.rgb=o.css=o.color=o.channels=o.NULL_COLOR=void 0;let l=0,h=0,u=0,d=0;var f,p,v,b,O;function g(x){const y=x.toString(16);return y.length<2?"0"+y:y}function m(x,y){return x<y?(y+.05)/(x+.05):(x+.05)/(y+.05)}o.NULL_COLOR={css:"#00000000",rgba:0},(function(x){x.toCss=function(y,k,C,P){return P!==void 0?`#${g(y)}${g(k)}${g(C)}${g(P)}`:`#${g(y)}${g(k)}${g(C)}`},x.toRgba=function(y,k,C,P=255){return(y<<24|k<<16|C<<8|P)>>>0},x.toColor=function(y,k,C,P){return{css:x.toCss(y,k,C,P),rgba:x.toRgba(y,k,C,P)}}})(f||(o.channels=f={})),(function(x){function y(k,C){return d=Math.round(255*C),[l,h,u]=O.toChannels(k.rgba),{css:f.toCss(l,h,u,d),rgba:f.toRgba(l,h,u,d)}}x.blend=function(k,C){if(d=(255&C.rgba)/255,d===1)return{css:C.css,rgba:C.rgba};const P=C.rgba>>24&255,_=C.rgba>>16&255,Q=C.rgba>>8&255,E=k.rgba>>24&255,A=k.rgba>>16&255,N=k.rgba>>8&255;return l=E+Math.round((P-E)*d),h=A+Math.round((_-A)*d),u=N+Math.round((Q-N)*d),{css:f.toCss(l,h,u),rgba:f.toRgba(l,h,u)}},x.isOpaque=function(k){return(255&k.rgba)==255},x.ensureContrastRatio=function(k,C,P){const _=O.ensureContrastRatio(k.rgba,C.rgba,P);if(_)return f.toColor(_>>24&255,_>>16&255,_>>8&255)},x.opaque=function(k){const C=(255|k.rgba)>>>0;return[l,h,u]=O.toChannels(C),{css:f.toCss(l,h,u),rgba:C}},x.opacity=y,x.multiplyOpacity=function(k,C){return d=255&k.rgba,y(k,d*C/255)},x.toColorRGB=function(k){return[k.rgba>>24&255,k.rgba>>16&255,k.rgba>>8&255]}})(p||(o.color=p={})),(function(x){let y,k;try{const C=document.createElement("canvas");C.width=1,C.height=1;const P=C.getContext("2d",{willReadFrequently:!0});P&&(y=P,y.globalCompositeOperation="copy",k=y.createLinearGradient(0,0,1,1))}catch{}x.toColor=function(C){if(C.match(/#[\da-f]{3,8}/i))switch(C.length){case 4:return l=parseInt(C.slice(1,2).repeat(2),16),h=parseInt(C.slice(2,3).repeat(2),16),u=parseInt(C.slice(3,4).repeat(2),16),f.toColor(l,h,u);case 5:return l=parseInt(C.slice(1,2).repeat(2),16),h=parseInt(C.slice(2,3).repeat(2),16),u=parseInt(C.slice(3,4).repeat(2),16),d=parseInt(C.slice(4,5).repeat(2),16),f.toColor(l,h,u,d);case 7:return{css:C,rgba:(parseInt(C.slice(1),16)<<8|255)>>>0};case 9:return{css:C,rgba:parseInt(C.slice(1),16)>>>0}}const P=C.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(P)return l=parseInt(P[1]),h=parseInt(P[2]),u=parseInt(P[3]),d=Math.round(255*(P[5]===void 0?1:parseFloat(P[5]))),f.toColor(l,h,u,d);if(!y||!k)throw new Error("css.toColor: Unsupported css format");if(y.fillStyle=k,y.fillStyle=C,typeof y.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(y.fillRect(0,0,1,1),[l,h,u,d]=y.getImageData(0,0,1,1).data,d!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:f.toRgba(l,h,u,d),css:C}}})(v||(o.css=v={})),(function(x){function y(k,C,P){const _=k/255,Q=C/255,E=P/255;return .2126*(_<=.03928?_/12.92:Math.pow((_+.055)/1.055,2.4))+.7152*(Q<=.03928?Q/12.92:Math.pow((Q+.055)/1.055,2.4))+.0722*(E<=.03928?E/12.92:Math.pow((E+.055)/1.055,2.4))}x.relativeLuminance=function(k){return y(k>>16&255,k>>8&255,255&k)},x.relativeLuminance2=y})(b||(o.rgb=b={})),(function(x){function y(C,P,_){const Q=C>>24&255,E=C>>16&255,A=C>>8&255;let N=P>>24&255,R=P>>16&255,W=P>>8&255,H=m(b.relativeLuminance2(N,R,W),b.relativeLuminance2(Q,E,A));for(;H<_&&(N>0||R>0||W>0);)N-=Math.max(0,Math.ceil(.1*N)),R-=Math.max(0,Math.ceil(.1*R)),W-=Math.max(0,Math.ceil(.1*W)),H=m(b.relativeLuminance2(N,R,W),b.relativeLuminance2(Q,E,A));return(N<<24|R<<16|W<<8|255)>>>0}function k(C,P,_){const Q=C>>24&255,E=C>>16&255,A=C>>8&255;let N=P>>24&255,R=P>>16&255,W=P>>8&255,H=m(b.relativeLuminance2(N,R,W),b.relativeLuminance2(Q,E,A));for(;H<_&&(N<255||R<255||W<255);)N=Math.min(255,N+Math.ceil(.1*(255-N))),R=Math.min(255,R+Math.ceil(.1*(255-R))),W=Math.min(255,W+Math.ceil(.1*(255-W))),H=m(b.relativeLuminance2(N,R,W),b.relativeLuminance2(Q,E,A));return(N<<24|R<<16|W<<8|255)>>>0}x.blend=function(C,P){if(d=(255&P)/255,d===1)return P;const _=P>>24&255,Q=P>>16&255,E=P>>8&255,A=C>>24&255,N=C>>16&255,R=C>>8&255;return l=A+Math.round((_-A)*d),h=N+Math.round((Q-N)*d),u=R+Math.round((E-R)*d),f.toRgba(l,h,u)},x.ensureContrastRatio=function(C,P,_){const Q=b.relativeLuminance(C>>8),E=b.relativeLuminance(P>>8);if(m(Q,E)<_){if(E<Q){const R=y(C,P,_),W=m(Q,b.relativeLuminance(R>>8));if(W<_){const H=k(C,P,_);return W>m(Q,b.relativeLuminance(H>>8))?R:H}return R}const A=k(C,P,_),N=m(Q,b.relativeLuminance(A>>8));if(N<_){const R=y(C,P,_);return N>m(Q,b.relativeLuminance(R>>8))?A:R}return A}},x.reduceLuminance=y,x.increaseLuminance=k,x.toChannels=function(C){return[C>>24&255,C>>16&255,C>>8&255,255&C]}})(O||(o.rgba=O={})),o.toPaddedHex=g,o.contrastRatio=m},8969:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreTerminal=void 0;const h=l(844),u=l(2585),d=l(4348),f=l(7866),p=l(744),v=l(7302),b=l(6975),O=l(8460),g=l(1753),m=l(1480),x=l(7994),y=l(9282),k=l(5435),C=l(5981),P=l(2660);let _=!1;class Q extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new O.EventEmitter),this._onScroll.event((A=>{this._onScrollApi?.fire(A.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(A){for(const N in A)this.optionsService.options[N]=A[N]}constructor(A){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new O.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new O.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new O.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new O.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new O.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new O.EventEmitter),this._instantiationService=new d.InstantiationService,this.optionsService=this.register(new v.OptionsService(A)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(p.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(f.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(g.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(m.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(x.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(P.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new k.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,O.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,O.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,O.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,O.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((N=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((N=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new C.WriteBuffer(((N,R)=>this._inputHandler.parse(N,R)))),this.register((0,O.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(A,N){this._writeBuffer.write(A,N)}writeSync(A,N){this._logService.logLevel<=u.LogLevelEnum.WARN&&!_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_=!0),this._writeBuffer.writeSync(A,N)}input(A,N=!0){this.coreService.triggerDataEvent(A,N)}resize(A,N){isNaN(A)||isNaN(N)||(A=Math.max(A,p.MINIMUM_COLS),N=Math.max(N,p.MINIMUM_ROWS),this._bufferService.resize(A,N))}scroll(A,N=!1){this._bufferService.scroll(A,N)}scrollLines(A,N,R){this._bufferService.scrollLines(A,N,R)}scrollPages(A){this.scrollLines(A*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(A){const N=A-this._bufferService.buffer.ydisp;N!==0&&this.scrollLines(N)}registerEscHandler(A,N){return this._inputHandler.registerEscHandler(A,N)}registerDcsHandler(A,N){return this._inputHandler.registerDcsHandler(A,N)}registerCsiHandler(A,N){return this._inputHandler.registerCsiHandler(A,N)}registerOscHandler(A,N){return this._inputHandler.registerOscHandler(A,N)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let A=!1;const N=this.optionsService.rawOptions.windowsPty;N&&N.buildNumber!==void 0&&N.buildNumber!==void 0?A=N.backend==="conpty"&&N.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(A=!0),A?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const A=[];A.push(this.onLineFeed(y.updateWindowsModeWrappedState.bind(null,this._bufferService))),A.push(this.registerCsiHandler({final:"H"},(()=>((0,y.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const N of A)N.dispose()}))}}}o.CoreTerminal=Q},8460:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===l)return void this._listeners.splice(h,1)}}})),this._event}fire(l,h){const u=[];for(let d=0;d<this._listeners.length;d++)u.push(this._listeners[d]);for(let d=0;d<u.length;d++)u[d].call(void 0,l,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(l,h){return l((u=>h.fire(u)))},o.runAndSubscribe=function(l,h){return h(void 0),l((u=>h(u)))}},5435:function(a,o,l){var h=this&&this.__decorate||function(K,$,I,X){var q,ie=arguments.length,pe=ie<3?$:X===null?X=Object.getOwnPropertyDescriptor($,I):X;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")pe=Reflect.decorate(K,$,I,X);else for(var $e=K.length-1;$e>=0;$e--)(q=K[$e])&&(pe=(ie<3?q(pe):ie>3?q($,I,pe):q($,I))||pe);return ie>3&&pe&&Object.defineProperty($,I,pe),pe},u=this&&this.__param||function(K,$){return function(I,X){$(I,X,K)}};Object.defineProperty(o,"__esModule",{value:!0}),o.InputHandler=o.WindowsOptionsReportType=void 0;const d=l(2584),f=l(7116),p=l(2015),v=l(844),b=l(482),O=l(8437),g=l(8460),m=l(643),x=l(511),y=l(3734),k=l(2585),C=l(1480),P=l(6242),_=l(6351),Q=l(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function N(K,$){if(K>24)return $.setWinLines||!1;switch(K){case 1:return!!$.restoreWin;case 2:return!!$.minimizeWin;case 3:return!!$.setWinPosition;case 4:return!!$.setWinSizePixels;case 5:return!!$.raiseWin;case 6:return!!$.lowerWin;case 7:return!!$.refreshWin;case 8:return!!$.setWinSizeChars;case 9:return!!$.maximizeWin;case 10:return!!$.fullscreenWin;case 11:return!!$.getWinState;case 13:return!!$.getWinPosition;case 14:return!!$.getWinSizePixels;case 15:return!!$.getScreenSizePixels;case 16:return!!$.getCellSizePixels;case 18:return!!$.getWinSizeChars;case 19:return!!$.getScreenSizeChars;case 20:return!!$.getIconTitle;case 21:return!!$.getWinTitle;case 22:return!!$.pushTitle;case 23:return!!$.popTitle;case 24:return!!$.setWinLines}return!1}var R;(function(K){K[K.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",K[K.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(o.WindowsOptionsReportType=R={}));let W=0;class H extends v.Disposable{getAttrData(){return this._curAttrData}constructor($,I,X,q,ie,pe,$e,re,U=new p.EscapeSequenceParser){super(),this._bufferService=$,this._charsetService=I,this._coreService=X,this._logService=q,this._optionsService=ie,this._oscLinkService=pe,this._coreMouseService=$e,this._unicodeService=re,this._parser=U,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new x.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=O.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=O.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new g.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new g.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new g.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new g.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new g.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new g.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new g.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new g.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new g.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new g.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new g.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new g.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new g.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 Z(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((M=>this._activeBuffer=M.activeBuffer))),this._parser.setCsiHandlerFallback(((M,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(M),params:te.toArray()})})),this._parser.setEscHandlerFallback((M=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(M)})})),this._parser.setExecuteHandlerFallback((M=>{this._logService.debug("Unknown EXECUTE code: ",{code:M})})),this._parser.setOscHandlerFallback(((M,te,Y)=>{this._logService.debug("Unknown OSC code: ",{identifier:M,action:te,data:Y})})),this._parser.setDcsHandlerFallback(((M,te,Y)=>{te==="HOOK"&&(Y=Y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(M),action:te,payload:Y})})),this._parser.setPrintHandler(((M,te,Y)=>this.print(M,te,Y))),this._parser.registerCsiHandler({final:"@"},(M=>this.insertChars(M))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(M=>this.scrollLeft(M))),this._parser.registerCsiHandler({final:"A"},(M=>this.cursorUp(M))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(M=>this.scrollRight(M))),this._parser.registerCsiHandler({final:"B"},(M=>this.cursorDown(M))),this._parser.registerCsiHandler({final:"C"},(M=>this.cursorForward(M))),this._parser.registerCsiHandler({final:"D"},(M=>this.cursorBackward(M))),this._parser.registerCsiHandler({final:"E"},(M=>this.cursorNextLine(M))),this._parser.registerCsiHandler({final:"F"},(M=>this.cursorPrecedingLine(M))),this._parser.registerCsiHandler({final:"G"},(M=>this.cursorCharAbsolute(M))),this._parser.registerCsiHandler({final:"H"},(M=>this.cursorPosition(M))),this._parser.registerCsiHandler({final:"I"},(M=>this.cursorForwardTab(M))),this._parser.registerCsiHandler({final:"J"},(M=>this.eraseInDisplay(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(M=>this.eraseInDisplay(M,!0))),this._parser.registerCsiHandler({final:"K"},(M=>this.eraseInLine(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(M=>this.eraseInLine(M,!0))),this._parser.registerCsiHandler({final:"L"},(M=>this.insertLines(M))),this._parser.registerCsiHandler({final:"M"},(M=>this.deleteLines(M))),this._parser.registerCsiHandler({final:"P"},(M=>this.deleteChars(M))),this._parser.registerCsiHandler({final:"S"},(M=>this.scrollUp(M))),this._parser.registerCsiHandler({final:"T"},(M=>this.scrollDown(M))),this._parser.registerCsiHandler({final:"X"},(M=>this.eraseChars(M))),this._parser.registerCsiHandler({final:"Z"},(M=>this.cursorBackwardTab(M))),this._parser.registerCsiHandler({final:"`"},(M=>this.charPosAbsolute(M))),this._parser.registerCsiHandler({final:"a"},(M=>this.hPositionRelative(M))),this._parser.registerCsiHandler({final:"b"},(M=>this.repeatPrecedingCharacter(M))),this._parser.registerCsiHandler({final:"c"},(M=>this.sendDeviceAttributesPrimary(M))),this._parser.registerCsiHandler({prefix:">",final:"c"},(M=>this.sendDeviceAttributesSecondary(M))),this._parser.registerCsiHandler({final:"d"},(M=>this.linePosAbsolute(M))),this._parser.registerCsiHandler({final:"e"},(M=>this.vPositionRelative(M))),this._parser.registerCsiHandler({final:"f"},(M=>this.hVPosition(M))),this._parser.registerCsiHandler({final:"g"},(M=>this.tabClear(M))),this._parser.registerCsiHandler({final:"h"},(M=>this.setMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(M=>this.setModePrivate(M))),this._parser.registerCsiHandler({final:"l"},(M=>this.resetMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(M=>this.resetModePrivate(M))),this._parser.registerCsiHandler({final:"m"},(M=>this.charAttributes(M))),this._parser.registerCsiHandler({final:"n"},(M=>this.deviceStatus(M))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(M=>this.deviceStatusPrivate(M))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(M=>this.softReset(M))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(M=>this.setCursorStyle(M))),this._parser.registerCsiHandler({final:"r"},(M=>this.setScrollRegion(M))),this._parser.registerCsiHandler({final:"s"},(M=>this.saveCursor(M))),this._parser.registerCsiHandler({final:"t"},(M=>this.windowOptions(M))),this._parser.registerCsiHandler({final:"u"},(M=>this.restoreCursor(M))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(M=>this.insertColumns(M))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(M=>this.deleteColumns(M))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(M=>this.selectProtected(M))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(M=>this.requestMode(M,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(M=>this.requestMode(M,!1))),this._parser.setExecuteHandler(d.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(d.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(d.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(d.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(d.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(d.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(d.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(d.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(d.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new P.OscHandler((M=>(this.setTitle(M),this.setIconName(M),!0)))),this._parser.registerOscHandler(1,new P.OscHandler((M=>this.setIconName(M)))),this._parser.registerOscHandler(2,new P.OscHandler((M=>this.setTitle(M)))),this._parser.registerOscHandler(4,new P.OscHandler((M=>this.setOrReportIndexedColor(M)))),this._parser.registerOscHandler(8,new P.OscHandler((M=>this.setHyperlink(M)))),this._parser.registerOscHandler(10,new P.OscHandler((M=>this.setOrReportFgColor(M)))),this._parser.registerOscHandler(11,new P.OscHandler((M=>this.setOrReportBgColor(M)))),this._parser.registerOscHandler(12,new P.OscHandler((M=>this.setOrReportCursorColor(M)))),this._parser.registerOscHandler(104,new P.OscHandler((M=>this.restoreIndexedColor(M)))),this._parser.registerOscHandler(110,new P.OscHandler((M=>this.restoreFgColor(M)))),this._parser.registerOscHandler(111,new P.OscHandler((M=>this.restoreBgColor(M)))),this._parser.registerOscHandler(112,new P.OscHandler((M=>this.restoreCursorColor(M)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const M in f.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:M},(()=>this.selectCharset("("+M))),this._parser.registerEscHandler({intermediates:")",final:M},(()=>this.selectCharset(")"+M))),this._parser.registerEscHandler({intermediates:"*",final:M},(()=>this.selectCharset("*"+M))),this._parser.registerEscHandler({intermediates:"+",final:M},(()=>this.selectCharset("+"+M))),this._parser.registerEscHandler({intermediates:"-",final:M},(()=>this.selectCharset("-"+M))),this._parser.registerEscHandler({intermediates:".",final:M},(()=>this.selectCharset("."+M))),this._parser.registerEscHandler({intermediates:"/",final:M},(()=>this.selectCharset("/"+M)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((M=>(this._logService.error("Parsing error: ",M),M))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new _.DcsHandler(((M,te)=>this.requestStatusString(M,te))))}_preserveStack($,I,X,q){this._parseStack.paused=!0,this._parseStack.cursorStartX=$,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=X,this._parseStack.position=q}_logSlowResolvingAsync($){this._logService.logLevel<=k.LogLevelEnum.WARN&&Promise.race([$,new Promise(((I,X)=>setTimeout((()=>X("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse($,I){let X,q=this._activeBuffer.x,ie=this._activeBuffer.y,pe=0;const $e=this._parseStack.paused;if($e){if(X=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(X),X;q=this._parseStack.cursorStartX,ie=this._parseStack.cursorStartY,this._parseStack.paused=!1,$.length>A&&(pe=this._parseStack.position+A)}if(this._logService.logLevel<=k.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof $=="string"?` "${$}"`:` "${Array.prototype.map.call($,(M=>String.fromCharCode(M))).join("")}"`),typeof $=="string"?$.split("").map((M=>M.charCodeAt(0))):$),this._parseBuffer.length<$.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min($.length,A))),$e||this._dirtyRowTracker.clearRange(),$.length>A)for(let M=pe;M<$.length;M+=A){const te=M+A<$.length?M+A:$.length,Y=typeof $=="string"?this._stringDecoder.decode($.substring(M,te),this._parseBuffer):this._utf8Decoder.decode($.subarray(M,te),this._parseBuffer);if(X=this._parser.parse(this._parseBuffer,Y))return this._preserveStack(q,ie,Y,M),this._logSlowResolvingAsync(X),X}else if(!$e){const M=typeof $=="string"?this._stringDecoder.decode($,this._parseBuffer):this._utf8Decoder.decode($,this._parseBuffer);if(X=this._parser.parse(this._parseBuffer,M))return this._preserveStack(q,ie,M,0),this._logSlowResolvingAsync(X),X}this._activeBuffer.x===q&&this._activeBuffer.y===ie||this._onCursorMove.fire();const re=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),U=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);U<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(U,this._bufferService.rows-1),Math.min(re,this._bufferService.rows-1))}print($,I,X){let q,ie;const pe=this._charsetService.charset,$e=this._optionsService.rawOptions.screenReaderMode,re=this._bufferService.cols,U=this._coreService.decPrivateModes.wraparound,M=this._coreService.modes.insertMode,te=this._curAttrData;let Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&X-I>0&&Y.getWidth(this._activeBuffer.x-1)===2&&Y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let ae=this._parser.precedingJoinState;for(let ee=I;ee<X;++ee){if(q=$[ee],q<127&&pe){const De=pe[String.fromCharCode(q)];De&&(q=De.charCodeAt(0))}const me=this._unicodeService.charProperties(q,ae);ie=C.UnicodeService.extractWidth(me);const Re=C.UnicodeService.extractShouldJoin(me),_e=Re?C.UnicodeService.extractWidth(ae):0;if(ae=me,$e&&this._onA11yChar.fire((0,b.stringFromCodePoint)(q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+ie-_e>re){if(U){const De=Y;let Te=this._activeBuffer.x-_e;for(this._activeBuffer.x=_e,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),Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),_e>0&&Y instanceof O.BufferLine&&Y.copyCellsFrom(De,Te,0,_e,!1);Te<re;)De.setCellFromCodepoint(Te++,0,1,te)}else if(this._activeBuffer.x=re-1,ie===2)continue}if(Re&&this._activeBuffer.x){const De=Y.getWidth(this._activeBuffer.x-1)?1:2;Y.addCodepointToCell(this._activeBuffer.x-De,q,ie);for(let Te=ie-_e;--Te>=0;)Y.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(M&&(Y.insertCells(this._activeBuffer.x,ie-_e,this._activeBuffer.getNullCell(te)),Y.getWidth(re-1)===2&&Y.setCellFromCodepoint(re-1,m.NULL_CELL_CODE,m.NULL_CELL_WIDTH,te)),Y.setCellFromCodepoint(this._activeBuffer.x++,q,ie,te),ie>0)for(;--ie;)Y.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=ae,this._activeBuffer.x<re&&X-I>0&&Y.getWidth(this._activeBuffer.x)===0&&!Y.hasContent(this._activeBuffer.x)&&Y.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler($,I){return $.final!=="t"||$.prefix||$.intermediates?this._parser.registerCsiHandler($,I):this._parser.registerCsiHandler($,(X=>!N(X.params[0],this._optionsService.rawOptions.windowOptions)||I(X)))}registerDcsHandler($,I){return this._parser.registerDcsHandler($,new _.DcsHandler(I))}registerEscHandler($,I){return this._parser.registerEscHandler($,I)}registerOscHandler($,I){return this._parser.registerOscHandler($,new P.OscHandler(I))}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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);$.hasWidth(this._activeBuffer.x)&&!$.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const $=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-$),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor($=this._bufferService.cols-1){this._activeBuffer.x=Math.min($,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($,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=$,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=$,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor($,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+$,this._activeBuffer.y+I)}cursorUp($){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,$.params[0]||1)):this._moveCursor(0,-($.params[0]||1)),!0}cursorDown($){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,$.params[0]||1)):this._moveCursor(0,$.params[0]||1),!0}cursorForward($){return this._moveCursor($.params[0]||1,0),!0}cursorBackward($){return this._moveCursor(-($.params[0]||1),0),!0}cursorNextLine($){return this.cursorDown($),this._activeBuffer.x=0,!0}cursorPrecedingLine($){return this.cursorUp($),this._activeBuffer.x=0,!0}cursorCharAbsolute($){return this._setCursor(($.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition($){return this._setCursor($.length>=2?($.params[1]||1)-1:0,($.params[0]||1)-1),!0}charPosAbsolute($){return this._setCursor(($.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative($){return this._moveCursor($.params[0]||1,0),!0}linePosAbsolute($){return this._setCursor(this._activeBuffer.x,($.params[0]||1)-1),!0}vPositionRelative($){return this._moveCursor(0,$.params[0]||1),!0}hVPosition($){return this.cursorPosition($),!0}tabClear($){const I=$.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab($){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=$.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab($){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=$.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected($){const I=$.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine($,I,X,q=!1,ie=!1){const pe=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);pe.replaceCells(I,X,this._activeBuffer.getNullCell(this._eraseAttrData()),ie),q&&(pe.isWrapped=!1)}_resetBufferLine($,I=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);X&&(X.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+$),X.isWrapped=!1)}eraseInDisplay($,I=!1){let X;switch(this._restrictCursor(this._bufferService.cols),$.params[0]){case 0:for(X=this._activeBuffer.y,this._dirtyRowTracker.markDirty(X),this._eraseInBufferLine(X++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);X<this._bufferService.rows;X++)this._resetBufferLine(X,I);this._dirtyRowTracker.markDirty(X);break;case 1:for(X=this._activeBuffer.y,this._dirtyRowTracker.markDirty(X),this._eraseInBufferLine(X,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(X+1).isWrapped=!1);X--;)this._resetBufferLine(X,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(X=this._bufferService.rows,this._dirtyRowTracker.markDirty(X-1);X--;)this._resetBufferLine(X,I);this._dirtyRowTracker.markDirty(0);break;case 3:const q=this._activeBuffer.lines.length-this._bufferService.rows;q>0&&(this._activeBuffer.lines.trimStart(q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-q,0),this._onScroll.fire(0))}return!0}eraseInLine($,I=!1){switch(this._restrictCursor(this._bufferService.cols),$.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines($){this._restrictCursor();let I=$.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=this._activeBuffer.ybase+this._activeBuffer.y,q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,ie=this._bufferService.rows-1+this._activeBuffer.ybase-q+1;for(;I--;)this._activeBuffer.lines.splice(ie-1,1),this._activeBuffer.lines.splice(X,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines($){this._restrictCursor();let I=$.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const X=this._activeBuffer.ybase+this._activeBuffer.y;let q;for(q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-q;I--;)this._activeBuffer.lines.splice(X,1),this._activeBuffer.lines.splice(q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars($){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,$.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars($){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,$.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp($){let I=$.params[0]||1;for(;I--;)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($){let I=$.params[0]||1;for(;I--;)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(O.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=$.params[0]||1;for(let X=this._activeBuffer.scrollTop;X<=this._activeBuffer.scrollBottom;++X){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+X);q.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=$.params[0]||1;for(let X=this._activeBuffer.scrollTop;X<=this._activeBuffer.scrollBottom;++X){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+X);q.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=$.params[0]||1;for(let X=this._activeBuffer.scrollTop;X<=this._activeBuffer.scrollBottom;++X){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+X);q.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns($){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=$.params[0]||1;for(let X=this._activeBuffer.scrollTop;X<=this._activeBuffer.scrollBottom;++X){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+X);q.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars($){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+($.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter($){const I=this._parser.precedingJoinState;if(!I)return!0;const X=$.params[0]||1,q=C.UnicodeService.extractWidth(I),ie=this._activeBuffer.x-q,pe=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(ie),$e=new Uint32Array(pe.length*X);let re=0;for(let M=0;M<pe.length;){const te=pe.codePointAt(M)||0;$e[re++]=te,M+=te>65535?2:1}let U=re;for(let M=1;M<X;++M)$e.copyWithin(U,0,re),U+=re;return this.print($e,0,U),!0}sendDeviceAttributesPrimary($){return $.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(d.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(d.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary($){return $.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(d.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(d.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent($.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(d.C0.ESC+"[>83;40003;0c")),!0}_is($){return(this._optionsService.rawOptions.termName+"").indexOf($)===0}setMode($){for(let I=0;I<$.length;I++)switch($.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate($){for(let I=0;I<$.length;I++)switch($.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),this._charsetService.setgCharset(1,f.DEFAULT_CHARSET),this._charsetService.setgCharset(2,f.DEFAULT_CHARSET),this._charsetService.setgCharset(3,f.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($){for(let I=0;I<$.length;I++)switch($.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate($){for(let I=0;I<$.length;I++)switch($.params[I]){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(),$.params[I]===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($,I){const X=this._coreService.decPrivateModes,{activeProtocol:q,activeEncoding:ie}=this._coreMouseService,pe=this._coreService,{buffers:$e,cols:re}=this._bufferService,{active:U,alt:M}=$e,te=this._optionsService.rawOptions,Y=Re=>Re?1:2,ae=$.params[0];return ee=ae,me=I?ae===2?4:ae===4?Y(pe.modes.insertMode):ae===12?3:ae===20?Y(te.convertEol):0:ae===1?Y(X.applicationCursorKeys):ae===3?te.windowOptions.setWinLines?re===80?2:re===132?1:0:0:ae===6?Y(X.origin):ae===7?Y(X.wraparound):ae===8?3:ae===9?Y(q==="X10"):ae===12?Y(te.cursorBlink):ae===25?Y(!pe.isCursorHidden):ae===45?Y(X.reverseWraparound):ae===66?Y(X.applicationKeypad):ae===67?4:ae===1e3?Y(q==="VT200"):ae===1002?Y(q==="DRAG"):ae===1003?Y(q==="ANY"):ae===1004?Y(X.sendFocus):ae===1005?4:ae===1006?Y(ie==="SGR"):ae===1015?4:ae===1016?Y(ie==="SGR_PIXELS"):ae===1048?1:ae===47||ae===1047||ae===1049?Y(U===M):ae===2004?Y(X.bracketedPasteMode):0,pe.triggerDataEvent(`${d.C0.ESC}[${I?"":"?"}${ee};${me}$y`),!0;var ee,me}_updateAttrColor($,I,X,q,ie){return I===2?($|=50331648,$&=-16777216,$|=y.AttributeData.fromColorRGB([X,q,ie])):I===5&&($&=-50331904,$|=33554432|255&X),$}_extractColor($,I,X){const q=[0,0,-1,0,0,0];let ie=0,pe=0;do{if(q[pe+ie]=$.params[I+pe],$.hasSubParams(I+pe)){const $e=$.getSubParams(I+pe);let re=0;do q[1]===5&&(ie=1),q[pe+re+1+ie]=$e[re];while(++re<$e.length&&re+pe+1+ie<q.length);break}if(q[1]===5&&pe+ie>=2||q[1]===2&&pe+ie>=5)break;q[1]&&(ie=1)}while(++pe+I<$.length&&pe+ie<q.length);for(let $e=2;$e<q.length;++$e)q[$e]===-1&&(q[$e]=0);switch(q[0]){case 38:X.fg=this._updateAttrColor(X.fg,q[1],q[3],q[4],q[5]);break;case 48:X.bg=this._updateAttrColor(X.bg,q[1],q[3],q[4],q[5]);break;case 58:X.extended=X.extended.clone(),X.extended.underlineColor=this._updateAttrColor(X.extended.underlineColor,q[1],q[3],q[4],q[5])}return pe}_processUnderline($,I){I.extended=I.extended.clone(),(!~$||$>5)&&($=1),I.extended.underlineStyle=$,I.fg|=268435456,$===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0($){$.fg=O.DEFAULT_ATTR_DATA.fg,$.bg=O.DEFAULT_ATTR_DATA.bg,$.extended=$.extended.clone(),$.extended.underlineStyle=0,$.extended.underlineColor&=-67108864,$.updateExtended()}charAttributes($){if($.length===1&&$.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=$.length;let X;const q=this._curAttrData;for(let ie=0;ie<I;ie++)X=$.params[ie],X>=30&&X<=37?(q.fg&=-50331904,q.fg|=16777216|X-30):X>=40&&X<=47?(q.bg&=-50331904,q.bg|=16777216|X-40):X>=90&&X<=97?(q.fg&=-50331904,q.fg|=16777224|X-90):X>=100&&X<=107?(q.bg&=-50331904,q.bg|=16777224|X-100):X===0?this._processSGR0(q):X===1?q.fg|=134217728:X===3?q.bg|=67108864:X===4?(q.fg|=268435456,this._processUnderline($.hasSubParams(ie)?$.getSubParams(ie)[0]:1,q)):X===5?q.fg|=536870912:X===7?q.fg|=67108864:X===8?q.fg|=1073741824:X===9?q.fg|=2147483648:X===2?q.bg|=134217728:X===21?this._processUnderline(2,q):X===22?(q.fg&=-134217729,q.bg&=-134217729):X===23?q.bg&=-67108865:X===24?(q.fg&=-268435457,this._processUnderline(0,q)):X===25?q.fg&=-536870913:X===27?q.fg&=-67108865:X===28?q.fg&=-1073741825:X===29?q.fg&=2147483647:X===39?(q.fg&=-67108864,q.fg|=16777215&O.DEFAULT_ATTR_DATA.fg):X===49?(q.bg&=-67108864,q.bg|=16777215&O.DEFAULT_ATTR_DATA.bg):X===38||X===48||X===58?ie+=this._extractColor($,ie,q):X===53?q.bg|=1073741824:X===55?q.bg&=-1073741825:X===59?(q.extended=q.extended.clone(),q.extended.underlineColor=-1,q.updateExtended()):X===100?(q.fg&=-67108864,q.fg|=16777215&O.DEFAULT_ATTR_DATA.fg,q.bg&=-67108864,q.bg|=16777215&O.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",X);return!0}deviceStatus($){switch($.params[0]){case 5:this._coreService.triggerDataEvent(`${d.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,X=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[${I};${X}R`)}return!0}deviceStatusPrivate($){if($.params[0]===6){const I=this._activeBuffer.y+1,X=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[?${I};${X}R`)}return!0}softReset($){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=O.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($){const I=$.params[0]||1;switch(I){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 X=I%2==1;return this._optionsService.options.cursorBlink=X,!0}setScrollRegion($){const I=$.params[0]||1;let X;return($.length<2||(X=$.params[1])>this._bufferService.rows||X===0)&&(X=this._bufferService.rows),X>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=X-1,this._setCursor(0,0)),!0}windowOptions($){if(!N($.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=$.length>1?$.params[1]:0;switch($.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${d.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor($){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($){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($){return this._windowTitle=$,this._onTitleChange.fire($),!0}setIconName($){return this._iconName=$,!0}setOrReportIndexedColor($){const I=[],X=$.split(";");for(;X.length>1;){const q=X.shift(),ie=X.shift();if(/^\d+$/.exec(q)){const pe=parseInt(q);if(B(pe))if(ie==="?")I.push({type:0,index:pe});else{const $e=(0,Q.parseColor)(ie);$e&&I.push({type:1,index:pe,color:$e})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink($){const I=$.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink($,I){this._getCurrentLinkId()&&this._finishHyperlink();const X=$.split(":");let q;const ie=X.findIndex((pe=>pe.startsWith("id=")));return ie!==-1&&(q=X[ie].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:q,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor($,I){const X=$.split(";");for(let q=0;q<X.length&&!(I>=this._specialColors.length);++q,++I)if(X[q]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const ie=(0,Q.parseColor)(X[q]);ie&&this._onColor.fire([{type:1,index:this._specialColors[I],color:ie}])}return!0}setOrReportFgColor($){return this._setOrReportSpecialColor($,0)}setOrReportBgColor($){return this._setOrReportSpecialColor($,1)}setOrReportCursorColor($){return this._setOrReportSpecialColor($,2)}restoreIndexedColor($){if(!$)return this._onColor.fire([{type:2}]),!0;const I=[],X=$.split(";");for(let q=0;q<X.length;++q)if(/^\d+$/.exec(X[q])){const ie=parseInt(X[q]);B(ie)&&I.push({type:2,index:ie})}return I.length&&this._onColor.fire(I),!0}restoreFgColor($){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor($){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor($){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,f.DEFAULT_CHARSET),!0}selectCharset($){return $.length!==2?(this.selectDefaultCharset(),!0):($[0]==="/"||this._charsetService.setgCharset(E[$[0]],f.CHARSETS[$[1]]||f.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 $=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,$,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=O.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=O.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel($){return this._charsetService.setgLevel($),!0}screenAlignmentPattern(){const $=new x.CellData;$.content=4194373,$.fg=this._curAttrData.fg,$.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const X=this._activeBuffer.ybase+this._activeBuffer.y+I,q=this._activeBuffer.lines.get(X);q&&(q.fill($),q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString($,I){const X=this._bufferService.buffer,q=this._optionsService.rawOptions;return(ie=>(this._coreService.triggerDataEvent(`${d.C0.ESC}${ie}${d.C0.ESC}\\`),!0))($==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:$==='"p'?'P1$r61;1"p':$==="r"?`P1$r${X.scrollTop+1};${X.scrollBottom+1}r`:$==="m"?"P1$r0m":$===" q"?`P1$r${{block:2,underline:4,bar:6}[q.cursorStyle]-(q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty($,I){this._dirtyRowTracker.markRangeDirty($,I)}}o.InputHandler=H;let Z=class{constructor(K){this._bufferService=K,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(K){K<this.start?this.start=K:K>this.end&&(this.end=K)}markRangeDirty(K,$){K>$&&(W=K,K=$,$=W),K<this.start&&(this.start=K),$>this.end&&(this.end=$)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function B(K){return 0<=K&&K<256}Z=h([u(0,k.IBufferService)],Z)},844:(a,o)=>{function l(h){for(const u of h)u.dispose();h.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const u=this._disposables.indexOf(h);u!==-1&&this._disposables.splice(u,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){this._isDisposed||h===this._value||(this._value?.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},o.toDisposable=function(h){return{dispose:h}},o.disposeArray=l,o.getDisposeArrayDisposable=function(h){return{dispose:()=>l(h)}}},1505:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.FourKeyMap=o.TwoKeyMap=void 0;class l{constructor(){this._data={}}set(u,d,f){this._data[u]||(this._data[u]={}),this._data[u][d]=f}get(u,d){return this._data[u]?this._data[u][d]:void 0}clear(){this._data={}}}o.TwoKeyMap=l,o.FourKeyMap=class{constructor(){this._data=new l}set(h,u,d,f,p){this._data.get(h,u)||this._data.set(h,u,new l),this._data.get(h,u).set(d,f,p)}get(h,u,d,f){return this._data.get(h,u)?.get(d,f)}clear(){this._data.clear()}}},6114:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.isChromeOS=o.isLinux=o.isWindows=o.isIphone=o.isIpad=o.isMac=o.getSafariVersion=o.isSafari=o.isLegacyEdge=o.isFirefox=o.isNode=void 0,o.isNode=typeof process<"u"&&"title"in process;const l=o.isNode?"node":navigator.userAgent,h=o.isNode?"node":navigator.platform;o.isFirefox=l.includes("Firefox"),o.isLegacyEdge=l.includes("Edge"),o.isSafari=/^((?!chrome|android).)*safari/i.test(l),o.getSafariVersion=function(){if(!o.isSafari)return 0;const u=l.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},o.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),o.isIpad=h==="iPad",o.isIphone=h==="iPhone",o.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),o.isLinux=h.indexOf("Linux")>=0,o.isChromeOS=/\bCrOS\b/.test(l)},6106:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SortedList=void 0;let l=0;o.SortedList=class{constructor(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(l=this._search(this._getKey(h)),this._array.splice(l,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;const u=this._getKey(h);if(u===void 0||(l=this._search(u),l===-1)||this._getKey(this._array[l])!==u)return!1;do if(this._array[l]===h)return this._array.splice(l,1),!0;while(++l<this._array.length&&this._getKey(this._array[l])===u);return!1}*getKeyIterator(h){if(this._array.length!==0&&(l=this._search(h),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===h))do yield this._array[l];while(++l<this._array.length&&this._getKey(this._array[l])===h)}forEachByKey(h,u){if(this._array.length!==0&&(l=this._search(h),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===h))do u(this._array[l]);while(++l<this._array.length&&this._getKey(this._array[l])===h)}values(){return[...this._array].values()}_search(h){let u=0,d=this._array.length-1;for(;d>=u;){let f=u+d>>1;const p=this._getKey(this._array[f]);if(p>h)d=f-1;else{if(!(p<h)){for(;f>0&&this._getKey(this._array[f-1])===h;)f--;return f}u=f+1}}return u}}},7226:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DebouncedIdleTask=o.IdleTaskQueue=o.PriorityTaskQueue=void 0;const h=l(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(p){this._tasks.push(p),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(p){this._idleCallback=void 0;let v=0,b=0,O=p.timeRemaining(),g=0;for(;this._i<this._tasks.length;){if(v=Date.now(),this._tasks[this._i]()||this._i++,v=Math.max(1,Date.now()-v),b=Math.max(v,b),g=p.timeRemaining(),1.5*b>g)return O-v<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(O-v))}ms`),void this._start();O=g}this.clear()}}class d extends u{_requestCallback(p){return setTimeout((()=>p(this._createDeadline(16))))}_cancelCallback(p){clearTimeout(p)}_createDeadline(p){const v=Date.now()+p;return{timeRemaining:()=>Math.max(0,v-Date.now())}}}o.PriorityTaskQueue=d,o.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(f){return requestIdleCallback(f)}_cancelCallback(f){cancelIdleCallback(f)}}:d,o.DebouncedIdleTask=class{constructor(){this._queue=new o.IdleTaskQueue}set(f){this._queue.clear(),this._queue.enqueue(f)}flush(){this._queue.flush()}}},9282:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.updateWindowsModeWrappedState=void 0;const h=l(643);o.updateWindowsModeWrappedState=function(u){const d=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),f=d?.get(u.cols-1),p=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);p&&f&&(p.isWrapped=f[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&f[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ExtendedAttrs=o.AttributeData=void 0;class l{constructor(){this.fg=0,this.bg=0,this.extended=new h}static toColorRGB(d){return[d>>>16&255,d>>>8&255,255&d]}static fromColorRGB(d){return(255&d[0])<<16|(255&d[1])<<8|255&d[2]}clone(){const d=new l;return d.fg=this.fg,d.bg=this.bg,d.extended=this.extended.clone(),d}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}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}o.AttributeData=l;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(d){this._ext=d}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(d){this._ext&=-469762049,this._ext|=d<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(d){this._ext&=-67108864,this._ext|=67108863&d}get urlId(){return this._urlId}set urlId(d){this._urlId=d}get underlineVariantOffset(){const d=(3758096384&this._ext)>>29;return d<0?4294967288^d:d}set underlineVariantOffset(d){this._ext&=536870911,this._ext|=d<<29&3758096384}constructor(d=0,f=0){this._ext=0,this._urlId=0,this._ext=d,this._urlId=f}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}o.ExtendedAttrs=h},9092:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Buffer=o.MAX_BUFFER_SIZE=void 0;const h=l(6349),u=l(7226),d=l(3734),f=l(8437),p=l(4634),v=l(511),b=l(643),O=l(4863),g=l(7116);o.MAX_BUFFER_SIZE=4294967295,o.Buffer=class{constructor(m,x,y){this._hasScrollback=m,this._optionsService=x,this._bufferService=y,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=f.DEFAULT_ATTR_DATA.clone(),this.savedCharset=g.DEFAULT_CHARSET,this.markers=[],this._nullCell=v.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=v.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.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 h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(m){return m?(this._nullCell.fg=m.fg,this._nullCell.bg=m.bg,this._nullCell.extended=m.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new d.ExtendedAttrs),this._nullCell}getWhitespaceCell(m){return m?(this._whitespaceCell.fg=m.fg,this._whitespaceCell.bg=m.bg,this._whitespaceCell.extended=m.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new d.ExtendedAttrs),this._whitespaceCell}getBlankLine(m,x){return new f.BufferLine(this._bufferService.cols,this.getNullCell(m),x)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const m=this.ybase+this.y-this.ydisp;return m>=0&&m<this._rows}_getCorrectBufferLength(m){if(!this._hasScrollback)return m;const x=m+this._optionsService.rawOptions.scrollback;return x>o.MAX_BUFFER_SIZE?o.MAX_BUFFER_SIZE:x}fillViewportRows(m){if(this.lines.length===0){m===void 0&&(m=f.DEFAULT_ATTR_DATA);let x=this._rows;for(;x--;)this.lines.push(this.getBlankLine(m))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(m,x){const y=this.getNullCell(f.DEFAULT_ATTR_DATA);let k=0;const C=this._getCorrectBufferLength(x);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<m)for(let _=0;_<this.lines.length;_++)k+=+this.lines.get(_).resize(m,y);let P=0;if(this._rows<x)for(let _=this._rows;_<x;_++)this.lines.length<x+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new f.BufferLine(m,y)):this.ybase>0&&this.lines.length<=this.ybase+this.y+P+1?(this.ybase--,P++,this.ydisp>0&&this.ydisp--):this.lines.push(new f.BufferLine(m,y)));else for(let _=this._rows;_>x;_--)this.lines.length>x+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){const _=this.lines.length-C;_>0&&(this.lines.trimStart(_),this.ybase=Math.max(this.ybase-_,0),this.ydisp=Math.max(this.ydisp-_,0),this.savedY=Math.max(this.savedY-_,0)),this.lines.maxLength=C}this.x=Math.min(this.x,m-1),this.y=Math.min(this.y,x-1),P&&(this.y+=P),this.savedX=Math.min(this.savedX,m-1),this.scrollTop=0}if(this.scrollBottom=x-1,this._isReflowEnabled&&(this._reflow(m,x),this._cols>m))for(let P=0;P<this.lines.length;P++)k+=+this.lines.get(P).resize(m,y);this._cols=m,this._rows=x,this._memoryCleanupQueue.clear(),k>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let m=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,m=!1);let x=0;for(;this._memoryCleanupPosition<this.lines.length;)if(x+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),x>100)return!0;return m}get _isReflowEnabled(){const m=this._optionsService.rawOptions.windowsPty;return m&&m.buildNumber?this._hasScrollback&&m.backend==="conpty"&&m.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(m,x){this._cols!==m&&(m>this._cols?this._reflowLarger(m,x):this._reflowSmaller(m,x))}_reflowLarger(m,x){const y=(0,p.reflowLargerGetLinesToRemove)(this.lines,this._cols,m,this.ybase+this.y,this.getNullCell(f.DEFAULT_ATTR_DATA));if(y.length>0){const k=(0,p.reflowLargerCreateNewLayout)(this.lines,y);(0,p.reflowLargerApplyNewLayout)(this.lines,k.layout),this._reflowLargerAdjustViewport(m,x,k.countRemoved)}}_reflowLargerAdjustViewport(m,x,y){const k=this.getNullCell(f.DEFAULT_ATTR_DATA);let C=y;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<x&&this.lines.push(new f.BufferLine(m,k))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-y,0)}_reflowSmaller(m,x){const y=this.getNullCell(f.DEFAULT_ATTR_DATA),k=[];let C=0;for(let P=this.lines.length-1;P>=0;P--){let _=this.lines.get(P);if(!_||!_.isWrapped&&_.getTrimmedLength()<=m)continue;const Q=[_];for(;_.isWrapped&&P>0;)_=this.lines.get(--P),Q.unshift(_);const E=this.ybase+this.y;if(E>=P&&E<P+Q.length)continue;const A=Q[Q.length-1].getTrimmedLength(),N=(0,p.reflowSmallerGetNewLineLengths)(Q,this._cols,m),R=N.length-Q.length;let W;W=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+R):Math.max(0,this.lines.length-this.lines.maxLength+R);const H=[];for(let X=0;X<R;X++){const q=this.getBlankLine(f.DEFAULT_ATTR_DATA,!0);H.push(q)}H.length>0&&(k.push({start:P+Q.length+C,newLines:H}),C+=H.length),Q.push(...H);let Z=N.length-1,B=N[Z];B===0&&(Z--,B=N[Z]);let K=Q.length-R-1,$=A;for(;K>=0;){const X=Math.min($,B);if(Q[Z]===void 0)break;if(Q[Z].copyCellsFrom(Q[K],$-X,B-X,X,!0),B-=X,B===0&&(Z--,B=N[Z]),$-=X,$===0){K--;const q=Math.max(K,0);$=(0,p.getWrappedLineTrimmedLength)(Q,q,this._cols)}}for(let X=0;X<Q.length;X++)N[X]<m&&Q[X].setCell(N[X],y);let I=R-W;for(;I-- >0;)this.ybase===0?this.y<x-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+C)-x&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+R,this.ybase+x-1)}if(k.length>0){const P=[],_=[];for(let Z=0;Z<this.lines.length;Z++)_.push(this.lines.get(Z));const Q=this.lines.length;let E=Q-1,A=0,N=k[A];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+C);let R=0;for(let Z=Math.min(this.lines.maxLength-1,Q+C-1);Z>=0;Z--)if(N&&N.start>E+R){for(let B=N.newLines.length-1;B>=0;B--)this.lines.set(Z--,N.newLines[B]);Z++,P.push({index:E+1,amount:N.newLines.length}),R+=N.newLines.length,N=k[++A]}else this.lines.set(Z,_[E--]);let W=0;for(let Z=P.length-1;Z>=0;Z--)P[Z].index+=W,this.lines.onInsertEmitter.fire(P[Z]),W+=P[Z].amount;const H=Math.max(0,Q+C-this.lines.maxLength);H>0&&this.lines.onTrimEmitter.fire(H)}}translateBufferLineToString(m,x,y=0,k){const C=this.lines.get(m);return C?C.translateToString(x,y,k):""}getWrappedRangeForLine(m){let x=m,y=m;for(;x>0&&this.lines.get(x).isWrapped;)x--;for(;y+1<this.lines.length&&this.lines.get(y+1).isWrapped;)y++;return{first:x,last:y}}setupTabStops(m){for(m!=null?this.tabs[m]||(m=this.prevStop(m)):(this.tabs={},m=0);m<this._cols;m+=this._optionsService.rawOptions.tabStopWidth)this.tabs[m]=!0}prevStop(m){for(m==null&&(m=this.x);!this.tabs[--m]&&m>0;);return m>=this._cols?this._cols-1:m<0?0:m}nextStop(m){for(m==null&&(m=this.x);!this.tabs[++m]&&m<this._cols;);return m>=this._cols?this._cols-1:m<0?0:m}clearMarkers(m){this._isClearing=!0;for(let x=0;x<this.markers.length;x++)this.markers[x].line===m&&(this.markers[x].dispose(),this.markers.splice(x--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let m=0;m<this.markers.length;m++)this.markers[m].dispose(),this.markers.splice(m--,1);this._isClearing=!1}addMarker(m){const x=new O.Marker(m);return this.markers.push(x),x.register(this.lines.onTrim((y=>{x.line-=y,x.line<0&&x.dispose()}))),x.register(this.lines.onInsert((y=>{x.line>=y.index&&(x.line+=y.amount)}))),x.register(this.lines.onDelete((y=>{x.line>=y.index&&x.line<y.index+y.amount&&x.dispose(),x.line>y.index&&(x.line-=y.amount)}))),x.register(x.onDispose((()=>this._removeMarker(x)))),x}_removeMarker(m){this._isClearing||this.markers.splice(this.markers.indexOf(m),1)}}},8437:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLine=o.DEFAULT_ATTR_DATA=void 0;const h=l(3734),u=l(511),d=l(643),f=l(482);o.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let p=0;class v{constructor(O,g,m=!1){this.isWrapped=m,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*O);const x=g||u.CellData.fromCharData([0,d.NULL_CELL_CHAR,d.NULL_CELL_WIDTH,d.NULL_CELL_CODE]);for(let y=0;y<O;++y)this.setCell(y,x);this.length=O}get(O){const g=this._data[3*O+0],m=2097151&g;return[this._data[3*O+1],2097152&g?this._combined[O]:m?(0,f.stringFromCodePoint)(m):"",g>>22,2097152&g?this._combined[O].charCodeAt(this._combined[O].length-1):m]}set(O,g){this._data[3*O+1]=g[d.CHAR_DATA_ATTR_INDEX],g[d.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[O]=g[1],this._data[3*O+0]=2097152|O|g[d.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*O+0]=g[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|g[d.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(O){return this._data[3*O+0]>>22}hasWidth(O){return 12582912&this._data[3*O+0]}getFg(O){return this._data[3*O+1]}getBg(O){return this._data[3*O+2]}hasContent(O){return 4194303&this._data[3*O+0]}getCodePoint(O){const g=this._data[3*O+0];return 2097152&g?this._combined[O].charCodeAt(this._combined[O].length-1):2097151&g}isCombined(O){return 2097152&this._data[3*O+0]}getString(O){const g=this._data[3*O+0];return 2097152&g?this._combined[O]:2097151&g?(0,f.stringFromCodePoint)(2097151&g):""}isProtected(O){return 536870912&this._data[3*O+2]}loadCell(O,g){return p=3*O,g.content=this._data[p+0],g.fg=this._data[p+1],g.bg=this._data[p+2],2097152&g.content&&(g.combinedData=this._combined[O]),268435456&g.bg&&(g.extended=this._extendedAttrs[O]),g}setCell(O,g){2097152&g.content&&(this._combined[O]=g.combinedData),268435456&g.bg&&(this._extendedAttrs[O]=g.extended),this._data[3*O+0]=g.content,this._data[3*O+1]=g.fg,this._data[3*O+2]=g.bg}setCellFromCodepoint(O,g,m,x){268435456&x.bg&&(this._extendedAttrs[O]=x.extended),this._data[3*O+0]=g|m<<22,this._data[3*O+1]=x.fg,this._data[3*O+2]=x.bg}addCodepointToCell(O,g,m){let x=this._data[3*O+0];2097152&x?this._combined[O]+=(0,f.stringFromCodePoint)(g):2097151&x?(this._combined[O]=(0,f.stringFromCodePoint)(2097151&x)+(0,f.stringFromCodePoint)(g),x&=-2097152,x|=2097152):x=g|4194304,m&&(x&=-12582913,x|=m<<22),this._data[3*O+0]=x}insertCells(O,g,m){if((O%=this.length)&&this.getWidth(O-1)===2&&this.setCellFromCodepoint(O-1,0,1,m),g<this.length-O){const x=new u.CellData;for(let y=this.length-O-g-1;y>=0;--y)this.setCell(O+g+y,this.loadCell(O+y,x));for(let y=0;y<g;++y)this.setCell(O+y,m)}else for(let x=O;x<this.length;++x)this.setCell(x,m);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,m)}deleteCells(O,g,m){if(O%=this.length,g<this.length-O){const x=new u.CellData;for(let y=0;y<this.length-O-g;++y)this.setCell(O+y,this.loadCell(O+g+y,x));for(let y=this.length-g;y<this.length;++y)this.setCell(y,m)}else for(let x=O;x<this.length;++x)this.setCell(x,m);O&&this.getWidth(O-1)===2&&this.setCellFromCodepoint(O-1,0,1,m),this.getWidth(O)!==0||this.hasContent(O)||this.setCellFromCodepoint(O,0,1,m)}replaceCells(O,g,m,x=!1){if(x)for(O&&this.getWidth(O-1)===2&&!this.isProtected(O-1)&&this.setCellFromCodepoint(O-1,0,1,m),g<this.length&&this.getWidth(g-1)===2&&!this.isProtected(g)&&this.setCellFromCodepoint(g,0,1,m);O<g&&O<this.length;)this.isProtected(O)||this.setCell(O,m),O++;else for(O&&this.getWidth(O-1)===2&&this.setCellFromCodepoint(O-1,0,1,m),g<this.length&&this.getWidth(g-1)===2&&this.setCellFromCodepoint(g,0,1,m);O<g&&O<this.length;)this.setCell(O++,m)}resize(O,g){if(O===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const m=3*O;if(O>this.length){if(this._data.buffer.byteLength>=4*m)this._data=new Uint32Array(this._data.buffer,0,m);else{const x=new Uint32Array(m);x.set(this._data),this._data=x}for(let x=this.length;x<O;++x)this.setCell(x,g)}else{this._data=this._data.subarray(0,m);const x=Object.keys(this._combined);for(let k=0;k<x.length;k++){const C=parseInt(x[k],10);C>=O&&delete this._combined[C]}const y=Object.keys(this._extendedAttrs);for(let k=0;k<y.length;k++){const C=parseInt(y[k],10);C>=O&&delete this._extendedAttrs[C]}}return this.length=O,4*m*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const O=new Uint32Array(this._data.length);return O.set(this._data),this._data=O,1}return 0}fill(O,g=!1){if(g)for(let m=0;m<this.length;++m)this.isProtected(m)||this.setCell(m,O);else{this._combined={},this._extendedAttrs={};for(let m=0;m<this.length;++m)this.setCell(m,O)}}copyFrom(O){this.length!==O.length?this._data=new Uint32Array(O._data):this._data.set(O._data),this.length=O.length,this._combined={};for(const g in O._combined)this._combined[g]=O._combined[g];this._extendedAttrs={};for(const g in O._extendedAttrs)this._extendedAttrs[g]=O._extendedAttrs[g];this.isWrapped=O.isWrapped}clone(){const O=new v(0);O._data=new Uint32Array(this._data),O.length=this.length;for(const g in this._combined)O._combined[g]=this._combined[g];for(const g in this._extendedAttrs)O._extendedAttrs[g]=this._extendedAttrs[g];return O.isWrapped=this.isWrapped,O}getTrimmedLength(){for(let O=this.length-1;O>=0;--O)if(4194303&this._data[3*O+0])return O+(this._data[3*O+0]>>22);return 0}getNoBgTrimmedLength(){for(let O=this.length-1;O>=0;--O)if(4194303&this._data[3*O+0]||50331648&this._data[3*O+2])return O+(this._data[3*O+0]>>22);return 0}copyCellsFrom(O,g,m,x,y){const k=O._data;if(y)for(let P=x-1;P>=0;P--){for(let _=0;_<3;_++)this._data[3*(m+P)+_]=k[3*(g+P)+_];268435456&k[3*(g+P)+2]&&(this._extendedAttrs[m+P]=O._extendedAttrs[g+P])}else for(let P=0;P<x;P++){for(let _=0;_<3;_++)this._data[3*(m+P)+_]=k[3*(g+P)+_];268435456&k[3*(g+P)+2]&&(this._extendedAttrs[m+P]=O._extendedAttrs[g+P])}const C=Object.keys(O._combined);for(let P=0;P<C.length;P++){const _=parseInt(C[P],10);_>=g&&(this._combined[_-g+m]=O._combined[_])}}translateToString(O,g,m,x){g=g??0,m=m??this.length,O&&(m=Math.min(m,this.getTrimmedLength())),x&&(x.length=0);let y="";for(;g<m;){const k=this._data[3*g+0],C=2097151&k,P=2097152&k?this._combined[g]:C?(0,f.stringFromCodePoint)(C):d.WHITESPACE_CELL_CHAR;if(y+=P,x)for(let _=0;_<P.length;++_)x.push(g);g+=k>>22||1}return x&&x.push(g),y}}o.BufferLine=v},4841:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.getRangeLength=void 0,o.getRangeLength=function(l,h){if(l.start.y>l.end.y)throw new Error(`Buffer range end (${l.end.x}, ${l.end.y}) cannot be before start (${l.start.x}, ${l.start.y})`);return h*(l.end.y-l.start.y)+(l.end.x-l.start.x+1)}},4634:(a,o)=>{function l(h,u,d){if(u===h.length-1)return h[u].getTrimmedLength();const f=!h[u].hasContent(d-1)&&h[u].getWidth(d-1)===1,p=h[u+1].getWidth(0)===2;return f&&p?d-1:d}Object.defineProperty(o,"__esModule",{value:!0}),o.getWrappedLineTrimmedLength=o.reflowSmallerGetNewLineLengths=o.reflowLargerApplyNewLayout=o.reflowLargerCreateNewLayout=o.reflowLargerGetLinesToRemove=void 0,o.reflowLargerGetLinesToRemove=function(h,u,d,f,p){const v=[];for(let b=0;b<h.length-1;b++){let O=b,g=h.get(++O);if(!g.isWrapped)continue;const m=[h.get(b)];for(;O<h.length&&g.isWrapped;)m.push(g),g=h.get(++O);if(f>=b&&f<O){b+=m.length-1;continue}let x=0,y=l(m,x,u),k=1,C=0;for(;k<m.length;){const _=l(m,k,u),Q=_-C,E=d-y,A=Math.min(Q,E);m[x].copyCellsFrom(m[k],C,y,A,!1),y+=A,y===d&&(x++,y=0),C+=A,C===_&&(k++,C=0),y===0&&x!==0&&m[x-1].getWidth(d-1)===2&&(m[x].copyCellsFrom(m[x-1],d-1,y++,1,!1),m[x-1].setCell(d-1,p))}m[x].replaceCells(y,d,p);let P=0;for(let _=m.length-1;_>0&&(_>x||m[_].getTrimmedLength()===0);_--)P++;P>0&&(v.push(b+m.length-P),v.push(P)),b+=m.length-1}return v},o.reflowLargerCreateNewLayout=function(h,u){const d=[];let f=0,p=u[f],v=0;for(let b=0;b<h.length;b++)if(p===b){const O=u[++f];h.onDeleteEmitter.fire({index:b-v,amount:O}),b+=O-1,v+=O,p=u[++f]}else d.push(b);return{layout:d,countRemoved:v}},o.reflowLargerApplyNewLayout=function(h,u){const d=[];for(let f=0;f<u.length;f++)d.push(h.get(u[f]));for(let f=0;f<d.length;f++)h.set(f,d[f]);h.length=u.length},o.reflowSmallerGetNewLineLengths=function(h,u,d){const f=[],p=h.map(((g,m)=>l(h,m,u))).reduce(((g,m)=>g+m));let v=0,b=0,O=0;for(;O<p;){if(p-O<d){f.push(p-O);break}v+=d;const g=l(h,b,u);v>g&&(v-=g,b++);const m=h[b].getWidth(v-1)===2;m&&v--;const x=m?d-1:d;f.push(x),O+=x}return f},o.getWrappedLineTrimmedLength=l},5295:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferSet=void 0;const h=l(8460),u=l(844),d=l(9092);class f extends u.Disposable{constructor(v,b){super(),this._optionsService=v,this._bufferService=b,this._onBufferActivate=this.register(new h.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 d.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new d.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(v){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(v),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(v,b){this._normal.resize(v,b),this._alt.resize(v,b),this.setupTabStops(v)}setupTabStops(v){this._normal.setupTabStops(v),this._alt.setupTabStops(v)}}o.BufferSet=f},511:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CellData=void 0;const h=l(482),u=l(643),d=l(3734);class f extends d.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new d.ExtendedAttrs,this.combinedData=""}static fromCharData(v){const b=new f;return b.setFromCharData(v),b}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(v){this.fg=v[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(v[u.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(v[u.CHAR_DATA_CHAR_INDEX].length===2){const O=v[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=O&&O<=56319){const g=v[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=g&&g<=57343?this.content=1024*(O-55296)+g-56320+65536|v[u.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=v[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|v[u.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=v[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|v[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.CellData=f},643:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WHITESPACE_CELL_CODE=o.WHITESPACE_CELL_WIDTH=o.WHITESPACE_CELL_CHAR=o.NULL_CELL_CODE=o.NULL_CELL_WIDTH=o.NULL_CELL_CHAR=o.CHAR_DATA_CODE_INDEX=o.CHAR_DATA_WIDTH_INDEX=o.CHAR_DATA_CHAR_INDEX=o.CHAR_DATA_ATTR_INDEX=o.DEFAULT_EXT=o.DEFAULT_ATTR=o.DEFAULT_COLOR=void 0,o.DEFAULT_COLOR=0,o.DEFAULT_ATTR=256|o.DEFAULT_COLOR<<9,o.DEFAULT_EXT=0,o.CHAR_DATA_ATTR_INDEX=0,o.CHAR_DATA_CHAR_INDEX=1,o.CHAR_DATA_WIDTH_INDEX=2,o.CHAR_DATA_CODE_INDEX=3,o.NULL_CELL_CHAR="",o.NULL_CELL_WIDTH=1,o.NULL_CELL_CODE=0,o.WHITESPACE_CELL_CHAR=" ",o.WHITESPACE_CELL_WIDTH=1,o.WHITESPACE_CELL_CODE=32},4863:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Marker=void 0;const h=l(8460),u=l(844);class d{get id(){return this._id}constructor(p){this.line=p,this.isDisposed=!1,this._disposables=[],this._id=d._nextId++,this._onDispose=this.register(new h.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(p){return this._disposables.push(p),p}}o.Marker=d,d._nextId=1},7116:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DEFAULT_CHARSET=o.CHARSETS=void 0,o.CHARSETS={},o.DEFAULT_CHARSET=o.CHARSETS.B,o.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:"≥","{":"π","|":"≠","}":"£","~":"·"},o.CHARSETS.A={"#":"£"},o.CHARSETS.B=void 0,o.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},o.CHARSETS.C=o.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},o.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},o.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},o.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},o.CHARSETS.E=o.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},o.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},o.CHARSETS.H=o.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(a,o)=>{var l,h,u;Object.defineProperty(o,"__esModule",{value:!0}),o.C1_ESCAPED=o.C1=o.C0=void 0,(function(d){d.NUL="\0",d.SOH="",d.STX="",d.ETX="",d.EOT="",d.ENQ="",d.ACK="",d.BEL="\x07",d.BS="\b",d.HT=" ",d.LF=`
52
+ `,d.VT="\v",d.FF="\f",d.CR="\r",d.SO="",d.SI="",d.DLE="",d.DC1="",d.DC2="",d.DC3="",d.DC4="",d.NAK="",d.SYN="",d.ETB="",d.CAN="",d.EM="",d.SUB="",d.ESC="\x1B",d.FS="",d.GS="",d.RS="",d.US="",d.SP=" ",d.DEL=""})(l||(o.C0=l={})),(function(d){d.PAD="€",d.HOP="",d.BPH="‚",d.NBH="ƒ",d.IND="„",d.NEL="…",d.SSA="†",d.ESA="‡",d.HTS="ˆ",d.HTJ="‰",d.VTS="Š",d.PLD="‹",d.PLU="Œ",d.RI="",d.SS2="Ž",d.SS3="",d.DCS="",d.PU1="‘",d.PU2="’",d.STS="“",d.CCH="”",d.MW="•",d.SPA="–",d.EPA="—",d.SOS="˜",d.SGCI="™",d.SCI="š",d.CSI="›",d.ST="œ",d.OSC="",d.PM="ž",d.APC="Ÿ"})(h||(o.C1=h={})),(function(d){d.ST=`${l.ESC}\\`})(u||(o.C1_ESCAPED=u={}))},7399:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const h=l(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:["'",'"']};o.evaluateKeyboardEvent=function(d,f,p,v){const b={type:0,cancel:!1,key:void 0},O=(d.shiftKey?1:0)|(d.altKey?2:0)|(d.ctrlKey?4:0)|(d.metaKey?8:0);switch(d.keyCode){case 0:d.key==="UIKeyInputUpArrow"?b.key=f?h.C0.ESC+"OA":h.C0.ESC+"[A":d.key==="UIKeyInputLeftArrow"?b.key=f?h.C0.ESC+"OD":h.C0.ESC+"[D":d.key==="UIKeyInputRightArrow"?b.key=f?h.C0.ESC+"OC":h.C0.ESC+"[C":d.key==="UIKeyInputDownArrow"&&(b.key=f?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:b.key=d.ctrlKey?"\b":h.C0.DEL,d.altKey&&(b.key=h.C0.ESC+b.key);break;case 9:if(d.shiftKey){b.key=h.C0.ESC+"[Z";break}b.key=h.C0.HT,b.cancel=!0;break;case 13:b.key=d.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,b.cancel=!0;break;case 27:b.key=h.C0.ESC,d.altKey&&(b.key=h.C0.ESC+h.C0.ESC),b.cancel=!0;break;case 37:if(d.metaKey)break;O?(b.key=h.C0.ESC+"[1;"+(O+1)+"D",b.key===h.C0.ESC+"[1;3D"&&(b.key=h.C0.ESC+(p?"b":"[1;5D"))):b.key=f?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(d.metaKey)break;O?(b.key=h.C0.ESC+"[1;"+(O+1)+"C",b.key===h.C0.ESC+"[1;3C"&&(b.key=h.C0.ESC+(p?"f":"[1;5C"))):b.key=f?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(d.metaKey)break;O?(b.key=h.C0.ESC+"[1;"+(O+1)+"A",p||b.key!==h.C0.ESC+"[1;3A"||(b.key=h.C0.ESC+"[1;5A")):b.key=f?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(d.metaKey)break;O?(b.key=h.C0.ESC+"[1;"+(O+1)+"B",p||b.key!==h.C0.ESC+"[1;3B"||(b.key=h.C0.ESC+"[1;5B")):b.key=f?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:d.shiftKey||d.ctrlKey||(b.key=h.C0.ESC+"[2~");break;case 46:b.key=O?h.C0.ESC+"[3;"+(O+1)+"~":h.C0.ESC+"[3~";break;case 36:b.key=O?h.C0.ESC+"[1;"+(O+1)+"H":f?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:b.key=O?h.C0.ESC+"[1;"+(O+1)+"F":f?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:d.shiftKey?b.type=2:d.ctrlKey?b.key=h.C0.ESC+"[5;"+(O+1)+"~":b.key=h.C0.ESC+"[5~";break;case 34:d.shiftKey?b.type=3:d.ctrlKey?b.key=h.C0.ESC+"[6;"+(O+1)+"~":b.key=h.C0.ESC+"[6~";break;case 112:b.key=O?h.C0.ESC+"[1;"+(O+1)+"P":h.C0.ESC+"OP";break;case 113:b.key=O?h.C0.ESC+"[1;"+(O+1)+"Q":h.C0.ESC+"OQ";break;case 114:b.key=O?h.C0.ESC+"[1;"+(O+1)+"R":h.C0.ESC+"OR";break;case 115:b.key=O?h.C0.ESC+"[1;"+(O+1)+"S":h.C0.ESC+"OS";break;case 116:b.key=O?h.C0.ESC+"[15;"+(O+1)+"~":h.C0.ESC+"[15~";break;case 117:b.key=O?h.C0.ESC+"[17;"+(O+1)+"~":h.C0.ESC+"[17~";break;case 118:b.key=O?h.C0.ESC+"[18;"+(O+1)+"~":h.C0.ESC+"[18~";break;case 119:b.key=O?h.C0.ESC+"[19;"+(O+1)+"~":h.C0.ESC+"[19~";break;case 120:b.key=O?h.C0.ESC+"[20;"+(O+1)+"~":h.C0.ESC+"[20~";break;case 121:b.key=O?h.C0.ESC+"[21;"+(O+1)+"~":h.C0.ESC+"[21~";break;case 122:b.key=O?h.C0.ESC+"[23;"+(O+1)+"~":h.C0.ESC+"[23~";break;case 123:b.key=O?h.C0.ESC+"[24;"+(O+1)+"~":h.C0.ESC+"[24~";break;default:if(!d.ctrlKey||d.shiftKey||d.altKey||d.metaKey)if(p&&!v||!d.altKey||d.metaKey)!p||d.altKey||d.ctrlKey||d.shiftKey||!d.metaKey?d.key&&!d.ctrlKey&&!d.altKey&&!d.metaKey&&d.keyCode>=48&&d.key.length===1?b.key=d.key:d.key&&d.ctrlKey&&(d.key==="_"&&(b.key=h.C0.US),d.key==="@"&&(b.key=h.C0.NUL)):d.keyCode===65&&(b.type=1);else{const g=u[d.keyCode],m=g?.[d.shiftKey?1:0];if(m)b.key=h.C0.ESC+m;else if(d.keyCode>=65&&d.keyCode<=90){const x=d.ctrlKey?d.keyCode-64:d.keyCode+32;let y=String.fromCharCode(x);d.shiftKey&&(y=y.toUpperCase()),b.key=h.C0.ESC+y}else if(d.keyCode===32)b.key=h.C0.ESC+(d.ctrlKey?h.C0.NUL:" ");else if(d.key==="Dead"&&d.code.startsWith("Key")){let x=d.code.slice(3,4);d.shiftKey||(x=x.toLowerCase()),b.key=h.C0.ESC+x,b.cancel=!0}}else d.keyCode>=65&&d.keyCode<=90?b.key=String.fromCharCode(d.keyCode-64):d.keyCode===32?b.key=h.C0.NUL:d.keyCode>=51&&d.keyCode<=55?b.key=String.fromCharCode(d.keyCode-51+27):d.keyCode===56?b.key=h.C0.DEL:d.keyCode===219?b.key=h.C0.ESC:d.keyCode===220?b.key=h.C0.FS:d.keyCode===221&&(b.key=h.C0.GS)}return b}},482:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(l){return l>65535?(l-=65536,String.fromCharCode(55296+(l>>10))+String.fromCharCode(l%1024+56320)):String.fromCharCode(l)},o.utf32ToString=function(l,h=0,u=l.length){let d="";for(let f=h;f<u;++f){let p=l[f];p>65535?(p-=65536,d+=String.fromCharCode(55296+(p>>10))+String.fromCharCode(p%1024+56320)):d+=String.fromCharCode(p)}return d},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,h){const u=l.length;if(!u)return 0;let d=0,f=0;if(this._interim){const p=l.charCodeAt(f++);56320<=p&&p<=57343?h[d++]=1024*(this._interim-55296)+p-56320+65536:(h[d++]=this._interim,h[d++]=p),this._interim=0}for(let p=f;p<u;++p){const v=l.charCodeAt(p);if(55296<=v&&v<=56319){if(++p>=u)return this._interim=v,d;const b=l.charCodeAt(p);56320<=b&&b<=57343?h[d++]=1024*(v-55296)+b-56320+65536:(h[d++]=v,h[d++]=b)}else v!==65279&&(h[d++]=v)}return d}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,h){const u=l.length;if(!u)return 0;let d,f,p,v,b=0,O=0,g=0;if(this.interim[0]){let y=!1,k=this.interim[0];k&=(224&k)==192?31:(240&k)==224?15:7;let C,P=0;for(;(C=63&this.interim[++P])&&P<4;)k<<=6,k|=C;const _=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,Q=_-P;for(;g<Q;){if(g>=u)return 0;if(C=l[g++],(192&C)!=128){g--,y=!0;break}this.interim[P++]=C,k<<=6,k|=63&C}y||(_===2?k<128?g--:h[b++]=k:_===3?k<2048||k>=55296&&k<=57343||k===65279||(h[b++]=k):k<65536||k>1114111||(h[b++]=k)),this.interim.fill(0)}const m=u-4;let x=g;for(;x<u;){for(;!(!(x<m)||128&(d=l[x])||128&(f=l[x+1])||128&(p=l[x+2])||128&(v=l[x+3]));)h[b++]=d,h[b++]=f,h[b++]=p,h[b++]=v,x+=4;if(d=l[x++],d<128)h[b++]=d;else if((224&d)==192){if(x>=u)return this.interim[0]=d,b;if(f=l[x++],(192&f)!=128){x--;continue}if(O=(31&d)<<6|63&f,O<128){x--;continue}h[b++]=O}else if((240&d)==224){if(x>=u)return this.interim[0]=d,b;if(f=l[x++],(192&f)!=128){x--;continue}if(x>=u)return this.interim[0]=d,this.interim[1]=f,b;if(p=l[x++],(192&p)!=128){x--;continue}if(O=(15&d)<<12|(63&f)<<6|63&p,O<2048||O>=55296&&O<=57343||O===65279)continue;h[b++]=O}else if((248&d)==240){if(x>=u)return this.interim[0]=d,b;if(f=l[x++],(192&f)!=128){x--;continue}if(x>=u)return this.interim[0]=d,this.interim[1]=f,b;if(p=l[x++],(192&p)!=128){x--;continue}if(x>=u)return this.interim[0]=d,this.interim[1]=f,this.interim[2]=p,b;if(v=l[x++],(192&v)!=128){x--;continue}if(O=(7&d)<<18|(63&f)<<12|(63&p)<<6|63&v,O<65536||O>1114111)continue;h[b++]=O}}return b}}},225:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const h=l(1480),u=[[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]],d=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;o.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let p=0;p<u.length;++p)f.fill(0,u[p][0],u[p][1]+1)}}wcwidth(p){return p<32?0:p<127?1:p<65536?f[p]:(function(v,b){let O,g=0,m=b.length-1;if(v<b[0][0]||v>b[m][1])return!1;for(;m>=g;)if(O=g+m>>1,v>b[O][1])g=O+1;else{if(!(v<b[O][0]))return!0;m=O-1}return!1})(p,d)?0:p>=131072&&p<=196605||p>=196608&&p<=262141?2:1}charProperties(p,v){let b=this.wcwidth(p),O=b===0&&v!==0;if(O){const g=h.UnicodeService.extractWidth(v);g===0?O=!1:g>b&&(b=g)}return h.UnicodeService.createPropertyValue(0,b,O)}}},5981:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const h=l(8460),u=l(844);class d extends u.Disposable{constructor(p){super(),this._action=p,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(p,v){if(v!==void 0&&this._syncCalls>v)return void(this._syncCalls=0);if(this._pendingData+=p.length,this._writeBuffer.push(p),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const O=this._callbacks.shift();O&&O()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(p,v){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+=p.length,this._writeBuffer.push(p),this._callbacks.push(v),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=p.length,this._writeBuffer.push(p),this._callbacks.push(v)}_innerWrite(p=0,v=!0){const b=p||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const O=this._writeBuffer[this._bufferOffset],g=this._action(O,v);if(g){const x=y=>Date.now()-b>=12?setTimeout((()=>this._innerWrite(0,y))):this._innerWrite(b,y);return void g.catch((y=>(queueMicrotask((()=>{throw y})),Promise.resolve(!1)))).then(x)}const m=this._callbacks[this._bufferOffset];if(m&&m(),this._bufferOffset++,this._pendingData-=O.length,Date.now()-b>=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()}}o.WriteBuffer=d},5941:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const l=/^([\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})$/,h=/^[\da-f]+$/;function u(d,f){const p=d.toString(16),v=p.length<2?"0"+p:p;switch(f){case 4:return p[0];case 8:return v;case 12:return(v+v).slice(0,3);default:return v+v}}o.parseColor=function(d){if(!d)return;let f=d.toLowerCase();if(f.indexOf("rgb:")===0){f=f.slice(4);const p=l.exec(f);if(p){const v=p[1]?15:p[4]?255:p[7]?4095:65535;return[Math.round(parseInt(p[1]||p[4]||p[7]||p[10],16)/v*255),Math.round(parseInt(p[2]||p[5]||p[8]||p[11],16)/v*255),Math.round(parseInt(p[3]||p[6]||p[9]||p[12],16)/v*255)]}}else if(f.indexOf("#")===0&&(f=f.slice(1),h.exec(f)&&[3,6,9,12].includes(f.length))){const p=f.length/3,v=[0,0,0];for(let b=0;b<3;++b){const O=parseInt(f.slice(p*b,p*b+p),16);v[b]=p===1?O<<4:p===2?O:p===3?O>>4:O>>8}return v}},o.toRgbString=function(d,f=16){const[p,v,b]=d;return`rgb:${u(p,f)}/${u(v,f)}/${u(b,f)}`}},5770:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const h=l(482),u=l(8742),d=l(5770),f=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=f,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}registerHandler(v,b){this._handlers[v]===void 0&&(this._handlers[v]=[]);const O=this._handlers[v];return O.push(b),{dispose:()=>{const g=O.indexOf(b);g!==-1&&O.splice(g,1)}}}clearHandler(v){this._handlers[v]&&delete this._handlers[v]}setHandlerFallback(v){this._handlerFb=v}reset(){if(this._active.length)for(let v=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;v>=0;--v)this._active[v].unhook(!1);this._stack.paused=!1,this._active=f,this._ident=0}hook(v,b){if(this.reset(),this._ident=v,this._active=this._handlers[v]||f,this._active.length)for(let O=this._active.length-1;O>=0;O--)this._active[O].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(v,b,O){if(this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].put(v,b,O);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(v,b,O))}unhook(v,b=!0){if(this._active.length){let O=!1,g=this._active.length-1,m=!1;if(this._stack.paused&&(g=this._stack.loopPosition-1,O=b,m=this._stack.fallThrough,this._stack.paused=!1),!m&&O===!1){for(;g>=0&&(O=this._active[g].unhook(v),O!==!0);g--)if(O instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!1,O;g--}for(;g>=0;g--)if(O=this._active[g].unhook(!1),O instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!0,O}else this._handlerFb(this._ident,"UNHOOK",v);this._active=f,this._ident=0}};const p=new u.Params;p.addParam(0),o.DcsHandler=class{constructor(v){this._handler=v,this._data="",this._params=p,this._hitLimit=!1}hook(v){this._params=v.length>1||v.params[0]?v.clone():p,this._data="",this._hitLimit=!1}put(v,b,O){this._hitLimit||(this._data+=(0,h.utf32ToString)(v,b,O),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(v){let b=!1;if(this._hitLimit)b=!1;else if(v&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then((O=>(this._params=p,this._data="",this._hitLimit=!1,O)));return this._params=p,this._data="",this._hitLimit=!1,b}}},2015:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const h=l(844),u=l(8742),d=l(6242),f=l(6351);class p{constructor(g){this.table=new Uint8Array(g)}setDefault(g,m){this.table.fill(g<<4|m)}add(g,m,x,y){this.table[m<<8|g]=x<<4|y}addMany(g,m,x,y){for(let k=0;k<g.length;k++)this.table[m<<8|g[k]]=x<<4|y}}o.TransitionTable=p;const v=160;o.VT500_TRANSITION_TABLE=(function(){const O=new p(4095),g=Array.apply(null,Array(256)).map(((P,_)=>_)),m=(P,_)=>g.slice(P,_),x=m(32,127),y=m(0,24);y.push(25),y.push.apply(y,m(28,32));const k=m(0,14);let C;for(C in O.setDefault(1,0),O.addMany(x,0,2,0),k)O.addMany([24,26,153,154],C,3,0),O.addMany(m(128,144),C,3,0),O.addMany(m(144,152),C,3,0),O.add(156,C,0,0),O.add(27,C,11,1),O.add(157,C,4,8),O.addMany([152,158,159],C,0,7),O.add(155,C,11,3),O.add(144,C,11,9);return O.addMany(y,0,3,0),O.addMany(y,1,3,1),O.add(127,1,0,1),O.addMany(y,8,0,8),O.addMany(y,3,3,3),O.add(127,3,0,3),O.addMany(y,4,3,4),O.add(127,4,0,4),O.addMany(y,6,3,6),O.addMany(y,5,3,5),O.add(127,5,0,5),O.addMany(y,2,3,2),O.add(127,2,0,2),O.add(93,1,4,8),O.addMany(x,8,5,8),O.add(127,8,5,8),O.addMany([156,27,24,26,7],8,6,0),O.addMany(m(28,32),8,0,8),O.addMany([88,94,95],1,0,7),O.addMany(x,7,0,7),O.addMany(y,7,0,7),O.add(156,7,0,0),O.add(127,7,0,7),O.add(91,1,11,3),O.addMany(m(64,127),3,7,0),O.addMany(m(48,60),3,8,4),O.addMany([60,61,62,63],3,9,4),O.addMany(m(48,60),4,8,4),O.addMany(m(64,127),4,7,0),O.addMany([60,61,62,63],4,0,6),O.addMany(m(32,64),6,0,6),O.add(127,6,0,6),O.addMany(m(64,127),6,0,0),O.addMany(m(32,48),3,9,5),O.addMany(m(32,48),5,9,5),O.addMany(m(48,64),5,0,6),O.addMany(m(64,127),5,7,0),O.addMany(m(32,48),4,9,5),O.addMany(m(32,48),1,9,2),O.addMany(m(32,48),2,9,2),O.addMany(m(48,127),2,10,0),O.addMany(m(48,80),1,10,0),O.addMany(m(81,88),1,10,0),O.addMany([89,90,92],1,10,0),O.addMany(m(96,127),1,10,0),O.add(80,1,11,9),O.addMany(y,9,0,9),O.add(127,9,0,9),O.addMany(m(28,32),9,0,9),O.addMany(m(32,48),9,9,12),O.addMany(m(48,60),9,8,10),O.addMany([60,61,62,63],9,9,10),O.addMany(y,11,0,11),O.addMany(m(32,128),11,0,11),O.addMany(m(28,32),11,0,11),O.addMany(y,10,0,10),O.add(127,10,0,10),O.addMany(m(28,32),10,0,10),O.addMany(m(48,60),10,8,10),O.addMany([60,61,62,63],10,0,11),O.addMany(m(32,48),10,9,12),O.addMany(y,12,0,12),O.add(127,12,0,12),O.addMany(m(28,32),12,0,12),O.addMany(m(32,48),12,9,12),O.addMany(m(48,64),12,0,11),O.addMany(m(64,127),12,12,13),O.addMany(m(64,127),10,12,13),O.addMany(m(64,127),9,12,13),O.addMany(y,13,13,13),O.addMany(x,13,13,13),O.add(127,13,0,13),O.addMany([27,156,24,26],13,14,0),O.add(v,0,2,0),O.add(v,8,5,8),O.add(v,6,0,6),O.add(v,11,0,11),O.add(v,13,13,13),O})();class b extends h.Disposable{constructor(g=o.VT500_TRANSITION_TABLE){super(),this._transitions=g,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.precedingJoinState=0,this._printHandlerFb=(m,x,y)=>{},this._executeHandlerFb=m=>{},this._csiHandlerFb=(m,x)=>{},this._escHandlerFb=m=>{},this._errorHandlerFb=m=>m,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new d.OscParser),this._dcsParser=this.register(new f.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(g,m=[64,126]){let x=0;if(g.prefix){if(g.prefix.length>1)throw new Error("only one byte as prefix supported");if(x=g.prefix.charCodeAt(0),x&&60>x||x>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(g.intermediates){if(g.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let k=0;k<g.intermediates.length;++k){const C=g.intermediates.charCodeAt(k);if(32>C||C>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");x<<=8,x|=C}}if(g.final.length!==1)throw new Error("final must be a single byte");const y=g.final.charCodeAt(0);if(m[0]>y||y>m[1])throw new Error(`final must be in range ${m[0]} .. ${m[1]}`);return x<<=8,x|=y,x}identToString(g){const m=[];for(;g;)m.push(String.fromCharCode(255&g)),g>>=8;return m.reverse().join("")}setPrintHandler(g){this._printHandler=g}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(g,m){const x=this._identifier(g,[48,126]);this._escHandlers[x]===void 0&&(this._escHandlers[x]=[]);const y=this._escHandlers[x];return y.push(m),{dispose:()=>{const k=y.indexOf(m);k!==-1&&y.splice(k,1)}}}clearEscHandler(g){this._escHandlers[this._identifier(g,[48,126])]&&delete this._escHandlers[this._identifier(g,[48,126])]}setEscHandlerFallback(g){this._escHandlerFb=g}setExecuteHandler(g,m){this._executeHandlers[g.charCodeAt(0)]=m}clearExecuteHandler(g){this._executeHandlers[g.charCodeAt(0)]&&delete this._executeHandlers[g.charCodeAt(0)]}setExecuteHandlerFallback(g){this._executeHandlerFb=g}registerCsiHandler(g,m){const x=this._identifier(g);this._csiHandlers[x]===void 0&&(this._csiHandlers[x]=[]);const y=this._csiHandlers[x];return y.push(m),{dispose:()=>{const k=y.indexOf(m);k!==-1&&y.splice(k,1)}}}clearCsiHandler(g){this._csiHandlers[this._identifier(g)]&&delete this._csiHandlers[this._identifier(g)]}setCsiHandlerFallback(g){this._csiHandlerFb=g}registerDcsHandler(g,m){return this._dcsParser.registerHandler(this._identifier(g),m)}clearDcsHandler(g){this._dcsParser.clearHandler(this._identifier(g))}setDcsHandlerFallback(g){this._dcsParser.setHandlerFallback(g)}registerOscHandler(g,m){return this._oscParser.registerHandler(g,m)}clearOscHandler(g){this._oscParser.clearHandler(g)}setOscHandlerFallback(g){this._oscParser.setHandlerFallback(g)}setErrorHandler(g){this._errorHandler=g}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(g,m,x,y,k){this._parseStack.state=g,this._parseStack.handlers=m,this._parseStack.handlerPos=x,this._parseStack.transition=y,this._parseStack.chunkPos=k}parse(g,m,x){let y,k=0,C=0,P=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,P=this._parseStack.chunkPos+1;else{if(x===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const _=this._parseStack.handlers;let Q=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(x===!1&&Q>-1){for(;Q>=0&&(y=_[Q](this._params),y!==!0);Q--)if(y instanceof Promise)return this._parseStack.handlerPos=Q,y}this._parseStack.handlers=[];break;case 4:if(x===!1&&Q>-1){for(;Q>=0&&(y=_[Q](),y!==!0);Q--)if(y instanceof Promise)return this._parseStack.handlerPos=Q,y}this._parseStack.handlers=[];break;case 6:if(k=g[this._parseStack.chunkPos],y=this._dcsParser.unhook(k!==24&&k!==26,x),y)return y;k===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(k=g[this._parseStack.chunkPos],y=this._oscParser.end(k!==24&&k!==26,x),y)return y;k===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,P=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let _=P;_<m;++_){switch(k=g[_],C=this._transitions.table[this.currentState<<8|(k<160?k:v)],C>>4){case 2:for(let R=_+1;;++R){if(R>=m||(k=g[R])<32||k>126&&k<v){this._printHandler(g,_,R),_=R-1;break}if(++R>=m||(k=g[R])<32||k>126&&k<v){this._printHandler(g,_,R),_=R-1;break}if(++R>=m||(k=g[R])<32||k>126&&k<v){this._printHandler(g,_,R),_=R-1;break}if(++R>=m||(k=g[R])<32||k>126&&k<v){this._printHandler(g,_,R),_=R-1;break}}break;case 3:this._executeHandlers[k]?this._executeHandlers[k]():this._executeHandlerFb(k),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:_,code:k,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const Q=this._csiHandlers[this._collect<<8|k];let E=Q?Q.length-1:-1;for(;E>=0&&(y=Q[E](this._params),y!==!0);E--)if(y instanceof Promise)return this._preserveStack(3,Q,E,C,_),y;E<0&&this._csiHandlerFb(this._collect<<8|k,this._params),this.precedingJoinState=0;break;case 8:do switch(k){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(k-48)}while(++_<m&&(k=g[_])>47&&k<60);_--;break;case 9:this._collect<<=8,this._collect|=k;break;case 10:const A=this._escHandlers[this._collect<<8|k];let N=A?A.length-1:-1;for(;N>=0&&(y=A[N](),y!==!0);N--)if(y instanceof Promise)return this._preserveStack(4,A,N,C,_),y;N<0&&this._escHandlerFb(this._collect<<8|k),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|k,this._params);break;case 13:for(let R=_+1;;++R)if(R>=m||(k=g[R])===24||k===26||k===27||k>127&&k<v){this._dcsParser.put(g,_,R),_=R-1;break}break;case 14:if(y=this._dcsParser.unhook(k!==24&&k!==26),y)return this._preserveStack(6,[],0,C,_),y;k===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let R=_+1;;R++)if(R>=m||(k=g[R])<32||k>127&&k<v){this._oscParser.put(g,_,R),_=R-1;break}break;case 6:if(y=this._oscParser.end(k!==24&&k!==26),y)return this._preserveStack(5,[],0,C,_),y;k===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&C}}}o.EscapeSequenceParser=b},6242:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const h=l(5770),u=l(482),d=[];o.OscParser=class{constructor(){this._state=0,this._active=d,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(f,p){this._handlers[f]===void 0&&(this._handlers[f]=[]);const v=this._handlers[f];return v.push(p),{dispose:()=>{const b=v.indexOf(p);b!==-1&&v.splice(b,1)}}}clearHandler(f){this._handlers[f]&&delete this._handlers[f]}setHandlerFallback(f){this._handlerFb=f}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}reset(){if(this._state===2)for(let f=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;f>=0;--f)this._active[f].end(!1);this._stack.paused=!1,this._active=d,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||d,this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].start();else this._handlerFb(this._id,"START")}_put(f,p,v){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(f,p,v);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(f,p,v))}start(){this.reset(),this._state=1}put(f,p,v){if(this._state!==3){if(this._state===1)for(;p<v;){const b=f[p++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&v-p>0&&this._put(f,p,v)}}end(f,p=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let v=!1,b=this._active.length-1,O=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,v=p,O=this._stack.fallThrough,this._stack.paused=!1),!O&&v===!1){for(;b>=0&&(v=this._active[b].end(f),v!==!0);b--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,v;b--}for(;b>=0;b--)if(v=this._active[b].end(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,v}else this._handlerFb(this._id,"END",f);this._active=d,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(f){this._handler=f,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(f,p,v){this._hitLimit||(this._data+=(0,u.utf32ToString)(f,p,v),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(f){let p=!1;if(this._hitLimit)p=!1;else if(f&&(p=this._handler(this._data),p instanceof Promise))return p.then((v=>(this._data="",this._hitLimit=!1,v)));return this._data="",this._hitLimit=!1,p}}},8742:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const l=2147483647;class h{static fromArray(d){const f=new h;if(!d.length)return f;for(let p=Array.isArray(d[0])?1:0;p<d.length;++p){const v=d[p];if(Array.isArray(v))for(let b=0;b<v.length;++b)f.addSubParam(v[b]);else f.addParam(v)}return f}constructor(d=32,f=32){if(this.maxLength=d,this.maxSubParamsLength=f,f>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(d),this.length=0,this._subParams=new Int32Array(f),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(d),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const d=new h(this.maxLength,this.maxSubParamsLength);return d.params.set(this.params),d.length=this.length,d._subParams.set(this._subParams),d._subParamsLength=this._subParamsLength,d._subParamsIdx.set(this._subParamsIdx),d._rejectDigits=this._rejectDigits,d._rejectSubDigits=this._rejectSubDigits,d._digitIsSub=this._digitIsSub,d}toArray(){const d=[];for(let f=0;f<this.length;++f){d.push(this.params[f]);const p=this._subParamsIdx[f]>>8,v=255&this._subParamsIdx[f];v-p>0&&d.push(Array.prototype.slice.call(this._subParams,p,v))}return d}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(d){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=d>l?l:d}}addSubParam(d){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=d>l?l:d,this._subParamsIdx[this.length-1]++}}hasSubParams(d){return(255&this._subParamsIdx[d])-(this._subParamsIdx[d]>>8)>0}getSubParams(d){const f=this._subParamsIdx[d]>>8,p=255&this._subParamsIdx[d];return p-f>0?this._subParams.subarray(f,p):null}getSubParamsAll(){const d={};for(let f=0;f<this.length;++f){const p=this._subParamsIdx[f]>>8,v=255&this._subParamsIdx[f];v-p>0&&(d[f]=this._subParams.slice(p,v))}return d}addDigit(d){let f;if(this._rejectDigits||!(f=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const p=this._digitIsSub?this._subParams:this.params,v=p[f-1];p[f-1]=~v?Math.min(10*v+d,l):d}}o.Params=h},5741:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let l=this._addons.length-1;l>=0;l--)this._addons[l].instance.dispose()}loadAddon(l,h){const u={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(u),h.dispose=()=>this._wrappedAddonDispose(u),h.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let h=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===l){h=u;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");l.isDisposed=!0,l.dispose.apply(l.instance),this._addons.splice(h,1)}}},8771:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const h=l(3785),u=l(511);o.BufferApiView=class{constructor(d,f){this._buffer=d,this.type=f}init(d){return this._buffer=d,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(d){const f=this._buffer.lines.get(d);if(f)return new h.BufferLineApiView(f)}getNullCell(){return new u.CellData}}},3785:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const h=l(511);o.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,d){if(!(u<0||u>=this._line.length))return d?(this._line.loadCell(u,d),d):this._line.loadCell(u,new h.CellData)}translateToString(u,d,f){return this._line.translateToString(u,d,f)}}},8285:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const h=l(8771),u=l(8460),d=l(844);class f extends d.Disposable{constructor(v){super(),this._core=v,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.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)}}o.BufferNamespaceApi=f},7975:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(l){this._core=l}registerCsiHandler(l,h){return this._core.registerCsiHandler(l,(u=>h(u.toArray())))}addCsiHandler(l,h){return this.registerCsiHandler(l,h)}registerDcsHandler(l,h){return this._core.registerDcsHandler(l,((u,d)=>h(u,d.toArray())))}addDcsHandler(l,h){return this.registerDcsHandler(l,h)}registerEscHandler(l,h){return this._core.registerEscHandler(l,h)}addEscHandler(l,h){return this.registerEscHandler(l,h)}registerOscHandler(l,h){return this._core.registerOscHandler(l,h)}addOscHandler(l,h){return this.registerOscHandler(l,h)}}},7090:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(l){this._core=l}register(l){this._core.unicodeService.register(l)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(l){this._core.unicodeService.activeVersion=l}}},744:function(a,o,l){var h=this&&this.__decorate||function(O,g,m,x){var y,k=arguments.length,C=k<3?g:x===null?x=Object.getOwnPropertyDescriptor(g,m):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(O,g,m,x);else for(var P=O.length-1;P>=0;P--)(y=O[P])&&(C=(k<3?y(C):k>3?y(g,m,C):y(g,m))||C);return k>3&&C&&Object.defineProperty(g,m,C),C},u=this&&this.__param||function(O,g){return function(m,x){g(m,x,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const d=l(8460),f=l(844),p=l(5295),v=l(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let b=o.BufferService=class extends f.Disposable{get buffer(){return this.buffers.active}constructor(O){super(),this.isUserScrolling=!1,this._onResize=this.register(new d.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(O.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(O.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new p.BufferSet(O,this))}resize(O,g){this.cols=O,this.rows=g,this.buffers.resize(O,g),this._onResize.fire({cols:O,rows:g})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(O,g=!1){const m=this.buffer;let x;x=this._cachedBlankLine,x&&x.length===this.cols&&x.getFg(0)===O.fg&&x.getBg(0)===O.bg||(x=m.getBlankLine(O,g),this._cachedBlankLine=x),x.isWrapped=g;const y=m.ybase+m.scrollTop,k=m.ybase+m.scrollBottom;if(m.scrollTop===0){const C=m.lines.isFull;k===m.lines.length-1?C?m.lines.recycle().copyFrom(x):m.lines.push(x.clone()):m.lines.splice(k+1,0,x.clone()),C?this.isUserScrolling&&(m.ydisp=Math.max(m.ydisp-1,0)):(m.ybase++,this.isUserScrolling||m.ydisp++)}else{const C=k-y+1;m.lines.shiftElements(y+1,C-1,-1),m.lines.set(k,x.clone())}this.isUserScrolling||(m.ydisp=m.ybase),this._onScroll.fire(m.ydisp)}scrollLines(O,g,m){const x=this.buffer;if(O<0){if(x.ydisp===0)return;this.isUserScrolling=!0}else O+x.ydisp>=x.ybase&&(this.isUserScrolling=!1);const y=x.ydisp;x.ydisp=Math.max(Math.min(x.ydisp+O,x.ybase),0),y!==x.ydisp&&(g||this._onScroll.fire(x.ydisp))}};o.BufferService=b=h([u(0,v.IOptionsService)],b)},7994:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(l){this.glevel=l,this.charset=this._charsets[l]}setgCharset(l,h){this._charsets[l]=h,this.glevel===l&&(this.charset=h)}}},1753:function(a,o,l){var h=this&&this.__decorate||function(x,y,k,C){var P,_=arguments.length,Q=_<3?y:C===null?C=Object.getOwnPropertyDescriptor(y,k):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Q=Reflect.decorate(x,y,k,C);else for(var E=x.length-1;E>=0;E--)(P=x[E])&&(Q=(_<3?P(Q):_>3?P(y,k,Q):P(y,k))||Q);return _>3&&Q&&Object.defineProperty(y,k,Q),Q},u=this&&this.__param||function(x,y){return function(k,C){y(k,C,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const d=l(2585),f=l(8460),p=l(844),v={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:x=>x.button!==4&&x.action===1&&(x.ctrl=!1,x.alt=!1,x.shift=!1,!0)},VT200:{events:19,restrict:x=>x.action!==32},DRAG:{events:23,restrict:x=>x.action!==32||x.button!==3},ANY:{events:31,restrict:x=>!0}};function b(x,y){let k=(x.ctrl?16:0)|(x.shift?4:0)|(x.alt?8:0);return x.button===4?(k|=64,k|=x.action):(k|=3&x.button,4&x.button&&(k|=64),8&x.button&&(k|=128),x.action===32?k|=32:x.action!==0||y||(k|=3)),k}const O=String.fromCharCode,g={DEFAULT:x=>{const y=[b(x,!1)+32,x.col+32,x.row+32];return y[0]>255||y[1]>255||y[2]>255?"":`\x1B[M${O(y[0])}${O(y[1])}${O(y[2])}`},SGR:x=>{const y=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${b(x,!0)};${x.col};${x.row}${y}`},SGR_PIXELS:x=>{const y=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${b(x,!0)};${x.x};${x.y}${y}`}};let m=o.CoreMouseService=class extends p.Disposable{constructor(x,y){super(),this._bufferService=x,this._coreService=y,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new f.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const k of Object.keys(v))this.addProtocol(k,v[k]);for(const k of Object.keys(g))this.addEncoding(k,g[k]);this.reset()}addProtocol(x,y){this._protocols[x]=y}addEncoding(x,y){this._encodings[x]=y}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(x){if(!this._protocols[x])throw new Error(`unknown protocol "${x}"`);this._activeProtocol=x,this._onProtocolChange.fire(this._protocols[x].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(x){if(!this._encodings[x])throw new Error(`unknown encoding "${x}"`);this._activeEncoding=x}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(x){if(x.col<0||x.col>=this._bufferService.cols||x.row<0||x.row>=this._bufferService.rows||x.button===4&&x.action===32||x.button===3&&x.action!==32||x.button!==4&&(x.action===2||x.action===3)||(x.col++,x.row++,x.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,x,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(x))return!1;const y=this._encodings[this._activeEncoding](x);return y&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(y):this._coreService.triggerDataEvent(y,!0)),this._lastEvent=x,!0}explainEvents(x){return{down:!!(1&x),up:!!(2&x),drag:!!(4&x),move:!!(8&x),wheel:!!(16&x)}}_equalEvents(x,y,k){if(k){if(x.x!==y.x||x.y!==y.y)return!1}else if(x.col!==y.col||x.row!==y.row)return!1;return x.button===y.button&&x.action===y.action&&x.ctrl===y.ctrl&&x.alt===y.alt&&x.shift===y.shift}};o.CoreMouseService=m=h([u(0,d.IBufferService),u(1,d.ICoreService)],m)},6975:function(a,o,l){var h=this&&this.__decorate||function(m,x,y,k){var C,P=arguments.length,_=P<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,y):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(m,x,y,k);else for(var Q=m.length-1;Q>=0;Q--)(C=m[Q])&&(_=(P<3?C(_):P>3?C(x,y,_):C(x,y))||_);return P>3&&_&&Object.defineProperty(x,y,_),_},u=this&&this.__param||function(m,x){return function(y,k){x(y,k,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const d=l(1439),f=l(8460),p=l(844),v=l(2585),b=Object.freeze({insertMode:!1}),O=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let g=o.CoreService=class extends p.Disposable{constructor(m,x,y){super(),this._bufferService=m,this._logService=x,this._optionsService=y,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new f.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new f.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,d.clone)(b),this.decPrivateModes=(0,d.clone)(O)}reset(){this.modes=(0,d.clone)(b),this.decPrivateModes=(0,d.clone)(O)}triggerDataEvent(m,x=!1){if(this._optionsService.rawOptions.disableStdin)return;const y=this._bufferService.buffer;x&&this._optionsService.rawOptions.scrollOnUserInput&&y.ybase!==y.ydisp&&this._onRequestScrollToBottom.fire(),x&&this._onUserInput.fire(),this._logService.debug(`sending data "${m}"`,(()=>m.split("").map((k=>k.charCodeAt(0))))),this._onData.fire(m)}triggerBinaryEvent(m){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${m}"`,(()=>m.split("").map((x=>x.charCodeAt(0))))),this._onBinary.fire(m))}};o.CoreService=g=h([u(0,v.IBufferService),u(1,v.ILogService),u(2,v.IOptionsService)],g)},9074:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const h=l(8055),u=l(8460),d=l(844),f=l(6106);let p=0,v=0;class b extends d.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new f.SortedList((m=>m?.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,d.toDisposable)((()=>this.reset())))}registerDecoration(m){if(m.marker.isDisposed)return;const x=new O(m);if(x){const y=x.marker.onDispose((()=>x.dispose()));x.onDispose((()=>{x&&(this._decorations.delete(x)&&this._onDecorationRemoved.fire(x),y.dispose())})),this._decorations.insert(x),this._onDecorationRegistered.fire(x)}return x}reset(){for(const m of this._decorations.values())m.dispose();this._decorations.clear()}*getDecorationsAtCell(m,x,y){let k=0,C=0;for(const P of this._decorations.getKeyIterator(x))k=P.options.x??0,C=k+(P.options.width??1),m>=k&&m<C&&(!y||(P.options.layer??"bottom")===y)&&(yield P)}forEachDecorationAtCell(m,x,y,k){this._decorations.forEachByKey(x,(C=>{p=C.options.x??0,v=p+(C.options.width??1),m>=p&&m<v&&(!y||(C.options.layer??"bottom")===y)&&k(C)}))}}o.DecorationService=b;class O extends d.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(m){super(),this.options=m,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=m.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const h=l(2585),u=l(8343);class d{constructor(...p){this._entries=new Map;for(const[v,b]of p)this.set(v,b)}set(p,v){const b=this._entries.get(p);return this._entries.set(p,v),b}forEach(p){for(const[v,b]of this._entries.entries())p(v,b)}has(p){return this._entries.has(p)}get(p){return this._entries.get(p)}}o.ServiceCollection=d,o.InstantiationService=class{constructor(){this._services=new d,this._services.set(h.IInstantiationService,this)}setService(f,p){this._services.set(f,p)}getService(f){return this._services.get(f)}createInstance(f,...p){const v=(0,u.getServiceDependencies)(f).sort(((g,m)=>g.index-m.index)),b=[];for(const g of v){const m=this._services.get(g.id);if(!m)throw new Error(`[createInstance] ${f.name} depends on UNKNOWN service ${g.id}.`);b.push(m)}const O=v.length>0?v[0].index:p.length;if(p.length!==O)throw new Error(`[createInstance] First service dependency of ${f.name} at position ${O+1} conflicts with ${p.length} static arguments`);return new f(...p,...b)}}},7866:function(a,o,l){var h=this&&this.__decorate||function(O,g,m,x){var y,k=arguments.length,C=k<3?g:x===null?x=Object.getOwnPropertyDescriptor(g,m):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(O,g,m,x);else for(var P=O.length-1;P>=0;P--)(y=O[P])&&(C=(k<3?y(C):k>3?y(g,m,C):y(g,m))||C);return k>3&&C&&Object.defineProperty(g,m,C),C},u=this&&this.__param||function(O,g){return function(m,x){g(m,x,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const d=l(844),f=l(2585),p={trace:f.LogLevelEnum.TRACE,debug:f.LogLevelEnum.DEBUG,info:f.LogLevelEnum.INFO,warn:f.LogLevelEnum.WARN,error:f.LogLevelEnum.ERROR,off:f.LogLevelEnum.OFF};let v,b=o.LogService=class extends d.Disposable{get logLevel(){return this._logLevel}constructor(O){super(),this._optionsService=O,this._logLevel=f.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),v=this}_updateLogLevel(){this._logLevel=p[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(O){for(let g=0;g<O.length;g++)typeof O[g]=="function"&&(O[g]=O[g]())}_log(O,g,m){this._evalLazyOptionalParams(m),O.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+g,...m)}trace(O,...g){this._logLevel<=f.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,O,g)}debug(O,...g){this._logLevel<=f.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,O,g)}info(O,...g){this._logLevel<=f.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,O,g)}warn(O,...g){this._logLevel<=f.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,O,g)}error(O,...g){this._logLevel<=f.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,O,g)}};o.LogService=b=h([u(0,f.IOptionsService)],b),o.setTraceLogger=function(O){v=O},o.traceCall=function(O,g,m){if(typeof m.value!="function")throw new Error("not supported");const x=m.value;m.value=function(...y){if(v.logLevel!==f.LogLevelEnum.TRACE)return x.apply(this,y);v.trace(`GlyphRenderer#${x.name}(${y.map((C=>JSON.stringify(C))).join(", ")})`);const k=x.apply(this,y);return v.trace(`GlyphRenderer#${x.name} return`,k),k}}},7302:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const h=l(8460),u=l(844),d=l(6114);o.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,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:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:d.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const f=["normal","bold","100","200","300","400","500","600","700","800","900"];class p extends u.Disposable{constructor(b){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const O={...o.DEFAULT_OPTIONS};for(const g in b)if(g in O)try{const m=b[g];O[g]=this._sanitizeAndValidateOption(g,m)}catch(m){console.error(m)}this.rawOptions=O,this.options={...O},this._setupOptions(),this.register((0,u.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(b,O){return this.onOptionChange((g=>{g===b&&O(this.rawOptions[b])}))}onMultipleOptionChange(b,O){return this.onOptionChange((g=>{b.indexOf(g)!==-1&&O()}))}_setupOptions(){const b=g=>{if(!(g in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${g}"`);return this.rawOptions[g]},O=(g,m)=>{if(!(g in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${g}"`);m=this._sanitizeAndValidateOption(g,m),this.rawOptions[g]!==m&&(this.rawOptions[g]=m,this._onOptionChange.fire(g))};for(const g in this.rawOptions){const m={get:b.bind(this,g),set:O.bind(this,g)};Object.defineProperty(this.options,g,m)}}_sanitizeAndValidateOption(b,O){switch(b){case"cursorStyle":if(O||(O=o.DEFAULT_OPTIONS[b]),!(function(g){return g==="block"||g==="underline"||g==="bar"})(O))throw new Error(`"${O}" is not a valid value for ${b}`);break;case"wordSeparator":O||(O=o.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof O=="number"&&1<=O&&O<=1e3)break;O=f.includes(O)?O:o.DEFAULT_OPTIONS[b];break;case"cursorWidth":O=Math.floor(O);case"lineHeight":case"tabStopWidth":if(O<1)throw new Error(`${b} cannot be less than 1, value: ${O}`);break;case"minimumContrastRatio":O=Math.max(1,Math.min(21,Math.round(10*O)/10));break;case"scrollback":if((O=Math.min(O,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${O}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(O<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${O}`);break;case"rows":case"cols":if(!O&&O!==0)throw new Error(`${b} must be numeric, value: ${O}`);break;case"windowsPty":O=O??{}}return O}}o.OptionsService=p},2660:function(a,o,l){var h=this&&this.__decorate||function(p,v,b,O){var g,m=arguments.length,x=m<3?v:O===null?O=Object.getOwnPropertyDescriptor(v,b):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(p,v,b,O);else for(var y=p.length-1;y>=0;y--)(g=p[y])&&(x=(m<3?g(x):m>3?g(v,b,x):g(v,b))||x);return m>3&&x&&Object.defineProperty(v,b,x),x},u=this&&this.__param||function(p,v){return function(b,O){v(b,O,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const d=l(2585);let f=o.OscLinkService=class{constructor(p){this._bufferService=p,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(p){const v=this._bufferService.buffer;if(p.id===void 0){const y=v.addMarker(v.ybase+v.y),k={data:p,id:this._nextId++,lines:[y]};return y.onDispose((()=>this._removeMarkerFromLink(k,y))),this._dataByLinkId.set(k.id,k),k.id}const b=p,O=this._getEntryIdKey(b),g=this._entriesWithId.get(O);if(g)return this.addLineToLink(g.id,v.ybase+v.y),g.id;const m=v.addMarker(v.ybase+v.y),x={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[m]};return m.onDispose((()=>this._removeMarkerFromLink(x,m))),this._entriesWithId.set(x.key,x),this._dataByLinkId.set(x.id,x),x.id}addLineToLink(p,v){const b=this._dataByLinkId.get(p);if(b&&b.lines.every((O=>O.line!==v))){const O=this._bufferService.buffer.addMarker(v);b.lines.push(O),O.onDispose((()=>this._removeMarkerFromLink(b,O)))}}getLinkData(p){return this._dataByLinkId.get(p)?.data}_getEntryIdKey(p){return`${p.id};;${p.uri}`}_removeMarkerFromLink(p,v){const b=p.lines.indexOf(v);b!==-1&&(p.lines.splice(b,1),p.lines.length===0&&(p.data.id!==void 0&&this._entriesWithId.delete(p.key),this._dataByLinkId.delete(p.id)))}};o.OscLinkService=f=h([u(0,d.IBufferService)],f)},8343:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const l="di$target",h="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(u){return u[h]||[]},o.createDecorator=function(u){if(o.serviceRegistry.has(u))return o.serviceRegistry.get(u);const d=function(f,p,v){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,O,g){O[l]===O?O[h].push({id:b,index:g}):(O[h]=[{id:b,index:g}],O[l]=O)})(d,f,v)};return d.toString=()=>u,o.serviceRegistry.set(u,d),d}},2585:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const h=l(8343);var u;o.IBufferService=(0,h.createDecorator)("BufferService"),o.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),o.ICoreService=(0,h.createDecorator)("CoreService"),o.ICharsetService=(0,h.createDecorator)("CharsetService"),o.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.OFF=5]="OFF"})(u||(o.LogLevelEnum=u={})),o.ILogService=(0,h.createDecorator)("LogService"),o.IOptionsService=(0,h.createDecorator)("OptionsService"),o.IOscLinkService=(0,h.createDecorator)("OscLinkService"),o.IUnicodeService=(0,h.createDecorator)("UnicodeService"),o.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const h=l(8460),u=l(225);class d{static extractShouldJoin(p){return(1&p)!=0}static extractWidth(p){return p>>1&3}static extractCharKind(p){return p>>3}static createPropertyValue(p,v,b=!1){return(16777215&p)<<3|(3&v)<<1|(b?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const p=new u.UnicodeV6;this.register(p),this._active=p.version,this._activeProvider=p}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(p){if(!this._providers[p])throw new Error(`unknown Unicode version "${p}"`);this._active=p,this._activeProvider=this._providers[p],this._onChange.fire(p)}register(p){this._providers[p.version]=p}wcwidth(p){return this._activeProvider.wcwidth(p)}getStringCellWidth(p){let v=0,b=0;const O=p.length;for(let g=0;g<O;++g){let m=p.charCodeAt(g);if(55296<=m&&m<=56319){if(++g>=O)return v+this.wcwidth(m);const k=p.charCodeAt(g);56320<=k&&k<=57343?m=1024*(m-55296)+k-56320+65536:v+=this.wcwidth(k)}const x=this.charProperties(m,b);let y=d.extractWidth(x);d.extractShouldJoin(x)&&(y-=d.extractWidth(b)),v+=y,b=x}return v}charProperties(p,v){return this._activeProvider.charProperties(p,v)}}o.UnicodeService=d}},r={};function i(a){var o=r[a];if(o!==void 0)return o.exports;var l=r[a]={exports:{}};return t[a].call(l.exports,l,l.exports,i),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.Terminal=void 0;const o=i(9042),l=i(3236),h=i(844),u=i(5741),d=i(8285),f=i(7975),p=i(7090),v=["cols","rows"];class b extends h.Disposable{constructor(g){super(),this._core=this.register(new l.Terminal(g)),this._addonManager=this.register(new u.AddonManager),this._publicOptions={...this._core.options};const m=y=>this._core.options[y],x=(y,k)=>{this._checkReadonlyOptions(y),this._core.options[y]=k};for(const y in this._core.options){const k={get:m.bind(this,y),set:x.bind(this,y)};Object.defineProperty(this._publicOptions,y,k)}}_checkReadonlyOptions(g){if(v.includes(g))throw new Error(`Option "${g}" 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 f.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new p.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 d.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const g=this._core.coreService.decPrivateModes;let m="none";switch(this._core.coreMouseService.activeProtocol){case"X10":m="x10";break;case"VT200":m="vt200";break;case"DRAG":m="drag";break;case"ANY":m="any"}return{applicationCursorKeysMode:g.applicationCursorKeys,applicationKeypadMode:g.applicationKeypad,bracketedPasteMode:g.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:m,originMode:g.origin,reverseWraparoundMode:g.reverseWraparound,sendFocusMode:g.sendFocus,wraparoundMode:g.wraparound}}get options(){return this._publicOptions}set options(g){for(const m in g)this._publicOptions[m]=g[m]}blur(){this._core.blur()}focus(){this._core.focus()}input(g,m=!0){this._core.input(g,m)}resize(g,m){this._verifyIntegers(g,m),this._core.resize(g,m)}open(g){this._core.open(g)}attachCustomKeyEventHandler(g){this._core.attachCustomKeyEventHandler(g)}attachCustomWheelEventHandler(g){this._core.attachCustomWheelEventHandler(g)}registerLinkProvider(g){return this._core.registerLinkProvider(g)}registerCharacterJoiner(g){return this._checkProposedApi(),this._core.registerCharacterJoiner(g)}deregisterCharacterJoiner(g){this._checkProposedApi(),this._core.deregisterCharacterJoiner(g)}registerMarker(g=0){return this._verifyIntegers(g),this._core.registerMarker(g)}registerDecoration(g){return this._checkProposedApi(),this._verifyPositiveIntegers(g.x??0,g.width??0,g.height??0),this._core.registerDecoration(g)}hasSelection(){return this._core.hasSelection()}select(g,m,x){this._verifyIntegers(g,m,x),this._core.select(g,m,x)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(g,m){this._verifyIntegers(g,m),this._core.selectLines(g,m)}dispose(){super.dispose()}scrollLines(g){this._verifyIntegers(g),this._core.scrollLines(g)}scrollPages(g){this._verifyIntegers(g),this._core.scrollPages(g)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(g){this._verifyIntegers(g),this._core.scrollToLine(g)}clear(){this._core.clear()}write(g,m){this._core.write(g,m)}writeln(g,m){this._core.write(g),this._core.write(`\r
53
+ `,m)}paste(g){this._core.paste(g)}refresh(g,m){this._verifyIntegers(g,m),this._core.refresh(g,m)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(g){this._addonManager.loadAddon(this,g)}static get strings(){return o}_verifyIntegers(...g){for(const m of g)if(m===1/0||isNaN(m)||m%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...g){for(const m of g)if(m&&(m===1/0||isNaN(m)||m%1!=0||m<0))throw new Error("This API only accepts positive integers")}}a.Terminal=b})(),n})()))})(kf)),kf.exports}var tI=eI(),Cf={exports:{}},_v;function sI(){return _v||(_v=1,(function(s,e){(function(t,r){s.exports=r()})(self,(()=>(()=>{var t={};return(()=>{var r=t;Object.defineProperty(r,"__esModule",{value:!0}),r.FitAddon=void 0,r.FitAddon=class{activate(i){this._terminal=i}dispose(){}fit(){const i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;const n=this._terminal._core;this._terminal.rows===i.rows&&this._terminal.cols===i.cols||(n._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const i=this._terminal._core,n=i._renderService.dimensions;if(n.css.cell.width===0||n.css.cell.height===0)return;const a=this._terminal.options.scrollback===0?0:i.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(o.getPropertyValue("height")),h=Math.max(0,parseInt(o.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),d=l-(parseInt(u.getPropertyValue("padding-top"))+parseInt(u.getPropertyValue("padding-bottom"))),f=h-(parseInt(u.getPropertyValue("padding-right"))+parseInt(u.getPropertyValue("padding-left")))-a;return{cols:Math.max(2,Math.floor(f/n.css.cell.width)),rows:Math.max(1,Math.floor(d/n.css.cell.height))}}}})(),t})()))})(Cf)),Cf.exports}var rI=sI(),Pf={exports:{}},kv;function iI(){return kv||(kv=1,(function(s,e){(function(t,r){s.exports=r()})(self,(()=>(()=>{var t={345:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===l)return void this._listeners.splice(h,1)}}})),this._event}fire(l,h){const u=[];for(let d=0;d<this._listeners.length;d++)u.push(this._listeners[d]);for(let d=0;d<u.length;d++)u[d].call(void 0,l,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(l,h){return l((u=>h.fire(u)))},o.runAndSubscribe=function(l,h){return h(void 0),l((u=>h(u)))}},859:(a,o)=>{function l(h){for(const u of h)u.dispose();h.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const u=this._disposables.indexOf(h);u!==-1&&this._disposables.splice(u,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){this._isDisposed||h===this._value||(this._value?.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},o.toDisposable=function(h){return{dispose:h}},o.disposeArray=l,o.getDisposeArrayDisposable=function(h){return{dispose:()=>l(h)}}}},r={};function i(a){var o=r[a];if(o!==void 0)return o.exports;var l=r[a]={exports:{}};return t[a](l,l.exports,i),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.SearchAddon=void 0;const o=i(345),l=i(859),h=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class u extends l.Disposable{constructor(f){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new l.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new l.MutableDisposable,this._onDidChangeResults=this.register(new o.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=f?.highlightLimit??1e3}activate(f){this._terminal=f,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,l.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{const f=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(f,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(f){this._selectedDecoration.clear(),(0,l.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),f||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(f,p){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const v=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,p);this._lastSearchOptions=p,p?.decorations&&(this._cachedSearchTerm===void 0||f!==this._cachedSearchTerm||v)&&this._highlightAllMatches(f,p);const b=this._findNextAndSelect(f,p);return this._fireResults(p),this._cachedSearchTerm=f,b}_highlightAllMatches(f,p){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!f||f.length===0)return void this.clearDecorations();p=p||{},this.clearDecorations(!0);const v=[];let b,O=this._find(f,0,0,p);for(;O&&(b?.row!==O.row||b?.col!==O.col)&&!(v.length>=this._highlightLimit);)b=O,v.push(b),O=this._find(f,b.col+b.term.length>=this._terminal.cols?b.row+1:b.row,b.col+b.term.length>=this._terminal.cols?0:b.col+1,p);for(const g of v){const m=this._createResultDecoration(g,p.decorations);m&&(this._highlightedLines.add(m.marker.line),this._highlightDecorations.push({decoration:m,match:g,dispose(){m.dispose()}}))}}_find(f,p,v,b){if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(v>this._terminal.cols)throw new Error(`Invalid col: ${v} to search in terminal of ${this._terminal.cols} cols`);let O;this._initLinesCache();const g={startRow:p,startCol:v};if(O=this._findInLine(f,g,b),!O)for(let m=p+1;m<this._terminal.buffer.active.baseY+this._terminal.rows&&(g.startRow=m,g.startCol=0,O=this._findInLine(f,g,b),!O);m++);return O}_findNextAndSelect(f,p){if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const v=this._terminal.getSelectionPosition();this._terminal.clearSelection();let b=0,O=0;v&&(this._cachedSearchTerm===f?(b=v.end.x,O=v.end.y):(b=v.start.x,O=v.start.y)),this._initLinesCache();const g={startRow:O,startCol:b};let m=this._findInLine(f,g,p);if(!m)for(let x=O+1;x<this._terminal.buffer.active.baseY+this._terminal.rows&&(g.startRow=x,g.startCol=0,m=this._findInLine(f,g,p),!m);x++);if(!m&&O!==0)for(let x=0;x<O&&(g.startRow=x,g.startCol=0,m=this._findInLine(f,g,p),!m);x++);return!m&&v&&(g.startRow=v.start.y,g.startCol=0,m=this._findInLine(f,g,p)),this._selectResult(m,p?.decorations,p?.noScroll)}findPrevious(f,p){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const v=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,p);this._lastSearchOptions=p,p?.decorations&&(this._cachedSearchTerm===void 0||f!==this._cachedSearchTerm||v)&&this._highlightAllMatches(f,p);const b=this._findPreviousAndSelect(f,p);return this._fireResults(p),this._cachedSearchTerm=f,b}_didOptionsChange(f,p){return!!p&&(f.caseSensitive!==p.caseSensitive||f.regex!==p.regex||f.wholeWord!==p.wholeWord)}_fireResults(f){if(f?.decorations){let p=-1;if(this._selectedDecoration.value){const v=this._selectedDecoration.value.match;for(let b=0;b<this._highlightDecorations.length;b++){const O=this._highlightDecorations[b].match;if(O.row===v.row&&O.col===v.col&&O.size===v.size){p=b;break}}}this._onDidChangeResults.fire({resultIndex:p,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(f,p){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const v=this._terminal.getSelectionPosition();this._terminal.clearSelection();let b=this._terminal.buffer.active.baseY+this._terminal.rows-1,O=this._terminal.cols;const g=!0;this._initLinesCache();const m={startRow:b,startCol:O};let x;if(v&&(m.startRow=b=v.start.y,m.startCol=O=v.start.x,this._cachedSearchTerm!==f&&(x=this._findInLine(f,m,p,!1),x||(m.startRow=b=v.end.y,m.startCol=O=v.end.x))),x||(x=this._findInLine(f,m,p,g)),!x){m.startCol=Math.max(m.startCol,this._terminal.cols);for(let y=b-1;y>=0&&(m.startRow=y,x=this._findInLine(f,m,p,g),!x);y--);}if(!x&&b!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let y=this._terminal.buffer.active.baseY+this._terminal.rows-1;y>=b&&(m.startRow=y,x=this._findInLine(f,m,p,g),!x);y--);return this._selectResult(x,p?.decorations,p?.noScroll)}_initLinesCache(){const f=this._terminal;this._linesCache||(this._linesCache=new Array(f.buffer.active.length),this._linesCacheDisposables.value=(0,l.getDisposeArrayDisposable)([f.onLineFeed((()=>this._destroyLinesCache())),f.onCursorMove((()=>this._destroyLinesCache())),f.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(f,p,v){return(f===0||h.includes(p[f-1]))&&(f+v.length===p.length||h.includes(p[f+v.length]))}_findInLine(f,p,v={},b=!1){const O=this._terminal,g=p.startRow,m=p.startCol;if(O.buffer.active.getLine(g)?.isWrapped)return b?void(p.startCol+=O.cols):(p.startRow--,p.startCol+=O.cols,this._findInLine(f,p,v));let y=this._linesCache?.[g];y||(y=this._translateBufferLineToStringWithWrap(g,!0),this._linesCache&&(this._linesCache[g]=y));const[k,C]=y,P=this._bufferColsToStringOffset(g,m),_=v.caseSensitive?f:f.toLowerCase(),Q=v.caseSensitive?k:k.toLowerCase();let E=-1;if(v.regex){const A=RegExp(_,"g");let N;if(b)for(;N=A.exec(Q.slice(0,P));)E=A.lastIndex-N[0].length,f=N[0],A.lastIndex-=f.length-1;else N=A.exec(Q.slice(P)),N&&N[0].length>0&&(E=P+(A.lastIndex-N[0].length),f=N[0])}else b?P-_.length>=0&&(E=Q.lastIndexOf(_,P-_.length)):E=Q.indexOf(_,P);if(E>=0){if(v.wholeWord&&!this._isWholeWord(E,Q,f))return;let A=0;for(;A<C.length-1&&E>=C[A+1];)A++;let N=A;for(;N<C.length-1&&E+f.length>=C[N+1];)N++;const R=E-C[A],W=E+f.length-C[N],H=this._stringLengthToBufferSize(g+A,R);return{term:f,col:H,row:g+A,size:this._stringLengthToBufferSize(g+N,W)-H+O.cols*(N-A)}}}_stringLengthToBufferSize(f,p){const v=this._terminal.buffer.active.getLine(f);if(!v)return 0;for(let b=0;b<p;b++){const O=v.getCell(b);if(!O)break;const g=O.getChars();g.length>1&&(p-=g.length-1);const m=v.getCell(b+1);m&&m.getWidth()===0&&p++}return p}_bufferColsToStringOffset(f,p){const v=this._terminal;let b=f,O=0,g=v.buffer.active.getLine(b);for(;p>0&&g;){for(let m=0;m<p&&m<v.cols;m++){const x=g.getCell(m);if(!x)break;x.getWidth()&&(O+=x.getCode()===0?1:x.getChars().length)}if(b++,g=v.buffer.active.getLine(b),g&&!g.isWrapped)break;p-=v.cols}return O}_translateBufferLineToStringWithWrap(f,p){const v=this._terminal,b=[],O=[0];let g=v.buffer.active.getLine(f);for(;g;){const m=v.buffer.active.getLine(f+1),x=!!m&&m.isWrapped;let y=g.translateToString(!x&&p);if(x&&m){const k=g.getCell(g.length-1);k&&k.getCode()===0&&k.getWidth()===1&&m.getCell(0)?.getWidth()===2&&(y=y.slice(0,-1))}if(b.push(y),!x)break;O.push(O[O.length-1]+y.length),f++,g=m}return[b.join(""),O]}_selectResult(f,p,v){const b=this._terminal;if(this._selectedDecoration.clear(),!f)return b.clearSelection(),!1;if(b.select(f.col,f.row,f.size),p){const O=b.registerMarker(-b.buffer.active.baseY-b.buffer.active.cursorY+f.row);if(O){const g=b.registerDecoration({marker:O,x:f.col,width:f.size,backgroundColor:p.activeMatchBackground,layer:"top",overviewRulerOptions:{color:p.activeMatchColorOverviewRuler}});if(g){const m=[];m.push(O),m.push(g.onRender((x=>this._applyStyles(x,p.activeMatchBorder,!0)))),m.push(g.onDispose((()=>(0,l.disposeArray)(m)))),this._selectedDecoration.value={decoration:g,match:f,dispose(){g.dispose()}}}}}if(!v&&(f.row>=b.buffer.active.viewportY+b.rows||f.row<b.buffer.active.viewportY)){let O=f.row-b.buffer.active.viewportY;O-=Math.floor(b.rows/2),b.scrollLines(O)}return!0}_applyStyles(f,p,v){f.classList.contains("xterm-find-result-decoration")||(f.classList.add("xterm-find-result-decoration"),p&&(f.style.outline=`1px solid ${p}`)),v&&f.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(f,p){const v=this._terminal,b=v.registerMarker(-v.buffer.active.baseY-v.buffer.active.cursorY+f.row);if(!b)return;const O=v.registerDecoration({marker:b,x:f.col,width:f.size,backgroundColor:p.matchBackground,overviewRulerOptions:this._highlightedLines.has(b.line)?void 0:{color:p.matchOverviewRuler,position:"center"}});if(O){const g=[];g.push(b),g.push(O.onRender((m=>this._applyStyles(m,p.matchBorder,!1)))),g.push(O.onDispose((()=>(0,l.disposeArray)(g))))}return O}}a.SearchAddon=u})(),n})()))})(Pf)),Pf.exports}var nI=iI(),Tf={exports:{}},Cv;function oI(){return Cv||(Cv=1,(function(s,e){(function(t,r){s.exports=r()})(self,(()=>(()=>{var t={6:(a,o)=>{function l(u){try{const d=new URL(u),f=d.password&&d.username?`${d.protocol}//${d.username}:${d.password}@${d.host}`:d.username?`${d.protocol}//${d.username}@${d.host}`:`${d.protocol}//${d.host}`;return u.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(u,d,f,p={}){this._terminal=u,this._regex=d,this._handler=f,this._options=p}provideLinks(u,d){const f=h.computeLink(u,this._regex,this._terminal,this._handler);d(this._addCallbacks(f))}_addCallbacks(u){return u.map((d=>(d.leave=this._options.leave,d.hover=(f,p)=>{if(this._options.hover){const{range:v}=d;this._options.hover(f,p,v)}},d)))}};class h{static computeLink(d,f,p,v){const b=new RegExp(f.source,(f.flags||"")+"g"),[O,g]=h._getWindowedLineStrings(d-1,p),m=O.join("");let x;const y=[];for(;x=b.exec(m);){const k=x[0];if(!l(k))continue;const[C,P]=h._mapStrIdx(p,g,0,x.index),[_,Q]=h._mapStrIdx(p,C,P,k.length);if(C===-1||P===-1||_===-1||Q===-1)continue;const E={start:{x:P+1,y:C+1},end:{x:Q,y:_+1}};y.push({range:E,text:k,activate:v})}return y}static _getWindowedLineStrings(d,f){let p,v=d,b=d,O=0,g="";const m=[];if(p=f.buffer.active.getLine(d)){const x=p.translateToString(!0);if(p.isWrapped&&x[0]!==" "){for(O=0;(p=f.buffer.active.getLine(--v))&&O<2048&&(g=p.translateToString(!0),O+=g.length,m.push(g),p.isWrapped&&g.indexOf(" ")===-1););m.reverse()}for(m.push(x),O=0;(p=f.buffer.active.getLine(++b))&&p.isWrapped&&O<2048&&(g=p.translateToString(!0),O+=g.length,m.push(g),g.indexOf(" ")===-1););}return[m,v]}static _mapStrIdx(d,f,p,v){const b=d.buffer.active,O=b.getNullCell();let g=p;for(;v;){const m=b.getLine(f);if(!m)return[-1,-1];for(let x=g;x<m.length;++x){m.getCell(x,O);const y=O.getChars();if(O.getWidth()&&(v-=y.length||1,x===m.length-1&&y==="")){const k=b.getLine(f+1);k&&k.isWrapped&&(k.getCell(0,O),O.getWidth()===2&&(v+=1))}if(v<0)return[f,x]}f++,g=0}return[f,g]}}o.LinkComputer=h}},r={};function i(a){var o=r[a];if(o!==void 0)return o.exports;var l=r[a]={exports:{}};return t[a](l,l.exports,i),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.WebLinksAddon=void 0;const o=i(6),l=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function h(u,d){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=d}else console.warn("Opening link blocked as opener could not be cleared")}a.WebLinksAddon=class{constructor(u=h,d={}){this._handler=u,this._options=d}activate(u){this._terminal=u;const d=this._options,f=d.urlRegex||l;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,f,this._handler,d))}dispose(){this._linkProvider?.dispose()}}})(),n})()))})(Tf)),Tf.exports}var aI=oI();function Qf(s,e){try{return getComputedStyle(document.documentElement).getPropertyValue(s).trim()||e}catch{return e}}function Pv(s){return typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC")?s.metaKey:s.ctrlKey}function V_(s){return!s||s.includes(" ")||/^https?:\/\//i.test(s)?!1:/^[a-zA-Z]:[\\/]/.test(s)||s.startsWith("/")||s.startsWith("~/")||s.startsWith("./")||s.startsWith("../")?!0:/^[\w./\\-]+\.[a-zA-Z0-9]{1,8}$/.test(s)}function Tv(s,e){const t=s.trim().replace(/\\/g,"/");return!t||!V_(t)?null:/^[a-zA-Z]:\//.test(t)||t.startsWith("~/")?t:t.startsWith("/")?/^\/packages\//.test(t)?!e||e==="/"?null:MO(t.slice(1),e):t:!e||e==="/"?null:MO(t,e)}function Qv(s){return s.clientWidth>=16&&s.clientHeight>=16}async function lI(s,e){try{const r=(await ne.files.check([s]))?.results?.[s];if(!r?.exists||!r?.isFile)return;e?.(s)}catch{e?.(s)}}function cI({terminalId:s,title:e,cwd:t,active:r=!0,onMeta:i,onSelection:n,onOpenUrl:a,onOpenPath:o,apiRef:l}){const{t:h}=Tt("common"),u=w.useRef(null),d=w.useRef(null),f=w.useRef(null),p=w.useRef(null),v=w.useRef(i),b=w.useRef(n),O=w.useRef(a),g=w.useRef(o),m=w.useRef(t);v.current=i,b.current=n,O.current=a,g.current=o,w.useEffect(()=>{t&&t!=="/"&&(m.current=t)},[t]);const[x,y]=w.useState(null),[k,C]=w.useState(!1),[P,_]=w.useState(""),[Q,E]=w.useState(!1),A=w.useRef(!0),N=w.useCallback(()=>{const W=u.current,H=d.current,Z=f.current;if(!W||!H||!Z||!Qv(W))return!1;try{return Z.fit(),!0}catch{return!1}},[]),R=w.useCallback(()=>{const W=d.current;W&&(W.scrollToBottom(),A.current=!0,E(!1))},[]);return w.useEffect(()=>{vC(s);const W=u.current,H=window.markusDesktop?.terminal;if(!W)return;if(!H){y("desktopOnly");return}let Z=!1,B=null,K=null,$,I,X,q=null,ie=null,pe=null,$e=null;const re=async()=>{if(Z||!u.current)return;if(!Qv(u.current)){$e=window.setTimeout(()=>{re()},50);return}const U=Qf("--color-surface-primary","#0f1419"),M=Qf("--color-fg-primary","#e7e9ea");B=new tI.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:1.25,allowProposedApi:!0,theme:{background:U,foreground:M,cursor:Qf("--color-brand-500","#3b82f6"),selectionBackground:"rgba(59, 130, 246, 0.35)"}});const te=new rI.FitAddon,Y=new nI.SearchAddon,ae=new aI.WebLinksAddon((ee,me)=>{Pv(ee)&&O.current?.(me)});if(B.loadAddon(te),B.loadAddon(Y),B.loadAddon(ae),B.open(u.current),d.current=B,f.current=te,p.current=Y,!N())try{te.fit()}catch{}B.registerLinkProvider({provideLinks:(ee,me)=>{const Re=B.buffer.active.getLine(ee-1);if(!Re){me(void 0);return}const _e=Re.translateToString(!0),De=/(?:(?:[A-Za-z]:|\/|~\/)[\w./\\-]+|(?:\.\.?\/)?[\w./\\-]+\.[a-zA-Z0-9]{1,8})/g,Te=[];let Fe;for(;Fe=De.exec(_e);){const Ue=Fe[0];V_(Ue)&&Tv(Ue,m.current)&&Te.push({range:{start:{x:Fe.index+1,y:ee},end:{x:Fe.index+Ue.length,y:ee}},text:Ue,decorations:{pointerCursor:!0,underline:!0},activate:ve=>{if(!Pv(ve))return;const V=Tv(Ue,m.current);V&&lI(V,g.current)}})}me(Te.length?Te:void 0)}});try{const ee=Math.max(B.cols||80,2),me=Math.max(B.rows||24,1);let Re=t||m.current;if(!Re||Re==="/")try{Re=await window.markusDesktop?.getDefaultCwd?.()}catch{}Re==="/"&&(Re=void 0),Re&&(m.current=Re);const _e=await H.create(s,{cwd:Re,title:e,cols:ee,rows:me});if(Z)return;if(!_e.ok){y(_e.error||"createFailed");return}_e.info&&(_e.info.cwd&&(m.current=_e.info.cwd),v.current?.(s,{title:_e.info.title,cwd:_e.info.cwd}));const De=await H.getBuffer(s,{maxChars:12e4});if(Z)return;const Te=De.ok?De.content:void 0;if(Te&&(await new Promise(Fe=>{let Ue=!1,ve;const V=()=>{Ue||(Ue=!0,ve!==void 0&&window.clearTimeout(ve),Fe())};ve=window.setTimeout(V,1500);try{B.write(Te,V)}catch{V()}}),Z))return;N(),H.resize(s,B.cols,B.rows),B.focus()}catch(ee){Z||y(ee instanceof Error?ee.message:String(ee));return}$=H.onData?.(ee=>{ee.id!==s||!d.current||(d.current.write(ee.data),A.current||E(!0))}),X=H.onEvent?.(ee=>{ee.id!==s||ee.type!=="cwd"||!ee.cwd||(m.current=ee.cwd,v.current?.(s,{cwd:ee.cwd}))}),I=H.onExit?.(()=>{}),q=B.onData(ee=>{H.write(s,ee)}),ie=B.onScroll(()=>{const ee=d.current;if(!ee)return;const me=ee.buffer.active,Re=me.viewportY>=me.baseY-1;A.current=Re,Re&&E(!1)}),pe=B.onSelectionChange(()=>{const ee=d.current,me=u.current;if(!ee||!me)return;if(!ee.getSelection().trim()){b.current?.(null);return}requestAnimationFrame(()=>{const _e=d.current,De=u.current;if(!_e||!De)return;const Te=_e.getSelection().trim();if(!Te){b.current?.(null);return}let Fe,Ue;const ve=De.querySelectorAll(".xterm-selection div");let V=1/0,Xe=1/0,Ke=-1/0;if(ve.forEach(ft=>{const mt=ft.getBoundingClientRect();mt.width<1&&mt.height<1||(V=Math.min(V,mt.top),Xe=Math.min(Xe,mt.left),Ke=Math.max(Ke,mt.right))}),V<1/0)Fe=(Xe+Ke)/2,Ue=V;else{const ft=_e.getSelectionPosition?.(),_t=(De.querySelector(".xterm-screen")??De).getBoundingClientRect(),Xt=Math.max(_e.cols,1),dt=Math.max(_e.rows,1),Dt=_t.width/Xt,Me=_t.height/dt;if(ft){const jt=_e.buffer.active.viewportY,ye=Math.max(0,ft.start.y-jt);Fe=_t.left+(ft.start.x+.5)*Dt,Ue=_t.top+ye*Me}else Fe=_t.left+_t.width/2,Ue=_t.top+12}b.current?.({text:Te,x:Fe,y:Ue})})}),K=new ResizeObserver(()=>{!N()||!d.current||H.resize(s,d.current.cols,d.current.rows)}),K.observe(u.current),l&&(l.current={getSelection:()=>d.current?.getSelection()??"",getRecentOutput:async(ee=80)=>{const me=await H.getBuffer(s,{maxLines:ee});return me.ok&&me.content||""},focus:()=>d.current?.focus(),findNext:ee=>{p.current?.findNext(ee)},clearSelection:()=>d.current?.clearSelection()})};return re(),()=>{Z=!0,$e!=null&&window.clearTimeout($e),$?.(),I?.(),X?.(),q?.dispose(),ie?.dispose(),pe?.dispose(),K?.disconnect(),l&&(l.current=null);try{B?.dispose()}catch{}d.current=null,f.current=null,p.current=null}},[s]),w.useEffect(()=>{if(!r)return;const W=window.requestAnimationFrame(()=>{N();const H=d.current;H&&(window.markusDesktop?.terminal?.resize(s,H.cols,H.rows),H.focus())});return()=>window.cancelAnimationFrame(W)},[r,s,N]),w.useEffect(()=>{const W=H=>{if(!r)return;if((navigator.platform.toUpperCase().includes("MAC")?H.metaKey&&!H.ctrlKey:H.ctrlKey&&!H.metaKey)&&!H.altKey&&!H.shiftKey&&H.key.toLowerCase()==="f"){const K=H.target;K instanceof HTMLElement&&(u.current?.contains(K)||K.closest(".xterm"))&&(H.preventDefault(),C(!0))}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[r]),c.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col rounded-lg overflow-hidden border border-border-default bg-surface-primary",children:[k&&c.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-2 py-1.5 border-b border-border-default bg-surface-elevated",children:[c.jsx("input",{autoFocus:!0,value:P,onChange:W=>_(W.target.value),onKeyDown:W=>{W.key==="Enter"?(W.preventDefault(),p.current?.findNext(P)):W.key==="Escape"&&C(!1)},placeholder:h("terminal.searchPlaceholder"),className:"flex-1 min-w-0 text-xs bg-transparent outline-none text-fg-primary placeholder:text-fg-muted"}),c.jsx("button",{type:"button",className:"text-[11px] px-2 py-0.5 rounded text-fg-secondary hover:bg-surface-overlay",onClick:()=>p.current?.findNext(P),children:h("terminal.searchNext")}),c.jsx("button",{type:"button",className:"text-[11px] px-2 py-0.5 rounded text-fg-tertiary hover:bg-surface-overlay",onClick:()=>C(!1),children:"Esc"})]}),x?c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 p-6 text-center",children:[c.jsxs("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 9l3 3-3 3M13 15h4"})]}),x==="desktopOnly"?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm font-medium text-fg-secondary",children:h("terminal.desktopOnlyTitle")}),c.jsx("p",{className:"text-xs text-fg-muted max-w-xs",children:h("terminal.desktopOnlyDesc")})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm font-medium text-fg-secondary",children:h("terminal.createFailedTitle")}),c.jsx("p",{className:"text-xs text-fg-muted max-w-xs break-words",children:x==="createFailed"?h("terminal.createFailedDesc"):x})]})]}):c.jsx("div",{ref:u,className:"flex-1 min-h-0 w-full h-full [&_.xterm]:h-full [&_.xterm]:w-full [&_.xterm-viewport]:overflow-auto"}),Q&&c.jsx("button",{type:"button",onClick:R,className:"absolute bottom-3 right-3 z-10 text-[11px] px-2.5 py-1 rounded-md bg-brand-600 text-on-brand shadow-lg hover:bg-brand-500",children:h("terminal.jumpToBottom")})]})}const hI=8;function dI(s){const{left:e,width:t,viewport:r}=s,i=Math.max(0,t-r);if(i<=0||t<=0||r<=0)return{visible:!1,leftPct:0,widthPct:0,overflow:0};const n=Math.max(hI,r/t*100);return{visible:!0,leftPct:Math.max(0,Math.min(100-n,e/t*100)),widthPct:n,overflow:i}}const $v=(s,e,t)=>Math.max(e,Math.min(t,s));function uI({scrollRef:s,watch:e}){const[t,r]=w.useState({left:0,width:0,viewport:0}),i=w.useRef(null),n=w.useRef(null),a=w.useCallback(()=>{const d=s.current;if(!d)return;const f={left:d.scrollLeft,width:d.scrollWidth,viewport:d.clientWidth};r(p=>p.left===f.left&&p.width===f.width&&p.viewport===f.viewport?p:f)},[s]);w.useEffect(()=>{const d=s.current;if(!d)return;a(),d.addEventListener("scroll",a,{passive:!0});const f=new ResizeObserver(a);f.observe(d);for(const p of Array.from(d.children))f.observe(p);return()=>{d.removeEventListener("scroll",a),f.disconnect()}},[s,a,e]);const o=dI(t),l=d=>{const f=s.current,p=i.current;if(!f||!p||!o.visible||d.button!==0)return;const v=p.getBoundingClientRect();if(v.width<=0)return;const b=o.widthPct/100*v.width,O=o.leftPct/100*v.width,g=d.clientX-v.left;if(g<O||g>O+b){const m=f.scrollWidth/v.width;f.scrollLeft=$v((g-b/2)*m,0,o.overflow)}n.current={pointerId:d.pointerId,startX:d.clientX,startLeft:f.scrollLeft};try{p.setPointerCapture(d.pointerId)}catch{}d.preventDefault(),d.stopPropagation()},h=d=>{const f=n.current,p=s.current,v=i.current;if(!f||f.pointerId!==d.pointerId||!p||!v)return;const b=v.getBoundingClientRect();if(b.width<=0)return;const O=p.scrollWidth/b.width;p.scrollLeft=$v(f.startLeft+(d.clientX-f.startX)*O,0,o.overflow)},u=d=>{const f=n.current;if(!(!f||f.pointerId!==d.pointerId)){n.current=null;try{i.current?.releasePointerCapture(d.pointerId)}catch{}}};return o.visible?c.jsx("div",{ref:i,"aria-hidden":!0,"data-tab-scroll-rail":!0,className:"relative h-[3px] mt-[3px] mx-1 shrink-0 rounded-full bg-border-default/30 cursor-pointer select-none",onPointerDown:l,onPointerMove:h,onPointerUp:u,onPointerCancel:u,children:c.jsx("div",{className:"absolute top-0 h-full rounded-full bg-fg-muted/60 hover:bg-fg-secondary transition-colors",style:{left:`${o.leftPct}%`,width:`${o.widthPct}%`}})}):null}const fI=5e3;function mI(s){return s.editorDirty||s.visibility!=="visible"?!1:s.kind==="file"||s.kind==="deliverable"}function pI(s,e){return s?s.mtimeMs===void 0||e.mtimeMs===void 0?s.size===void 0||e.size===void 0?!1:s.size!==e.size:s.mtimeMs!==e.mtimeMs||s.size!==e.size:!1}function jv(s){return/^(https?|file):\/\//i.test(s)?s:/^[a-zA-Z]:[\\/]/.test(s)?`file:///${s.replace(/\\/g,"/")}`:`file://${s.startsWith("/")?s:`/${s}`}`}function go(s){return/^https?:\/\//i.test(s)}function gI(s){return s.kind==="deliverable"?s.deliverable.reference??"":s.kind==="url"?s.url:s.kind==="terminal"?s.terminalId:s.path}function OI(s){return s.kind==="deliverable"?s.deliverable.title||s.deliverable.reference||"":s.kind==="url"?s.title||s.url:s.kind==="terminal"?s.title||"Terminal":s.title||s.path.split(/[/\\]/).pop()||s.path}function xI(s,e){if(s.kind==="file")return`file:${s.path}:${e??""}`;if(s.kind==="url")return`url:${s.browserId||s.url}:${e??""}`;if(s.kind==="terminal")return`terminal:${s.terminalId}:${e??""}`;const t=s.deliverable;return`deliverable:${t.id||t.reference||t.title||"unknown"}:${e??""}`}function $f(s){return s==null||!Number.isFinite(s)?"":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function bI(s){const e=s.includes("\\")?"\\":"/",t=s.lastIndexOf(e);return t<=0?e==="/"?"/":s.slice(0,2):s.slice(0,t)}function vI({payload:s,onClose:e,width:t,onResizeStart:r,onAddToChat:i,tabs:n,activeTabId:a,onSelectTab:o,onCloseTab:l,onNewTab:h,fullscreen:u,onToggleFullscreen:d,onBrowserMeta:f,panelMode:p="browser",onPanelModeChange:v,onTerminalMeta:b,onOpenUrlFromTerminal:O,onOpenPathFromTerminal:g}){const{t:m}=Tt(["deliverables","agent","common"]),[x,y]=w.useState({mode:"loading"}),[k,C]=w.useState(null),[P,_]=w.useState(!1),[Q,E]=w.useState(!1),[A,N]=w.useState(null),[R,W]=w.useState(null),[H,Z]=w.useState({}),[B,K]=w.useState({}),[$,I]=w.useState(!1),[X,q]=w.useState(!1),[ie,pe]=w.useState(()=>yC()),$e=zo(),re=w.useRef(null),U=w.useRef(null),M=w.useRef(null),te=w.useRef(null),Y=w.useRef(null),ae=w.useRef(!1);ae.current=$;const[ee,me]=w.useState(0),Re=w.useRef(null),_e=w.useCallback(()=>D_(ae.current,m("common:fileEditor.discardConfirm",{defaultValue:"Discard unsaved changes?"})),[m]);w.useEffect(()=>Kv(pe),[]),w.useEffect(()=>{if(!X)return;const de=we=>{const oe=we.target;oe instanceof Node&&(M.current?.contains(oe)||q(!1))};return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[X]),w.useEffect(()=>{if(!k)return;const de=SC({kind:"file",path:k,title:k.split(/[/\\]/).pop()||k});de&&wC(de)},[k]),w.useEffect(()=>{let de=!1;ne.browser.tabOwnership().then(oe=>{if(de)return;const st={};for(const ue of oe.ownership??[])st[ue.pageId]={agentId:ue.agentId,agentName:ue.agentName||ue.agentId};Z(st)}).catch(()=>{});const we=Rt.on("ui:browser_ownership",oe=>{const st=oe.payload;typeof st.pageId=="number"&&Z(ue=>{if(st.action==="released"||!st.agentId){if(!(st.pageId in ue))return ue;const Le={...ue};return delete Le[st.pageId],Le}return{...ue,[st.pageId]:{agentId:st.agentId,agentName:st.agentName||st.agentId}}})});return()=>{de=!0,we()}},[]),w.useEffect(()=>{let de=!1;ne.terminal?.sessionOwnership?.().then(oe=>{if(de)return;const st={};for(const ue of oe.ownership??[])st[ue.terminalId]={agentId:ue.agentId,agentName:ue.agentName||ue.agentId};K(st)}).catch(()=>{});const we=Rt.on("ui:terminal_ownership",oe=>{const st=oe.payload;typeof st.terminalId=="string"&&K(ue=>{if(st.action==="released"||!st.agentId){if(!(st.terminalId in ue))return ue;const Le={...ue};return delete Le[st.terminalId],Le}return{...ue,[st.terminalId]:{agentId:st.agentId,agentName:st.agentName||st.agentId}}})});return()=>{de=!0,we()}},[]);const De=gI(s),Te=OI(s),Fe=k??De,Ue=(n?.length??0)>=1,ve=xI(s,a);w.useEffect(()=>{if(!a)return;const de=te.current,we=U.current;if(!de||!we)return;const oe=requestAnimationFrame(()=>{de.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})});return()=>cancelAnimationFrame(oe)},[a,n?.length]),w.useEffect(()=>{const de=we=>{if(we.key==="Escape"){if(!_e())return;u&&d?d():e()}};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[e,u,d,_e]),w.useEffect(()=>{let de=!1;if(W(null),I(!1),N(null),s.kind==="url")return y({mode:"url",url:s.url,browserId:s.browserId}),()=>{de=!0};if(s.kind==="terminal")return y({mode:"terminal",terminalId:s.terminalId,title:s.title,cwd:s.cwd}),()=>{de=!0};if(go(De))return y({mode:"url",url:De}),()=>{de=!0};y({mode:"loading"});const we=oe=>ee?`${oe}${oe.includes("?")?"&":"?"}_v=${ee}`:oe;return s.kind==="deliverable"&&s.deliverable.artifactType&&s.deliverable.artifactData?(y({mode:"artifact",summary:s.deliverable.summary||s.deliverable.title||""}),()=>{de=!0}):Fe?(ne.files.preview(Fe).then(oe=>{if(de)return;if(oe.type==="directory"&&Array.isArray(oe.entries)){y({mode:"directory",path:oe.path,name:oe.name,entries:oe.entries});return}if(oe.type==="image"){const ue=oe.content?`data:${oe.mimeType||"image/png"};base64,${oe.content}`:we(oe.streamUrl||(oe.path?ne.files.streamUrl(oe.path):ne.files.streamUrl(Fe)));y({mode:"image",src:ue,name:oe.name||Te});return}if(oe.type==="audio"){const ue=we(oe.streamUrl||(oe.path?ne.files.streamUrl(oe.path):ne.files.streamUrl(Fe)));y({mode:"audio",src:ue,name:oe.name||Te,mimeType:oe.mimeType||"audio/mpeg",size:oe.size});return}if(oe.type==="video"){const ue=we(oe.streamUrl||(oe.path?ne.files.streamUrl(oe.path):ne.files.streamUrl(Fe)));y({mode:"video",src:ue,name:oe.name||Te,mimeType:oe.mimeType||"video/mp4",size:oe.size});return}if(oe.type==="binary"){y({mode:"binary",name:oe.name||Te,reference:oe.path||Fe,size:oe.size,extension:oe.extension});return}if(oe.type==="office"){const ue=we(oe.streamUrl||(oe.path?ne.files.streamUrl(oe.path):ne.files.streamUrl(Fe)));y({mode:"office",format:oe.format||String(oe.extension||"").replace(/^\./,"")||"pdf",streamUrl:ue,name:oe.name||Te,size:oe.size,reference:oe.path||Fe});return}if(typeof oe.content!="string"){y({mode:"unpreviewable",reference:Fe,isDirectory:!1});return}const st=j2({format:s.kind==="deliverable"?s.deliverable.format:void 0,reference:De,content:oe.content});y({mode:"content",content:oe.content,format:st})}).catch(()=>{de||y({mode:"unpreviewable",reference:Fe,isDirectory:!1})}),()=>{de=!0}):(y({mode:"unpreviewable",reference:"",isDirectory:!1}),()=>{de=!0})},[ve,s,Fe,De,Te,ee]),w.useEffect(()=>{if(Re.current=null,!Fe||go(Fe)||s.kind!=="file"&&s.kind!=="deliverable")return;let de=!1;const we=async()=>{if(!(de||!mI({kind:s.kind,editorDirty:ae.current,visibility:document.visibilityState})))try{const Le=await ne.files.stat(Fe);if(de||!Le.exists)return;const ke=Re.current;Re.current={mtimeMs:Le.mtimeMs,size:Le.size},pI(ke,{mtimeMs:Le.mtimeMs,size:Le.size})&&me(nt=>nt+1)}catch{}};we();const oe=window.setInterval(()=>{we()},fI),st=()=>{we()};return document.addEventListener("visibilitychange",st),window.addEventListener("focus",st),()=>{de=!0,window.clearInterval(oe),document.removeEventListener("visibilitychange",st),window.removeEventListener("focus",st)}},[Fe,s.kind,ve]),w.useEffect(()=>{C(null),q(!1)},[ve]);const V=Te||Fe,Xe=w.useCallback((de,we)=>{const oe=If(de),st=oe.length>40?`${oe.slice(0,24)}…${oe.slice(-12)}`:oe;return we?{kind:"web",label:`🌐 ${st}`,content:["[html-selection]",`Text: "${de}"`,`CSS Selector: ${we.cssSelector}`,`XPath: ${we.xpath}`,De?`File: ${De}`:""].filter(Boolean).join(`
54
+ `)}:s.kind==="terminal"?{kind:"terminal",label:`⌘ ${st}`,content:["[terminal-selection]",`Terminal: ${s.title||"Terminal"} (${s.terminalId})`,s.cwd?`Cwd: ${s.cwd}`:"",'"""',de,'"""'].filter(Boolean).join(`
55
+ `)}:{kind:"selection",label:`“${st}”`,content:`${m("deliverables:chat.selectedFrom",{defaultValue:"Selected from"})} ${V}:
56
+
57
+ """
58
+ ${de}
59
+ """`}},[De,V,m,s]),Ke=w.useCallback((de,we)=>{!de.trim()||!i||(i(Xe(de.trim(),we)),W(null),window.getSelection()?.removeAllRanges(),Y.current?.clearSelection())},[i,Xe]),ft=w.useCallback(async()=>{if(!i||s.kind!=="terminal")return;const de=(await Y.current?.getRecentOutput(80))?.trim();if(!de)return;const we=If(de),oe=we.length>40?`${we.slice(0,24)}…${we.slice(-12)}`:we;i({kind:"terminal",label:`⌘ ${oe}`,content:["[terminal-output]",`Terminal: ${s.title||"Terminal"} (${s.terminalId})`,s.cwd?`Cwd: ${s.cwd}`:"",'"""',de,'"""'].filter(Boolean).join(`
60
+ `)})},[i,s]);w.useEffect(()=>{if(s.kind!=="terminal"||!i)return;const de=navigator.platform.toUpperCase().includes("MAC"),we=oe=>{if(!(de?oe.metaKey&&!oe.ctrlKey:oe.ctrlKey&&!oe.metaKey)||!oe.shiftKey||oe.altKey||oe.key.toLowerCase()!=="a")return;const ue=Y.current?.getSelection()?.trim();ue&&(oe.preventDefault(),Ke(ue))};return window.addEventListener("keydown",we),()=>window.removeEventListener("keydown",we)},[s.kind,i,Ke]);const mt=w.useCallback(de=>{if(!de.text.trim()||!i)return;const we=re.current?.querySelector("iframe")?.getBoundingClientRect(),oe=(we?.left??0)+de.rect.x+de.rect.width/2,st=(we?.top??0)+de.rect.y;W({x:oe,y:st,text:de.text,htmlMeta:{xpath:de.xpath,cssSelector:de.cssSelector}})},[i]);w.useEffect(()=>{const de=re.current;if(!de||!i)return;const we=()=>{requestAnimationFrame(()=>{const st=window.getSelection(),ue=st?.toString().trim();if(!ue||!st?.rangeCount){W(null);return}const Le=st.getRangeAt(0);if(!de.contains(Le.commonAncestorContainer)){W(null);return}const ke=Le.getBoundingClientRect();W({x:ke.left+ke.width/2,y:ke.top,text:ue})})},oe=st=>{const ue=document.getElementById("right-panel-selection-toolbar");ue&&ue.contains(st.target)||W(null)};return de.addEventListener("mouseup",we),document.addEventListener("mousedown",oe),()=>{de.removeEventListener("mouseup",we),document.removeEventListener("mousedown",oe)}},[i,x.mode]);const _t=()=>{ne.files.reveal(Fe||De).catch(()=>{})},Xt=()=>{navigator.clipboard?.writeText(Fe||De).then(()=>{_(!0),setTimeout(()=>_(!1),1500)}).catch(()=>{})},dt=w.useMemo(()=>{if(!i)return null;const de=Fe||De;if(s.kind==="deliverable"){const we=s.deliverable;if(!we.id&&!we.reference)return null;const oe=Te||we.title||we.reference||we.id;return{kind:"deliverable",label:`📄 ${oe.length>40?`${oe.slice(0,24)}…${oe.slice(-12)}`:oe}`,content:["[deliverable]",we.id?`ID: ${we.id}`:"",we.title?`Title: ${we.title}`:"",we.reference?`Reference: ${we.reference}`:"",we.taskId?`Task: ${we.taskId}`:"",we.projectId?`Project: ${we.projectId}`:""].filter(Boolean).join(`
61
+ `)}}if(s.kind==="file"){if(!de||go(de))return null;const we=Te||de.split(/[/\\]/).pop()||de;return{kind:"file",label:`📄 ${we.length>40?`${we.slice(0,24)}…${we.slice(-12)}`:we}`,content:["[file]",`Path: ${de}`,x.mode==="content"&&x.format?`Format: ${x.format}`:""].filter(Boolean).join(`
62
+ `)}}return null},[i,s,Fe,De,Te,x]),[Dt,Me]=w.useState(!1),jt=w.useCallback(()=>{dt&&(i?.(dt),Me(!0),setTimeout(()=>Me(!1),1200))},[dt,i]),ye=w.useCallback(async()=>{if(s.kind==="deliverable"){gr.navigate(Ut.DELIVERABLES,{openDeliverable:s.deliverable.id});return}if(s.kind==="url"){let we=s.url;if(s.browserId&&window.markusDesktop?.browser)try{const oe=await window.markusDesktop.browser.getState(s.browserId);if(oe.ok){if(oe.directoryPath){await ne.system.openPath(oe.directoryPath).catch(()=>ne.files.reveal(oe.directoryPath));return}oe.url&&oe.url!=="about:blank"&&(we=oe.url)}}catch{}if(!we||we==="about:blank")return;if(/^https?:\/\//i.test(we)||/^file:\/\//i.test(we)){fc(we);return}await ne.system.openPath(we).catch(()=>fc(jv(we)));return}if(s.kind!=="file")return;const de=s.path;if(de){if(/^https?:\/\//i.test(de)||/^file:\/\//i.test(de)){fc(de);return}await ne.system.openPath(de).catch(()=>fc(jv(de)))}},[s]),ze=s.kind==="deliverable"?!!s.deliverable.id:s.kind==="url"?!!(s.url&&s.url!=="about:blank")||!!s.browserId:s.kind==="file"?!!s.path:!1,Ie=s.kind==="deliverable"?m("agent:deliverables.openInPage",{defaultValue:"Open in Output"}):m("common:openInSystemBrowser"),ce=!!De&&!go(De)&&(s.kind==="file"||s.kind==="deliverable"),et=s.kind==="deliverable"&&s.deliverable.type==="file"&&!!De&&!go(De)&&!s.deliverable.artifactType&&R2(s.deliverable.format),xe=s.kind==="deliverable"?{...s.deliverable,hubShareId:A?.id??s.deliverable.hubShareId??null,shareStatus:A?.status??s.deliverable.shareStatus??null,shareUrl:A?.url??s.deliverable.shareUrl??null,shareVisibility:A?.visibility??s.deliverable.shareVisibility??null}:null,gt=w.useCallback(de=>{N(de)},[]),He=w.useMemo(()=>E2(LO,ap.getUrl()),[]),Ct=s.kind==="deliverable"?s.deliverable.id:null;w.useEffect(()=>{if(!Ct||!LO())return;let de=!1;const we=async()=>{try{const st=await He.listMine();if(de)return;const ue=s.kind==="deliverable"?s.deliverable:null;if(!ue)return;const Le=ue.hubShareId&&st.find(Ye=>Ye.id===ue.hubShareId)||st.find(Ye=>Ye.localId===ue.id);if(!Le)return;N(Ye=>Ye&&Ye.id===Le.id&&Ye.status===Le.status?Ye:Le);const ke={hubShareId:ue.hubShareId??Le.id??null,shareStatus:Le.status??null,shareUrl:Le.url??null,shareVisibility:ue.shareVisibility??Le.visibility??null};(ue.shareStatus!==ke.shareStatus||ue.hubShareId!==ke.hubShareId||ue.shareUrl!==ke.shareUrl||ue.shareVisibility!==ke.shareVisibility)&&ue.id&&ne.deliverables.update(ue.id,ke).catch(Ye=>{console.warn("[right-panel] Hub 分享状态本地持久化失败:",Ye)})}catch{}};we();const oe=setInterval(we,3e4);return()=>{de=!0,clearInterval(oe)}},[He,Ct,s]);const vt=xe?.shareStatus??null;return c.jsxs(c.Fragment,{children:[!u&&c.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative z-10 flex items-center justify-center",onMouseDown:r,children:c.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),c.jsxs("div",{className:`bg-surface-primary flex flex-col overflow-hidden ${u?"flex-1 min-w-0":"shrink-0"}`,style:u?void 0:{width:t},"data-right-panel":!0,children:[c.jsxs("header",{"data-electron-drag":!0,className:"relative z-20 h-10 shrink-0 flex items-center gap-1 pl-1.5 pr-1.5 border-b border-border-default bg-surface-primary",children:[v&&c.jsxs("div",{"data-no-drag":!0,className:"shrink-0 flex items-center gap-0.5 pr-1 border-r border-border-default/60",children:[c.jsx("button",{type:"button",onClick:()=>v("browser"),title:m("common:browserMode",{defaultValue:"Browser"}),"aria-label":m("common:browserMode",{defaultValue:"Browser"}),"aria-pressed":p==="browser",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${p==="browser"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),c.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),c.jsx("button",{type:"button",onClick:()=>v("terminal"),title:m("common:terminalMode",{defaultValue:"Terminal"}),"aria-label":m("common:terminalMode",{defaultValue:"Terminal"}),"aria-pressed":p==="terminal",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${p==="terminal"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"4 17 10 11 4 5"}),c.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})})]}),Ue||h?c.jsxs("div",{"data-no-drag":!0,className:"flex-1 min-w-0 self-stretch flex flex-col justify-end",children:[c.jsxs("div",{ref:U,role:"tablist",className:"flex flex-nowrap items-center gap-0.5 overflow-x-auto overflow-y-hidden overscroll-x-contain scrollbar-hide",onWheel:de=>{const we=de.currentTarget;we.scrollWidth<=we.clientWidth||Math.abs(de.deltaY)<=Math.abs(de.deltaX)||(we.scrollLeft+=de.deltaY,de.preventDefault())},children:[n?.map(de=>{const we=de.id===a,oe=de.payload.kind==="url"?de.payload.pageId:void 0,st=de.payload.kind==="terminal"?de.payload.terminalId:void 0,ue=oe!=null?H[oe]:st?B[st]:void 0,Le=ue?`${de.title} — ${m("common:browserTabControlledBy",{name:ue.agentName})}`:de.title;return c.jsxs("div",{className:`group shrink-0 flex items-center max-w-[200px] rounded-md text-[11px] border transition-colors ${we?ue?"bg-brand-500/10 border-brand-500/35 text-fg-primary":"bg-surface-elevated border-border-default text-fg-primary":ue?"border-brand-500/25 text-fg-secondary hover:bg-brand-500/8":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[c.jsxs("button",{type:"button",role:"tab","aria-selected":we,ref:we?te:void 0,className:"min-w-0 flex-1 truncate pl-2.5 pr-1 py-1 text-left cursor-pointer flex items-center gap-1",title:Le,onPointerDown:ke=>{ke.button===0&&(de.id!==a&&!_e()||o?.(de.id))},onClick:()=>{de.id!==a&&!_e()||o?.(de.id)},children:[ue&&c.jsxs("span",{className:"shrink-0 inline-flex items-center gap-0.5 max-w-[72px] px-1 py-px rounded text-[9px] font-semibold tracking-wide bg-brand-500/20 text-brand-500",title:m("common:browserTabControlledBy",{name:ue.agentName}),children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 animate-pulse shrink-0","aria-hidden":!0}),c.jsx("span",{className:"truncate",children:ue.agentName})]}),c.jsx("span",{className:"truncate min-w-0",children:de.title})]}),l&&c.jsx("button",{type:"button",onPointerDown:ke=>{ke.button===0&&(ke.preventDefault(),ke.stopPropagation(),!(de.id===a&&!_e())&&l(de.id))},onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),!(de.id===a&&!_e())&&l(de.id)},className:`shrink-0 mr-1 p-0.5 rounded hover:bg-surface-overlay transition-colors ${we?"text-fg-tertiary hover:text-fg-secondary":"text-fg-muted hover:text-fg-secondary opacity-70 group-hover:opacity-100"}`,title:m("common:closeTab",{defaultValue:"Close tab"}),"aria-label":m("common:closeTab",{defaultValue:"Close tab"}),children:c.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},de.id)}),h&&c.jsx("button",{type:"button",onClick:h,className:"shrink-0 w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/60 transition-colors",title:m("common:newTab",{defaultValue:"New Tab"}),"aria-label":m("common:newTab",{defaultValue:"New Tab"}),children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),c.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),c.jsx(uI,{scrollRef:U,watch:`${n?.length??0}:${a??""}`})]}):c.jsx("span",{className:"text-sm font-semibold text-fg-primary truncate flex-1 min-w-0 px-1.5",title:De||Te,children:Te}),c.jsxs("div",{"data-no-drag":!0,"data-panel-actions":!0,className:"shrink-0 flex items-center gap-0.5 pl-1 border-l border-border-default/60",children:[(s.kind==="file"||s.kind==="deliverable")&&c.jsxs("div",{ref:M,className:"relative shrink-0",children:[c.jsx("button",{type:"button",onClick:()=>q(de=>!de),title:m("common:browserHistoryRecent",{defaultValue:"最近访问"}),"aria-label":m("common:browserHistoryRecent",{defaultValue:"最近访问"}),"aria-haspopup":"listbox","aria-expanded":X,className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${X?"text-brand-500 bg-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),c.jsx("polyline",{points:"3 4 3 10 9 10"}),c.jsx("polyline",{points:"12 8 12 12 15 14"})]})}),X&&c.jsx(q_,{items:ie,query:"",activeIndex:-1,onHover:()=>{},onPick:de=>{q(!1),z_(de,{openPanel:$e?.openRightPanel})},onRemove:de=>pe(ey(op(de))),onClear:()=>{Jv(),q(!1)},anchorClassName:"right-0 top-full mt-1 w-72",keyboardHint:!1})]}),s.kind==="terminal"&&i&&c.jsx("button",{type:"button",onClick:()=>{ft()},title:m("common:addRecentOutput",{defaultValue:"Add recent output to chat"}),"aria-label":m("common:addRecentOutput",{defaultValue:"Add recent output to chat"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),dt&&c.jsx("button",{type:"button",onClick:jt,title:Dt?m("common:addedToChat",{defaultValue:"Added to chat"}):s.kind==="deliverable"?m("common:addDeliverableToChat",{defaultValue:"Add deliverable to chat"}):m("common:addFilePathToChat",{defaultValue:"Add file path to chat"}),"aria-label":s.kind==="deliverable"?m("common:addDeliverableToChat",{defaultValue:"Add deliverable to chat"}):m("common:addFilePathToChat",{defaultValue:"Add file path to chat"}),className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${Dt?"text-green-500 bg-green-500/10":"text-fg-tertiary hover:text-brand-500 hover:bg-brand-500/10"}`,children:Dt?c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}):c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h6"}),c.jsx("line",{x1:"17",y1:"3",x2:"17",y2:"9"}),c.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"})]})}),et&&c.jsxs("button",{type:"button",onClick:()=>E(!0),title:m("deliverables:share.title",{defaultValue:"分享到 Markus Hub"}),"aria-label":m("deliverables:share.title",{defaultValue:"分享到 Markus Hub"}),className:`relative w-7 h-7 flex items-center justify-center rounded-md transition-colors ${vt==="published"?"text-green-500 hover:text-green-400":vt==="pending_review"?"text-amber-500 hover:text-amber-400":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"18",cy:"5",r:"3"}),c.jsx("circle",{cx:"6",cy:"12",r:"3"}),c.jsx("circle",{cx:"18",cy:"19",r:"3"}),c.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),c.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),(vt==="published"||vt==="pending_review"||vt==="rejected")&&c.jsx("span",{className:`absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full border border-surface-primary ${vt==="published"?"bg-green-500":vt==="pending_review"?"bg-amber-500":"bg-red-500"}`,"aria-hidden":!0})]}),ze&&c.jsx("button",{type:"button",onClick:()=>{ye()},title:Ie,"aria-label":Ie,className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),c.jsx("polyline",{points:"15 3 21 3 21 9"}),c.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),ce&&c.jsx("button",{onClick:Xt,title:P?m("common:copied",{defaultValue:"Copied"}):m("common:copyPath",{defaultValue:"复制路径"}),"aria-label":m("common:copyPath",{defaultValue:"复制路径"}),className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${P?"text-green-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:P?c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}):c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),ce&&c.jsx("button",{onClick:_t,title:m("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),"aria-label":m("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),d&&c.jsx("button",{onClick:d,title:u?m("common:exitFullscreen",{defaultValue:"Exit fullscreen"}):m("common:fullscreen",{defaultValue:"Fullscreen"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:u?c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"4 14 10 14 10 20"}),c.jsx("polyline",{points:"20 10 14 10 14 4"}),c.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),c.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"15 3 21 3 21 9"}),c.jsx("polyline",{points:"9 21 3 21 3 15"}),c.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),c.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}),c.jsx("button",{onClick:()=>{_e()&&e()},title:m("common:collapsePanel",{defaultValue:"Hide panel"}),"aria-label":m("common:collapsePanel",{defaultValue:"Hide panel"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),c.jsxs("div",{className:`flex-1 min-w-0 min-h-0 ${x.mode==="url"||x.mode==="terminal"||x.mode==="office"||x.mode==="directory"||x.mode==="content"&&["code","json","text","markdown","html"].includes(x.format)?"overflow-hidden p-2 flex flex-col":"overflow-auto p-4"}`,children:[k&&x.mode!=="directory"&&x.mode!=="loading"&&c.jsx("div",{className:"shrink-0 mb-2",children:c.jsxs("button",{className:"inline-flex items-center gap-1 text-xs text-fg-secondary hover:text-brand-500 transition-colors cursor-pointer",onClick:()=>C(bI(Fe)),children:[c.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z",clipRule:"evenodd"})}),m("deliverables:detail.backToParentFolder")]})}),x.mode==="loading"&&c.jsxs("div",{className:"animate-pulse space-y-3",children:[c.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),c.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),c.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),c.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"})]}),x.mode==="image"&&c.jsxs("div",{className:"flex flex-col items-center gap-2",children:[c.jsx("img",{src:x.src,alt:x.name,className:"max-w-full rounded-lg object-contain"}),c.jsx("span",{className:"text-xs text-fg-tertiary",children:x.name})]}),x.mode==="audio"&&c.jsxs("div",{className:"flex flex-col items-stretch gap-3 py-6",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-12 h-12 rounded-xl bg-brand-500/15 text-brand-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M9 18V5l12-2v13"}),c.jsx("circle",{cx:"6",cy:"18",r:"3"}),c.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:x.name}),c.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[x.mimeType,x.size!=null?` · ${$f(x.size)}`:""]})]})]}),c.jsx("audio",{controls:!0,preload:"metadata",src:x.src,className:"w-full"})]}),x.mode==="video"&&c.jsxs("div",{className:"flex flex-col items-stretch gap-3",children:[c.jsx("video",{controls:!0,preload:"metadata",src:x.src,className:"w-full max-h-[70vh] rounded-lg bg-black"}),c.jsxs("span",{className:"text-xs text-fg-tertiary",children:[x.name,x.size!=null?` · ${$f(x.size)}`:""]})]}),x.mode==="binary"&&c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated text-fg-tertiary flex items-center justify-center shrink-0 text-xs font-mono uppercase",children:(x.extension||"file").replace(/^\./,"")||"file"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:x.name}),c.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[m("detail.cannotPreview",{type:"file",defaultValue:"This file type cannot be previewed."}),x.size!=null?` · ${$f(x.size)}`:""]})]})]}),x.reference&&c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("button",{onClick:()=>{ne.files.reveal(x.reference)},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",children:m("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"})})})]}),x.mode==="office"&&c.jsx("div",{ref:re,className:"flex-1 min-h-0 min-w-0 w-full",children:c.jsx(_C,{data:{format:x.format,streamUrl:x.streamUrl,name:x.name,size:x.size},reference:x.reference,onFallback:x.reference?()=>{ne.files.reveal(x.reference)}:void 0})}),x.mode==="content"&&(()=>{const de=De?De.replace(/[/\\][^/\\]+$/,""):void 0,we=De&&!go(De)?De:"",oe=x.format;return we&&(oe==="code"||oe==="json"||oe==="text")?c.jsx("div",{ref:re,className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:c.jsx(N_,{path:we,initialContent:x.content,language:xg(we,oe),onDirtyChange:I})}):we&&(oe==="markdown"||oe==="html")?c.jsx("div",{ref:re,className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:c.jsx(WD,{path:we,content:x.content,format:oe,basePath:de,onHtmlSelection:mt,onDirtyChange:I,copyVariant:"preview"})}):c.jsx("div",{ref:re,className:"min-w-0 max-w-full overflow-auto break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto [&_img]:max-w-full",children:c.jsx(Bf,{content:x.content,format:oe,className:"text-fg-secondary text-sm",onHtmlSelection:mt,basePath:de,copyVariant:"preview"})})})(),x.mode==="artifact"&&c.jsx("div",{ref:re,className:"min-w-0 max-w-full break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto [&_img]:max-w-full",children:c.jsx(Bf,{content:x.summary,format:"markdown",className:"text-fg-secondary text-sm",copyVariant:"preview"})}),x.mode==="url"&&c.jsx("div",{className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:c.jsx(JD,{url:x.url,browserId:x.browserId,className:"flex-1 min-h-0",onMeta:x.browserId&&f?de=>f(x.browserId,de):void 0},x.browserId||x.url)}),x.mode==="terminal"&&c.jsx("div",{className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:c.jsx(cI,{terminalId:x.terminalId,title:x.title,cwd:x.cwd,active:!0,apiRef:Y,onMeta:b,onOpenUrl:O,onOpenPath:g,onSelection:de=>{if(!de||!i){W(null);return}W({x:de.x,y:de.y,text:de.text})}},x.terminalId)}),x.mode==="directory"&&c.jsx(kC,{path:x.path,entries:x.entries,onNavigate:de=>C(de),onOpenFile:de=>C(de),onReveal:_t,onCopyPath:Xt}),x.mode==="unpreviewable"&&c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm text-fg-secondary",children:x.isDirectory?m("detail.cannotPreview",{type:"directory",defaultValue:"This item cannot be previewed here."}):m("detail.cannotPreview",{type:"file",defaultValue:"This file cannot be previewed here."})}),x.reference&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:_t,className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:m("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),children:x.reference}),c.jsx("button",{onClick:_t,className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:m("common:open",{defaultValue:"Open"})}),c.jsx("button",{onClick:Xt,className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${P?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:P?m("common:copied",{defaultValue:"Copied"}):m("common:copy",{defaultValue:"Copy"})})]})]})]},ve)]}),R&&i&&c.jsx("div",{id:"right-panel-selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full rounded-lg shadow-xl overflow-hidden border border-brand-400/40 bg-brand-600",style:{left:R.x,top:R.y-8},children:c.jsxs("button",{onMouseDown:de=>{de.preventDefault(),de.stopPropagation(),Ke(R.text,R.htmlMeta)},className:"px-3 py-1.5 text-xs font-medium text-on-brand hover:bg-brand-500 transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),m("deliverables:contextMenu.addToConversation",{defaultValue:"Add to conversation"})]})}),Q&&xe&&c.jsx(A2,{item:xe,onClose:()=>E(!1),onShared:gt})]})}function yI({members:s,candidates:e,currentUserId:t,memberCount:r,onClose:i,onRemoveMember:n,onAddMember:a}){const{t:o}=Tt(["team","common"]);return c.jsxs("div",{className:"bg-surface-secondary/80 px-4 py-3 flex flex-col gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-xs font-semibold text-fg-secondary",children:[o("page.members")," (",r,")"]}),c.jsx("button",{onClick:i,className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>c.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-[11px] font-medium ${l.type==="agent"?"bg-brand-500/10 text-brand-500":"bg-green-500/10 text-green-600"}`,children:[c.jsx(Is,{name:l.name,size:16,bgClass:l.type==="agent"?"bg-brand-500/15 text-brand-500":"bg-green-500/15 text-green-600"}),l.name,l.id!==t&&c.jsx("button",{onClick:()=>n(l.id),className:"ml-0.5 hover:text-red-500 transition-colors",title:o("common:remove"),children:c.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},l.id))}),e.length>0&&c.jsx("div",{className:"mt-1",children:c.jsxs("select",{className:"w-full bg-surface-primary border border-border-default rounded-lg px-2.5 py-1.5 text-xs text-fg-primary outline-none focus:ring-1 focus:ring-brand-500/50",value:"",onChange:l=>{l.target.value&&a(l.target.value)},children:[c.jsx("option",{value:"",children:o("page.addMemberPlaceholder")}),e.map(l=>c.jsxs("option",{value:l.id,children:["[",l.type==="agent"?"Agent":"Human","] ",l.name]},l.id))]})})]})}const SI={text:"page.findFieldText",thinking:"page.findFieldThinking",tool:"page.findFieldTool"},wI={text:"bg-brand-500/10 text-brand-500",thinking:"bg-amber-500/10 text-amber-600",tool:"bg-sky-500/10 text-sky-600"};function _I({match:s}){const e=s.snippet.slice(0,s.snippetMatchStart),t=s.snippet.slice(s.snippetMatchStart,s.snippetMatchStart+s.snippetMatchLength),r=s.snippet.slice(s.snippetMatchStart+s.snippetMatchLength);return c.jsxs("span",{className:"text-xs text-fg-secondary",children:[e,c.jsx("mark",{className:"bg-yellow-500/30 text-fg-primary rounded-[3px] px-0.5",children:t}),r]})}function kI({query:s,onQueryChange:e,matches:t,cursor:r,scanned:i,hasMore:n,loadingMore:a,truncated:o,onLoadEarlier:l,onJump:h,onClose:u,labelFor:d,serverResults:f,serverLoading:p,onServerResultClick:v}){const{t:b,i18n:O}=Tt(["team","common"]),g=w.useRef(null),m=w.useRef(null);w.useEffect(()=>{g.current?.focus()},[]),w.useEffect(()=>{if(r<0)return;m.current?.querySelector(`[data-find-idx="${r}"]`)?.scrollIntoView({block:"nearest"})},[r]);const x=k=>{if(t.length===0)return;const P=(((r<0?k>=0?-1:0:r)+k)%t.length+t.length)%t.length;h(P)},y=s.trim().length>0;return c.jsxs("div",{className:"border-b border-border-default bg-surface-secondary/60 px-4 py-2 space-y-1.5 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("div",{className:"flex-1 relative",children:[c.jsx("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-tertiary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),c.jsx("input",{ref:g,value:s,onChange:k=>e(k.target.value),onKeyDown:k=>{k.key==="Escape"?(k.preventDefault(),u()):k.key==="Enter"?(k.preventDefault(),x(k.shiftKey?-1:1)):k.key==="ArrowDown"?(k.preventDefault(),x(1)):k.key==="ArrowUp"&&(k.preventDefault(),x(-1))},placeholder:b("page.findPlaceholder"),className:"w-full pl-8 pr-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 transition-colors"})]}),c.jsx("span",{className:"text-[11px] text-fg-tertiary tabular-nums shrink-0 min-w-[44px] text-center",children:y&&t.length>0?b("page.findMatchCount",{current:(r<0?0:r)+1,total:t.length}):y?"0/0":""}),c.jsx("button",{onClick:()=>x(-1),disabled:t.length===0,title:b("page.findPrev"),className:"p-1 rounded-md text-fg-tertiary hover:text-fg-primary hover:bg-surface-elevated disabled:opacity-40 disabled:hover:bg-transparent transition-colors",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"18 15 12 9 6 15"})})}),c.jsx("button",{onClick:()=>x(1),disabled:t.length===0,title:b("page.findNext"),className:"p-1 rounded-md text-fg-tertiary hover:text-fg-primary hover:bg-surface-elevated disabled:opacity-40 disabled:hover:bg-transparent transition-colors",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})}),c.jsx("button",{onClick:u,title:b("page.findClose"),className:"p-1 rounded-md text-fg-tertiary hover:text-fg-primary hover:bg-surface-elevated transition-colors",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y&&c.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[c.jsx("span",{children:b("page.findScopeLoaded",{count:i})}),o&&c.jsx("span",{className:"text-amber-600",children:b("page.findTruncated",{count:t.length})}),t.length===0&&!n&&c.jsx("span",{className:"text-fg-secondary",children:b("page.findNoMatches")}),n&&c.jsx("button",{onClick:l,disabled:a,className:"ml-auto text-brand-500 hover:text-brand-500 disabled:opacity-50 underline decoration-dotted",children:b(a?"page.findLoadingEarlier":"page.findLoadEarlier")})]}),y&&t.length>0&&c.jsx("div",{ref:m,className:"max-h-52 overflow-y-auto scrollbar-thin space-y-0.5",children:t.map((k,C)=>c.jsxs("button",{"data-find-idx":C,onClick:()=>h(C),className:`w-full text-left px-2.5 py-1.5 rounded-lg transition-colors ${C===r?"bg-brand-500/15 ring-1 ring-brand-500/40":"hover:bg-surface-elevated"}`,children:[c.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[c.jsx("span",{className:`px-1.5 py-0 rounded text-[9px] font-medium shrink-0 ${wI[k.field]}`,children:b(SI[k.field])}),d&&c.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:d(k)})]}),c.jsx("div",{className:"line-clamp-2 break-words",children:c.jsx(_I,{match:k})})]},`${k.messageId}-${k.field}-${C}`))}),y&&(p||f&&f.length>0)&&c.jsxs("div",{className:"border-t border-border-default/60 mt-1 px-1",children:[c.jsx("div",{className:"text-[10px] text-fg-tertiary font-medium py-0.5",children:b("page.findServerResultsTitle")}),p&&c.jsx("div",{className:"text-xs text-fg-tertiary px-2.5 py-1",children:b("page.searching")}),f&&f.length>0&&c.jsx("div",{className:"max-h-40 overflow-y-auto scrollbar-thin space-y-0.5",children:f.map(k=>c.jsxs("button",{onClick:()=>v?.(k),className:"w-full text-left px-2.5 py-1.5 rounded-lg transition-colors hover:bg-surface-elevated",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-fg-tertiary mb-0.5 min-w-0",children:[c.jsx("span",{className:`px-1.5 py-0 rounded text-[9px] font-medium shrink-0 ${k.source==="channel"?"bg-blue-500/10 text-blue-500":"bg-emerald-500/10 text-emerald-500"}`,children:k.source==="channel"?"#":"1:1"}),c.jsx("span",{className:"truncate max-w-[9rem] text-fg-secondary font-medium",children:k.source==="channel"?k.channel?`#${k.channel}`:b("page.findServerResultsTitle"):k.sessionTitle||b("page.untitledSession")}),k.senderName&&c.jsx("span",{className:"truncate max-w-[6rem] shrink-0",children:k.senderName}),c.jsx("span",{className:"shrink-0 ml-auto tabular-nums",title:cp(k.createdAt,O.language),children:lp(k.createdAt,b)})]}),c.jsx("div",{className:"text-xs text-fg-secondary line-clamp-2 break-words",children:k.text.length>200?k.text.slice(0,200)+"…":k.text})]},k.id))})]})]})}const CI=300,PI=48;function TI(s){const e=[];if(s.segments&&s.segments.length>0){for(const t of s.segments)if(t.type==="text")t.thinking&&e.push({field:"thinking",value:t.thinking}),t.content&&e.push({field:"text",value:t.content});else if(t.type==="tool"){const r=[t.tool,t.result,t.error].filter(i=>!!i);r.length>0&&e.push({field:"tool",value:r.join(`
63
+ `)})}if(e.length>0)return e}return s.text&&e.push({field:"text",value:s.text}),e}function QI(s,e,t,r=PI){const i=Math.max(0,e-r),n=Math.min(s.length,e+t+r),a=i>0?"…":"",o=n<s.length?"…":"",l=s.slice(i,e).replace(/\s+/g," "),h=s.slice(e,e+t).replace(/\s+/g," "),u=s.slice(e+t,n).replace(/\s+/g," ");return{text:`${a}${l}${h}${u}${o}`,matchStart:a.length+l.length,matchLength:h.length}}function $I(s,e,t={}){const r=t.limit??CI,i=e.trim().toLocaleLowerCase();if(i.length===0)return{matches:[],scanned:s.length,truncated:!1};const n=[];for(let a=0;a<s.length;a+=1){const o=s[a];for(const{field:l,value:h}of TI(o)){const u=h.toLocaleLowerCase();let d=0;for(;;){const f=u.indexOf(i,d);if(f===-1)break;const p=QI(h,f,i.length);if(n.push({messageIndex:a,messageId:o.id,field:l,snippet:p.text,snippetMatchStart:p.matchStart,snippetMatchLength:p.matchLength}),n.length>=r)return{matches:n,scanned:s.length,truncated:!0};d=f+i.length}}}return{matches:n,scanned:s.length,truncated:!1}}function jI(s,e,t){if(s.length<=500)return s;const n=s.findIndex(o=>o.id===e);if(n<0)return s.slice(-500);const a=Math.max(0,Math.min(n-20,s.length-500));return s.slice(a,a+500)}async function RI(s){const{targetId:e,has:t,fetchPage:r,targetCreatedAt:i,maxPages:n=40}=s;if(t(e))return{found:!0,messages:[],hasMore:!0,oldestCursor:null,exhausted:!1};const a=i?Date.parse(i):Number.NaN;let o=[],l,h=!0,u=!1,d=!1;const f=()=>o.length>0?o[0].createdAt:null;for(let p=0;p<n;p++){let v;try{v=await r(l)}catch{return{found:!1,messages:o,hasMore:h,oldestCursor:f(),exhausted:!1}}const b=v?.messages??[];if(b.length===0){u=!0,h=!1;break}if(o=[...b,...o],h=!!v.hasMore,b.some(m=>m.id===e)){d=!0;break}if(!h){u=!0;break}const O=b[0],g=Date.parse(O.createdAt);if(Number.isFinite(a)&&Number.isFinite(g)&&g<a)break;l=O.createdAt}return{found:d,messages:o,hasMore:h,oldestCursor:f(),exhausted:u}}const EI="markus.scrollDebug";let jf=null,Rv=!1;function AI(){if(!Rv){try{jf=typeof localStorage<"u"&&localStorage.getItem(EI)==="1"}catch{jf=!1}Rv=!0}return jf===!0}function Xi(s,e){AI()&&console.info(`[scroll] ${s}`,{t:Math.round(performance.now()),...e??{}})}const Ev={urgent:0,high:1,normal:2,low:3};function Av(s){return Ev[s??"normal"]??Ev.normal}function MI(s){return[...s].sort((e,t)=>{const r=Av(e.priority)-Av(t.priority);return r!==0?r:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()})}function LI(s){const e=s.metadata?.agentId;return typeof e=="string"&&e?e:void 0}function Gm(s){const e=s.metadata??{};if(typeof e.sessionId=="string"&&e.sessionId)return e.sessionId;if(s.actionType==="open_chat"&&s.actionTarget)try{const t=typeof s.actionTarget=="string"?JSON.parse(s.actionTarget):s.actionTarget;if(t&&typeof t=="object"&&typeof t.sessionId=="string")return t.sessionId}catch{}}function NI(s,e){return e?MI(s.filter(t=>!t.read&&t.type==="agent_report"&&!t.metadata?.creditExhausted&&LI(t)===e)):[]}const Mv={sessionId:null,messageId:null};function DI(s){if(s.length===0)return Mv;const e=new Set(s.map(Gm).filter(n=>!!n));if(e.size!==1||s.some(n=>!Gm(n)))return Mv;const t=[...e][0],i=[...s].sort((n,a)=>new Date(n.createdAt).getTime()-new Date(a.createdAt).getTime()).map(n=>n.metadata?.messageId).find(n=>typeof n=="string"&&n.length>0)??null;return{sessionId:t,messageId:i}}const F_={system_event:{icon:"⚙",category:"system"},human_chat:{icon:"💬",category:"interaction"},task_comment:{icon:"💬",category:"task"},mention:{icon:"@",category:"interaction"},session_reply:{icon:"↩",category:"task"},task_status_update:{icon:"📋",category:"task"},a2a_message:{icon:"🔗",category:"interaction"},review_request:{icon:"👀",category:"task"},requirement_comment:{icon:"💬",category:"task"},requirement_update:{icon:"📝",category:"notification"},daily_report:{icon:"📊",category:"system"},heartbeat:{icon:"♡",category:"system"},memory_consolidation:{icon:"🧠",category:"system"},workflow_update:{icon:"🔄",category:"task"},callback_result:{icon:"↩",category:"system"},external_signal:{icon:"📡",category:"notification"}};function zc(s){return s?F_[s]?.icon??"●":"●"}["interaction","task","notification","system"].reduce((s,e)=>(s[e]=Object.entries(F_).filter(([,t])=>t.category===e).map(([t])=>t),s),{});const II=Object.freeze([{key:"all",dot:""},{key:"queued",dot:"bg-amber-400"},{key:"processing",dot:"bg-blue-400"},{key:"completed",dot:"bg-green-500"},{key:"merged",dot:"bg-brand-400"},{key:"deferred",dot:"bg-purple-400"},{key:"bounced",dot:"bg-red-500"},{key:"catch_all",dot:"bg-red-700"}]);function Rf(s){return!s||s==="all"?void 0:s}const BI=[{id:"files",prefixes:["file_read","file_write","file_edit","apply_patch"]},{id:"search",prefixes:["grep_search","glob_find","list_directory"]},{id:"runtime",prefixes:["shell_execute","background_exec","process"]},{id:"terminal",prefixes:["terminal__","list_terminals","new_terminal","select_terminal","close_terminal","read_terminal","write_terminal","exec_terminal"]},{id:"web",prefixes:["web_search","web_fetch","web_extract"]},{id:"multimodal",prefixes:["generate_image","text_to_speech","speech_to_text","generate_video","describe_image","upload_reference"]},{id:"browser",prefixes:["navigate_page","new_page","close_page","select_page","list_pages","open_page","resize_page","click","hover","fill","fill_form","type_text","press_key","take_screenshot","take_snapshot","evaluate_script","wait_for","list_console_messages","list_network_requests","get_console_message","get_network_request","lighthouse_audit","drag","upload_file","emulate","handle_dialog"]},{id:"tasks",prefixes:["task_create","task_list","task_update","task_get","task_assign","task_note","task_comment","task_submit_review","task_request_approval","subtask_create","subtask_complete","subtask_cancel","subtask_list","task_check_duplicates","task_cleanup_duplicates","task_board_health","create_task","update_task","add_task_note","create_subtask"]},{id:"requirements",prefixes:["requirement_propose","requirement_list","requirement_get","requirement_update","requirement_update_status","requirement_resubmit","requirement_comment"]},{id:"projects",prefixes:["list_projects","get_project","create_project","update_project","delete_project","project_stats","project_structure","code_stats","git_"]},{id:"deliverables",prefixes:["deliverable_create","deliverable_search","deliverable_list","deliverable_update","office_generate"]},{id:"packages",prefixes:["package_list","package_install","hub_search","hub_install","builder_list","builder_install","markus-hub__"]},{id:"communication",prefixes:["agent_send_message","agent_ask_agent","agent_list_colleagues","agent_send_group_message","agent_create_group_chat","agent_list_group_chats","agent_broadcast_status","agent_delegate_task","feishu_"]},{id:"memory",prefixes:["memory_","recall_context","recall_activity","notebook_upsert","notebook_clear","notebook_read","session"]},{id:"knowledge",prefixes:["kb_search","kb_list","kb_read"]},{id:"mailbox",prefixes:["check_mailbox","defer_mailbox_item","drop_mailbox_item","prioritize_mailbox_item","delegate_message","bind_address","address_revoke","address_list","message_route","catch_all","external_source_register","external_source_list","external_source_toggle","rest","list_waits","cancel_wait"]},{id:"planning",prefixes:["goal_create","goal_update","goal_status","workflow_"]},{id:"reasoning",prefixes:["decide","fact_"]},{id:"teamManager",prefixes:["team_list","team_status","team_update","team_start","team_stop","agent_update","agent_start","agent_stop","list_teams"]},{id:"subagents",prefixes:["spawn_subagent","spawn_subagents","invoke_coding_tool","coding_tool_apply"]},{id:"system",prefixes:["work_status","discover_tools","notify_user","request_user_input","request_user_approval","schedule_wakeup","cancel_wakeup","set_heartbeat_interval","org_info","org_list","org_usage"]},{id:"llm",prefixes:["llm_","agent_model_"]}];function WI(s,e){const t=new Map,r=new Set;for(const{id:a,prefixes:o}of BI){const l=e(`agent:toolCategories.${a}`),h=s.filter(u=>!r.has(u.name)&&o.some(d=>u.name.startsWith(d)));h.length>0&&(t.set(l,h),h.forEach(u=>r.add(u.name)))}const i=s.filter(a=>!r.has(a.name));for(const a of i){const o=a.name.indexOf("__");if(o>0){const l=a.name.slice(0,o),h=e("agent:toolCategories.mcp",{server:l});t.has(h)||t.set(h,[]),t.get(h).push(a),r.add(a.name)}}const n=s.filter(a=>!r.has(a.name));return n.length>0&&t.set(e("agent:toolCategories.other"),n),[...t.entries()].map(([a,o])=>({category:a,tools:o}))}function XI(s){return!s.agentRunning||s.itemStatus!=="processing"||!s.currentFocusId?!1:s.currentFocusId===s.itemId}function zI({itemStatus:s,agentRunning:e,currentFocusMailboxItemId:t,itemId:r}){return s!=="processing"?s:e&&t===r?"processing":"stale"}const qI=[/^Comment on task "(.+?)" from (.+)$/,/^Comment on requirement "(.+?)" from (.+)$/];function Lv(s){if(!s)return null;for(const e of qI){const t=e.exec(s);if(t)return{subject:t[1],author:t[2]}}return null}const U_=16;function ZI(s,e,t=U_){const r=s??[];return r.length<=t?{visible:[...r],hiddenCount:0,collapsible:!1}:e?{visible:[...r],hiddenCount:0,collapsible:!0}:{visible:r.slice(0,t),hiddenCount:r.length-t,collapsible:!0}}function VI(s,e=Date.now()){const t=Math.max(0,e-(Number.isFinite(s)?s:e));return t<6e4?{unit:"seconds",count:Math.round(t/1e3)}:t<36e5?{unit:"minutes",count:Math.round(t/6e4)}:{unit:"hours",count:Math.round(t/36e5*10)/10}}function H_(s,e={}){const{enabled:t=!0,deps:r=[]}=e,[i,n]=w.useState(mu()),[a,o]=w.useState(0),l=w.useRef(s);l.current=s;const h=JSON.stringify(r);w.useEffect(()=>{if(!t){n(mu());return}let d=!1;return n(mu()),(async()=>{const f=await CC(()=>l.current());d||n(f)})(),()=>{d=!0}},[t,h,a]);const u=w.useCallback(()=>o(d=>d+1),[]);return{resource:i,view:PC(i),reload:u}}const FI=w.lazy(()=>ry(()=>import("./MarkdownMessage-CaLBeMto.js"),__vite__mapDeps([0,1,2])).then(s=>({default:s.MarkdownMessage}))),Ef=new Map,Af=new Map,Y_=s=>{s.size>4e3&&s.clear()},UI=s=>{if(!s)return"";const e=Ef.get(s);if(e!==void 0)return e;Y_(Ef);const t=new Date(s).toLocaleString();return Ef.set(s,t),t},HI=s=>{if(!s)return"";const e=Af.get(s);if(e!==void 0)return e;Y_(Af);const t=new Date(s).toLocaleTimeString();return Af.set(s,t),t},dh={mind:"run",files:"settings",tools:"settings",memory:"memory"},bg=[{key:"overview",icon:"▦"},{key:"deliverables",icon:"📦"}];function YI(s,e){const{labelKey:t}=vl(s);return t?e(t):s}function Km(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Nv({agentId:s,onBack:e,inline:t,defaultTab:r,onSwipeBack:i,highlightMailboxId:n,authUser:a,headless:o,activeTab:l,initialSection:h}){const{t:u}=Tt(["agent","common"]),d=rp(),[f,p]=w.useState(null),[v,b]=w.useState(null),[O,g]=w.useState(r??"overview"),m=o&&l?l:O,[x,y]=w.useState(null),k=w.useMemo(()=>bg.map(Z=>({...Z,label:u(`agent:tabs.${Z.key}`)})),[u]),C=w.useMemo(()=>k.map(Z=>({id:Z.key})),[k]),P=w.useMemo(()=>({onSwipeOutLeft:i}),[i]),_=TC(C,O,g,P),Q=w.useRef(null);w.useEffect(()=>{const Z=Q.current;if(!Z)return;Z.querySelector('[data-active="true"]')?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[O]);const E=w.useCallback(()=>{ne.agents.get(s).then(p).catch(()=>{})},[s]);if(w.useEffect(()=>(g(r??"overview"),y(null),E(),ne.externalAgents.list().then(B=>{const K=B.agents.find($=>$.markusAgentId===s);y(K??null)}).catch(()=>{}),Rt.on("agent:update",B=>{B.payload.agentId===s&&E()})),[s,E]),!f)return c.jsx(ay,{label:u("agent:profilePage.loadingAgent")});const A=vl(f.state.status).dotClass,N=a?.role==="owner"||a?.role==="admin",R=Z=>h??dh[Z],W=Z=>x||dh[Z]?"overview":Z,H=dh[O];return o?c.jsx("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:c.jsxs("div",{className:"p-5",children:[W(m)==="overview"&&c.jsx(Dv,{agent:f,externalInfo:x,t:u,canManageAgents:N,highlightMailboxId:n,initialSection:R(m)}),W(m)==="deliverables"&&c.jsx(qv,{agentId:s})]})}):c.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[c.jsxs("div",{className:"px-5 py-3.5 bg-surface-secondary sticky top-0 z-10",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Is,{name:f.name,avatarUrl:f.avatarUrl,size:40,className:"rounded-xl"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("h2",{className:"text-base font-semibold",children:f.name}),c.jsx("span",{className:`w-2 h-2 rounded-full ${A}`}),c.jsx("span",{className:"text-xs text-fg-tertiary",children:YI(f.state.status,u)}),x&&c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:u("agent:profilePage.badges.external")}),f.agentRole==="manager"&&c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/15 text-amber-600 rounded font-medium",children:u("agent:profilePage.badges.manager")})]}),c.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[f.role,f.roleDescription?` — ${f.roleDescription}`:""]})]}),c.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[!t&&c.jsxs("button",{onClick:()=>gr.navigate(Ut.TEAM,{agentId:s}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors flex items-center gap-1",children:[c.jsx("span",{children:"◈"})," ",u("agent:profilePage.chat")]}),N&&c.jsxs("button",{onClick:async()=>{if(f)try{const{filesMap:Z}=await ne.agents.getFilesMap(s),B={type:"agent",name:ty(f.name,f.name),displayName:f.name,version:"1.0.0",description:f.roleDescription??f.role,author:"",category:"general",tags:[],agent:{roleName:f.role,agentRole:f.agentRole},dependencies:{skills:f.skills??[]}};await ap.publishViaProxy({itemType:"agent",name:f.name,description:B.description,category:"general",config:B,files:Z}),b({title:u("agent:profilePage.hub"),message:u("agent:profilePage.publishSuccess",{name:f.name}),variant:"primary"})}catch(Z){b({title:u("agent:profilePage.hub"),message:u("agent:profilePage.publishFailed",{error:String(Z)}),variant:"danger"})}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:u("agent:profilePage.publishTitle"),children:[c.jsx("span",{children:"↑"})," ",u("agent:profilePage.hub")]}),t&&c.jsx("button",{onClick:e,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),c.jsx("div",{ref:Q,className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto scrollbar-hide",children:k.filter(Z=>!x||Z.key==="overview").map(Z=>c.jsxs("button",{onClick:()=>g(Z.key),"data-active":O===Z.key,className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${O===Z.key?"bg-surface-primary text-fg-primary border-border-default":"text-fg-tertiary border-transparent hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[c.jsx("span",{className:"mr-1",children:Z.icon}),Z.label]},Z.key))})]}),c.jsxs("div",{className:"p-5",onTouchStart:d?_.onTouchStart:void 0,onTouchEnd:d?_.onTouchEnd:void 0,children:[W(O)==="overview"&&c.jsx(Dv,{agent:f,externalInfo:x,t:u,canManageAgents:N,highlightMailboxId:n,initialSection:h??H}),W(O)==="deliverables"&&c.jsx(qv,{agentId:s})]}),v&&c.jsx(qo,{alertOnly:!0,variant:v.variant??"primary",title:v.title,message:v.message,onConfirm:()=>b(null),onCancel:()=>b(null)})]})}function GI({section:s,onChange:e,t}){return c.jsx("div",{role:"tablist",className:"flex border-b border-border-default overflow-x-auto scrollbar-hide",onTouchStart:r=>r.stopPropagation(),onTouchEnd:r=>r.stopPropagation(),children:dp.map(r=>{const i=r===s,n=t(`agent:profilePage.overview.sections.${r}.hint`,{defaultValue:""});return c.jsx("button",{type:"button",role:"tab","aria-selected":i,title:n||void 0,onClick:()=>e(r),className:`px-3 py-2 text-xs whitespace-nowrap border-b-2 transition-colors cursor-pointer ${i?"border-brand-500 text-fg-primary font-medium":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:t(`agent:profilePage.overview.sections.${r}.title`)},r)})})}function qc({children:s}){return c.jsx("div",{role:"tabpanel",className:"border border-border-default rounded-xl bg-surface-elevated/30 p-4",children:s})}function Dv({agent:s,externalInfo:e,t,canManageAgents:r,highlightMailboxId:i,initialSection:n}){const[a,o]=w.useState(null),[l,h]=w.useState([]),[u,d]=w.useState(null),[f,p]=w.useState(null),[v,b]=w.useState(""),[O,g]=w.useState([]),[m,x]=w.useState(0),[y,k]=w.useState(!1),[C,P]=w.useState(!1),[_,Q]=w.useState(()=>y0(n,i));w.useEffect(()=>{Q(y0(n,i))},[n,i]);const E=(s.state.activeTaskIds??[]).join(",");w.useEffect(()=>{ne.usage.agents().then($=>{const I=$.agents.find(X=>X.agentId===s.id);I&&o(I)}).catch(()=>{}),s.state.activeTaskIds?.length&&ne.tasks.list({assignedAgentId:s.id}).then($=>{g($.tasks.filter(I=>s.state.activeTaskIds?.includes(I.id)))}).catch(()=>{}),ne.agents.getMailbox(s.id,{limit:1}).then($=>{x($.queued?.length??0)}).catch(()=>{})},[s.id,E,s.state.status]);const A=w.useCallback(async()=>{if(!y){k(!0);try{const $=await ne.agents.storage(s.id);b($.dataDir),p({size:$.size,subItems:$.subItems??[],depthLimited:$.depthLimited})}catch{}finally{k(!1)}}},[s.id,y]);w.useEffect(()=>{if(_!=="run")return;let $=!1;return P(!0),ne.agents.getActivities(s.id,{limit:FP}).then(I=>{$||h(I.activities)}).catch(()=>{}).finally(()=>{$||P(!1)}),()=>{$=!0}},[_,s.id]);const N=w.useMemo(()=>[{method:"POST",path:"/api/gateway/sync",desc:t("agent:profilePage.gateway.sync")},{method:"GET",path:"/api/gateway/manual",desc:t("agent:profilePage.gateway.manual")},{method:"GET",path:"/api/gateway/team",desc:t("agent:profilePage.gateway.team")},{method:"GET",path:"/api/gateway/projects",desc:t("agent:profilePage.gateway.projects")},{method:"GET",path:"/api/gateway/requirements",desc:t("agent:profilePage.gateway.requirements")}],[t]),R=w.useMemo(()=>[{field:"assignedTasks",desc:t("agent:profilePage.syncContext.assignedTasks")},{field:"inboxMessages",desc:t("agent:profilePage.syncContext.inboxMessages")},{field:"teamContext",desc:t("agent:profilePage.syncContext.teamContext")},{field:"projectContext",desc:t("agent:profilePage.syncContext.projectContext")}],[t]);if(e)return c.jsxs("div",{className:"space-y-4",children:[c.jsx(pr,{title:t("agent:profilePage.overview.identity"),children:c.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[c.jsx(Ls,{label:t("agent:profilePage.overview.labels.name"),children:s.name}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.agentRole"),children:c.jsx("span",{className:s.agentRole==="manager"?"text-amber-600":"text-blue-600",children:s.agentRole==="manager"?t("agent:profilePage.roles.managerDisplay"):t("agent:profilePage.roles.workerDisplay")})}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.roleTemplate"),children:s.role}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.markusAgentId"),mono:!0,children:s.id}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.organization"),children:s.config?.orgId??"default"}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.created"),children:s.config?.createdAt?new Date(s.config.createdAt).toLocaleDateString():t("agent:profilePage.emDash")})]})}),c.jsx(pr,{title:t("agent:profilePage.overview.connectionStatus"),children:c.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[c.jsx(di,{label:t("agent:profilePage.overview.labels.connection"),value:QC(e.connected?"online":"offline",t),color:e.connected?"green":"gray"}),c.jsx(di,{label:t("agent:profilePage.overview.labels.platform"),value:t("agent:profilePage.overview.openClaw")}),c.jsx(di,{label:t("agent:profilePage.overview.labels.activeTasks"),value:String(s.state.activeTaskIds?.length??0)}),c.jsx(di,{label:t("agent:profilePage.overview.labels.lastSync"),value:e.lastHeartbeat?new Date(e.lastHeartbeat).toLocaleTimeString():t("agent:profilePage.never")})]})}),c.jsx(pr,{title:t("agent:profilePage.overview.externalAgentDetails"),children:c.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[c.jsx(Ls,{label:t("agent:profilePage.overview.labels.externalAgentId"),mono:!0,children:e.externalAgentId}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.registered"),children:new Date(e.registeredAt).toLocaleString()}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.capabilities"),children:e.capabilities.length>0?e.capabilities.join(", "):t("agent:profilePage.overview.noneDeclared")}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.lastHeartbeat"),children:e.lastHeartbeat?new Date(e.lastHeartbeat).toLocaleString():t("agent:profilePage.never")})]})}),c.jsx(pr,{title:t("agent:profilePage.overview.syncContextTitle"),children:c.jsx("div",{className:"space-y-1.5",children:R.map($=>c.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated",children:[c.jsx("span",{className:"font-mono text-[10px] text-brand-500 shrink-0 pt-0.5",children:$.field}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:$.desc})]},$.field))})}),c.jsx(pr,{title:t("agent:profilePage.overview.gatewayEndpoints"),children:c.jsx("div",{className:"space-y-1.5",children:N.map($=>c.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated",children:[c.jsx("span",{className:`text-[10px] font-semibold shrink-0 pt-0.5 ${$.method==="POST"?"text-amber-600":"text-green-600"}`,children:$.method}),c.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:$.path}),c.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:$.desc})]},$.path))})})]});const{heartbeats:W,comms:H}=UP(l),Z=v0(W),B=v0(H),K=s.state.activeTaskIds?.length??0;return[l.length>0?t("agent:profilePage.overview.recentWindow",{count:l.length}):null,Z.total>0?t("agent:profilePage.overview.heartbeatRuns",{count:Z.total}):null,B.total>0?t("agent:profilePage.overview.a2aRuns",{count:B.total}):null].filter(Boolean).join(" · "),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"bg-surface-elevated rounded-xl px-4 py-3 flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[c.jsx(Ls,{label:t("agent:profilePage.overview.labels.roleTemplate"),children:s.role}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.agentRole"),children:c.jsx("span",{className:s.agentRole==="manager"?"text-amber-600":"text-blue-600",children:s.agentRole==="manager"?t("agent:profilePage.roles.managerDisplay"):t("agent:profilePage.roles.workerDisplay")})}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.agentId"),mono:!0,children:s.id}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.model"),children:s.effectiveModel?.model?c.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c.jsx("span",{className:"font-mono",children:s.effectiveModel.model}),s.config?.llmConfig?.modelMode==="custom"&&s.effectiveModel.source!=="override"?c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:t("agent:profilePage.overview.labels.badgeAgentModel")}):s.effectiveModel.source==="override"?c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/15 text-amber-600 rounded font-medium",children:t("agent:profilePage.overview.labels.badgeSessionModel")}):null]}):c.jsx("span",{className:"text-fg-tertiary",children:t("agent:profilePage.overview.labels.followsGlobal")})}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.tokensToday"),children:Km(XP(a,s.state.tokensUsedToday))}),c.jsx(Ls,{label:t("agent:profilePage.overview.labels.created"),children:s.config?.createdAt?new Date(s.config.createdAt).toLocaleDateString():t("agent:profilePage.emDash")})]}),(s.state.status==="error"||s.state.status==="working"&&(K>0||m>0||s.runtime?.activityLabel))&&c.jsxs("div",{className:"bg-surface-elevated rounded-xl px-4 py-3 space-y-3",children:[s.state.status==="error"&&c.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:"text-xs font-medium text-red-500",children:t("agent:profilePage.overview.errorDetails")}),s.state.lastErrorAt&&c.jsx("span",{className:"text-[10px] text-red-500/50 ml-auto",children:new Date(s.state.lastErrorAt).toLocaleString()})]}),c.jsx("pre",{className:"text-[11px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono bg-red-500/5 rounded p-2",children:c.jsx(ny,{text:fh(s.state.lastError,t)||s.state.lastError||t("agent:profilePage.overview.errorFallback")})})]}),s.state.status==="working"&&(K>0||m>0||s.runtime?.activityLabel)&&c.jsx("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg p-2.5",children:c.jsxs("div",{className:"space-y-1.5",children:[s.runtime?.activityLabel&&c.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),c.jsx("span",{className:"text-fg-secondary truncate flex-1",children:s.runtime.activityLabel}),s.runtime.activityType&&c.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:s.runtime.activityType})]}),O.map($=>c.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),c.jsx("span",{className:"text-fg-secondary truncate flex-1",children:$.title}),c.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:Df($.status,t,$.blockedReason)})]},$.id)),m>0&&c.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),c.jsx("span",{className:"text-fg-secondary flex-1",children:t("agent:profilePage.overview.mailboxQueued",{count:m})})]})]})})]}),c.jsx(GI,{section:_,onChange:Q,t}),_==="settings"&&c.jsx(qc,{children:c.jsx(t3,{agentId:s.id})}),_==="settings"&&c.jsx(qc,{children:c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.overview.lifetimeCaption")}),a?c.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[c.jsx(di,{label:t("agent:profilePage.overview.labels.totalTokens"),value:Km(a.totalTokens)}),c.jsx(di,{label:t("agent:profilePage.overview.labels.requests"),value:String(a.requestCount)}),c.jsx(di,{label:t("agent:profilePage.overview.labels.toolCalls"),value:String(a.toolCalls)})]}):c.jsx("p",{className:"text-xs text-fg-tertiary",children:t("agent:profilePage.overview.sections.usage.empty")})]}),c.jsxs("div",{className:"border-t border-border-subtle pt-2 space-y-1",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.overview.storageLabel","磁盘占用")}),f?c.jsxs(c.Fragment,{children:[c.jsx(di,{label:t("agent:profilePage.overview.storage"),value:Mf(f.size)}),pc(f.subItems).slice(0,4).map($=>{const I=qP($.name);return c.jsx(di,{label:I?t(I):$.name,value:Mf($.size)},$.name)}),pc(f.subItems).length>4&&c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.overview.storageMore",{count:pc(f.subItems).length-4,size:Mf(pc(f.subItems).slice(4).reduce(($,I)=>$+I.size,0))})}),c.jsxs("button",{onClick:()=>{ne.system.openPath(v)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary",children:[t("agent:profilePage.overview.openFolder")," →"]})]}):c.jsx("button",{onClick:()=>{A()},disabled:y,className:"text-[11px] px-2 py-1 rounded border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50",children:y?t("agent:profilePage.overview.storageLoading","读取中…"):t("agent:profilePage.overview.storageScanBtn","查看磁盘占用")})]}),f?.depthLimited&&c.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.overview.storageDepthLimited")})]}),c.jsxs("div",{className:"border-t border-border-subtle pt-2 space-y-1",children:[c.jsx("button",{type:"button",onClick:()=>gr.navigate(Ut.TEAM,{agentId:s.id,preferMain:"1",prefillMessage:t("agent:profilePage.overview.cleanupPrefill",{name:s.name,defaultValue:`请检查你自己的数据(工作区、日志、会话历史、记忆归档),列出一份「可以安全清理」的清单与理由。
64
+ 不确定的项先问我,不要自行删除;我确认后你再动手。`})}),className:"text-[11px] px-2 py-1 rounded border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40",children:t("agent:profilePage.overview.cleanupCta","让 Agent 清理数据")}),c.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.overview.cleanupHint","会在聊天里预填指令,发送与否由你决定;Agent 拿不准时会先问你。")})]})]})}),_==="run"&&c.jsx(qc,{children:c.jsx(p3,{agentId:s.id,highlightId:i,agentStatus:s.state.status,canManageAgents:r})}),_==="settings"&&c.jsxs("details",{className:"mt-4 border border-border-default rounded-xl bg-surface-elevated/30",children:[c.jsx("summary",{className:"cursor-pointer px-4 py-3 text-xs font-medium text-fg-secondary select-none",children:t("agent:profilePage.overview.capabilityCollapsed","能力(工具与技能)— 点开查看")}),c.jsx("div",{className:"px-4 pb-4",children:c.jsx(o3,{tools:s.tools??[],agent:s})})]}),_==="memory"&&c.jsx(qc,{children:c.jsx(a3,{agentId:s.id})})]})}function KI(s,e){const t=s.split(`
65
+ `),r=e.split(`
66
+ `),i=t.length,n=r.length,a=Array.from({length:i+1},()=>new Array(n+1).fill(0));for(let f=i-1;f>=0;f--)for(let p=n-1;p>=0;p--)a[f][p]=t[f]===r[p]?a[f+1][p+1]+1:Math.max(a[f+1][p],a[f][p+1]);const o=[];let l=0,h=0,u=1,d=1;for(;l<i||h<n;)l<i&&h<n&&t[l]===r[h]?(o.push({type:"equal",content:t[l],oldLineNum:u++,lineNum:d++}),l++,h++):h<n&&(l>=i||a[l][h+1]>=a[l+1][h])?(o.push({type:"add",content:r[h],lineNum:d++}),h++):(o.push({type:"remove",content:t[l],oldLineNum:u++}),l++);return o}function Iv(s){return s.match(/\S+|\s+/g)??[""]}function Bv({oldText:s,newText:e,mode:t}){const r=Iv(s),i=Iv(e),n=r.length,a=i.length,o=Array.from({length:n+1},()=>new Array(a+1).fill(0));for(let d=n-1;d>=0;d--)for(let f=a-1;f>=0;f--)o[d][f]=r[d]===i[f]?o[d+1][f+1]+1:Math.max(o[d+1][f],o[d][f+1]);const l=[];let h=0,u=0;for(;h<n||u<a;)h<n&&u<a&&r[h]===i[u]?(l.push({text:t==="remove"?r[h]:i[u],changed:!1}),h++,u++):u<a&&(h>=n||o[h][u+1]>=o[h+1][u])?(t==="add"&&l.push({text:i[u],changed:!0}),u++):(t==="remove"&&l.push({text:r[h],changed:!0}),h++);return c.jsx("span",{children:l.map((d,f)=>d.changed?c.jsx("span",{className:t==="add"?"bg-green-500/30 rounded-sm":"bg-red-500/30 rounded-sm",children:d.text},f):c.jsx("span",{children:d.text},f))})}function JI({agent:s,template:e,templateId:t}){const{t:r}=Tt(["agent","common"]),i=w.useMemo(()=>KI(s,e),[s,e]),[n,a]=w.useState(!0),o=3,l=w.useMemo(()=>{const p=i.map((g,m)=>g.type!=="equal"?m:-1).filter(g=>g>=0);if(p.length===0)return[];const v=[];let b=Math.max(0,p[0]-o),O=Math.min(i.length-1,p[0]+o);for(let g=1;g<p.length;g++){const m=Math.max(0,p[g]-o),x=Math.min(i.length-1,p[g]+o);m<=O+1||(v.push({start:b,end:O}),b=m),O=x}return v.push({start:b,end:O}),v},[i]),h=(p,v,b)=>{const O=p.type==="add"?"+":p.type==="remove"?"-":" ",g=p.type==="add"?"bg-green-500/8":p.type==="remove"?"bg-red-500/8":"",m=p.type==="add"?"text-green-600/90":p.type==="remove"?"text-red-500/80":"text-fg-tertiary",x=p.type==="add"?"text-green-500":p.type==="remove"?"text-red-500":"text-fg-muted",y=p.type==="remove"?p.oldLineNum:p.lineNum;let k=null;return p.type==="remove"&&v+1<b.length&&b[v+1].type==="add"?k=c.jsx(Bv,{oldText:p.content,newText:b[v+1].content,mode:"remove"}):p.type==="add"&&v>0&&b[v-1].type==="remove"&&(k=c.jsx(Bv,{oldText:b[v-1].content,newText:p.content,mode:"add"})),c.jsxs("div",{className:`flex ${g} hover:brightness-95 transition-colors`,children:[c.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-[10px] text-fg-muted/50 select-none leading-[20px]",children:y??""}),c.jsx("span",{className:`w-4 shrink-0 text-center text-[11px] font-mono ${x} select-none leading-[20px]`,children:O}),c.jsxs("span",{className:`flex-1 text-[11px] font-mono ${m} whitespace-pre-wrap break-words leading-[20px]`,children:[k??p.content,p.content===""&&" "]})]},v)},u=i.filter(p=>p.type==="add").length,d=i.filter(p=>p.type==="remove").length,f=n?l.flatMap(p=>{const v=[];for(let b=p.start;b<=p.end;b++)v.push({...i[b],_idx:b});return v}):i.map((p,v)=>({...p,_idx:v}));return c.jsxs("div",{className:"mb-3 bg-surface-elevated rounded-lg overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-elevated",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("span",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:r("agent:profilePage.diff.title",{templateId:t})}),c.jsxs("span",{className:"text-[10px] text-green-500 font-mono",children:["+",u]}),c.jsxs("span",{className:"text-[10px] text-red-500 font-mono",children:["-",d]})]}),c.jsx("button",{onClick:()=>a(p=>!p),className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:r(n?"agent:profilePage.diff.showFullFile":"agent:profilePage.diff.showChangesOnly")})]}),c.jsxs("div",{className:"max-h-72 overflow-y-auto bg-surface-primary/50",children:[n&&l.length>0&&l[0].start>0&&c.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-b border-border-default/30",children:r("agent:profilePage.diff.linesHidden",{count:l[0].start})}),f.map((p,v)=>{const b=v>0?f[v-1]:null,O=n&&b&&p._idx-b._idx>1;return c.jsxs("div",{children:[O&&c.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-y border-border-default/30",children:"···"}),h(p,p._idx,i)]},v)}),n&&l.length>0&&l[l.length-1].end<i.length-1&&c.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-t border-border-default/30",children:r("agent:profilePage.diff.linesHidden",{count:i.length-1-l[l.length-1].end})}),l.length===0&&c.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:r("agent:profilePage.diff.identical")})]})]})}function e3(s,e){const t=s.split(`
67
+ `),r=e.split(`
68
+ `),i=[],n=Math.max(t.length,r.length);for(let a=0;a<n;a++){const o=t[a],l=r[a];if(o===l){i.push(` ${o??""}`);continue}o!==void 0&&(l===void 0||o!==l)&&i.push(`- ${o}`),l!==void 0&&(o===void 0||o!==l)&&i.push(`+ ${l}`)}if(i.length>80){const a=i.filter(o=>o.startsWith("+ ")||o.startsWith("- "));if(a.length>0)return a.join(`
69
+ `)}return i.join(`
70
+ `)}function t3({agentId:s}){const{t:e}=Tt(["agent","common"]),[t,r]=w.useState([]),[i,n]=w.useState(!0),[a,o]=w.useState(null),[l,h]=w.useState(""),[u,d]=w.useState(""),[f,p]=w.useState(!1);w.useEffect(()=>{ne.system.info().then(Z=>{d(Z.dataDir+"/agents/"+s+"/role")}).catch(()=>{})},[s]);const[v,b]=w.useState(!1),[O,g]=w.useState(!1),[m,x]=w.useState(null),[y,k]=w.useState(null),C=w.useCallback(()=>{n(!0),Promise.all([ne.agents.getFiles(s),ne.agents.roleStatus(s).catch(()=>null)]).then(([Z,B])=>{r(Z.files),x(B),Z.files.length>0&&!a&&(o(null),h(""))}).catch(()=>{}).finally(()=>n(!1))},[s]);w.useEffect(()=>{C()},[C]);const P=Z=>{const B=t.find(K=>K.name===Z);B&&(o(Z),h(B.content),g(!1),k(null))},_=async()=>{if(a){b(!0);try{await ne.agents.updateFile(s,a,l),r(Z=>Z.map(B=>B.name===a?{...B,content:l}:B)),g(!1),a==="ROLE.md"&&await ne.agents.updateSystemPrompt(s,l)}catch{}b(!1)}},Q=m?.files.filter(Z=>Z.status==="modified"||Z.status==="added_in_template")??[],E=async Z=>{const B=Z?Q.filter(I=>I.file===Z):Q;if(B.length===0)return;const K=[];for(const I of B)try{const X=await ne.agents.roleDiff(s,I.file);X.agentContent!=null&&X.templateContent!=null&&K.push(`## ${I.file}
71
+
72
+ **Template file path:** built-in template \`${m?.templateId??"unknown"}\`
73
+
74
+ **Key changes in the new template version:**
75
+ \`\`\`diff
76
+ `+e3(X.agentContent,X.templateContent)+"\n```\n")}catch{}if(K.length===0)return;const $=`Your role configuration files have been updated in the latest template (\`${m?.templateId??""}\`). Please review the following changes and decide whether to update your files accordingly.
77
+
78
+ `+K.join(`
79
+ ---
80
+
81
+ `)+"\nPlease review each change and update your files if appropriate. You can use the `update_file` tool or ask me to apply the changes.";gr.navigate(Ut.TEAM,{agentId:s,prefillMessage:$})},A=async Z=>{if(y?.file===Z){k(null);return}try{const B=await ne.agents.roleDiff(s,Z);B.agentContent!=null&&B.templateContent!=null&&k({file:Z,agent:B.agentContent,template:B.templateContent})}catch{}};if(i)return c.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.filesTab.loading")});const N={"ROLE.md":"roleMd","HEARTBEAT.md":"heartbeatMd","POLICIES.md":"policiesMd","CONTEXT.md":"contextMd"},R=Z=>{const B=N[Z];return B?e(`agent:profilePage.filesTab.fileLabels.${B}`):Z},W=m?.hasTemplate&&!m.isUpToDate,H=a?Q.some(Z=>Z.file===a):!1;return c.jsxs("div",{className:"space-y-4",children:[W&&c.jsxs("div",{className:"bg-amber-500/8 border border-amber-500/25 rounded-xl p-4 flex items-start gap-3",children:[c.jsx("span",{className:"text-amber-600 text-sm mt-0.5",children:"↻"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-xs text-amber-600 font-medium",children:e("agent:profilePage.filesTab.templateUpdateAvailable")}),c.jsxs("div",{className:"text-[11px] text-amber-600/70 mt-0.5",children:[e("agent:profilePage.filesTab.filesDiffer",{count:Q.length,templateId:m.templateId})," ",Q.map(Z=>Z.file).join(", ")]})]}),c.jsx("button",{onClick:()=>E(),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors shrink-0",children:e("agent:profilePage.filesTab.sendToAgent")})]}),c.jsxs(pr,{title:e("agent:profilePage.filesTab.agentConfigFiles"),action:m?.hasTemplate?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${m.isUpToDate?"bg-green-400":"bg-amber-400"}`}),c.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[e("agent:profilePage.filesTab.templateLabel")," ",c.jsx("span",{className:"text-fg-secondary",children:m.templateId}),m.isUpToDate?e("agent:profilePage.filesTab.upToDate"):e("agent:profilePage.filesTab.updatesAvailable")]})]}):c.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e("agent:profilePage.filesTab.customAgentNoTemplate")}),children:[c.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:t.map(Z=>{const B=Q.some(K=>K.file===Z.name);return c.jsxs("button",{onClick:()=>P(Z.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${a===Z.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[Z.name,B&&c.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},Z.name)})}),a&&c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-1",children:[c.jsx("div",{className:"text-xs text-fg-secondary",children:R(a)}),c.jsxs("div",{className:"flex gap-2 items-center",children:[H&&c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:()=>A(a),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:y?.file===a?e("agent:profilePage.filesTab.hideDiff"):e("agent:profilePage.filesTab.viewDiff")}),c.jsx("button",{onClick:()=>E(a),className:"px-2.5 py-1 text-[11px] bg-brand-600 hover:bg-brand-500 text-on-brand rounded-lg transition-colors",title:e("agent:profilePage.filesTab.sendToAgentTitle"),children:e("agent:profilePage.filesTab.sendToAgent")})]}),v&&c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e("common:saving")})]})]}),u&&c.jsxs("div",{className:"flex items-center gap-2 mb-3 bg-surface-elevated/40 rounded-lg px-3 py-2",children:[c.jsxs("code",{className:"text-[10px] text-fg-tertiary font-mono flex-1 truncate select-all",title:`${u}/${a}`,children:[u,"/",a]}),c.jsx("button",{onClick:()=>{navigator.clipboard.writeText(`${u}/${a}`),p(!0),setTimeout(()=>p(!1),2e3)},className:"shrink-0 px-2 py-1 text-[10px] text-fg-tertiary hover:text-fg-secondary border border-border-default hover:border-border-default rounded-md transition-colors",title:e("agent:profilePage.filesTab.copyPath"),children:e(f?"agent:profilePage.filesTab.pathCopied":"agent:profilePage.filesTab.copyPath")}),c.jsx("button",{onClick:()=>{ne.system.openPath(u)},className:"shrink-0 px-2 py-1 text-[10px] text-fg-tertiary hover:text-fg-secondary border border-border-default hover:border-border-default rounded-md transition-colors",title:e("agent:profilePage.filesTab.openInFinder"),children:e("agent:profilePage.filesTab.openInFinder")})]}),y?.file===a&&c.jsx(JI,{agent:y.agent,template:y.template,templateId:m?.templateId??""}),c.jsx(s3,{content:t.find(Z=>Z.name===a)?.content??"",editContent:l,setEditContent:Z=>{h(Z),g(!0)},dirty:O,onSave:_}),a==="ROLE.md"&&c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:e("agent:profilePage.filesTab.roleMdHint")})]}),t.length===0&&c.jsx(Uh,{text:e("agent:profilePage.filesTab.noConfigFiles")})]})]})}function s3({content:s,editContent:e,setEditContent:t,dirty:r,onSave:i}){const[n,a]=w.useState(!1),o=w.useRef(null),{t:l}=Tt(["agent","common","work"]);return w.useEffect(()=>{n&&o.current?.focus()},[n]),w.useEffect(()=>{a(!1)},[s]),n||r?c.jsx("textarea",{ref:o,value:e,onChange:h=>t(h.target.value),onBlur:()=>{e!==s&&i(),a(!1)},onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),t(s),a(!1))},className:"w-full min-h-[60vh] bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none",spellCheck:!1}):c.jsxs("div",{className:"group relative cursor-pointer rounded-lg px-4 py-3 bg-surface-elevated hover:bg-surface-overlay transition-colors min-h-[200px]",onClick:()=>a(!0),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&a(!0)},children:[c.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity text-[10px] text-fg-tertiary bg-surface-secondary/80 px-2 py-0.5 rounded",children:l("work:task.clickToEdit")}),e.trim()?c.jsx(w.Suspense,{fallback:c.jsx("div",{className:"text-xs text-fg-tertiary",children:l("common:loading")}),children:c.jsx(FI,{content:e,className:"text-sm text-fg-secondary leading-relaxed"})}):c.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:l("agent:profilePage.filesTab.emptyFile")})]})}function r3(s){return s.replace(/^\[MCP:[^\]]*\]\s*/i,"")}function i3({tools:s}){const{t:e}=Tt(["agent","common"]),t=WI(s,e);return c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"text-xs text-fg-tertiary",children:e("agent:profilePage.toolsTab.registeredCount",{count:s.length})}),t.map(r=>c.jsx(pr,{title:`${r.category} (${r.tools.length})`,children:c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.tools.map(i=>{const n=GC(i.name),a=e(`common:execution.tools.${n.key}`,{defaultValue:n.label}),o=i.name.includes("__"),l=o?i.name.split("__").pop():i.name,h=r3(i.description||"");return c.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2.5 rounded-lg bg-surface-elevated min-w-0",children:[c.jsx(AC,{name:n.iconName,size:15,className:"shrink-0 mt-0.5 text-fg-secondary"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[c.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:a}),o&&c.jsx("span",{className:"text-[9px] px-1 py-px rounded bg-surface-secondary text-fg-tertiary border border-border-default/40 shrink-0",children:"MCP"})]}),l!==a&&c.jsx("div",{className:"text-[10px] font-mono text-fg-tertiary/70 truncate",children:l}),h&&c.jsx("div",{className:"text-[10px] text-fg-tertiary truncate mt-0.5",title:h,children:h})]})]},i.name)})})},r.category)),s.length===0&&c.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:e("agent:profilePage.toolsTab.noToolsRegistered")})]})}function n3({agent:s}){const{t:e}=Tt(["agent","common"]),t=s.proficiency??{},[r,i]=w.useState(null),[n,a]=w.useState(null),[o,l]=w.useState(!1),h=s.availableSkills??[],u=s.skillWarnings?.missing??[],d=new Map;for(const g of h){const m=g.category||"custom";d.has(m)||d.set(m,[]),d.get(m).push(g)}const f=async g=>{if(r===g){i(null),a(null);return}i(g),l(!0);try{const m=await fetch(`/api/skills/${encodeURIComponent(g)}`);if(m.ok){const x=await m.json();a(x.skill)}else a(null)}catch{a(null)}l(!1)},p={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",productivity:"bg-amber-500/15 text-amber-600",browser:"bg-blue-500/15 text-blue-600",custom:"bg-gray-500/15 text-fg-secondary",platform:"bg-purple-500/15 text-purple-500"},v=g=>{const m=t[g.name],x=m&&m.uses>0?Math.round(m.successes/m.uses*100):null,y=m&&c.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[e("agent:profilePage.skillsTab.usesStats",{uses:m.uses,successes:m.successes}),m.lastUsed&&e("agent:profilePage.skillsTab.lastUsed",{date:new Date(m.lastUsed).toLocaleDateString()})]}),k=r===g.name;return c.jsxs("div",{children:[c.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${k?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>f(g.name),children:[c.jsx("span",{className:`text-sm transition-transform ${k?"rotate-90":""}`,children:"▶"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium",children:g.name}),g.alwaysOn&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:e("agent:profilePage.skillsTab.alwaysOn")}),g.builtIn&&!g.alwaysOn&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:e("agent:profilePage.skillsTab.builtIn")}),!g.builtIn&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-brand-500/15 text-brand-400",children:e("agent:profilePage.skillsTab.installed")})]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:g.description}),y]}),x!==null&&c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsx("div",{className:"w-16 h-1.5 bg-surface-overlay rounded-full overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full ${x>=80?"bg-green-400":x>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${x}%`}})}),c.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[x,"%"]})]})]}),k&&c.jsx("div",{className:"ml-6 mt-1 mb-2 p-4 bg-surface-elevated/30 rounded-lg border border-border-default/20 space-y-3",children:o?c.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.skillsTab.loadingDetails")}):n?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${p[n.category]??p.custom}`,children:n.category}),c.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",n.version]}),n.author&&c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e("agent:profilePage.skillsTab.byAuthor",{author:n.author})}),n.requiredPermissions?.map(C=>c.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:C},C))]}),n.description&&c.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:n.description}),n.tags&&n.tags.length>0&&c.jsx("div",{className:"flex gap-1 flex-wrap",children:n.tags.map(C=>c.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",C]},C))}),(n.toolDetails??n.tools??[]).length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-fg-tertiary font-semibold uppercase tracking-wider mb-2",children:e("agent:profilePage.skillsTab.toolsHeading",{count:(n.toolDetails??n.tools??[]).length})}),c.jsx("div",{className:"space-y-1.5",children:(n.toolDetails??n.tools??[]).map(C=>c.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 rounded border border-border-default/20",children:[c.jsx("div",{className:"text-xs font-medium text-brand-500",children:C.name}),C.description&&c.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:C.description})]},C.name))})]})]}):c.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.skillsTab.detailsUnavailable")})})]},g.name)},b=["development","productivity","browser","communication","devops","data","platform","custom"],O=[...d.entries()].sort((g,m)=>{const x=b.indexOf(g[0]),y=b.indexOf(m[0]);return(x===-1?999:x)-(y===-1?999:y)});return c.jsxs("div",{className:"space-y-4",children:[u.length>0&&c.jsxs("div",{role:"alert",className:"rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-xs text-amber-600 space-y-1.5",children:[c.jsxs("div",{className:"font-semibold flex items-center gap-1.5",children:[c.jsx("span",{"aria-hidden":!0,children:"⚠️"}),e("agent:profilePage.skillsTab.missingSkillsTitle",{count:u.length})]}),c.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:u.map(g=>c.jsx("li",{children:c.jsx("span",{className:"font-medium",children:g})},g))}),c.jsx("div",{className:"text-amber-600/90",children:e("agent:profilePage.skillsTab.missingSkillsHint")})]}),c.jsx("div",{className:"flex items-center justify-between",children:c.jsx("div",{className:"text-xs text-fg-tertiary",children:e("agent:profilePage.skillsTab.installedCount",{count:h.length})})}),O.map(([g,m])=>c.jsx(pr,{title:c.jsxs("span",{className:"capitalize",children:[g," ",c.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",m.length,")"]})]}),children:c.jsx("div",{className:"space-y-2",children:m.map(x=>v(x))})},g)),h.length===0&&c.jsx(Uh,{text:e("agent:profilePage.skillsTab.noSkills")})]})}function o3({tools:s,agent:e}){const{t}=Tt(["agent","common"]),[r,i]=w.useState("tools");return c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-center gap-2 mb-2",children:["tools","skills"].map(n=>c.jsx("button",{onClick:()=>i(n),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${r===n?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:n==="tools"?`${t("agent:profilePage.toolsTab.title",{defaultValue:"Tools"})} (${s.length})`:`${t("agent:tabs.skills")} (${e.availableSkills?.length??0})`},n))}),r==="tools"?c.jsx(i3,{tools:s}):c.jsx(n3,{agent:e})]})}function a3({agentId:s}){const{t:e}=Tt(["agent","common"]),[t,r]=w.useState(null),[i,n]=w.useState(!0),[a,o]=w.useState("longterm"),[l,h]=w.useState(""),[u,d]=w.useState(""),[f,p]=w.useState(!1),[v,b]=w.useState(null),[O,g]=w.useState(null),m=H_(()=>ne.agents.getMemorySession(s,O??"").then(R=>R.messages),{enabled:O!==null,deps:[s,O]}),x=w.useCallback(()=>{n(!0),ne.agents.getMemory(s).then(R=>{r(R),h(R.recentDailyLogs??""),d(R.longTermMemory??"")}).catch(()=>{}).finally(()=>n(!1))},[s]);w.useEffect(()=>{x()},[x]);const y=async()=>{p(!0),await ne.agents.updateDailyMemory(s,l).catch(()=>{}),p(!1),x()},k=async()=>{p(!0),await ne.agents.updateLongTermMemory(s,e("agent:profilePage.memoryTab.userEditedSource"),u).catch(()=>{}),p(!1),x()},C=l!==(t?.recentDailyLogs??""),P=u!==(t?.longTermMemory??"");if(i)return c.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.memoryTab.loading")});if(!t)return c.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.memoryTab.loadFailed")});const _=[{key:"longterm",label:"knowledge.md"},{key:"entries",label:`Observations (${t.entries.length})`},{key:"sessions",label:e("agent:profilePage.memoryTab.sessions",{count:t.sessions.length})},{key:"daily",label:e("agent:profilePage.memoryTab.dailyLogs")}],Q=t.curatedCap&&t.curatedCap>0?(t.curatedChars??0)/t.curatedCap*100:null,E=t.injectionCapChars&&t.injectionCapChars>0?(t.injectedChars??0)/t.injectionCapChars*100:null,A=R=>R>=90?"text-red-500 font-medium":R>=70?"text-amber-600 font-medium":"text-fg-tertiary",N=R=>R>=90?"bg-red-500":R>=70?"bg-amber-500":"bg-brand-500";return c.jsxs("div",{className:"space-y-4",children:[(t.curatedChars!=null||t.injectedChars!=null)&&c.jsx(pr,{title:e("agent:profilePage.memoryTab.healthTitle","记忆健康(knowledge.md)"),children:c.jsxs("div",{className:"space-y-2",children:[E!=null&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between text-xs",children:[c.jsxs("span",{className:"text-fg-secondary",children:[e("agent:profilePage.memoryTab.injectionLine","本轮注入(prompt 预算)"),c.jsxs("span",{className:"text-fg-tertiary",children:[" ",e("agent:profilePage.memoryTab.charsOfCap",{used:t.injectedChars??0,cap:t.injectionCapChars??0})]})]}),c.jsxs("span",{className:A(E),children:[Math.round(E),"%"]})]}),c.jsx("div",{className:"h-1.5 rounded-full bg-surface-overlay overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full ${N(E)}`,style:{width:`${Math.min(100,E)}%`}})}),(t.injectionOmittedCount??0)>0&&c.jsx("div",{className:"text-[10px] text-amber-600",children:e("agent:profilePage.memoryTab.injectionOmittedHint",{count:t.injectionOmittedCount??0,defaultValue:"已有 {{count}} 段因超出注入上限而未内联(仍可按需检索)"})})]}),c.jsxs("details",{className:"text-[10px] text-fg-tertiary",children:[c.jsx("summary",{className:"cursor-pointer select-none hover:text-fg-secondary",children:e("agent:profilePage.memoryTab.detailsToggle","明细(磁盘策展区 · 观察缓冲 · 归档)")}),c.jsxs("div",{className:"mt-1.5 space-y-1",children:[Q!=null&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-fg-tertiary",children:[e("agent:profilePage.memoryTab.curatedLine","磁盘策展区(超预算会无损归档)"),c.jsxs("span",{className:"text-fg-secondary",children:[" ",e("agent:profilePage.memoryTab.charsOfCap",{used:t.curatedChars??0,cap:t.curatedCap??0})]})]}),c.jsxs("span",{className:A(Q),children:[Math.round(Q),"%"]})]}),t.observationLimit!=null&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-fg-tertiary",children:[e("agent:profilePage.memoryTab.observationLine","观察缓冲(不注入)"),c.jsxs("span",{className:"text-fg-secondary",children:[" ",e("agent:profilePage.memoryTab.charsOfCap",{used:t.observationChars??0,cap:t.observationLimit??0})]})]}),c.jsxs("span",{className:A(t.observationPercent??0),children:[Math.round(t.observationPercent??0),"%"]})]}),c.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:[c.jsxs("span",{children:[e("agent:profilePage.memoryTab.observationsCount","观察")," ",t.observationCount??0]}),c.jsxs("span",{children:[e("agent:profilePage.memoryTab.curatedCount","知识段")," ",t.curatedCount??0]}),(t.archivedChars??0)>0&&c.jsxs("span",{children:[e("agent:profilePage.memoryTab.archivedChars","已归档")," ",e("agent:profilePage.memoryTab.archivedCharsSearchable",{count:t.archivedChars})]}),t.lastConsolidatedAt&&c.jsxs("span",{children:[e("agent:profilePage.memoryTab.lastConsolidated","上次整理")," ",new Date(t.lastConsolidatedAt).toLocaleDateString()]})]})]})]}),((E??0)>=90||(Q??0)>=70)&&c.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[c.jsx("button",{type:"button",onClick:()=>{gr.navigate(Ut.TEAM,{agentId:s,preferMain:"1",prefillMessage:e("agent:profilePage.memoryTab.organizePrefill",{used:t.curatedChars??0,limit:t.curatedCap??0,pct:Math.round(Q??0),defaultValue:"你的 knowledge.md 已超出预算({{used}}/{{limit}} 字符,{{pct}}%)。请整理:合并同类段落、删掉已被新结论取代的条目,只留可复用的结论;过程与流水不要留在策展区。整理前先把打算删/合并的清单给我看。"})})},className:"text-[11px] px-2 py-1 rounded border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40",children:e("agent:profilePage.memoryTab.organizeCta","让 Agent 整理记忆")}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e("agent:profilePage.memoryTab.organizePrefillHint","会跳到聊天并预填指令,发送与否由你决定")})]})]})}),c.jsx("div",{className:"flex gap-2",children:_.map(R=>c.jsx("button",{onClick:()=>o(R.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${a===R.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:R.label},R.key))}),a==="entries"&&c.jsx(pr,{title:e("agent:profilePage.memoryTab.recentEntries"),children:t.entries.length===0?c.jsx(Uh,{text:e("agent:profilePage.memoryTab.noEntries")}):c.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:t.entries.map((R,W)=>{const H=v===W;return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>b(H?null:W),className:"w-full flex gap-2 px-3 py-2 rounded-lg bg-surface-elevated/20 text-xs text-left hover:bg-surface-elevated/40 transition-colors cursor-pointer",children:[c.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ${R.type==="fact"?"bg-blue-500/15 text-blue-600":R.type==="task"?"bg-green-500/15 text-green-600":R.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:R.type}),c.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${H?"":"line-clamp-2"}`,children:R.content}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[R.importance!=null&&c.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${R.importance>=7?"bg-red-500/15 text-red-500":R.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",R.importance]}),c.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(R.timestamp).toLocaleTimeString()}),c.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]})]}),H&&c.jsxs("div",{className:"mx-3 mt-1 mb-2 p-3 bg-surface-elevated/30 rounded-lg border border-border-default/20",children:[c.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed break-words",children:R.content}),c.jsxs("div",{className:"flex gap-3 mt-2 pt-2 border-t border-border-default/30 text-[10px] text-fg-tertiary",children:[c.jsxs("span",{children:[e("agent:profilePage.overview.labels.type"),": ",R.type]}),R.importance!=null&&c.jsxs("span",{children:[e("agent:profilePage.overview.labels.importance"),": ",R.importance]}),c.jsx("span",{children:new Date(R.timestamp).toLocaleString()})]})]})]},W)})})}),a==="sessions"&&c.jsx(pr,{title:e("agent:profilePage.memoryTab.chatSessions"),children:t.sessions.length===0?c.jsx(Uh,{text:e("agent:profilePage.memoryTab.noSessions")}):c.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:t.sessions.map(R=>{const W=O===R.id,H=()=>{g(W?null:R.id)};return c.jsxs("div",{children:[c.jsxs("button",{onClick:H,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg bg-surface-elevated/20 hover:bg-surface-elevated/40 transition-colors cursor-pointer text-left",children:[c.jsx("div",{className:"text-xs text-fg-secondary font-mono flex-1 truncate",children:R.id}),c.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[R.messageCount," ",e("agent:profilePage.memoryTab.msgs")]}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(R.updatedAt).toLocaleDateString()}),c.jsx("span",{className:"text-fg-tertiary text-[10px]",children:W?"▲":"▼"})]}),W&&c.jsx("div",{className:"mx-3 mt-1 mb-2 bg-surface-elevated/30 rounded-lg border border-border-default/20 max-h-96 overflow-y-auto",children:m.view.loading?c.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.memoryTab.loadingMessages")}):m.view.error?c.jsx(sy,{variant:"inline",subject:e("agent:profilePage.sessionMessagesSubject"),error:m.resource.error??e("common:readFailed"),notEquals:e("agent:profilePage.noSessionMessages"),onRetry:m.reload}):m.view.empty?c.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.memoryTab.noMessagesInSession")}):(()=>{const Z=m.resource.items,B=new Map;for(const K of Z)K.role==="tool"&&K.toolCallId&&B.set(K.toolCallId,K.content);return c.jsx("div",{className:"divide-y divide-gray-700/30",children:Z.filter(K=>K.role!=="tool").map((K,$)=>c.jsxs("div",{className:"px-3 py-2",children:[(K.role==="user"||K.role==="system")&&c.jsxs("div",{children:[c.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 ${K.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:e(`agent:profilePage.memoryTab.roles.${K.role}`,{defaultValue:K.role})}),c.jsx("div",{className:"text-xs text-fg-secondary",children:c.jsx(Hi,{content:K.content,className:"text-xs text-fg-secondary"})})]}),K.role==="assistant"&&c.jsxs("div",{className:"space-y-1",children:[K.content&&c.jsxs("div",{children:[c.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 bg-green-500/15 text-green-600",children:e("agent:profilePage.memoryTab.roles.assistant")}),c.jsx("div",{className:"text-xs text-fg-secondary",children:c.jsx(Hi,{content:K.content,className:"text-xs text-fg-secondary"})})]}),K.toolCalls&&K.toolCalls.length>0&&c.jsx("div",{className:"space-y-0.5",children:K.toolCalls.map(I=>{let X;try{X=JSON.parse(I.arguments)}catch{}const q={tool:I.name,status:"done",args:X,result:B.get(I.id)};return c.jsx(HC,{entry:{type:"tool",info:q}},I.id)})})]})]},$))})})()})]},R.id)})})}),a==="daily"&&c.jsx(pr,{title:e("agent:profilePage.memoryTab.dailyLogs"),action:C?c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:()=>h(t?.recentDailyLogs??""),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:e("common:cancel")}),c.jsx("button",{onClick:y,disabled:f,className:"text-xs text-brand-500",children:e(f?"common:saving":"common:save")})]}):null,children:c.jsx("textarea",{value:l,onChange:R=>h(R.target.value),placeholder:e("agent:profilePage.memoryTab.noDailyLogs"),className:"w-full min-h-[50vh] bg-surface-elevated/30 border border-border-default/50 hover:border-border-default focus:border-brand-500 rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y outline-none transition-colors"})}),a==="longterm"&&c.jsx(pr,{title:e("agent:profilePage.memoryTab.longTermTitle"),action:P?c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:()=>d(t?.longTermMemory??""),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:e("common:cancel")}),c.jsx("button",{onClick:k,disabled:f,className:"text-xs text-brand-500",children:e(f?"common:saving":"common:save")})]}):null,children:c.jsx("textarea",{value:u,onChange:R=>d(R.target.value),placeholder:e("agent:profilePage.memoryTab.noLongTerm"),className:"w-full min-h-[50vh] bg-surface-elevated/30 border border-border-default/50 hover:border-border-default focus:border-brand-500 rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y outline-none transition-colors"})})]})}function l3({taskId:s,isLive:e}){const{t}=Tt("agent"),[r,i]=w.useState([]),[n,a]=w.useState(""),[o,l]=w.useState(!0);if(w.useEffect(()=>{l(!0),a(""),ne.tasks.getLogs(s).then(u=>{i(u.logs),l(!1)}).catch(()=>l(!1))},[s]),w.useEffect(()=>{if(!e)return;const u=Rt.on("task:log",f=>{const p=f.payload;if(p.taskId!==s)return;const v={id:p.id,taskId:p.taskId,agentId:p.agentId,seq:p.seq,type:p.logType,content:p.content,metadata:p.metadata,createdAt:p.createdAt};i(b=>v.id&&b.some(O=>O.id===v.id)?b:[...b,v]),v.type==="text"&&a("")}),d=Rt.on("task:log:delta",f=>{const p=f.payload;p.taskId===s&&a(v=>v+p.text)});return()=>{u(),d()}},[s,e]),o)return c.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:t("profilePage.taskLog.loading")});if(r.length===0&&!n)return c.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:t("profilePage.taskLog.noLogs")});const h=r.map(u=>RC(u));return c.jsx("div",{className:"px-3 py-2",children:c.jsx(oy,{entries:h,isStreaming:e,streamingText:n})})}function c3({agentId:s,activityId:e,isLive:t=!1}){const{t:r}=Tt("agent"),[i,n]=w.useState([]),[a,o]=w.useState(!0);if(w.useEffect(()=>{o(!0),ne.agents.getActivityLogs(s,e).then(h=>{n(h.logs),o(!1)}).catch(()=>o(!1))},[s,e]),w.useEffect(()=>t?Rt.on("agent:activity_log",u=>{const d=u.payload;if(d.agentId!==s||d.activityId!==e)return;const f={seq:d.seq,type:d.type,content:d.content,metadata:d.metadata,createdAt:d.createdAt};n(p=>p.some(v=>v.seq===f.seq)?p:[...p,f])}):void 0,[s,e,t]),a)return c.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:r("profilePage.activityLog.loading")});if(i.length===0)return c.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:r("profilePage.activityLog.noLogs")});const l=i.map(h=>EC(h,e,s)).filter(h=>h!==null);return c.jsx("div",{className:"px-3 py-2",children:c.jsx(oy,{entries:l,isStreaming:t})})}function pr({title:s,action:e,children:t}){return c.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h3",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:s}),e]}),t]})}function Ls({label:s,mono:e,children:t}){return c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s}),c.jsx("span",{className:`text-xs text-fg-secondary ${e?"font-mono text-[10px]":""}`,children:t})]})}function di({label:s,value:e,color:t}){const r=t==="green"?"text-green-500":t==="blue"?"text-blue-400":t==="indigo"?"text-brand-500":t==="red"?"text-red-400":"text-fg-secondary";return c.jsxs("div",{className:"flex items-baseline gap-1.5",children:[c.jsx("span",{className:`text-sm font-semibold ${r}`,children:e}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s})]})}function Uh({text:s}){return c.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:s})}function Mf(s){if(s===0)return"0 B";const e=["B","KB","MB","GB"],t=Math.min(Math.floor(Math.log(s)/Math.log(1024)),e.length-1),r=s/Math.pow(1024,t);return`${r<10?r.toFixed(1):Math.round(r)} ${e[t]}`}const Wv={0:"0",1:"1",2:"2",3:"3",4:"4"},Xv={0:"text-red-500",1:"text-amber-500",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},h3={pick:"bg-brand-500/20 text-brand-500",continue:"bg-gray-500/20 text-gray-500",preempt:"bg-amber-500/20 text-amber-500",merge:"bg-blue-500/20 text-blue-500",defer:"bg-purple-500/20 text-purple-500",delegate:"bg-green-500/20 text-green-500",drop:"bg-red-500/20 text-red-500"},d3={idle:"bg-green-500/20 text-green-500",focused:"bg-brand-500/20 text-brand-500",deciding:"bg-amber-500/20 text-amber-500"},u3=["all","task","requirement","channel","none"],f3={completed:"bg-green-500",processing:"bg-blue-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-brand-400",queued:"bg-amber-400",bounced:"bg-red-500",catch_all:"bg-red-700"},m3={pending:"text-gray-400",assigned:"text-blue-400",in_progress:"text-brand-400",completed:"text-green-400",failed:"text-red-400",cancelled:"text-gray-500",review:"text-amber-400",approved:"text-green-500",rejected:"text-red-500",draft:"text-gray-400"};function Lf(s){const e=s.match(/Comment from .+?:\s*(.+?)(?:\n\n\*\*MANDATORY|\n\n---|\n\n\[|$)/s);if(e?.[1]){const t=e[1].trim().replace(/\n/g," ");return t.length>80?t.slice(0,80)+"…":t}}function zv(s,e){const t=s.payload,r=t?.summary??"",i=t?.content??"",n=s.metadata?.senderName;switch(s.sourceType){case"task_status_update":{const a=r.match(/^Task "(.+?)" status:/),o=r.match(/status:\s*(\S+)\s*→\s*(\S+)/),l=a?.[1]??r;if(o){const u=o[1],d=o[2],f=Df(u,e),p=Df(d,e),v=m3[d]??"text-fg-secondary";return{title:l,subtitle:e("agent:profilePage.mind.mailbox.statusArrow",{from:f,to:p}),badge:{label:p,color:v}}}const h=r.match(/^Task:\s*(.+)/);return h?{title:h[1]}:{title:l}}case"task_comment":{const a=Lv(r),o=Lf(i);if(a){const l=o?e("agent:profilePage.mind.mailbox.commentFromAuthor",{author:a.author,text:o}):e("agent:profilePage.mind.mailbox.commentFrom",{name:a.author});return{title:a.subject,subtitle:l}}return{title:r}}case"requirement_update":{const a=r.match(/^Requirement "(.+?)"\s+(.*)/);return a?{title:a[1],subtitle:a[2]}:{title:r}}case"requirement_comment":{const a=Lv(r),o=Lf(i);if(a){const l=o?e("agent:profilePage.mind.mailbox.commentFromAuthor",{author:a.author,text:o}):e("agent:profilePage.mind.mailbox.commentFrom",{name:a.author});return{title:a.subject,subtitle:l}}return{title:r}}case"human_chat":{const a=i.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.chatFrom",{sender:n}):e("agent:profilePage.mind.mailbox.humanChat"),subtitle:a+(i.length>120?"…":"")}}case"a2a_message":{const a=i.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.messageFrom",{sender:n}):e("agent:profilePage.mind.mailbox.agentMessage"),subtitle:a+(i.length>120?"…":"")}}case"mention":{const a=r.match(/from (.+)$/),o=Lf(i);return{title:a?e("agent:profilePage.mind.mailbox.mentionedBy",{name:a[1]}):e("agent:profilePage.mind.mailbox.mention"),subtitle:o||void 0}}case"review_request":{const a=i.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.reviewRequestFrom",{sender:n}):e("agent:profilePage.mind.mailbox.reviewRequest"),subtitle:a+(i.length>120?"…":"")}}case"session_reply":{const a=i.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.replyInSession",{sender:n}):e("agent:profilePage.mind.mailbox.sessionReply"),subtitle:a+(i.length>120?"…":"")}}case"heartbeat":return{title:e("agent:profilePage.mind.mailbox.scheduledHeartbeat")};case"daily_report":return{title:e("agent:profilePage.mind.mailbox.dailyReport")};case"memory_consolidation":return{title:e("agent:profilePage.mind.mailbox.memoryConsolidation")};case"system_event":{const a=r.match(/^\[Announcement]\s*(.+)/);return a?{title:a[1],subtitle:e("agent:profilePage.mind.mailbox.systemAnnouncement")}:{title:r||e("agent:profilePage.mind.mailbox.systemEvent")}}default:return{title:r||s.sourceType}}}function p3({agentId:s,highlightId:e,agentStatus:t,canManageAgents:r}){const{t:i}=Tt(["agent","common","team"]),[n,a]=w.useState(null),[o,l]=w.useState(null),[h,u]=w.useState(!0),[d,f]=w.useState("all"),[p,v]=w.useState("all"),[b,O]=w.useState({}),[g,m]=w.useState({}),[x,y]=w.useState(0),[k,C]=w.useState(e??null),[P,_]=w.useState(e??null),[Q,E]=w.useState(!1),[A,N]=w.useState(!1),[R,W]=w.useState(null),H=50,[Z,B]=w.useState(0),[K,$]=w.useState(!1),I=w.useRef(0),[X,q]=w.useState([]),ie=w.useRef(null),pe=w.useRef(!1),$e=w.useRef(!1),re=3,[U,M]=w.useState(null),[te,Y]=w.useState(new Set),[ae,ee]=w.useState(null);w.useEffect(()=>{let ye=!1;const ze=()=>{ne.agents.workUnits(s,"running").then(ce=>{ye||Y(et=>{const xe=YC(ce.units);return et.size===xe.size&&[...xe].every(gt=>et.has(gt))?et:xe})}).catch(()=>{})};ze();const Ie=window.setInterval(ze,15e3);return()=>{ye=!0,window.clearInterval(Ie)}},[s]);const me=w.useCallback(async(ye=!0,ze)=>{const Ie=Math.max(0,ze??I.current);ye&&u(!0);try{const ce=d==="all"?void 0:d,et=Rf(p),[xe,gt]=await Promise.all([ne.agents.getMindState(s),ne.agents.getMailbox(s,{mode:"groups",limit:H,offset:Ie*H,entityKind:ce,status:et})]);a(xe);const He=gt,Ct=He.groups??[];I.current=Ie,B(Ie),pe.current=!!He.hasNext,$(!!He.hasNext),q(Ct),O(He.kindCounts??{}),m(He.statusCounts??{}),typeof He.staleProcessingCount=="number"&&y(He.staleProcessingCount),ee(vt=>{const de=`channel:loop_${s}`;return vt&&(d==="all"&&p==="all"&&vt===de||Ct.some(oe=>oe.key===vt))?vt:Ct.find(oe=>oe.key)?.key??null})}catch{}u(!1)},[s,d,p]);w.useEffect(()=>{if(!ae)return;let ye=!1;return(async()=>{try{const ze=Rf(p),Ie=await ne.agents.getMailbox(s,{entity:ae,status:ze});ye||(l(ce=>ce?{...ce,history:Ie.history}:Ie),typeof Ie.staleProcessingCount=="number"&&y(Ie.staleProcessingCount))}catch{}})(),()=>{ye=!0}},[s,ae,p]);const Re=w.useCallback(async()=>{if($e.current||!pe.current)return;$e.current=!0;const ye=I.current+1;try{const ze=d==="all"?void 0:d,Ie=Rf(p),et=await ne.agents.getMailbox(s,{mode:"groups",limit:H,offset:ye*H,entityKind:ze,status:Ie}),xe=et.groups??[];I.current=ye,B(ye),pe.current=!!et.hasNext,$(!!et.hasNext),q(gt=>[...gt,...xe])}catch{}finally{$e.current=!1}},[s,d,p]);w.useEffect(()=>{const ye=ie.current;if(!ye||!K)return;const ze=new IntersectionObserver(Ie=>{Ie.some(ce=>ce.isIntersecting)&&($e.current||Re().finally(()=>{const ce=ie.current;ce&&(ze.unobserve(ce),ze.observe(ce))}))},{root:ye.parentElement,rootMargin:"120px"});return ze.observe(ye),()=>ze.disconnect()},[Re,K]);const _e=w.useCallback(async ye=>{M(ye);try{await ne.agents.dropMailboxItem(s,ye,"operator"),await me()}catch{}finally{M(null)}},[s,me]);w.useCallback(ye=>{const ze=Math.max(0,ye);ze!==I.current&&me(!0,ze)},[me]);const De=w.useMemo(()=>{if(!(d==="all"&&p==="all"))return X;const ze=`channel:loop_${s}`;return X.some(Ie=>Ie.key===ze)?X:[{key:ze,kind:"channel",id:`loop_${s}`,name:"",count:0,units:0,latestAt:""},...X]},[X,s,d,p]),Te=60,[Fe,Ue]=w.useState(Te),[ve,V]=w.useState(!1),[Xe,Ke]=w.useState({}),ft=w.useCallback(async ye=>{try{const Ie=(await ne.agents.getMailbox(s,{itemId:ye})).history?.[0]?.payload?.content;typeof Ie=="string"&&Ke(ce=>({...ce,[ye]:Ie}))}catch{}},[s]),mt=w.useCallback(async()=>{try{await ne.agents.recoverStaleMailbox(s)}catch{}await me()},[s,me]);w.useEffect(()=>{C(e??null),_(e??null),me()},[me,e]);const _t=w.useRef(!1);if(w.useEffect(()=>{if(!P||h)return;if(o?.history?.some(ze=>ze.id===P)){_t.current=!1;const ze=document.getElementById(`mbx-${P}`);if(ze){setTimeout(()=>ze.scrollIntoView({behavior:"smooth",block:"center"}),100);const Ie=setTimeout(()=>_(null),3e3);return()=>clearTimeout(Ie)}}else K&&!_t.current&&(_t.current=!0,(async()=>{let ze=I.current+1;try{for(let Ie=0;Ie<20;Ie++){const ce=await ne.agents.getMailbox(s,{limit:H,offset:ze*H});if(ce.history.some(et=>et.id===P)){I.current=ze,B(ze),l(ce),$((ce.history?.length??0)>=H);break}if((ce.history?.length??0)<H)break;ze++}}catch{}_t.current=!1})())},[P,h,o,K,s]),w.useEffect(()=>{let ye=null;const ze=ce=>{ce.payload?.agentId===s&&(ye&&clearTimeout(ye),ye=setTimeout(()=>{ye=null,me(!1)},500))},Ie=[Rt.on("agent:mailbox",ze),Rt.on("agent:decision",ze),Rt.on("agent:attention",ze),Rt.on("agent:focus",ze),Rt.on("agent:update",ze),Rt.on("agent:triage",ze)];return()=>{ye&&clearTimeout(ye),Ie.forEach(ce=>ce())}},[s,me]),h&&!n)return c.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:i("agent:profilePage.mind.loading")});const Xt=n?.mailboxDepth??n?.queuedItems?.length??0,dt=vl(t).running,Dt=(()=>{const ye=n?.attentionState??"idle";return ye==="deciding"||ye==="idle"&&Xt>0?"deciding":ye!=="idle"&&!n?.currentFocus?"idle":ye})(),Me=dt&&x>0,jt=(n?.attentionState??"idle")==="idle"&&Xt>0;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("section",{children:[c.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[dt?c.jsx("span",{className:`px-2.5 py-1 text-xs font-medium rounded-full ${d3[Dt]??"bg-gray-500/20 text-gray-500"}`,children:jC(Dt,i)}):c.jsx("span",{className:"px-2.5 py-1 text-xs font-medium rounded-full bg-gray-500/20 text-fg-tertiary",children:i("agent:profilePage.mind.agentStopped")}),dt?n?.currentFocus?(()=>{const ye=zv({id:n.currentFocus.mailboxItemId,sourceType:n.currentFocus.type,payload:{summary:n.currentFocus.label,taskId:n.currentFocus.taskId},metadata:{},queuedAt:n.currentFocus.startedAt},i);return c.jsxs("span",{className:"text-sm text-fg-secondary inline-flex items-center gap-2",children:[c.jsxs("span",{children:[zc(n.currentFocus.type)," ",c.jsx("span",{className:"text-fg-primary font-medium",children:ye.title}),ye.subtitle&&c.jsx("span",{className:"text-fg-tertiary ml-1.5 text-xs",children:ye.subtitle}),c.jsx("span",{className:"text-fg-tertiary ml-2 text-xs",children:i("agent:profilePage.mind.since",{time:new Date(n.currentFocus.startedAt).toLocaleTimeString()})})]}),r&&c.jsxs("button",{onClick:()=>W(n.currentFocus.mailboxItemId),className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-red-500/15 text-red-500 hover:bg-red-500/25 transition-colors shrink-0",children:["✕ ",i("agent:profilePage.mind.cancelCurrentBtn")]})]})})():jt?c.jsx("span",{className:"text-sm text-amber-500",children:i("agent:profilePage.mind.queuedButIdle",{count:Xt,defaultValue:"Queue has {{count}} item(s) — attention loop should pick them up…"})}):Dt==="deciding"?c.jsx("span",{className:"text-sm text-amber-500",children:i("agent:profilePage.mind.decidingWaiting",{count:Xt})}):c.jsx("span",{className:"text-sm text-fg-tertiary",children:i("agent:profilePage.mind.idleWaiting")}):c.jsx("span",{className:"text-sm text-fg-tertiary",children:i("agent:profilePage.mind.stoppedHint")}),c.jsx("div",{className:"ml-auto flex items-center gap-2",children:c.jsx("button",{onClick:()=>{me()},className:"text-xs text-fg-tertiary hover:text-fg-secondary active:text-fg-primary transition-colors",children:i("agent:profilePage.mind.refresh")})})]}),dt&&Me&&c.jsxs("div",{className:"mb-3 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 flex items-center gap-2",children:[c.jsx("span",{className:"text-amber-500 text-sm",children:"⚠"}),c.jsx("span",{className:"text-[11px] text-amber-600 flex-1",children:i("agent:profilePage.mind.staleProcessingWarning")}),r&&c.jsx("button",{onClick:()=>{mt()},className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-amber-500/20 text-amber-700 hover:bg-amber-500/30 transition-colors shrink-0",children:i("agent:profilePage.mind.recoverStaleBtn")})]}),(n?.queuedItems?.length??0)>0&&(()=>{const ye=n.queuedItems,ze=ye.length>re,Ie=ze&&!Q?ye.slice(0,re):ye,ce=ye.reduce((et,xe)=>(et[xe.sourceType]=(et[xe.sourceType]??0)+1,et),{});return c.jsxs("div",{className:"mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[c.jsx("h4",{className:"text-xs font-medium text-amber-500 uppercase tracking-wider",children:i("agent:profilePage.mind.queue",{count:ye.length})}),c.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Object.entries(ce).map(([et,xe])=>c.jsxs("span",{className:"text-[10px] text-fg-tertiary bg-amber-500/10 px-1.5 py-0.5 rounded",children:[zc(et)," ",xe]},et))})]}),c.jsxs("div",{className:"space-y-1",children:[Ie.map((et,xe)=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded bg-amber-500/5 border border-amber-500/20 text-sm",children:[c.jsx("span",{className:"text-fg-tertiary w-4 text-right text-xs",children:xe+1}),c.jsx("span",{className:"text-sm",children:zc(et.sourceType)}),c.jsx("span",{className:`text-[10px] ${Xv[et.priority]??"text-fg-tertiary"}`,children:i(`agent:profilePage.mind.priority.${Wv[et.priority]??et.priority}`,{defaultValue:`P${et.priority}`})}),c.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:et.summary}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(et.queuedAt).toLocaleTimeString()})]},et.id)),ze&&c.jsx("button",{onClick:()=>E(!Q),className:"w-full text-center text-[11px] text-amber-500 hover:text-amber-400 py-1 transition-colors",children:Q?i("agent:profilePage.mind.collapseQueue"):i("agent:profilePage.mind.expandQueue",{count:ye.length-re})})]})]})})()]}),(n?.notebook?.length??0)>0&&(()=>{const ye=ZI(n.notebook,A);return c.jsx("section",{className:"bg-surface-elevated rounded-lg border border-border-subtle p-3",children:c.jsxs("details",{children:[c.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[c.jsx("span",{className:"text-sm",children:"📓"}),c.jsx("h4",{className:"text-xs font-medium text-fg-secondary uppercase tracking-wider",children:i("agent:profilePage.mind.notebook")}),c.jsx("span",{className:"text-[10px] text-fg-muted ml-auto",children:i("agent:profilePage.mind.notebookEntries",{count:n.notebook.length})})]}),c.jsx("p",{className:"mt-2 text-[10px] text-fg-muted leading-relaxed",children:i("agent:profilePage.mind.notebookHint",{count:U_})}),c.jsxs("div",{className:"mt-2 space-y-2",children:[ye.visible.map(ze=>{const Ie=VI(ze.updatedAt),ce=i(`agent:profilePage.relative.${Ie.unit==="seconds"?"secondsAgo":Ie.unit==="minutes"?"minutesAgo":"hoursAgo"}`,{count:Ie.count,hours:Ie.count}),et=ze.managed==="system"?"text-blue-400":"text-emerald-400";return c.jsxs("div",{className:"px-3 py-2 rounded bg-surface-overlay border border-border-subtle",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:"text-xs font-medium text-fg-primary",children:ze.key}),c.jsxs("span",{className:`text-[10px] ${et}`,children:["[",ze.managed,"]"]}),c.jsx("span",{className:"text-[10px] text-fg-muted ml-auto",children:ce})]}),c.jsx("pre",{className:"text-[11px] text-fg-secondary whitespace-pre-wrap break-words leading-relaxed max-h-32 overflow-y-auto",children:ze.text.length>500?ze.text.slice(0,500)+"…":ze.text})]},ze.key)}),ye.collapsible&&c.jsx("button",{onClick:()=>N(!A),className:"w-full text-center text-[11px] text-accent-primary hover:opacity-80 py-1 transition-colors",children:A?i("agent:profilePage.mind.collapseQueue"):i("agent:profilePage.mind.expandNotebook",{count:ye.hiddenCount})})]})]})})})(),c.jsxs("section",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:i("agent:profilePage.mind.mailboxHistory")}),c.jsx("div",{className:"flex gap-1 ml-auto flex-wrap",children:u3.map(ye=>{const ze=ye==="all"?Object.values(b).reduce((Ie,ce)=>Ie+ce,0):b[ye];return c.jsxs("button",{onClick:()=>f(ye),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${d===ye?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-elevated border-border-subtle text-fg-secondary hover:bg-surface-overlay"}`,children:[i(`agent:profilePage.mind.entityFilters.${ye}`),ze!=null&&ze>0&&c.jsx("span",{className:"ml-1 opacity-60",children:ze})]},ye)})})]}),c.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:II.map(ye=>{const ze=g,Ie=ye.key==="all"?Object.values(ze).reduce((ce,et)=>ce+et,0):ze[ye.key];return c.jsxs("button",{onClick:()=>v(ye.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors flex items-center gap-1 ${p===ye.key?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-elevated border-border-subtle text-fg-secondary hover:bg-surface-overlay"}`,children:[ye.dot&&c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ye.dot}`}),i(`agent:profilePage.mind.statusFilters.${ye.key}`),Ie!=null&&Ie>0&&c.jsx("span",{className:"ml-1 opacity-60",children:Ie})]},ye.key)})}),X.length===0&&!h&&c.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:d==="all"&&p==="all"?i("agent:profilePage.mind.noHistory","暂无邮箱历史"):i("agent:profilePage.mind.noMatch","这个筛选下没有记录")}),(()=>{const ye=De,ze=ye.find(ce=>ce.key===ae)??ye[0],Ie=o?.history??[];return c.jsx("div",{className:"@container relative overflow-hidden",children:c.jsxs("div",{className:"flex flex-col @2xl:flex-row gap-3 items-stretch",children:[c.jsxs("div",{className:"w-full @2xl:w-48 shrink-0 space-y-1 max-h-[30rem] overflow-y-auto pr-1",children:[ye.map(ce=>{const et=(ze?.key??"")===ce.key;return c.jsxs("button",{onClick:()=>{ee(ce.key),Ue(Te),V(!0)},className:`w-full text-left px-2 py-1.5 rounded-md border transition-colors ${et?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-elevated border-border-subtle text-fg-secondary hover:bg-surface-overlay"}`,children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"w-4 shrink-0 text-center text-[11px]",children:YP(ce.key)}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium",children:ce.name||(ce.kind==="none"||!ce.key?i("agent:profilePage.mind.unitOrphan","历史记录"):S0(ce.key))})]}),c.jsxs("div",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[i("agent:profilePage.mind.itemCount",{count:ce.count})," · ",ce.latestAt?new Date(ce.latestAt).toLocaleTimeString():"—"]})]},ce.key||"__none__")}),K&&c.jsx("div",{ref:ie,className:"flex items-center justify-center py-2 text-[10px] text-fg-tertiary",children:i("agent:profilePage.mind.scrollForMore","下滑加载更多")})]}),ve&&c.jsx("div",{className:"@2xl:hidden absolute inset-0 z-30 bg-black/40",onClick:()=>V(!1)}),c.jsxs("div",{className:`
82
+ absolute inset-y-0 right-0 z-40 w-full max-w-none @sm:w-[86%] @sm:max-w-md overflow-y-auto bg-surface-primary border-l border-border-default shadow-2xl px-3 pb-3
83
+ transition-transform duration-200 ease-out
84
+ ${ve?"translate-x-0":"translate-x-full"}
85
+ @2xl:static @2xl:z-auto @2xl:w-auto @2xl:max-w-none @2xl:translate-x-0 @2xl:overflow-y-auto
86
+ @2xl:bg-transparent @2xl:border-0 @2xl:shadow-none @2xl:p-0
87
+ @2xl:flex-1 @2xl:min-w-0 @2xl:max-h-[30rem] space-y-1
88
+ `,children:[c.jsxs("div",{className:"@2xl:hidden sticky top-0 z-10 -mx-3 mb-2 px-3 py-2 bg-surface-primary border-b border-border-default flex items-center gap-2",children:[c.jsx("span",{className:"text-[11px] font-medium text-fg-secondary truncate flex-1",children:ze?.name||(ze?.key?S0(ze.key):"")}),c.jsx("button",{onClick:()=>V(!1),className:"text-fg-tertiary hover:text-fg-primary text-sm px-1","aria-label":i("common:close"),children:"✕"})]}),(()=>{const ce=Ie.flatMap(xe=>xe.decisions??[]);if(ce.length===0)return null;const et=new Map;for(const xe of ce){const gt=et.get(xe.decisionType);gt?gt.push(xe):et.set(xe.decisionType,[xe])}return c.jsxs("div",{className:"mb-2 rounded-lg border border-border-subtle bg-surface-elevated/40 px-2 py-1.5",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary mb-1",children:i("agent:profilePage.mind.roundDecisions","本轮决策")}),c.jsx("div",{className:"space-y-0.5",children:[...et.entries()].map(([xe,gt])=>c.jsxs("div",{className:"flex items-baseline gap-2 text-[11px]",children:[c.jsx("span",{className:"shrink-0 font-medium text-fg-primary",children:xe}),c.jsxs("span",{className:"shrink-0 tabular-nums text-fg-tertiary",children:["×",gt.length]}),c.jsx("span",{className:"truncate text-fg-secondary",title:gt[0]?.reasoning??"",children:gt[0]?.reasoning??""})]},xe))})]})})(),Ie.length===0&&X.length>0&&c.jsx("p",{className:"text-xs text-fg-tertiary py-6 text-center",children:ze&&ze.key.startsWith("channel:loop_")?i("agent:profilePage.mind.loopIdle","这段时间没有需要它判断的信号 —— 它在睡或已完成处置"):i("agent:profilePage.mind.unitEmpty","这个实体目前没有记录")}),Ie.map(ce=>{const et=k===ce.id,xe=zc(ce.sourceType),gt=zv(ce,i),He=zI({itemStatus:ce.status,agentRunning:dt,currentFocusMailboxItemId:n?.currentFocus?.mailboxItemId??null,itemId:ce.id}),Ct=ce.metadata?.senderName,vt=ce.metadata?.senderRole,de=P===ce.id;return c.jsxs("div",{id:`mbx-${ce.id}`,className:`bg-surface-elevated rounded-lg border transition-colors duration-1000 ${de?"border-brand-500 ring-1 ring-brand-500/40":ce.status==="bounced"||ce.status==="catch_all"?"border-border-subtle border-l-2 border-l-red-500":"border-border-subtle"}`,children:[c.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2 text-left hover:bg-surface-overlay/50 transition-colors rounded-lg",onClick:()=>{const we=et?null:ce.id;C(we),we&&ce.contentTruncated&&!Xe[we]&&ft(we)},children:[c.jsx("span",{className:"hidden @sm:inline text-xs mt-0.5 text-fg-tertiary",children:et?"▾":"▸"}),c.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${He==="stale"?"bg-amber-400/70":f3[ce.status]??"bg-gray-400"}`}),c.jsx("span",{className:"text-sm",children:xe}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:`text-xs font-medium text-fg-primary break-words ${et?"":"truncate"}`,children:gt.title}),gt.subtitle&&c.jsx("div",{className:`text-[11px] text-fg-secondary mt-0.5 break-words ${et?"":"truncate"}`,children:gt.subtitle}),c.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap items-center",children:[c.jsx("span",{children:UI(ce.queuedAt)}),ce.completedAt&&c.jsxs("span",{children:["→ ",HI(ce.completedAt)]}),ce.activity&&c.jsxs(c.Fragment,{children:[ce.activity.totalTokens>0&&c.jsx("span",{className:"hidden @sm:inline",children:i("agent:profilePage.mind.tokensCount",{count:Km(ce.activity.totalTokens)})}),ce.activity.totalTools>0&&c.jsx("span",{className:"hidden @sm:inline",children:i("agent:profilePage.mind.toolsCount",{count:ce.activity.totalTools})})]}),gt.badge&&c.jsx("span",{className:`font-medium ${gt.badge.color}`,children:gt.badge.label}),c.jsx("span",{className:Xv[ce.priority]??"text-fg-tertiary",children:i(`agent:profilePage.mind.priority.${Wv[ce.priority]??ce.priority}`,{defaultValue:""})})]})]}),r&&XI({agentRunning:dt,itemId:ce.id,currentFocusId:n?.currentFocus?.mailboxItemId??null,itemStatus:ce.status})&&c.jsxs("button",{onClick:we=>{we.stopPropagation(),W(ce.id)},className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-red-500/15 text-red-500 hover:bg-red-500/25 transition-colors shrink-0",children:["✕ ",i("agent:profilePage.mind.cancelCurrentBtn")]})]}),et&&c.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[c.jsx("div",{className:"text-[10px] text-fg-tertiary",children:c.jsx("span",{className:"bg-surface-overlay px-1.5 py-0.5 rounded",children:ce.sourceType})}),Ct&&c.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[i("agent:profilePage.mind.from")," ",c.jsx("span",{className:"text-fg-secondary",children:Ct}),vt&&c.jsxs("span",{className:"text-fg-tertiary",children:[" (",vt,")"]})]}),["human_chat","a2a_message","task_comment","requirement_comment","review_request","session_reply","mention"].includes(ce.sourceType)&&c.jsx("div",{className:"text-xs text-fg-secondary bg-surface-primary/50 rounded-md p-2.5 whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:Xe[ce.id]??ce.payload?.content??c.jsx("span",{className:"text-fg-tertiary",children:i("agent:profilePage.mind.loadingContent","正在载入完整正文…")})}),ce.decisions&&ce.decisions.length>0&&c.jsxs("div",{children:[c.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:i("agent:profilePage.mind.decisions")}),c.jsx("div",{className:"space-y-1",children:ce.decisions.map(we=>c.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[c.jsx("span",{className:`px-1.5 py-0.5 rounded shrink-0 ${h3[we.decisionType]??"bg-gray-500/20 text-gray-500"}`,children:we.decisionType}),c.jsx("span",{className:"text-fg-secondary flex-1",children:we.reasoning}),c.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date(we.createdAt).toLocaleTimeString()})]},we.id))})]}),r&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider",children:i("agent:profilePage.mind.actions")}),c.jsx("div",{className:"flex gap-2",children:c.jsx("button",{disabled:U===ce.id,onClick:()=>{_e(ce.id)},className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-red-500/15 text-red-400 hover:bg-red-500/25 disabled:opacity-40 transition-colors",children:i("agent:profilePage.mind.dropBtn")})})]}),ce.activity?c.jsxs("div",{children:[c.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:[i("agent:profilePage.mind.activityHeading",{label:ce.activity.label}),c.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${ce.activity.success?"bg-green-500/15 text-green-500":"bg-red-500/15 text-red-500"}`,children:ce.activity.success?i("agent:profilePage.mind.success"):i("agent:profilePage.mind.failed")})]}),ce.activity.type==="task"&&ce.payload?.taskId?c.jsx(l3,{taskId:ce.payload.taskId,isLive:qO(ce.activity,te)}):c.jsx(c3,{agentId:s,activityId:ce.activity.id,isLive:qO(ce.activity,te)})]}):He==="processing"?c.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:i("agent:profilePage.mind.processing")}):He==="stale"?c.jsx("div",{className:"text-xs text-amber-600 text-center py-2",children:i("agent:profilePage.mind.staleProcessingWarning")}):ce.status==="completed"?c.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:i("agent:profilePage.mind.noActivityLog")}):null]})]},ce.id)}),Ie.length>Fe&&c.jsx("button",{onClick:()=>Ue(ce=>ce+Te),className:"w-full text-center text-[11px] text-brand-400 hover:text-brand-300 py-2",children:i("agent:profilePage.mind.showMoreCount",{count:Ie.length-Fe})})]})]})})})()]}),R&&c.jsx(qo,{title:i("agent:profilePage.mind.cancelConfirmTitle"),message:i("agent:profilePage.mind.cancelConfirmMessage"),confirmLabel:i("agent:profilePage.mind.cancelCurrentBtn"),onConfirm:()=>{const ye=R;W(null),ne.agents.cancelProcessing(s,{itemId:ye}).then(()=>{let ze=0;const Ie=()=>{ze+=1,me(),ze<8&&window.setTimeout(Ie,750)};Ie()}).catch(()=>{me()})},onCancel:()=>W(null)})]})}function qv({agentId:s}){const{t:e}=Tt(["agent","common"]),t=zo(),r=H_(()=>ne.deliverables.search({agentId:s,limit:200}).then(l=>l.results),{deps:[s]}),i=r.resource.items,n=r.view.loading,a=r.reload,o=w.useCallback(l=>{if(GP(t?.hostAvailable)==="right-panel"){t?.openRightPanel({kind:"deliverable",deliverable:l});return}gr.navigate(Ut.DELIVERABLES,{openDeliverable:l.id})},[t]);return w.useEffect(()=>{const l=Rt.on("deliverable:created",()=>a()),h=Rt.on("deliverable:updated",()=>a()),u=Rt.on("deliverable:removed",()=>a());return()=>{l(),h(),u()}},[a]),n?c.jsx("div",{className:"space-y-3 py-4",children:[1,2,3].map(l=>c.jsxs("div",{className:"animate-pulse space-y-2",children:[c.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),c.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},l))}):r.view.error?c.jsx(sy,{variant:"inline",subject:e("common:deliverables"),error:r.resource.error??e("common:readFailed"),notEquals:e("agent:profilePage.noDeliverables"),onRetry:a}):i.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[c.jsx("span",{className:"text-3xl mb-3",children:"📦"}),c.jsx("p",{className:"text-sm text-fg-secondary",children:e("agent:deliverables.empty")}),c.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:e("agent:deliverables.emptyHint")})]}):c.jsx(c.Fragment,{children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:e("agent:deliverables.count",{count:i.length})}),i.map(l=>{const h=$C[l.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},u=NO[l.status]??NO.active;return c.jsxs("button",{onClick:()=>o(l),className:"w-full text-left rounded-xl border border-border-default bg-surface-elevated/30 overflow-hidden transition-colors hover:border-brand-500/40 hover:bg-surface-elevated/50 px-4 py-3 flex items-start gap-3",children:[c.jsx("span",{className:`inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 ${h.color}`,children:h.icon}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:l.title}),c.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${u.color}`,children:l.status})]}),l.summary&&c.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:l.summary}),c.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-tertiary",children:[c.jsx("span",{children:new Date(l.createdAt).toLocaleDateString()}),l.tags.length>0&&c.jsx("span",{children:l.tags.slice(0,3).join(", ")})]})]}),c.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]},l.id)})]})})}const g3=w.lazy(()=>ry(()=>import("./MarkdownMessage-CaLBeMto.js"),__vite__mapDeps([0,1,2])).then(s=>({default:s.MarkdownMessage}))),vg=[{key:"overview",labelKey:"teamProfile.overview",icon:"▦"},{key:"announcements",labelKey:"teamProfile.announcements",icon:"◈"},{key:"norms",labelKey:"teamProfile.norms",icon:"☰"},{key:"settings",labelKey:"teamProfile.settings",icon:"⚙"}],Zv={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",offline:"bg-gray-500",error:"bg-red-400"};function Vv({teamId:s,onBack:e,inline:t,headless:r,activeTab:i,onSelectAgent:n}){const{t:a}=Tt(["team","common","work","agent"]),[o,l]=w.useState(null),[h,u]=w.useState(!0),[d,f]=w.useState(!0),[p,v]=w.useState(null),[b,O]=w.useState("overview"),g=r&&i?i:b,[m,x]=w.useState(""),[y,k]=w.useState(""),[C,P]=w.useState(!1),[_,Q]=w.useState(!1),[E,A]=w.useState(""),[N,R]=w.useState(""),W=w.useRef(null),H=w.useRef(null),Z=w.useRef(null),B=w.useRef(null),[K,$]=w.useState(!1),[I,X]=w.useState(!1),[q,ie]=w.useState(""),[pe,$e]=w.useState(""),[re,U]=w.useState(!1),[M,te]=w.useState([]),Y=w.useRef(null),ae=w.useCallback(async()=>{try{const Xe=(await ne.teams.list()).teams.find(ft=>ft.id===s);Xe&&l(Xe);const Ke=await ne.teams.status(s);te(Ke.agents)}catch{}finally{u(!1)}},[s]),ee=w.useCallback(async()=>{f(!0);try{const V=await ne.teams.getFile(s,"ANNOUNCEMENT.md");x(V.content)}catch{x("")}try{const V=await ne.teams.getFile(s,"NORMS.md");k(V.content)}catch{k("")}finally{f(!1)}},[s]);w.useEffect(()=>{O("overview"),ae(),ee()},[s,ae,ee]),w.useEffect(()=>{C&&H.current&&H.current.focus()},[C]),w.useEffect(()=>{_&&B.current&&B.current.focus()},[_]);const me=async(V,Xe)=>{$(!0);try{await ne.teams.updateFile(s,V,Xe),V==="ANNOUNCEMENT.md"?(x(Xe),P(!1)):(k(Xe),Q(!1))}catch{}$(!1)},Re=async()=>{q.trim()&&(await ne.teams.update(s,{name:q.trim()}),X(!1),ae())},_e=async()=>{await ne.teams.update(s,{description:pe}),U(!1),ae()};if(!o)return h?c.jsx(ay,{label:a("common:loading",{defaultValue:"Loading…"})}):c.jsx(w2,{icon:c.jsx("span",{className:"text-2xl",children:"🫥"}),title:a("teamProfile.teamMissing",{defaultValue:"Team not found"})});const De=o.members.find(V=>V.agentRole==="manager"),Te=M.filter(V=>V.status!=="offline").length,Fe=V=>{const{labelKey:Xe}=vl(V);return Xe?a(Xe):V??"offline"},Ue=g==="announcements"&&C||g==="norms"&&_;if(r)return c.jsx("div",{className:`flex-1 bg-surface-primary ${Ue?"flex flex-col overflow-hidden":"overflow-y-auto"}`,children:c.jsxs("div",{className:`${Ue?"flex-1 flex flex-col min-h-0 p-5":"p-5"}`,children:[g==="overview"&&c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("agent:profilePage.badges.manager")}),c.jsx("div",{className:"text-sm font-medium",children:De?.name??o.managerName??a("common:none")})]}),c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("team:teamProfile.teamId")}),c.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:o.id})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-xs text-fg-tertiary font-medium px-1",children:a("team:page.members")}),o.members.map(V=>{const Xe=M.find(mt=>mt.id===V.id),Ke=Zv[Xe?.status??"offline"]??"bg-gray-500",ft=V.type==="agent";return c.jsxs("div",{onClick:()=>ft&&n?.(V.id),className:`p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3${ft&&n?" cursor-pointer hover:border-brand-500/40 transition-colors":""}`,children:[c.jsx(Is,{name:V.name,avatarUrl:V.avatarUrl,size:32,className:"rounded-lg"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium",children:V.name}),c.jsx("span",{className:`w-2 h-2 rounded-full ${Ke}`}),c.jsx("span",{className:"text-xs text-fg-tertiary",children:Fe(Xe?.status)}),V.agentRole==="manager"&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:a("agent:profilePage.badges.manager")})]}),c.jsxs("div",{className:"text-xs text-fg-tertiary",children:[V.role," · ",V.type]})]}),ft&&n&&c.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})]},V.id)}),o.members.length===0&&c.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:a("team:teamProfile.noMembers")})]})]}),g==="announcements"&&c.jsx(Zc,{content:m,draft:E,setDraft:A,editing:C,setEditing:P,textareaRef:H,contentRef:W,saving:K,onSave:()=>me("ANNOUNCEMENT.md",E),placeholder:a("teamProfile.annPlaceholder"),emptyText:a("teamProfile.noAnnouncements"),loading:d}),g==="norms"&&c.jsx(Zc,{content:y,draft:N,setDraft:R,editing:_,setEditing:Q,textareaRef:B,contentRef:Z,saving:K,onSave:()=>me("NORMS.md",N),placeholder:a("teamProfile.normsPlaceholder"),emptyText:a("teamProfile.noNorms"),loading:d}),g==="settings"&&c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("team:modals.createTeam.teamName")}),I?c.jsxs("div",{className:"flex gap-2 items-center",children:[c.jsx("input",{ref:Y,value:q,onChange:V=>ie(V.target.value),onKeyDown:V=>V.key==="Enter"&&Re(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),c.jsx("button",{onClick:Re,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-on-brand",children:a("common:save")}),c.jsx("button",{onClick:()=>X(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:a("common:cancel")})]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm",children:o.name}),c.jsx("button",{onClick:()=>{ie(o.name),X(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:a("common:edit")})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("work:project.description")}),re?c.jsxs("div",{className:"space-y-2",children:[c.jsx("textarea",{value:pe,onChange:V=>$e(V.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:_e,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-on-brand",children:a("common:save")}),c.jsx("button",{onClick:()=>U(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:a("common:cancel")})]})]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-fg-secondary",children:o.description||a("work:task.noDescription")}),c.jsx("button",{onClick:()=>{$e(o.description??""),U(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:a("common:edit")})]})]})]}),c.jsx(Fv,{teamId:s,teamName:o.name,onDeleted:e})]})]})});const ve=b==="announcements"&&C||b==="norms"&&_;return c.jsxs("div",{className:`flex-1 bg-surface-primary ${ve?"flex flex-col overflow-hidden":"overflow-y-auto"}`,children:[c.jsxs("div",{className:"px-5 py-3.5 bg-surface-secondary sticky top-0 z-10 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-on-brand flex items-center justify-center text-lg font-bold shrink-0",children:c.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsx("h2",{className:"text-base font-semibold",children:o.name}),c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:a("common:units.members",{count:o.members.length})}),c.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:a("team:teamProfile.onlineCount",{count:Te})})]}),c.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:o.description||a("work:task.noDescription")})]}),c.jsxs("button",{onClick:async()=>{if(o)try{const{files:V}=await ne.teams.getFilesMap(o.id),Xe=o.members.filter(ft=>ft.type==="agent"),Ke={type:"team",name:ty(o.name,o.name),displayName:o.name,version:"1.0.0",description:o.description??"",author:"",category:"general",tags:[],team:{members:Xe.map(ft=>({name:ft.name,roleName:ft.role,role:ft.agentRole??"worker",count:1,skills:[]}))}};await ap.publishViaProxy({itemType:"team",name:o.name,description:o.description??"",category:"general",config:Ke,files:V}),v({title:"Hub",message:a("agent:profilePage.publishSuccess",{name:o.name}),variant:"primary"})}catch(V){v({title:"Hub",message:a("agent:profilePage.publishFailed",{error:String(V)}),variant:"danger"})}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:a("common:publishToHub"),children:[c.jsx("span",{children:"↑"})," Hub"]}),t&&c.jsx("button",{onClick:e,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),c.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:vg.map(V=>c.jsxs("button",{onClick:()=>O(V.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${b===V.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[V.icon," ",a(V.labelKey)]},V.key))})]}),c.jsxs("div",{className:`${ve?"flex-1 flex flex-col min-h-0 p-5":"p-5"}`,children:[b==="overview"&&c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("agent:profilePage.badges.manager")}),c.jsx("div",{className:"text-sm font-medium",children:De?.name??o.managerName??a("common:none")})]}),c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("team:teamProfile.teamId")}),c.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:o.id})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-xs text-fg-tertiary font-medium px-1",children:a("team:page.members")}),o.members.map(V=>{const Xe=M.find(mt=>mt.id===V.id),Ke=Zv[Xe?.status??"offline"]??"bg-gray-500",ft=V.type==="agent";return c.jsxs("div",{onClick:()=>ft&&n?.(V.id),className:`p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3${ft&&n?" cursor-pointer hover:border-brand-500/40 transition-colors":""}`,children:[c.jsx(Is,{name:V.name,avatarUrl:V.avatarUrl,size:32,className:"rounded-lg"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium",children:V.name}),c.jsx("span",{className:`w-2 h-2 rounded-full ${Ke}`}),c.jsx("span",{className:"text-xs text-fg-tertiary",children:Fe(Xe?.status)}),V.agentRole==="manager"&&c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:a("agent:profilePage.badges.manager")})]}),c.jsxs("div",{className:"text-xs text-fg-tertiary",children:[V.role," · ",V.type]})]}),ft&&n&&c.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})]},V.id)}),o.members.length===0&&c.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:a("teamProfile.noMembers",{defaultValue:"No members"})})]})]}),b==="announcements"&&c.jsx(Zc,{content:m,draft:E,setDraft:A,editing:C,setEditing:P,textareaRef:H,contentRef:W,saving:K,onSave:()=>me("ANNOUNCEMENT.md",E),placeholder:a("teamProfile.annPlaceholder"),emptyText:a("teamProfile.noAnnouncements"),loading:d}),b==="norms"&&c.jsx(Zc,{content:y,draft:N,setDraft:R,editing:_,setEditing:Q,textareaRef:B,contentRef:Z,saving:K,onSave:()=>me("NORMS.md",N),placeholder:a("teamProfile.normsPlaceholder"),emptyText:a("teamProfile.noNorms"),loading:d}),b==="settings"&&c.jsxs("div",{className:"space-y-5",children:[c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("team:modals.createTeam.teamName")}),I?c.jsxs("div",{className:"flex gap-2 items-center",children:[c.jsx("input",{ref:Y,value:q,onChange:V=>ie(V.target.value),onKeyDown:V=>V.key==="Enter"&&Re(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),c.jsx("button",{onClick:Re,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-on-brand",children:a("common:save")}),c.jsx("button",{onClick:()=>X(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:a("common:cancel")})]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm",children:o.name}),c.jsx("button",{onClick:()=>{ie(o.name),X(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:a("common:edit")})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:a("work:project.description")}),re?c.jsxs("div",{className:"space-y-2",children:[c.jsx("textarea",{value:pe,onChange:V=>$e(V.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:_e,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-on-brand",children:a("common:save")}),c.jsx("button",{onClick:()=>U(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:a("common:cancel")})]})]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-fg-secondary",children:o.description||a("work:task.noDescription")}),c.jsx("button",{onClick:()=>{$e(o.description??""),U(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:a("common:edit")})]})]})]}),c.jsx(Fv,{teamId:s,teamName:o.name,onDeleted:e})]})]}),p&&c.jsx(qo,{alertOnly:!0,variant:p.variant??"primary",title:p.title,message:p.message,onConfirm:()=>v(null),onCancel:()=>v(null)})]})}function Zc({content:s,draft:e,setDraft:t,editing:r,setEditing:i,textareaRef:n,contentRef:a,saving:o,onSave:l,placeholder:h,emptyText:u,loading:d}){const{t:f}=Tt(["common"]);return r?c.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[c.jsx("textarea",{ref:n,value:e,onChange:p=>t(p.target.value),onBlur:()=>{e!==s?l():i(!1)},onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),t(s),i(!1))},className:"flex-1 w-full bg-transparent border border-brand-500/30 rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-none px-3 py-2 font-mono",placeholder:h}),o&&c.jsx("div",{className:"text-xs text-fg-tertiary mt-1 shrink-0",children:f("common:saving")})]}):c.jsx("div",{ref:a,className:"group relative cursor-pointer rounded-lg px-1 py-1 hover:bg-surface-elevated/50 transition-colors min-h-[80px]",onClick:()=>{t(s),i(!0)},role:"button",tabIndex:0,onKeyDown:p=>{p.key==="Enter"&&(t(s),i(!0))},children:d&&!s.trim()?c.jsx(ly,{variant:"text",className:"px-1 py-2"}):s.trim()?c.jsx(w.Suspense,{fallback:c.jsx("div",{className:"text-xs text-fg-tertiary",children:f("common:loading")}),children:c.jsx(g3,{content:s,className:"text-sm text-fg-secondary leading-relaxed"})}):c.jsx("div",{className:"text-sm text-fg-tertiary italic",children:u})})}function Fv({teamId:s,teamName:e,onDeleted:t}){const{t:r}=Tt(["team","common","work"]),[i,n]=w.useState(!1),[a,o]=w.useState(!1),[l,h]=w.useState(!1),[u,d]=w.useState(!1);return c.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[c.jsx("div",{className:"text-sm font-medium text-red-500",children:r("work:project.dangerZone")}),i?c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"text-xs text-fg-secondary",children:r("team:teamProfile.deleteTeamConfirm",{name:e})}),c.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:l,onChange:f=>h(f.target.checked),className:"rounded"}),r("team:modals.deleteTeam.deleteMembers")]}),c.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:a,onChange:f=>o(f.target.checked),className:"rounded"}),r("team:modals.deleteTeam.purgeFiles")]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{disabled:u,onClick:async()=>{d(!0);try{await ne.teams.delete(s,l,{purgeFiles:a}),window.dispatchEvent(new CustomEvent("markus:data-changed")),t()}catch{d(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:r(u?"common:deleting":"common:confirmDelete")}),c.jsx("button",{onClick:()=>n(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors border border-border-default",children:r("common:cancel")})]})]}):c.jsx("button",{onClick:()=>n(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:r("team:contextMenu.deleteTeam")})]})}const O3=["chat","overview","deliverables"],x3=["chat","overview","announcements","norms","settings"];function b3(s,e){if(s==="chat")return e("page.chatTitle");if(bg.find(i=>i.key===s))return e(`agent:tabs.${s}`);const r=vg.find(i=>i.key===s);return r?e(r.labelKey):s}function v3(s){if(s==="chat")return"💬";const e=bg.find(r=>r.key===s);if(e)return e.icon;const t=vg.find(r=>r.key===s);return t?t.icon:""}function zi(s){return s!=="chat"}function Aa(s,e,t,r){return s==="channel"?`ch:${t}`:s==="dm"?`dm:${r??""}`:e||"_direct"}const Jm=s=>!!s&&!s.startsWith("ch:")&&!s.startsWith("dm:")&&s!=="_direct";class Ns{currentConvKey="";loadingSession=null;buffers=new Map;view=new Map;viewReader={get:e=>this.view.get(e)};get activeSessions(){return this.viewReader}actBuffers=new Map;sessionTabs=new Map;windowBounds=new Map;getWindowBounds(e){return this.windowBounds.get(e)??{hasMore:!1,oldestCursor:null}}setWindowBounds(e,t){this.windowBounds.set(e,t)}phase=new Map;sendCount=new Map;streamingSessions=new Map;bufferOrder=[];static MAX_MESSAGES=500;static MAX_BUFFERS=30;static NEW_CHAT_ID="__new_chat__";getPhase(e){const t=this.phase.get(e)??"idle";return t==="streaming"?t:this.hasLiveStream(e)?"streaming":t}hasLiveStream(e){return(this.streamingSessions.get(e)?.size??0)>0}beginLoad(e){this.getPhase(e)!=="streaming"&&this.phase.set(e,"loading")}completeLoad(e){this.getPhase(e)==="loading"&&this.phase.set(e,"ready")}beginStream(e){this.phase.set(e,"streaming")}endStream(e){this.getPhase(e)==="streaming"&&this.phase.set(e,"ready")}resetConv(e,t){this.isStreamLiveForSession(e,Ns.NEW_CHAT_ID)||(this.buffers.delete(Ns.NEW_CHAT_ID),this.windowBounds.delete(Ns.NEW_CHAT_ID),this.actBuffers.delete(Ns.NEW_CHAT_ID),this.actBuffers.delete(e)),t?this.view.set(e,t):this.view.delete(e)}bufferIdFor(e,t){return t??this.view.get(e)??e}updateMessages(e,t,r){const i=this.bufferIdFor(e,r);let n=t(this.buffers.get(i)??[]);n.length>Ns.MAX_MESSAGES&&(n=n.slice(-500)),this.buffers.set(i,n),this.touchBuffer(i),this.evictIfNeeded(i);const a=this.currentConvKey===e&&(this.view.get(e)??e)===i;return{displayChanged:a,newMessages:a?n:void 0}}applyLoadResult(e,t,r){const i=this.buffers.get(t)??[],n=this.isStreamLiveForSession(e,t),a=this.mergeDbWithCache(r,i,n);this.buffers.set(t,a),this.touchBuffer(t),this.evictIfNeeded(t),this.loadingSession===t&&this.completeLoad(e);const o=this.currentConvKey===e&&(this.view.get(e)??e)===t;return{displayChanged:o,newMessages:o?a:void 0}}mergeDbWithCache(e,t,r=!1){if(!t||t.length===0)return[...e];const i=new Set,n=[];for(const d of e)i.add(d.id),n.push(d);const a=[],o=[],l=e.length>0?e[e.length-1]:void 0,h=!!l&&l.sender==="agent";let u=!1;for(const d of t)if(!i.has(d.id)){if(d.sender==="agent"&&!!!(d.isError||d.isStopped||d.emptyReply)){if(r&&d.isStreaming)if(h&&l&&!u){const p=n.findIndex(v=>v.id===l.id);p>=0&&n.splice(p,1),u=!0,a.push({...d,id:l.id}),i.add(l.id)}else a.push(d),i.add(d.id);continue}o.push(d)}for(const d of o){if(i.has(d.id))continue;const f=d.rawCreatedAt?Date.parse(d.rawCreatedAt):NaN;let p=n.length;for(;p>0&&n[p-1].rawCreatedAt&&Number.isFinite(f);){const v=Date.parse(n[p-1].rawCreatedAt);if(!Number.isFinite(v)||v<=f)break;p--}n.splice(p,0,d),i.add(d.id)}for(const d of a)n.push(d);return n}appendActivity(e,t,r){const i=r??e,n=[...this.actBuffers.get(i)??[],t];if(this.actBuffers.set(i,n),this.currentConvKey!==e)return{displayChanged:!1};const a=this.view.get(e);return!r||!a||a===r?{displayChanged:!0,newActivities:n}:{displayChanged:!1}}getActiveSession(e){return this.view.get(e)}setActiveSession(e,t){if(!Jm(e))return;const r=this.view.get(e);if(r!==t&&(r===void 0||r===Ns.NEW_CHAT_ID)){this.promotePlaceholder(t),this.view.set(e,t);return}}promotePlaceholder(e){const t=this.buffers.get(Ns.NEW_CHAT_ID);if(!t||t.length===0)return;const r=this.buffers.get(e)??[],i=new Set(r.map(a=>a.id)),n=[...r,...t.filter(a=>!i.has(a.id))];this.buffers.set(e,n),this.touchBuffer(e),this.buffers.delete(Ns.NEW_CHAT_ID)}clearActiveSession(e){this.view.delete(e)}saveToCache(){}restoreFromCache(e,t){Jm(e)&&this.view.set(e,t);const r=this.buffers.get(t);if(!r||r.length===0)return;if(this.isStreamLiveForSession(e,t))return r;const n=r.filter(a=>!(a.sender==="agent"&&a.isStreaming&&!a.isStopped));if(n.length===0){this.buffers.delete(t);return}return this.buffers.set(t,n),n}isStreamLiveForSession(e,t){if(this.getPhase(e)!=="streaming")return!1;const r=this.streamingSessions.get(e);return!r||r.size===0||r.has(t)?!0:this.placeholderTurnBelongsTo(e,t)}placeholderTurnBelongsTo(e,t){const r=this.streamingSessions.get(e);return!r||!r.has(Ns.NEW_CHAT_ID)?!1:this.view.get(e)===t}incrementSend(e){this.sendCount.set(e,(this.sendCount.get(e)??0)+1)}decrementSend(e){const t=Math.max(0,(this.sendCount.get(e)??1)-1);return this.sendCount.set(e,t),t}resetSend(e){this.sendCount.set(e,0)}isSending(e){return(this.sendCount.get(e)??0)>0}addStreamSession(e,t){const r=this.streamingSessions.get(e)??new Set;return r.has(t)?(this.streamingSessions.set(e,r),!1):(r.add(t),this.streamingSessions.set(e,r),!0)}removeStreamSession(e,t){if(t){const r=this.streamingSessions.get(e);return!r||!r.has(t)?!1:(r.delete(t),r.size===0&&this.streamingSessions.delete(e),!0)}return this.streamingSessions.delete(e)}getStreamSessions(e){return this.streamingSessions.get(e)}abortStream(e,t){let r=!1;(this.sendCount.get(e)??0)>0&&(this.sendCount.set(e,0),r=!0);const i=t??e;if(this.actBuffers.delete(i)&&(r=!0),this.getPhase(e)==="streaming"&&(this.phase.set(e,"ready"),r=!0),t){const n=this.streamingSessions.get(e)?.has(t)??!1;this.removeStreamSession(e,t),n&&(r=!0)}else this.streamingSessions.delete(e)&&(r=!0);return r}getMessages(e){return this.buffers.get(this.view.get(e)??e)}getActivities(e){return this.actBuffers.get(e)??[]}deleteBuffer(e){this.buffers.delete(e),this.windowBounds.delete(e)}viewBufferId(){const e=this.currentConvKey;return this.view.get(e)??e}protectedBufferIds(){const e=new Set(this.view.values());e.add(this.viewBufferId());for(const t of this.streamingSessions.values())for(const r of t)e.add(r);for(const[t,r]of this.phase)r==="streaming"&&!this.streamingSessions.get(t)?.size&&(e.add(Ns.NEW_CHAT_ID),e.add(this.view.get(t)??t));return e}evictIfNeeded(e){if(this.buffers.size<=Ns.MAX_BUFFERS)return;const t=this.protectedBufferIds();t.add(e);for(const r of[...this.buffers.keys()]){if(this.buffers.size<=Ns.MAX_BUFFERS)break;t.has(r)||(this.deleteBuffer(r),this.actBuffers.delete(r))}}touchBuffer(e){const t=this.bufferOrder.indexOf(e);for(t!==-1&&this.bufferOrder.splice(t,1),this.bufferOrder.push(e);this.bufferOrder.length>Ns.MAX_BUFFERS;){const r=this.bufferOrder.shift();if(this.protectedBufferIds().has(r)){this.bufferOrder.push(r);break}this.deleteBuffer(r),this.actBuffers.delete(r)}}}const lt=Ns.NEW_CHAT_ID;function y3(s){const e=w.useRef(new Ns),[t,r]=w.useState(s??[]),[i,n]=w.useState(!1),[a,o]=w.useState([]),l=w.useRef(null),[,h]=w.useState(0),u=w.useCallback(()=>h(E=>E+1),[]),d=w.useCallback(E=>e.current.getStreamSessions(E),[]),f=w.useCallback((E,A)=>{e.current.addStreamSession(E,A)&&u()},[u]),p=w.useCallback((E,A)=>{e.current.removeStreamSession(E,A)&&u()},[u]),v=w.useCallback((E,A)=>e.current.setActiveSession(E,A),[]),b=w.useCallback(E=>e.current.clearActiveSession(E),[]);w.useEffect(()=>()=>{l.current!==null&&cancelAnimationFrame(l.current)},[]);const O=w.useCallback((E,A,N)=>{const R=e.current.updateMessages(E,A,N);R.displayChanged&&R.newMessages&&r(R.newMessages)},[]),g=w.useCallback((E,A,N)=>{e.current.updateMessages(E,A,N).displayChanged&&l.current===null&&(l.current=requestAnimationFrame(()=>{l.current=null;const W=e.current.getMessages(E);W&&e.current.currentConvKey===E&&r([...W])}))},[]),m=w.useCallback((E,A,N)=>{const R=e.current.appendActivity(E,A,N);R.displayChanged&&R.newActivities&&o(R.newActivities)},[]),x=w.useCallback(E=>e.current.getPhase(E),[]),y=w.useCallback(E=>e.current.beginLoad(E),[]),k=w.useCallback(E=>{e.current.beginStream(E)},[]),C=w.useCallback(E=>{e.current.endStream(E)},[]),P=w.useCallback((E,A)=>{e.current.abortStream(E,A)&&u(),e.current.currentConvKey===E&&(n(!1),o([]))},[u]),_=w.useCallback((E,A)=>{e.current.resetConv(E,A)},[]),Q=w.useCallback(async(E,A,N)=>{e.current.loadingSession=E,e.current.beginLoad(A);try{const R=await N(),W=e.current.applyLoadResult(A,E,R.messages);return W.displayChanged&&W.newMessages&&r(W.newMessages),{count:R.messages.length,hasMore:R.hasMore,oldestCursor:R.oldestCursor}}catch{return e.current.currentConvKey===A&&e.current.getPhase(A)!=="streaming"&&(r([]),e.current.completeLoad(A)),{count:0,hasMore:!1,oldestCursor:null}}},[]);return{manager:e.current,messages:t,setMessages:r,sending:i,setSending:n,activities:a,setActivities:o,get buffers(){return e.current.buffers},get viewBuffer(){return e.current.activeSessions},get activeSessionBuffer(){return e.current.activeSessions},get actBuffers(){return e.current.actBuffers},get sessionTabsBuffer(){return e.current.sessionTabs},get currentConvKeyRef(){return{get current(){return e.current.currentConvKey},set current(E){e.current.currentConvKey=E}}},get loadingSessionRef(){return{get current(){return e.current.loadingSession},set current(E){e.current.loadingSession=E}}},updateConvMsgs:O,updateConvMsgsRaf:g,appendConvActivity:m,getPhase:x,beginLoad:y,beginStream:k,endStream:C,resetConv:_,abortStream:P,loadAndDisplay:Q,setActiveSession:v,clearActiveSession:b,incrementSending:E=>e.current.incrementSend(E),decrementSending:E=>e.current.decrementSend(E),resetSending:E=>e.current.resetSend(E),isSendingFor:E=>e.current.isSending(E),setStreamSession:f,clearStreamSession:p,getStreamSession:d,saveSessionToCache:(E,A)=>e.current.saveToCache(),restoreSessionFromCache:(E,A)=>{const N=e.current.restoreFromCache(E,A);return r(N??[]),N},readConvMsgs:E=>e.current.getMessages(E),readSessionMsgs:E=>e.current.buffers.get(E),writeConvMsgs:(E,A)=>{const N=e.current.updateMessages(E,()=>A);N.displayChanged&&N.newMessages&&r(N.newMessages)}}}function Nf(s,e){return!s||s===e?{kind:"skip"}:{kind:"cancel",target:{sessionId:s}}}function Uv(){const s=new Uint8Array(12);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(s);else for(let t=0;t<s.length;t++)s[t]=Math.floor(Math.random()*256);let e="";for(const t of s)e+=t.toString(16).padStart(2,"0");return`cm_${e}`}function S3(s){const e=w.useRef(new Map),t=w.useRef(new Map),r=Ue=>{if(Ue)for(const[ve,V]of e.current)V===Ue&&e.current.delete(ve)},i=Ue=>{if(Ue)for(const[ve,V]of t.current)V===Ue&&t.current.delete(ve)},n=Ue=>{const ve=e.current.get(Ue);ve&&(ve.abort(),e.current.delete(Ue));const V=t.current.get(Ue);V&&(V.abort(),t.current.delete(Ue))},a=Ue=>{const ve=e.current.get(lt);ve&&e.current.size===1&&(e.current.delete(lt),e.current.set(Ue,ve))},o=w.useRef(new Map),l=w.useRef(new Set),h=w.useRef(null),u=w.useRef(new Map),d=w.useRef(0),{stateRef:f}=s,{actBuffers:p,activeSessionBuffer:v,readConvMsgs:b,readSessionMsgs:O,currentConvKeyRef:g,updateConvMsgs:m,updateConvMsgsRaf:x,appendConvActivity:y,beginStream:k,endStream:C,abortStream:P,clearStreamSession:_,setStreamSession:Q,getStreamSession:E,setActiveSession:A,incrementSending:N,decrementSending:R,loadAndDisplay:W,sessionSwitchSeqRef:H,setSending:Z,setActivities:B,setInput:K,setChatContext:$,setPendingImages:I,setMentionDropdown:X,setChatReplyTo:q,setActiveSessionId:ie,setStoredActiveSession:pe,setOpenSessionTabs:$e,setSessions:re,setLoadingChat:U,setWindowBounds:M,makeConvKey:te,makeDmChannel:Y,addRecentMsgId:ae,resumeChatScrollFollow:ee,loadSessions:me}=s,{t:Re}=s,_e=w.useCallback(async(Ue,ve)=>{const V=H.current,Xe=g.current===ve&&(b(ve)?.length??0)===0;Xe&&U(!0);try{const{count:Ke,hasMore:ft,oldestCursor:mt}=await W(Ue,ve,async()=>{const _t=await ne.sessions.getMessages(Ue,50);return{messages:_t.messages.map(mh).filter(dt=>dt.sender!=="agent"||dt.text||dt.segments&&dt.segments.length>0||dt.isStreaming),hasMore:_t.hasMore,oldestCursor:_t.messages[0]?new Date(_t.messages[0].createdAt).toISOString():null}});return M(Ue,{hasMore:ft,oldestCursor:mt}),Ke}finally{Xe&&g.current===ve&&H.current===V&&U(!1)}},[W,b,H]),De=()=>{const Ue=f.current.chatMode==="direct"?f.current.selectedAgent:null;if(Ue){const ve=Nf(f.current.activeSessionId,lt);ve.kind==="cancel"&&ne.agents.cancelProcessing(Ue,ve.target).catch(()=>{})}n(f.current.activeSessionId??lt),Ue&&f.current.activeSessionId&&f.current.activeSessionId!==lt&&l.current.add(f.current.activeSessionId),P(g.current,f.current.activeSessionId)},Te=w.useCallback(async(Ue,ve,V)=>{if(!Ue||!ve||ve===lt||l.current.has(ve))return;let Xe=null;try{const Ke=e.current.get(ve);if(Ke&&!Ke.signal.aborted&&E(V)?.has(ve)){g.current===V&&Z(!0);return}const ft=()=>{KC({liveSessions:E(V),sessionId:ve,placeholderId:lt})&&(_(V,ve),g.current===V&&(Z(!1),m(V,ue=>gu(ue),ve)))},mt=`${Ue}:${ve}`,_t=o.current.get(mt)??0;if(Date.now()-_t<1500)return;o.current.set(mt,Date.now());let Xt;const dt=await ne.sessions.streamStatus(Ue,ve);dt.messageId&&(Xt=dt.messageId);const Dt=O(ve)??[],Me=dt.status==="streaming",jt=JC(Dt,{expectedMessageId:dt.messageId,allowCurrentTurnPartial:Me}),ye=!!dt.active&&(dt.status==="done"||dt.status==="error")&&!!jt?.isStreaming;if(O0({aborted:!1,sawTerminal:ye,serverStatus:x0(dt.status)})==="finalize"){ft();return}o.current.set(mt,Date.now());for(const ue of t.current.values())ue.abort();t.current.clear(),Xe=new AbortController,t.current.set(ve,Xe),k(V),Z(!0),Q(V,ve);const Ie=jt&&!jt.isError&&jt.sender==="agent"?Dt.findIndex(ue=>ue.id===jt.id):-1,ce=Ie>=0?Dt[Ie]:void 0,et=e2(dt);if(!ce&&!et){ft();return}const xe=ce?ce.id:et;if(!ce)m(V,ue=>[...ue,{id:xe,sender:"agent",text:"",time:new Date().toLocaleTimeString(),isStreaming:!0,segments:[]}],ve);else{const ue=(ce.segments??[]).filter(Le=>Le.type==="tool").map(Le=>Le.status==="stopped"||Le.status==="running"?{...Le,status:"running"}:Le);m(V,Le=>Le.map(ke=>ke.id===xe?{...ke,text:"",isStreaming:!0,isStopped:!1,segments:ue,committedSegments:void 0}:ke),ve)}const gt=ue=>{g.current===V&&(d.current=Date.now(),x(V,Le=>{const ke=[...Le],nt=xe?ke.findIndex(J=>J.id===xe):-1,Ye=nt>=0?nt:ke.map((J,je)=>({m:J,j:je})).reverse().find(J=>J.m.sender==="agent"&&J.m.isStreaming)?.j??-1;if(Ye<0)return Le;const Je=ke[Ye];return ke[Ye]={...Je,text:(Je.text??"")+ue,segments:ZO(Je.segments??[],ue),isStreaming:!0},ke},ve))},He=ue=>{g.current===V&&(d.current=Date.now(),x(V,Le=>{const ke=[...Le],nt=xe?ke.findIndex(J=>J.id===xe):-1,Ye=nt>=0?nt:ke.map((J,je)=>({m:J,j:je})).reverse().find(J=>J.m.sender==="agent"&&J.m.isStreaming)?.j??-1;if(Ye<0)return Le;const Je=ke[Ye];return ke[Ye]={...Je,segments:VO(Je.segments??[],ue),isStreaming:!0},ke},ve))},Ct=ue=>{if(g.current===V&&(d.current=Date.now(),ue.phase!=="heartbeat")){if((ue.phase==="start"||ue.phase==="end")&&y(V,{...ue,phase:ue.phase,ts:Date.now()},ve),ue.phase==="start"){const Le=`${ue.tool}_${Date.now()}`,ke=new Date().toISOString(),nt=Ye=>{const Je=[...Ye];for(let J=Je.length-1;J>=0;J--){const je=Je[J];if(je.type==="tool"&&je.tool===ue.tool&&(je.status==="running"||je.status==="stopped"))return Je[J]={...je,status:"running",args:ue.arguments??je.args},Je}return Je.push({type:"tool",key:Le,tool:ue.tool,status:"running",args:ue.arguments,createdAt:ke}),Je};m(V,Ye=>{const Je=[...Ye],J=xe?Je.findIndex(Pe=>Pe.id===xe):-1;if(J<0)return Ye;const je=nt(Je[J].segments??[]),Qe=Je[J].committedSegments,be=Qe&&nt(Qe);return Je[J]={...Je[J],segments:je,committedSegments:be,isStreaming:!0},Je},ve)}else if(ue.phase==="end"){const Le=new Date().toISOString(),ke=nt=>{const Ye=[...nt];for(let Je=Ye.length-1;Je>=0;Je--){const J=Ye[Je];if(J.type==="tool"&&J.tool===ue.tool&&(J.status==="running"||J.status==="stopped")){Ye[Je]={...J,status:ue.success===!1?"error":"done",args:ue.arguments??J.args,result:ue.result,error:ue.error,durationMs:ue.durationMs,liveOutput:void 0,createdAt:Le};break}}return Ye};m(V,nt=>{const Ye=[...nt],Je=xe?Ye.findIndex(be=>be.id===xe):-1;if(Je<0)return nt;const J=ke(Ye[Je].segments??[]),je=Ye[Je].committedSegments,Qe=je&&ke(je);return Ye[Je]={...Ye[Je],segments:J,committedSegments:Qe,isStreaming:!0},Ye},ve)}else if(ue.phase==="subagent_progress"&&ue.subagentEvent){const Le=ke=>{const nt=[...ke];for(let Ye=nt.length-1;Ye>=0;Ye--){const Je=nt[Ye];if(Je.type==="tool"&&(Je.tool==="spawn_subagent"||Je.tool==="spawn_subagents")&&(Je.status==="running"||Je.status==="stopped")){nt[Ye]={...Je,status:"running",subagentLogs:FO(Je.subagentLogs,ue.subagentEvent)};break}}return nt};x(V,ke=>{const nt=[...ke],Ye=xe?nt.findIndex(Qe=>Qe.id===xe):-1;if(Ye<0)return ke;const Je=Le(nt[Ye].segments??[]),J=nt[Ye].committedSegments,je=J&&Le(J);return nt[Ye]={...nt[Ye],segments:Je,committedSegments:je,isStreaming:!0},nt},ve)}}},vt=ue=>{g.current===V&&(d.current=Date.now(),m(V,Le=>{const ke=[...Le],nt=xe?ke.findIndex(Je=>Je.id===xe):-1;if(nt<0)return Le;const Ye=[...ke[nt].committedSegments??[]];if(ue.type==="thinking_commit")Ye.push({type:"text",content:"",thinking:ue.content,createdAt:ue.createdAt});else if(ue.type==="text_commit")Ye.push({type:"text",content:ue.content,createdAt:ue.createdAt});else return Le;return ke[nt]={...ke[nt],committedSegments:Ye,isStreaming:!0},ke},ve))},de=ue=>{if(g.current!==V)return;d.current=Date.now();const Le=(ue.segments??[]).map((ke,nt)=>ke.type==="tool"?{type:"tool",key:`${ke.tool}_${nt}`,tool:ke.tool??"tool",status:ke.status==="error"?"error":ke.status==="running"||ke.status==="stopped"?"running":"done",args:ke.arguments,result:ke.result,error:ke.error,durationMs:ke.durationMs,createdAt:ke.createdAt,...ke.subagentLogs?.length?{subagentLogs:ke.subagentLogs}:{}}:{type:"text",content:ke.content??"",thinking:ke.thinking,createdAt:ke.createdAt});m(V,ke=>{const nt=[...ke],Ye=xe?nt.findIndex(Je=>Je.id===xe):-1;return Ye<0?ke:(nt[Ye]={...nt[Ye],text:ue.content||nt[Ye].text,segments:Le,committedSegments:Le,isStreaming:!0,isStopped:!1},nt)},ve);for(const ke of Le)ke.type==="tool"&&y(V,{tool:ke.tool,phase:ke.status==="running"||ke.status==="stopped"?"start":"end",success:ke.status!=="error",arguments:ke.args,result:ke.result,error:ke.error,durationMs:ke.durationMs,ts:Date.now()},ve)},we=8;let oe=null;const st=ue=>{g.current===V&&m(V,Le=>{const ke=Le.map((Ye,Je)=>({m:Ye,j:Je})).reverse().find(Ye=>Ye.m.sender==="agent"&&Ye.m.isStreaming)?.j??-1;if(ke<0||Le[ke].reconnecting===ue)return Le;const nt=[...Le];return nt[ke]={...nt[ke],reconnecting:ue},nt},ve)};for(let ue=1;ue<=we;ue++){if(Xe.signal.aborted)return;try{oe=await ne.sessions.reattachStream(Ue,ve,{onChunk:gt,onThinking:He,onActivity:Ct,onCommit:vt,onSnapshot:de},Xe.signal,0)}catch(ke){if(Xe.signal.aborted)throw ke;oe=null}if(!oe||!oe.attached){oe=null;break}if(oe.terminal)break;st(!0);const Le=await ne.sessions.streamStatus(Ue,ve).catch(()=>null);if(Le?.messageId&&(Xt=Le.messageId),!Le||!Le.active||Le.status==="not_found"||Le.status==="idle"){st(!1),oe=null;break}await new Promise(ke=>setTimeout(ke,Math.min(800*ue,4e3))),st(!1)}if(!oe){C(V),_(V,ve),g.current===V&&(Z(!1),Xt&&xe&&m(V,ue=>_a(ue,xe,Xt),ve),_e(ve,V).catch(()=>{}).finally(()=>{m(V,ue=>gu(ue,"done"),ve)})),i(Xe);return}if(g.current===V){let ue;m(V,Le=>{const ke=[...Le],nt=xe?ke.findIndex(je=>je.id===xe):-1,Ye=nt>=0?nt:ke.map((je,Qe)=>({m:je,j:Qe})).reverse().find(je=>je.m.sender==="agent"&&je.m.isStreaming)?.j??-1;if(Ye<0)return Le;const Je=ke[Ye];if(!Je.isStreaming)return Le;ue=Je.id;const J=oe.segments?.length?UO(oe.segments,Je.segments):void 0;return ke[Ye]={...Je,text:oe.content||Je.text,isStreaming:!1,isStopped:!1,reconnecting:!1,...J?{segments:J,committedSegments:J}:{}},ke},ve),ue&&m(V,Le=>_a(Le,ue,oe.messageId),ve),Z(!1)}C(V),_(V,ve),i(Xe)}catch(Ke){const ft=Xe?[...t.current.values()].includes(Xe):!1;i(Xe),C(V);const mt=l.current.has(ve);if(mt&&_(V,ve),g.current===V&&(Z(!1),ft&&mt&&m(V,_t=>gu(_t),ve)),Ke instanceof Error&&Ke.name==="AbortError")return}},[y,k,C,E,b,Q,m,x]),Fe=w.useCallback(async(Ue,ve)=>{const V=f.current,Xe=rP({text:V.input,chips:V.chatContext??[]}),Ke=Ue?Ue.trim():Xe.text,ft=Ue?Ue.trim():Xe.titleSource,mt=Ue?void 0:Xe.chips.length>0?Xe.chips:void 0;if(!Ke&&V.pendingImages.length===0||V.chatMode==="direct"&&!V.selectedAgent)return;ee();const _t=Date.now(),Xt=h.current;if(!ve?.isRetry&&!ve?.isResume&&Ke&&Xt&&Xt.text===Ke&&_t-Xt.at<1500)return;if(h.current={text:Ke,at:_t},ve?.isResume){const Ie=ve.sessionIdOverride??V.activeSessionId??"";if(_t-(u.current.get(Ie)??0)<2e3)return;u.current.set(Ie,_t)}if(V.chatMode==="direct"){if(t2({authorityStreaming:Cs.isServerConfirmedStreaming(V.activeSessionId),sendSessionId:V.activeSessionId})){const ce=g.current;if([...b(ce)??[]].reverse().find(He=>He.sender==="user")?.text===Ke&&!ve?.isRetry&&!ve?.isResume){n(V.activeSessionId??lt);const He=Nf(V.activeSessionId,lt);return He.kind==="cancel"&&ne.agents.cancelProcessing(V.selectedAgent,He.target).catch(()=>{}),P(ce,V.activeSessionId),m(ce,Ct=>{const vt=[...Ct];return vt.length>0&&vt[vt.length-1].sender==="agent"&&vt.pop(),vt.length>0&&vt[vt.length-1].sender==="user"&&vt[vt.length-1].text===Ke&&vt.pop(),vt}),await new Promise(Ct=>setTimeout(Ct,50)),Fe(Ke,{isRetry:!0})}n(V.activeSessionId??lt);const gt=Nf(V.activeSessionId,lt);gt.kind==="cancel"&&ne.agents.cancelProcessing(V.selectedAgent,gt.target).catch(()=>{}),P(ce,V.activeSessionId),m(ce,He=>HO(He)),await new Promise(He=>setTimeout(He,50))}}else if(V.sending){n(f.current.activeSessionId??g.current);const Ie=g.current;P(Ie),m(Ie,ce=>HO(ce)),await new Promise(ce=>setTimeout(ce,50))}const dt=V.pendingImages.length>0?V.pendingImages.map(Ie=>Ie.dataUrl):void 0,Dt=V.pendingImages.length>0?V.pendingImages.map(Ie=>Ie.name):void 0,Me=te(V.chatMode,V.selectedAgent??"",V.activeChannel??"",V.activeDmUserId),jt=V.chatReplyTo;Ue||(K(""),$([])),I([]),X(!1),q(null);const ye=V.chatMode==="dm";N(Me);const ze=V.activeSessionId??Me;if(p.set(ze,[]),g.current===Me&&!ye&&(Z(!0),B([])),V.chatMode==="dm"){const Ie=Y(V.authUser?.id??"",V.activeDmUserId),ce=`opt_${Date.now()}`,et={id:ce,sender:"user",text:Ke,time:new Date().toLocaleTimeString(),rawCreatedAt:new Date().toISOString()};dt?.length&&(et.images=dt),jt&&(et.replyToId=jt.id,et.replyToSender=jt.sender,et.replyToText=jt.text),m(Me,xe=>[...xe,et]);try{const xe=await ne.channels.sendMessage(Ie,{text:Ke,senderName:V.authUser?.name??Re("page.fallbackYou"),senderId:V.authUser?.id,mentions:[],orgId:"default",humanOnly:!0,...dt?.length?{images:dt}:{},...Dt?.length?{fileNames:Dt}:{}});xe.userMessage&&ae(xe.userMessage.id),m(Me,gt=>{const He=gt.filter(vt=>vt.id!==ce),Ct=[];return xe.userMessage&&Ct.push(Bn(xe.userMessage,V.authUser?.id)),Ct.length>0?[...He,...Ct]:gt})}catch(xe){Vc(xe)&&Fc(),DO(xe)&&(K(Ke),I(V.pendingImages)),m(Me,gt=>[...gt.filter(Ct=>Ct.id!==ce),{id:`err_${Date.now()}`,sender:"agent",text:Re("page.errorWithMessage",{message:String(xe)}),errorRaw:String(xe),time:new Date().toLocaleTimeString(),agentName:Re("page.systemName"),isError:!0}])}R(Me),g.current===Me&&Z(!1)}else if(V.chatMode==="channel"){const Ie=`opt_${Date.now()}`,ce={id:Ie,sender:"user",text:Ke,time:new Date().toLocaleTimeString(),rawCreatedAt:new Date().toISOString()};jt&&(ce.replyToId=jt.id,ce.replyToSender=jt.sender,ce.replyToText=jt.text),m(Me,xe=>[...xe,ce]);const et=s2(Ke);V.groupChats.find(xe=>xe.channelKey===V.activeChannel);try{const xe=await ne.channels.sendMessage(V.activeChannel,{text:Ke,senderName:V.authUser?.name??Re("page.fallbackYou"),mentions:et,senderId:V.authUser?.id,orgId:"default",replyToId:jt?.id,...dt?.length?{images:dt}:{},...Dt?.length?{fileNames:Dt}:{}});xe.userMessage&&ae(xe.userMessage.id),xe.agentMessage&&ae(xe.agentMessage.id),xe.agentStopped&&m(Me,gt=>[...gt,{id:`stopped_${Date.now()}`,sender:"agent",text:xe.notice??Re("page.agentStopped"),time:new Date().toLocaleTimeString(),agentName:Re("page.systemName"),isError:!0}]),m(Me,gt=>{const He=gt.filter(vt=>vt.id!==Ie),Ct=[];return xe.userMessage&&Ct.push(Bn(xe.userMessage,V.authUser?.id)),xe.agentMessage&&Ct.push(Bn(xe.agentMessage,V.authUser?.id)),Ct.length>0?[...He,...Ct]:gt})}catch(xe){Vc(xe)&&Fc();const gt=DO(xe);gt&&(K(Ke),I(V.pendingImages));const He=fh(xe,Re)||Re("page.errorWithMessage",{message:String(xe)});m(Me,Ct=>[...gt?Ct.filter(de=>de.id!==Ie):Ct,{id:`err_${Date.now()}`,sender:"agent",text:He,errorRaw:String(xe),time:new Date().toLocaleTimeString(),agentName:Re("page.systemName"),isError:!0}])}R(Me),g.current===Me&&Z(!1)}else{k(Me);const Ie=ve?.isResume?b(Me)??[]:[],ce=ve?.isResume?r2(Ie):-1,et=ce>=0?Ie[ce].id:void 0,xe=et??Uv(),gt=Uv();let He=ve?.sessionIdOverride??(V.activeSessionId===lt?null:V.activeSessionId??null);if(ve?.isResume){const J=new Date().toISOString();m(Me,je=>{if(et){const Qe=je.findIndex(be=>be.id===et);if(Qe>=0)return je.map((be,Pe)=>Pe===Qe?{...be,isStreaming:!0,isStopped:!1,isError:!1}:be)}return[...je,{id:xe,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:J,segments:[],isStreaming:!0}]},He)}else{const J=new Date().toISOString(),je=i2({id:gt,text:Ke,time:new Date().toLocaleTimeString(),rawCreatedAt:J,chips:mt,images:dt,replyTo:jt});m(Me,Qe=>[...Qe,je,{id:xe,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:J,segments:[],isStreaming:!0}],He)}const Ct=J=>{d.current=Date.now(),x(Me,je=>{const Qe=[...je],be=Qe.findIndex(tt=>tt.id===xe);if(be<0)return je;const Pe=Qe[be];return Qe[be]={...Pe,text:(Pe.text??"")+J,segments:ZO(Pe.segments??[],J)},Qe},He)},vt=J=>{d.current=Date.now(),x(Me,je=>{const Qe=[...je],be=Qe.findIndex(tt=>tt.id===xe);if(be<0)return je;const Pe=Qe[be];return Qe[be]={...Pe,segments:VO(Pe.segments??[],J)},Qe},He)},de=J=>{if(d.current=Date.now(),J.type==="session_start"&&J.sessionId){const je=He;if(He=J.sessionId,l.current.delete(J.sessionId),je&&je!==J.sessionId&&(_(Me,je),V.selectedAgent&&je===lt&&(Cs.applyLocalOptimistic(V.selectedAgent,je,!1),Cs.applyLocalOptimistic(V.selectedAgent,J.sessionId,!0))),Q(Me,J.sessionId),J.userMessageId&&!ve?.isResume&&m(Me,Qe=>Qe.map(be=>be.id===gt?{...be,id:J.userMessageId}:be),J.sessionId),g.current===Me){const Qe=V.activeSessionId;(!Qe||Qe===lt||Qe===J.sessionId)&&(ie(J.sessionId),A(Me,J.sessionId),a(J.sessionId),V.selectedAgent&&pe(V.selectedAgent,J.sessionId),$e(be=>be.some(Pe=>Pe.id===lt)?be.map(Pe=>Pe.id===lt?{...Pe,id:J.sessionId}:Pe):be.some(Pe=>Pe.id===J.sessionId)?be:[...be,{id:J.sessionId,agentId:V.selectedAgent??"",userId:null,title:"",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()}]))}return}m(Me,je=>{const Qe=[...je],be=Qe.findIndex(tt=>tt.id===xe);if(be<0)return je;const Pe=[...Qe[be].committedSegments??[]];return J.type==="thinking_commit"?Pe.push({type:"text",content:"",thinking:J.content,createdAt:J.createdAt}):Pe.push({type:"text",content:J.content,createdAt:J.createdAt}),Qe[be]={...Qe[be],committedSegments:Pe},Qe},He)},we=J=>{d.current=Date.now(),J.phase!=="heartbeat"&&((J.phase==="start"||J.phase==="end")&&y(Me,{...J,phase:J.phase,ts:Date.now()},He),J.phase==="start"?m(Me,je=>{const Qe=[...je],be=Qe.findIndex(Ot=>Ot.id===xe);if(be<0)return je;const Pe=[...Qe[be].segments??[]];let tt=!1;if(J.arguments)for(let Ot=Pe.length-1;Ot>=0;Ot--){const At=Pe[Ot];if(At.type==="tool"&&At.tool===J.tool&&At.status==="running"){Pe[Ot]={...At,args:J.arguments},tt=!0;break}}const pt=`${J.tool}_${Date.now()}`,Pt=new Date().toISOString();tt||Pe.push({type:"tool",key:pt,tool:J.tool,status:"running",args:J.arguments,createdAt:Pt});const kt=[...Qe[be].committedSegments??[]];return J.arguments!==void 0&&kt.push({type:"tool",key:pt,tool:J.tool,status:"running",args:J.arguments,createdAt:Pt}),Qe[be]={...Qe[be],segments:Pe,committedSegments:kt},Qe},He):J.phase==="output"?x(Me,je=>{const Qe=[...je],be=Qe.findIndex(tt=>tt.id===xe);if(be<0)return je;const Pe=[...Qe[be].segments??[]];for(let tt=Pe.length-1;tt>=0;tt--){const pt=Pe[tt];if(pt.type==="tool"&&pt.tool===J.tool&&pt.status==="running"){Pe[tt]={...pt,liveOutput:a2(pt.liveOutput,J.output??"")};break}}return Qe[be]={...Qe[be],segments:Pe},Qe},He):J.phase==="subagent_progress"&&J.subagentEvent?x(Me,je=>{const Qe=[...je],be=Qe.findIndex(Pt=>Pt.id===xe);if(be<0)return je;const Pe=Pt=>{const kt=[...Pt];for(let Ot=kt.length-1;Ot>=0;Ot--){const At=kt[Ot];if(At.type==="tool"&&(At.tool==="spawn_subagent"||At.tool==="spawn_subagents")&&At.status==="running"){kt[Ot]={...At,subagentLogs:FO(At.subagentLogs,J.subagentEvent)};break}}return kt},tt=Pe(Qe[be].segments??[]),pt=Pe(Qe[be].committedSegments??[]);return Qe[be]={...Qe[be],segments:tt,committedSegments:pt},Qe},He):m(Me,je=>{const Qe=[...je],be=Qe.findIndex(kt=>kt.id===xe);if(be<0)return je;const Pe=new Date().toISOString(),tt=[...Qe[be].segments??[]];let pt;for(let kt=tt.length-1;kt>=0;kt--){const Ot=tt[kt];if(Ot.type==="tool"&&Ot.tool===J.tool&&Ot.status==="running"){pt=Ot.subagentLogs,tt[kt]={...Ot,status:J.success===!1?"error":"done",args:J.arguments,result:J.result,error:J.error,durationMs:J.durationMs,liveOutput:void 0,createdAt:Pe};break}}const Pt=[...Qe[be].committedSegments??[]];for(let kt=Pt.length-1;kt>=0;kt--){const Ot=Pt[kt];if(Ot.type==="tool"&&Ot.tool===J.tool&&Ot.status==="running"){Pt[kt]={...Ot,status:J.success===!1?"error":"done",args:J.arguments,result:J.result,error:J.error,durationMs:J.durationMs,liveOutput:void 0,createdAt:Pe,subagentLogs:pt??Ot.subagentLogs};break}}return Qe[be]={...Qe[be],segments:tt,committedSegments:Pt},Qe},He))},oe=new AbortController;e.current.set(f.current.activeSessionId??lt,oe);const st=He,ue=st;ue&&l.current.delete(ue),ue&&Q(Me,ue),V.selectedAgent&&Cs.applyLocalOptimistic(V.selectedAgent,ue??lt,!0);try{d.current=Date.now();const J=await ne.agents.messageStream(V.selectedAgent,Ke,{onChunk:Ct,onThinking:vt,onActivity:we,onCommit:de},{signal:oe.signal,images:dt,sessionId:st,isRetry:ve?.isRetry,isResume:ve?.isResume,fileNames:Dt,replyTo:jt,titleSource:ft,chips:mt,userMessageId:gt,assistantMessageId:xe});if(g.current===Me){if(J.merged&&m(Me,Qe=>Qe.filter(be=>be.id!==xe&&be.id!==gt),He),!J.merged&&J.segments?.length&&m(Me,Qe=>{const be=[...Qe],Pe=be.findIndex(kt=>kt.id===xe);if(Pe<0)return Qe;const tt=UO(J.segments,be[Pe].segments);let pt=J.content||be[Pe].text;pt||(pt=tt.filter(kt=>kt.type==="text").map(kt=>kt.content).join(""));const Pt=J.emptyReply===!0;return be[Pe]={...be[Pe],text:pt,segments:tt,committedSegments:tt,isStopped:J.cancelled||be[Pe].isStopped,emptyReply:J.emptyReply||Pt||void 0,isError:J.emptyReply||Pt?!0:be[Pe].isError},be},He),!J.merged&&!J.segments?.length&&m(Me,Qe=>{const be=[...Qe],Pe=be.findIndex(At=>At.id===xe);if(Pe<0)return Qe;const tt=be[Pe],pt=tt.committedSegments??[],kt=pt.filter(At=>At.type==="text"&&!!At.content).map(At=>At.content).join("")||J.content||tt.text,Ot=J.emptyReply===!0;return(pt.length>0||kt||J.cancelled||J.emptyReply||Ot)&&(be[Pe]={...tt,text:kt,segments:pt.length>0?pt:tt.segments,isStopped:J.cancelled||tt.isStopped,emptyReply:J.emptyReply||Ot||void 0,isError:J.emptyReply||Ot?!0:tt.isError}),be},He),J.sessionId){ie(be=>!be||be===lt||be===J.sessionId?J.sessionId:be);const Qe=v.get(Me);(!Qe||Qe===lt||Qe===J.sessionId)&&(A(Me,J.sessionId),a(J.sessionId)),$e(be=>be.some(Pe=>Pe.id===lt)?be.map(Pe=>Pe.id===lt?{...Pe,id:J.sessionId}:Pe):be.some(Pe=>Pe.id===J.sessionId)?be:[...be,{id:J.sessionId,agentId:V.selectedAgent??"",userId:null,title:"",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()}])}me(V.selectedAgent).then(Qe=>{if(g.current===Me&&(re(Qe),J.sessionId)){const be=Qe.find(Pe=>Pe.id===J.sessionId);be&&$e(Pe=>Pe.some(pt=>pt.id===be.id)?Pe.map(pt=>pt.id===be.id?be:pt):[be,...Pe.filter(pt=>pt.id!==lt)])}});const je=J.sessionId??(ue&&ue!==lt?ue:null);if(!oe.signal.aborted&&!J.merged&&(J.softDisconnected??J.segments===void 0)&&V.chatMode==="direct"&&V.selectedAgent&&je){const Qe=V.selectedAgent;let be=!1,Pe;for(let tt=0;tt<4&&!be&&(tt>0&&await new Promise(pt=>setTimeout(pt,350*tt)),!oe.signal.aborted);tt+=1)try{const pt=await ne.sessions.streamStatus(Qe,je);if(pt.messageId&&(Pe=pt.messageId),O0({aborted:oe.signal.aborted,sawTerminal:!1,serverStatus:x0(pt.status)})==="reattach"){m(Me,kt=>kt.map(Ot=>Ot.id===xe?{...Ot,isStreaming:!0,isStopped:!1,segments:(Ot.segments??[]).map(At=>At.type==="tool"&&(At.status==="stopped"||At.status==="running")?{...At,status:"running"}:At)}:Ot),je),R(Me),r(oe),Q(Me,je),C(Me),Te(Qe,je,Me),be=!0;return}break}catch{}if(!be&&!oe.signal.aborted){Pe&&xe&&m(Me,tt=>_a(tt,xe,Pe),je);try{if(await _e(je,Me)>0){R(Me),r(oe),C(Me);return}}catch{}}}}!J.merged&&(He||g.current===Me)&&m(Me,je=>_a(je,xe,J.messageId),He)}catch(J){const je=J?.sessionId;je&&V.chatMode==="direct"&&g.current===Me&&(ie(je),A(Me,je),a(je),$e(be=>be.map(Pe=>Pe.id===lt?{...Pe,id:je}:Pe)),me(V.selectedAgent).then(be=>{if(g.current!==Me)return;re(be);const Pe=be.find(tt=>tt.id===je);Pe&&$e(tt=>tt.some(Pt=>Pt.id===Pe.id)?tt.map(Pt=>Pt.id===Pe.id?Pe:Pt):[Pe,...tt])})),Vc(J)&&Fc();const Qe=fh(J,Re);Qe?m(Me,be=>{const Pe=[...be],tt=Pe.findIndex(pt=>pt.id===xe);return tt>=0&&(Pe[tt]={...Pe[tt],text:Qe,isError:!0,errorRaw:String(J)}),Pe},He):m(Me,be=>{const Pe=[...be],tt=Pe.findIndex(pt=>pt.id===xe);if(tt>=0){const pt=YO(Pe[tt],"stopped");if(pt===null)return be.filter(Pt=>Pt.id!==xe);Pe[tt]=pt}return Pe},He)}m(Me,J=>n2(J,xe),He),oe.signal.aborted&&m(Me,J=>{const je=[...J],Qe=je.findIndex(be=>be.id===xe);if(Qe>=0){const be=YO(je[Qe],"stopped");if(be===null)return J.filter(Pe=>Pe.id!==xe);je[Qe]=be}return je},He);const ke=((He?O(He):b(Me))??[]).find(J=>J.id===xe),nt=He&&He!==lt?He:V.activeSessionId&&V.activeSessionId!==lt?V.activeSessionId:null,Ye=ke?o2(ke):!1;ke&&!Ye&&V.chatMode==="direct"&&nt&&!oe.signal.aborted&&await(async(je,Qe)=>{for(let be=0;be<je;be++){const Pe=MC(be,{baseMs:Qe,maxMs:8e3,maxAttempts:je});await new Promise(tt=>setTimeout(tt,Pe));try{const pt=(await ne.sessions.getMessages(nt,2)).messages.find(Pt=>Pt.role==="assistant");if(pt?.content){const Pt=mh(pt);m(Me,kt=>{const Ot=[...kt],At=Ot.findIndex(js=>js.id===xe);return At>=0&&(Ot[At]={...Ot[At],text:Pt.text,segments:Pt.segments}),Ot},He),m(Me,kt=>_a(kt,xe,Pt.id),He);return}}catch{}}})(5,2e3);const Je=R(Me);_(Me,He??lt),V.selectedAgent&&Cs.applyLocalOptimistic(V.selectedAgent,He??lt,!1),C(Me),[...e.current.values()].includes(oe)||e.current.size===0?(r(oe),p.delete(He??Me),g.current===Me&&(Z(Je>0),Je===0&&B([]))):p.delete(He??Me)}},[y,k,_,g,R,C,N,me,b,Z,Q,f,m,x]);return{send:Fe,stopSending:De,tryReattachActiveStream:Te,loadSessionMessages:_e}}function w3({value:s,onSelect:e,agentId:t,disabled:r}){const{t:i}=Tt("team"),[n,a]=w.useState(!1),[o,l]=w.useState("agent"),[h,u]=w.useState(""),[d,f]=w.useState(!1),[p,v]=w.useState([]),[b,O]=w.useState(null),g=w.useRef(null),m=w.useCallback(async()=>{f(!0);try{const P=await LC(),_=P.providers?.markus;if(_?.configured&&_.enabled!==!1&&(!_.models||_.models.length===0))try{const A=await fetch("/api/models/live/markus",{credentials:"include"});if(A.ok){const N=await A.json();N.models?.length&&(_.models=N.models)}}catch{}const Q=[];for(const[A,N]of Object.entries(P.providers??{})){if(!N.configured||N.enabled===!1)continue;const R=(N.models??[]).filter(Q2).map(W=>({id:W.id,name:W.name}));R.length!==0&&Q.push({provider:A,displayName:N.displayName??A,models:R})}Q.sort((A,N)=>A.displayName.localeCompare(N.displayName)),v(Q);let E=null;if(P.routingDefaultModel?.provider&&P.routingDefaultModel?.model)E={provider:P.routingDefaultModel.provider,model:P.routingDefaultModel.model};else if(P.defaultProvider){const A=P.providers?.[P.defaultProvider];A?.model&&(E={provider:P.defaultProvider,model:A.model})}O(E)}catch{v([])}finally{f(!1)}},[]);w.useEffect(()=>{m()},[m]),w.useEffect(()=>{n&&(l("agent"),u(""),m())},[n,m]),w.useEffect(()=>{if(!n)return;const P=_=>{g.current?.contains(_.target)||a(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[n]);const x=w.useMemo(()=>{const P=h.trim().toLowerCase();return p.map(_=>({..._,models:P?_.models.filter(Q=>Q.id.toLowerCase().includes(P)||(Q.name?.toLowerCase().includes(P)??!1)||_.displayName.toLowerCase().includes(P)||_.provider.toLowerCase().includes(P)):_.models})).filter(_=>_.models.length>0)},[p,h]),y=s??b,C=(y?.model?y.model.includes("/")?y.model.split("/").pop():y.model:"")||i("chatModel.title",{defaultValue:"Model"});return c.jsxs("div",{ref:g,className:"relative shrink-0",children:[c.jsxs("button",{type:"button",disabled:r,onClick:()=>a(P=>!P),className:"max-w-[110px] md:max-w-[180px] px-1.5 py-1 text-[12px] text-fg-secondary hover:text-fg-primary disabled:opacity-40 rounded-md hover:bg-surface-elevated transition-colors flex items-center gap-1",title:y?`${y.provider}: ${y.model}`:i("chatModel.title",{defaultValue:"Model"}),children:[c.jsx("span",{className:"truncate",children:C}),c.jsx("svg",{className:"w-3 h-3 shrink-0 opacity-60",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{d:"M6 9l6 6 6-6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&c.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-[300px] max-h-[360px] flex flex-col rounded-xl border border-border-default bg-surface-elevated shadow-xl z-50 overflow-hidden",children:[c.jsxs("div",{className:"p-2 border-b border-border-default/60 space-y-2",children:[c.jsx("input",{autoFocus:!0,value:h,onChange:P=>u(P.target.value),placeholder:i("chatModel.search",{defaultValue:"Search models"}),className:"w-full px-2.5 py-1.5 text-xs rounded-lg bg-surface-primary border border-border-default/50 outline-none focus:border-brand-500/50"}),c.jsxs("label",{className:"flex items-center justify-between gap-2 px-0.5 text-xs text-fg-secondary cursor-pointer select-none",children:[c.jsx("span",{children:i("chatModel.applyGlobal",{defaultValue:"Apply to global"})}),c.jsx(t0,{checked:o==="global",onChange:()=>l("global"),label:i("chatModel.applyGlobal",{defaultValue:"Apply to global"}),size:"sm",disabled:!t})]}),c.jsxs("label",{className:"flex items-center justify-between gap-2 px-0.5 text-xs text-fg-secondary cursor-pointer select-none",children:[c.jsx("span",{children:i("chatModel.applyAgent",{defaultValue:"Apply to current agent"})}),c.jsx(t0,{checked:o==="agent",onChange:()=>l("agent"),label:i("chatModel.applyAgent",{defaultValue:"Apply to current agent"}),size:"sm",disabled:!t})]}),!t&&c.jsx("div",{className:"px-0.5 text-[10px] text-fg-tertiary",children:i("chatModel.noAgent",{defaultValue:"Select an agent to apply per-agent"})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[d&&c.jsx("div",{className:"px-3 py-4 text-xs text-fg-tertiary",children:i("common:loading",{defaultValue:"Loading…"})}),!d&&x.length===0&&c.jsx("div",{className:"px-3 py-4 text-xs text-fg-tertiary",children:i("chatModel.empty",{defaultValue:"No enabled providers / models"})}),!d&&x.length>0&&c.jsx("div",{className:"px-3 pb-1 text-[10px] text-fg-tertiary",children:i("chatModel.chatOnlyHint",{defaultValue:"Only models with a chat interface are listed"})}),!d&&x.map(P=>c.jsxs("div",{className:"mb-1",children:[c.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-fg-tertiary",children:P.displayName}),P.models.slice(0,80).map(_=>{const Q=y?.provider===P.provider&&y?.model===_.id;return c.jsxs("button",{type:"button",onClick:()=>{e({provider:P.provider,model:_.id},o),o==="global"&&O({provider:P.provider,model:_.id}),a(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 hover:bg-surface-primary transition-colors ${Q?"text-fg-primary":"text-fg-secondary"}`,children:[c.jsx("span",{className:"truncate flex-1",children:_.id}),Q&&c.jsx("svg",{className:"w-3.5 h-3.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:c.jsx("path",{d:"M5 12l5 5L20 7",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${P.provider}:${_.id}`)})]},P.provider))]})]})]})}async function Hv(s,e,t){if(e==="agent"){if(!t)return;await ne.agents.updateConfig(t,{llmConfig:{modelMode:"custom",primary:s.provider,defaultModel:s.model}}),s0(t);return}t&&await ne.agents.updateConfig(t,{llmConfig:{modelMode:"default",primary:"",defaultModel:null}}).then(()=>s0(t)).catch(()=>{}),await ne.settings.updateRouting({defaultProvider:s.provider,routingDefaultModel:{provider:s.provider,model:s.model}}),NC()}const Yv="markus_team_sidebars_c";function ep(s,e){return s.id===lt?e("page.newChat"):s.isMain?e("page.sessionMain"):s.title?.trim()||e("page.sessionConversation")}function Gv(s,e){const t=s.title?.trim(),r=!!t;return s.isMain?r?`${e("page.sessionMain")} · ${t}`:e("page.sessionMain"):ep(s,e)}const tp=new Set;function _3(){return window.location.hash}function k3(s){return tp.add(s),()=>{tp.delete(s)}}typeof window<"u"&&window.addEventListener("hashchange",()=>tp.forEach(s=>s()));function V3({initialAgentId:s,authUser:e,previewMode:t,previewData:r}={}){const{t:i,i18n:n}=Tt(["team","common"]),a=w.useMemo(()=>({today:i("page.dateToday"),yesterday:i("page.dateYesterday")}),[i]),o=ip(Ut.TEAM),[l,h]=w.useState(r?.agents??[]),[u,d]=w.useState(r?.humans??[]),[f,p]=w.useState(!r),v=rp(),b=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),O=w.useSyncExternalStore(k3,_3),g=v&&(O.startsWith(`#${Ut.TEAM}/`)||O.startsWith("#chat/")),m=v&&O.match(/^#team\/t\/(.+)$/),x=v?m?"team":g?"chat":"roster":"roster",y=m?m[1]:null;w.useEffect(()=>(IO(v&&x==="chat"),()=>IO(!1)),[v,x]),w.useEffect(()=>(BO(Ut.TEAM,v&&x!=="roster"?1:0),()=>BO(Ut.TEAM,0)),[v,x]);const k=w.useCallback(()=>{window.location.hash=`${Ut.TEAM}/d`},[]),C=w.useCallback(S=>{window.location.hash=`${Ut.TEAM}/t/${S}`},[]);w.useEffect(()=>{if(!v)return;const S=()=>{zi(Q.current)&&_("chat")};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[v]);const[P,_]=w.useState("chat"),Q=w.useRef("chat");Q.current=P;const E=WO({side:"left",defaultWidth:280,minWidth:220,maxWidth:400,storageKey:"markus_chat_sidebar"}),[A,N]=w.useState(()=>{try{return localStorage.getItem(Yv)==="1"}catch{return!1}}),R=w.useCallback(S=>{N(S);try{localStorage.setItem(Yv,S?"1":"0")}catch{}},[]),W=zo(),H=W?.leftCollapsed??!1,Z=W?.rightPanel??null,B=W?.rightPanelTabs??[],K=W?.activeRightPanelTabId??null,$=W?.rightPanelFullscreen??!1,I=Z?"2xl:pr-8":"2xl:pr-[280px]",X=W?.setHostAvailable,q=W?.collapseRightPanelOnly??W?.toggleRightPanel,ie=W?.openRightPanel,pe=400,$e=320,re=6,[U,M]=w.useState(typeof window<"u"?window.innerWidth:1440),[te,Y]=w.useState("auto"),ae=w.useRef(H);w.useEffect(()=>{ae.current!==H&&(ae.current=H,N(H))},[H]);const ee=W?.keyboardPane??"content",me=w.useRef(!1),Re=w.useRef(ee);w.useEffect(()=>{if(t||v||!o)return;const S=Re.current;Re.current=ee,(ee==="l1"||ee==="l2")&&S!==ee&&A&&(N(!1),W?.setLeftCollapsed(!1))},[ee,t,v,o,A,W]),w.useEffect(()=>{if(t||v||!o)return;const S=T=>{const j=W?.keyboardPane??"content";if(j==="l0"||j==="l1"||j==="l2"||T.metaKey||T.ctrlKey||T.altKey)return;if(T.target instanceof HTMLElement){const F=T.target.tagName;if(F==="INPUT"||F==="TEXTAREA"||F==="SELECT"||T.target.isContentEditable||T.target.closest(".xterm"))return}const D=T.key.length===1?T.key.toLowerCase():T.key;D!=="h"&&D!=="ArrowLeft"||(T.preventDefault(),A&&(R(!1),W?.setLeftCollapsed(!1)),W?.setKeyboardPane(me.current?"l2":"l1"))};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[t,v,o,W,A,R]),w.useEffect(()=>{if(X)return X(o&&!v),()=>X(!1)},[o,v,X]),w.useEffect(()=>t||v||!o?void 0:Rt.on("ui:right_panel",T=>{const j=T.payload;if(j.action==="collapse"){q?.();return}if(j.action!=="open"||!j.panel||!ie)return;const D=j.panel;if(D.kind==="url"&&D.url){const F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ie({kind:"url",url:D.url,title:D.title||D.url,browserId:F});return}if(D.kind==="file"&&D.path){ie({kind:"file",path:D.path,title:D.title});return}if(D.kind==="terminal"){const F=D.terminalId||`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ie({kind:"terminal",terminalId:F,title:D.title||"Terminal",cwd:D.cwd});return}D.kind==="deliverable"&&D.deliverableId&&ne.deliverables.get(D.deliverableId).then(F=>{F.deliverable&&ie({kind:"deliverable",deliverable:F.deliverable})}).catch(()=>{})}),[t,v,o,q,ie]);const _e=w.useCallback((S,T)=>{const j=pd.current,D=T??Ss.current?.selectionStart??j.text.length,F=hp({text:j.text,chips:j.chips},S,D);ir(F.draft.text),pn(F.draft.chips),requestAnimationFrame(()=>{const G=Ss.current;G&&(G.focus(),G.setSelectionRange(F.caret,F.caret))})},[]),De=w.useCallback(S=>{if(!S)return;let T=0;const j=C2(S,()=>`ctx_${Date.now()}_${++T}`);if(j.length===0)return;const D=pd.current,F=nP({text:D.text,chips:D.chips},j);ir(F.draft.text),pn(F.draft.chips),requestAnimationFrame(()=>{const G=Ss.current;G&&(G.focus(),G.setSelectionRange(F.caret,F.caret))})},[]),Te=w.useRef(null),[Fe,Ue]=w.useState(()=>{if(t)return!0;try{return localStorage.getItem("markus_team_panel_visible")==="true"}catch{return!1}}),ve=WO({side:"left",defaultWidth:260,minWidth:200,maxWidth:400,storageKey:"markus_team_detail_panel"}),V=w.useRef(null),[Xe,Ke]=w.useState(!1),[ft,mt]=w.useState(!1),_t=w.useCallback(()=>{Xe?mt(S=>!S):Ue(S=>{const T=!S;try{localStorage.setItem("markus_team_panel_visible",String(T))}catch{}return T})},[Xe]);w.useEffect(()=>{if(v)return;const S=V.current;if(!S)return;const T=new ResizeObserver(([j])=>{if(!j)return;const D=j.contentRect.width;if(M(D),!t){const F=D-E.width-ve.width;Ke(F<400)}});return T.observe(S),()=>T.disconnect()},[v,t,E.width,ve.width]);const Xt=Fe&&!Xe&&!ft,dt=A?0:E.width+re+(Xt?ve.width+re:0),Dt=Math.max(0,U-dt-re-8),Me=Math.min(pe,Math.floor(Dt*.4)),jt=Math.max(0,Dt-Me),ye=Math.min(Math.round(Dt/2),jt),Ie=Math.max(0,Math.min(te==="auto"?ye:te,jt)),ce=w.useRef(!1);w.useEffect(()=>{const S=(W?.rightPanel??null)!==null;S&&!ce.current&&(N(!0),Y("auto")),ce.current=S},[W?.rightPanel]);const et=w.useRef(Ie);et.current=Ie;const xe=w.useRef(jt);xe.current=jt;const gt=w.useCallback(S=>{S.preventDefault();const T=S.clientX,j=et.current,D=G=>{const se=j+(T-G.clientX),Ee=xe.current,Ze=Math.min($e,Ee);Y(Math.max(Ze,Math.min(Ee,se)))},F=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",F),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",D),document.addEventListener("mouseup",F),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);w.useEffect(()=>{if(!ft)return;const S=T=>{T.target.closest("[data-l2-floating]")||mt(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[ft]);const[He,Ct]=w.useState(null),[vt,de]=w.useState(!1),we=w.useRef(null);w.useEffect(()=>{if(!vt)return;const S=j=>{we.current&&!we.current.contains(j.target)&&de(!1)},T=j=>{j.key==="Escape"&&de(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",T)}},[vt]);const[oe,st]=w.useState(),[ue,Le]=w.useState(),[ke,nt]=w.useState(),[Ye,Je]=w.useState(!1),[J,je]=w.useState(""),[Qe,be]=w.useState(!1),[Pe,tt]=w.useState(""),pt=w.useRef(null),Pt=w.useRef(null),kt=w.useCallback((S,T)=>{const j=S?dh[S]:void 0,D=j?"overview":S;Le(j),st(D),nt(T),v?(_("profile"),history.pushState({mobileProfile:!0},"",window.location.hash)):_(D??"overview")},[v]);w.useCallback(S=>{S==="profile"?kt():zi(Q.current)?history.back():_("chat")},[kt]);const Ot=w.useCallback((S,T)=>{Mt("direct"),Xs(S),v&&k(),kt(T?.tab,T?.highlightMailboxId),Ct(null)},[v,k,kt]),At=w.useCallback((S,T)=>{const j=l.find(D=>D.name.toLowerCase()===S.toLowerCase());if(j){const D=T.target.getBoundingClientRect();Ct({agentId:j.id,top:D.bottom,left:D.left})}},[l]),js=w.useMemo(()=>l.map(S=>S.name),[l]),[he,Mt]=w.useState(()=>r?.chatMode??(s?"direct":localStorage.getItem("markus_chat_mode")??"direct")),[ge,Xs]=w.useState(()=>s??localStorage.getItem("markus_chat_agent")??""),[yt,zs]=w.useState(()=>r?.activeChannel??localStorage.getItem("markus_chat_channel")??"#general"),[Zt,Ti]=w.useState(""),Rl=500,ln=w.useRef(new Set),fd=S=>{if(ln.current.add(S),ln.current.size>Rl){const T=Math.floor(Rl*.2),j=ln.current.values();for(let D=0;D<T;D++){const F=j.next().value;F&&ln.current.delete(F)}}},cn=w.useMemo(()=>{if(r?.channelMessages){const S=r.activeChannel??"custom:general";return r.channelMessages.filter(T=>T.channel===S).map(T=>Bn(T))}},[]),{manager:zt,messages:ns,setMessages:Rs,sending:hs,setSending:Qi,activities:hn,setActivities:dn,activeSessionBuffer:un,actBuffers:Gn,sessionTabsBuffer:Yo,readConvMsgs:Hs,readSessionMsgs:$i,writeConvMsgs:z,setActiveSession:Oe,currentConvKeyRef:le,updateConvMsgs:Be,updateConvMsgsRaf:rt,appendConvActivity:ot,beginLoad:ut,beginStream:Lt,endStream:St,resetConv:ss,abortStream:gs,loadAndDisplay:rr,incrementSending:ni,decrementSending:Br,isSendingFor:xr,setStreamSession:us,clearStreamSession:ji,getStreamSession:md,saveSessionToCache:Kt,restoreSessionFromCache:fn}=y3(cn),[os,ir]=w.useState(""),[mn,El]=w.useState(null),[br,pn]=w.useState([]),pd=w.useRef({text:"",chips:[]});pd.current={text:os,chips:br};const[Al,Ml]=w.useState(!!r?.streamLastMessage),gn=w.useRef(null),G_=400;w.useEffect(()=>(hs?(gn.current&&(clearTimeout(gn.current),gn.current=null),Ml(!0)):Al&&(gn.current=setTimeout(()=>{Ml(!1),gn.current=null},G_)),()=>{gn.current&&clearTimeout(gn.current)}),[hs]);const gd=w.useRef({fullText:"",timers:[]});w.useEffect(()=>{if(!t||!r?.streamLastMessage||ns.length===0)return;const S=ns[ns.length-1];if(!S||S.sender!=="agent")return;const T=S.text;gd.current.fullText=T;const j=gd.current.timers;function D(){let G=0;Rs(Ee=>Ee.map((Ze,Se)=>Se===Ee.length-1?{...Ze,text:""}:Ze)),Ml(!0);const se=setInterval(()=>{if(G+=1+Math.floor(Math.random()*2),G>=T.length){clearInterval(se),Rs(Se=>Se.map((Ce,Ne)=>Ne===Se.length-1?{...Ce,text:T}:Ce));const Ee=setTimeout(()=>Ml(!1),800);j.push(Ee);const Ze=setTimeout(D,6e3);j.push(Ze)}else Rs(Ee=>Ee.map((Ze,Se)=>Se===Ee.length-1?{...Ze,text:T.slice(0,G)}:Ze))},30);j.push(se)}const F=setTimeout(D,1500);return j.push(F),()=>{j.forEach(G=>clearTimeout(G)),gd.current.timers=[]}},[]);const[K_,yg]=w.useState(!1),[Od,Sg]=w.useState(!1),[J_,wg]=w.useState(!1);w.useEffect(()=>{if(!Od){wg(!1);return}const S=setTimeout(()=>wg(!0),250);return()=>clearTimeout(S)},[Od]);const[On,Wr]=w.useState(!0),[ek,xd]=w.useState(!0),bd=w.useRef(0),[nr,Ll]=w.useState([]),[_g,kg]=w.useState(null),vd=w.useRef(null),Ss=w.useRef(null),[tk,Ri]=w.useState(null),[sk,Cg]=w.useState(0);w.useEffect(()=>$2(S=>{S===ge&&Cg(T=>T+1)}),[ge]),w.useEffect(()=>{const S=()=>Cg(T=>T+1);return window.addEventListener("focus",S),()=>window.removeEventListener("focus",S)},[]),w.useEffect(()=>{if(!ge){Ri(null);return}let S=!1;return ne.agents.get(ge).then(T=>{if(S)return;const j=T.effectiveModel;Ri(j?.provider&&j?.model?{provider:j.provider,model:j.model}:null)}).catch(()=>{S||Ri(null)}),()=>{S=!0}},[ge,sk]);const yd=w.useRef(!1),Go=w.useCallback(()=>{const S=Ss.current;if(!S)return;const T=yd.current,j=T?36:52,D=e0(T);S.style.height="auto";const F=Math.max(j,Math.min(S.scrollHeight,D));S.style.height=`${F}px`,S.style.overflowY=F>=D?"auto":"hidden"},[]);w.useEffect(()=>{const S=requestAnimationFrame(()=>Go());return()=>cancelAnimationFrame(S)},[os,nr.length,Go]);const Sd=S=>{try{const T=localStorage.getItem(`markus_closed_tabs_${S}`);return T?new Set(JSON.parse(T)):new Set}catch{return new Set}},rk=(S,T)=>{const j=Sd(S);j.add(T);try{localStorage.setItem(`markus_closed_tabs_${S}`,JSON.stringify([...j]))}catch{}},ik=(S,T)=>{const j=Sd(S);if(j.delete(T))try{localStorage.setItem(`markus_closed_tabs_${S}`,JSON.stringify([...j]))}catch{}},Pg=S=>{try{return localStorage.getItem(`markus_active_session_${S}`)}catch{return null}},Ko=(S,T)=>{if(S)try{T&&T!==lt?localStorage.setItem(`markus_active_session_${S}`,T):localStorage.removeItem(`markus_active_session_${S}`)}catch{}},[Qr,Ei]=w.useState([]),[nk,Nl]=w.useState(0),[Tg,Dl]=w.useState(1),[Il,Bl]=w.useState(!1),[Wl,Qg]=w.useState(!1),[it,Ai]=w.useState(null),[Jo,xn]=w.useState(!1),[$g,bn]=w.useState(!1),[wd,jg]=w.useState(null),[_d,kd]=w.useState(""),[Rg,Cd]=w.useState([]),[vn,Xl]=w.useState(null),[ok,Eg]=w.useState(null),[ea,Pd]=w.useState([]),[yn,ta]=w.useState(null),[ak,Ag]=w.useState(null),Mg=w.useRef(new Set),[Lg,Td]=w.useState([]),[$r,sa]=w.useState(null),Mi=$r?$r.items[$r.index]??null:null,[lk,Ng]=w.useState(null),[Dg,Qd]=w.useState([]),[qs,ck]=w.useState([]),Ys=S=>{ck(T=>{const j=typeof S=="function"?S(T):S,D=new Set,F=j.filter(G=>D.has(G.id)?!1:(D.add(G.id),!0));return F.some(G=>G.isMain)?[...F.filter(G=>G.isMain),...F.filter(G=>!G.isMain)]:F})},Ig=w.useRef(null);w.useEffect(()=>{if(!it)return;const S=Ig.current;if(!S)return;const T=S.querySelector(`[data-session-tab-id="${CSS.escape(it)}"]`);if(!T)return;const j=requestAnimationFrame(()=>{T.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})});return()=>cancelAnimationFrame(j)},[it,qs.length]);const zl=w.useRef(null),$d=w.useRef(null),[ws,ra]=w.useState(r?.groupChats??[]),jd=w.useRef(ws);jd.current=ws;const Bg=w.useRef(null),[Rd,_s]=w.useState(!1),[Ed,Kn]=w.useState(!1),[ql,Ad]=w.useState(""),[hk,ia]=w.useState(-1),[dk,Zl]=w.useState([]),[uk,Wg]=w.useState(!1),Md=w.useRef(void 0),[Es,Xg]=w.useState(r?.teams??[]),[Ld,fk]=w.useState(!!r),[mk,pk]=w.useState([]),[Nd,zg]=w.useState([]),[gk,Ok]=w.useState(null),[T3,Q3]=w.useState(!1),[$3,j3]=w.useState(""),[Jn,na]=w.useState(!1),Vl=w.useRef(null),[qg,xk]=w.useState(""),[oa,eo]=w.useState(0),[to,Fl]=w.useState(!1),[Zg,bk]=w.useState(""),[Dd,aa]=w.useState(0),[Id,vk]=w.useState([]),Vg=w.useRef(!1),Bd=w.useCallback(()=>{Vg.current||(Vg.current=!0,(async()=>{try{const{skills:S}=await ne.skills.list();vk(S.map(T=>({name:T.name,description:T.description??T.name})))}catch{}})())},[]);w.useEffect(()=>{Bd()},[Bd]);const Sn=Zg?Id.filter(S=>S.name.toLowerCase().includes(Zg.toLowerCase())):Id,[yk,Sk]=w.useState([]),Fg=w.useRef(!1),wk=w.useCallback(()=>{Fg.current||(Fg.current=!0,(async()=>{const S=[];try{const[T,j,D,F,G]=await Promise.all([ne.projects.list().catch(()=>({projects:[]})),ne.requirements.list({lean:!0}).catch(()=>({requirements:[]})),ne.tasks.list({pageSize:20,lean:!0}).catch(()=>({tasks:[]})),ne.deliverables.search({limit:100}).catch(()=>({results:[]})),ne.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const se of T.projects)S.push({id:se.id,name:se.name,entityType:"project",role:se.status});for(const se of j.requirements)S.push({id:se.id,name:se.title,entityType:"requirement",role:se.priority});for(const se of D.tasks)S.push({id:se.id,name:se.title,entityType:"task",role:se.status});for(const se of F.results)S.push({id:se.id,name:se.title,entityType:"deliverable",role:se.type});for(const se of G.teams)try{const Ee=await ne.workflows.list(se.id);for(const Ze of Ee.workflows)S.push({id:Ze.name,name:Ze.displayName||Ze.name,entityType:"workflow",role:`v${Ze.version}`})}catch{}}catch{}Sk(S)})())},[]),as=he==="channel"?ws.find(S=>S.channelKey===yt)?.teamId:void 0,_k=w.useRef(null),Xr=w.useRef(null),Ug=w.useRef(void 0),la=w.useCallback((S,T)=>{Ai(T),S&&(T===null?zt.clearActiveSession(S):zt.setActiveSession(S,T))},[Ai,zt]),Hg=w.useMemo(()=>Aa(he,ge,yt,Zt),[he,ge,yt,Zt]);uh();const ca=Cs.isStreaming(it),kk=Cs.liveBubbleId(it),wn=w.useMemo(()=>po(Hg,it),[Hg,it]),Zs=w.useRef(wn);Zs.current=wn;const[ha,Ck]=w.useState(wn);if(w.useEffect(()=>{ka.save(ha,{text:os,images:nr,context:br,replyTo:mn})},[os,ha,nr,br,mn]),ha!==wn){const S={text:os,images:nr,context:br,replyTo:mn};if(os!==ka.peek(ha).text)ka.save(wn,S);else{ka.save(ha,S);const T=ka.get(wn);ir(T.text),Ll(T.images),pn(T.context),El(T.replyTo)}Ck(wn)}const Os=w.useRef(null),Wd=w.useRef(null),oi=w.useRef(null),Ul=w.useRef(null),Xd=w.useRef(null),Hl=w.useRef(0),Yl=w.useRef([]),so=w.useRef(null),Yg=w.useRef([]),zd=w.useRef(void 0),Gl=w.useRef(null),_n=w.useCallback(()=>zt.getActiveSession(le.current)??le.current,[zt]),Li=w.useCallback((S,T)=>{S&&(zt.setWindowBounds(S,T),S===_n()&&yg(T.hasMore))},[zt,_n]);w.useEffect(()=>{yg(zt.getWindowBounds(_n()).hasMore)},[zt,_n,he,ge,yt,Zt,it]),w.useEffect(()=>{if(!Jo)return;const S=T=>{$d.current&&!$d.current.contains(T.target)&&zl.current&&!zl.current.contains(T.target)&&xn(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[Jo]);const Kl=(S,T)=>{if(!T||S===T)return`notes:${S}`;const[j,D]=[S,T].sort();return`dm:${j}:${D}`};w.useEffect(()=>{localStorage.setItem("markus_chat_mode",he)},[he]),w.useEffect(()=>{localStorage.setItem("markus_chat_agent",ge)},[ge]),w.useEffect(()=>{localStorage.setItem("markus_chat_channel",yt)},[yt]),w.useEffect(()=>{let S=!1;if(t||!ge||he!=="direct"){Ri(null);return}return ne.agents.get(ge).then(T=>{if(S)return;const j=T.config?.llmConfig;Ri(j?.modelMode==="custom"&&j.primary&&j.defaultModel?{provider:j.primary,model:j.defaultModel}:null)}).catch(()=>{S||Ri(null)}),()=>{S=!0}},[ge,he,t]);const{counts:qd,sessionAgentMap:da,markRead:Zd,markReadMany:Gg,setActiveKey:Pk,clearActiveKeys:Tk}=DC({enabled:!t}),Jl=w.useMemo(()=>{const S={};for(const[T,j]of Object.entries(qd))T.startsWith("channel:")&&(S[T.slice(8)]=j);return S},[qd]),Vd=IC(da,qd);w.useEffect(()=>{let S=0;for(const T of Vd.values())S+=T;for(const T of Object.values(Jl))S+=T;window.dispatchEvent(new CustomEvent("markus:team-unread-changed",{detail:{count:S}}))},[Vd,Jl]);const ec=Vd,Qk=w.useCallback(async S=>{const T=[];for(const[j,D]of Object.entries(da))D===S&&T.push(`session:${j}`);await Gg(T)},[da,Gg]);w.useEffect(()=>{if(t||!((!v||x==="chat")&&P==="chat"))return;if(he==="direct"&&ge&&Qk(ge),he==="channel"&&yt)Zd(`channel:${yt}`);else if(he==="direct"&&it)Zd(`session:${it}`);else if(he==="dm"&&Zt){const j=`dm:${[e?.id,Zt].sort().join(":")}`;Zd(`channel:${j}`)}const T=[];if(he==="direct"&&it){T.push(`session:${it}`);for(const[j,D]of Object.entries(da))D===ge&&T.push(`session:${j}`)}else he==="channel"&&yt?T.push(`channel:${yt}`):he==="dm"&&Zt&&e?.id&&T.push(`channel:dm:${[e.id,Zt].sort().join(":")}`);for(const j of T)Pk(j);return()=>{Tk(T)}},[t,he,yt,it,Zt,ge,x,P,da]);const or=w.useCallback(()=>ne.agents.list().then(S=>h(S.agents)).catch(()=>{}),[]),$k=w.useCallback((S,T)=>{S&&h(j=>j.map(D=>D.id===S?{...D,avatarUrl:T}:D))},[]),Gs=w.useCallback(()=>ne.teams.list().then(S=>{Xg(S.teams),fk(!0)}).catch(()=>{}),[]),ro=w.useCallback(()=>ne.groupChats.list().then(S=>ra(S.chats)).catch(()=>{}),[]),jk=w.useMemo(()=>Ou(or,3e3),[or]),tc=w.useMemo(()=>Ou(Gs,5e3),[Gs]),Fd=w.useMemo(()=>Ou(ro,3e3),[ro]),ua=w.useCallback(()=>{ne.users.list(e?.orgId).then(S=>d(S.users)).catch(()=>{})},[e?.orgId]);w.useEffect(()=>{v&&(x!=="team"||!y||GO(y,Es.map(S=>S.id),Ld)==="missing"&&(window.location.hash=Ut.TEAM))},[v,x,y,Es,Ld]),w.useEffect(()=>{t||(Promise.all([or(),Gs()]).finally(()=>p(!1)),ua(),ne.tasks.list().then(S=>zg(S.tasks)).catch(()=>{}),ne.externalAgents.list().then(S=>pk(S.agents)).catch(()=>{}),ro())},[t,ua]),w.useEffect(()=>{if(!(!t||!r)&&(h(r.agents??[]),d(r.humans??[]),Xg(r.teams??[]),ra(r.groupChats??[]),r.channelMessages)){const S=r.activeChannel??"custom:general";Rs(r.channelMessages.filter(T=>T.channel===S).map(T=>Bn(T)))}},[t,r]),w.useEffect(()=>{AP()},[]),w.useEffect(()=>{if(t||!o)return;const S=()=>{const G=ge,se=qs.map(Ee=>Ee.id).filter(Ee=>Ee!==lt);it&&it!==lt&&!se.includes(it)&&se.push(it),G&&se.length>0&&MP(G,se)};let T=null;const j=()=>{T||(T=setInterval(S,6e4))},D=()=>{T&&clearInterval(T),T=null},F=()=>{document.hidden?D():(S(),j())};return document.addEventListener("visibilitychange",F),document.hidden||j(),S(),()=>{D(),document.removeEventListener("visibilitychange",F)}},[t,o,qs,ge,it]),w.useEffect(()=>{if(t||!o)return;or(),Gs();const S=setInterval(or,3e4),T=setInterval(Gs,6e4),j=Rt.on("agent:update",Ne=>{const ct=Ne?.payload;if(ct?.agentId){const wt=ct.status,es=ct.currentActivity;h(Vt=>Vt.map(xs=>{if(xs.id!==ct.agentId)return xs;const bs={...xs};return wt&&(bs.status=wt),es!==void 0&&(bs.currentActivity=es),bs}))}jk(),tc()}),D=Rt.on("team:update",()=>{tc(),Fd()}),F=Rt.on("agent:removed",tc),G=Rt.on("chat:group_created",()=>{ro(),Gs(),or()}),se=Rt.on("chat:group_updated",Fd),Ee=Rt.on("chat:group_deleted",()=>{Fd(),tc()}),Ze=Rt.on("task:update",Ne=>{const ct=Ne?.payload;ct?.taskId&&zg(wt=>wt.map(es=>es.id===ct.taskId?{...es,status:ct.status??es.status}:es))}),Se=Rt.on("approval:resolved",Ne=>{const ct=Ne?.payload?.approvalId;ct&&(Xl(wt=>wt&&wt.id===ct?null:wt),ta(wt=>wt&&wt.id===ct?null:wt))}),Ce=()=>{or(),Gs(),ua()};return window.addEventListener("markus:data-changed",Ce),()=>{clearInterval(S),clearInterval(T),j(),D(),F(),G(),se(),Ee(),Ze(),Se(),window.removeEventListener("markus:data-changed",Ce)}},[t,o,ua]),w.useEffect(()=>{if(t)return;const S=Se=>{const Ce=Se.detail;if(VC(Ce.page)===Ut.TEAM){if(Ce.params?.agentId&&(Ce.params.profileTab?Ot(Ce.params.agentId,{tab:Ce.params.profileTab}):(Mt("direct"),Xs(Ce.params.agentId),_("chat"),v&&k(),Ce.params.sessionId?Te.current={agentId:Ce.params.agentId,sessionId:Ce.params.sessionId,chips:Ce.params.chatChips??null}:Ce.params.preferMain==="1"&&(oi.current={mode:"direct",agentId:Ce.params.agentId,sessionId:null,preferMain:!0}))),Ce.params?.selectAgent&&(Mt("direct"),Xs(Ce.params.selectAgent),_("chat"),v&&k()),Ce.params?.openDeliverable){const Ne=Ce.params.openDeliverable;localStorage.removeItem("markus_nav_openDeliverable"),v?gr.navigate(Ut.DELIVERABLES,{openDeliverable:Ne}):ie&&ne.deliverables.get(Ne).then(ct=>{ct.deliverable&&ie({kind:"deliverable",deliverable:ct.deliverable})}).catch(()=>{})}if(Ce.params?.prefillMessage){const Ne=Ce.params.prefillMessage;localStorage.removeItem("markus_nav_prefillMessage"),localStorage.removeItem("markus_nav_autoSend"),_("chat"),Ce.params?.autoSend==="true"?setTimeout(()=>Ug.current?.(Ne),300):((Ce.params?.preferMain==="1"||Ce.params?.sessionId)&&(Ul.current=Ne),ir(Ne),setTimeout(()=>{const ct=Ss.current;ct&&(ct.focus(),ct.setSelectionRange(ct.value.length,ct.value.length))},100))}if(Ce.params?.chatChips){const Ne=Ce.params.chatChips;localStorage.removeItem("markus_nav_chatChips"),_("chat"),Ce.params.sessionId||De(Ne)}if(Ce.params?.dm&&(Mt("dm"),Ti(Ce.params.dm),_("chat"),v&&k()),Ce.params?.channel&&(Mt("channel"),zs(Ce.params.channel),_("chat"),v&&k()),Ce.params?.selectTeam){const Ne=Ce.params.selectTeam;if(v)C(Ne);else{const ct=jd.current.find(wt=>wt.type==="team"&&wt.teamId===Ne);Mt("channel"),zs(ct?.channelKey??`group:${Ne}`),_("chat"),_s(!1),Ue(!0)}}Ce.params?.openHire}},T=localStorage.getItem("markus_nav_agentId");if(T){localStorage.removeItem("markus_nav_agentId");const Se=localStorage.getItem("markus_nav_profileTab");localStorage.removeItem("markus_nav_profileTab"),Mt("direct"),Xs(T),Se?Ot(T,{tab:Se}):(_("chat"),v&&k())}const j=localStorage.getItem("markus_nav_dm");j&&(localStorage.removeItem("markus_nav_dm"),Mt("dm"),Ti(j),_("chat"),v&&k());const D=localStorage.getItem("markus_nav_channel");D&&(localStorage.removeItem("markus_nav_channel"),Mt("channel"),zs(D),_("chat"),v&&k());const F=localStorage.getItem("markus_nav_prefillMessage");F&&(localStorage.removeItem("markus_nav_prefillMessage"),localStorage.removeItem("markus_nav_autoSend"),_("chat"),ir(F),setTimeout(()=>{const Se=Ss.current;Se&&(Se.focus(),Se.setSelectionRange(Se.value.length,Se.value.length))},150));const G=localStorage.getItem("markus_nav_chatChips");G&&(localStorage.removeItem("markus_nav_chatChips"),_("chat"),De(G));const se=localStorage.getItem("markus_nav_openDeliverable");se&&(localStorage.removeItem("markus_nav_openDeliverable"),v?gr.navigate(Ut.DELIVERABLES,{openDeliverable:se}):ie&&ne.deliverables.get(se).then(Se=>{Se.deliverable&&ie({kind:"deliverable",deliverable:Se.deliverable})}).catch(()=>{}));const Ee=localStorage.getItem("markus_nav_selectAgent");Ee&&(localStorage.removeItem("markus_nav_selectAgent"),Mt("direct"),Xs(Ee),_("chat"),v&&k());const Ze=localStorage.getItem("markus_nav_selectTeam");if(Ze)if(localStorage.removeItem("markus_nav_selectTeam"),v)C(Ze);else{const Se=jd.current.find(Ce=>Ce.type==="team"&&Ce.teamId===Ze);Mt("channel"),zs(Se?.channelKey??`group:${Ze}`),_("chat"),_s(!1),Ue(!0)}return window.addEventListener("markus:navigate",S),()=>window.removeEventListener("markus:navigate",S)},[t]),w.useEffect(()=>{const S=Bg.current;if(!S)return;const T=ws.find(j=>j.type==="team"&&j.teamId===S);Bg.current=null,Mt("channel"),zs(T?.channelKey??`group:${S}`),_("chat"),_s(!1),Ue(!0)},[ws,Es]),w.useEffect(()=>{if(t&&r?.chatMode==="channel"||l.length===0||ge&&l.some(j=>j.id===ge))return;const S=localStorage.getItem("markus_nav_after_remove");if(S&&(localStorage.removeItem("markus_nav_after_remove"),S.startsWith("channel:"))){Mt("channel"),zs(S.slice(8)),_("chat");return}const T=l.find(j=>!j.teamId&&j.role?.toLowerCase()==="secretary")??l.find(j=>j.role?.toLowerCase()==="secretary")??l.find(j=>j.name?.toLowerCase().includes("secretary"));T?(Mt("direct"),Xs(T.id),_("chat")):l.length>0&&(Mt("direct"),Xs(l[0].id),_("chat"))},[l,ge]);const io=w.useRef(!1),kn=w.useRef(!1),fa=w.useRef(0),Ud=w.useRef("none"),Hd=w.useRef(0),sc=w.useRef(0),ai=w.useRef(null),Yd=w.useRef(null),Kg=w.useRef([]),Gd=w.useRef(0),[Rk,Cn]=w.useState(!1),no=w.useRef(0),[Jg,ma]=w.useState(0),oo=w.useCallback(()=>performance.now()<fa.current,[]),Ni=w.useCallback(()=>xP({takeover:kn.current,gestureActive:oo()}),[oo]),ar=w.useCallback(()=>{kn.current=!1,fa.current=0,Ud.current="none",Gd.current=0,sc.current+=1,io.current=!1,Cn(!1),no.current=0,ma(0)},[]),zr=w.useCallback(()=>{kn.current||(kn.current=!0,sc.current+=1,io.current=!1,ai.current!==null&&(cancelAnimationFrame(ai.current),ai.current=null),Cn(!0))},[]),rc=w.useCallback(S=>{fa.current=performance.now()+vu,S!=="none"&&(Ud.current=S);const T=Xr.current;bP(S,!!T&&c0(T))&&zr()},[zr]),ic=w.useCallback(S=>{const T=Xr.current;if(!T)return;const j=T.scrollTop-Hd.current;Hd.current=T.scrollTop;const D=OP({takeover:kn.current,gestureActive:oo(),gestureDirection:Ud.current,scrollable:c0(T),distance:Uc(T),deltaScrollTop:j,programmatic:S?.programmatic??io.current,intentPending:Os.current!==null});D==="handover"?zr():D==="resume"?ar():D==="follow"?(Cn(!1),no.current=0,ma(0)):kn.current&&Cn(!0)},[oo,zr,ar]);w.useEffect(()=>{const S=Xr.current;if(!S)return;let T=null;const j=Ce=>{rc(uP(Ce.deltaX,Ce.deltaY))},D=Ce=>{T=Ce.touches[0]?.clientY??null,fa.current=performance.now()+vu},F=Ce=>{const Ne=Ce.touches[0]?.clientY;if(Ne==null)return;const ct=gP(T,Ne);T=Ne,rc(ct)},G=()=>{T=null},se=Ce=>{np(Ce.target)||rc(pP(Ce.key))},Ee=Ce=>{const Ne=S.getBoundingClientRect();Ce.clientX-Ne.left<S.clientWidth||(fa.current=performance.now()+vu)},Ze=()=>{ic()};S.addEventListener("wheel",j,{passive:!0}),S.addEventListener("touchstart",D,{passive:!0}),S.addEventListener("touchmove",F,{passive:!0}),S.addEventListener("touchend",G,{passive:!0}),S.addEventListener("pointerdown",Ee,{passive:!0}),S.addEventListener("scroll",Ze,{passive:!0}),document.addEventListener("keydown",se);const Se=typeof ResizeObserver<"u"?new ResizeObserver(()=>ic()):null;return Se?.observe(S),Hd.current=S.scrollTop,ic(),()=>{S.removeEventListener("wheel",j),S.removeEventListener("touchstart",D),S.removeEventListener("touchmove",F),S.removeEventListener("touchend",G),S.removeEventListener("pointerdown",Ee),S.removeEventListener("scroll",Ze),document.removeEventListener("keydown",se),Se?.disconnect()}},[x,ic,rc]);const Kd=w.useMemo(()=>new Set(Dg),[Dg]),ls=w.useMemo(()=>{const S=he==="channel"?ns:ns.filter(D=>!D.isActivityLog),T=Kd.size===0?S:S.filter(D=>!(D.isNotification&&Kd.has(D.id))),j=t&&Al?T.length-1:-1;return T.filter((D,F)=>l2(D,F===j||!!D.isStreaming&&ca))},[ns,he,Kd,ca,t,Al]);w.useEffect(()=>{yd.current=P==="chat"&&ls.length>0,Go()},[P,ls.length,Go]);const ao=V2({count:ls.length,getScrollElement:()=>Xr.current,getItemKey:S=>ls[S]?.id??S,estimateSize:S=>{const T=ls[S];return T?T.segments&&T.segments.length>0?300:T.text.length>500?200:120:120},overscan:8});ao.shouldAdjustScrollPositionOnItemSizeChange=(S,T,j)=>xu()||Os.current?.priority==="jump"?!1:S.start<(j.scrollOffset??0);const lr=w.useCallback((S="instant")=>{if(!Ni()||performance.now()<Gd.current)return;const T=Xr.current;if(!T)return;const j=++sc.current,D=()=>j===sc.current&&Ni();if(S==="smooth"){Gd.current=performance.now()+hP,T.scrollTo({top:T.scrollHeight,behavior:"smooth"});return}ai.current!==null&&(cancelAnimationFrame(ai.current),ai.current=null),io.current=!0;let F=0;const G=()=>{if(ai.current=null,!D()){io.current=!1;return}if(T.scrollTop=T.scrollHeight,F+=1,F<cP&&Uc(T)>1){ai.current=requestAnimationFrame(G);return}io.current=!1};T.scrollTop=T.scrollHeight,ai.current=requestAnimationFrame(G)},[Ni]),Pn=w.useCallback(S=>{const T=Xr.current;!T||!S||T.scrollHeight<=T.clientHeight||u0.save(S,yP(d0(T),T))},[]),Tn=w.useCallback(()=>{Hl.current+=1;for(const S of Yl.current)clearTimeout(S);Yl.current=[]},[]),lo=w.useCallback(()=>{Os.current=null,Tn()},[Tn]),eO=w.useCallback(()=>{ar(),lo(),Yd.current!==null&&cancelAnimationFrame(Yd.current);for(const S of Kg.current)clearTimeout(S);lr("instant"),Yd.current=requestAnimationFrame(()=>lr("instant")),Kg.current=[60,160,320].map(S=>setTimeout(()=>lr("instant"),S))},[ar,lo,lr]),Jd=w.useCallback(S=>{const T=Os.current;if(!T||T.key!==S)return!0;if(Zs.current!==S||T.priority!=="prepend"&&oo())return Os.current=null,!0;const j=Xr.current;if(!j)return!0;if(xu())return!1;const{anchor:D}=T;if(D.kind==="bottom"){yu(T.priority)&&ar(),j.scrollTop=j.scrollHeight;const ct=Uc(j)<=1,wt=p0(ct,T.prevSettled);return T.prevSettled=ct,wt?(Os.current=null,!0):!1}const F=TP(T.at,performance.now()),G=_P(d0(j),j,D.id,D.delta),se=G===null&&!F&&(Hs(T.bufferId)??[]).some(ct=>ct.id===D.id),Ee=G!==null&&Math.abs(G)<=1,Ze=p0(Ee,T.prevSettled),Se=G===null&&!se,Ce=zt.getWindowBounds(T.bufferId).hasMore,Ne=QP({priority:T.priority,rendered:G!==null,stale:F,stable:Ze,absent:Se,canLoadMore:Ce});switch(T.prevSettled=G!==null?Ee:null,yu(T.priority)&&Ne!=="release-bottom"&&Ne!=="release-hold"&&zr(),Ne){case"apply":return Xi("intent:apply",{id:D.id,priority:T.priority,correction:G}),Os.current=null,!0;case"refine":return G!==null&&Math.abs(G)>1&&(j.scrollTop+=G),G!==null&&Math.abs(G)>8&&Xi("intent:refine",{id:D.id,priority:T.priority,correction:G}),!1;case"release-bottom":return Xi("intent:release-bottom",{id:D.id,priority:T.priority}),Os.current=null,yu(T.priority)&&ar(),j.scrollTop=j.scrollHeight,!0;case"release-hold":return Xi("intent:release-hold",{id:D.id,priority:T.priority,stale:F,absent:Se,canLoadMore:Ce,bufferId:T.bufferId}),Os.current=null,console.warn("[scroll-intent] 目标行始终没能渲染出来,放弃定位(视口保持在原地)",{priority:T.priority,anchor:D}),!0;default:{const ct=Yg.current.findIndex(wt=>wt.id===D.id);if(ct>=0){const wt=ao.getOffsetForIndex(ct,"start");wt&&(j.scrollTop=wt[0]+D.delta)}else zd.current?.();return!1}}},[ao,oo,zr,ar,Hs]),nc=w.useCallback(()=>{const S=Os.current;if(!S)return;const T=S.key;Tn();const j=Hl.current,D=G=>{Yl.current.push(setTimeout(()=>{j===Hl.current&&Os.current?.key===T&&(Jd(T)||D(m0))},G))},F=[0,60,160,320,560,900];F.forEach((G,se)=>{const Ee=se===F.length-1,Ze=()=>{if(j!==Hl.current)return;!Jd(T)&&Ee&&D(m0)};G===0?requestAnimationFrame(Ze):Yl.current.push(setTimeout(Ze,G))})},[Jd,Tn]),co=w.useCallback((S,T,j="restore",D)=>{if(!S)return!1;const F=Os.current;return CP(F,{key:S,priority:j})?(Os.current={key:S,bufferId:D??_n(),anchor:T,at:performance.now(),priority:j,prevSettled:null},nc(),!0):!1},[_n,nc]),pa=w.useCallback(S=>{S&&co(S,u0.get(S)??{kind:"bottom"})},[co]),Ek=w.useCallback(()=>{Os.current||(so.current!==null&&clearTimeout(so.current),so.current=setTimeout(()=>{so.current=null,Pn(Zs.current)},200))},[Pn]);Yg.current=ls,w.useLayoutEffect(()=>()=>{Pn(Zs.current),Tn(),so.current!==null&&clearTimeout(so.current)},[Pn,Tn]);const ga=w.useMemo(()=>$I(ls,ql),[ls,ql]);w.useEffect(()=>{ia(-1)},[ql]);const oc=w.useCallback(S=>{const T=()=>{const F=document.getElementById(`msg-${S}`);return F?(F.classList.remove("chat-find-hit"),F.offsetWidth,F.classList.add("chat-find-hit"),window.setTimeout(()=>F.classList.remove("chat-find-hit"),1600),!0):!1};let j=0;const D=()=>{T()||j++>=8||window.requestAnimationFrame(D)};D()},[]),tO=w.useCallback(async(S,T)=>{lo(),zr();const j=Zs.current,D=le.current,F=()=>(Hs(D)??[]).some(se=>se.id===S);let G=F();if(!G&&j){const se=zt.getActiveSession(D)??D,Ee=await RI({targetId:S,has:F,targetCreatedAt:T,fetchPage:async Se=>{if(!se||se===lt)return{messages:[],hasMore:!1};const Ce=await ne.sessions.getMessages(se,50,Se);return{messages:Ce.messages,hasMore:Ce.hasMore}}}),Ze=jI(Ee.messages,S);Ze.length>0&&(z(D,Ze.map(mh)),Li(se,{hasMore:Ee.hasMore,oldestCursor:Ze[0]?new Date(Ze[0].createdAt).toISOString():null})),G=Ee.found||F(),Xi("jump:collected",{messageId:S,found:Ee.found,kept:Ze.length,exhausted:Ee.exhausted})}if(Xi("jump:located",{messageId:S,loaded:G,key:j,nowKey:Zs.current}),!(j&&Zs.current!==j)){if(G&&j){co(j,h0(S),"jump",_n()),Xi("jump:scheduled",{messageId:S,key:j}),oc(S);return}j&&(Xi("jump:fallback-bottom",{messageId:S,key:j}),console.warn("[jump] target message not loaded — falling back to the bottom",{messageId:S}),ar(),lr("instant"))}},[lo,zr,co,oc,Hs,zt,z,Li,ar,lr]),Ak=w.useCallback(S=>{const T=ga.matches[S];T&&(ia(S),lo(),zr(),Zs.current&&co(Zs.current,h0(T.messageId),"jump"),oc(T.messageId))},[ga.matches,lo,zr,co,oc]);w.useEffect(()=>{if(P!=="chat"||t)return;const S=T=>{T.key.toLowerCase()!=="f"||T.altKey||T.shiftKey||!(b?T.metaKey&&!T.ctrlKey:T.ctrlKey&&!T.metaKey)||(T.preventDefault(),Kn(!0))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[P,t,b]);const sO=w.useRef(o);w.useEffect(()=>{sO.current=o},[o]),w.useLayoutEffect(()=>{const S=Wd.current;if(S&&(Wd.current=null,!Os.current&&S.key===Zs.current)){const T=Xr.current,j=T?T.scrollHeight-S.scrollHeight:0;T&&j>0&&(T.scrollTop+=j,T.dispatchEvent(new Event("scroll")))}if(Os.current){nc();return}sO.current&&Ni()&&(xu()||lr())},[ns,lr,Ni,nc]);const rO=w.useRef(P);w.useEffect(()=>{const S=rO.current!=="chat";rO.current=P,P==="chat"&&S&&pa(Zs.current)},[P,hs,lr,Ni,pa]);const iO=w.useRef(I);w.useEffect(()=>{if(iO.current===I||(iO.current=I,P!=="chat")||ls.length===0||hs||On||!Ni())return;const S=[],T=requestAnimationFrame(()=>lr("instant"));for(const j of[60,160,320])S.push(setTimeout(()=>lr("instant"),j));return()=>{cancelAnimationFrame(T);for(const j of S)clearTimeout(j)}},[I,P,ls.length,hs,On,lr,Ni]);const ac=w.useCallback(async(S,T,j)=>{const D=T??`ch:${S}`;!j?.quiet&&le.current===D&&Wr(!0);try{const F=await ne.channels.getMessages(S,50),G=F.messages.map(se=>Bn(se,e?.id));z(D,G),Li(D,{hasMore:F.hasMore,oldestCursor:F.messages[0]?new Date(F.messages[0].createdAt).toISOString():null}),le.current===D&&Rs(G)}catch{le.current===D&&Rs([])}finally{!j?.quiet&&le.current===D&&Wr(!1)}},[Li]),eu=w.useCallback(async S=>{if(!S)return Ei([]),Nl(0),Dl(1),Bl(!1),xd(!1),[];xd(!0);try{const T=await ne.sessions.listByAgent(S,20,1);return Ei(T.sessions),Nl(T.total??T.sessions.length),Dl(T.page??1),Bl(!!T.hasMore),T.sessions}catch{return Ei([]),Nl(0),Dl(1),Bl(!1),[]}finally{xd(!1)}},[]),nO=w.useRef({chatContext:[],input:"",pendingImages:[],chatMode:he,selectedAgent:ge,activeSessionId:it,activeDmUserId:Zt,authUser:e,activeChannel:yt,groupChats:ws,agents:l,humans:u,sending:hs,chatReplyTo:null});nO.current={chatContext:br,input:os,pendingImages:nr,chatMode:he,selectedAgent:ge,activeSessionId:it,activeDmUserId:Zt,authUser:e,activeChannel:yt,groupChats:ws,agents:l,humans:u,sending:hs,chatReplyTo:mn};const Mk=S3({stateRef:nO,actBuffers:Gn,activeSessionBuffer:un,readConvMsgs:Hs,readSessionMsgs:$i,currentConvKeyRef:le,updateConvMsgs:Be,updateConvMsgsRaf:rt,appendConvActivity:ot,beginStream:Lt,endStream:St,abortStream:gs,clearStreamSession:ji,setStreamSession:us,getStreamSession:md,setActiveSession:Oe,incrementSending:ni,decrementSending:Br,loadAndDisplay:rr,sessionSwitchSeqRef:bd,setSending:Qi,setActivities:dn,setInput:ir,setChatContext:pn,setPendingImages:Ll,setMentionDropdown:na,setChatReplyTo:El,setActiveSessionId:Ai,setStoredActiveSession:Ko,setOpenSessionTabs:Ys,setSessions:Ei,setLoadingChat:Wr,setWindowBounds:Li,makeConvKey:Aa,makeDmChannel:Kl,addRecentMsgId:fd,resumeChatScrollFollow:ar,loadSessions:eu,t:i}),{send:ho,stopSending:Lk,tryReattachActiveStream:Qn,loadSessionMessages:lc}=Mk;Ug.current=ho;const oO=w.useCallback(()=>{eO(),ho()},[eO,ho]),aO=w.useRef(Qn);aO.current=Qn;const Nk=uh();w.useEffect(()=>{if(!o||t||he!=="direct"||!ge)return;const S=it;!S||S===lt||Cs.isStreaming(S)&&aO.current(ge,S,le.current)},[o,t,he,ge,it,Nk]);const lO=w.useRef(()=>{});lO.current=()=>{const S=b2({isActive:o,previewMode:t,chatMode:he,selectedAgent:ge,activeSessionId:it,placeholderId:lt});if(!S||!ge)return;const T=le.current;lc(S,T).then(()=>{Qn(ge,S,T)})},w.useEffect(()=>{const S=()=>{document.visibilityState==="visible"&&lO.current()};return document.addEventListener("visibilitychange",S),window.addEventListener("pageshow",S),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("pageshow",S)}},[]);const Dk=w.useCallback(async()=>{if(Wl||!ge||!Il)return;Qg(!0);const S=Tg+1,T=ge;try{const j=await ne.sessions.listByAgent(T,20,S);Ei(D=>{const F=new Set(D.map(se=>se.id)),G=[...D,...j.sessions.filter(se=>!F.has(se.id))];return Nl(j.total??G.length),G}),Dl(S),Bl(!!j.hasMore)}catch{}Qg(!1)},[Wl,Il,Tg,ge]),cO=w.useCallback(S=>{jg(S.id),kd((S.isMain?"":S.title)||"")},[]),Oa=w.useCallback(()=>{jg(null),kd("")},[]),hO=w.useCallback(async S=>{const T=_d.trim();if(!T){Oa();return}try{const D=(await ne.sessions.renameTitle(S.id,T))?.session?.title??T;Ei(F=>F.map(G=>G.id===S.id?{...G,title:D}:G)),Ys(F=>F.map(G=>G.id===S.id?{...G,title:D}:G))}catch{}Oa()},[_d,Oa]),dO=w.useCallback(async()=>{if(Gl.current)return Gl.current;const S=le.current,T=zt.getActiveSession(S)??S,j=zt.getWindowBounds(T),D=j.oldestCursor;if(!j.hasMore||!D)return 0;const F=T&&T!==lt?T:null,se=(async()=>{Sg(!0);try{const Ee=Zs.current;let Ze=[],Se=!1,Ce=null;if(he==="channel"||he==="dm"){const xs=he==="dm"?Kl(e?.id??"",Zt):yt,bs=await ne.channels.getMessages(xs,50,D);Ze=bs.messages.map(jr=>Bn(jr,e?.id)),Se=bs.hasMore,Ce=bs.messages[0]?new Date(bs.messages[0].createdAt).toISOString():null}else if(F){const xs=await ne.sessions.getMessages(F,50,D);Ze=xs.messages.map(mh),Se=xs.hasMore,Ce=xs.messages[0]?new Date(xs.messages[0].createdAt).toISOString():null}else return 0;if(Ze.length===0)return Li(T,{hasMore:Se,oldestCursor:D}),0;if(le.current!==S||Zs.current!==Ee)return 0;const Ne=Xr.current,ct=Ne?Ne.scrollHeight:null,wt=Hs(S)??[],es=new Set(Ze.map(xs=>xs.id));let Vt=[...Ze,...wt.filter(xs=>!es.has(xs.id))];return Vt.length>500&&(Vt=Vt.slice(-500)),z(S,Vt),Li(T,{hasMore:Se,oldestCursor:Ce}),ct!==null&&(Wd.current={key:Zs.current,scrollHeight:ct}),Rs(Vt),Ze.length}catch{return 0}finally{Sg(!1)}})();Gl.current=se;try{return await se}finally{Gl.current=null}},[he,yt,e?.id,Zt,Hs,z,zt,Li]);zd.current=dO;const tu=w.useRef(!1),Ik=w.useCallback(S=>{Ek(),!tu.current&&(tu.current=!0,requestAnimationFrame(()=>{tu.current=!1,S.target.scrollTop<100&&zd.current?.()}))},[]);w.useEffect(()=>{if(t)return;const S=Aa(he,ge,yt,Zt),T=le.current;le.current=S,T&&T!==S&&(Yo.set(T,qs),it&&Jm(T)&&Oe(T,it),Pn(po(T,it))),T!==S&&(ar(),Cn(!1),no.current=0,ma(0),Kn(!1),Ad(""),ia(-1));const j=Hs(S),D=Yo.get(S),F=un.get(S)??(ge?Pg(ge)??void 0:void 0),G=F??it,se=he!=="direct"?xr(S):Cs.isStreaming(G),Ee=G??S,Ze=Gn.get(Ee)??[];dn(se?Ze:[]),Qi(se),he==="direct"&&ge&&eu(ge),D&&D.length>0&&Ys(D),xn(!1);const Se=LP(oi.current,{chatMode:he,agentId:ge});if(j!==void 0&&j.length>0)if(se||zt.completeLoad(S),Wr(!1),Rs(j),F!==void 0&&(la(S,F),pa(po(S,F))),(!D||D.length===0)&&Ys([]),he==="channel"||he==="dm"){const Ne=he==="dm"?Kl(e?.id??"",Zt):yt;ac(Ne,S)}else he==="direct"&&ge&&F&&F!==lt&&!Se&&(se?Qn(ge,F,S):lc(F,S).then(()=>{le.current===S&&ge&&Qn(ge,F,S)}));else if(ut(S),Wr(!0),Rs([]),z(S,[]),he==="channel"||he==="dm"){const Ne=he==="dm"?Kl(e?.id??"",Zt):yt;ac(Ne,S),(!D||D.length===0)&&Ys([])}else he==="direct"&&ge?eu(ge).then(Ne=>{if(le.current===S)if(Ne.length>0){const ct=Ne.find(Ms=>Ms.isMain),wt=Sd(ge),es=ct?[ct,...Ne.filter(Ms=>!Ms.isMain&&!wt.has(Ms.id)).slice(0,4)]:Ne.filter(Ms=>!wt.has(Ms.id)).slice(0,5);let Vt=D&&D.length>0?D:es;const xs=Pg(ge),bs=F!==void 0?F:xs??ct?.id??Vt[0].id;if(bs&&bs!==lt&&!Vt.some(Ms=>Ms.id===bs)){const Ms=Ne.find(fu=>fu.id===bs);Ms&&(Vt=[...Vt,Ms])}const jr=bs&&Vt.some(Ms=>Ms.id===bs)?bs:Vt[0].id,ci=oi.current;if(ci&&ci.mode==="direct"&&ci.agentId===ge&&(ci.sessionId||ci.preferMain)){Ys(Vt);return}la(S,jr),pa(po(S,jr)),Ko(ge,jr),Ys(Vt),lc(jr,S).then(()=>{le.current===S&&ge&&Qn(ge,jr,S)})}else la(S,null),Wr(!1),(!D||D.length===0)&&Ys([])}).catch(()=>{le.current===S&&Wr(!1)}):Wr(!1)},[t,he,ge,yt,Zt,n.language,i]),w.useEffect(()=>t?void 0:Rt.on("chat:message",T=>{const j=T.payload,D=j.channel??"";if(!D)return;const F=j.senderType??"agent",G=j.text??j.message??"",se=j.senderId??j.agentId??"",Ee=j.senderName??j.agentId??i("page.fallbackAgent"),Ze=j.metadata,Se=j.messageId??j.id??"";if(Se&&ln.current.has(Se))return;const Ce=F==="human"&&se===(e?.id??""),Ne={id:Se||`ws_${Date.now()}_${se}`,sender:Ce?"user":"agent",text:G,time:new Date().toLocaleTimeString(),rawCreatedAt:T.timestamp??new Date().toISOString(),agentName:Ce?void 0:Ee,agentId:Ce?void 0:se,replyToId:j.replyToId??void 0,replyToSender:j.replyToSender??void 0,replyToText:j.replyToText??void 0};if(Ze&&F==="agent"){const wt=[];if(Ze.thinking?.length&&wt.push({type:"text",content:"",thinking:Ze.thinking.join(`
89
+
90
+ `)}),Ze.toolCalls?.length)for(let es=0;es<Ze.toolCalls.length;es++){const Vt=Ze.toolCalls[es];wt.push({type:"tool",key:`${Vt.tool}_${es}`,tool:Vt.tool,status:Vt.status==="error"?"error":"done",args:Vt.arguments,result:Vt.result,durationMs:Vt.durationMs})}wt.length>0&&(wt.push({type:"text",content:G}),Ne.segments=wt)}let ct;if(D.startsWith("notes:"))ct=`dm:${D.slice(6)}`;else if(D.startsWith("dm:")){const wt=D.slice(3).split(":");ct=`dm:${wt.find(Vt=>Vt!==(e?.id??""))??wt[0]??""}`}else ct=`ch:${D}`;Be(ct,wt=>bu(wt,Ne)),ct===le.current&&kn.current&&(no.current+=1,ma(no.current),Cn(!0))}),[t,Be,e?.id,yt]);const uO=w.useRef(!1);w.useEffect(()=>t?void 0:Rt.on("connected",()=>{const T=!uO.current;uO.current=!0,!T&&he==="channel"&&yt&&ac(yt,void 0,{quiet:!0})}),[t,he,yt,ac]),w.useEffect(()=>t?void 0:Rt.on("session:title_updated",T=>{const j=T.payload;if(!j)return;const D=j.sessionId,F=j.title;!D||typeof F!="string"||(Ei(G=>G.map(se=>se.id===D?{...se,title:F}:se)),Ys(G=>G.map(se=>se.id===D?{...se,title:F}:se)))}),[t]),w.useEffect(()=>t?void 0:Rt.on("chat:proactive_message",T=>{const j=T.payload,D=j.targetUserId;if(D&&D!==e?.id)return;const F=j.agentId??"",G=j.agentName??i("page.fallbackAgent"),se=j.message??"",Ee=j.sessionId??"",Ze=j.messageId??"",Se=j.metadata??{};if(!F||!se||se==="[cancelled]"||se==="[Stream cancelled]")return;const Ce=Se.role==="user",Ne=!Ce&&(!!Se.activityLog||se.startsWith("[ACTIVITY:")),{cleaned:ct,priority:wt}=c2(se),es=!Ce&&(!!Se.notifyUser||ct!==se),Vt=Aa("direct",F,"","");if(Ee&&le.current===Vt){const Rr=it;if(Rr&&Rr!==lt&&Rr!==Ee)return}const xs=!!Se.isMainSession&&!Ce,bs=Ee||it,jr=typeof Se.userText=="string"?Se.userText:"",ci=typeof Se.userMessageId=="string"?Se.userMessageId:"",Ms=typeof Se.createdAt=="string"&&Se.createdAt||(typeof T.timestamp=="string"?T.timestamp:void 0)||new Date().toISOString(),fu=(()=>{try{return new Date(Ms).toLocaleTimeString()}catch{return new Date().toLocaleTimeString()}})(),Ii={id:Ze||`proactive_${Date.now()}`,sender:Ce?"user":"agent",text:ct,time:fu,rawCreatedAt:Ms,...Ce?{}:{agentName:G,agentId:F,...es?{isNotification:!0,notifyPriority:Se.priority??wt}:{},...Ne?{isActivityLog:!0,activityType:Se.activityType,outcome:Se.outcome,mailboxItemId:Se.mailboxItemId,taskId:Se.taskId,requirementId:Se.requirementId}:{},...!Ne&&Se.taskId?{taskId:Se.taskId}:{},...!Ne&&Se.requirementId?{requirementId:Se.requirementId}:{}}};es&&Ii.id&&Qd(Rr=>Rr.includes(Ii.id)?Rr:[...Rr,Ii.id]),Be(Vt,Rr=>{if(Rr.some(An=>An.id===Ii.id))return Rr;let En=Rr;if(!Ce&&jr&&(En.some(Bi=>ci&&Bi.id===ci||Bi.sender==="user"&&Bi.text===jr)||(En=bu(En,{id:ci||`feishu_user_${Ii.id}`,sender:"user",text:jr,time:new Date().toLocaleTimeString(),rawCreatedAt:Ii.rawCreatedAt}))),xs)for(let An=En.length-1;An>=0;An--){const Bi=En[An];if(Bi.sender==="agent"&&Bi.agentId===F&&Bi.isStopped){const RO=[...En];return RO[An]={...Ii,id:Bi.id},RO}}return bu(En,Ii)},bs||void 0)}),[t,Be,i,it]),Nd.find(S=>S.id===gk),w.useEffect(()=>{Ok(null)},[ge]);const[vr,su]=w.useState(null),[fO,mO]=w.useState(!1),[Bk,pO]=w.useState(null),[Di,ru]=w.useState(null),Wk=w.useMemo(()=>{for(let S=ns.length-1;S>=0;S--)if(ns[S]?.sender==="agent"&&!ns[S]?.isActivityLog)return ns[S].id;return null},[ns]),Xk=w.useCallback(S=>{const T=S.segments?S.segments.filter(j=>j.type==="text").map(j=>j.content).join(`
91
+ `):S.text;navigator.clipboard.writeText(T),pO(S.id),setTimeout(()=>pO(j=>j===S.id?null:j),2e3)},[]),iu=w.useCallback((S,T,j)=>{const D=le.current,F=Hs(D)??ns,G=F.findIndex(Ee=>Ee.id===S.id);if(G<0)return;const se=T&&G>0&&F[G-1]?.id===T.id;Be(D,Ee=>{const Ze=Ee.findIndex(Se=>Se.id===(se?T.id:S.id));return Ze>=0?Ee.slice(0,Ze):Ee}),ho(j,{isRetry:!0})},[ns,Be]),zk=w.useCallback(S=>{const T=le.current,j=Hs(T)??ns,D=j.findIndex(Ee=>Ee.id===S.id);if(D<0)return;let F=null;for(let Ee=D-1;Ee>=0;Ee--)if(j[Ee]?.sender==="user"){F=j[Ee];break}const G=F?.text??"";if(!G)return;if(D<j.length-1){const Ee=j.length-1-D;ru({retryMsg:S,userMsg:F,retryText:G,followCount:Ee});return}iu(S,F,G)},[ns,iu]),qk=w.useCallback(S=>{const T=le.current;if((Hs(T)??ns).findIndex(G=>G.id===S.id)<0)return;Be(T,G=>{const se=[...G],Ee=se.findIndex(Ce=>Ce.id===S.id);if(Ee<0)return G;const Ze=se[Ee],Se=[...Ze.segments??[]];for(;Se.length>0;){const Ce=Se[Se.length-1];if(Ce.type==="tool"&&(Ce.status==="stopped"||Ce.status==="running"))Se.pop();else if(Ce.type==="text"&&!Ce.content)Se.pop();else break}return se[Ee]={...Ze,segments:Se,isStopped:!1,isError:!1},se});const F=un.get(T)??(it&&it!==lt?it:null);if(!F){console.warn("[resume] no session bound to this conversation — resume aborted");return}ho("[Continue from where you left off. Do not repeat content already generated.]",{isResume:!0,sessionIdOverride:F})},[ns,Be,it]),Zk=w.useCallback(S=>{const T=S.sender==="user"?e?.name??i("page.fallbackYou"):S.agentName??i("page.fallbackAgent");if(El({id:S.id,sender:T,text:S.text}),he==="channel"&&S.sender==="agent"&&S.agentName){const j=`@${S.agentName} `;ir(D=>D.startsWith(j)?D:j+D)}Ss.current?.focus()},[e?.name,he,i]),Vk=async S=>{if(!vr||!ge||he!=="direct")return;const T=it;if(!(!T||T===lt)){mO(!0);try{const j=await ne.agents.evolveFromMessage(ge,{parentSessionId:T,sourceMessageId:vr.isStreaming===!0||vr.id.startsWith("a_")||vr.id.startsWith("u_")?void 0:vr.id,sourceText:(vr.text||"").slice(0,500)||void 0,userNote:S.trim()||void 0}),D=new Date().toISOString(),F={id:j.sessionId,agentId:ge,userId:e?.id??null,title:"Remember / Evolution",isMain:!1,metadata:{kind:"evolution",parentSessionId:j.parentSessionId,sourceMessageId:vr.id,sourceAgentId:ge,createdFrom:"remember_button"},createdAt:D,lastMessageAt:D};su(null),Ei(se=>[F,...se.filter(Ee=>Ee.id!==F.id)]),Ys(se=>se.some(Ee=>Ee.id===F.id)?se:[...se,F]),Ai(F.id);const G=Aa("direct",ge,yt,Zt);ss(G,F.id),Ko(ge,F.id),Rs([]),await ho(j.seedPrompt,{sessionIdOverride:j.sessionId})}catch(j){console.error("evolve-from-message failed",j)}finally{mO(!1)}}},li=async S=>{const T=++bd.current,j=it,D=le.current;Pn(po(D,j)),la(D,S.id),pa(po(D,S.id)),xn(!1),ar(),Cn(!1),no.current=0,ma(0);const F=Cs.isStreaming(S.id);Qi(F),dn(F?Gn.get(S.id)??[]:[]),ge&&Ko(ge,S.id),j&&j!==lt&&Kt(D,j);const G=fn(D,S.id);(!G||G.length===0)&&S.id!==lt&&Wr(!0),Ys(se=>se.some(Ee=>Ee.id===S.id)?se:[...se,S]),ge&&ik(ge,S.id),le.current!==D&&(le.current=D);try{await lc(S.id,D)}finally{bd.current===T&&Wr(!1)}ge&&Qn(ge,S.id,D)};w.useEffect(()=>{const S=Te.current;!S||ge!==S.agentId||(Te.current=null,(async()=>{try{const{sessions:T}=await ne.sessions.listByAgent(S.agentId,50),j=T.find(D=>D.id===S.sessionId);if(!j){S.chips&&De(S.chips);return}await li(j),S.chips&&De(S.chips)}catch{S.chips&&De(S.chips)}})())},[ge,li,De]);const Fk=S=>{if(Ys(T=>T.filter(j=>j.id!==S)),ge&&S!==lt&&rk(ge,S),it===S){const T=qs.filter(j=>j.id!==S);T.length>0?li(T[T.length-1]):xa()}},gO=w.useCallback(async S=>{if(S.trim().length<2){Zl([]);return}Wg(!0);try{const T=he==="channel"?"channel":he==="direct"?"direct":"all",j=he==="channel"?yt:void 0,{results:D}=await ne.messages.search(S,{scope:T,channel:j,limit:30});Zl(D)}catch{Zl([])}Wg(!1)},[he,yt]),Uk=w.useCallback(S=>{Ad(S),Md.current&&clearTimeout(Md.current),Md.current=setTimeout(()=>{gO(S)},300)},[gO]),cc=w.useRef(null),Hk=w.useCallback(S=>{if(Kn(!1),Ad(""),Zl([]),S.source==="channel"&&S.channel){Mt("channel"),zs(S.channel),_("chat"),oi.current={messageId:S.id,mode:"channel",channel:S.channel};return}S.source==="direct"&&S.agentId&&(Mt("direct"),_("chat"),S.agentId!==ge&&Xs(S.agentId),oi.current={messageId:S.id,mode:"direct",agentId:S.agentId,sessionId:S.sessionId??null,createdAt:S.createdAt})},[ge]);w.useEffect(()=>{const S=oi.current;if(!S){Ul.current=null;return}const T=()=>{if(Xd.current=null,oi.current!==S)return;oi.current=null;const D=Ul.current;D!=null&&(Ul.current=null,ir(D)),S.messageId&&tO(S.messageId,S.createdAt)};if(S.mode==="channel"){if(he!=="channel"||yt!==S.channel||On)return;T();return}if(he!=="direct"||P!=="chat"||S.agentId&&S.agentId!==ge)return;const j=S.preferMain?(Qr.find(D=>D.isMain)??qs.find(D=>D.isMain))?.id:S.sessionId;if(!(S.preferMain&&!j)){if(j&&j!==it){if(Xd.current===S)return;const D=Qr.find(F=>F.id===j)??qs.find(F=>F.id===j)??(Qr.length===0?null:void 0);if(D===null)return;Xd.current=S,(async()=>{const F=new Date().toISOString();await li(D??{id:j,agentId:S.agentId??ge??"",userId:null,title:null,createdAt:F,lastMessageAt:F}),T()})();return}On||T()}},[he,yt,ge,it,Qr,Il,qs,On,P,ls,tO,li]);const xa=()=>{Pn(Zs.current),Tn(),Os.current=null,Ai(lt);const S=le.current;ss(S,lt),Rs([]),xn(!1),Ys(j=>{const D=j.filter(F=>F.id!==lt);return[{id:lt,agentId:ge??"",userId:null,title:i("page.newChat"),createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...D]});const T=ge;T&&ne.sessions.create(T).then(j=>{const D=j?.session;if(!D?.id)return;const F=D.id;if(le.current!==S)return;const G=un.get(S);G!==void 0&&G!==lt||(la(S,F),Ko(T,F),Ys(se=>se.map(Ee=>Ee.id===lt?{...Ee,id:F,title:D.title??Ee.title}:Ee)))}).catch(()=>{})},ba=w.useCallback(()=>{t||!o||P==="chat"&&(wd||Ye||Qe||Jn||to||Di||vr||requestAnimationFrame(()=>{const S=Ss.current;S&&!S.disabled&&(S.focus(),S.setSelectionRange(S.value.length,S.value.length))}))},[t,o,P,wd,Ye,Qe,Jn,to,Di,vr]),OO=w.useRef(o),xO=w.useRef(ge),bO=w.useRef(it);w.useEffect(()=>{const S=o&&!OO.current,T=ge!==xO.current,j=it!==bO.current;OO.current=o,xO.current=ge,bO.current=it,!v&&(S||T||j)&&ba()},[o,ge,it,v,ba]),w.useEffect(()=>{if(t||!o||v)return;const S=T=>{if(Di||vr||Jn||to||FC(T.target))return;const j=v2({key:T.key,metaKey:T.metaKey,ctrlKey:T.ctrlKey,altKey:T.altKey,shiftKey:T.shiftKey},b);if(j==="new-conversation"){if(he!=="direct"||!ge||P!=="chat")return;const D=T.target;if(D&&D!==Ss.current&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"||D.isContentEditable))return;T.preventDefault(),xa(),ba();return}if(j==="cycle-session-next"||j==="cycle-session-prev"){if(he!=="direct"||!ge||P!=="chat"||qs.length<2)return;const D=j==="cycle-session-prev"?-1:1,F=y2(qs.map(se=>se.id),it,D);if(!F)return;T.preventDefault();const G=qs.find(se=>se.id===F);if(!G)return;if(G.id===lt){Ai(lt);const se=le.current;ss(se,lt),Rs([])}else li(G);ba()}};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[t,o,v,b,he,ge,P,qs,it,Jn,to,Di,vr,xa,li,ba,Ai,ss,Rs,le]);const Yk=S=>{const T=eP({text:os,chips:br},S);ir(T.text),pn(T.chips);const j=Ss.current?.selectionStart??S.length,D=S.slice(0,j),F=D.lastIndexOf("@");if(F>=0){const G=F===0?"":D[F-1];if(F===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(G)){const Ee=D.slice(F+1);if(!Ee.includes(" ")&&!Ee.includes(`
92
+ `)){wk(),na(!0),xk(Ee.toLowerCase()),Vl.current={at:F,fragment:Ee},eo(0);return}}}if(Vl.current=null,na(!1),Id.length>0){const G=D.lastIndexOf("/");if(G>=0){const se=G===0?"":D[G-1];if(G===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(se)){const Ze=D.slice(G+1);if(!Ze.includes(" ")&&!Ze.includes(`
93
+ `)){Bd(),Fl(!0),bk(Ze.toLowerCase()),aa(0);return}}}}Fl(!1)},vO=w.useCallback(S=>{const T=Ss.current?.selectionStart??os.length,D=os.slice(0,T).lastIndexOf("/"),F=os.slice(T),G=os.slice(0,D)+"/"+S.name+" "+F;ir(G),Fl(!1),aa(0);const se=D+S.name.length+2;requestAnimationFrame(()=>{const Ee=Ss.current;Ee&&(Ee.focus(),Ee.setSelectionRange(se,se))})},[os]),hc=(S,T,j)=>{const D=Ss.current?.selectionStart??os.length,F=lP(os,Vl.current,D);Vl.current=null,ir(F),na(!1),eo(0);const G=T&&j?`@[${S}](${T}:${j})`:S.includes(" ")?`@[${S}]`:`@${S}`;_e({kind:T&&T2(T)?T:"note",label:S,content:`${G} `,id:`mention_${Date.now()}`}),requestAnimationFrame(()=>{const se=Ss.current;se&&(se.focus(),se.setSelectionRange(se.value.length,se.value.length))})},Gk=10*1024*1024,yO=5,Kk=new Set(["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-excel","application/msword","text/csv","text/html","application/json","application/xml","text/xml","application/epub+zip"]),uo=w.useCallback(S=>S.type.startsWith("image/")||Kk.has(S.type),[]),nu=S=>S.dataUrl.startsWith("data:image/"),Jk=(S,T)=>{if(nu({dataUrl:T}))return null;const j=S.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[j]??"📁"},va=w.useCallback(S=>{const T=Array.from(S).filter(uo);if(T.length!==0)for(const j of T){if(j.size>Gk)continue;const D=new FileReader;D.onload=()=>{const F=D.result;Ll(G=>G.length>=yO||G.some(se=>se.dataUrl===F)?G:[...G,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:F,name:j.name}])},D.readAsDataURL(j)}},[uo]),eC=w.useCallback(S=>{Ll(T=>T.filter(j=>j.id!==S))},[]),tC=w.useCallback(S=>{const T=S.clipboardData?.files;if(T&&T.length>0){const j=Array.from(T).filter(uo);j.length>0&&(S.preventDefault(),va(j))}},[va,uo]),sC=w.useCallback(S=>{S.preventDefault();const T=S.dataTransfer?.files;T&&T.length>0&&va(Array.from(T).filter(uo))},[va,uo]),rC=w.useCallback(S=>{S.preventDefault()},[]),Nt=l.find(S=>S.id===ge),$n=as??(he==="direct"?Nt?.teamId:void 0),ya=!!(!v&&!$&&$n&&Es.some(S=>S.id===$n)),SO=!!(ya&&!A&&(Fe&&!Xe||ft));me.current=ya,w.useEffect(()=>{if(ee==="l2"){if(!ya){W?.setKeyboardPane("l1");return}!A&&!Fe&&!ft&&W?.setKeyboardPane("l1")}},[ee,ya,A,Fe,ft,W]);const wO=w.useRef(ee);w.useEffect(()=>{if(t||v||!o)return;const S=wO.current;if(wO.current=ee,!(ee!=="l2"||S==="l2")){if(!$n){W?.setKeyboardPane("l1");return}Xe?mt(!0):Ue(!0)}},[ee,t,v,o,$n,Xe,W]);const dc=e?.name??i("page.fallbackYou"),_O=ls[ls.length-1];hs&&_O?.sender;const iC=Al&&_O?.sender==="agent"&&(ca||!!r),kO=w.useMemo(()=>{if(he!=="channel")return null;if(yt.startsWith("group:custom:")){const T=ws.find(j=>j.channelKey===yt);return T?.members?new Set(T.members.filter(j=>j.type==="agent").map(j=>j.id)):null}if(!as)return null;const S=Es.find(T=>T.id===as);return S?new Set(S.members.filter(T=>T.type==="agent").map(T=>T.id)):null},[he,yt,as,Es,ws]),CO=l.filter(S=>kO?kO.has(S.id):!0).filter(S=>S.name.toLowerCase().includes(qg)),PO=yk.filter(S=>S.name.toLowerCase().includes(qg)),jn=w.useMemo(()=>[...CO.map(S=>({kind:"agent",agent:S})),...PO.map(S=>({kind:"entity",entity:S}))],[CO,PO]),Rn=u.find(S=>S.id===Zt),fo=Zt===e?.id||!Zt,As=ws.find(S=>S.channelKey===yt);w.useEffect(()=>{if(t||!yt.startsWith("group:custom:"))return;const S=ws.find(T=>T.channelKey===yt);!S||S.members||ne.groupChats.getById(S.id).then(T=>{T.chat.members&&ra(j=>j.map(D=>D.id===S.id?{...D,members:T.chat.members}:D))}).catch(()=>{})},[t,yt,ws]);const ou=w.useCallback(async()=>{if(t||he!=="direct"||!ge){Cd([]),Pd([]);return}try{pu("/approvals");const{approvals:S}=await ne.approvals.list("pending");Cd(S.filter(T=>T.status==="pending"&&Array.isArray(T.questions)&&T.questions.length>0&&(T.details?.agentId??T.agentId)===ge)),Pd(BC(S,{agentId:ge,sessionId:it&&it!==lt?it:null}))}catch{}},[t,he,ge,it]),au=w.useCallback(async()=>{if(t||he!=="direct"||!ge||!it||it===lt){Td([]);return}try{pu("/notifications");const{notifications:S}=await ne.notifications.list(e?.id,!0,{type:"agent_report",limit:30}),T=S.filter(j=>!j.read&&j.type==="agent_report"&&!j.metadata?.creditExhausted&&j.metadata?.agentId===ge&&Gm(j)===it).sort((j,D)=>new Date(D.createdAt).getTime()-new Date(j.createdAt).getTime()).slice(0,5);Td(T),Qd(T.map(j=>j.metadata?.messageId).filter(j=>typeof j=="string"&&j.length>0))}catch{}},[t,he,ge,it,e?.id]);w.useEffect(()=>{ou(),au();let S=null;const T=()=>{S||(S=setTimeout(()=>{S=null,ou(),au()},400))},j=Rt.on("approval:requested",T),D=Rt.on("approval:resolved",T),F=Rt.on("notification",T),G=()=>T();return window.addEventListener("markus:notifications-changed",G),()=>{S&&clearTimeout(S),j(),D(),F(),window.removeEventListener("markus:notifications-changed",G)}},[ou,au]),w.useEffect(()=>{if(!o||t||he!=="direct"||P!=="chat"||ea.length===0||yn||vn||Mi)return;const S=ea.find(T=>!Mg.current.has(T.id));S&&(Mg.current.add(S.id),ta(S))},[o,t,he,P,ea,yn,vn,Mi]);const nC=w.useCallback(async(S,T)=>{Eg(S);try{await ne.approvals.respond(S,T.approved,e?.id,T.comment,T.selectedOption,T.answers),Cd(j=>j.filter(D=>D.id!==S)),Xl(null),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}Eg(null)},[e?.id]),oC=w.useCallback(async(S,T,j)=>{Ag(S);try{await ne.approvals.respond(S,T,e?.id,j),Pd(D=>D.filter(F=>F.id!==S)),ta(null),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}Ag(null)},[e?.id]),lu=w.useCallback(()=>{sa(null);const S=cc.current;cc.current=null,S&&(oi.current={messageId:S.messageId,mode:"direct",agentId:S.agentId,sessionId:S.sessionId,preferMain:S.preferMain})},[]);w.useEffect(()=>{const S=$r?.agentId;!S||S===ge||(sa(null),cc.current=null)},[$r?.agentId,ge]);const TO=w.useCallback(async S=>{if(!(t||!e?.id||$r))try{pu("/notifications");const{notifications:T}=await ne.notifications.list(e.id,!0,{type:"agent_report",limit:30}),j=NI(T,S);if(j.length===0)return;const D=DI(j);cc.current=D.sessionId?{agentId:S,sessionId:D.sessionId,messageId:D.messageId??void 0}:{agentId:S,sessionId:null,preferMain:!0},sa({items:j,index:0,agentId:S})}catch{}},[t,e?.id,$r]),cu=w.useCallback(S=>{Mt("direct"),Xs(S),_("chat"),TO(S)},[TO]),aC=w.useCallback(async S=>{Ng(S);const T=$r;try{const j=T?.items.find(G=>G.id===S)??Mi,D=typeof j?.metadata?.messageId=="string"?j.metadata.messageId:null;await ne.notifications.markRead(S),Td(G=>G.filter(se=>se.id!==S)),D&&Qd(G=>G.filter(se=>se!==D));const F=(T?.index??0)+1;T&&F<T.items.length?sa({...T,index:F}):lu(),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}Ng(null)},[$r,Mi,lu]),QO=he==="channel"?As?.name??yt:he==="direct"?Nt?.name??i("page.selectAgent"):he==="dm"?fo?i("chat.myNotes"):Rn?.name??i("page.directMessage"):i("page.chatTitle"),$O=w.useMemo(()=>Math.floor(Math.random()*5),[ge,it]),hu=w.useMemo(()=>Math.floor(Math.random()*3),[Zt,fo,it]),jO=w.useMemo(()=>{if(he==="dm"){if(fo)return i(`page.placeholder.dmSelfOptions.${hu}`);const S=Rn?.name??"";return S?i(`page.placeholder.dmOtherOptions.${hu}`,{name:S}):i("page.placeholder.dmOtherEmpty")}return he==="direct"&&ge?i(`page.placeholder.directOptions.${$O}`):""},[he,fo,Rn?.name,hu,ge,$O,i]),Sa=he==="direct"&&!!Nt&&Nt.status==="offline",du=he==="channel"?As?i("page.placeholder.channel",{name:As.name}):i("page.placeholder.channelWithMention",{name:yt}):he==="dm"?fo?i("page.placeholder.dmSelf"):i("page.placeholder.dmOther",{name:Rn?.name??""}):i(Sa?"page.placeholder.agentOffline":ge?"page.placeholder.direct":"page.placeholder.noAgent"),lC=v&&x==="chat",cC=w.useMemo(()=>WP({chatMode:he,agentTeamId:Nt?.teamId,channelTeamId:As?.teamId,knownTeamIds:Es.map(S=>S.id)}),[he,Nt?.teamId,As?.teamId,Es]),hC=w.useMemo(()=>{if(he==="direct"){const S=Qr.find(T=>T.id===it);if(S?.title)return S.title;if(Nt?.name)return Nt.name}return(he==="channel"?As?.name??yt:Rn?.name)||i("page.loadingChat",{defaultValue:"Loading conversation…"})},[he,Qr,it,Nt?.name,yt,Zt,As?.name,Rn?.name,i]),wa=P==="chat"&&ls.length===0&&!On,yr=P==="chat"&&ls.length>0;yd.current=yr;const dC=!!(os.trim()||nr.length>0),uu=S2(v,dC);return c.jsxs("div",{ref:V,className:"flex-1 overflow-hidden flex relative",children:[!$&&c.jsx(JP,{authUser:e,agents:l,teams:Es,humans:u,tasks:Nd,externalAgents:mk,groupChats:ws,chatMode:he,selectedAgent:ge,activeChannel:yt,activeDmUserId:Zt,previewMode:t,onSelectAgent:S=>{cu(S),_s(!1),v&&k()},onSelectChannel:S=>{Mt("channel"),zs(S),_("chat"),_s(!1),v&&k()},onSelectDm:S=>{Mt("dm"),Ti(S),_("chat"),_s(!1),v&&k()},onSelectTeam:S=>{const T=ws.find(D=>D.type==="team"&&D.teamId===S),j=T?.channelKey??`group:${S}`;v?C(S):(Mt("channel"),zs(j),_("chat"),_s(!1),!Fe&&!Xe&&Ue(!0),T||(ro(),Gs()))},selectedTeamId:as??(he==="direct"&&Nt?.teamId?Nt.teamId:null),onRefreshTeams:Gs,onRefreshAgents:or,onRefreshHumans:ua,onRefreshGroupChats:ro,onViewProfile:Ot,onManageGroupMembers:S=>{Mt("channel"),zs(S),_("chat"),_s(!0),v&&k()},unreadByAgent:ec,unreadByChannel:Jl,width:v?void 0:E.width,onResizeStart:v?void 0:E.onResizeStart,hidden:v&&x!=="roster"||!v&&A,onCollapse:()=>R(!0),initialLoading:f,focused:!v&&!A&&ee==="l1",l2Available:ya}),v&&x==="team"&&y&&(()=>{const S=Es.find(D=>D.id===y);if(!S){const F=GO(y,Es.map(G=>G.id),Ld)==="missing";return c.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 shrink-0 border-b border-border-default",children:[c.jsx("button",{onClick:()=>{window.location.hash=Ut.TEAM},className:"p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-secondary",title:i("common:back",{defaultValue:"Back"}),children:c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsx("span",{className:"text-sm font-semibold text-fg-primary truncate",children:i(F?"page.teamMissingTitle":"page.loadingTeam")})]}),c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[c.jsx("p",{className:"text-xs text-fg-tertiary max-w-[280px]",children:i(F?"page.teamMissingBody":"page.loadingTeamBody")}),c.jsx("div",{className:"flex items-center gap-2",children:F?c.jsx("button",{onClick:()=>{window.location.hash=Ut.TEAM},className:"px-3 py-1.5 text-xs font-medium bg-brand-600 text-on-brand rounded-md hover:bg-brand-700 transition-colors",children:i("page.backToList")}):c.jsx("button",{onClick:()=>{Gs()},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:i("common:retry",{defaultValue:"Retry"})})})]})]})}const T=l.filter(D=>D.teamId===y),j=ws.find(D=>D.type==="team"&&D.teamId===y);return c.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 shrink-0 border-b border-border-default",children:[c.jsx("button",{onClick:()=>{window.location.hash=Ut.TEAM},className:"p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-secondary",children:c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[c.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:S.name}),c.jsx("p",{className:"text-[10px] text-fg-tertiary",children:i("chat.members_other",{count:S.members?.length||T.length})})]})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-1",children:[(()=>{const D=j?.channelKey??my(y),F=Jl[D]??0;return c.jsxs("button",{onClick:()=>{Mt("channel"),zs(D),_("chat"),k()},className:"w-full flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors",children:[c.jsx("div",{className:"w-9 h-9 rounded-xl bg-brand-500/15 flex items-center justify-center shrink-0",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:c.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:j?.name??S.name}),c.jsx("div",{className:"text-[10px] text-fg-tertiary",children:i("chat.groupChat")})]}),F>0?c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:F}):c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})]})})(),T.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider px-2.5 pt-2",children:i("chat.agents")}),T.map(D=>{const F=ec.get(D.id)??0,G=D.status==="offline";return c.jsxs("button",{onClick:()=>{Mt("direct"),Xs(D.id),_("chat"),k()},className:`w-full flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors ${G?"opacity-50":""}`,children:[c.jsx(Is,{name:D.name||"Agent",avatarUrl:D.avatarUrl,size:36}),c.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[c.jsxs("div",{className:"text-sm font-medium text-fg-primary truncate flex items-center gap-1.5",children:[D.name,G&&c.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium leading-relaxed",children:i("common:status.offline")})]}),c.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:D.role||D.status})]}),F>0?c.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:F}):c.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${yl(D.status,Cs.isAgentStreaming(D.id)).dotClass}`})]},D.id)})]})]})]})})(),!$&&Fe&&!Xe&&!v&&!A&&(()=>{const S=as??(he==="direct"?Nt?.teamId:void 0);if(!S)return null;const T=Es.find(D=>D.id===S);if(!T)return null;const j=ws.find(D=>D.type==="team"&&D.teamId===S);return c.jsx(w0,{team:T,agents:l,humans:u,authUser:e,groupChat:j,chatMode:he,selectedAgent:ge,activeChannel:yt,activeDmUserId:Zt,teams:Es,onSelectAgent:D=>{cu(D),_s(!1)},onSelectChannel:D=>{Mt("channel"),zs(D),_("chat"),_s(!1)},onSelectDm:D=>{Mt("dm"),Ti(D),_("chat"),_s(!1)},onBack:()=>Ue(!1),onViewProfile:Ot,onRefreshAgents:or,onRefreshTeams:Gs,unreadByAgent:ec,width:ve.width,onResizeStart:ve.onResizeStart,focused:ee==="l2"&&SO})})(),!$&&ft&&!v&&!A&&(()=>{if(!$n)return null;const S=Es.find(j=>j.id===$n);if(!S)return null;const T=ws.find(j=>j.type==="team"&&j.teamId===$n);return c.jsxs("div",{"data-l2-floating":!0,className:"absolute z-30 inset-0",style:{left:E.width+6},children:[c.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:()=>mt(!1)}),c.jsx("div",{className:"relative h-full",style:{width:ve.width+8},children:c.jsx(w0,{team:S,agents:l,humans:u,authUser:e,groupChat:T,chatMode:he,selectedAgent:ge,activeChannel:yt,activeDmUserId:Zt,teams:Es,onSelectAgent:j=>{cu(j),_s(!1),mt(!1)},onSelectChannel:j=>{Mt("channel"),zs(j),_("chat"),_s(!1),mt(!1)},onSelectDm:j=>{Mt("dm"),Ti(j),_("chat"),_s(!1),mt(!1)},onBack:()=>mt(!1),onViewProfile:j=>{Ot(j),mt(!1)},onRefreshAgents:or,onRefreshTeams:Gs,unreadByAgent:ec,width:ve.width,focused:ee==="l2"&&SO})})]})})(),!$&&(!v||lC)&&c.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col ${v||Z?"min-w-0":"min-w-[400px]"}`,children:[c.jsxs("div",{className:"shrink-0 relative pb-2",children:[v?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[c.jsx("button",{onClick:()=>{window.location.hash=cC},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsxs("div",{className:"flex-1 min-w-0 flex items-center justify-center gap-1.5",children:[c.jsx("span",{className:"font-semibold text-sm truncate min-w-0",children:QO}),he==="direct"&&Nt&&c.jsx(C3,{agent:Nt})]}),c.jsx("button",{onClick:()=>bn(S=>!S),"aria-label":i("page.moreActions",{defaultValue:"更多操作"}),className:`p-1.5 rounded-md transition-colors shrink-0 ${$g?"bg-brand-500/15 text-brand-500":"text-fg-secondary"}`,children:c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[c.jsx("circle",{cx:"5",cy:"12",r:"1.7"}),c.jsx("circle",{cx:"12",cy:"12",r:"1.7"}),c.jsx("circle",{cx:"19",cy:"12",r:"1.7"})]})})]}),$g&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>bn(!1)}),c.jsxs("div",{className:"absolute right-2 top-full z-50 w-44 py-1 bg-surface-secondary border border-border-default rounded-xl shadow-2xl shadow-black/40",children:[c.jsxs("button",{onClick:()=>{bn(!1),zi(P)||kt()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-fg-secondary hover:bg-surface-overlay text-left",children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),c.jsx("path",{d:"M5 20a7 7 0 1 1 14 0"})]}),i(he==="channel"?"page.teamTab":"page.profileTab")]}),c.jsxs("button",{onClick:()=>{bn(!1),Kn(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-fg-secondary hover:bg-surface-overlay text-left",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),i("page.findInConversation")]}),he==="direct"&&!zi(P)&&c.jsxs("button",{onClick:()=>{bn(!1),xa()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-fg-secondary hover:bg-surface-overlay text-left",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 5v14M5 12h14"})}),i("page.newChat")]}),he==="direct"&&!zi(P)&&c.jsxs("button",{ref:zl,onClick:()=>{bn(!1),xn(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-fg-secondary hover:bg-surface-overlay text-left",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),i("page.historyTitle")]}),he==="channel"&&As?.type==="custom"&&c.jsxs("button",{onClick:()=>{bn(!1),_s(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-fg-secondary hover:bg-surface-overlay text-left",children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),i("page.membersTitle",{defaultValue:"成员"})," (",As.members?.length??As.memberCount??0,")"]})]})]})]}):(()=>{const S=as?Es.find(Se=>Se.id===as):void 0,T=he==="direct"&&ge?O3:he==="channel"&&as?x3:["chat"],j=async()=>{const Se=J.trim();if(!Se){Je(!1);return}try{he==="direct"&&ge?(await ne.agents.updateConfig(ge,{name:Se}),or()):he==="channel"&&as&&(await ne.teams.update(as,{name:Se}),Gs())}catch{}Je(!1)},D=async()=>{try{he==="direct"&&ge?(await ne.agents.updateConfig(ge,{title:Pe}),or()):he==="channel"&&as&&(await ne.teams.update(as,{description:Pe}),Gs())}catch{}be(!1)},F=he==="direct"?Nt?.name:he==="channel"?S?.name??As?.name:Rn?.name??"",G=he==="direct"?Nt?.role||"":he==="channel"&&S?.description||"",se=he==="direct"?Nt?.avatarUrl:void 0,Ee=F||"U",Ze=he==="direct"&&ge||he==="channel"&&as;return c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{"data-electron-drag":!0,className:"flex items-center px-4 h-14 gap-2.5",children:[A&&!v&&c.jsx("button",{onClick:()=>R(!1),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:i("page.toggleSidebar"),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),(!Fe||Xe)&&(he==="channel"&&as||he==="direct"&&Nt?.teamId)&&c.jsx("button",{onClick:_t,className:`w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 ${ft?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:i("chat.toggleTeamPanel"),children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),Ze&&c.jsx("div",{"data-no-drag":!0,className:"shrink-0",children:he==="channel"&&as?c.jsx("div",{className:"w-9 h-9 rounded-xl bg-brand-600 text-on-brand flex items-center justify-center text-sm font-bold",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}):c.jsxs("div",{className:"relative",ref:we,children:[c.jsx("button",{type:"button",onClick:()=>de(Se=>!Se),className:"block rounded-xl shrink-0 transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500",title:i("page.editAgentAvatar"),"aria-label":i("page.editAgentAvatar"),"aria-expanded":vt,children:c.jsx(Is,{name:Ee,avatarUrl:se,size:36,className:"rounded-xl shrink-0 pointer-events-none"})}),vt&&c.jsx("div",{"data-no-drag":!0,className:"absolute z-50 top-full left-0 mt-1.5 p-3 rounded-xl bg-surface-secondary border border-border-default shadow-2xl",children:c.jsx(WC,{currentUrl:se,name:Ee,size:64,targetType:"agent",targetId:Nt?.id,onUploaded:Se=>{de(!1),$k(Nt?.id,Se),or()}})})]})}),Ze?c.jsxs("div",{"data-no-drag":!0,className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Ye?c.jsx("input",{ref:pt,value:J,onChange:Se=>je(Se.target.value),onBlur:j,onKeyDown:Se=>{Se.key==="Enter"&&j(),Se.key==="Escape"&&Je(!1)},className:"text-sm font-semibold bg-transparent border-b border-brand-500 outline-none py-0 px-0 min-w-[80px] max-w-[240px]",autoFocus:!0}):c.jsx("span",{className:"text-sm font-semibold truncate cursor-pointer hover:text-brand-500 transition-colors",onClick:()=>{je(F??""),Je(!0)},title:i("chat.clickToEditName"),children:F}),he==="direct"&&Nt&&c.jsx(P3,{agent:Nt,tasks:Nd,onViewProfile:Ot})]}),(he==="direct"||he==="channel"&&as)&&(Qe?c.jsx("input",{ref:Pt,value:Pe,onChange:Se=>tt(Se.target.value),onBlur:D,onKeyDown:Se=>{Se.key==="Enter"&&D(),Se.key==="Escape"&&be(!1)},className:"text-[11px] text-fg-tertiary bg-transparent border-b border-brand-500/50 outline-none py-0 px-0 w-full max-w-[400px] mt-0.5",placeholder:i("chat.addTitle"),autoFocus:!0}):c.jsx("div",{className:"text-[11px] text-fg-tertiary truncate cursor-pointer hover:text-fg-secondary transition-colors mt-0.5",onClick:()=>{tt(G),be(!0)},title:i("chat.clickToEditTitle"),children:G||"No title"}))]}):c.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[c.jsx("span",{className:"font-semibold text-sm truncate",children:QO}),he==="dm"&&c.jsx("span",{className:"text-xs text-fg-tertiary",children:fo?i("page.privateNotepad"):""})]}),c.jsxs("div",{"data-no-drag":!0,className:"ml-auto flex items-center gap-2 shrink-0",children:[he==="direct"&&Nt&&P==="chat"&&c.jsx("button",{onClick:xa,title:i("page.newChatKbdHint",{kbd:XO(["N"],b)}),className:"text-xs font-semibold text-on-brand bg-brand-600 hover:bg-brand-700 px-3.5 py-1.5 rounded-lg shadow-sm transition-colors flex items-center gap-1",children:i("page.newChatButton")}),c.jsx("button",{onClick:()=>{Kn(Se=>!Se),Ed&&ia(-1)},className:`p-1.5 rounded-md transition-colors ${Ed?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:`${i("page.findInConversationHint")} (${XO(["F"],b)})`,"data-testid":"find-in-conversation-btn",children:c.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 6h11M8 12h11M8 18h6"}),c.jsx("circle",{cx:"17.5",cy:"17.5",r:"3.5"}),c.jsx("path",{strokeLinecap:"round",d:"M20.5 20.5L22 22"})]})}),he==="channel"&&As?.type==="custom"&&c.jsxs("button",{onClick:()=>_s(!Rd),className:`text-xs px-2.5 py-1 rounded-md border transition-colors flex items-center gap-1.5 ${Rd?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-secondary hover:text-fg-primary border-border-default hover:bg-surface-elevated"}`,children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),c.jsx("circle",{cx:"9",cy:"7",r:"4"}),c.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),c.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),As.members?.length??As.memberCount??0]}),he==="direct"&&Nt&&P==="chat"&&c.jsx("button",{ref:zl,onClick:()=>xn(!Jo),className:`p-1.5 rounded-md transition-colors ${Jo?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:i("page.historyTitle"),children:c.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})}),!v&&W&&c.jsx("button",{onClick:()=>W.toggleRightPanel(),className:`p-1.5 rounded-md transition-colors ${Z?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:i("page.rightPanelToggle",{defaultValue:"Toggle side panel"}),children:c.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),c.jsx("path",{d:"M15 4v16"})]})})]})]}),T.length>1&&c.jsx("div",{className:"flex items-center gap-1 px-4 pb-1.5 overflow-x-auto scrollbar-hide",children:T.map(Se=>c.jsxs("button",{onClick:()=>_(Se),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors whitespace-nowrap flex items-center gap-1 ${P===Se?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[c.jsx("span",{children:v3(Se)}),b3(Se,i)]},Se))})]})})(),he==="direct"&&ge&&P==="chat"&&qs.length>1&&(()=>{const S=T=>Cs.isStreaming(T.id);return c.jsx("div",{ref:Ig,className:"flex items-center gap-0 px-3 overflow-x-auto scrollbar-hide",children:qs.map(T=>{const j=ep(T,i);return c.jsxs("div",{"data-session-tab-id":T.id,title:Gv(T,i),className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs cursor-pointer rounded-md transition-colors shrink-0 max-w-[180px] ${T.id===it?"text-brand-500 bg-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,onClick:()=>{if(T.id===lt){Ai(lt);const D=le.current;ss(D,lt),Rs([])}else li(T)},children:[T.isMain&&c.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:"●"}),c.jsx("span",{className:"truncate",children:j}),S(T)&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse shrink-0",title:i("common:status.working"),"aria-label":i("common:status.working"),"data-testid":"session-tab-streaming"}),!T.isMain&&c.jsx("button",{onClick:D=>{D.stopPropagation(),Fk(T.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},T.id)})})})(),Ed&&P==="chat"&&c.jsx(kI,{query:ql,onQueryChange:Uk,matches:ga.matches,cursor:hk,scanned:ga.scanned,truncated:ga.truncated,hasMore:K_,loadingMore:Od,onLoadEarlier:()=>{dO()},onJump:Ak,onClose:()=>{Kn(!1),ia(-1)},serverResults:dk,serverLoading:uk,onServerResultClick:Hk,labelFor:S=>{const T=ls[S.messageIndex];if(!T)return"";const j=T.sender==="user"?i("page.you",{defaultValue:"你"}):T.agentName??"",D=T.rawCreatedAt?mc(T.time,T.rawCreatedAt,a):T.time;return[j,D].filter(Boolean).join(" · ")}}),he==="direct"&&P==="chat"&&(qs.find(S=>S.id===it)??Qr.find(S=>S.id===it))?.metadata?.kind==="evolution"&&c.jsx("div",{className:"px-4 py-1.5 text-[11px] text-fg-tertiary border-b border-border-default bg-surface-secondary/40",children:i("page.messageActions.evolvedFrom")}),he==="channel"&&As?.type==="custom"&&Rd&&(()=>{const S=As,T=S.members??[],j=[];for(const D of l)T.some(F=>F.id===D.id)||j.push({id:D.id,name:D.name,type:"agent",subtitle:D.role||"Agent"});for(const D of u)T.some(F=>F.id===D.id)||j.push({id:D.id,name:D.name,type:"human",subtitle:D.email||D.role||""});return c.jsx(yI,{members:T,candidates:j,currentUserId:e?.id,memberCount:T.length,onClose:()=>_s(!1),onRemoveMember:D=>{ne.groupChats.removeMember(S.id,D).then(()=>{ra(F=>F.map(G=>G.id===S.id?{...G,members:(G.members??[]).filter(se=>se.id!==D),memberCount:(G.memberCount??1)-1}:G))}).catch(()=>{})},onAddMember:D=>{const F=j.find(G=>G.id===D);F&&ne.groupChats.addMember(S.id,F.id,F.type,F.name).then(()=>{ra(G=>G.map(se=>se.id===S.id?{...se,members:[...se.members??[],{id:F.id,name:F.name,type:F.type}],memberCount:(se.memberCount??0)+1}:se))}).catch(()=>{})}})})(),he==="direct"&&ge&&Jo&&c.jsxs("div",{ref:$d,className:"absolute right-4 top-full mt-1 w-72 max-h-[420px] bg-surface-secondary border border-border-default rounded-xl shadow-2xl shadow-black/40 z-50 flex flex-col overflow-hidden",children:[c.jsxs("div",{className:"px-4 py-3 border-b border-border-default flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:i("page.historyTitle")}),c.jsx("button",{onClick:()=>xn(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[ek&&Qr.length===0?c.jsx(ly,{rows:3,variant:"skeleton",className:"px-2 py-2"}):Qr.length===0?c.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:i("page.noConversationsYet")}):null,(()=>{const S=new Date,T=new Date(S.getFullYear(),S.getMonth(),S.getDate()).getTime(),j=T-864e5,D=T-7*864e5,F=[],G=[],se=[],Ee=[],Ze=[];for(const Se of Qr){const Ce=new Date(Se.lastMessageAt).getTime();Ce>=T?G.push(Se):Ce>=j?se.push(Se):Ce>=D?Ee.push(Se):Ze.push(Se)}return G.length>0&&F.push({label:i("page.dateToday"),items:G}),se.length>0&&F.push({label:i("page.dateYesterday"),items:se}),Ee.length>0&&F.push({label:i("page.datePrevious7Days"),items:Ee}),Ze.length>0&&F.push({label:i("page.dateOlder"),items:Ze}),F.map(Se=>c.jsxs("div",{className:"mb-2",children:[c.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider px-3 py-1.5",children:Se.label}),Se.items.map(Ce=>c.jsx("div",{className:`w-full text-left px-3 py-2 rounded-lg text-xs mb-0.5 transition-colors ${Ce.id===it?"bg-brand-600/20 text-brand-500":"hover:bg-surface-elevated"}`,children:wd===Ce.id?c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("input",{autoFocus:!0,value:_d,onChange:Ne=>kd(Ne.target.value),onKeyDown:Ne=>{Ne.key==="Enter"&&(Ne.stopPropagation(),hO(Ce)),Ne.key==="Escape"&&Oa()},onClick:Ne=>Ne.stopPropagation(),placeholder:Ce.isMain?i("page.sessionMain"):Ce.title||i("page.sessionConversation"),className:"w-full bg-surface-primary border border-brand-500/50 rounded-md px-2 py-1 text-xs text-fg-primary outline-none focus:ring-1 focus:ring-brand-500/50"}),c.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),hO(Ce)},className:"text-brand-400 hover:text-brand-300 shrink-0",title:i("common:save"),children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6L9 17l-5-5"})})}),c.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),Oa()},className:"text-fg-tertiary hover:text-fg-secondary shrink-0",title:i("common:cancel"),children:c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):c.jsxs("button",{onClick:()=>{li(Ce)},title:Gv(Ce,i),className:"w-full text-left group/session",children:[c.jsxs("div",{className:"truncate font-medium flex items-center gap-1",children:[Ce.isMain&&c.jsx("span",{className:"text-[10px] text-brand-500 opacity-80",children:"●"}),c.jsx("span",{className:"truncate",children:ep(Ce,i)}),!Ce.isMain&&c.jsx("span",{role:"button",tabIndex:0,onClick:Ne=>{Ne.stopPropagation(),cO(Ce)},onKeyDown:Ne=>{Ne.key==="Enter"&&(Ne.stopPropagation(),cO(Ce))},className:"opacity-0 group-hover/session:opacity-100 transition-opacity ml-auto text-fg-tertiary hover:text-brand-400 shrink-0",title:i("page.renameSession"),children:c.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})})]}),c.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(Ce.lastMessageAt).toLocaleString()})]})},Ce.id))]},Se.label))})(),Il&&c.jsx("button",{onClick:()=>{Dk()},disabled:Wl,className:"w-full text-center text-[11px] text-fg-tertiary hover:text-brand-400 py-2 rounded-lg transition-colors disabled:opacity-50",children:Wl?i("page.loadingEarlierMessages"):`${i("page.loadMoreSessions")} (${Qr.length}/${nk})`})]})]})]}),v&&P==="profile"&&he==="direct"&&ge&&c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx(Nv,{agentId:ge,onBack:()=>_("chat"),inline:!0,defaultTab:oe,initialSection:ue,highlightMailboxId:ke,onSwipeBack:()=>{zi(Q.current)?history.back():_("chat")},authUser:e})}),v&&P==="profile"&&he==="channel"&&as&&c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx(Vv,{teamId:as,onBack:()=>_("chat"),inline:!0,onSelectAgent:S=>{Mt("direct"),Xs(S),_("chat")}})}),!v&&zi(P)&&he==="direct"&&ge&&c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx(Nv,{agentId:ge,onBack:()=>_("chat"),inline:!0,headless:!0,activeTab:P,initialSection:ue,highlightMailboxId:ke,authUser:e})}),!v&&zi(P)&&he==="channel"&&as&&c.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:c.jsx(Vv,{teamId:as,onBack:()=>_("chat"),inline:!0,headless:!0,activeTab:P,onSelectAgent:S=>{Mt("direct"),Xs(S),_("chat")}})}),c.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col relative ${wa?"justify-center":""} ${P!=="chat"?"hidden":""}`,children:[On&&ls.length===0&&c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2.5",role:"status","aria-live":"polite",children:[c.jsx(_2,{className:"h-6 w-6 text-brand-400"}),c.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[c.jsx("span",{className:"text-xs text-fg-tertiary animate-pulse",children:i("page.loadingChat",{defaultValue:"Loading conversation…"})}),c.jsx("span",{className:"text-[11px] text-fg-muted max-w-[70%] truncate",children:hC})]})]}),J_&&c.jsx("div",{className:"absolute top-0 left-0 right-0 z-10 flex justify-center pointer-events-none pt-2",children:c.jsxs("span",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-surface-secondary/90 backdrop-blur-sm border border-border-default shadow",children:[c.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-brand-400",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),c.jsx("span",{className:"text-xs text-fg-tertiary",children:i("page.loadingEarlierMessages")})]})}),c.jsxs("div",{ref:Xr,"data-swipe-owner":!0,className:`${wa?"hidden":"flex-1"} overflow-y-auto scrollbar-thin ${v?"px-4 py-2":`p-5 ${I}`}`,onScroll:Ik,children:[ls.length>0&&c.jsx("div",{style:{height:ao.getTotalSize(),width:"100%",position:"relative"},children:ao.getVirtualItems().map(S=>{const T=S.index,j=ls[T],D=T>0?ls[T-1]:null,F=KO(j.rawCreatedAt),G=D?KO(D.rawCreatedAt):"",se=!!(F&&G&&F!==G),Ee=T===ls.length-1,Ze=RP({msgIsStreaming:!!j.isStreaming,liveStreamForView:ca,liveBubbleId:kk,msgId:j.id}),Se=iC&&Ee||Ze,Ce=he==="channel"||!Ze||j.isStopped;return c.jsx("div",{"data-index":T,ref:ao.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},children:c.jsxs("div",{className:"pb-3",children:[se&&c.jsxs("div",{className:"flex items-center gap-3 py-2 my-1",children:[c.jsx("div",{className:"flex-1 h-px bg-border-default"}),c.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:h2(j.rawCreatedAt,a)}),c.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),c.jsxs("div",{id:`msg-${j.id}`,className:`group/msg flex transition-colors rounded-lg ${v?"gap-0":"gap-3"}`,children:[he==="channel"?c.jsx("div",{className:`shrink-0 cursor-pointer ${v?"hidden":""}`,onClick:Ne=>{if(j.sender==="agent"&&j.agentId){const ct=Ne.currentTarget.getBoundingClientRect();Ct({agentId:j.agentId,top:ct.top,left:ct.right+8})}},children:c.jsx(Is,{name:j.sender==="user"?dc:j.agentName??i("page.fallbackAgent"),avatarUrl:j.sender==="user"?e?.avatarUrl:l.find(Ne=>Ne.id===j.agentId)?.avatarUrl,size:32,bgClass:j.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:j.sender==="agent"?"hover:ring-1 hover:ring-brand-500/40 rounded-lg":"rounded-lg"})}):c.jsx("div",{className:`shrink-0 ${v?"hidden":""}`,children:c.jsx(Is,{name:j.sender==="user"?dc:j.agentName??(he==="direct"?Nt?.name??i("page.fallbackAgent"):i("page.fallbackAgent")),avatarUrl:j.sender==="user"?e?.avatarUrl:l.find(Ne=>Ne.id===(j.agentId??(he==="direct"?Nt?.id:void 0)))?.avatarUrl,size:32,bgClass:j.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-lg"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-baseline gap-2",children:[v&&c.jsx(Is,{name:j.sender==="user"?dc:j.agentName??(he==="direct"?Nt?.name??i("page.fallbackAgent"):i("page.fallbackAgent")),avatarUrl:j.sender==="user"?e?.avatarUrl:l.find(Ne=>Ne.id===(j.agentId??(he==="direct"?Nt?.id:void 0)))?.avatarUrl,size:22,bgClass:j.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded self-center"}),c.jsx("span",{className:"text-sm font-medium text-fg-primary",children:j.sender==="user"?dc:he==="channel"?j.agentName??i("page.fallbackAgent"):c.jsx(d2,{name:j.agentName??(he==="direct"?Nt?.name??i("page.fallbackAgent"):i("page.fallbackAgent")),agentId:j.agentId??(he==="direct"?Nt?.id:void 0),agents:l,onViewProfile:Ot})}),c.jsx("span",{className:"text-xs text-fg-tertiary",title:j.rawCreatedAt?new Date(j.rawCreatedAt).toLocaleString():"",children:mc(j.time,j.rawCreatedAt,a)})]}),j.replyToId&&j.replyToSender&&c.jsxs("button",{onClick:()=>{const Ne=document.getElementById(`msg-${j.replyToId}`);Ne&&(Ne.scrollIntoView({behavior:"smooth",block:"center"}),Ne.classList.add("bg-brand-500/10"),setTimeout(()=>Ne.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mt-0.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[c.jsx("span",{className:"font-medium text-brand-500",children:j.replyToSender}),c.jsx("span",{className:"truncate max-w-[250px]",children:j.replyToText??"..."})]}),c.jsxs("div",{className:`mt-0.5 ${j.sender==="agent"?"py-1":"bg-surface-secondary rounded-2xl px-3.5 py-2.5 w-fit max-w-full"} ${Se&&j.sender==="agent"?"streaming-bubble":""}`,children:[Se&&j.sender==="agent"&&c.jsx("span",{className:"streaming-ring","aria-hidden":"true",children:c.jsx("span",{className:"streaming-ring-spin"})}),j.sender==="user"?c.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap msg-break-anywhere",children:[j.images&&j.images.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:j.images.map((Ne,ct)=>c.jsx("img",{src:Ne,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>kg(Ne)},ct))}),he==="channel"?JO(j.text,l,(Ne,ct)=>{const wt=ct.currentTarget.getBoundingClientRect();Ct({agentId:Ne.id,top:wt.bottom,left:wt.left})}):c.jsx(oP,{text:j.text,chips:j.sender==="user"?j.chips:void 0,className:"leading-relaxed",renderText:Ne=>JO(Ne,l,(ct,wt)=>{const es=wt.currentTarget.getBoundingClientRect();Ct({agentId:ct.id,top:es.bottom,left:es.left})})})]}):j.sender==="agent"&&he==="channel"&&!(j.segments&&j.segments.length>0)?Ze&&!j.text?.trim()?c.jsx(u2,{activities:hn,isActive:!0}):c.jsx(zO,{resetKeys:[j.text],fallback:c.jsx("div",{className:"whitespace-pre-wrap break-words msg-break-anywhere text-sm text-fg-secondary",children:j.text}),children:c.jsx(Hi,{content:j.text,className:"text-sm text-fg-secondary",onMentionClick:At,knownNames:js})}):c.jsx(zO,{resetKeys:[j.id,j.text,j.segments?.length,Ze],fallback:c.jsx("div",{className:"whitespace-pre-wrap break-words msg-break-anywhere text-sm text-fg-secondary",children:j.text}),children:c.jsx(f2,{msg:j,isStreaming:Ze,liveActivities:Ze?hn:[],onMentionClick:At,knownNames:js})}),j.isNotification&&c.jsx(m2,{priority:j.notifyPriority})]}),Ce&&!t&&c.jsx("div",{className:`transition-opacity ${j.isStopped||j.isError||j.emptyReply||v?"opacity-100":"opacity-0 group-hover/msg:opacity-100"}`,children:c.jsx(p2,{msg:j,onCopy:Xk,onRetry:zk,onResume:qk,onReply:Zk,onRemember:he==="direct"?su:void 0,showRemember:he==="direct",isCopied:Bk===j.id,isLastAgentMsg:j.id===Wk})})]})]})]})},j.id)})}),c.jsx("div",{ref:_k}),Rk&&P==="chat"&&c.jsx("div",{className:"sticky bottom-0 z-20 h-0 pointer-events-none",children:c.jsx("div",{className:"absolute inset-x-0 bottom-2 flex justify-center",children:c.jsxs("button",{onClick:()=>{ar(),lr("smooth")},className:"pointer-events-auto flex items-center gap-1.5 px-3.5 py-2 bg-surface-secondary/90 backdrop-blur-sm border border-border-default rounded-full shadow-lg hover:bg-surface-elevated transition-colors text-xs text-fg-secondary",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})}),Jg>0?i("page.newMessages",{count:Jg}):i("page.scrollToBottom")]})})})]}),He&&(()=>{const S=l.find(T=>T.id===He.agentId);return S?c.jsx(g2,{agent:S,anchorRect:{top:He.top,left:He.left},onClose:()=>Ct(null),onViewProfile:Ot}):null})(),wa&&(jO||du)&&c.jsx("div",{className:"text-center mb-4",children:c.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:jO||du})}),he==="direct"&&(Rg.length>0||ea.length>0||Lg.length>0)&&c.jsx("div",{className:`${v?"px-3":"px-5"} pb-1 shrink-0 ${wa?"":I}`,children:c.jsxs("div",{className:`${v?"":"max-w-3xl mx-auto"} flex flex-col gap-1.5`,children:[Rg.map(S=>c.jsxs("button",{onClick:()=>Xl(S),className:"w-full text-left px-3.5 py-2.5 rounded-xl border border-amber-500/40 bg-amber-500/10 hover:bg-amber-500/15 transition-colors flex items-center gap-3",children:[c.jsx("span",{className:"w-8 h-8 rounded-lg bg-amber-500/20 text-amber-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),c.jsx("path",{d:"M12 8v4"}),c.jsx("path",{d:"M12 16h.01"})]})}),c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"flex items-baseline gap-1.5 min-w-0",children:[c.jsx("span",{className:"flex-1 text-sm font-medium text-fg-primary truncate",children:S.title}),c.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 whitespace-nowrap",children:mc(S.requestedAt,S.requestedAt,a)})]}),c.jsx("span",{className:"block text-xs text-fg-tertiary truncate",children:i("page.userInputPrompt",{count:S.questions?.length??1,defaultValue:`${S.questions?.length??1} question(s) awaiting your response`})})]}),c.jsxs("span",{className:"text-xs font-medium text-amber-500 shrink-0 inline-flex items-center gap-1",children:[i("page.userInputRespond",{defaultValue:"Respond"}),c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M9 18l6-6-6-6"})})]})]},S.id)),ea.map(S=>c.jsxs("button",{onClick:()=>ta(S),className:"w-full text-left px-3.5 py-2.5 rounded-xl border border-amber-500/40 bg-amber-500/10 hover:bg-amber-500/15 transition-colors flex items-center gap-3",children:[c.jsx("span",{className:"w-8 h-8 rounded-lg bg-amber-500/20 text-amber-500 flex items-center justify-center shrink-0",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),c.jsx("path",{d:"M12 9v4"}),c.jsx("path",{d:"M12 17h.01"})]})}),c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"flex items-baseline gap-1.5 min-w-0",children:[c.jsx("span",{className:"flex-1 text-sm font-medium text-fg-primary truncate",children:S.title}),c.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 whitespace-nowrap",children:mc(S.requestedAt,S.requestedAt,a)})]}),c.jsx("span",{className:"block text-xs text-fg-tertiary truncate",children:i("page.toolApprovalPrompt",{defaultValue:"Tool execution awaiting your approval"})})]}),c.jsxs("span",{className:"text-xs font-medium text-amber-500 shrink-0 inline-flex items-center gap-1",children:[i("page.toolApprovalReview",{defaultValue:"Review"}),c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M9 18l6-6-6-6"})})]})]},S.id)),Lg.map(S=>{const T=S.priority==="high"||S.priority==="urgent";return c.jsxs("button",{onClick:()=>sa({items:[S],index:0}),className:`w-full text-left px-3.5 py-2.5 rounded-xl border transition-colors flex items-center gap-3 ${T?"border-amber-500/40 bg-amber-500/10 hover:bg-amber-500/15":"border-blue-500/40 bg-blue-500/10 hover:bg-blue-500/15"}`,children:[c.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${T?"bg-amber-500/20 text-amber-500":"bg-blue-500/20 text-blue-500"}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),c.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsxs("span",{className:"flex items-baseline gap-1.5 min-w-0",children:[c.jsx("span",{className:"flex-1 text-sm font-medium text-fg-primary truncate",children:XC(S,i)}),c.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 whitespace-nowrap",title:cp(S.createdAt,n.language),children:lp(S.createdAt,i)})]}),c.jsx("span",{className:"block text-xs text-fg-tertiary truncate",children:zC(S,i).replace(/\s+/g," ").trim()||i("page.notifyUserPrompt",{defaultValue:"Agent notification awaiting your attention"})})]}),c.jsxs("span",{className:`text-xs font-medium shrink-0 inline-flex items-center gap-1 ${T?"text-amber-500":"text-blue-500"}`,children:[i("page.notifyUserView",{defaultValue:"View"}),c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M9 18l6-6-6-6"})})]})]},S.id)})]})}),vn&&c.jsx(U2,{approval:vn,submitting:ok===vn.id,readOnly:vn.status!=="pending",onClose:()=>Xl(null),onSubmit:S=>nC(vn.id,S)}),yn&&c.jsx(H2,{approval:yn,submitting:ak===yn.id,readOnly:yn.status!=="pending",onClose:()=>ta(null),onDecision:(S,T)=>oC(yn.id,S,T)}),Mi&&c.jsx(Y2,{notification:Mi,agentName:Nt?.name,acknowledging:lk===Mi.id,index:$r?.index??0,total:$r?.items.length??1,onClose:lu,onAcknowledge:()=>aC(Mi.id)}),Di&&c.jsx(qo,{variant:"primary",title:i("page.retry",{defaultValue:"Retry"}),message:Di.followCount===1?i("page.retryConfirmSingular"):i("page.retryConfirmPlural",{count:Di.followCount}),confirmLabel:i("common:confirm"),onConfirm:()=>{const S=Di;ru(null),iu(S.retryMsg,S.userMsg,S.retryText)},onCancel:()=>ru(null)}),vr&&c.jsx(O2,{busy:fO,onConfirm:S=>{Vk(S)},onCancel:()=>{fO||su(null)}}),c.jsxs("div",{"data-keep-edit-focus":!0,className:`${v?"px-3 py-2":"px-5 py-3"} relative shrink-0 ${wa?"":I}`,onDrop:sC,onDragOver:rC,children:[c.jsxs("div",{className:`bg-surface-primary border border-border-default shadow-lg shadow-black/10 ${v?`${yr?"rounded-2xl p-2":"rounded-2xl p-3"}`:`${yr?"rounded-2xl p-2":"rounded-2xl p-3"} max-w-3xl mx-auto`}`,children:[Jn&&jn.length>0&&c.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-64 max-w-xs w-72 overflow-y-auto",children:[c.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("page.mentionAgent")}),jn.map((S,T)=>S.kind==="agent"?c.jsxs("button",{ref:j=>{T===oa&&j&&j.scrollIntoView({block:"nearest"})},onClick:()=>hc(S.agent.name),onMouseEnter:()=>eo(T),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${T===oa?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[c.jsx(Is,{name:S.agent.name,avatarUrl:S.agent.avatarUrl,size:24,bgClass:"bg-brand-500/20 text-brand-500"}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-overlay text-fg-tertiary shrink-0",children:i("page.mentionType.agent")}),c.jsx("span",{className:"flex-1 min-w-0 truncate",children:S.agent.name}),c.jsx("span",{className:"text-xs text-fg-tertiary ml-auto shrink-0",children:S.agent.role})]},`agt-${S.agent.id}`):c.jsxs("button",{ref:j=>{T===oa&&j&&j.scrollIntoView({block:"nearest"})},onClick:()=>hc(S.entity.name,S.entity.entityType,S.entity.id),onMouseEnter:()=>eo(T),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${T===oa?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[c.jsx("span",{className:"w-6 h-6 flex items-center justify-center text-sm shrink-0",children:qC[S.entity.entityType]??"📄"}),c.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-overlay text-fg-tertiary shrink-0",children:i(`page.mentionType.${S.entity.entityType}`,{defaultValue:S.entity.entityType})}),c.jsx("span",{className:"flex-1 min-w-0 truncate",children:S.entity.name}),c.jsx("span",{className:"text-xs text-fg-tertiary ml-auto shrink-0",children:S.entity.role})]},`${S.entity.entityType}-${S.entity.id}`))]}),to&&Sn.length>0&&c.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-64 max-w-xs w-72 overflow-y-auto",children:[c.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("page.slashSkill")}),Sn.map((S,T)=>c.jsxs("button",{ref:j=>{T===Dd&&j&&j.scrollIntoView({block:"nearest"})},onClick:()=>vO(S),onMouseEnter:()=>aa(T),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${T===Dd?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[c.jsx("span",{className:"text-xs w-5 h-5 flex items-center justify-center shrink-0",children:"🔧"}),c.jsxs("span",{className:"flex-1 min-w-0 truncate font-mono text-[13px]",children:["/",S.name]}),c.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto shrink-0 max-w-[100px] truncate",children:S.description})]},S.name))]}),br.length>0&&c.jsx("div",{className:"flex items-center gap-1.5 mb-2 flex-wrap","data-chip-strip":!0,children:br.map(S=>c.jsx(dy,{kind:S.kind,label:S.label,title:S.content,removeLabel:i("common:remove",{defaultValue:"Remove"}),onRemove:()=>{const T=Xf({text:os,chips:br},S.id);ir(T.draft.text),pn(T.draft.chips)}},S.id))}),nr.length>0&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[nr.map(S=>c.jsxs("div",{className:"relative group/img shrink-0",children:[nu(S)?c.jsx("img",{src:S.dataUrl,alt:S.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):c.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:S.name,children:[c.jsx("span",{className:"text-xl leading-none",children:Jk(S.name,S.dataUrl)}),c.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:S.name.split(".").pop()?.toUpperCase()})]}),c.jsx("button",{onClick:()=>eC(S.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},S.id)),nr.length<yO&&c.jsx("button",{onClick:()=>vd.current?.click(),className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:i("page.addMoreFiles"),children:c.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),nr.length>0&&nr.some(S=>nu(S))&&Nt&&Nt.modelSupportsVision===!1&&c.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[c.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),i("page.visionWarning")]}),c.jsx("input",{ref:vd,type:"file",accept:"image/*,.pdf,.docx,.xlsx,.pptx,.xls,.doc,.csv,.json,.xml,.html,.epub",multiple:!0,className:"hidden",onChange:S=>{S.target.files&&va(S.target.files),S.target.value=""}}),mn&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[c.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[c.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:mn.sender}),c.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:mn.text})]}),c.jsx("button",{onClick:()=>El(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),c.jsxs("div",{className:uu?"flex flex-col gap-2 min-w-0":"flex gap-2 items-end min-w-0",children:[c.jsxs("div",{className:uu?"flex gap-2 items-end min-w-0":"contents",children:[c.jsx("button",{onClick:()=>vd.current?.click(),disabled:he==="direct"&&(!ge||Sa),className:`${yr?"p-1.5":"px-2.5 py-2.5"} text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated shrink-0 self-end mb-0.5`,title:i("page.attachFilesTitle"),children:c.jsx("svg",{className:yr?"w-[18px] h-[18px]":"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:c.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),c.jsx("textarea",{ref:Ss,value:os,onChange:S=>{Yk(S.target.value),Go()},onKeyDown:S=>{const T=S.nativeEvent;if(!(T.isComposing===!0||T.keyCode===229)){if(Jn&&jn.length>0){const j=S.key==="ArrowUp"||S.ctrlKey&&S.key==="p",D=S.key==="ArrowDown"||S.ctrlKey&&S.key==="n",F=S.key==="Enter"||S.key==="Tab",G=S.key==="Escape";if(j){S.preventDefault(),eo(se=>(se-1+jn.length)%jn.length);return}if(D){S.preventDefault(),eo(se=>(se+1)%jn.length);return}if(F){S.preventDefault();const se=jn[oa];se&&(se.kind==="agent"?hc(se.agent.name):hc(se.entity.name,se.entity.entityType,se.entity.id));return}if(G){S.preventDefault(),na(!1);return}}if(to&&Sn.length>0){const j=S.key==="ArrowUp"||S.ctrlKey&&S.key==="p",D=S.key==="ArrowDown"||S.ctrlKey&&S.key==="n",F=S.key==="Enter"||S.key==="Tab",G=S.key==="Escape";if(j){S.preventDefault(),aa(se=>(se-1+Sn.length)%Sn.length);return}if(D){S.preventDefault(),aa(se=>(se+1)%Sn.length);return}if(F){S.preventDefault();const se=Sn[Dd];se&&vO(se);return}if(G){S.preventDefault(),Fl(!1);return}}if(S.key==="Escape"){S.preventDefault(),S.currentTarget.blur();return}if((S.key==="Backspace"||S.key==="Delete")&&br.length>0){const j=Ss.current;if(j&&j.selectionStart===j.selectionEnd){const D=j.selectionStart??0,F=br.find(G=>S.key==="Backspace"?D>G.start&&D<=G.end:D>=G.start&&D<G.end);if(F){S.preventDefault();const G=Xf({text:os,chips:br},F.id);ir(G.draft.text),pn(G.draft.chips),requestAnimationFrame(()=>{const se=Ss.current;se&&se.setSelectionRange(G.caret,G.caret)});return}}}S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),oO())}},onPaste:tC,placeholder:du,disabled:he==="direct"&&(!ge||Sa),rows:yr?1:2,className:`flex-1 min-w-0 w-full bg-transparent rounded-xl text-sm outline-none disabled:opacity-40 transition-colors resize-none overflow-y-auto leading-relaxed placeholder:text-fg-secondary ${yr?"px-2 py-1.5":"px-4 py-3"}`,style:{minHeight:yr?"36px":"52px",maxHeight:`${e0(yr)}px`}})]}),c.jsxs("div",{className:`flex items-center gap-1.5 shrink-0 ${x2(uu)}`,children:[he==="direct"&&c.jsx(w3,{value:tk,agentId:ge,disabled:!ge||Sa,onSelect:(S,T)=>{if(T==="agent"){Ri(S),Hv(S,T,ge).catch(()=>{});return}Ri(null),Hv(S,T,ge).catch(()=>{})}}),(he==="direct"?hs&&ca:hs)&&he!=="dm"?c.jsx("button",{onClick:Lk,className:`${yr?"w-8 h-8 rounded-full flex items-center justify-center":"px-3 py-2.5 rounded-xl"} bg-red-600 hover:bg-red-500 text-white text-sm transition-colors`,title:i("page.stopAgent"),children:c.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}):c.jsx("button",{onClick:()=>oO(),disabled:he==="direct"&&(!ge||Sa)||!os.trim()&&nr.length===0,className:yr?"w-8 h-8 rounded-full flex items-center justify-center bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand transition-colors":"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-on-brand text-sm rounded-xl transition-colors",title:i("common:send"),children:yr?c.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:c.jsx("path",{d:"M12 19V5M5 12l7-7 7 7",strokeLinecap:"round",strokeLinejoin:"round"})}):i("common:send")})]})]})]}),(os.trim()||nr.length>0)&&c.jsx("div",{className:"mt-0.5 flex justify-end px-1 pointer-events-none select-none",children:c.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})})]})]})]}),!v&&Z&&q&&c.jsx(vI,{payload:Z,onClose:q,width:$?U:Ie,onResizeStart:gt,onAddToChat:S=>{let T=0;const j=P2(S,()=>`ctx_${Date.now()}_${++T}`);j&&_e(j)},tabs:B,activeTabId:K,onSelectTab:W?.setActiveRightPanelTab,onCloseTab:W?.closeRightPanelTab,onNewTab:()=>{if(!ie)return;if(W?.rightPanelMode==="terminal"){const T=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ie({kind:"terminal",terminalId:T,title:"Terminal"});return}const S=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ie({kind:"url",url:"about:blank",title:"New Tab",browserId:S})},fullscreen:$,onToggleFullscreen:W?.toggleRightPanelFullscreen,onBrowserMeta:W?.updateRightPanelBrowserTab?(S,T)=>W.updateRightPanelBrowserTab(S,T):void 0,panelMode:W?.rightPanelMode??"browser",onPanelModeChange:S=>W?.switchRightPanelMode(S),onTerminalMeta:W?.updateRightPanelTerminalTab?(S,T)=>W.updateRightPanelTerminalTab(S,T):void 0,onOpenUrlFromTerminal:S=>{if(!ie)return;const T=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ie({kind:"url",url:S,title:S,browserId:T})},onOpenPathFromTerminal:S=>{ie?.({kind:"file",path:S,title:S.split(/[/\\]/).pop()||S})}}),_g&&c.jsx(ZC,{src:_g,onClose:()=>kg(null)})]})}function C3({agent:s}){const{t:e}=Tt(["common"]),t=iy(s.id),r=yl(s.status,t),i=r.labelKey?e(`common:${r.labelKey}`):"";return c.jsx("span",{className:`shrink-0 w-2 h-2 rounded-full ${r.dotClass} ${r.tone==="busy"?"animate-pulse":""}`,title:i,"aria-label":i})}function P3({agent:s,tasks:e,onViewProfile:t}){const{t:r}=Tt(["team","common"]),[i,n]=w.useState(!1),a=w.useRef(null),o=w.useRef(null),l=iy(s.id),h=yl(s.status,l),u=h.tone==="busy",d=h.tone==="danger",f=!h.running,p=u?e.find(g=>g.assignedAgentId===s.id&&g.status==="in_progress"):null,v=s.currentActivity;w.useEffect(()=>{d&&s.lastError&&Vc(s.lastError)&&Fc()},[d,s.lastError]),w.useEffect(()=>{if(!i)return;const g=m=>{a.current&&!a.current.contains(m.target)&&n(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[i]),w.useLayoutEffect(()=>{if(!i||!o.current)return;const g=o.current,m=g.getBoundingClientRect(),x=window.innerWidth;m.right>x-8&&(g.style.left="auto",g.style.right="0"),m.left<8&&(g.style.left="0",g.style.right="auto");const y=x-16;m.width>y&&(g.style.width=`${y}px`)},[i]);const b=h.labelKey?r(h.labelKey):s.status||"—",O=v?v.type==="heartbeat"?r("page.activityHeartbeat",{name:v.heartbeatName??v.label}):v.type==="chat"?v.label:v.type==="task"?r("page.activityTask",{label:v.label}):v.label:r("page.processing");return c.jsxs("div",{className:"relative",ref:a,children:[c.jsxs("button",{onClick:()=>n(g=>!g),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors hover:opacity-80 ${h.chipClass}`,children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${h.dotClass}`}),c.jsx("span",{className:`text-xs ${h.textClass}`,children:b}),s.mailboxDepth!=null&&s.mailboxDepth>0&&c.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:s.mailboxDepth})]}),i&&d&&c.jsxs("div",{ref:o,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-red-500/30 rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[c.jsx("p",{className:"text-[10px] text-red-500 uppercase font-semibold",children:r("page.errorDetails")}),c.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-2.5",children:[c.jsx("pre",{className:"text-[10px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono line-clamp-6",children:c.jsx(ny,{text:fh(s.lastError,r)||s.lastError||r("page.agentErrorFallback")})}),s.lastErrorAt&&c.jsx("div",{className:"text-[9px] text-red-500/50 mt-1.5 border-t border-red-500/10 pt-1",children:new Date(s.lastErrorAt).toLocaleString()})]}),c.jsx("button",{onClick:()=>{n(!1),t?.(s.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:r("page.viewAgentProfileArrow")})]}),i&&f&&c.jsxs("div",{ref:o,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[c.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:r("page.agentNotRunningTitle")}),c.jsx("p",{className:"text-[11px] text-fg-secondary",children:r("page.agentNotRunningHint")}),c.jsx("button",{onClick:()=>{n(!1),t?.(s.id,{tab:"overview"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:r("page.viewAgentProfileArrow")})]}),i&&!u&&!d&&!f&&c.jsxs("div",{ref:o,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[c.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:r("page.agentIdleTitle")}),c.jsx("p",{className:"text-[11px] text-fg-secondary",children:r("page.agentIdleHint")}),c.jsx("button",{onClick:()=>{n(!1),t?.(s.id,{tab:"overview"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:r("page.viewAgentProfileArrow")})]}),i&&u&&c.jsxs("div",{ref:o,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[c.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:r("page.currentActivity")}),p?c.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-brand-500/10 border border-brand-500/30 cursor-pointer hover:bg-brand-500/10 transition-colors",onClick:()=>{n(!1),gr.navigate(Ut.WORK,{openTask:p.id})},children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-xs text-brand-500 truncate",children:p.title}),c.jsx("div",{className:"text-[10px] text-fg-tertiary",children:r("page.workingOnTaskHint")})]}),c.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"→"})]}):c.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-surface-elevated/50",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${v?.type==="heartbeat"||v?.type==="chat","bg-blue-400 animate-pulse"}`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-xs text-fg-secondary",children:O}),c.jsx("div",{className:"text-[10px] text-fg-tertiary",children:v?.type==="heartbeat"?r("page.activityDescHeartbeat"):v?.type==="chat"?r("page.activityDescChat"):r("page.activityDescFallback")})]})]}),c.jsx("button",{onClick:()=>{n(!1),t?.(s.id,{tab:"overview"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1.5 transition-colors",children:r("page.viewMindArrow")})]})]})}export{V3 as TeamPage};