@cuongtran001/kanna 1.110.2 → 1.112.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 (129) hide show
  1. package/dist/client/assets/{BoardsPage-oPyAf75q.js → BoardsPage-BS-X9aov.js} +1 -1
  2. package/dist/client/assets/{BoardsRoutePage-DYOaDXCi.js → BoardsRoutePage-DH_FSa9D.js} +1 -1
  3. package/dist/client/assets/ChatPage-DXxHoPc9.js +35 -0
  4. package/dist/client/assets/{CronJobsPage-C13JbFQW.js → CronJobsPage-C4VwunK5.js} +1 -1
  5. package/dist/client/assets/{FilePreviewSheet-C9jJcK9W.js → FilePreviewSheet-CG0HpRDD.js} +1 -1
  6. package/dist/client/assets/{FlowSurface-DSIHmjRi.js → FlowSurface-DykSXuEq.js} +1 -1
  7. package/dist/client/assets/{GenUIBlock-B964gzI8.js → GenUIBlock-DH3JfQv6.js} +2 -2
  8. package/dist/client/assets/{InboundHandlerFields-BN9tyTe5.js → InboundHandlerFields-1HglWhvK.js} +1 -1
  9. package/dist/client/assets/{InboxPage-CpvuzPUA.js → InboxPage-D0x0vrxJ.js} +1 -1
  10. package/dist/client/assets/{LocalProjectsPage-3IfGjawb.js → LocalProjectsPage-ByzldcFY.js} +1 -1
  11. package/dist/client/assets/{PluginPage-CQ5d0bSg.js → PluginPage-3M8_92nv.js} +1 -1
  12. package/dist/client/assets/SettingsPage-D1pWNjOV.js +19 -0
  13. package/dist/client/assets/{StackBoardsRoutePage-CExvIhlR.js → StackBoardsRoutePage-BB4N2PvL.js} +1 -1
  14. package/dist/client/assets/ToolCallMessage-BUYUQ7gJ.js +4 -0
  15. package/dist/client/assets/{VChartSurface-D0O2TFGP.js → VChartSurface-CIvQZGUJ.js} +1 -1
  16. package/dist/client/assets/{WebhooksPage-QMkP3Kfp.js → WebhooksPage-skxsqDwx.js} +1 -1
  17. package/dist/client/assets/{WorkflowsPage-KkO5zHKX.js → WorkflowsPage-CiMSQgt6.js} +1 -1
  18. package/dist/client/assets/{beacon-alias-VNcGE6qS.js → beacon-alias-DOK96oF3.js} +3 -3
  19. package/dist/client/assets/contextWindow-DzdFsmAN.js +1 -0
  20. package/dist/client/assets/{copyFeedbackStore--0eXUA37.js → copyFeedbackStore-C99Dk7dd.js} +1 -1
  21. package/dist/client/assets/core-types-BWpRMPSe.js +1 -0
  22. package/dist/client/assets/{errors-BFSDFmzD.js → errors-gzkyHtvT.js} +1 -1
  23. package/dist/client/assets/inboxAutonomy-BbSS39ZI.js +1 -0
  24. package/dist/client/assets/index-C7sUnaMy.js +85 -0
  25. package/dist/client/assets/{keybindings-C9wyRakr.js → keybindings-CcJR7jqv.js} +1 -1
  26. package/dist/client/assets/{pendingActionsStore-BP3IRM15.js → pendingActionsStore-Bg8DPvPu.js} +1 -1
  27. package/dist/client/assets/runDetached-BriqYoL_.js +1 -0
  28. package/dist/client/assets/{searchable-select-Coiyd_lo.js → searchable-select-BfJAIk39.js} +1 -1
  29. package/dist/client/assets/{select-DF4DOYDC.js → select-BmtMqoF4.js} +1 -1
  30. package/dist/client/assets/{settings-header-button-B_fNtvLt.js → settings-header-button-AstqocLX.js} +1 -1
  31. package/dist/client/assets/{textarea-jOws6A3N.js → textarea-CS61Vz3t.js} +1 -1
  32. package/dist/client/assets/{timer.adapter-DcMx69zO.js → timer.adapter-B8nasB3D.js} +1 -1
  33. package/dist/client/assets/{tool-call-types-DbO8xec2.js → tool-call-types-CoEzmgyY.js} +1 -1
  34. package/dist/client/assets/{tools-Bre-udFS.js → tools-CryRpKwA.js} +1 -1
  35. package/dist/client/assets/types-tbL38EdO.js +1 -0
  36. package/dist/client/assets/useAppGlobalState-C6kvhjRE.js +1 -0
  37. package/dist/client/assets/{useProviderCatalog-DF_umnvd.js → useProviderCatalog-Dkwrdqi0.js} +2 -2
  38. package/dist/client/assets/{useTheme-C0zkvazY.js → useTheme-Cb3XmN93.js} +1 -1
  39. package/dist/client/index.html +19 -19
  40. package/package.json +1 -1
  41. package/src/server/__fixtures__/plugins/packages/client-pkg/index.js +5 -0
  42. package/src/server/__fixtures__/plugins/packages/client-pkg/package.json +1 -0
  43. package/src/server/__fixtures__/plugins/packages/server-pkg/index.js +9 -0
  44. package/src/server/__fixtures__/plugins/packages/server-pkg/package.json +1 -0
  45. package/src/server/__fixtures__/plugins/with-deps/bun.lock +18 -0
  46. package/src/server/__fixtures__/plugins/with-deps/compress.server.ts +8 -0
  47. package/src/server/__fixtures__/plugins/with-deps/compress.shared.ts +8 -0
  48. package/src/server/__fixtures__/plugins/with-deps/fixture-packages.d.ts +11 -0
  49. package/src/server/__fixtures__/plugins/with-deps/index.ts +10 -0
  50. package/src/server/__fixtures__/plugins/with-deps/kanna-plugin.json +1 -0
  51. package/src/server/__fixtures__/plugins/with-deps/package.json +8 -0
  52. package/src/server/agent-coordinator-types.ts +2 -0
  53. package/src/server/agent-coordinator.ts +16 -26
  54. package/src/server/agent-tools-bridge.test.ts +85 -0
  55. package/src/server/agent-tools-bridge.ts +144 -0
  56. package/src/server/agent.test.ts +49 -34
  57. package/src/server/antigravity-acp-protocol.ts +230 -0
  58. package/src/server/antigravity-acp-translator.ts +260 -0
  59. package/src/server/antigravity-acp.test.ts +367 -0
  60. package/src/server/antigravity-acp.ts +516 -0
  61. package/src/server/antigravity-spawn.adapter.ts +24 -0
  62. package/src/server/app-settings.test.ts +1 -0
  63. package/src/server/app-settings.ts +15 -21
  64. package/src/server/claude-context-commands.test.ts +6 -1
  65. package/src/server/claude-context-commands.ts +2 -0
  66. package/src/server/claude-send-command.test.ts +20 -1
  67. package/src/server/claude-send-command.ts +13 -2
  68. package/src/server/claude-session-runner.ts +39 -10
  69. package/src/server/claude-session-state.ts +1 -0
  70. package/src/server/claude-subagent-wiring.test.ts +3 -1
  71. package/src/server/claude-subagent-wiring.ts +3 -0
  72. package/src/server/claude-tool-respond.test.ts +12 -0
  73. package/src/server/claude-tool-respond.ts +2 -1
  74. package/src/server/claude-turn-failure.test.ts +19 -6
  75. package/src/server/claude-turn-failure.ts +27 -12
  76. package/src/server/claude-turn-starter-types.ts +2 -0
  77. package/src/server/claude-turn-starter.test.ts +27 -0
  78. package/src/server/claude-turn-starter.ts +46 -0
  79. package/src/server/codex-app-server.ts +3 -15
  80. package/src/server/codex-spawn.adapter.ts +3 -2
  81. package/src/server/http-dispatcher.ts +6 -1
  82. package/src/server/kanna-mcp-peer.ts +2 -2
  83. package/src/server/kanna-mcp-plugins.ts +8 -3
  84. package/src/server/peer-messaging/create-peer-messaging.ts +13 -1
  85. package/src/server/peer-messaging/peer-messenger.test.ts +21 -2
  86. package/src/server/peer-messaging/peer-messenger.ts +37 -10
  87. package/src/server/peer-messaging/peer-tools.ts +10 -5
  88. package/src/server/plugin-system-acceptance.test.tsx +76 -9
  89. package/src/server/plugins/plugin-build.adapter.ts +81 -17
  90. package/src/server/provider-catalog.test.ts +8 -0
  91. package/src/server/provider-catalog.ts +17 -0
  92. package/src/server/scheduled-work-rehydrate.ts +42 -0
  93. package/src/server/server.test.ts +2 -0
  94. package/src/server/server.ts +7 -34
  95. package/src/server/stdio-process.ts +13 -0
  96. package/src/server/subagent-orchestrator.test.ts +2 -0
  97. package/src/server/subagent-provider-run.test.ts +28 -0
  98. package/src/server/subagent-provider-run.ts +44 -1
  99. package/src/server/test-helpers/fake-acp-process.ts +113 -0
  100. package/src/server/turn-end-guards.ts +38 -0
  101. package/src/server/ws-router-defaults.ts +6 -1
  102. package/src/server/ws-router.test.ts +1 -0
  103. package/src/shared/app-settings-types.schema.ts +2 -0
  104. package/src/shared/app-settings-types.ts +2 -0
  105. package/src/shared/core-types.ts +1 -1
  106. package/src/shared/inbox/autonomy.test.ts +10 -0
  107. package/src/shared/inbox/autonomy.ts +2 -1
  108. package/src/shared/peer-messaging/limits.ts +2 -0
  109. package/src/shared/peer-messaging/tool-specs.schema.ts +21 -4
  110. package/src/shared/provider-model-types.schema.ts +13 -0
  111. package/src/shared/provider-model-types.ts +38 -0
  112. package/src/shared/settings/merge-settings-sections.ts +5 -0
  113. package/src/shared/settings/provider-defaults.test.ts +13 -0
  114. package/src/shared/settings/provider-defaults.ts +48 -1
  115. package/src/shared/subagent-types.schema.ts +10 -3
  116. package/src/shared/subagent-types.ts +4 -4
  117. package/src/shared/turn-model-selection.ts +5 -0
  118. package/dist/client/assets/ChatPage-Bi2DpYr6.js +0 -35
  119. package/dist/client/assets/SettingsPage-cmTy1iED.js +0 -19
  120. package/dist/client/assets/ToolCallMessage-q3fyT9N9.js +0 -4
  121. package/dist/client/assets/contextWindow-oZVu-dHr.js +0 -1
  122. package/dist/client/assets/core-types-Ds7PFmZN.js +0 -1
  123. package/dist/client/assets/inboxAutonomy-tnljjzDS.js +0 -1
  124. package/dist/client/assets/index-BN_FkYqi.js +0 -85
  125. package/dist/client/assets/runDetached-BwsENNPw.js +0 -1
  126. package/dist/client/assets/types-B0ERlQHU.js +0 -1
  127. package/dist/client/assets/useAppGlobalState-nV_BOKmq.js +0 -1
  128. package/src/server/__fixtures__/plugins/.tmp-unlisted/index.ts +0 -2
  129. package/src/server/__fixtures__/plugins/.tmp-unlisted/kanna-plugin.json +0 -1
@@ -0,0 +1,35 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-B_ssCuNh.js","assets/rolldown-runtime-BCiCTKAo.js","assets/react-BWPDF9mI.js","assets/jsx-runtime-BB9-612F.js","assets/preload-helper-BLdHbfdN.js","assets/lib-BlOM_ItO.js","assets/LocalProjectsPage-ByzldcFY.js","assets/chunk-6KYCQHYJ-C0N1h4Su.js","assets/utils-gw0dpHSZ.js","assets/copyFeedbackStore-C99Dk7dd.js","assets/pendingActionsStore-Bg8DPvPu.js","assets/log-8K5PdGJC.js","assets/errors-gzkyHtvT.js","assets/timer.adapter-B8nasB3D.js","assets/focusOverlay-BNpERJzs.js","assets/react-dom-2r3XOwTS.js","assets/code-xml-BjFagt-D.js","assets/monitor-B1cxkbAV.js","assets/plus-k8ypzgh4.js","assets/terminal-D7v6A2Rn.js","assets/segmented-control-CthWIFFX.js","assets/dist-DQaZwNEz.js","assets/input-Bkp2JE9C.js","assets/pathUtils-BU6_uBbH.js","assets/dom.adapter-C26vNdMA.js","assets/runDetached-BriqYoL_.js","assets/index-C7sUnaMy.js","assets/useAppGlobalState-C6kvhjRE.js","assets/beacon-alias-DOK96oF3.js","assets/createScopedStore-BZ7oYp5V.js","assets/useTheme-Cb3XmN93.js","assets/core-types-BWpRMPSe.js","assets/tool-call-types-CoEzmgyY.js","assets/contextWindow-DzdFsmAN.js","assets/useProviderCatalog-Dkwrdqi0.js","assets/types-tbL38EdO.js","assets/sidebar-data-BV2p2vi6.js","assets/state-mark-p6veyUZZ.js","assets/storage.adapter-DafyA8In.js","assets/textarea-CS61Vz3t.js","assets/cronJobsStore-CkFW3wrj.js","assets/keybindings-CcJR7jqv.js","assets/ToolCallMessage-BUYUQ7gJ.js","assets/FilePreviewSheet-CG0HpRDD.js","assets/minus-C2PhdGp1.js","assets/refresh-cw-BnSFXoQI.js","assets/triangle-alert-BlEPrBcS.js","assets/file-plus-corner-BfUy6cfa.js","assets/pencil-BnnPP0sI.js","assets/search-DaMiMFjO.js","assets/formatDuration-BbWTR_M_.js","assets/tools-CryRpKwA.js","assets/index-B0_Z9Tv4.css","assets/BoardsRoutePage-DH_FSa9D.js","assets/BoardsPage-BS-X9aov.js","assets/StackBoardsRoutePage-BB4N2PvL.js","assets/SettingsPage-D1pWNjOV.js","assets/select-BmtMqoF4.js","assets/info-DRKK3Ev3.js","assets/searchable-select-BfJAIk39.js","assets/inboxAutonomy-BbSS39ZI.js","assets/settings-header-button-AstqocLX.js","assets/InboundHandlerFields-1HglWhvK.js","assets/WorkflowsPage-CiMSQgt6.js","assets/arrow-left-Bhl_I1HL.js","assets/WebhooksPage-skxsqDwx.js","assets/InboxPage-D0x0vrxJ.js","assets/CronJobsPage-C4VwunK5.js","assets/PluginPage-3M8_92nv.js","assets/browser-DUvIcXp1.js"])))=>i.map(i=>d[i]);
2
+ import{o as e,t}from"./rolldown-runtime-BCiCTKAo.js";import{t as n}from"./react-BWPDF9mI.js";import{t as r}from"./react-dom-2r3XOwTS.js";import{c as i,d as a,l as o,u as s}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as c}from"./jsx-runtime-BB9-612F.js";import{B as l,C as u,Ct as d,D as f,E as p,F as m,I as h,K as g,L as _,M as v,N as y,O as b,P as x,R as S,S as C,St as w,U as T,V as E,W as D,Y as O,_t as k,b as A,bt as j,gt as M,j as N,p as P,t as F,v as I,vt as ee,w as L,wt as R,x as te,xt as ne,y as re,yt as ie,z as ae}from"./useAppGlobalState-C6kvhjRE.js";import{i as z,t as B}from"./utils-gw0dpHSZ.js";import{S as oe,_ as se,a as ce,b as le,c as ue,d as de,g as fe,i as pe,l as me,m as he,n as ge,r as _e,s as ve,v as ye,x as be,y as xe}from"./ToolCallMessage-BUYUQ7gJ.js";import{A as Se,B as Ce,C as we,D as Te,E as Ee,G as De,H as Oe,I as ke,J as Ae,K as je,L as Me,M as Ne,N as Pe,O as Fe,P as Ie,Q as Le,S as Re,St as ze,T as Be,Tt as Ve,U as He,W as Ue,X as We,Y as Ge,Z as Ke,_t as qe,at as Je,bt as Ye,ct as Xe,dt as Ze,et as Qe,ft as $e,gt as et,ht as tt,i as nt,it as rt,j as it,k as at,l as ot,lt as st,m as ct,nt as lt,o as V,ot as ut,pt as dt,q as ft,r as pt,rt as mt,st as ht,tt as gt,ut as _t,w as vt,x as yt,xt as bt,yt as xt,z as St}from"./beacon-alias-DOK96oF3.js";import{a as Ct,i as wt,n as H,o as Tt,t as Et}from"./copyFeedbackStore-C99Dk7dd.js";import{a as Dt,c as Ot,i as kt,l as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./select-BmtMqoF4.js";import{C as It,E as Lt,I as Rt,M as zt,O as Bt,U as Vt,V as Ht,_ as Ut,a as Wt,c as Gt,d as Kt,f as qt,h as Jt,l as Yt,n as Xt,o as Zt,r as Qt,s as $t,t as en,u as tn,v as nn,w as rn,x as an}from"./FilePreviewSheet-CG0HpRDD.js";import{a as on,i as sn,l as cn,n as ln,o as un,r as dn,s as fn,t as pn,u as mn}from"./contextWindow-DzdFsmAN.js";import{d as hn,f as gn,i as _n,l as U,n as vn,o as yn,r as bn,t as W}from"./pendingActionsStore-Bg8DPvPu.js";import{t as xn}from"./minus-C2PhdGp1.js";import{t as Sn}from"./pencil-BnnPP0sI.js";import{t as Cn}from"./plus-k8ypzgh4.js";import{t as wn}from"./refresh-cw-BnSFXoQI.js";import{t as Tn}from"./search-DaMiMFjO.js";import{t as En}from"./terminal-D7v6A2Rn.js";import{S as Dn,x as On}from"./useProviderCatalog-Dkwrdqi0.js";import{t as kn}from"./triangle-alert-BlEPrBcS.js";import{a as An,c as jn,g as Mn,i as Nn,n as Pn,o as Fn,r as In,t as Ln,u as Rn}from"./timer.adapter-B8nasB3D.js";import{a as zn,c as Bn,i as Vn,l as Hn,n as Un,o as Wn,r as Gn,t as Kn,u as qn}from"./segmented-control-CthWIFFX.js";import{n as Jn,t as Yn}from"./log-8K5PdGJC.js";import{n as Xn,r as Zn,t as Qn}from"./createScopedStore-BZ7oYp5V.js";import{t as $n}from"./input-Bkp2JE9C.js";import{t as er}from"./preload-helper-BLdHbfdN.js";import{c as tr,r as nr,t as rr}from"./errors-gzkyHtvT.js";import{d as ir,f as ar,r as or}from"./core-types-BWpRMPSe.js";import{L as sr,R as cr,_ as lr,at as ur,c as dr,f as fr,h as pr,i as mr,l as hr,nt as gr,o as _r,ot as vr,ut as yr,v as br}from"./tool-call-types-CoEzmgyY.js";import{iu as xr,k as Sr,nu as Cr,r as wr,ru as Tr}from"./useTheme-Cb3XmN93.js";import{a as Er,d as Dr,l as Or,n as kr,o as Ar,u as jr}from"./pathUtils-BU6_uBbH.js";import{n as Mr,t as Nr}from"./sidebar-data-BV2p2vi6.js";import{S as Pr,b as Fr,d as Ir,f as Lr,h as Rr,n as zr,p as Br,r as Vr,t as Hr,v as Ur,w as Wr,x as Gr,y as Kr}from"./state-mark-p6veyUZZ.js";import{t as qr}from"./storage.adapter-DafyA8In.js";import{d as Jr,g as Yr,l as Xr,n as Zr,o as Qr,p as $r,r as ei,t as ti,u as ni}from"./textarea-CS61Vz3t.js";import{t as ri}from"./runDetached-BriqYoL_.js";import{E as ii,N as ai,_ as oi,i as si,j as ci,o as li,r as ui,w as di}from"./types-tbL38EdO.js";import{n as fi,t as pi}from"./dom.adapter-C26vNdMA.js";import{c as mi,d as hi,m as gi,n as _i,o as vi,p as yi,u as bi}from"./keybindings-CcJR7jqv.js";import{n as xi,r as Si,t as Ci}from"./formatDuration-BbWTR_M_.js";import{n as wi,r as Ti,u as Ei}from"./tools-CryRpKwA.js";import{$ as Di,A as Oi,At as ki,B as Ai,Cn as ji,Ct as Mi,Dn as Ni,En as Pi,F as Fi,G as Ii,H as Li,I as Ri,J as zi,K as Bi,L as Vi,M as Hi,Mt as Ui,N as Wi,On as Gi,Ot as Ki,P as qi,Q as Ji,R as Yi,Sn as Xi,St as Zi,U as Qi,V as $i,W as ea,X as ta,Y as na,Z as ra,_n as ia,_t as aa,a as oa,an as sa,at as ca,bn as la,bt as ua,cn as da,ct as fa,dn as pa,dt as ma,et as ha,fn as ga,ft as _a,gn as va,gt as ya,hn as ba,ht as xa,i as Sa,in as Ca,it as wa,j as Ta,jt as Ea,kn as Da,kt as Oa,ln as ka,lt as Aa,mn as ja,mt as Ma,n as Na,nt as Pa,o as Fa,on as Ia,ot as La,pn as Ra,pt as za,q as Ba,r as Va,s as Ha,sn as Ua,st as Wa,t as Ga,tn as Ka,tt as qa,un as Ja,ut as Ya,vn as Xa,vt as Za,wt as Qa,xn as $a,xt as eo,yn as to,yt as no,z as ro}from"./index-C7sUnaMy.js";import{t as io}from"./shim-IYZxwmPZ.js";var ao={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};ao.node;var oo=z(ao),so={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};so.node;var co=z(so),lo={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};lo.node;var uo=z(lo),fo={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};fo.node;var po=z(fo),mo={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};mo.node;var ho=z(mo),go={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};go.node;var _o=z(go),vo={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 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`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};vo.node;var yo=z(vo),bo={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};bo.node;var xo=z(bo),So={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};So.node;var Co=z(So),wo={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};wo.node;var To=z(wo),Eo={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};Eo.node;var Do=z(Eo),Oo={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};Oo.node;var ko=z(Oo),Ao={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};Ao.node;var jo=z(Ao),Mo={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Mo.node;var No=z(Mo),Po={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Po.node;var Fo=z(Po),Io={name:`git-branch-plus`,size:24,node:[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]};Io.node;var Lo=z(Io),Ro={name:`git-compare`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]};Ro.node;var zo=z(Ro),Bo={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};Bo.node;var Vo=z(Bo),Ho={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};Ho.node;var Uo=z(Ho),Wo={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Wo.node;var Go=z(Wo),Ko={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};Ko.node;var qo=z(Ko),Jo={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};Jo.node;var Yo=z(Jo),Xo={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};Xo.node;var Zo=z(Xo),Qo={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Qo.node;var $o=z(Qo),es={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};es.node;var ts=z(es),ns={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};ns.node;var rs=z(ns),is={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};is.node;var as=z(is),os={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};os.node;var ss=z(os),cs={name:`pencil-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]};cs.node;var ls=z(cs),us={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};us.node;var ds=z(us),fs={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};fs.node;var ps=z(fs),ms={name:`rows-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]],aliases:[`rows`]};ms.node;var hs=z(ms),gs={name:`rows-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]],aliases:[`panels-top-bottom`]};gs.node;var _s=z(gs),vs={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};vs.node;var ys=z(vs),bs={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};bs.node;var xs=z(bs),Ss={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};Ss.node;var Cs=z(Ss),ws={name:`square-menu`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]],aliases:[`menu-square`]};ws.node;var Ts=z(ws),Es={name:`square-minus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-square`]};Es.node;var Ds=z(Es),Os={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};Os.node;var ks=z(Os),As={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};As.node;var js=z(As),Ms={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Ms.node;var Ns=z(Ms),Ps=[`public`,`private`],G=e(n(),1),Fs=e(r(),1),K=e(c(),1);function Is(e,t){let n;return we(e(),{unwatched(){n&&=(n(),void 0)},watched(){this.value=e(),n=t(this)}})}var Ls={bold:`bold`,italic:`italic`,strikeThrough:`strikethrough`,subscript:`subscript`,superscript:`superscript`,underline:`underline`},Rs=Symbol.for(`@lexical/dragon/WindowState`);function zs(e,t,n){let r=function(e){let t=e[Rs];return t===void 0&&(t={dispose:()=>{},editors:new Map,installs:new Set},e[Rs]=t),t}(e);if(r.installs.size===0){let t=Us.bind(e);e.addEventListener(`message`,t,!0),r.dispose=()=>{e.removeEventListener(`message`,t,!0)}}if(r.installs.add(t),n){let e=r.editors.get(n)||new Set;e.add(t),r.editors.set(n,e)}return Bs.bind(null,e,r,t,n)}function Bs(e,t,n,r){if(r){let e=t.editors.get(r);e&&e.delete(n)&&e.size===0&&t.editors.delete(r)}t.installs.delete(n)&&t.installs.size===0&&(t.dispose(),delete e[Rs])}function Vs(e){return e&&e.ownerDocument.defaultView}function Hs(e){let t=Is(()=>Vs(e.getRootElement()),t=>e.registerRootListener(e=>{t.value=Vs(e)}));return Re(()=>{let n=t.value;if(n)return zs(n,Symbol(`@lexical/dragon/editorInstall`),e)})}function Us(e){if(e.origin!==this.location.origin)return;let t=function(e){let t=e[Rs];if(t===void 0)return null;let n=Qe(qe(e.document));return Ue(n)&&t.editors.has(n)?n:null}(this);if(t===null)return;let n=e.data;if(typeof n==`string`){let r;try{r=JSON.parse(n)}catch{return}if(r&&r.protocol===`nuanria_messaging`&&r.type===`request`){let n=r.payload;if(n&&n.functionId===`makeChanges`){let r=n.args;if(Array.isArray(r)){let[n,i,a,o,s,c]=r;if(![n,i,o,s].every(Number.isFinite)||typeof a!=`string`&&a!==-1)return;t.update(()=>{let t=St();if(Ke(t)){let r=t.anchor,l=r.getNode(),u=0,d=0;if(ke(l)&&n>=0&&i>=0&&(u=n,d=n+i,t.setTextNodeRange(l,u,l,d)),typeof a!=`string`||u===d&&a===``||(t.insertRawText(a),l=r.getNode()),ke(l)){let e=l.getTextContentSize();u=Math.min(Math.max(o,0),e),d=o<0||s<0?u:Math.min(o+s,e),t.setTextNodeRange(l,u,l,d)}if(typeof c==`string`&&s>0&&!t.isCollapsed()){let e=Ls[c];e!==void 0&&t.formatText(e)}e.stopImmediatePropagation()}})}}}}}var Ws=[];function Gs(e,t){return`${e}:${t}`}var Ks=Jn()(e=>({boardsByOwner:{},viewByBoard:{},pageSizeByBoard:{},setBoards:(t,n)=>e(e=>({boardsByOwner:{...e.boardsByOwner,[t]:n}})),setBoardView:(t,n)=>e(e=>({viewByBoard:{...e.viewByBoard,[t]:n}})),growPage:t=>e(e=>{let n=e.viewByBoard[t];if(n&&!Object.values(n.cursors).some(e=>e!==null))return e;let r=e.pageSizeByBoard[t]??30;return{pageSizeByBoard:{...e.pageSizeByBoard,[t]:r+30}}}),clearBoardView:t=>e(e=>{if(!(t in e.viewByBoard))return e;let n={...e.viewByBoard};delete n[t];let r={...e.pageSizeByBoard};return delete r[t],{viewByBoard:n,pageSizeByBoard:r}})}));function qs(e){return t=>t.boardsByOwner[e]??Ws}function Js(e){return t=>t.viewByBoard[e]??null}function Ys(e){return t=>t.pageSizeByBoard[e]??30}var Xs={"muted-icon":`bg-muted-icon`,info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`};function Zs(e,t){return t!==null&&e>t}var Qs=io();(0,G.forwardRef)(function(e,t){return G.createElement(`div`,{ref:t,...e})});var $s=(0,G.forwardRef)(function(e,t){return G.createElement(`div`,{ref:t,...e})}),ec=$s,tc={OS:`web`};function nc(e,t){return t===void 0?e:Math.max(0,Math.min(t,e))}function rc(e,t){if(t!==void 0&&Number.isFinite(t)&&Number.isFinite(e.scrollLength))return Math.max(0,t-e.scrollLength)}var ic=new WeakMap;function ac(e){var t;{let n=((t=e?.refScroller?.current)?.getScrollableNode)?.call(t);if(n&&typeof getComputedStyle==`function`){let e=ic.get(n);return e||(e=getComputedStyle(n).direction===`ltr`?`normal`:`negative`,ic.set(n,e)),e}}return e?.horizontalRTLScrollType??`negative`}function oc(e){var t;if(sc(e)){let n=((t=e.refScroller?.current)?.getScrollableNode)?.call(t);n&&ic.delete(n)}}function sc(e){return cc(e?.props)}function cc(e){return!!e?.horizontal&&(e.rtl??!1)}function lc(e){return e?.horizontal?(cc(e)?e.stylePaddingLeft:e.stylePaddingRight)||0:e?.stylePaddingBottom||0}function uc(e,t){return t&&(sc(e)?t.left:t.right)||0}function dc(e,t,n,r){return!sc(e)||r===void 0||!Number.isFinite(r)||ac(e)===`normal`?t:Math.max(0,r-t-n)}function fc(e,t,n){if(!e||!sc(e))return t;let r=rc(e,n),i=nc(t,r),a=ac(e);return a===`negative`?i===0?0:-i:a===`inverted`?r===void 0?i:nc(r-i,r):i}function pc(e,t,n){if(!sc(e))return t;let r=ac(e);return t<0&&r!==`normal`&&(r=`negative`),nc(r===`negative`?-t:r===`inverted`&&n!==void 0?n-t:t,n)}function mc(e,t,n){if(!sc(e))return e.horizontalRTLScrollType=void 0,t;let r=rc(e,n),i=ac(e);if(i===`normal`)return e.horizontalRTLScrollType=`normal`,nc(t,r);if(t<0||i===`negative`)return e.horizontalRTLScrollType=`negative`,nc(-t,r);if(r===void 0)return t;let a=t,o=r-t;if(!Number.isFinite(o))return e.horizontalRTLScrollType=`normal`,a;let s=e.horizontalRTLScrollType;if(s===`inverted`)return nc(o,r);if(s===`normal`)return nc(a,r);if(!e.hasScrolled)return e.horizontalRTLScrollType=`inverted`,nc(o,r);let c=e.scroll,l=Math.abs(a-c),u=Math.abs(o-c)+.5<l;return e.horizontalRTLScrollType=u?`inverted`:`normal`,nc(u?o:a,r)}var hc=e=>e,gc=G.createContext(null),_c=`\0`,vc=0;function yc({children:e}){let[t]=G.useState(()=>({animatedScrollY:hc(0),columnWrapperStyle:void 0,containerLayoutTriggers:new Map,contextNum:vc++,listeners:new Map,mapViewabilityAmountCallbacks:new Map,mapViewabilityAmountValues:new Map,mapViewabilityCallbacks:new Map,mapViewabilityConfigStates:new Map,mapViewabilityValues:new Map,pendingContainerIds:void 0,positionListeners:new Map,scrollAxisGap:0,state:void 0,values:new Map([[`alignItemsAtEndPadding`,0],[`containerLayoutEpoch`,0],[`stylePaddingTop`,0],[`headerSize`,0],[`numContainers`,0],[`activeStickyIndex`,-1],[`isAtEnd`,!1],[`isAtStart`,!1],[`isNearEnd`,!1],[`isNearStart`,!1],[`isWithinMaintainScrollAtEndThreshold`,!1],[`adaptiveRender`,`normal`],[`totalSize`,0],[`scrollAdjustPending`,0]]),viewRefs:new Map}));return G.createElement(gc.Provider,{value:t},e)}function bc(){return G.useContext(gc)}function xc(e,t){if(!e){let e=[];return{get:()=>e,subscribe:()=>()=>{}}}let n=[],r=[];return{get:()=>{let i=[],a=!1;for(let n=0;n<t.length;n++){let o=q(e,t[n]);i.push(o),o!==r[n]&&(a=!0)}return r=i,a&&(n=i),n},subscribe:n=>{let r=[];for(let i of t)r.push(wc(e,i,n));return()=>{for(let e of r)e()}}}}function Sc(e){return e.length===1?e[0]:e.join(_c)}function Cc(e){return e.split(_c)}function wc(e,t,n){let{listeners:r}=e,i=r.get(t);return i||(i=new Set,r.set(t,i)),i.add(n),()=>i.delete(n)}function q(e,t){let{values:n}=e;return n.get(t)}function J(e,t,n){let{listeners:r,values:i}=e;if(i.get(t)!==n){i.set(t,n);let e=r.get(t);if(e)for(let t of e)t(n)}}function Tc(e,t,n){let{positionListeners:r}=e,i=r.get(t);return i||(i=new Set,r.set(t,i)),i.add(n),()=>i.delete(n)}function Ec(e,t,n){let{positionListeners:r}=e,i=r.get(t);if(i)for(let e of i)e(n)}function Dc(e){let t=G.useContext(gc),n=Sc(e),{subscribe:r,get:i}=G.useMemo(()=>xc(t,Cc(n)),[t,n]);return(0,Qs.useSyncExternalStore)(r,i,i)}function Oc(e,t){let n=G.useContext(gc),{subscribe:r,get:i}=G.useMemo(()=>xc(n,[e]),[n,e]),a=G.useCallback(()=>t(i()[0]),[i,t]);return(0,Qs.useSyncExternalStore)(r,a,a)}function kc(e){return Math.max(0,e??0)}function Ac(e,t){let n=e.state,{props:r}=n,i=r.horizontal,a=n.nativeContentInset,o=kc(t??r.contentInsetEndAdjustment),s=q(e,`anchoredEndSpaceSize`),c=r.anchoredEndSpace&&s?s:0,l=n.contentInsetOverride??void 0,u=l?{bottom:0,left:0,right:0,...a,...l}:a,d=((i?uc(n,u):u?.bottom)||0)+o;return Math.max(d,c)}function jc(e,t=!0){let{values:n,state:r}=e,i=r.props.horizontal?r.props.stylePaddingLeft||0:n.get(`stylePaddingTop`)||0,a=r.props.horizontal?r.props.stylePaddingRight||0:r.props.stylePaddingBottom||0,o=n.get(`alignItemsAtEndPadding`)||0,s=n.get(`headerSize`)||0,c=n.get(`footerSize`)||0,l=Ac(e),u=r.pendingTotalSize??r.totalSize??n.get(`totalSize`),d=Math.max(0,u-(r.props.data.length>0?e.scrollAxisGap:0)),f=s+c+d+i+o+a,p=l,m=f+p;return(t?Math.max(m,r.props.contentContainerMinSize??0):m)+l-p}var Mc=({children:e})=>G.createElement($s,{style:{alignItems:`center`,flexDirection:`row`,justifyContent:`space-between`}},e);G.memo(function(){let e=bc(),[t=0,n=0,r=0,i=0,a=0,o=0,s=!1]=Dc([`totalSize`,`scrollAdjust`,`debugRawScroll`,`debugComputedScroll`,`numContainers`,`numContainersPooled`,`isAtEnd`]),c=jc(e),[,l]=(0,G.useReducer)(e=>e+1,0);return Nc(()=>{l()},100),G.createElement($s,{pointerEvents:`none`,style:{backgroundColor:`#FFFFFFCC`,borderRadius:4,padding:4,paddingBottom:4,paddingLeft:4,position:`absolute`,right:0,top:0}},G.createElement(Mc,null,G.createElement(ec,null,`TotalSize:`),G.createElement(ec,null,t.toFixed(2))),G.createElement(Mc,null,G.createElement(ec,null,`ContentSize:`),G.createElement(ec,null,c.toFixed(2))),G.createElement(Mc,null,G.createElement(ec,null,`At end:`),G.createElement(ec,null,String(s))),G.createElement(Mc,null,G.createElement(ec,null,`ScrollAdjust:`),G.createElement(ec,null,n.toFixed(2))),G.createElement(Mc,null,G.createElement(ec,null,`RawScroll: `),G.createElement(ec,null,r.toFixed(2))),G.createElement(Mc,null,G.createElement(ec,null,`ComputedScroll: `),G.createElement(ec,null,i.toFixed(2))))});function Nc(e,t){(0,G.useEffect)(()=>{let n=setInterval(e,t);return()=>clearInterval(n)},[t])}var Pc=!0,Fc=typeof __DEV__<`u`?__DEV__:void 0,Ic=typeof process<`u`?`production`:void 0,Lc=(typeof Ic==`string`?Ic.toLowerCase()!==`production`:void 0)??Fc??!1,Rc=-1e7,zc=1,Bc=100,Vc=500,Hc=Lc&&!1,Uc=Lc&&!1;function Wc(e,t){let n=e.state;return t===void 0?0:n.positions[t]||0}function Gc({scheduledWork:e}){e.cancel(`checkFinishedScrollFrame`),e.cancel(`checkFinishedScrollRetryFrame`),e.cancel(`checkFinishedScrollFallback`),e.cancel(`platformScrollCompletion`)}function Kc(e){let{state:t}=e;J(e,`isScrollActive`,!!t.isDragging||!!t.isMomentumScrolling||!!t.scrollingTo||!!t.pendingScrollResolve)}function qc(e){let t=e.pendingScrollResolve;e.pendingScrollResolve=void 0,e.pendingScrollToEnd=void 0,t?.()}function Jc(e){Gc(e),e.scheduledWork.cancel(`imperativeScrollReady`),e.scrollingTo=void 0,e.scrollTargetPinnedRange=void 0,qc(e)}function Yc(e){return e.state,0}function Xc(e,t=jc(e)){return Math.max(0-Yc(e),t-e.state.scrollLength)}function Zc(e,t,n){let r=e.state,i=0-Yc(e),a=jc(e,!n||!!n.clampToContentContainerMinSize),o=t;if(Number.isFinite(a)&&Number.isFinite(r.scrollLength)&&tc.OS!==`android`){let s=Xc(e,a),c=n?.isInitialScroll?void 0:n?.viewOffset,l=typeof c==`number`&&c<0?-c:0,u=n?.offset!==void 0&&(n.index===void 0||n.isInitialScroll&&r.initialScrollSession?.kind===`offset`),d=Math.max(u?0:i,s+l);o=Math.min(t,d)}return Math.max(i,o)}function Qc(e,t,n=e.state.props.horizontal){let{state:r}=e;return n?{x:fc(r,t,Math.max(jc(e),r.props.contentContainerMinSize??0)),y:0}:{x:0,y:t}}function $c(e,t,n){return{...t,nativeEvent:{...t.nativeEvent,contentOffset:e.props.horizontal?{x:n,y:0}:{x:0,y:n}}}}function el(e,t){var n,r;let i=e.state,a=i.deferredPublicOnScrollEvent;i.deferredPublicOnScrollEvent=void 0,a&&((r=(n=i.props).onScroll)==null||r.call(n,$c(i,a,t??i.scrollPending??i.scroll??0)))}function tl(e,t=0){return-e-t}function nl(e,t){return!!e&&t>0&&e.viewPosition===1&&!!e.preserveForBottomPadding&&e.index!==void 0&&e.index>=t-1}var rl=1;function il(e){return!!(e?.didDispatchNativeScroll||e?.didRetrySilentInitialScroll||e?.watchdog)}function al(e){e.initialScrollSession=void 0}function ol(e){let{bootstrap:t,completion:n,kind:r,previousDataLength:i}=e;return r===`offset`?{completion:n,kind:r,previousDataLength:i}:{bootstrap:t,completion:n,kind:r,previousDataLength:i}}function sl(e,t=(t=>(t=(t=>(t=e.initialScrollSession)?.kind)())??`bootstrap`)()){var n;return e.initialScrollSession?e.initialScrollSession.kind!==t&&(e.initialScrollSession=ol({bootstrap:e.initialScrollSession.kind===`bootstrap`?e.initialScrollSession.bootstrap:void 0,completion:e.initialScrollSession.completion,kind:t,previousDataLength:e.initialScrollSession.previousDataLength})):e.initialScrollSession=ol({completion:{},kind:t,previousDataLength:0}),(n=e.initialScrollSession).completion??(n.completion={}),e.initialScrollSession.completion}var cl={didDispatchNativeScroll(e){return!!e.initialScrollSession?.completion?.didDispatchNativeScroll},didRetrySilentInitialScroll(e){return!!e.initialScrollSession?.completion?.didRetrySilentInitialScroll},markInitialScrollNativeDispatch(e){sl(e).didDispatchNativeScroll=!0},markSilentInitialScrollRetry(e){sl(e).didRetrySilentInitialScroll=!0},resetFlags(e){if(!e.initialScrollSession)return;let t=sl(e,e.initialScrollSession.kind);t.didDispatchNativeScroll=void 0,t.didRetrySilentInitialScroll=void 0}},ll={clear(e){ll.set(e,void 0)},didReachTarget(e,t){return Math.abs(e-t.targetOffset)<=rl},get(e){return e.initialScrollSession?.completion?.watchdog},hasNonZeroTargetOffset(e){return e!==void 0&&e>rl},isAtZeroTargetOffset(e){return e<=rl},set(e,t){if(!t&&!e.initialScrollSession?.completion?.watchdog)return;let n=sl(e);n.watchdog=t?{startScroll:t.startScroll,targetOffset:t.targetOffset}:void 0}};function ul(e,t={}){let n=e.initialScrollSession,r=t.kind??n?.kind,i=n?.completion,a=n?.kind===`bootstrap`?n.bootstrap:void 0,o=r===`bootstrap`?t.bootstrap===null?void 0:t.bootstrap??a:void 0;return!r||!e.initialScroll&&!o&&!il(i)?al(e):(e.initialScrollSession=ol({bootstrap:o,completion:i,kind:r,previousDataLength:t.previousDataLength??n?.previousDataLength??0}),e.initialScrollSession)}function dl(e,t=e.state.scroll){let{state:n}=e,r=n.refScroller.current,i=(r?.getCurrentScrollOffset)?.call(r);return i===void 0?n.lastNativeScroll??t:n.props.horizontal?pc(n,i,r.getMaxScrollOffset?.call(r)):i}function fl(e){let{state:t,values:n}=e;return(n.get(`headerSize`)||0)+(n.get(`footerSize`)||0)+(t.pendingTotalSize??t.totalSize??n.get(`totalSize`)??0)+(t.props.stylePaddingTop||0)+(t.props.stylePaddingBottom||0)}function pl(e){let{state:t}=e;return t.props.alignItemsAtEndPaddingEnabled&&!t.props.horizontal&&t.props.data.length>0&&t.scrollLength>0?Math.max(0,t.scrollLength-fl(e)-Yc(e)-Ac(e)):0}function ml(e){let{state:t}=e,n=q(e,`alignItemsAtEndPadding`)||0,r=pl(e);if(n!==r){let i=t.maintainingScrollAtEnd===`pending-animated`||t.maintainingScrollAtEnd===`animated`,a=t.didContainersLayout&&t.props.maintainScrollAtEnd?.animated&&(i||n>r&&q(e,`isWithinMaintainScrollAtEndThreshold`));a&&!i&&!t.pendingMaintainScrollAtEnd?t.scheduledWork.microtask(()=>{!t.maintainingScrollAtEnd&&!t.pendingMaintainScrollAtEnd&&J(e,`alignItemsAtEndPadding`,pl(e))},`alignItemsAtEndPaddingFallback`):a||J(e,`alignItemsAtEndPadding`,r)}}function hl(e,t,n){let r=e.state;if(Math.abs(t)>.1){r.layoutAdjustmentEpoch=(r.layoutAdjustmentEpoch??0)+1;let n=()=>{r.scrollAdjustHandler.requestAdjust(t),r.adjustingFromInitialMount&&r.adjustingFromInitialMount--};r.scroll+=t,r.userScrollContentSize!==void 0&&(r.userScrollContentSize+=t),r.scrollForNextCalculateItemsInView=void 0,q(e,`readyToRender`)?n():(r.adjustingFromInitialMount=(r.adjustingFromInitialMount||0)+1,requestAnimationFrame(n))}}function gl(e){let{state:t}=e,n=t.maintainingScrollAtEnd;t.endFollowInterrupted=!0,J(e,`isFollowingEnd`,!1),(n===`animated`||n===`instant`||n&&t.scrollingTo?.isScrollToEnd)&&(Jc(t),Kc(e)),(n||t.pendingMaintainScrollAtEnd)&&yl(e)}function _l(e){e.state.scheduledWork.timeout(()=>vl(e),Vc,`appScrollRearm`)}function vl(e){let{state:t}=e;!t.endFollowInterrupted||t.visibleContentAnchor&&!t.visibleContentAnchor.sizeOnly||t.isDragging||t.userScrollContentSize!==void 0||t.scheduledWork.has(`appScrollRearm`)||t.scrollingTo||t.pendingScrollResolve||!q(e,`isWithinMaintainScrollAtEndThreshold`)||(t.endFollowInterrupted=!1,t.props.maintainScrollAtEnd&&J(e,`isFollowingEnd`,!0))}function yl(e){var t;let{state:n}=e,r=q(e,`alignItemsAtEndPadding`)||0,i=pl(e);n.maintainingScrollAtEnd=void 0,n.pendingMaintainScrollAtEnd=!1;for(let e of n.pendingEndMeasurements??[])n.containerItemKeys.has(e)||n.pendingEndMeasurements.delete(e);if(r!==i){J(e,`alignItemsAtEndPadding`,i),n.scrollForNextCalculateItemsInView=void 0,(t=n.triggerCalculateItemsInView)==null||t.call(n,{forceFullItemPositions:!0});let a=Zc(e,n.scroll+i-r),o=n.scroll;n.scroll=o,hl(e,a-o)}}var bl=1.3;function xl(e,t,n){let r=Math.abs(e);return!t&&n>0&&r>=n*bl||!t&&n<=0&&r>0}function Sl(e,t){return!!e&&(e.dataLength!==t.dataLength||e.data!==t.data&&e.contentSize!==t.contentSize)}var Cl=(e,t,n,r,i,a,o,s)=>{let c=Math.abs(e),l=a.dataLength!==0&&(t||n>0&&c<=n),u=i?.scroll!==a.scroll;return i&&(i.scroll=a.scroll),l?(!r||Sl(i,a))&&o(e)?!0:!!r:((a.dataLength===0||u&&xl(e,t,n))&&(r||i)&&s(void 0),!1)};function wl(e){return e.state.scroll+Yc(e)}function Tl(e){let t=e.state;if(!t.edgeReachedGate||t.edgeReachedGateScroll===t.scroll)return;t.edgeReachedGateScroll=t.scroll;let n=jc(e),r=n-t.scroll-t.scrollLength,i=n<t.scrollLength,a=t.props.onStartReachedThreshold*t.scrollLength,o=t.props.onEndReachedThreshold*t.scrollLength,s=xl(wl(e),!1,a),c=xl(r,i,o);s&&c&&(t.edgeReachedGate=void 0)}function El(e,t,n,r){let i=e.state;return!i.edgeReachedGate||n===t||!!r||Sl(t===`start`?i.startReachedSnapshot:i.endReachedSnapshot,Ol(e))}function Dl(e,t){let n=e.state;n.edgeReachedGate=`closed`,n.edgeReachedGateScroll=n.scroll;let r=t===`start`?`startReachedSnapshot`:`endReachedSnapshot`,i=Ol(e);i.didRearmForData=Sl(n[r],i),n[r]=i}function Ol(e){let{data:t}=e.state.props;return{contentSize:jc(e),data:t,dataLength:t.length,scroll:e.state.scroll}}function kl(e){e.state.edgeReachedGate&&(e.state.edgeReachedGate=`prepared`)}function Al(e,t){let n=e.state,r=t<0?`start`:`end`;if(n.edgeReachedGate!==`prepared`&&n.edgeReachedGate!==(r===`start`?`consumed-end`:`consumed-start`))return;let i=r===`start`?`startReachedSnapshot`:`endReachedSnapshot`,a=n[i];if(a?.didRearmForData&&a.data===n.props.data)a.didRearmForData=!1,n.edgeReachedGate=n.edgeReachedGate===`prepared`?`consumed-${r}`:`closed`;else return n[r===`start`?`isStartReached`:`isEndReached`]=!1,n[i]=void 0,r}function jl(e){return!!e?.initialScroll&&!e.didFinishInitialScroll}function Ml(e,t,n){let r=e.state;if(!r)return;let{queuedInitialLayout:i,scrollLength:a,scroll:o,maintainingScrollAtEnd:s,props:{maintainScrollAtEndThreshold:c,onEndReachedThreshold:l}}=r,u=jc(e),d=u-o-a;if(Tl(e),r.props.data.length===0&&a>0&&u<=a)J(e,`isAtEnd`,!0),J(e,`isNearEnd`,!0),J(e,`isWithinMaintainScrollAtEndThreshold`,!0);else if(u>0&&i){let i=u<a;J(e,`isAtEnd`,i||d<=zc),J(e,`isNearEnd`,i||d<=l*a),J(e,`isWithinMaintainScrollAtEndThreshold`,i||d<=Math.max(zc,c*a)||r.pendingMaintainScrollAtEnd||!!s||!!q(e,`isFollowingEnd`)),jl(r)||s||(r.isEndReached=Cl(d,i,l*a,r.isEndReached,r.endReachedSnapshot,{contentSize:u,data:r.props.data,dataLength:r.props.data.length,scroll:o},i=>r.props.onEndReached&&El(e,`end`,t,n)?(Dl(e,`end`),r.props.onEndReached({distanceFromEnd:i}),!0):!1,e=>{r.endReachedSnapshot=e}))}}function Nl(e,t,n){let r=e?.state;if(!r)return;let{props:{data:i,onStartReachedThreshold:a},scrollLength:o}=r,s=a*o,c=wl(e);Tl(e),J(e,`isAtStart`,c<=zc),J(e,`isNearStart`,c<=s),!r.queuedInitialLayout||jl(r)||r.scrollingTo||(r.isStartReached=Cl(c,!1,s,r.isStartReached,r.startReachedSnapshot,{contentSize:jc(e),data:i,dataLength:i.length,scroll:r.scroll},i=>r.props.onStartReached&&El(e,`start`,t,n)?(Dl(e,`start`),r.props.onStartReached({distanceFromStart:i}),!0):!1,e=>{r.startReachedSnapshot=e}))}function Pl(e,t){let n=!e.state.edgeReachedGate;Ml(e,t,n),Nl(e,t,n),vl(e)}function Fl(e){var t;let n=e.state;n.props?.data&&((t=n.triggerCalculateItemsInView)==null||t.call(n,{forceFullItemPositions:!0})),Pl(e)}var Il=6,Ll=3,Rl=250;function zl(e){e.state.scheduledWork.cancel(`adaptiveRender`)}function Bl(e,t){let n=e.state;zl(e),t<=0?Vl(e,`normal`,`scroll`):n.scheduledWork.timeout(()=>Vl(e,`normal`,`scroll`),t,`adaptiveRender`)}function Vl(e,t,n){var r,i;q(e,`adaptiveRender`)!==t&&(J(e,`adaptiveRender`,t),(i=(r=e.state.props.adaptiveRender)?.onChange)==null||i.call(r,t,n))}function Hl(e){zl(e);let t=e.state.props.adaptiveRender?.initialMode??`normal`;q(e,`adaptiveRender`)!==t&&Vl(e,t,`initial`)}function Ul(e,t,n){let r=e.state,i=r.props.adaptiveRender,a=q(e,`adaptiveRender`);if(q(e,`readyToRender`)){if(i){let o=i.enterVelocity??Il,s=i.exitVelocity??Ll,c=i.exitDelay??Rl,l=a===`light`?s:o,u=n?.forceLight||Math.abs(t)>l?`light`:`normal`;u!==(r.scheduledWork.has(`adaptiveRender`)?`normal`:a)&&(u===`light`?(Vl(e,`light`,`scroll`),Bl(e,c)):a===`light`&&Bl(e,c))}else Hl(e)}}var Wl=50;function Gl(e,t){let n=e.state.props.drawDistance,r=e.state.initialScroll,i=r!==void 0&&(r.viewPosition??0)>0;return t===`visible-first`||t!==`full`&&!q(e,`readyToRender`)&&!i?Math.min(n,Wl):n}function Kl(e){let{state:t}=e;t.props.drawDistance<=Wl||t.scheduledWork.has(`fullDrawDistancePrewarm`)||t.scheduledWork.frame(()=>{var e,n;if(t.props.hasExternalScroll&&!jl(t)&&!t.scrollingTo&&!t.pendingNativeMVCPAdjust){let n=((e=t.refScroller.current)?.getRawScrollOffset)?.call(e);n!==void 0&&(t.scroll=t.scrollPending=t.props.horizontal?mc(t,n,t.totalSize):n)}(n=t.triggerCalculateItemsInView)==null||n.call(t)},`fullDrawDistancePrewarm`)}function ql(e,{resetLayout:t,resetInitialScroll:n}){let{state:r}=e;t&&(r.didContainersLayout=!1,r.queuedInitialLayout=!1,r.scrollBufferDirection=void 0,r.scrollHistory.length=0,r.scheduledWork.cancel(`renderRangeProjection`),r.edgeReachedGate=void 0,r.isStartReached=null,r.isEndReached=null,r.startReachedSnapshot=void 0,r.endReachedSnapshot=void 0),n&&(r.didFinishInitialScroll=!1),J(e,`readyToRender`,!1),Hl(e)}function Jl(e,{didLayout:t,didInitialScroll:n}){let{state:r}=e,{loadStartTime:i,props:{onLoad:a,onReady:o}}=r;t&&(r.didContainersLayout=!0),n&&(r.didFinishInitialScroll=!0),r.didContainersLayout&&r.didFinishInitialScroll&&!q(e,`readyToRender`)&&(J(e,`readyToRender`,!0),Vl(e,`normal`,`ready`),r.props.drawDistance>Wl&&Kl(e),r.didLoad||(r.didLoad=!0,a&&a({elapsedTimeInMs:Date.now()-i})),o?.())}var Yl=2e3;function Xl(e,t){e.scroll=t,e.scrollPending=t,e.scrollPrev=t}function Zl(e){e.scheduledWork.cancel(`preservedInitialScroll`),e.clearPreservedInitialScrollOnNextFinish=void 0,e.initialScroll=void 0,e.preservedEndAnchorCorrection=void 0,ul(e)}function Ql(e){let t=e.state,n=t.initialScrollSession?.kind===`bootstrap`?t.initialScrollSession.bootstrap:void 0;(t.initialScroll||n||t.scrollingTo?.isInitialScroll)&&(n?.frameHandle!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(n.frameHandle),t.scrollingTo?.isInitialScroll&&(Gc(t),t.scrollingTo=void 0,t.scrollTargetPinnedRange=void 0),cl.resetFlags(t),ul(t,{bootstrap:null}),$l(e))}function $l(e,t){let n=e.state,r=n.freshDataTransitionEpoch;if(t?.resolvedOffset!==void 0)Xl(n,t.resolvedOffset);else if(t?.syncObservedOffset&&n.initialScrollSession?.kind===`offset`){let t=dl(e);Number.isFinite(t)&&Xl(n,t)}let i=()=>{var i,a;if(n.isUnmounted)return;if(r!==n.freshDataTransitionEpoch){(i=t?.onFinished)==null||i.call(t);return}let o=n.initialScrollSession?.kind===`bootstrap`;nl(n.initialScroll,n.props.data.length)&&n.props.maintainScrollAtEnd&&!n.endFollowInterrupted&&J(e,`isFollowingEnd`,!0);let s=t?.resolvedOffset??n.scrollPending;ll.clear(n),t?.preserveTarget&&n.initialScroll?(n.clearPreservedInitialScrollOnNextFinish=void 0,ul(n),n.scheduledWork.cancel(`preservedInitialScroll`),t?.schedulePreservedTargetClear&&n.scheduledWork.timeout(()=>{n.didFinishInitialScroll&&!n.scrollingTo?.isInitialScroll&&n.initialScroll&&Zl(n)},Yl,`preservedInitialScroll`)):Zl(n),t?.recalculateItems&&Fl(e),Jl(e,{didInitialScroll:!0}),o&&el(e,s),(a=t?.onFinished)==null||a.call(t)};t?.waitForCompletionFrame?requestAnimationFrame(i):i()}function eu(e){let{state:t}=e;return(t.props.horizontal?(sc(t)?t.props.stylePaddingRight:t.props.stylePaddingLeft)||0:q(e,`stylePaddingTop`)||0)+(q(e,`alignItemsAtEndPadding`)||0)+(q(e,`headerSize`)||0)}function tu(e,t,n=(t=>(t=q(e,`scrollAdjustPending`))??0)(),r=eu(e)){return Math.round(t+(n-r))}function nu(e,t){let{data:n,keyExtractor:r}=e.props;if(!n)return``;let i=t<n.length?r?r(n[t],t):t:null;return e.idCache[t]=i,i}function ru(e,t,n,r=!0){let i=e.state,a=i.totalSize,o=i.totalSize;t===null?(o=n,i.timeoutSetPaddingTop&&=(clearTimeout(i.timeoutSetPaddingTop),void 0)):o+=n,a===o?r&&e.values.get(`totalSize`)!==o&&J(e,`totalSize`,o):(i.pendingTotalSize=void 0,i.totalSize=o,r&&J(e,`totalSize`,o),ml(e))}function iu(e,t,n,r=!0){let i=e.state,{sizes:a}=i,o=a.get(t),s=o===void 0?n:n-o;s!==0&&(i.positionsAreCurrent=!1,ru(e,t,s,r)),a.set(t,n)}function au(e){return typeof e==`function`}function ou(e){return Array.isArray(e)}var su=new Set;function cu(e,t){Lc&&!su.has(e)&&(su.add(e),console.warn(`[legend-list] ${t}`))}function lu(e){return Math.floor(e*8)/8}function uu(e){return e==null}function du(e,t){let n=t===`Left`||t===`Right`?e.paddingHorizontal:e.paddingVertical;return e[`padding${t}`]??n??e.padding??0}function fu(e,t,n){return du(e,n)+du(t,n)}function pu(e,t){let n=(e.state?.containerItemKeys)?.get(t);if(n!==void 0)return n;let r=q(e,`numContainers`);for(let n=0;n<r;n++)if(q(e,`containerItemKey${n}`)===t)return n;return-1}function mu(e,t,n,r,i){let a=e.state,{getFixedItemSize:o,getItemType:s}=a.props,c=t?a.sizesKnown.get(t):void 0;if(c===void 0&&t&&o){let l=i?.itemType??(s?s(r,n)??``:``),u=i?.didResolveFixedItemSize?i.fixedItemSize:o(r,n,l);u!==void 0&&(c=u+e.scrollAxisGap,a.positionsAreCurrent=!1,a.positionRecalculationStartIndex=Math.min(a.positionRecalculationStartIndex??n,n),a.scrollForNextCalculateItemsInView=void 0,a.sizesKnown.set(t,c),a.fixedItemSizeKeys??=new Set,a.fixedItemSizeKeys.add(t))}return c}function hu(e,t){return mu(e,nu(e.state,t),t,e.state.props.data[t])}function gu(e,t,n){for(let r=t;r<=n;r++)if(hu(e,r)===void 0)return!1;return!0}function _u(e,t,n,r,i,a,o,s){let c=e.state,{sizes:l,averageSizes:u,props:{estimatedItemSize:d,getItemType:f},scrollingTo:p}=c,m=c.sizesKnown.get(t);if(m!==void 0)return m;let h=l.get(t),g=mu(e,t,n,r,s);if(g!==void 0)return iu(e,t,g,o),g;if(a&&h!==void 0)return h;let _=s?.itemType??(f?f(r,n)??``:``);if(i&&!p){let e=u[_]?.avg;e!==void 0&&(g=lu(e))}if(g===void 0&&h!==void 0)return h;if(g===void 0&&i&&p){let e=p.averageSizeSnapshot?.[_];e!==void 0&&(g=lu(e))}return g===void 0&&(g=d+e.scrollAxisGap),iu(e,t,g,o),g}function vu(e,t){if(!(t===void 0||t<0))return _u(e,nu(e.state,t),t,e.state.props.data[t])}function yu(e,t,n){let r=t;return e<0&&n!==void 0&&(r=n===`start`?0:1),-r*e}function bu(e,t,n){let r=e.state,{index:i,viewOffset:a,viewPosition:o,viewPositionFallback:s}=n,c=t;a&&(c-=a);let l=i===void 0?0:Yc(e);if(i!==void 0&&(c+=eu(e)-l),o!==void 0&&i!==void 0){let t=r.props.data.length;if(t===0)return c;let n=i<0||i>=t,a=r.props.estimatedItemSize??0,u=n?a:_u(e,nu(r,i),i,r.props.data[i]),d=Math.max(0,u-(n?0:e.scrollAxisGap)),f=Ac(e),p=r.scrollLength-l-f-d;c+=yu(p,o,s)}return i!==void 0&&n.clampToContentContainerMinSize&&(c+=jc(e)-jc(e,!1)),c}var xu=.1,Su=300,Cu=2,wu=1;function Tu(e,t,n,r){if(!t){e.mvcpAnchorLock=void 0;return}let i=e.mvcpAnchorLock;if(!i)return;let a=r>i.expiresAt,o=e.indexByKey.get(i.id)===void 0;if(a||o||!n)e.mvcpAnchorLock=void 0;else return i}function Eu(e,t){{let{anchorId:n,anchorPosition:r,dataChanged:i,now:a,positionDiff:o}=t,s=!!i||!!e.mvcpAnchorLock,c=e.props.maintainVisibleContentPosition.data;if(!s||!c||e.scrollingTo||!n||r===void 0)return;let l=e.mvcpAnchorLock,u=!i&&Math.abs(o)<=xu&&l?.id===n?l.quietPasses+1:0;if(!i&&u>=Cu){e.mvcpAnchorLock=void 0;return}e.mvcpAnchorLock={expiresAt:a+Su,id:n,position:r,quietPasses:u}}}function Du(e,t,n,r,i,a){return!1}function Ou(e,t,n){if(Math.abs(t)<=xu)return 0;let r=e.state,i=Xc(e,n)-r.scroll;return t<0?Math.max(t,Math.min(0,i)):t>0?Math.min(t,Math.max(0,i)):0}function ku(e,t){return e<0?-t:t}function Au(e,t,n){let r=e.state;r.pendingNativeMVCPAdjust=void 0;let i=t-n;Math.abs(i)>xu&&hl(e,i)}function ju(e){let t=e.state.pendingNativeMVCPAdjust;if(!t||Math.abs(t.manualApplied)>xu)return;let n=jc(e),r=Ou(e,t.amount,n);if(Math.abs(r)<=xu)return;let i=t.amount-r;Math.abs(i)<=xu||(t.manualApplied=i,hl(e,i),t.furthestProgressTowardAmount=0)}function Mu(e,t){let n=e.state,r=n.pendingNativeMVCPAdjust;if(!r)return!1;let i=r.amount-r.manualApplied,a=t-(r.startScroll+r.manualApplied),o=i<0&&a>xu||i>0&&a<-xu,s=ku(i,a);if(Math.abs(i)<=xu)return n.pendingNativeMVCPAdjust=void 0,!0;if(o)return n.pendingNativeMVCPAdjust=void 0,!1;if(s+xu>=Math.abs(i))return Au(e,i,a),!0;let c=Xc(e);return Math.abs(t-c)<=wu||n.pendingMaintainScrollAtEnd&&q(e,`isWithinMaintainScrollAtEndThreshold`)&&s>xu?(Au(e,i,a),!0):s>r.furthestProgressTowardAmount+xu?(r.furthestProgressTowardAmount=s,!1):(r.furthestProgressTowardAmount>xu&&s<r.furthestProgressTowardAmount-xu&&(n.pendingNativeMVCPAdjust=void 0),!1)}function Nu(e,t,n){let r=e.state,{idsInView:i,positions:a,props:o}=r,{maintainVisibleContentPosition:{data:s,size:c,shouldRestorePosition:l}}=o,u=Date.now(),d=!!t||!!r.mvcpAnchorLock,f=r.scrollingTo;if(f?.key!==void 0){let e=r.indexByKey.get(f.key);e!==void 0&&(f.index=e)}if(t&&r.pendingScrollToEnd&&f===void 0){r.mvcpAnchorLock=void 0;return}let p=Tu(r,d,s,u),m,h,g=[],_=f?.index,v=f?.viewPosition,y=_!==void 0&&r.props.data.length>0&&_>=r.props.data.length-1&&(v??0)>0;t&&r.visibleContentAnchor?.sizeOnly&&(r.visibleContentAnchor=void 0);let b=r.visibleContentAnchor,x=!!b||(t?s:c),S=r.indexByKey,C=r.scroll;if(jc(e),x){if(b&&_===void 0?(h=b.key,m=r.scroll-b.offset):p&&_===void 0?(h=p.id,m=p.position):_===void 0?i.length>0&&r.didContainersLayout&&!t&&(h=i.find(e=>S.get(e)!==void 0)):h=f?.key??nu(r,_),t&&i.length>0&&r.didContainersLayout)for(let e=0;e<i.length;e++){let t=i[e],n=S.get(t);if(n!==void 0){let e=a[n];e!==void 0&&g.push({id:t,position:e})}}if(h!==void 0&&m===void 0){let e=S.get(h);e!==void 0&&(m=a[e])}return()=>{if(_!==void 0&&r.scrollingTo!==f)return;let n=0,i=p?.id,o,c=!1,d=r.props.data;if(t&&s&&_===void 0&&h!==void 0&&p?.id===h&&l!==void 0&&h!==void 0){let e=S.get(h);if(e!==void 0){let t=d[e];c=t===void 0||!l(t,e,d),c&&p?.id===h&&(r.mvcpAnchorLock=void 0)}}if(t&&s&&_===void 0&&(()=>{if(h===void 0||c)return!0;let e=S.get(h);return e===void 0||a[e]===void 0})())for(let e=0;e<g.length;e++){let{id:t,position:r}=g[e],s=S.get(t);if(s!==void 0&&l){let e=d[s];if(e===void 0||!l(e,s,d))continue}let c=s===void 0?void 0:a[s];if(c!==void 0){n=c-r,i=t,o=c;break}}if(!c&&h!==void 0&&m!==void 0){let t=S.get(h),s=t===void 0?void 0:a[t];if(s!==void 0){f?.key===h&&(f.index=t);let a=jc(e),c=s-m;if(c!==0&&y&&r.scroll+r.scrollLength>a){if(c>0)c=Math.max(0,a-r.scroll-r.scrollLength);else{let t=Xc(e,a);r.scroll=t,r.scrollPending=t,c=0}}n=c,i=h,o=s}}if(f&&v!==void 0&&(v>0||f.viewPositionFallback)){let t=f.index,i=_u(e,h,t,r.props.data[t]),a=f.itemSize;if(a!==void 0&&i!==a){if(f.viewPositionFallback){let t=r.scrollLength-Yc(e)-Ac(e),o=t-Math.max(0,a-e.scrollAxisGap),s=t-Math.max(0,i-e.scrollAxisGap);n+=yu(s,v,f.viewPositionFallback)-yu(o,v,f.viewPositionFallback)}else n+=(i-a)*v;f.itemSize=i}}Eu(r,{anchorId:i,anchorPosition:o,dataChanged:t,now:u,positionDiff:n}),Du()?(r.pendingNativeMVCPAdjust={amount:n,furthestProgressTowardAmount:0,manualApplied:0,startScroll:C},ju(e)):Math.abs(n)>xu&&(r.maintainingScrollAtEnd!==`pending-animated`&&r.maintainingScrollAtEnd!==`animated`||!q(e,`isWithinMaintainScrollAtEndThreshold`))&&hl(e,n)}}}var Pu=1e3,Fu=200,Iu=e=>{let{scrollHistory:t}=e,n=t.length-1;if(n<1)return 0;let r=t[n];if(Date.now()-r.time>Pu)return 0;let i=0,a=0,o=0;for(let e=n;e>0;e--){let n=t[e],s=t[e-1],c=n.scroll-s.scroll,l=n.time-s.time,u=Math.sign(c);if(u!==0){if(i===0)i=u;else if(u!==i)break}if(r.time-s.time>Pu)break;if(c===0||l<=0)continue;let d=r.time-n.time,f=Math.exp(-d/Fu);a+=c/l*f,o+=f}return o>0?a/o:0};function Lu(e){let t=e.mvcpAnchorLock;return t?Date.now()>t.expiresAt?(e.mvcpAnchorLock=void 0,!1):!0:!1}function Ru(e){return e.dataChangeNeedsScrollUpdate||Lu(e)}function zu(e,t,n,r){var i;let a=e.state,{ignoreScrollFromMVCP:o,lastScrollAdjustForHistory:s,scrollAdjustHandler:c,scrollHistory:l,scrollingTo:u}=a,d=a.scroll;r?.markHasScrolled!==!1&&(a.hasScrolled=!0);let f=Date.now();a.lastBatchingAction=f;let p=c.getAdjust(),m=s!==void 0&&Math.abs(p-s)>.1;if(m&&(l.length=0),a.lastScrollAdjustForHistory=p,u!==void 0||l.length===0&&t===a.scroll||m||l.push({scroll:t,time:f}),l.length>5&&l.shift(),o&&!u){let{lt:e,gt:n}=o;if(e&&t<e||n&&t>n){a.ignoreScrollFromMVCPIgnored=!0;return}}a.scrollPrev=d,a.scrollPrevTime=a.scrollTime,a.scroll=t,a.scrollTime=f;let h=r?.fromNativeScrollEvent&&t<d?Math.min(d,((i=a.refScroller.current)?.getMaxScrollOffset)?.call(i)??d):d,g=Math.abs(t-d),_=!!r?.fromNativeScrollEvent&&g>.1&&!jl(a)&&Math.abs(t-h)>.1&&!m&&u===void 0&&!a.pendingNativeMVCPAdjust;_&&(a.scrollBufferDirection=t>d?1:-1);let v=_&&!!(a.maintainingScrollAtEnd||a.pendingMaintainScrollAtEnd||q(e,`isFollowingEnd`))&&t<h-1;v&&e.interruptUserScroll(),_&&(a.visibleContentAnchor=void 0,!a.isDragging&&!a.isMomentumScrolling&&a.userScrollContentSize===void 0&&t>d&&jc(e)-t-a.scrollLength<=1&&(a.endFollowInterrupted=!1,a.props.maintainScrollAtEnd&&J(e,`isFollowingEnd`,!0)));let y=_?Al(e,t-d):void 0,b=Mu(e,t),x=a.scrollLength,S=x>0&&u===void 0&&g>x&&!a.pendingNativeMVCPAdjust,C=Iu(a);Ul(e,C,{forceLight:S});let w=a.scrollLastCalculate;if(Ru(a)||b||v||y!==void 0||n||w===void 0||Math.abs(a.scroll-w)>2){a.scrollLastCalculate=a.scroll,a.ignoreScrollFromMVCPIgnored=!1,a.lastScrollDelta=g;let t=()=>{var t;let n={doMVCP:u!==void 0,scrollVelocity:C};S&&(n.drawDistanceMode=`visible-first`),(t=a.triggerCalculateItemsInView)==null||t.call(a,n),Pl(e,y)};S?(a.mvcpAnchorLock=void 0,a.pendingNativeMVCPAdjust=void 0,a.userScrollAnchorReset={keys:new Set},a.scheduledWork.cancel(`mvcpRecalculate`),(0,Fs.flushSync)(t),Kl(e)):t();let n=!!a.pendingMaintainScrollAtEnd||!!a.props.maintainScrollAtEnd?.onDataChange;b&&n&&(a.pendingMaintainScrollAtEnd=!1,e.doMaintainScrollAtEnd()),a.dataChangeNeedsScrollUpdate=!1,a.lastScrollDelta=0}}function Bu(e,t=!0,n=!0,r=0){let{state:i}=e,a=dl(e,q(e,`scrollAdjustPending`)?i.scrollPending:void 0),o=(!!i.scrollingTo?.animated||!!e.scrollRequestTracker?.cancel())&&t,s=o&&r?Zc(e,a+r):a;Hu(e,!0),i.scrollPending=s;let c=i.ignoreScrollFromMVCP;return q(e,`scrollAdjustPending`)&&(i.ignoreScrollFromMVCP=void 0),zu(e,s,!0,{markHasScrolled:!1}),i.ignoreScrollFromMVCP=c,o&&Vu(e,a,r),n?i.scrollAdjustHandler.commitPendingAdjust():i.scrollAdjustHandler.supersedePendingAdjust(),o}function Vu(e,t=dl(e),n=0){let{state:r}=e,i=r.refScroller.current,a=t+n,o=r.props.horizontal?n?Qc(e,a).x:(i?.getCurrentScrollOffset)?.call(i)??Qc(e,t).x:0;i?.scrollTo({animated:!1,x:o,y:r.props.horizontal?0:a})}function Hu(e,t){var n;let{state:r}=e;(n=e.scrollRequestTracker)==null||n.cancel(),gl(e),Jc(r),r.pendingEndMeasurements=void 0,r.visibleContentAnchor=void 0,t&&Ql(e),Zl(r),Kc(e)}function Uu(e,t=0){return e.state.scrollingTo||e.scrollRequestTracker?.isWaitingToRun()||e.state.initialScroll&&!e.state.didFinishInitialScroll?Bu(e,tc.OS===`web`,!0,t)&&t!==0:(Hu(e,!1),!1)}function Wu(e,t){return t<=0?-1:e>=t?t-1:e<0?0:e}function Gu(e,t){return(t.isScrollToEnd||t.index===e.state.props.data.length-1)&&t.viewPosition===1}function Ku(e,t){let n=t.isScrollToEnd?e.state.props.data.length-1:t.index===void 0?void 0:Wu(t.index,e.state.props.data.length),r=!t.isInitialScroll||e.state.initialScrollSession?.kind===`bootstrap`;return Zc(e,n!==void 0&&(r||Gu(e,t))?bu(e,Wc(e,n),{...t,index:n}):r?bu(e,t.offset,t):t.targetOffset??t.offset-(t.viewOffset||0),t)}function qu(e){if(!e.scrollRequestTracker){let t=0,n,r,i=(i,a=!1)=>{let o=e.state,s=!a&&!!o.scrollingTo?.animated;a||(s&&Bu(e,!1,!1),o.scheduledWork.cancel(`appScrollRearm`),o.pendingEndMeasurements=void 0,o.visibleContentAnchor=void 0,o.userScrollAnchorReset=void 0,gl(e)),o.scheduledWork.cancel(`imperativeScrollReady`);let c=++t;return r=s||r!==void 0?c:void 0,qc(o),o.pendingScrollResolve=i,n=c,J(e,`isScrollActive`,!0),c},a=(i,a,o)=>{let s=e.state;if(i!==t)return;n=void 0;let c=o();r===i&&(r=void 0,c!==!0&&(Vu(e),s.scrollAdjustHandler.commitPendingAdjust())),c===`unreachable`||!c&&s.scrollingTo?Bu(e):c&&s.scrollingTo||(s.pendingScrollResolve===a&&(s.pendingScrollResolve=void 0),Kc(e),vl(e),a())};e.scrollRequestTracker={cancel:()=>{let e=r!==void 0;return t++,n=void 0,r=void 0,e},isCurrent:e=>e===t,isWaitingToRun:()=>n===t&&!!e.state.pendingScrollResolve,runNow:a,runNowIfIdle:t=>{let n=e.state;return n.pendingScrollResolve||n.scrollingTo?Promise.resolve():new Promise(e=>{let n=i(e,!0);a(n,e,t)})},start:i}}return e.scrollRequestTracker}function Ju(e){var t;let n=e.state,r=n.scrollingTo;if(r?.isScrollToEnd&&!r.animated&&!e.scrollRequestTracker?.isWaitingToRun()){let i=Ku(e,r),a=i-(n.lastNativeScroll??n.scroll);(a>1||n.lastNativeScroll===void 0&&a<-1)&&((t=n.refScroller.current)==null||t.scrollTo({animated:!1,...Qc(e,i)}))}}function Yu(e,t){var n;let r=e.state;if(r.isUnmounted)return!1;if(r.isDragging||r.userScrollContentSize!==void 0||((n=r.refScroller.current)?.isScrollInRange)?.call(n)===!1)return yl(e),!1;let{didContainersLayout:i,didFinishInitialScroll:a,pendingNativeMVCPAdjust:o,props:{maintainScrollAtEnd:s}}=r;if((r.scrollingTo?.isInitialScroll||!a&&!r.scrollingTo&&i&&r.initialScrollSession?.kind===`bootstrap`&&!r.initialScrollSession.bootstrap&&r.initialScrollSession.completion)&&s&&!r.endFollowInterrupted&&!e.scrollRequestTracker?.isWaitingToRun()&&nl(r.initialScroll,r.props.data.length))return r.pendingMaintainScrollAtEnd=!0,!1;let c=t?.immediate&&tc.OS===`web`&&!s?.animated,l=q(e,`isWithinMaintainScrollAtEndThreshold`),u=!!r.pendingMaintainScrollAtEnd;if(e.scrollRequestTracker?.isWaitingToRun()||r.scrollingTo&&!r.scrollingTo.isScrollToEnd||r.endFollowInterrupted||!q(e,`isFollowingEnd`)&&!l&&!u&&!r.scrollingTo?.isScrollToEnd||!s||!a)return o?r.pendingMaintainScrollAtEnd=!1:yl(e),!1;if(J(e,`isFollowingEnd`,!0),!r.scrollingTo){let t=r.refScroller.current,n=(t?.getMaxScrollOffset)?.call(t),i=(t?.getCurrentScrollOffset)?.call(t);n!==void 0&&i!==void 0&&n<r.scroll-1&&Math.abs(i-n)<=1&&(r.pendingMaintainScrollAtEnd=!0,r.scrollPending=i,zu(e,i,!0,{markHasScrolled:!1}))}let d=r.props.anchoredEndSpace?.anchorIndex,f=r.props.data.length;if(!i||d!==void 0&&d>=0&&d<f&&!gu(e,d,f-1)||o)return r.pendingMaintainScrollAtEnd=!0,!1;if(r.scrollingTo||r.pendingScrollResolve)return t?.immediate&&!s.animated&&r.scrollingTo?.isScrollToEnd&&!r.scrollingTo.animated?(r.pendingMaintainScrollAtEnd=!1,e.scrollToEnd({animated:!1}),!0):(r.pendingMaintainScrollAtEnd=!0,!1);if(r.pendingMaintainScrollAtEnd=!1,jc(e)<r.scrollLength&&(r.scroll=Zc(e,0)),!r.maintainingScrollAtEnd||c&&(r.maintainingScrollAtEnd===`pending-instant`||r.maintainingScrollAtEnd===`instant`)){let t=s.animated?`pending-animated`:`pending-instant`,n=s.animated?`animated`:`instant`,i=r.scroll;r.maintainingScrollAtEnd=t;let a=()=>{var a;r.maintainingScrollAtEnd===t&&(r.isDragging||r.userScrollContentSize!==void 0||((a=r.refScroller.current)?.isScrollInRange)?.call(a)===!1||!u&&!q(e,`isWithinMaintainScrollAtEndThreshold`)&&tc.OS===`web`&&r.scroll!==i?yl(e):r.scrollingTo||r.pendingScrollResolve?(r.pendingMaintainScrollAtEnd=!0,r.maintainingScrollAtEnd=void 0):(r.maintainingScrollAtEnd=n,qu(e).runNowIfIdle(()=>e.scrollToEnd({animated:s.animated})).then(()=>{r.maintainingScrollAtEnd===n&&!r.scrollingTo&&!r.pendingScrollResolve&&(r.pendingMaintainScrollAtEnd?(r.maintainingScrollAtEnd=void 0,Yu(e)):yl(e))})))};c?a():r.scheduledWork.frame(a,`maintainScrollAtEnd`)}else(r.maintainingScrollAtEnd===`animated`||r.maintainingScrollAtEnd===`instant`||tc.OS===`android`)&&(r.pendingMaintainScrollAtEnd=!0);return!0}function Xu(e){let t=e.state;if(t?.scrollingTo){Gc(t);let n=e.scrollRequestTracker?.isWaitingToRun()?void 0:t.pendingScrollResolve;n&&(t.pendingScrollResolve=void 0);let r=t.scrollingTo;t.scrollHistory.length=0,t.scrollingTo=void 0,t.scrollTargetPinnedRange=void 0,Kc(e),t.pendingTotalSize!==void 0&&ru(e,null,t.pendingTotalSize),t.scrollAdjustHandler.commitPendingAdjust(r);let i=()=>{n?.(),t.pendingMaintainScrollAtEnd&&(t.maintainingScrollAtEnd=void 0,Yu(e,{immediate:!!r.isInitialScroll}))};if(r.isInitialScroll||t.initialScroll){let n=t.initialScrollSession?.kind===`offset`,a=!!r.isInitialScroll&&!t.clearPreservedInitialScrollOnNextFinish&&t.props.data.length>0&&t.initialScroll?.viewPosition===1;$l(e,{onFinished:i,preserveTarget:n&&t.props.data.length===0||a,recalculateItems:!0,schedulePreservedTargetClear:a,syncObservedOffset:n,waitForCompletionFrame:!!r.waitForInitialScrollCompletionFrame});return}Fl(e),i()}}var Zu=20,Qu=1,$u=1,ed=16;function td(e,t){let n=e.state.scrollingTo;(!t?.onlyIfAligned||n?.isInitialScroll&&!n.animated&&od(e,n).isAtResolvedTarget)&&e.state.scheduledWork.frame(()=>sd(e),`checkFinishedScrollFrame`)}function nd(e,t){return!!t?.isInitialScroll&&cl.didDispatchNativeScroll(e)&&!e.hasScrolled}function rd(e){let t=ll.get(e)?.targetOffset;return!e.didFinishInitialScroll&&ll.hasNonZeroTargetOffset(t)}function id(e,t){if(!t.isInitialScroll||t.animated||!e.didContainersLayout||e.initialScrollSession?.kind===`bootstrap`)return!1;let n=t.targetOffset??t.offset;return ll.hasNonZeroTargetOffset(n)&&cl.didDispatchNativeScroll(e)&&!e.hasScrolled||ll.isAtZeroTargetOffset(n)||Math.abs(e.scroll-n)>1||Math.abs(e.scrollPending-n)>1?!1:!!t.waitForInitialScrollCompletionFrame||rd(e)}function ad(e){let{state:t}=e;return!!t.scrollingTo?.isInitialScroll&&t.props.data.length>0&&jc(e)<=t.scrollLength&&t.scrollPending<=$u}function od(e,t){let{state:n}=e,r=t.isInitialScroll,i=r?dl(e,n.scrollPending):n.scrollPending,a=n.scrollAdjustHandler.getAdjust(),o=Ku(e,t),s=Zc(e,i,t),c=Math.abs(i-o),l=o+a,u=Math.abs(i-l),d=!r&&(!t.animated||tc.OS===`ios`);return{clampedTargetOffset:o,isAtResolvedTarget:tc.OS===`web`&&Math.abs(i-s)<1&&(c<1||d&&u<1)}}function sd(e){let t=e.state.scrollingTo;if(!t)return;let{state:n}=e,r=od(e,t);!(t.animated&&!t.isInitialScroll&&Math.abs(r.clampedTargetOffset-(t.targetOffset??t.offset))>1)&&r.isAtResolvedTarget&&(!t.isInitialScroll||n.hasScrolled||r.clampedTargetOffset<=Qu)&&Xu(e)}function cd(e,t,n=!1){var r;(r=e.state.refScroller.current)==null||r.scrollTo({animated:n,...Qc(e,t)})}function ld(e){let t=e.state;if(t.scheduledWork.has(`checkFinishedScrollFallback`))return;let n=t.scrollingTo,r=ad(e),i=nd(t,n),a=n!==void 0&&id(t,n),o=n?.isInitialScroll&&!r&&!a||!t.didContainersLayout||tc.OS!==`web`,s=r||a?0:i?ed:o?500:100,c=0,l=t.scrollPending,u=e=>{t.scheduledWork.timeout(d,e,`checkFinishedScrollFallback`)},d=()=>{let n=t.scrollingTo;if(n){c++;let r=rd(t)&&!t.hasScrolled,a=!i&&r?Zu:5,o=ad(e),s=id(t,n),d=od(e,n),f=tc.OS===`android`,p=t.hasScrolled&&(!n.isInitialScroll||d.isAtResolvedTarget),m=n.isInitialScroll&&!d.isAtResolvedTarget,h=!!(n.animated&&n.isScrollToEnd&&t.maintainingScrollAtEnd===`animated`)&&Math.abs(t.scrollPending-l)>.1;l=t.scrollPending;let g=tc.OS!==`web`;if((h||g)&&!d.isAtResolvedTarget)c=0,u(100);else if(o||p||s||f||c>a)Xu(e);else{if(r||m){let n=ll.get(t),r=d.clampedTargetOffset;n&&(n.targetOffset=r),cd(e,r)}u(i?ed:100)}}};u(s)}var ud=80,dd=1500,fd=320,pd=3,md=50;function hd(e,t){return t.index===void 0?0:e.state.scrollAdjustHandler.getUnsupersededPendingAdjust()}function gd(e,t){let n=e.state,{animated:r,horizontal:i,offset:a}=t;n.scheduledWork.cancel(`platformScrollCompletion`);let o=n.refScroller.current,s=o?.getScrollableNode();if(!o||!s)return;let c=!!r,l=!!i;o.scrollTo({animated:c,...Qc(e,a,l)});let u=()=>{let e=o.getCurrentScrollOffset?.call(o)??NaN;return l?pc(n,e,o.getMaxScrollOffset?.call(o)):e};if(c){let t=Math.max(0,Math.min(a,o.getMaxScrollOffset?.call(o)??a));if(!(Math.abs(u()-t)<=zc)){vd(e,o,u,t);return}}else n.scroll=a;let d=c?void 0:u(),f=n.scrollingTo;n.scheduledWork.frame(()=>{if(f===n.scrollingTo){let t=u(),n=f?Ku(e,f):a,r=Math.max(0,Math.min(n-(f?hd(e,f):0),o.getMaxScrollOffset?.call(o)??1/0));f?.isInitialScroll&&Math.abs(t-n)>zc?ld(e):f&&!f.isInitialScroll&&Math.abs(t-r)>zc?d!==void 0&&Math.abs(d-r)>zc&&f.landingRetryFrom!==void 0&&Math.abs(t-f.landingRetryFrom)<=zc&&Math.abs(r-(f.targetOffset??a))<=zc?e.scrollRequestTracker?.isWaitingToRun()?Xu(e):Bu(e,!1):_d(e,f,t,r):Xu(e)}},`platformScrollCompletion`)}function _d(e,t,n,r){let i=(t.landingRetries??0)+1,a=t.landingRetryFrom===void 0||Math.abs(n-t.landingRetryFrom)>zc,o=i>=pd||!a,{averageSizeSnapshot:s,...c}=t,l=c.index===void 0?void 0:Wu(c.index,e.state.props.data.length);e.scrollTo({...c,animated:!!t.animated&&!o&&Math.abs(r-n)>md,landingRetries:i,landingRetryFrom:n,...l===void 0?{}:{index:l,itemSize:vu(e,l),offset:Wc(e,l)-hd(e,t),precomputedWithViewOffset:!1}})}function vd(e,t,n,r){let i=t.getScrollEventTarget?.call(t),{scheduledWork:a,scrollingTo:o}=e.state;if(!i||!o){Xu(e);return}let s=`onscrollend`in i,c,l=!1,u=setTimeout(()=>f(`max`),dd),d=()=>{l||(l=!0,i.removeEventListener(`scroll`,p),s&&i.removeEventListener(`scrollend`,m),c!==void 0&&clearTimeout(c),clearTimeout(u))},f=i=>{if(l)return;if(o!==e.state.scrollingTo){a.cancel(`platformScrollCompletion`);return}let s=n(),c=Math.max(0,Math.min(Ku(e,o)-hd(e,o),t.getMaxScrollOffset?.call(t)??1/0)),u=Math.abs(s-c)<=zc;u&&Math.abs(r-c)<=zc||o.isInitialScroll?Xu(e):i===`scrollend`&&!u&&Math.abs(s-r)>zc||_d(e,o,s,c)},p=()=>{c!==void 0&&clearTimeout(c),c=setTimeout(()=>f(`idle`),ud)},m=()=>f(`scrollend`);i.addEventListener(`scroll`,p),s?i.addEventListener(`scrollend`,m):c=setTimeout(()=>f(`idle`),fd),a.register(`platformScrollCompletion`,d)}function yd(e){if(Object.keys(e.averageSizes).length===0)return;let t={};for(let n in e.averageSizes)t[n]=e.averageSizes[n].avg;return t}function bd(e,t){let{isInitialScroll:n,requestedOffset:r,targetOffset:i}=t,a=ll.get(e),o=!e.didFinishInitialScroll&&(n||!!a)&&ll.hasNonZeroTargetOffset(i),s=!e.didFinishInitialScroll&&!!a&&ll.isAtZeroTargetOffset(r);o?(e.hasScrolled=!1,ll.set(e,{startScroll:a?.startScroll??e.scroll,targetOffset:i})):s&&ll.clear(e)}function xd(e,t){let n=e.state.positions[t];if(n===void 0)return;let r=vu(e,t)??0;return n+(Number.isFinite(r)?r:0)}function Sd(e,t,n){let r=e.state,i=r.props.data.length,a=0,o=i-1,s;for(;a<=o;){let e=Math.floor((a+o)/2),n=r.positions[e];n!==void 0&&n<=t?(s=e,a=e+1):o=e-1}let c=s??0;for(;c>0&&r.positions[c-1]===r.positions[c];)c--;for(;c<r.props.data.length;c++){let i=r.positions[c];if(i===void 0||i>=n)break;let a=xd(e,c)-e.scrollAxisGap;if(a>t&&a>i)return c}}function Cd(e,t,n){let r=e.state,i=r.props.data.length;if(i===0)return;let a=tu(e,t),o=Math.max(0,a),s=Math.max(o,a+r.scrollLength),c=n===void 0?Sd(e,o,s):Math.max(0,Math.min(i-1,n));if(c===void 0)return;if(n!==void 0&&r.positions[c]===void 0)return{end:c,start:c};for(;c>0;){let e=r.positions[c];if(e===void 0||e<=o||r.positions[c-1]===void 0)break;c--}for(;c>0;){let t=xd(e,c-1);if(t===void 0||t<=o)break;c--}let l=c;for(;l+1<i;){let e=r.positions[l+1];if(e===void 0||e>s)break;l++}return{end:l,start:c}}function wd(e,t){var n;let r=e.state,{noScrollingTo:i,forceScroll:a,...o}=t,{animated:s,isInitialScroll:c,offset:l,precomputedWithViewOffset:u}=o,{props:{horizontal:d}}=r;Gc(r);let f=u?l:bu(e,l,o),p=!!c&&r.initialScrollSession?.kind===`offset`,m=Zc(e,f,o),h=p?f:m;if(r.scrollHistory.length=0,!i){c&&cl.resetFlags(r);let t=yd(r);r.scrollingTo={...o,...t?{averageSizeSnapshot:t}:{},targetOffset:m},c||(r.scrollTargetPinnedRange=Cd(e,m,o.index),r.scrollTargetPinnedRange&&(r.scrollForNextCalculateItemsInView=void 0))}(!s||c)&&(r.scrollPending=m),bd(r,{isInitialScroll:c,requestedOffset:h,targetOffset:m}),!c&&!i&&Math.abs(r.scroll-m)>1&&(s?r.scrollTargetPinnedRange&&((n=r.triggerCalculateItemsInView)==null||n.call(r)):zu(e,m,!0,{markHasScrolled:!1})),a||!c||tc.OS===`android`?gd(e,{animated:s,horizontal:d,offset:h}):r.scroll=m}function Td(e,t){let{forceScroll:n,resolvedOffset:r,target:i,waitForCompletionFrame:a}=t,o=i.index,s=o===void 0?void 0:Wu(o,e.state.props.data.length),c=vu(e,s);wd(e,{animated:!1,clampToContentContainerMinSize:e.state.initialScrollSession?.kind===`offset`||nl(i,e.state.props.data.length),forceScroll:n,index:s!==void 0&&s>=0?s:void 0,isInitialScroll:!0,itemSize:c,offset:r,precomputedWithViewOffset:!0,viewOffset:i.viewOffset,viewPosition:i.viewPosition,viewPositionFallback:i.viewPositionFallback,waitForInitialScrollCompletionFrame:a})}function Ed(e,t,n){let{state:r}=e;r.clearPreservedInitialScrollOnNextFinish=void 0,r.scheduledWork.cancel(`preservedInitialScroll`),r.initialScroll=t,n?.resetDidFinish&&ql(e,{resetInitialScroll:!0}),ul(r,{kind:r.initialScrollSession?.kind===`offset`?`offset`:`bootstrap`})}function Dd(e,t){let n=e.state;if(n.initialScrollSession?.kind===`offset`)return t.contentOffset??0;let r=t.index===void 0?0:Wc(e,t.index),i={...t,clampToContentContainerMinSize:nl(t,n.props.data.length)};return Zc(e,bu(e,r,i),i)}function Od(e,t){let{didFinishInitialScroll:n,queuedInitialLayout:r,scrollingTo:i}=e,a=e.initialScroll,o=!!i?.isInitialScroll,s=!!t?.requiresMeasuredLayout&&!r&&!o;if(!(!a||s||n||i&&!o))return{initialScroll:a,isInitialScrollInProgress:o,queuedInitialLayout:r,scrollingTo:i}}function kd(e,t){let n=e.state,r=Od(n,{requiresMeasuredLayout:!0});if(!r)return!1;let{initialScroll:i,isInitialScrollInProgress:a,queuedInitialLayout:o}=r,s=a?r.scrollingTo:void 0,c=Dd(e,i),l=s?s.targetOffset??s.offset:void 0,u=i.contentOffset===void 0||Math.abs(i.contentOffset-c)>1,d=l!==void 0&&Math.abs(l-c)>1,f=t?.forceScroll&&tc.OS===`web`?dl(e):void 0,p=l!==void 0&&Math.abs(n.scroll-c)<=1&&Math.abs(n.scrollPending-c)<=1&&(f===void 0||Math.abs(f-c)<=1);return!t?.forceScroll&&!u&&a&&!d||t?.forceScroll&&p?!1:(u&&n.initialScrollSession?.kind!==`offset`&&Ed(e,{...i,contentOffset:c}),Td(e,{forceScroll:t?.forceScroll??(!!o||a&&u),resolvedOffset:c,target:i}),!0)}function Ad(e,t){let n=e.state,r=Od(n);if(!r)return!1;let{initialScroll:i,queuedInitialLayout:a}=r,o=i.contentOffset??0,s=Math.abs(n.scroll-o)<=1&&Math.abs(n.scrollPending-o)<=1;if(t?.forceScroll&&s)return!1;let c=!!n.lastLayout&&n.scrollLength>0;return Td(e,{forceScroll:t?.forceScroll??(c||!!a),resolvedOffset:o,target:i}),!0}function jd(e,t){return e.state.initialScrollSession?.kind===`offset`?Ad(e,t):kd(e,t)}function Md(e,t=e.didColumnsChange){let{previousData:n,props:{data:r,keyExtractor:i,maintainScrollAtEnd:a}}=e,o=a?.onDataChange;return!!(!t&&o&&(o!==`append`||n&&r.length>n.length&&n.every((t,n)=>t===r[n]||(i?.(t,n)??n)===nu(e,n))))}function Nd(e,t,n){if(t==null||n==null||t<0||n<t)return!1;let r=!1;for(let i of e.containerItemKeys.keys()){let a=e.indexByKey.get(i);if(a!==void 0&&a>=t&&a<=n){r=!0;let t=nu(e,a);if(t===void 0||!e.sizesKnown.has(t))return!1}}return r}var Pd=1,Fd=8,Id=24,Ld=`LegendList bootstrap initial scroll aborted after exceeding convergence bounds.`;function Rd(e){return e.initialScrollSession?.kind===`bootstrap`?e.initialScrollSession.bootstrap:void 0}function zd(e){return e.initialScrollSession?.kind===`offset`}function Bd(e,t){if(!e||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vd(e){let{dataLength:t,getSize:n,offset:r,positions:i,scrollLength:a,startIndex:o}=e,s=r+a,c=[],l=o===void 0?0:Math.max(0,Math.min(t-1,o));for(;l>0;){let e=l-1,t=i[e];if(t!==void 0&&t+n(e)<=r)break;l=e}for(;l<t;l++){let e=i[l];if(e===void 0)continue;let t=n(l);if(e<s&&e+t>r)c.push(l);else if(c.length>0&&e>=s)break}return c}function Hd(e,t){return t.mountFrameCount>=Fd||t.passCount>=Id?(Lc&&console.warn(Ld),df(e),!0):!1}function Ud(e){let t=Rd(e),n=t?.frameHandle;n!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(n),t&&(t.frameHandle=void 0)}function Wd(e){Ud(e),ul(e,{bootstrap:null})}function Gd(e,t){let n=Rd(e);ul(e,{bootstrap:{frameHandle:n?.frameHandle,mountFrameCount:n?.mountFrameCount??0,passCount:0,previousResolvedOffset:void 0,scroll:t.scroll,seedContentOffset:t.seedContentOffset??t.scroll,targetIndexSeed:t.targetIndexSeed,visibleIndices:void 0},kind:`bootstrap`})}function Kd(e){requestAnimationFrame(()=>{var t;!e.isUnmounted&&Rd(e)&&((t=e.triggerCalculateItemsInView)==null||t.call(e,{forceFullItemPositions:!0}))})}function qd(e){let t=e.state,n=Rd(t);n&&n.frameHandle===void 0&&(n.frameHandle=requestAnimationFrame(()=>{let n=Rd(t);!t.isUnmounted&&n&&(n.frameHandle=void 0,n.mountFrameCount+=1,!Hd(e,n)&&qd(e))}))}function Jd(e,t){let n=e.state,r=Rd(n);r?(r.passCount=0,r.previousResolvedOffset=void 0,r.scroll=t.scroll,r.seedContentOffset=t.seedContentOffset??r.seedContentOffset,r.targetIndexSeed=t.targetIndexSeed??r.targetIndexSeed,r.visibleIndices=void 0):Gd(n,t),qd(e),Kd(n)}function Yd(e){let{dataLength:t,footerSize:n,index:r,preserveForFooterLayout:i,stylePaddingEnd:a}=e;return{contentOffset:void 0,index:r??Math.max(0,t-1),preserveForBottomPadding:!0,preserveForFooterLayout:i,viewOffset:tl(a,n),viewPosition:1}}function Xd(e){return!!(e&&e.viewPosition===1&&(e.preserveForBottomPadding||e.preserveForFooterLayout))}function Zd(e,t){return e.index===t.index&&e.preserveForBottomPadding===t.preserveForBottomPadding&&e.preserveForFooterLayout===t.preserveForFooterLayout&&e.viewOffset===t.viewOffset&&e.viewPosition===t.viewPosition&&e.viewPositionFallback===t.viewPositionFallback}function Qd(e,t){let{dataLength:n,stylePaddingEnd:r,target:i}=t;i.preserveForFooterLayout&&Ed(e,Yd({dataLength:n,footerSize:q(e,`footerSize`)||0,stylePaddingEnd:r}))}function $d(e,t){let n=e.state;if(!n.didFinishInitialScroll)return!1;let r=ef(n);return Math.abs(r-Dd(e,t))>Pd}function ef(e){var t,n;let r=((t=e.refScroller.current)?.getCurrentScrollOffset)?.call(t);return typeof r==`number`&&Number.isFinite(r)?e.props.horizontal?pc(e,r,((n=e.refScroller.current)?.getMaxScrollOffset)?.call(n)):r:e.scrollPending}function tf(e){let t=e.state,n=t.initialScroll;if(!t.didFinishInitialScroll||t.scrollingTo||t.pendingScrollResolve||t.maintainingScrollAtEnd||t.isDragging||!n||n.viewPosition!==1||t.props.data.length===0||n.index!==void 0&&n.index>=t.props.data.length||zd(t))return;let r=ef(t);return Dd(e,n)-r}function nf(e){if(tf(e)===void 0)return!1;let t=e.state,n={};t.preservedEndAnchorCorrection=n;let r=()=>{var i;if(t.preservedEndAnchorCorrection!==n)return;let a=tf(e);t.isUnmounted||a===void 0||Math.abs(a)<=Pd?t.preservedEndAnchorCorrection=void 0:(!n.lastRequestTime||(t.lastNativeScrollTime,n.lastRequestTime),n.lastRequestTime=Date.now(),gd(e,{animated:!1,horizontal:t.props.horizontal,offset:Dd(e,t.initialScroll)}),(i=t.triggerCalculateItemsInView)==null||i.call(t),requestAnimationFrame(r))};return queueMicrotask(r),!0}function rf(e,t=!1){let n=e.state,r=n.initialScroll;!n.didFinishInitialScroll||n.scrollingTo?.isInitialScroll||r?.viewPosition!==1||n.preservedEndAnchorCorrection&&!t||$d(e,r)&&(Xd(r)&&q(e,`isAtEnd`)||(n.preservedEndAnchorCorrection=void 0,r.preserveForFooterLayout?Qd(e,{dataLength:n.props.data.length,stylePaddingEnd:lc(n.props),target:r}):Zl(n)))}function af(e,t){let{initialScrollAtEnd:n,target:r}=t,i=e.state,a=Dd(e,r),o=a===0&&!n&&(zd(i)?Math.abs(r.contentOffset??0)<=1:r.index===0&&(r.viewPosition??0)===0&&Math.abs(r.viewOffset??0)<=1),s=i.props.data.length===0&&r.index!==void 0;o||s?(Wd(i),$l(e,{preserveTarget:!o,resolvedOffset:a})):(Gd(i,{scroll:a,seedContentOffset:0,targetIndexSeed:r.index}),qd(e))}function of(e,t){let{dataLength:n,didDataChange:r,initialScrollAtEnd:i,previousDataLength:a,stylePaddingEnd:o}=t,s=e.state,c=s.initialScroll;if(zd(s)||!c)return;let l=!!(s.didFinishInitialScroll&&a===0&&n>0&&c.index!==void 0),u=Rd(s);if(r&&n>0&&s.didFinishInitialScroll&&!u&&!l&&!s.scrollingTo?.isInitialScroll&&(!i||Md(s))){Zl(s);return}let d=n>0&&(i||Xd(c));if(!r&&!l&&!d)return;let f=t=>{Ed(e,t,{resetDidFinish:l}),Jd(e,{scroll:Dd(e,t),seedContentOffset:l&&!u?ef(s):void 0,targetIndexSeed:t.index})};if(d){let t=i?Yd({dataLength:n,footerSize:q(e,`footerSize`)||0,preserveForFooterLayout:!!c.preserveForFooterLayout,stylePaddingEnd:o}):{...c,contentOffset:void 0,preserveForBottomPadding:!0,preserveForFooterLayout:!!c.preserveForFooterLayout,viewOffset:tl(o,nl(c,n)&&q(e,`footerSize`)||0),viewPosition:1};if(!l&&$d(e,c)){Qd(e,{dataLength:n,stylePaddingEnd:o,target:c});return}if(!Zd(c,t)||u||l||r){f(t);return}}r&&(u||a===0&&n>0)&&f(c)}function sf(e,t){let{dataLength:n,footerSize:r,initialScrollAtEnd:i,stylePaddingEnd:a}=t,o=e.state,s=o.initialScroll;if(!i&&!nl(s,n)||zd(o)||n===0||!s)return;let c=Rd(o),l=!!o.scrollingTo?.isInitialScroll&&!c;if(l||c||s.preserveForFooterLayout){if($d(e,s))Qd(e,{dataLength:n,stylePaddingEnd:a,target:s});else{let t=Yd({dataLength:n,footerSize:r,index:i?void 0:s.index,preserveForFooterLayout:!!s.preserveForFooterLayout,stylePaddingEnd:a}),c=s.index!==t.index||s.viewPosition!==t.viewPosition||s.viewPositionFallback!==t.viewPositionFallback||s.viewOffset!==t.viewOffset;l?(Ed(e,t),jd(e,{forceScroll:!0})):c?(Ed(e,t,{resetDidFinish:!!o.didFinishInitialScroll}),Jd(e,{scroll:Dd(e,t),targetIndexSeed:t.index})):Qd(e,{dataLength:n,stylePaddingEnd:a,target:s})}}}function cf(e){let t=e.state,n=t.initialScroll,r=Rd(t);if(n&&t.props.data.length>0&&!zd(t)&&(r||n.viewPosition===1)){let i=Dd(e,n),a=t.scrollingTo?.isInitialScroll?t.scrollingTo:void 0;if(!r&&(a||t.didFinishInitialScroll)){let r=i-(a?a.targetOffset??a.offset:ef(t));Math.abs(r)>Pd&&(t.didFinishInitialScroll?nf(e):a&&(t.initialScroll={...n,contentOffset:i},Td(e,{forceScroll:!0,resolvedOffset:i,target:t.initialScroll})))}else Jd(e,{scroll:i,targetIndexSeed:n.index})}}function lf(e){let t=e.state,n=Rd(t),r=t.initialScroll;if(t.isUnmounted||!n||!r||t.scrollingTo?.isInitialScroll||(n.passCount+=1,Hd(e,n)))return;r.index!==void 0&&t.startBuffered>=0&&t.endBuffered>=0&&r.index>=t.startBuffered&&r.index<=t.endBuffered&&(n.targetIndexSeed=void 0);let i=Dd(e,r),a=Nd(t,t.startBuffered,t.endBuffered),o=Math.abs(n.scroll-i)>1,{data:s}=t.props,c=Vd({dataLength:s.length,getSize:n=>{let r=t.idCache[n]??nu(t,n);return t.sizes.get(r)??_u(e,r,n,s[n])},offset:i,positions:t.positions,scrollLength:t.scrollLength,startIndex:n.targetIndexSeed??(t.startBuffered>=0?t.startBuffered:void 0)}),l=c.length>0&&c.every(e=>{let n=t.idCache[e]??nu(t,e);return t.sizesKnown.has(n)}),u=n.previousResolvedOffset,d=n.visibleIndices;n.previousResolvedOffset=i,n.visibleIndices=c,o?(n.scroll=i,Kd(t)):a&&l&&(u!==void 0&&Math.abs(u-i)<=Pd&&Bd(d,c)?(Wd(t),Td(e,{forceScroll:!0,resolvedOffset:i,target:r,waitForCompletionFrame:tc.OS===`web`})):Kd(t))}function uf(e,t){let n=e.state;Wd(n);let r=!n.clearPreservedInitialScrollOnNextFinish&&n.props.data.length>0&&n.initialScroll?.viewPosition===1;$l(e,{preserveTarget:r,recalculateItems:!0,resolvedOffset:t,schedulePreservedTargetClear:r})}function df(e){let t=e.state,n=Rd(t),r=t.initialScroll;n&&r&&t.refScroller.current?(Wd(t),Td(e,{forceScroll:!0,resolvedOffset:n.scroll,target:r,waitForCompletionFrame:tc.OS===`web`})):uf(e,n?.scroll??t.scrollPending)}var ff=new WeakMap;function pf(e){return ff.get(e)}function mf(e,t){ff.set(e,t)}function hf(e,t,n,r){return{data:e.props.data,dataChangeEpoch:e.dataChangeEpoch,getFixedItemSize:e.props.getFixedItemSize,getItemType:e.props.getItemType,itemData:n,itemIndex:t,itemType:r}}function gf(e,t,n,r,i){let{getItemType:a}=e.props,o=e.containerItemMetadata.get(t);if(o?.dataChangeEpoch===e.dataChangeEpoch&&o.getItemType===a&&o.itemData===r&&o.itemIndex===n)return o;let s=hf(e,n,r,a?a(r,n)??``:void 0);return e.containerItemMetadata.set(t,s),s}function _f(e,t,n,r){let{getFixedItemSize:i}=e.props,a=gf(e,t,n,r);return a.getFixedItemSize!==i&&(a.didResolveFixedItemSize=!1,a.fixedItemSize=void 0,a.getFixedItemSize=i),i&&!a.didResolveFixedItemSize&&(a.fixedItemSize=i(r,n,a.itemType??``),a.didResolveFixedItemSize=!0),a}function vf(e){var t;for(let t of e.fixedItemSizeKeys??[])e.sizesKnown.delete(t);(t=e.fixedItemSizeKeys)==null||t.clear();let{data:n,getFixedItemSize:r,getItemType:i}=e.props;if(r)for(let t=0;t<n.length;t++){let a=nu(e,t),o=n[t];e.sizesKnown.has(a)&&r(o,t,i?i(o,t)??``:``)!==void 0&&e.sizesKnown.delete(a)}for(let t of e.containerItemMetadata.values())t.didResolveFixedItemSize=!1,t.fixedItemSize=void 0}function yf(e){e.positionsAreCurrent=!1,e.indexByKey.clear(),e.idCache.length=0,e.positions.length=0,e.columns.length=0,e.columnSpans.length=0}function bf(e,t,n){let r=e.state,i=q(e,`numColumns`),a=t;r.columns[t]!==1&&(a=xf(r,i,t));let o=0,s=r.columns[a];if(a>0){let t=a-1;o=(r.positions[t]??0)+Sf(e,xf(r,i,t),t,n)}return{column:s,currentRowTop:o,startIndex:a}}function xf(e,t,n){if(t<=1)return Math.max(0,n);let r=Math.max(0,n);for(;r>0&&e.columns[r]!==1;)r--;return r}function Sf(e,t,n,r){let i=e.state;if(n<t)return 0;let{data:a}=i.props;if(!a)return 0;let o=0;for(let s=t;s<=n;s++){if(s<0||s>=a.length)continue;let t=i.idCache[s],n=_u(e,t,s,a[s],r);n>o&&(o=n)}return o}function Cf(e){let t=e.state,{positions:n,props:{data:r}}=t,i=q(e,`numColumns`)??1;if(r.length===0)ru(e,null,0);else{let a=r.length-1,o=nu(t,a),s=n[a];if(o!==void 0&&s!==void 0){if(i>1){let n=a;for(;n>0;){let e=t.columns[n];if(e===1||e===void 0)break;--n}let i=0;for(let o=n;o<=a;o++){let n=_u(e,t.idCache[o]??nu(t,o),o,r[o]);n>i&&(i=n)}ru(e,null,s+i)}else{let t=_u(e,o,a,r[a]);t!==void 0&&ru(e,null,s+t)}}}}function wf(e){let t=e.state,{props:{snapToIndices:n}}=t,r=t.props.horizontal?jc(e,!1):void 0,i=Array(n.length);for(let e=0;e<n.length;e++){let a=n[e];nu(t,a);let o=t.positions[a];i[e]=fc(t,o,r)}J(e,`snapToOffsets`,i)}function Tf(e,t,{doMVCP:n,forceFullUpdate:r=!1,optimizeForVisibleWindow:i=!1,scrollBottomBuffered:a,scrollVelocity:o,startIndex:s}={doMVCP:!1,forceFullUpdate:!1,optimizeForVisibleWindow:!1,scrollBottomBuffered:-1,startIndex:0}){let c=e.state,l=e.positionListeners.size>0,{columns:u,columnSpans:d,indexByKey:f,positions:p,idCache:m,sizesKnown:h,props:{data:g,overrideItemLayout:_,snapToIndices:v},scrollingTo:y}=c,b=y?.index,x=g.length;y?.isScrollToEnd&&(y.index=x-1);let S=q(e,`numColumns`)??1,C=S>1,w=!n||!c.didContainersLayout&&Object.keys(c.averageSizes).length===0;if(c.positionsAreCurrent&&!t&&!r&&c.positionRecalculationStartIndex===void 0&&!y&&!C&&!v&&p.length===x&&w)return;c.positionsAreCurrent=!1;let T=Lc?new Map:void 0,E=q(e,`extraData`),D=_?{span:1}:void 0,O=c.lastScrollDelta,k=o??Iu(c),A=!r&&!t&&(i||Math.abs(k)>0||c.scrollLength>0&&O>c.scrollLength),j=a+1e3,M=!!c.visibleContentAnchor||!n||t||c.scrollAdjustHandler.getAdjust()!==0||(q(e,`scrollAdjustPending`)??0)!==0,N=0,P=1,F=0;if(s=Math.max(0,s),t&&(d.length=0),C||(u.length&&=0,d.length&&=0),s>0){if(C){let{startIndex:t,currentRowTop:n}=bf(e,s,!0);s=t,N=n}else if(s<x){let t=s-1,n=nu(c,t);N=(p[t]??0)+(h.get(n)??_u(e,n,t,g[t],!0,M,!1))}}let I=t||f.size===0,ee=C&&!!_&&!!D,L=!1,R;for(let n=s;n<x;n++){if(A&&R!==void 0&&n>R){L=!0;break}A&&R===void 0&&!y&&!t&&N>j&&(R=n+(C?S:1)+10);let r=m[n]??nu(c,n),i=1;if(ee){D.span=1,_(D,g[n],n,S,E);let e=D.span;e!==void 0&&Number.isFinite(e)&&(i=Math.max(1,Math.min(S,Math.round(e))))}C&&P+i-1>S&&(N+=F,P=1,F=0);let a=h.get(r),o=a===void 0?_u(e,r,n,g[n],!0,M,!1):a;Lc&&I&&(T.has(r)&&console.error(`[legend-list] Error: Detected overlapping key (${r}) which causes missing items and gaps and other terrrible things. Check that keyExtractor returns unique values.`),T.set(r,n)),N!==p[n]&&(p[n]=N,l&&Ec(e,r,N)),I&&(f.set(r,n),y?.key!==void 0&&y.key===r&&(y.index=n)),C?(u[n]=P,d[n]=i,o>F&&(F=o),P+=i,P>S&&(N+=F,P=1,F=0)):N+=o}L||(Cf(e),c.positionsAreCurrent=!C,s<=(c.positionRecalculationStartIndex??-1)&&(c.positionRecalculationStartIndex=void 0)),y&&(y.isScrollToEnd&&x===0||y.key!==void 0&&!f.has(y.key)||!y.isInitialScroll&&!y.isScrollToEnd&&y.index!==void 0&&y.index>=x)?e.scrollRequestTracker?.isWaitingToRun()?Xu(e):Bu(e):y&&(y.isScrollToEnd||y.key!==void 0)&&y.index!==b&&c.scheduledWork.microtask(()=>{if(c.scrollingTo!==y)return;let t=y.index;wd(e,{...y,itemSize:vu(e,t),offset:Wc(e,t)})},`scrollTargetRetarget`),v&&wf(e)}function Ef(e){let t=e.state,n=t.initialScroll;return t.didFinishInitialScroll?nf(e):!n||t.initialScrollSession?.kind===`offset`||n.viewPosition!==1||t.props.data.length===0?!1:jd(e,{forceScroll:!0})}function Df(e){if(!e.state.initialScroll)return;let t=()=>jd(e,{forceScroll:!0});t(),e.state.initialScrollSession?.kind!==`offset`&&requestAnimationFrame(t),td(e,{onlyIfAligned:!0})}function Of(e,t){let{alwaysDispatchInitialScroll:n,dataLength:r,hasFooterComponent:i,initialContentOffset:a,initialScrollAtEnd:o,useBootstrapInitialScroll:s}=t,c=e.state,l=c.initialScroll,u=a??0,d=s&&o&&i;l&&(l.contentOffset===void 0||!!l.preserveForFooterLayout!==d&&c.initialScrollSession?.kind!==`offset`)&&Ed(e,{...l,contentOffset:u,preserveForFooterLayout:d}),s&&l&&c.initialScrollSession?.kind!==`offset`?af(e,{initialScrollAtEnd:o,target:c.initialScroll}):n||u||l&&r===0&&(u!==0||o)||(l&&!o?$l(e,{resolvedOffset:u}):Jl(e,{didInitialScroll:!0}))}function kf(e,t){let{dataLength:n,didDataChange:r,didStartFreshData:i,initialScrollAtEnd:a,latestInitialScroll:o,latestInitialScrollSessionKind:s,stylePaddingEnd:c,useBootstrapInitialScroll:l}=t,u=e.state,d=u.initialScrollSession?.previousDataLength??0,f=n>0&&(!u.hasHadNonEmptyData||i);if(i&&(Jc(u),Kc(e),u.endFollowInterrupted=!1,u.userScrollContentSize=void 0,u.visibleContentAnchor=void 0,u.pendingEndMeasurements=void 0,J(e,`isFollowingEnd`,!1),u.maintainingScrollAtEnd=void 0,u.pendingMaintainScrollAtEnd=!1),n>0&&(u.hasHadNonEmptyData=!0),f&&(o?(Ed(e,o),ul(u,{kind:s,previousDataLength:d})):Zl(u)),u.initialScrollSession&&(u.initialScrollSession.previousDataLength=n),ul(u),l){i&&!u.didColumnsChange&&(yf(u),Tf(e,!0)),of(e,{dataLength:n,didDataChange:r,initialScrollAtEnd:a,previousDataLength:i?0:d,stylePaddingEnd:c});return}let p=d===0&&n>0&&!!u.initialScroll&&e.state.initialScrollSession?.kind===`offset`&&!!u.didFinishInitialScroll;d===0&&n!==0&&u.initialScroll&&u.queuedInitialLayout&&(!u.didFinishInitialScroll||p)&&(p&&ql(e,{resetInitialScroll:!0}),jd(e))}function Af(e){let t=e.pendingContainerIds;if(e.pendingContainerIds=void 0,t===void 0)return;let n=e.state,r=t;if(r&&n.userScrollAnchorReset?.keys.size){r=new Set(r);for(let e of n.userScrollAnchorReset.keys){let t=n.containerItemKeys.get(e);t!==void 0&&r.add(t)}}return r}function jf(e,t){let n=e.pendingContainerIds!==void 0,r=e.pendingContainerIds;if(t===void 0)e.pendingContainerIds=null;else if(r!==null){let n=r;if(!n)n=typeof t==`number`?new Set([t]):new Set(t);else if(typeof t==`number`)n.add(t);else for(let e of t)n.add(e);e.pendingContainerIds=n}n||J(e,`containerLayoutEpoch`,(q(e,`containerLayoutEpoch`)??0)+1)}function Mf(e,t,n,r){let i=e.state,{columns:a,columnSpans:o,positions:s,props:{data:c,itemsAreEqual:l,keyExtractor:u}}=i,d=c[n];if(d===void 0)return{didChangePosition:!1,didRefreshData:!1};let f=i.idCache[n]??nu(i,n),p=gf(i,t,n,d),m=r?.updateLayout??!0,h=!1,g=!1;if(m){let c=s[n];if(c===void 0)return J(e,`containerPosition${t}`,Rc),{didChangePosition:!1,didRefreshData:!1};let l=dc(i,(c||0)-(r?.scrollAdjustPending??0),i.sizes.get(f)??_u(e,f,n,d,void 0,void 0,void 0,p),q(e,`totalSize`)),u=a[n]||1,m=o[n]||1,g=q(e,`containerPosition${t}`),_=q(e,`containerColumn${t}`),v=q(e,`containerSpan${t}`);l>Rc&&l!==g&&(J(e,`containerPosition${t}`,l),h=!0),u>=0&&u!==_&&J(e,`containerColumn${t}`,u),m!==v&&J(e,`containerSpan${t}`,m)}q(e,`containerItemIndex${t}`)!==n&&J(e,`containerItemIndex${t}`,n);let _=q(e,`containerItemData${t}`),v=()=>{J(e,`containerItemData${t}`,d),g=!0};if(_!==d){let r=(i.pendingDataComparison?.previousData===i.previousData&&i.pendingDataComparison?.nextData===c?i.pendingDataComparison:void 0)?.byIndex[n]??0;if(r===2)v();else if(r!==1){let r=q(e,`containerItemKey${t}`)??f,a=u?.(_,n);if(_===void 0||!u||a!==r)v();else if(!l)v();else{let e=l(_,d,n,c);(!i.pendingDataComparison||i.pendingDataComparison.previousData!==i.previousData||i.pendingDataComparison.nextData!==c)&&i.previousData&&(i.pendingDataComparison={byIndex:[],nextData:c,previousData:i.previousData}),i.pendingDataComparison?.byIndex&&(i.pendingDataComparison.byIndex[n]=e?1:2),e||v()}}}return{didChangePosition:h,didRefreshData:g}}function Nf(e,t){let n=e.mapViewabilityConfigStates;n||(n=new Map,e.mapViewabilityConfigStates=n);let r=n.get(t);return r||(r={end:-1,endBuffered:-1,previousEnd:-1,previousStart:-1,start:-1,startBuffered:-1,viewableItems:[]},n.set(t,r)),r}function Pf(e){let{viewabilityConfig:t,viewabilityConfigCallbackPairs:n,onViewableItemsChanged:r}=e;return(t||r)&&(n=[...n||[],{onViewableItemsChanged:r,viewabilityConfig:t||{viewAreaCoveragePercentThreshold:0}}]),n}function Ff(e,t,n,r,i,a,o=i,s=a){let{props:{data:c}}=e;for(let l of n){let n=Nf(t,l.viewabilityConfig.id);n.start=i,n.end=a,n.startBuffered=o,n.endBuffered=s,l.viewabilityConfig.minimumViewTime?e.scheduledWork.timeout(()=>If(c,l,e,t,r),l.viewabilityConfig.minimumViewTime):If(c,l,e,t,r)}}function If(e,t,n,r,i){let{viewabilityConfig:a,onViewableItemsChanged:o}=t,s=a.id,c=Nf(r,s),{viewableItems:l,start:u,end:d,startBuffered:f,endBuffered:p}=c,m;for(let[e,t]of r.mapViewabilityAmountValues)Rf(n,r,a,e,t.key,i,t.item,t.index).sizeVisible<0&&(m??=[],m.push(e));let h=[],g=new Set;if(l)for(let t of l){g.add(t.key);let o=n.indexByKey.get(t.key),s=o===void 0?void 0:e[o],c=pu(r,t.key),l=!1;o!==void 0&&s!==void 0&&(l=zf(n,r,a,c,t.key,i,s,o)),l||h.push({...t,index:o??t.index,isViewable:!1,item:s??t.item})}let _=[];for(let t=u;t<=d;t++){let o=e[t];if(o){let e=nu(n,t),s=pu(r,e);if(zf(n,r,a,s,e,i,o,t)){let n={containerId:s,index:t,isViewable:!0,item:o,key:e};_.push(n),g.has(n.key)||h.push(n)}}}if(Object.assign(c,{previousEnd:d,previousStart:u,viewableItems:_}),h.length>0){c.viewableItems=_;for(let e=0;e<h.length;e++){let t=h[e];Bf(r,s,t.containerId,t)}o&&o({changed:h,end:d,endBuffered:p,start:u,startBuffered:f,viewableItems:_})}if(m)for(let e of m){let t=r.mapViewabilityAmountValues.get(e);t&&t.sizeVisible<0&&r.mapViewabilityAmountValues.delete(e)}}function Lf(e,t){return!!e&&e.containerId===t.containerId&&e.index===t.index&&e.isViewable===t.isViewable&&e.item===t.item&&e.key===t.key&&e.percentOfScroller===t.percentOfScroller&&e.percentVisible===t.percentVisible&&e.scrollSize===t.scrollSize&&e.size===t.size&&e.sizeVisible===t.sizeVisible}function Rf(e,t,n,r,i,a,o,s){a=Math.max(0,a-(e.viewabilityInsetEnd??0));let{sizes:c,scroll:l}=e,u=eu(t),{itemVisiblePercentThreshold:d,viewAreaCoveragePercentThreshold:f}=n,p=f!=null,m=p?f:d,h=l-u,g=e.positions[s],_=c.get(i)||0;if(g===void 0){let e={containerId:r,index:s,isViewable:!1,item:o,key:i,percentOfScroller:0,percentVisible:0,scrollSize:a,size:_,sizeVisible:-1};if(!Lf(t.mapViewabilityAmountValues.get(r),e)){t.mapViewabilityAmountValues.set(r,e);let n=t.mapViewabilityAmountCallbacks.get(r);n&&n(e)}return e}let v=g-h,y=v+_,b=v>=0&&y<=a&&y>v,x=b?_:Math.min(y,a)-Math.max(v,0),S=_?b?100:x/_*100:0,C=_&&a>0?x/a*100:0,w={containerId:r,index:s,isViewable:a>0&&(b?100:p?C:S)>=m,item:o,key:i,percentOfScroller:C,percentVisible:S,scrollSize:a,size:_,sizeVisible:x};if(!Lf(t.mapViewabilityAmountValues.get(r),w)){t.mapViewabilityAmountValues.set(r,w);let e=t.mapViewabilityAmountCallbacks.get(r);e&&e(w)}return w}function zf(e,t,n,r,i,a,o,s){let c=t.mapViewabilityAmountValues.get(r);return c&&c.key===i&&c.index===s||(c=Rf(e,t,n,r,i,a,o,s)),c.isViewable}function Bf(e,t,n,r){let i=n+t;e.mapViewabilityValues.set(i,r),e.mapViewabilityCallbacks.get(i)?.(r)}var Vf=Fs.unstable_batchedUpdates,Hf=typeof Vf==`function`?Vf:e=>e(),Uf=32,Wf=64,Gf=3;function Kf(e,t){if(e<=0||t<=0)return 0;let n=Math.ceil(t*Gf),r=t+Wf;return Math.min(Math.max(e,t),Math.max(t,Math.min(n,r),Math.min(e,Uf)))}function qf(e,t){return e<=0||t<=0?0:Math.min(Math.max(e,t),Math.max(t,Math.ceil(t*1.5)))}function Jf(e,t,n,r,i,a,o=!1){let s=t.length;if(s===0)return[];let c=q(e,`numContainers`),l=e.state,{containerItemMetadata:u,stickyContainerPool:d}=l,{data:f,getItemType:p}=l.props,m=!!p,h=l.props.recycleItems&&!!l.props.positionComponentInternal,g=i.length>0?new Set(i):void 0,_=Array(s),v=[],y=[];for(let e=0;e<s;e++){let i=t[e],a=p?.(f[i],i),s={isBuffered:i>=n&&i<=r,isSticky:l.props.stickyHeaderIndicesSet.has(i),itemIndex:i,itemType:m?a===void 0?``:String(a):void 0,order:e,renderPriority:o?-i:i};_[e]=s,(s.isSticky?y:v).push(s)}let b=[],x=[];for(let t=0;t<c;t++){let i=q(e,`containerItemKey${t}`),o=!!g?.has(t);if(!(i&&a?.has(i)&&l.indexByKey.has(i))){if(d.has(t))(i===void 0||o)&&x.push({containerIndex:t,distance:1/0});else if(i===void 0||o)b.push({containerIndex:t,distance:o||!l.props.recycleItems?1/0:0});else if(!h){let e=l.indexByKey.get(i);if(e!==void 0&&(e<n||e>r)){let i=e<n?n-e:e-r;b.push({containerIndex:t,distance:i})}}}}b.sort(Yf);let S=Array(s),C=c,w=!1,T=(e,t)=>{S[e.order]={containerIndex:t,itemIndex:e.itemIndex,itemType:e.itemType},g?.delete(t)&&(w=!0)},E=(e,t,n)=>{for(let r of e){if(S[r.order])continue;let e=t.findIndex(e=>n(u.get(e.containerIndex)?.itemType,r.itemType));if(e!==-1){let[n]=t.splice(e,1);T(r,n.containerIndex)}}},D=(e,t,n)=>{m&&E(e,t,(e,t)=>t!==void 0&&e===t),E(e,t,e=>e===void 0),n&&E(e,t,()=>!0)};D(v,b,!0),D(y,x,!1);for(let e of _){if(S[e.order])continue;let t=C++;e.isSticky&&d.add(t),T(e,t)}if(v.length>1||y.length>1){let e=[];Qf(v,S,e,m),Qf(y,S,e,m)}if(w&&(i.length=0,g))for(let e of g)i.push(e);if(Lc){let t=q(e,`numContainersPooled`)??1/0;C>t&&console.warn(`[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize.`,{debugInfo:{numContainers:c,numContainersPooled:t,numNeeded:s,stillNeeded:C-c}})}return S}function Yf(e,t){return t.distance-e.distance}function Xf(e,t){return Number(t.isBuffered)-Number(e.isBuffered)||e.renderPriority-t.renderPriority}function Zf(e,t){return e-t}function Qf(e,t,n,r){if(e.length>=2){if(r){let r=new Map;for(let t of e){let e=r.get(t.itemType);e?e.push(t):r.set(t.itemType,[t])}for(let e of r.values())Qf(e,t,n,!1)}else{n.length=0;let r=!0;for(let i=0;i<e.length;i++){let a=t[e[i].order].containerIndex;i>0&&a<n[i-1]&&(r=!1),n.push(a)}r||n.sort(Zf),e.sort(Xf);for(let r=0;r<e.length;r++)t[e[r].order].containerIndex=n[r]}}}function $f(e){let t=e.state;t.queuedInitialLayout=!0,Pl(e),Jl(e,{didLayout:!0}),t.pendingMaintainScrollAtEnd&&Yu(e)}var ep=4,tp=100;function np(e,t){if(t<=0)return 0;let n=Math.min(1,Math.abs(e)/ep);return Math.sign(e)*t*n}function rp(e){let t=e.state;t.scheduledWork.timeout(()=>{var e;t.scrollHistory.length=0,(e=t.triggerCalculateItemsInView)==null||e.call(t)},tp,`renderRangeProjection`)}function ip(e,t,n){let r=n.positions;for(let n=e.length-1;n>=0;n--){let i=r[e[n]];if(i!==void 0&&t>=i)return n}return-1}function ap(e,t){let n=e.state,r=!1;for(let i of n.stickyContainerPool){let a=q(e,`containerItemKey${i}`);if((a?n.indexByKey.get(a):void 0)===t){r=!0;break}}return r}function op(e,t,n,r,i,a,o){let s=e.state;J(e,`activeStickyIndex`,n>=0?t[n]:-1);for(let c=0;c<=1;c++){let l=n-c;if(l<0)continue;let u=t[l];if(ap(e,u))continue;let d=s.idCache[u]??nu(s,u);d&&!s.containerItemKeys.has(d)&&(u<a||u>o)&&!i.has(u)&&(i.add(u),r.push(u))}}function sp(e,t,n,r,i,a,o){let s=e.state;for(let c of s.stickyContainerPool){let l=q(e,`containerItemKey${c}`),u=l?s.indexByKey.get(l):void 0;if(u===void 0||o(u))continue;let d=t.indexOf(u);if(d===-1){s.stickyContainerPool.delete(c),J(e,`containerSticky${c}`,!1);continue}if(d>=i-1&&d<=i+1)continue;let f=t[d+1],p=!1;if(f){let e=s.positions[f];p=e!==void 0&&n>e+r*2}else{let t=s.idCache[u]??nu(s,u);if(t){let i=s.positions[u],a=s.sizes.get(t)??_u(e,t,u,s.props.data[u]);p=i!==void 0&&n>i+a+r*3}}p&&a.push(c)}}function cp(e,t,n,r,i,a){let o=!1;return e.startNoBuffer===null&&n+r>i&&n<=a&&(e.startNoBuffer=t),e.firstFullyOnScreenIndex===void 0&&n>=i-10&&n<=a&&(e.firstFullyOnScreenIndex=t),e.startNoBuffer!==null&&(n<=a?e.endNoBuffer=t:o=!0),o}function lp(e,t){let n=[],r=t.firstFullyOnScreenIndex??t.startNoBuffer;if(r!=null&&t.endNoBuffer!==null)for(let i=r;i<=t.endNoBuffer;i++){let t=e.idCache[i]??nu(e,i);n.push(t)}return n}function up(e,t){let n=e.props.onFirstVisibleItemChanged;if(!n||t===null||t<0||t>=e.props.data.length)return;let r=e.idCache[t]??nu(e,t),i=e.lastFirstVisibleItemCallback;(i?.index!==t||i.key!==r)&&(e.lastFirstVisibleItemCallback={index:t,key:r},n({index:t,item:e.props.data[t],key:r}))}function dp(e,t,n,r,i){let a=e.state,{endBuffered:o,idCache:s,positions:c,props:{data:l},sizes:u,startBuffered:d}=a;if(d===null||o===null||d<0||o<d)return;let f={endNoBuffer:null,firstFullyOnScreenIndex:void 0,startNoBuffer:null};for(let t=d;t<=o&&t<l.length;t++){let n=s[t]??nu(a,t),o=u.get(n)??_u(e,n,t,l[t]),d=c[t];if(cp(f,t,d,o,r,i))break}Object.assign(a,f,{idsInView:lp(a,f)}),up(a,f.startNoBuffer),t&&(a.props.hasExternalScroll||f.startNoBuffer!==null&&f.endNoBuffer!==null)&&Ff(a,e,t,n,f.startNoBuffer??0,f.endNoBuffer??-1,d,o)}function fp(e,t={}){let n=e.state;Hf(()=>{var r,i,a;let{columns:o,containerItemKeys:s,enableScrollForNextCalculateItemsInView:c,idCache:l,indexByKey:u,positionRecalculationStartIndex:d,positions:f,props:{alwaysRenderIndicesArr:p,alwaysRenderIndicesSet:m,keyExtractor:h,onStickyHeaderChange:g},scrollForNextCalculateItemsInView:_,scrollLength:v,sizes:y,startBufferedId:b,viewabilityConfigCallbackPairs:x}=n,{data:S}=n.props,C=n.props.stickyHeaderIndicesArr||[],w=n.props.stickyHeaderIndicesSet||new Set,T=Gl(e,t.drawDistanceMode),{dataChanged:E,doMVCP:D,forceFullItemPositions:O,mvcpAdjustmentSource:k}=t,A=n.initialScrollSession?.kind===`bootstrap`?n.initialScrollSession.bootstrap:void 0,j=!!A,M=q(e,`numContainers`);if(!S||v===0||!M)return;let N=tc.OS===`web`,P=jc(e,N),F,I=eu(e),ee=q(e,`numColumns`),L=t.scrollVelocity??Iu(n),{initialScroll:R,queuedInitialLayout:te}=n,ne=j?A?.scroll??n.scroll:!te&&jl(n)&&R?Dd(e,R):n.scroll,re=0,ie=0,ae=0,z=0,B=0,oe=ne,se=t=>{oe=t,re=q(e,`scrollAdjustPending`)??0,ie=tu(e,t+0,re,I),!n.props.hasExternalScroll&&ie+v>P&&(ie=Math.max(0,P-v))};se(ne);let ce=q(e,`activeStickyIndex`),le=()=>{let t=C.length>0?ip(C,ie,n):-1,r=t>=0?C[t]:-1,i=ce!==r;return(t>=0||ce>=0)&&J(e,`activeStickyIndex`,r),{currentStickyIdx:t,finishCalculateItemsInView:g&&C.length>0&&i?()=>{let e=S[r];e!==void 0&&g?.({index:r,item:e})}:void 0}},ue=E?void 0:le(),de=T,fe=T;L!==0&&(n.scrollBufferDirection=L>0?1:-1),n.scrollBufferDirection===1||n.scrollBufferDirection===void 0&&ie<Math.max(50,T)?(de=T*.5,fe=T*1.5):(de=T*1.5,fe=T*.5);let pe=!E&&!O&&!j&&!jl(n)&&!n.scrollingTo&&!n.pendingNativeMVCPAdjust&&q(e,`readyToRender`)?np(L,Math.min(de,fe)):0,me=()=>{let e=n.props.hasExternalScroll?ie:Math.max(0,ie),t=n.props.hasExternalScroll?0:Math.max(0,-oe);z=Math.max(e,ie+v+t);let r=n.props.hasExternalScroll?0:Math.max(0,de-ie);ae=e-de+pe,B=z+fe+r+pe};if(me(),pe!==0&&rp(e),c&&!j&&!E&&!O&&_){let{top:t,bottom:i}=_;if(t===null&&i===null)n.scrollForNextCalculateItemsInView=void 0;else if((t===null||ae>t)&&(i===null||B<i)&&!Ru(n)){dp(e,x,v,ie,z),(r=ue?.finishCalculateItemsInView)==null||r.call(ue);return}}let he=D&&!j?Nu(e,E):void 0;E&&yf(n);let ge=O||E?0:d??n.startBuffered??0;Tf(e,E,{doMVCP:D,forceFullUpdate:!!O||d!==void 0,optimizeForVisibleWindow:!O&&!E&&ee>1&&d!==void 0,scrollBottomBuffered:B,scrollVelocity:L,startIndex:ge}),P=jc(e,N),d!==void 0&&(n.positionRecalculationStartIndex=void 0);let _e;if(E&&D&&n.props.maintainVisibleContentPosition.data&&n.didContainersLayout&&n.idsInView.length>0){let e=n.props.maintainVisibleContentPosition.shouldRestorePosition;_e=new Set;for(let t of n.idsInView){let n=u.get(t);n!==void 0&&(!e||e(S[n],n,S))&&_e.add(t)}}let ve=n.scroll,ye=q(e,`scrollAdjustPending`)??0;he?.(),he&&(n.scroll!==ve||(q(e,`scrollAdjustPending`)??0)!==ye)&&(se(n.scroll),me()),E&&(ue=le());let be=null,xe=null,Se=null,Ce=(j?A?.targetIndexSeed:void 0)??(!E&&b&&u.get(b)||0);for(let t=Ce;t>=0;t--){let r=l[t]??nu(n,t);if(f[t]+(y.get(r)??_u(e,r,t,S[t]))>ae)Ce=t;else break}if(ee>1)for(;Ce>0;){let e=o[Ce];if(e===1||e===void 0)break;--Ce}let we=!1,Te,Ee,De=0;for(let t=0;t<M;t++){let n=q(e,`containerItemKey${t}`);if(n!==void 0){let e=u.get(n);De=Math.max(De,e)}}let Oe={endNoBuffer:null,firstFullyOnScreenIndex:void 0,startNoBuffer:null},ke=S.length;for(let t=Math.max(0,Ce);t<ke&&(!we||t<=De);t++){let r=l[t]??nu(n,t),i=y.get(r)??_u(e,r,t,S[t]),a=f[t];we||(cp(Oe,t,a,i,ie,z),be===null&&a+i>ae&&(be=t,xe=r,Te=ae<0?null:a),be===null?a>B&&(we=!0):a<=B?(Se=t,Ee=B>P?null:a+i):we=!0)}Object.assign(n,Oe,{endBuffered:Se,idsInView:lp(n,Oe),startBuffered:be,startBufferedId:xe}),c&&Te!==void 0&&Ee!==void 0?n.scrollForNextCalculateItemsInView=uu(Te)&&uu(Ee)?void 0:{bottom:Ee,top:Te}:c&&n.props.hasExternalScroll&&(B<0?n.scrollForNextCalculateItemsInView={bottom:0,top:null}:ae>P&&(n.scrollForNextCalculateItemsInView={bottom:null,top:P}));let Ae=M,je=[];if(E)for(let t=0;t<Ae;t++){let n=q(e,`containerItemKey${t}`);(!h||n&&u.get(n)===void 0)&&je.push(t)}let Me=n.scrollTargetPinnedRange,Ne=0,Pe=-1;Me&&(Ne=Math.max(0,Math.min(Me.start,Me.end)),Pe=Math.min(ke-1,Math.max(Me.start,Me.end)));let Fe=Ne<=Pe,Ie=e=>m.has(e)||Fe&&e>=Ne&&e<=Pe;if(be!==null&&Se!==null||p.length||Fe){let t=be??0,r=Se??-1,a=[],o=new Set,c=e=>{if(e>=0&&e<ke){let t=l[e]??nu(n,e),r=s.get(t);r===void 0?!uu(t)&&!o.has(e)&&(o.add(e),a.push(e)):n.stickyContainerPool.add(r)}};for(let e=t;e<=r;e++){let t=l[e]??nu(n,e);s.has(t)||(o.add(e),a.push(e))}for(let e of p)c(e);if(Fe)for(let e=Ne;e<=Pe;e++)c(e);if(C.length>0?op(e,C,ue?.currentStickyIdx??-1,a,o,t,r):ce!==-1&&J(e,`activeStickyIndex`,-1),a.length>0){let o=Jf(e,a,t,r,je,_e,jl(n)?R?.viewPosition===1:(L||(n.hasScrolled?n.scroll-n.scrollPrev:0))<0);for(let t of o){let r=t.itemIndex,a=t.containerIndex,o=l[r]??nu(n,r),c=q(e,`containerItemKey${a}`);if(c&&c!==o&&s.delete(c),n.containerItemMetadata.set(a,hf(n,r,S[r],t.itemType)),c!==o&&(F??=new Set,F.add(a),n.containerItemGenerations[a]=(n.containerItemGenerations[a]??0)+1,n.props.hideItemsUntilMeasured)){let t=n.sizesKnown.has(o)||_f(n,a,r,S[r]).fixedItemSize!==void 0;J(e,`containerLayoutReady${a}`,t)}J(e,`containerItemKey${a}`,o),J(e,`containerItemIndex${a}`,r),J(e,`containerItemData${a}`,S[r]),s.set(o,a),(i=n.userScrollAnchorReset)==null||i.keys.add(o);let u=`containerSticky${a}`,d=w.has(r),f=Ie(r);d?(J(e,u,!0),n.stickyContainerPool.add(a)):(q(e,u)&&J(e,u,!1),f?n.stickyContainerPool.add(a):n.stickyContainerPool.delete(a)),a>=Ae&&(Ae=a+1)}Ae!==M&&(J(e,`numContainers`,Ae),Ae>q(e,`numContainersPooled`)&&J(e,`numContainersPooled`,qf(ke,Ae)))}n.userScrollAnchorReset?.keys.size===0&&(n.userScrollAnchorReset=void 0)}n.stickyContainerPool.size>0&&sp(e,C,ie,T,ue?.currentStickyIdx??-1,je,Ie);let Le=je.length>0?new Set(je):void 0,Re=!1;for(let t=0;t<Ae;t++){let r=q(e,`containerItemKey${t}`);if(Le?.has(t))r!==void 0&&(s.delete(r),F??=new Set,F.add(t),n.containerItemGenerations[t]=(n.containerItemGenerations[t]??0)+1),n.containerItemMetadata.delete(t),n.stickyContainerPool.has(t)&&(J(e,`containerSticky${t}`,!1),n.stickyContainerPool.delete(t)),J(e,`containerItemKey${t}`,void 0),J(e,`containerItemIndex${t}`,void 0),J(e,`containerItemData${t}`,void 0),J(e,`containerPosition${t}`,Rc),J(e,`containerColumn${t}`,-1),J(e,`containerSpan${t}`,1);else{let n=u.get(r);n!==void 0&&(Re=Mf(e,t,n,{scrollAdjustPending:re,updateLayout:!0}).didChangePosition||Re)}}F&&Pc&&jf(e,F),Re&&J(e,`lastPositionUpdate`,Date.now()),j?lf(e):(up(n,Oe.startNoBuffer),!te&&!n.didContainersLayout&&(jl(n)?Nd(n,n.startBuffered,n.endBuffered):Nd(n,n.startNoBuffer,n.endNoBuffer)||Nd(n,n.startBuffered,n.endBuffered))&&($f(e),Df(e)),x&&(n.props.hasExternalScroll||Oe.startNoBuffer!==null&&Oe.endNoBuffer!==null)&&Ff(e.state,e,x,v,Oe.startNoBuffer??0,Oe.endNoBuffer??-1,be??Oe.startNoBuffer??0,Se??Oe.endNoBuffer??-1),(a=ue?.finishCalculateItemsInView)==null||a.call(ue))})}function pp(e){var t,n;let r=e.state,i=r.props.anchoredEndSpace,a=q(e,`anchoredEndSpaceSize`),o=r.anchoredEndSpaceReadyAnchorIndex,s=r.anchoredEndSpaceReadyAnchorKey,c=i?.anchorIndex,l,u=!0,d=!0,f=0;if(i){let{anchorIndex:t,anchorMaxSize:n,anchorOffset:o=0}=i,{data:s}=r.props;if(t>=0&&t<s.length&&r.scrollLength>0){l=nu(r,t);let i=0,c=!1;for(let r=t;r<s.length;r++){let a=hu(e,r),o=r===t&&n!==void 0?Math.min(a||0,Math.max(0,n)):a;a===void 0&&(c=!0),o!=null&&o>0&&(i+=o)}i=Math.max(0,i-e.scrollAxisGap),i+=(e.values.get(`footerSize`)||0)+lc(r.props),u=!c;let d=Math.max(0,r.scrollLength-i-o-0);f=c?Math.min(a||0,d):d}else t>=0&&(u=!1,d=!1)}let p=a!==f&&(a!==void 0||i!==void 0),m=(a||0)!==f,h=d&&(u||a!==void 0),g=o!==c||s!==l,_=u&&r.anchoredEndSpacePendingReady;return r.anchoredEndSpacePendingReady=!u,h&&p&&(J(e,`anchoredEndSpaceSize`,f),(t=i?.onSizeChanged)==null||t.call(i,f)),h&&m&&(ml(e),zu(e,r.scroll,!0,{markHasScrolled:!1})),u&&(p||g||_)&&(r.anchoredEndSpaceReadyAnchorIndex=c,r.anchoredEndSpaceReadyAnchorKey=l,(n=i?.onReady)==null||n.call(i,{anchorIndex:c,anchorKey:l,size:f})),f}function mp(e,t){let n=e.state;n.userScrollAnchorReset===void 0?n.mvcpAnchorLock&&!t?n.scheduledWork.has(`mvcpRecalculate`)||n.scheduledWork.frame(()=>fp(e,{doMVCP:!0,mvcpAdjustmentSource:`item-size`}),`mvcpRecalculate`):(n.scheduledWork.cancel(`mvcpRecalculate`),fp(e,{doMVCP:!0,mvcpAdjustmentSource:`item-size`})):(fp(e),n.userScrollAnchorReset?.keys.size===0&&(n.userScrollAnchorReset=void 0))}function hp(e,t,n){if(e.state.needsOtherAxisSize){let r=n?t.height:t.width,i=q(e,`otherAxisSize`);(!i||r>i)&&J(e,`otherAxisSize`,r)}}var gp;function _p(e){let t=gp===void 0;gp??=new Map;try{e()}finally{if(t){let e=gp;gp=void 0;for(let[t,n]of e)Sp(t,n)}}}function vp(e,t){e.didChange||=t.didChange,e.didMeasureUserScrollAnchorResetItem||=t.didMeasureUserScrollAnchorResetItem,e.needsRecalculate||=t.needsRecalculate,e.shouldMaintainScrollAtEnd||=t.shouldMaintainScrollAtEnd}function yp(e,t){let n=e.state;t.shouldMaintainScrollAtEnd&&tc.OS===`web`&&queueMicrotask(()=>Yu(e,{immediate:!0})),t.needsRecalculate?(t.didChange&&nf(e),n.scrollForNextCalculateItemsInView=void 0,mp(e,t.shouldMaintainScrollAtEnd&&(q(e,`isFollowingEnd`)||q(e,`isWithinMaintainScrollAtEndThreshold`)))):t.didMeasureUserScrollAnchorResetItem&&n.userScrollAnchorReset?.keys.size===0&&(n.userScrollAnchorReset=void 0),t.didChange&&(pp(e),Pl(e))}function bp(e,t){if(gp){let n=gp.get(e);n?n.push(t):gp.set(e,[t])}else Sp(e,[t])}function xp(e,t,n){if(q(e,`containerItemKey${t}`)!==n)return!1;let r=e.state,i=r.indexByKey.get(n);return i!==void 0&&i<r.props.data.length&&nu(r,i)===n||(r.scheduledWork.microtask(()=>e.containerLayoutTriggers.get(t)?.(),`containerMeasurementRetry${t}`),!1)}function Sp(e,t){let n=e.state,r={},i=n.totalSize;for(let i of t)if(i.containerId===void 0||xp(e,i.containerId,i.itemKey)){let t=n.indexByKey.get(i.itemKey),a=t===void 0?void 0:n.props.data?.[t],o=i.containerId!==void 0&&t!==void 0&&a!==void 0?_f(n,i.containerId,t,a):void 0;vp(r,Cp(e,i.itemKey,i.size,o))}n.totalSize!==i&&J(e,`totalSize`,n.totalSize),yp(e,r)}function Cp(e,t,n,r){let i=e.state,a=!!i.pendingEndMeasurements?.delete(t),o=!!i.userScrollAnchorReset?.keys.delete(t),{didContainersLayout:s,sizesKnown:c,props:{getFixedItemSize:l,getItemType:u,horizontal:d,onItemSizeChanged:f,data:p,maintainScrollAtEnd:m}}=i;if(!p)return{didMeasureUserScrollAnchorResetItem:o};let h=i.indexByKey.get(t);if(l){if(h===void 0)return{didMeasureUserScrollAnchorResetItem:o};let a=i.props.data[h];if(a===void 0)return{didMeasureUserScrollAnchorResetItem:o};if(!r?.didResolveFixedItemSize){let e=r?.itemType??(u?u(a,h)??``:``);r={didResolveFixedItemSize:!0,fixedItemSize:l(a,h,e),itemType:e}}let s=r.fixedItemSize;if(s!==void 0&&s===c.get(t))return hp(e,n,d),{didMeasureUserScrollAnchorResetItem:o}}let g=!s,_=i.sizesKnown.get(t),v=_===void 0&&!!i.pendingMaintainScrollAtEnd,y=wp(e,t,n,r,!1),b=lu(d?n.width:n.height);if(y!==0){let{startBuffered:e,endBuffered:n}=i;g||=h>=e&&h<=n,g||=i.containerItemKeys.has(t),f?.({index:h,itemData:i.props.data[h],itemKey:t,previous:b-y,size:b}),i.positionRecalculationStartIndex=Math.min(i.positionRecalculationStartIndex??h,h)}if(hp(e,n,d),s||Nd(i,i.startBuffered,i.endBuffered)){let e=(y!==0&&_!==b||v)&&(!!m?.onItemLayout||a||!!i.pendingMaintainScrollAtEnd);return{didChange:y!==0,didMeasureUserScrollAnchorResetItem:o,needsRecalculate:g,shouldMaintainScrollAtEnd:e}}return{didChange:y!==0,didMeasureUserScrollAnchorResetItem:o}}function wp(e,t,n,r,i=!0){var a;let o=e.state,{indexByKey:s,sizesKnown:c,averageSizes:l,props:{data:u,horizontal:d,getItemType:f,getFixedItemSize:p}}=o;if(!u)return 0;let m=s.get(t),h=u[m],g=r?.itemType,_=r?.fixedItemSize;p&&!r?.didResolveFixedItemSize&&(g=f?f(h,m)??``:``,_=p(h,m,g));let v=_u(e,t,m,h,void 0,void 0,i,r?.didResolveFixedItemSize||g!==void 0||_!==void 0?{didResolveFixedItemSize:r?.didResolveFixedItemSize,fixedItemSize:_,itemType:g}:void 0),y=d?n.width:n.height;_===void 0?(a=o.fixedItemSizeKeys)==null||a.delete(t):(o.fixedItemSizeKeys??=new Set,o.fixedItemSizeKeys.add(t));let b=c.get(t),x=Math.round(y);if(b!==x&&(o.positionsAreCurrent=!1),c.set(t,x),_===void 0&&x>0){g??=f?f(h,m)??``:``;let e=l[g];e||=l[g]={avg:0,num:0},e.num===0?(e.avg=x,e.num++):b!==void 0&&b>0?e.avg+=(x-b)/e.num:(e.avg=(e.avg*e.num+x)/(e.num+1),e.num++)}return!v||Math.abs(v-x)>.1?(iu(e,t,x,i),x-v):0}function Tp(e,t=null){let n=e.state.dataChangeEpoch,r=[],i=e.state.initialScrollSession?.kind===`bootstrap`&&e.state.initialScrollSession.bootstrap?e.viewRefs.keys():t??e.viewRefs.keys();for(let t of i){let n=e.viewRefs.get(t),i=q(e,`containerItemKey${t}`),a=n?.current;if(i!==void 0&&a&&xp(e,t,i)){let n=e.state.containerItemGenerations[t]??0,o=a.getBoundingClientRect();mf(a,o),r.push({containerId:t,generation:n,itemKey:i,size:{height:o.height,width:o.width}})}}if(r.length>0){if(Sp(e,r),e.state.initialScrollSession?.kind!==`bootstrap`||!e.state.initialScrollSession.bootstrap)return;e.state.scheduledWork.microtask(()=>{var t;let i=e.state,a=i.initialScrollSession?.kind===`bootstrap`?i.initialScrollSession.bootstrap:void 0;if(a?.visibleIndices?.length&&i.dataChangeEpoch===n){let n=new Set;for(let{containerId:t,generation:a,itemKey:o}of r)q(e,`containerItemKey${t}`)===o&&(i.containerItemGenerations[t]??0)===a&&n.add(o);let o=a.visibleIndices.every(e=>n.has(nu(i,e))),s=Array.from(i.containerItemKeys.keys()).every(e=>{let t=i.indexByKey.get(e);return t===void 0||t<i.startBuffered||t>i.endBuffered||n.has(e)}),c=((t=i.refScroller.current)?.getMaxScrollOffset)?.call(t),l=Xc(e);o&&s&&c!==void 0&&Math.abs(c-l)<=1&&lf(e)}},`bootstrapMeasuredLayout`)}}var Ep=G.forwardRef,Dp=G.memo,Op=Dp(function({children:e}){let t=bc(),[n]=Dc([`containerLayoutEpoch`]);return G.useLayoutEffect(()=>{{let e=Af(t);e!==void 0&&Tp(t,e)}},[t,n]),e}),kp=e=>G.isValidElement(e)?e:e?G.createElement(e,null):null,Ap={contain:`paint layout style`,...typeof document<`u`&&document.getElementById(`react-native-stylesheet`)?{display:`flex`,flexDirection:`column`}:{}},jp=Dp(function({id:e,horizontal:t,style:n,refView:r,...i}){let[a=Rc]=Dc([`containerPosition${e}`]),o=ou(n)?Object.assign({},...n):n,s=t?{...Ap,...o,left:a}:{...Ap,...o,top:a},{animatedScrollY:c,onLayout:l,onLayoutChange:u,stickyHeaderConfig:d,...f}=i;return G.createElement(`div`,{ref:r,...f,style:s})}),Mp=Dp(function({id:e,horizontal:t,style:n,refView:r,animatedScrollY:i,stickyHeaderConfig:a,onLayout:o,onLayoutChange:s,children:c,...l}){let[u=Rc,d,f]=Dc([`containerPosition${e}`,`activeStickyIndex`,`containerItemIndex${e}`]),p=G.useMemo(()=>(ou(n)?Object.assign({},...n):n)??{},[n]),m=G.useMemo(()=>{let e={...Ap,...p};delete e.transform;let n=a?.offset??0,r=d===f;return e.position=r?`sticky`:`absolute`,e.zIndex=f+1e3,t?e.left=r?n:u:e.top=r?n:u,e},[p,t,u,f,d,a?.offset]),h=G.useMemo(()=>a?.backdropComponent?G.createElement(`div`,{style:{inset:0,pointerEvents:`none`,position:`absolute`}},kp(a.backdropComponent)):null,[a?.backdropComponent]);return G.createElement(`div`,{ref:r,style:m,...l},h,c)}),Np=jp;function Pp(e){(0,G.useState)(()=>e())}var Fp=(0,G.createContext)(null),Ip=-1;function Lp(){return(0,G.useContext)(Fp)}function Rp(){let e=Lp(),[t]=Dc([`containerItemKey${e?.containerId??Ip}`]);return Oc(`lastItemKeys`,n=>e&&!uu(t)&&n?.includes(t)||!1)}function zp({ItemSeparatorComponent:e,leadingItem:t}){return Rp()?null:G.createElement(e,{leadingItem:t})}var Bp=null;function Vp(){return Bp||=new ResizeObserver(e=>{_p(()=>{for(let t of e){let e=Hp.get(t.target);if(e)for(let n of e)n(t)}})}),Bp}var Hp=new WeakMap;function Up(e,t){if(typeof ResizeObserver>`u`||!e)return()=>{};let n=Vp(),r=Hp.get(e)??new Set;return r.size===0&&(Hp.set(e,r),n.observe(e,{box:`border-box`})),r.add(t),()=>{r.delete(t),r.size===0&&(Hp.delete(e),n.unobserve(e))}}function Wp(e){let t=G.useRef(e);return t.current=e,t}function Gp({ref:e,measureInLayoutEffect:t=!0,onLayoutProp:n,onLayoutChange:r,webLayoutResync:i,webExternalScroll:a=!1},o){let s=Wp({onLayoutChange:r,onLayoutProp:n,webLayoutResync:i}),c=(0,G.useCallback)(e=>{r(e.nativeEvent.layout,!1),n?.(e)},[r,n]);return(0,G.useLayoutEffect)(()=>{if(a)return;let n=e.current,r=((n?.getScrollableNode)?.call(n)??null)||n;if(!r)return;let i=(e,t)=>{var n,r;(e.height!==0||e.width!==0)&&(s.current.onLayoutChange(e,t),(r=(n=s.current).onLayoutProp)==null||r.call(n,{nativeEvent:{layout:e}}))},o;if(t){let e=r.getBoundingClientRect();i(Kp(e),!0),o=e}return Up(r,e=>{var t;let n=e.target instanceof HTMLElement?e.target:void 0,a=Array.isArray(e.borderBoxSize)?e.borderBoxSize[0]:e.borderBoxSize,c=a?{height:a.blockSize,left:e.contentRect.left,top:e.contentRect.top,width:a.inlineSize}:n?.getBoundingClientRect()??e.contentRect,l=o??pf(r),u=l===void 0||c.width!==l.width||c.height!==l.height;o=c;let d=!!(t=s.current).webLayoutResync?.call(t);(u||d)&&i(Kp(c),!1)})},[s,t,a,...o||[]]),a?{onLayout:c}:{}}function Kp(e){return e?{height:e.height,width:e.width,x:e.left,y:e.top}:{height:0,width:0,x:0,y:0}}var qp=new Map,Jp;function Yp(e){qp.delete(e)}function Xp(e,t){qp.set(e,t),Jp===void 0&&(Jp=requestAnimationFrame(()=>{let e=Array.from(qp.values());qp.clear(),Jp=void 0,_p(()=>{for(let t of e)t()})}))}function Zp({containerId:e,ctx:t,rectangle:n,ref:r,state:i}){let a=t.state,o=i.itemKey;i.didLayout=!0;let s=n,c=i.horizontal?`width`:`height`,l=lu(n[c]);i.lastSize&&lu(i.lastSize[c]);let u=a.sizesKnown.get(o),d=()=>{i.lastSize=s,bp(t,{containerId:e,itemKey:o,size:s})};!Ru(a)&&u!==void 0&&l+1<u?Xp(i,()=>{if(i.itemKey===o){let e=r.current,t=(e?.getBoundingClientRect)?.call(e);t&&(s={height:t.height,width:t.width}),d()}}):(Yp(i),d())}function Qp({containerId:e,ctx:t,horizontal:n,itemKey:r,ref:i}){let a=(0,G.useRef)({didLayout:!1,horizontal:n,itemKey:r});a.current.horizontal=n,a.current.itemKey=r;let[o,s]=(0,G.useState)(0),c=(0,G.useCallback)(n=>{Zp({containerId:e,ctx:t,rectangle:n,ref:i,state:a.current})},[e,t,i]),l=(0,G.useCallback)(()=>{jf(t,e)},[e,t]);(0,G.useLayoutEffect)(()=>(t.containerLayoutTriggers.set(e,l),()=>{Yp(a.current),t.containerLayoutTriggers.get(e)===l&&t.containerLayoutTriggers.delete(e)}),[e,t,l]),(0,G.useLayoutEffect)(()=>{jf(t,e)});let{onLayout:u}=Gp({measureInLayoutEffect:!Pc,onLayoutChange:c,ref:i,webLayoutResync:()=>Ru(t.state)},[r,o]);return(0,G.useEffect)(()=>{},[e,t,r]),{onLayout:u,triggerLayout:l}}function $p({columnWrapperStyle:e,contentContainerAlignItems:t,horizontal:n,hasItemSeparator:r,isHorizontalRTLList:i,numColumns:a,otherAxisPos:o,otherAxisSize:s}){let c;if(e){let{columnGap:t,rowGap:r,gap:i}=e;c=n?{paddingBottom:a>1?(r||i||0)/2:void 0,paddingRight:t||i||void 0,paddingTop:a>1?(r||i||0)/2:void 0}:{paddingBottom:r||i||void 0,paddingLeft:a>1?(t||i||0)/2:void 0,paddingRight:a>1?(t||i||0)/2:void 0}}return n?{bottom:t===`flex-end`&&a===1?0:void 0,boxSizing:c?`border-box`:void 0,direction:i&&tc.OS===`web`?`ltr`:void 0,flexDirection:r?`row`:void 0,height:s,left:0,position:`absolute`,top:t===`flex-end`&&a===1?void 0:o,...c||{}}:{boxSizing:c?`border-box`:void 0,left:o,position:`absolute`,right:a>1?null:0,top:0,width:s,...c||{}}}var em=Dp(function({id:e,itemKey:t,recycleItems:n,horizontal:r,getRenderedItem:i,ItemSeparatorComponent:a,stickyHeaderConfig:o}){let s=bc(),{columnWrapperStyle:c,animatedScrollY:l}=s,u=sc(s.state),d=s.state.props.positionComponentInternal,f=s.state.props.stickyPositionComponentInternal,[p=0,m=1,h,g=1,_,v]=Dc([`containerColumn${e}`,`containerSpan${e}`,`containerItemData${e}`,`numColumns`,`extraData`,`containerSticky${e}`]),y=(0,G.useRef)(null),{onLayout:b,triggerLayout:x}=Qp({containerId:e,ctx:s,horizontal:r,itemKey:t,ref:y}),S=p>0?p:1,C=Math.min(Math.max(m||1,1),g),w=g>1?`${(S-1)/g*100}%`:0,T=g>1?`${C/g*100}%`:void 0,E=(0,G.useMemo)(()=>$p({columnWrapperStyle:c,contentContainerAlignItems:s.state.props.contentContainerAlignItems,hasItemSeparator:!!a,horizontal:r,isHorizontalRTLList:u,numColumns:g,otherAxisPos:w,otherAxisSize:T}),[r,u,w,T,c,s.state.props.contentContainerAlignItems,g,a]),D=(0,G.useMemo)(()=>t===void 0?null:i(t,e),[t,h,_]),{renderedItem:O}=D||{},k=(0,G.useMemo)(()=>(s.viewRefs.set(e,y),{containerId:e,triggerLayout:x}),[e,x]),A=v?f||Mp:d||Np;return G.createElement(A,{animatedScrollY:v?l:void 0,horizontal:r,id:e,key:n?void 0:t,onLayout:b,refView:y,stickyHeaderConfig:o,style:E},G.createElement(Fp.Provider,{value:k},O,D&&a&&G.createElement(zp,{ItemSeparatorComponent:a,leadingItem:D.item})))});function tm({id:e,horizontal:t,recycleItems:n,ItemSeparatorComponent:r,getRenderedItem:i,stickyHeaderConfig:a,ContainerComponent:o=em}){let[s]=Dc([`containerItemKey${e}`]);return s===void 0?null:G.createElement(o,{getRenderedItem:i,horizontal:t,ItemSeparatorComponent:r,id:e,itemKey:s,recycleItems:n,stickyHeaderConfig:a})}var nm=Dp(function(e){return G.createElement(tm,{...e})});function rm(e,t){let n=Array.from(e.children);if(n.length<=1)return n;let r=n.map(e=>[e,t.get(e)??null]);r.sort((e,t)=>{let n=e[1],r=t[1];return n===null?1:r===null?-1:n-r});let i=new Map;r.forEach((e,t)=>{i.set(e[0],t)});let a=im(n.map(e=>i.get(e))),o=new Set(a);for(let t=0;t<r.length;t++){let i=r[t][0],a=n.indexOf(i);if(!o.has(a)){let a=null;for(let e=t+1;e<r.length;e++){let t=r[e][0],i=n.indexOf(t);if(o.has(i)){a=t;break}}`moveBefore`in e&&typeof e.moveBefore==`function`&&e.isConnected?e.moveBefore(i,a):a?e.insertBefore(i,a):e.appendChild(i)}}}function im(e){let t=e.length,n=[],r=Array(t).fill(-1),i=[];for(let a=0;a<t;a++){let t=e[a],o=0,s=n.length;for(;o<s;){let n=Math.floor((o+s)/2);e[i[n]]<t?o=n+1:s=n}o===n.length?(n.push(t),i.push(a)):(n[o]=t,i[o]=a),o>0&&(r[a]=i[o-1])}let a=[],o=i[i.length-1];for(;o!==-1;)a.unshift(o),o=r[o];return a}function am(e){let t=bc();(0,G.useEffect)(()=>{let n,r=0,i=500,a=wc(t,`lastPositionUpdate`,()=>{let a=e.current,o=Date.now();i=a&&`moveBefore`in a&&typeof a.moveBefore==`function`&&a.isConnected&&(o-r>=1e3||n!==void 0&&i===0)&&o-t.state.scrollTime>=500?0:500,r=o,clearTimeout(n),n=setTimeout(()=>{n=void 0;let r=e.current;if(r){let e=new Map;for(let[n,r]of t.viewRefs){let i=r.current,a=q(t,`containerItemIndex${n}`);i&&a!==void 0&&e.set(i,a)}rm(r,e)}},i)});return()=>{a(),clearTimeout(n)}},[t])}function om(e,t){let[n,r]=(0,G.useState)(t),i=(0,G.useRef)(!1);return(0,G.useLayoutEffect)(()=>{e&&(i.current=!0),r(t)},[e,t]),e||i.current}var sm=Dp(function({freshDataTransitionEpoch:e,horizontal:t,numColumns:n,children:r}){let i=(0,G.useRef)(null),a=bc(),o=a.columnWrapperStyle,s=sc(a.state),[c,l,u]=Dc([`otherAxisSize`,`readyToRender`,`totalSize`]),d=om(!!l,e);am(i);let f=t?{direction:s?`ltr`:void 0,flexShrink:0,minHeight:c,opacity:+!!d,position:`relative`,width:u}:{height:u,minWidth:c,opacity:+!!d,position:`relative`};if(l||(f.pointerEvents=`none`),o&&n>1){let{columnGap:e,rowGap:n,gap:r}=o,i=e||r||0,a=n||r||0;t?(a&&(f.marginTop=f.marginBottom=-a/2),i&&(f.marginRight=-i)):a&&(f.marginBottom=-a)}return G.createElement(`div`,{ref:i,style:f},G.createElement(Op,null,r))}),cm=Dp(function({freshDataTransitionEpoch:e,horizontal:t,recycleItems:n,ItemSeparatorComponent:r,getRenderedItem:i,stickyHeaderConfig:a}){let[o,s]=Dc([`numContainersPooled`,`numColumns`]),c=[];for(let e=0;e<o;e++)c.push(G.createElement(nm,{getRenderedItem:i,horizontal:t,ItemSeparatorComponent:r,id:e,key:e,recycleItems:n,stickyHeaderConfig:a}));return G.createElement(sm,{freshDataTransitionEpoch:e,horizontal:t,numColumns:s},c)});function lm(e){return ou(e)?Object.assign({},...e.filter(Boolean)):e}var um={create:e=>e,flatten:e=>lm(e)};function dm(e){let t=Wp(e),n=(0,G.useRef)(void 0),r=(0,G.useMemo)(()=>({cancel(){n.current!==void 0&&(cancelAnimationFrame(n.current),n.current=void 0)},flush(){r.cancel(),t.current()},schedule(){if(n.current!==void 0)return!1;let e=requestAnimationFrame(()=>{n.current===e&&(n.current=void 0,t.current())});return n.current=e,!0}}),[]);return(0,G.useEffect)(()=>()=>{r.cancel()},[r]),r}var fm=100;function pm(e,t,n){return e*(t===1?16:t===2&&n>0?n:1)}function mm(e,t,n,r){let i=Math.abs(t),a=r!==!0&&(!e||n-e.time>fm||Math.sign(t)!==Math.sign(e.delta)||r===!1&&e.momentum===!0||r===void 0&&e.decaying&&i>=Math.max(10,e.peak*.5)&&i>Math.abs(e.delta)*1.5),o=!e||a?i:Math.max(e.peak,i);return{decaying:!a&&(!!e?.decaying||i<o*.8),delta:t,isNew:a,momentum:r,peak:o,time:n}}function hm(e){return typeof window<`u`&&e===window}function gm(e){return hm(e)?{x:e.scrollX??e.pageXOffset??0,y:e.scrollY??e.pageYOffset??0}:{x:e?.scrollLeft??0,y:e?.scrollTop??0}}function _m(e,t,n=!1){let r=e?.getBoundingClientRect(),i=gm(t),a=t&&!hm(t)?t:null,o=a?.getBoundingClientRect(),s=n?(r?.width??0)-(hm(t)?t.document.documentElement.clientWidth:a?.clientWidth??0):0;return{left:(r?.left??0)-(o?.left??0)-(a?.clientLeft??0)+i.x+s,top:(r?.top??0)-(o?.top??0)-(a?.clientTop??0)+i.y}}function vm(e){return{height:e?.scrollHeight??0,width:e?.scrollWidth??0}}function ym(e,t,n){return vm(n===void 0?e:t)}function bm(e,t,n){if(t!==void 0){let r=e?.getBoundingClientRect(),i=hm(t)?{height:t.innerHeight,width:t.innerWidth}:{height:t?.clientHeight??0,width:t?.clientWidth??0};return{height:n?r?.height??e?.clientHeight??0:i.height,width:n?i.width:r?.width??e?.clientWidth??0}}return{height:e?.clientHeight??0,width:e?.clientWidth??0}}function xm(e,t){return Math.max(0,Math.min(e,t))}function Sm(e,t,n){let r=n?`width`:`height`;return Math.max(0,e[r]-t[r])}function Cm(e,t){return hm(t)?document.scrollingElement||document.documentElement||document.body:t===void 0?e:t}function wm(e,t){return t===void 0?e:t}function Tm(e,t,n){if(t===void 0){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.left,y:t.top}}let{left:r,top:i}=_m(e,t),{height:a,width:o}=bm(e,t,n);return{height:a,width:o,x:r,y:i}}function Em({clampedOffset:e,horizontal:t,listPos:n,scroll:r}){return{left:t?n.left+e:r.x,top:t?r.y:n.top+e}}function Dm(e,t,n,r=0){let i=e;for(i?.nodeType!==1&&(i=i?.parentElement??null);i&&i!==t;){let e=getComputedStyle(i),t=n?e.overflowX:e.overflowY;if(/auto|scroll|overlay/.test(t)){let t=n?e.overscrollBehaviorX:e.overscrollBehaviorY;if(/contain|none/.test(t||e.overscrollBehavior))return!1;let a=n?i.scrollWidth-i.clientWidth:i.scrollHeight-i.clientHeight,o=n?i.scrollLeft+(e.direction===`rtl`?a:0):i.scrollTop;if(a>1&&(r===0||(r>0?o<a-1:o>1)))return!1}i=i.parentElement}return i===t}function Om(e,t,n){if(t===null)return;let r=new ResizeObserver(n),i=t===void 0?void 0:new MutationObserver(a);function a(){if(r.disconnect(),i?.disconnect(),r.observe(e),t!==void 0)for(let n=e;n&&n!==t;n=n.parentElement){let e=n.parentElement;e&&(r.observe(e),i?.observe(e,{childList:!0}));for(let e=n.previousElementSibling;e;e=e.previousElementSibling)r.observe(e)}n()}return a(),hm(t)&&t.addEventListener(`resize`,n),()=>{r.disconnect(),i?.disconnect(),hm(t)&&t.removeEventListener(`resize`,n)}}var km=`legend-list-content-container`,Am=`legend-list-scrollbar-x-hidden`,jm=`legend-list-scrollbar-y-hidden`,Mm=`legend-list-scrollbar-axis-hidden-style`,Nm=200,Pm=`.${jm}::-webkit-scrollbar:vertical{width:0;display:none;}.${Am}::-webkit-scrollbar:horizontal{height:0;display:none;}`;function Fm(){if(typeof document>`u`||document.getElementById(Mm))return;let e=document.createElement(`style`);e.id=Mm,e.textContent=Pm,document.head.appendChild(e)}function Im(e){if(!e?.length)return[];let t=[],n=new Set;for(let r of e)Number.isFinite(r)&&!n.has(r)&&(n.add(r),t.push(r));return t}function Lm(e,t){return{height:t?`100%`:1,left:t?e:0,pointerEvents:`none`,position:`absolute`,scrollSnapAlign:`start`,top:t?0:e,width:t?1:`100%`}}var Rm=(0,G.forwardRef)(function({children:e,style:t,contentContainerClassName:n,contentContainerStyle:r,horizontal:i=!1,contentOffset:a,maintainVisibleContentPosition:o,onScroll:s,onInternalScrollEnd:c,onMomentumScrollBegin:l,onMomentumScrollEnd:u,showsHorizontalScrollIndicator:d=!0,showsVerticalScrollIndicator:f=!0,refreshControl:p,useWindowScroll:m=!1,scrollElement:h,onLayout:g,..._},v){let y=bc(),[b]=Dc([`anchoredEndSpaceSize`]),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=h===void 0&&m?typeof window>`u`?null:window:h,w=hm(C),T=C!==void 0,E=(0,G.useCallback)(()=>wm(x.current,C),[C]),D=(0,G.useCallback)(()=>{let e=x.current;return Sm(ym(e,S.current,C),bm(e,C,i),i)},[C,i]),O=(0,G.useCallback)(()=>_m(x.current,C,i&&sc(y.state)&&ac(y.state)===`negative`),[y,C,i]),k=(0,G.useCallback)(()=>{let e=x.current;if(T){let e=gm(C),t=O();return i?e.x-t.left:e.y-t.top}return(i?e?.scrollLeft:e?.scrollTop)??0},[C,O,i,T]),A=(0,G.useCallback)(e=>{let t=D();return i&&sc(y.state)&&ac(y.state)===`negative`?-xm(-e,t):xm(e,t)},[y,D,i]),j=(0,G.useCallback)(()=>{if(!T)return!0;let e=k();return Math.abs(e-A(e))<=1},[A,k,T]),M=(0,G.useCallback)(()=>{let e=k();return T?A(e):e},[A,k,T]),N=(0,G.useCallback)((e,t)=>{let n=E();if(!n||typeof n.scrollTo!=`function`)return;let r={behavior:t?`smooth`:`instant`};if(T){let t=gm(C),n=O(),{left:a,top:o}=Em({clampedOffset:A(e),horizontal:i,listPos:n,scroll:t});r.left=a,r.top=o}else{let t=D();i?r.left=e<0?-xm(-e,t):xm(e,t):r.top=xm(e,t)}n.scrollTo(r)},[A,C,O,D,E,i,T]);(0,G.useImperativeHandle)(v,()=>({getBoundingClientRect:()=>x.current?.getBoundingClientRect(),getContentNode:()=>S.current,getCurrentScrollOffset:M,getMaxScrollOffset:D,getRawScrollOffset:k,getScrollableNode:()=>Cm(x.current,C),getScrollEventTarget:E,getScrollResponder:()=>Cm(x.current,C),isScrollInRange:j,isWindowScroll:()=>w,scrollBy:(e,t)=>{let n=E();n&&typeof n.scrollBy==`function`&&n.scrollBy({behavior:`auto`,left:e,top:t})},scrollTo:e=>{let{x:t=0,y:n=0,animated:r=!0}=e;N(i?t:n,r)},scrollToEnd:(e={})=>{let{animated:t=!0}=e,n=D();N(n,t)},scrollToOffset:e=>{let{offset:t,animated:n=!0}=e;N(t,n)}}),[C,M,k,D,j,E,i,w,N]);let P=(0,G.useCallback)(()=>{if(!s||!x.current)return;let e=vm(S.current),t=bm(x.current,C,i),n=k();s({nativeEvent:{contentOffset:{x:i?n:0,y:i?0:n},contentSize:{height:e.height,width:e.width},layoutMeasurement:{height:t.height,width:t.width}}})},[C,k,i,s]),F=dm(P),I=(0,G.useRef)(void 0),ee=(0,G.useCallback)(()=>{let e=I.current;e!==void 0&&(clearTimeout(e),I.current=void 0),F.flush(),c?.()},[c,F]),L=(0,G.useCallback)(e=>{if(!s)return;let t=y.state;if(!jl(t)&&!t.scrollingTo&&(t.maintainingScrollAtEnd||t.pendingMaintainScrollAtEnd)){let e=D();pc(t,M(),e)<xm(t.scroll,e)-1&&Uu(y)}if(t.scrollingTo||!t.didFinishInitialScroll&&(t.initialScrollSession||t.initialScroll)||Ru(t)?F.flush():F.schedule(),c){let e=I.current;e!==void 0&&clearTimeout(e),I.current=setTimeout(ee,Nm)}},[y,ee,M,D,c,s,F]);(0,G.useLayoutEffect)(()=>{let e=E();if(e)return e.addEventListener(`scroll`,L,{passive:!0}),`onscrollend`in e&&e.addEventListener(`scrollend`,ee),()=>{e.removeEventListener(`scroll`,L),e.removeEventListener(`scrollend`,ee);let t=I.current;t!==void 0&&(clearTimeout(t),I.current=void 0),F.cancel()}},[ee,E,L,F]),(0,G.useEffect)(()=>{let e=E();if(!e)return;let t=()=>{let e=y.state,t=e.initialScroll;return jl(e)?t?.viewPosition!==1||t.index!==e.props.data.length-1:!!(e.scrollingTo&&!e.scrollingTo.isInitialScroll&&(!e.scrollingTo.isScrollToEnd||e.pendingScrollResolve&&!e.maintainingScrollAtEnd)||e.endFollowInterrupted&&e.pendingScrollResolve)},n=(e,n,r=!0,c=!1,l=!1)=>{var u,d;let f=y.state;if(!f.props.onUserScroll&&!f.props.maintainScrollAtEnd&&!f.maintainingScrollAtEnd&&!f.pendingMaintainScrollAtEnd&&!f.scrollingTo&&!f.pendingScrollResolve&&!jl(f))return!1;let p=t();if(n>0&&!p&&!(r&&f.props.onUserScroll))return!1;let m=Cm(x.current,C),h=D(),g=pc(f,M(),h);return!e.defaultPrevented&&m&&h>1&&(p||n===0||(n>0?g<h-1:g>1))&&j()?Dm(e.target,m,i,s(n))?((p?!c:n<=0)&&Uu(y,l&&e.cancelable?n:0)&&e.cancelable&&e.preventDefault(),r&&((d=(u=f.props).onUserScroll)==null||d.call(u)),!0):(l&&!a&&(o=!0),!1):!1},r,a=!1,o=!1,s=e=>sc(y.state)&&ac(y.state)!==`normal`?-e:e,c=e=>{let t=e,c=pm(i?t.deltaX||(t.shiftKey?t.deltaY:0):t.deltaY,t.deltaMode,y.state.scrollLength);c!==0&&!t.ctrlKey&&!t.defaultPrevented&&(r=mm(r,c,t.timeStamp,t.momentum),r.isNew&&(a=!1,o=!1),a=n(t,s(c),!a,!r.isNew&&(!o||a),!0)||a)},l,u=!1,d=e=>{let r=e.touches[0];l=r?i?r.clientX:r.clientY:void 0,u=!1,l!==void 0&&t()&&n(e,0,!1)},f=e=>{let t=e.touches[0];if(!t)return;let r=i?t.clientX:t.clientY;l!==void 0&&r!==l&&(u=n(e,s(l-r),!u)||u),l=r},p=e=>{let t=e,r=t.target;t.repeat||t.defaultPrevented||r?.isContentEditable||(r?.closest)?.call(r,`input, textarea, select, button, a, summary, [role=button], [role=checkbox], [role=radio], [role=menu], [role=menuitem], [role=listbox], [role=combobox], [role=slider], [role=tab], [role=tree]`)||(i?t.key!==`ArrowLeft`&&t.key!==`ArrowRight`||t.altKey||t.metaKey||n(t,s(t.key===`ArrowLeft`?-1:1)):t.key===`ArrowUp`||t.key===`PageUp`||t.key===`Home`||t.key===` `&&t.shiftKey?n(t,-1):(t.key===`ArrowDown`||t.key===`PageDown`||t.key===`End`||t.key===` `)&&n(t,1))},m,h=e=>{m=void 0;let r=e,a=Cm(x.current,C);if(r.target!==a||!a||r.pointerType===`touch`)return;let o=a.getBoundingClientRect(),s=getComputedStyle(a);if(i?r.clientY>=o.top+a.clientTop+a.clientHeight&&r.clientY<o.top+a.offsetHeight-(Number.parseFloat(s.borderBottomWidth)||0):r.clientX>=o.left+(Number.parseFloat(s.borderLeftWidth)||0)&&r.clientX<o.left+a.clientLeft||r.clientX>=o.left+a.clientLeft+a.clientWidth&&r.clientX<o.left+a.offsetWidth-(Number.parseFloat(s.borderRightWidth)||0)){let e=t(),i=M();n(r,0)&&!e&&(m=i)}},g=()=>{let e=m;m=void 0,e!==void 0&&M()===e&&vl(y)},_,v=t=>{t!==_&&(_!==void 0&&e.removeEventListener(`wheel`,c),e.addEventListener(`wheel`,c,{passive:t}),_=t)};v(!q(y,`isScrollActive`));let b=wc(y,`isScrollActive`,e=>v(!e));return e.addEventListener(`touchstart`,d,{passive:!0}),e.addEventListener(`touchmove`,f,{passive:!0}),e.addEventListener(`keydown`,p),e.addEventListener(`pointerdown`,h),e.addEventListener(`pointerup`,g),e.addEventListener(`pointercancel`,g),()=>{b(),e.removeEventListener(`wheel`,c),e.removeEventListener(`touchstart`,d),e.removeEventListener(`touchmove`,f),e.removeEventListener(`keydown`,p),e.removeEventListener(`pointerdown`,h),e.removeEventListener(`pointerup`,g),e.removeEventListener(`pointercancel`,g)}},[y,C,M,D,E,i,j]),(0,G.useEffect)(()=>{let e=()=>{a&&N(i?a.x||0:a.y||0,!1)};e();let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)},[a?.x,a?.y,i,N]),(0,G.useLayoutEffect)(()=>{let e=x.current;if(g&&e)return Om(e,C,()=>{T&&!y.state.lastLayout&&!y.state.initialScroll&&(y.state.scroll=y.state.scrollPending=k()),g({nativeEvent:{layout:Tm(e,C,i)}}),T&&P()})},[y,P,C,k,i,T,g]);let R=!T&&(i?!d&&Am:!f&&jm);(0,G.useLayoutEffect)(()=>{R&&Fm()},[R]);let te={...T?{}:{overflow:`auto`,overflowX:i||d?`auto`:`hidden`,overflowY:i?f?`auto`:`hidden`:`auto`,WebkitOverflowScrolling:`touch`},...um.flatten(t),...o?{overflowAnchor:`none`}:{}},ne=Math.max(0,y.state.props.contentInsetEndAdjustment??0),re=y.state.props.anchoredEndSpace&&b?b:0,ie=Math.max(0,ne-re),ae=ie?i?{flexShrink:0,width:ie}:{height:ie}:void 0,z={display:i?`flex`:`block`,flexDirection:i?`row`:void 0,minHeight:i?void 0:`100%`,minWidth:i?`100%`:void 0,...um.flatten(r),...o?{overflowAnchor:`none`}:{}},B=n?`${km} ${n}`:km,{contentContainerClassName:oe,contentInset:se,scrollEventThrottle:ce,ScrollComponent:le,snapToOffsets:ue,className:de,...fe}=_,pe=T?[]:Im(ue);pe.length>0&&(te.scrollSnapType=i?`x mandatory`:`y mandatory`,z.position=z.position??`relative`);let me=R?de?`${de} ${R}`:R:de;return Lc&&/(?:^|\s)(?:[a-z0-9_-]+:)*gap(?:-[xy])?-(?:\[[^\]]+\]|[^\s]+)/.test(`${n??``} ${de??``}`)&&cu(`className-gap`,`className/contentContainerClassName gap classes are not supported in LegendList because it needs to use exact values internally. Use contentContainerStyle={{ gap: ... }} or columnWrapperStyle instead.`),G.createElement(`div`,{className:me,ref:x,...fe,style:te},p,G.createElement(`div`,{className:B,ref:S,style:z},pe.map(e=>G.createElement(`div`,{"aria-hidden":!0,"data-legend-list-snap-anchor":e,key:`snap-${e}`,style:Lm(e,i)})),e,ae?G.createElement(`div`,{"aria-hidden":!0,style:ae}):null))});function zm({horizontal:e,needsOtherAxisSize:t,otherAxisSize:n}){if(!(!t||!n||n<=0))return e?{height:n}:{width:n}}function Bm(e,t){let n=bc();(0,G.useLayoutEffect)(()=>wc(n,e,e=>{t(e)}),[t,n,e])}function Vm(e){return e?{contentSizeKey:`scrollWidth`,paddingEndProp:`paddingRight`,viewportSizeKey:`clientWidth`,x:1,y:0}:{contentSizeKey:`scrollHeight`,paddingEndProp:`paddingBottom`,viewportSizeKey:`clientHeight`,x:0,y:1}}function Hm(e,t){let n=e.state?.refScroller.current,r=(n?.getScrollableNode)?.call(n)??null,i=null;return r&&(i=(n?.getContentNode)?.call(n)??(t?.isConnected&&t.parentElement===r?t:r.querySelector(`:scope > .${km}`))),r?{contentNode:i,scrollElement:r}:null}function Um(e,t,n){e.scrollBy({behavior:`auto`,left:t,top:n})}function Wm(){let e=bc(),t=G.useRef(0),n=G.useRef(0),r=G.useRef(void 0),i=G.useRef(void 0),a=G.useRef(null),o=G.useCallback(()=>{let o=q(e,`scrollAdjust`),s=q(e,`scrollAdjustUserOffset`),c=(o||0)+(s||0);if(c-t.current!==0){let o=Hm(e,a.current);if(o){let t=!!e.state.props.horizontal,c=Vm(t),{contentNode:l,scrollElement:u}=o,d=e.state.refScroller.current,f=t?u.scrollLeft:u.scrollTop,p=e.state.props.hasExternalScroll,m=(p?(d?.getCurrentScrollOffset)?.call(d):void 0)??f,h=(d?.isScrollInRange)?.call(d)===!1,g=(s||0)-n.current,_=(g===0?e.state.scroll:m+g)-m,v=!h&&Math.abs(_)>.01,y=()=>Um(u,c.x*_,c.y*_);if(a.current=l,v&&l){let t=p?u[c.contentSizeKey]:l[c.contentSizeKey],n=u[c.viewportSizeKey],a=f+_;if(_>0&&!e.state.adjustingFromInitialMount&&t<a+n){let e=l.style[c.paddingEndProp],o=i.current,s=o?.value===e?o.baseline:e,u=(a+n-t)*2,d=`${(Number.parseFloat(window.getComputedStyle(l)[c.paddingEndProp])||0)+u}px`;l.style[c.paddingEndProp]=d,i.current={baseline:s,value:l.style[c.paddingEndProp]},l.offsetHeight,y(),r.current!==void 0&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let e=i.current;r.current=void 0,i.current=void 0,l.style[c.paddingEndProp]===e?.value&&(l.style[c.paddingEndProp]=e.baseline)})}else y()}else v&&y()}t.current=c,n.current=s||0}},[e]);return Bm(`scrollAdjust`,o),Bm(`scrollAdjustUserOffset`,o),null}var Gm=G.forwardRef(function({ScrollComponent:e,...t},n){let[r]=Dc([`snapToOffsets`]);return G.createElement(e,{...t,ref:n,snapToOffsets:r})}),Km=.1;function qm(e,t,n){let r=q(e,t)!==n;return r&&(J(e,t,n),ml(e)),r}function Jm(e,t,n){let{didContainersLayout:r,didFinishInitialScroll:i,props:a,scroll:o,scrollingTo:s}=e.state,c=n-t,l=((a.horizontal?a.stylePaddingLeft:a.stylePaddingTop)||0)+t;return a.maintainVisibleContentPosition.size&&r&&i&&!s&&o>=l-Km&&Math.abs(c)>Km}function Ym(e,t){let{state:n}=e,r=q(e,`headerSize`)||0,i=r!==t,a=n.didMeasureHeader||r>Km;i&&(J(e,`headerSize`,t),ml(e),a&&Jm(e,r,t)&&hl(e,t-r)),n.didMeasureHeader=!0,i&&Pl(e)}function Xm(e,t){let n=qm(e,`footerSize`,t);return n&&(pp(e),Pl(e)),n}function Zm(e,t){return(e?.top??0)===(t?.top??0)&&(e?.bottom??0)===(t?.bottom??0)&&(e?.left??0)===(t?.left??0)&&(e?.right??0)===(t?.right??0)}function Qm(e,t){let{state:n}=e,r=n.contentInsetOverride,i=t??void 0,a=!Zm(r,i);return n.contentInsetOverride=i,a&&ml(e),a}function $m(e,t){let n=Wp(e),r=Wp(t);return G.useMemo(()=>G.forwardRef((e,t)=>n.current?.call(n,r.current(e,t))??null),[r,n])}var eh=({onLayoutChange:e,refView:t,children:n,...r})=>{let i=(0,G.useRef)(null),a=t??i;return Gp({onLayoutChange:e,ref:a}),G.createElement(`div`,{...r,ref:a},n)},th=()=>()=>{},nh=Dp(function({horizontal:e}){let[t=0]=Dc([`alignItemsAtEndPadding`]);return t<=0?null:G.createElement($s,{style:e?{flexShrink:0,width:t}:{flexShrink:0,height:t}},null)}),rh=Dp(function({canRender:e,freshDataTransitionEpoch:t,style:n,contentContainerStyle:r,horizontal:i,initialContentOffset:a,recycleItems:o,ItemSeparatorComponent:s,alignItemsAtEnd:c,onScroll:l,onScrollToTop:u,onLayout:d,ListHeaderComponent:f,ListHeaderComponentStyle:p,ListFooterComponent:m,ListFooterComponentStyle:h,ListEmptyComponent:g,getRenderedItem:_,refScrollView:v,renderScrollComponent:y,onLayoutFooter:b,onInternalScrollBeginDrag:x,onInternalScrollEndDrag:S,onInternalScrollEnd:C,scrollAdjustHandler:w,snapToIndices:T,stickyHeaderConfig:E,stickyHeaderIndices:D,useWindowScroll:O=!1,scrollElement:k,...A}){let j=bc(),M=j.state.props.maintainVisibleContentPosition,[N=0,P=0]=Dc([`anchoredEndSpaceSize`,`otherAxisSize`]),F=j.state.props.alignItemsAtEndPaddingEnabled,I=!!j.state.props.anchoredEndSpace&&j.state.props.anchoredEndSpaceOwner===`list`&&N>0,ee;if(I){let e=i?sc(j.state)?`Left`:`Right`:`Bottom`,t=um.flatten(r);ee={[`padding${e}`]:fu({},t||{},e)+N}}let L=zm({horizontal:i,needsOtherAxisSize:j.state.needsOtherAxisSize,otherAxisSize:P}),R=$m(y,(e,t)=>({...e,ref:t})),te=y?R:Rm,ne=T?Gm:te,re=(0,G.useCallback)((e,t)=>{let n=Xm(j,e);t?.(),n&&j.state.props.maintainScrollAtEnd?.onFooterLayout&&Yu(j)},[j]);(0,G.useLayoutEffect)(()=>{f||Ym(j,0),m||re(0)},[f,m,j,re]),(0,G.useCallback)(e=>{var t,n;Uu(j);let r=j.state.accessibilityScrollEvent;r&&(r.time=void 0),(n=(t=j.state.props).onUserScroll)==null||n.call(t),u?.(e)},[j,u]);let{onContentSizeChange:ie}=A;(0,G.useCallback)((e,t)=>{Ju(j),ie?.(e,t)},[j,ie]);let ae=(0,G.useCallback)(e=>{let t=e[i?`width`:`height`];Ym(j,t)},[j,i]),z=(0,G.useCallback)((e,t)=>{let n=e[i?`width`:`height`];re(n,()=>{b?.(e,t)})},[i,b,re]);return G.createElement(ne,{...A,...te===Rm?{onInternalScrollEnd:C,scrollElement:k,useWindowScroll:O}:{},contentContainerStyle:[i?{height:`100%`}:{},r,ee,{boxSizing:`border-box`}],contentOffset:a===void 0?void 0:i?{x:a,y:0}:{x:0,y:a},horizontal:i,maintainVisibleContentPosition:M.size||M.data?{minIndexForVisible:0}:void 0,onLayout:d,onScroll:l,ref:v,ScrollComponent:T?te:void 0,style:L?[L,n]:n},G.createElement(Wm,null),f&&G.createElement(eh,{onLayoutChange:ae,style:p},kp(f)),g&&kp(g),F&&G.createElement(nh,{horizontal:i}),e&&!g&&G.createElement(cm,{freshDataTransitionEpoch:t,getRenderedItem:_,horizontal:i,ItemSeparatorComponent:s,recycleItems:o,stickyHeaderConfig:E}),m&&G.createElement(eh,{onLayoutChange:z,style:h},kp(m)),Lc&&Hc)}),ih=100,ah=.9,oh=.9;function sh(e){let t=bc(),{anchoredEndSpace:n,childrenMode:r,keyExtractor:i,numColumns:a,renderScrollComponent:o,scrollElement:s,useWindowScroll:c}=e,l=!!n;(0,G.useEffect)(()=>globalThis.__LEGEND_LIST_DEV_HOOK__?.call(globalThis,t),[t]),(0,G.useEffect)(()=>{l&&(a??1)>1&&cu(`anchoredEndSpaceNumColumns`,`anchoredEndSpace is only supported when numColumns is 1. Using it with multiple columns may produce incorrect anchored spacing.`)},[l,a]),(0,G.useEffect)(()=>{(c||s!==void 0)&&o&&cu(`useWindowScrollRenderScrollComponent`,`useWindowScroll and scrollElement are not supported when renderScrollComponent is provided.`)},[o,s,c]),(0,G.useEffect)(()=>{!i&&!t.state.isFirst&&t.state.didDataChange&&!r&&cu(`keyExtractor`,`Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior.`)},[r,t,i]),(0,G.useEffect)(()=>{let e=t.state,n=e.props.data.length;if(e.props.hasExternalScroll||n<ih)return;let r=()=>{let e=q(t,`readyToRender`),r=q(t,`numContainers`)||0,i=q(t,`totalSize`)||0,a=t.state.scrollLength||0;if(!e||i<=0||a<=0)return;let o=r>=Math.ceil(n*ah),s=a>=i*oh;o&&s&&cu(`webUnboundedOuterSize`,`LegendList appears to have an unbounded outer height on web, so virtualization is effectively disabled. Set a bounded height or flex: 1 on the list container, or use useWindowScroll.`)};r();let i=[wc(t,`numContainers`,r),wc(t,`readyToRender`,r),wc(t,`totalSize`,r)];return()=>{for(let e of i)e()}},[t])}function ch(e){}var lh=Lc?sh:ch;function uh(e,t,{didColumnsChange:n=!1}={}){let r=e.state,{previousData:i}=r,{maintainScrollAtEnd:a}=r.props;if(n){r.sizes.clear(),r.sizesKnown.clear(),vf(r);for(let e in r.averageSizes)delete r.averageSizes[e];r.positionRecalculationStartIndex=0,r.scrollForNextCalculateItemsInView=void 0}if(r.positionsAreCurrent=!1,fp(e,{dataChanged:!0,doMVCP:!0}),r.pendingEndMeasurements?.size){let e=new Set(r.pendingEndMeasurements);for(let n=0;n<t.length&&e.size;n++)e.delete(nu(r,n));for(let t of e)r.pendingEndMeasurements.delete(t)}let o=Md(r,n);if(o&&!a?.onItemLayout&&i&&t.length>i.length){r.pendingEndMeasurements??=new Set;for(let e=i.length;e<t.length;e++){let t=nu(r,e);r.sizesKnown.has(t)||r.pendingEndMeasurements.add(t)}}let s=o&&Yu(e);!s&&!r.pendingMaintainScrollAtEnd&&(r.pendingEndMeasurements=void 0),s||Pl(e),delete r.previousData}function dh(e,t,n){if(e.pendingDataComparison=void 0,!n||!t||t.length!==n.length)return!0;let{idCache:r,props:{itemsAreEqual:i,keyExtractor:a}}=e,o;for(let s=0;s<t.length;s++){if(t[s]===n[s])continue;if(!a||(r[s]??a(n[s],s))!==a(t[s],s)||!i)return o&&(e.pendingDataComparison={byIndex:o,nextData:t,previousData:n}),!0;let c=i(n[s],t[s],s,t);if(o??=[],o[s]=c?1:2,!c)return e.pendingDataComparison={byIndex:o,nextData:t,previousData:n},!0}return!1}var fh=`containerLayoutReady`;function ph(e){for(let t of e.values.keys())t.startsWith(fh)&&J(e,t,void 0)}function mh(e){let t=e.state,{scrollLength:n,props:{data:r,getFixedItemSize:i,getItemType:a,numColumns:o,estimatedItemSize:s}}=t,c=Gl(e),l=q(e,`numContainers`);if(n>0&&r.length>0&&!l){let l;if(i){let t=0,n=Math.min(20,r.length);for(let o=0;o<n;o++){let n=r[o];if(n!==void 0){let r=a?.(n,o)??``;t+=(i(n,o,r)??s)+e.scrollAxisGap}}l=t/n}else l=s+e.scrollAxisGap;let u=Math.max(1,Math.ceil((n+c*2)/l*o));for(let t=0;t<u;t++)J(e,`containerPosition${t}`,Rc),J(e,`containerColumn${t}`,-1),J(e,`containerSpan${t}`,1);return J(e,`numContainers`,u),J(e,`numContainersPooled`,Kf(r.length,u)),t.lastLayout&&(t.initialScroll?requestAnimationFrame(()=>{fp(e,{dataChanged:!0,doMVCP:!0})}):fp(e,{dataChanged:!(!t.didLoad&&t.positionsAreCurrent&&!t.didDataChange&&!t.didColumnsChange),doMVCP:!0})),!0}}function hh(e,{index:t,key:n,viewOffset:r=0,animated:i=!0,forceScroll:a,isInitialScroll:o,clampToContentContainerMinSize:s,viewPosition:c,viewPositionFallback:l}){let u=e.state,{data:d}=u.props;t=Wu(t,d.length);let f=vu(e,t),p=Wc(e,t);t===d.length-1&&c===void 0&&(c=1),u.scrollForNextCalculateItemsInView=void 0,wd(e,{animated:i,clampToContentContainerMinSize:s,forceScroll:a,index:t,isInitialScroll:o,itemSize:f,key:n,offset:p,viewOffset:r,viewPosition:c??0,viewPositionFallback:l})}function gh(){return typeof window>`u`?{height:0,width:0}:{height:window.innerHeight,width:window.innerWidth}}function _h(e,t,n){let r=e.state;oc(r);let{maintainScrollAtEnd:i,useWindowScroll:a}=r.props,o=r.props.horizontal?`width`:`height`,s=r.props.horizontal?`height`:`width`,c=t;if(a){let e=gh()[o];c=e>0?{...t,[o]:e}:t}let l=c[o],u=r.scrollLength,d=l>0?l:u,f=c[s],p=!r.lastLayout||d>r.scrollLength||r.lastLayout.x!==c.x||r.lastLayout.y!==c.y;r.lastLayout=c;let m=r.otherAxisSize,h=d!==r.scrollLength||f!==m;if(h){r.scrollLength=d,r.otherAxisSize=f,ml(e),r.lastBatchingAction=Date.now(),r.scrollForNextCalculateItemsInView=void 0;let t=d>0&&mh(e);p&&(!t||r.initialScroll)&&fp(e,{doMVCP:!0});let n=r.scrollingTo;d!==u&&n?.viewPositionFallback&&!n.isInitialScroll&&n.index!==void 0&&hh(e,{...n,forceScroll:!0,index:n.index}),(h||f!==m)&&J(e,`scrollSize`,{height:c.height,width:c.width}),i?.onLayout&&Yu(e,{immediate:!0}),Pl(e),r&&(r.needsOtherAxisSize=f-(r.props.horizontal?(r.props.stylePaddingTop||0)+(r.props.stylePaddingBottom||0):(r.props.stylePaddingLeft||0)+(r.props.stylePaddingRight||0))<10),Lc&&l===0&&cu(`height0`,`List ${r.props.horizontal?`width`:`height`} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`)}n(!0)}function vh(e,t){let n=ll.get(e);n&&ll.didReachTarget(t,n)?ll.clear(e):n&&(e.hasScrolled=!1,ll.set(e,{startScroll:n.startScroll,targetOffset:n.targetOffset}))}function yh(e){return!!e.initialScroll&&e.initialScrollSession?.kind===`bootstrap`&&!e.didFinishInitialScroll}function bh(e){return{...e,nativeEvent:{...e.nativeEvent}}}function xh(e,t,n=!0){let r=e.state,{scrollProcessingEnabled:i}=r;if(i===!1||t.nativeEvent?.contentSize?.height===0&&t.nativeEvent.contentSize?.width===0)return;let a=!1;if(t.nativeEvent?.contentInset){let{contentInset:e}=t.nativeEvent,n=r.nativeContentInset;n&&n.top===e.top&&n.bottom===e.bottom&&n.left===e.left&&n.right===e.right||(r.nativeContentInset=e,a=!0)}let o=t.nativeEvent.contentOffset[r.props.horizontal?`x`:`y`];if(r.props.horizontal&&(o=mc(r,o,t.nativeEvent.contentSize?.width)),r.didFinishInitialScroll&&r.initialScroll?.viewPosition===1&&(r.scroll,r.scrollLength),r.accessibilityScrollEvent&&=void 0,r.lastNativeScroll=o,r.lastNativeScrollTime=Date.now(),r.scheduledWork.has(`appScrollRearm`)&&_l(e),!r.props.hasExternalScroll&&r.scrollingTo&&!r.scrollingTo.animated&&r.scrollingTo.offset>=o){let t=Zc(e,o,r.scrollingTo);if(o!==t&&Math.abs(o-t)>1){(r.scrollingTo.isInitialScroll||Math.abs(r.scroll-t)>1)&&wd(e,{forceScroll:!0,isInitialScroll:!0,noScrollingTo:!0,offset:t});return}}let s=r.scroll,c=!!r.preservedEndAnchorCorrection;r.scrollPending=o,zu(e,o,a,{fromNativeScrollEvent:!0}),vh(r,o),rf(e,!c&&Math.abs(o-s)>1),r.scrollingTo&&td(e),n&&r.props.onScroll&&(yh(r)?r.deferredPublicOnScrollEvent=bh(t):r.props.onScroll(t))}var Sh=class{constructor(){this.work=new Map}microtask(e,t){let n=this.work.get(t);if(n?.callback)n.callback=e;else{this.cancel(t);let n={callback:e,cancel:()=>{}};this.work.set(t,n),queueMicrotask(()=>{var e;this.work.get(t)===n&&(this.work.delete(t),(e=n.callback)==null||e.call(n))})}}timeout(e,t,n){n&&this.cancel(n);let r={cancel:()=>clearTimeout(i)},i=setTimeout(()=>{let t=n??i;this.work.get(t)===r&&(this.work.delete(t),e())},t);this.work.set(n??i,r)}frame(e,t){this.cancel(t);let n={cancel:()=>cancelAnimationFrame(r)};this.work.set(t,n);let r=requestAnimationFrame(()=>{this.work.get(t)===n&&(this.work.delete(t),e())})}register(e,t){this.cancel(e),this.work.set(e,{cancel:t})}cancel(e){let t=this.work.get(e);t&&(this.work.delete(e),t.cancel())}has(e){return this.work.has(e)}dispose(){for(let e of this.work.values())e.cancel();this.work.clear()}},Ch=class{constructor(e){this.appliedAdjust=0,this.pendingAdjust=0,this.supersededAdjust=0,this.ctx=e}requestAdjust(e){let t=this.ctx.state.scrollingTo;t?.animated&&!t.isInitialScroll?(this.pendingAdjust+=e,J(this.ctx,`scrollAdjustPending`,this.pendingAdjust)):(this.appliedAdjust+=e,J(this.ctx,`scrollAdjust`,this.appliedAdjust)),this.ctx.state.scrollingTo&&td(this.ctx)}getAdjust(){return this.appliedAdjust}getUnsupersededPendingAdjust(){return this.pendingAdjust-this.supersededAdjust}supersedePendingAdjust(){this.supersededAdjust=this.pendingAdjust}commitPendingAdjust(e){{let t=this.ctx.state,n=this.pendingAdjust,r=e?this.supersededAdjust:0;if(this.pendingAdjust=0,this.supersededAdjust=0,n!==0){let i;if(e?.index!==void 0){let t=Wc(this.ctx,e.index);i=bu(this.ctx,t,e),i=Zc(this.ctx,i,e)}else i=Zc(this.ctx,t.scroll+n-r,{clampToContentContainerMinSize:!e||e.clampToContentContainerMinSize});let a=i-t.scroll;(Math.abs(a)>.1||Math.abs(n)>.1)&&(this.appliedAdjust+=a,t.scroll=i,t.scrollForNextCalculateItemsInView=void 0,J(this.ctx,`scrollAdjust`,this.appliedAdjust)),J(this.ctx,`scrollAdjustPending`,0),fp(this.ctx)}}}};function wh(e,t){let n=e.state,r=n.props.data.length-1;if(r===-1)return!1;let i=lc(n.props),a=q(e,`footerSize`)||0;return hh(e,{...t,clampToContentContainerMinSize:!0,index:r,viewOffset:tl(i,a)+(t?.viewOffset||0),viewPosition:1}),n.scrollingTo&&(n.scrollingTo.isScrollToEnd=!0),!0}function Th(e,t){let n=e.state,r=Ac(e,t),i=Ac(e)-r;if(i!==0){let t=!!q(e,`isWithinMaintainScrollAtEndThreshold`);zu(e,n.scroll,!0,{markHasScrolled:!1}),!Ef(e)&&t&&i>0&&hl(e,i)}}function Eh(e){e.state.scheduledWork.timeout(()=>{let t=e.state,n=t.isMomentumScrolling?Vc:Bc;Date.now()-(t.lastNativeScrollTime??0)<n?Eh(e):Dh(e)},Bc,`endFollowRearm`)}function Dh(e){let t=e.state;if(t.isDragging)return;t.scheduledWork.cancel(`endFollowRearm`),t.isMomentumScrolling=!1,Kc(e);let n=t.userScrollContentSize;if(t.userScrollContentSize=void 0,n===void 0){vl(e);return}if(t.scrollingTo||t.pendingScrollResolve||e.scrollRequestTracker?.isWaitingToRun()||t.scheduledWork.has(`appScrollRearm`))return;let r=jc(e),i=Math.max(0,r-t.scroll-t.scrollLength),a=Math.max(0,r-n);J(e,`isWithinMaintainScrollAtEndThreshold`,i-a<=Math.max(zc,(t.props.maintainScrollAtEndThreshold??0)*t.scrollLength)),t.endFollowInterrupted=!0,J(e,`isFollowingEnd`,!1),vl(e),q(e,`isFollowingEnd`)&&a>0&&i>zc&&Yu(e)}function Oh(e){return(0,G.useMemo)(()=>e?(t,n,r)=>t!==void 0&&n!==void 0?e(t,n,r):void 0:void 0,[e])}var kh=(...e)=>(0,G.useCallback)(t=>{for(let n of e)n&&(au(n)?n(t):n.current=t)},e);function Ah(e){return null}function jh(e,t,n,r){return r}function Mh(e){let{gap:t,columnGap:n,rowGap:r}=e;if(t||n||r)return e.gap=void 0,e.columnGap=void 0,e.rowGap=void 0,{columnGap:n,gap:t,rowGap:r}}var Nh=`default`;function Ph(e){let t={};for(let n in e.averageSizes){let r=e.averageSizes[n];r&&(t[n||Nh]={average:r.avg,count:r.num})}return t}function Fh(e){jf(e)}function Ih(e,t){let n=e.state,r=qu(e),i=()=>!!n.didDataChange||!!n.didColumnsChange||n.scheduledWork.has(`mvcpRecalculate`)||n.ignoreScrollFromMVCP!==void 0,a=(t,r=!1)=>{let i=n.props,a=i.data.length,o=i.anchoredEndSpace?.anchorIndex;return t<0?r:t>=a?!1:o===void 0||o<0||o>=a||t<o||gu(e,o,a-1)},o=e=>{if(n.props.keyExtractor)return n.indexByKey.get(e);let t=Number(e);return Number.isInteger(t)&&String(t)===e&&t>=0&&t<n.props.data.length?t:void 0},s=(e,t,a,o)=>{let s=()=>r.runNow(e,t,a);if(!i()&&o()){s();return}let c=Date.now(),l=0,u=()=>{if(!r.isCurrent(e))return;i()||!o()?l=0:l+=1;let t=Date.now()-c>=800;l>=2||t?s():n.scheduledWork.frame(u,`imperativeScrollReady`)};n.scheduledWork.frame(u,`imperativeScrollReady`)},c=(t,i=()=>!0)=>new Promise(a=>{if(n.isUnmounted){a();return}let o=r.start(a);Ql(e),s(o,a,t,i)});n.runPendingScrollToEnd=()=>{let t=n.pendingScrollToEnd;t&&(n.pendingScrollToEnd=void 0,r.isCurrent(t.token)&&s(t.token,n.pendingScrollResolve,()=>n.props.data.length===0?`unreachable`:wh(e,t.options),()=>a(n.props.data.length-1,!0)))};let l=t=>{let{index:r,itemOffset:i,itemLength:a,viewportMargin:o,...s}=t;if(r<0||r>=n.props.data.length)return`unreachable`;let c=i!==void 0||a!==void 0,l=dl(e),u=Wc(e,r)+eu(e)+(i??0),d=c?a??0:(vu(e,r)??0)-e.scrollAxisGap,f=Yc(e),p=n.scrollLength-f-Ac(e),m=l+f+(o?.start??0),h=l+f+p-(o?.end??0);if(!c&&u<=m&&u+d>=h)return!1;let g=u<m,_=u+d>h;if(g||_){let t=g||d>h-m;return hh(e,{...s,index:r,viewOffset:c?(t?o?.start??0:p-(o?.end??0)-d)-(i??0):t?o?.start??0:-(o?.end??0),viewPosition:c||t?0:1,viewPositionFallback:`start`}),!0}return!1},u=n.refScroller,d=t=>{var i;let a=t?.mode??`sizes`;if(a===`sizes`&&n.didContainersLayout&&!q(e,`isFollowingEnd`)&&!n.scrollingTo&&!r.isWaitingToRun()){let t=n.scroll-eu(e),r=Sd(e,t,t+n.scrollLength);r!==void 0&&(n.visibleContentAnchor={key:nu(n,r),offset:n.scroll-n.positions[r],sizeOnly:!0})}n.sizesKnown.clear(),vf(n);for(let e in n.averageSizes)delete n.averageSizes[e];n.positionRecalculationStartIndex=0,n.scrollForNextCalculateItemsInView=void 0,n.pendingTotalSize=void 0,a===`full`&&(n.visibleContentAnchor=void 0,n.sizes.clear(),n.totalSize=0,J(e,`totalSize`,0),n.indexByKey.clear(),n.idCache.length=0,n.positions.length=0,n.columns.length=0,n.columnSpans.length=0),Fh(e),(i=n.triggerCalculateItemsInView)==null||i.call(n,{doMVCP:a===`sizes`,forceFullItemPositions:!0})},f=(t,r=!0)=>{let i=Qm(e,t);zu(e,n.scroll,!0,{markHasScrolled:!1}),i&&r&&(Ef(e)||Yu(e))};return{anchorVisibleContent:({key:t,hold:r=!0}={})=>{if(!n.didFinishInitialScroll||n.freshDataTransitionEpoch!==n.handledFreshDataTransitionEpoch)return;let i=dl(e),a=i-eu(e),s=t===void 0?Sd(e,a,a+n.scrollLength):o(t);if(s===void 0||n.positions[s]===void 0)return;let c=nu(n,s),l=a-n.positions[s];return r&&!(q(e,`isFollowingEnd`)&&q(e,`isAtEnd`))&&(zu(e,i,!0,{markHasScrolled:!1}),gl(e),n.visibleContentAnchor={key:c,offset:n.scroll-n.positions[s]}),{key:String(c),offset:l}},cancelScroll:()=>{_l(e),Bu(e)},clearCaches:d,flashScrollIndicators:()=>u.current.flashScrollIndicators(),getAnimatableRef:()=>{var e;return(e=u.current).getNativeScrollRef?.call(e)??u.current},getNativeScrollRef:()=>u.current,getScrollableNode:()=>u.current.getScrollableNode(),getScrollResponder:()=>u.current.getScrollResponder(),getState:()=>({activeStickyIndex:q(e,`activeStickyIndex`),contentLength:jc(e),data:n.props.data,dataKey:n.props.dataKey,distanceFromEnd:Math.max(0,jc(e)-dl(e)-n.scrollLength),elementAtIndex:t=>e.viewRefs.get(pu(e,nu(n,t)))?.current,end:n.endNoBuffer,endBuffered:n.endBuffered,getAverageItemSizes:()=>Ph(n),indexByKey:e=>n.indexByKey.get(e),isAtEnd:q(e,`isAtEnd`),isAtStart:q(e,`isAtStart`),isEndReached:n.isEndReached,isFollowingEnd:!!q(e,`isFollowingEnd`),isNearEnd:q(e,`isNearEnd`),isNearStart:q(e,`isNearStart`),isStartReached:n.isStartReached,isWithinMaintainScrollAtEndThreshold:q(e,`isWithinMaintainScrollAtEndThreshold`),listen:(t,n)=>wc(e,t,n),listenToPosition:(t,n)=>Tc(e,t,n),positionAtIndex:e=>n.positions[e],positionByKey:e=>{let t=n.indexByKey.get(e);return t===void 0?void 0:n.positions[t]},scroll:n.scroll,scrollLength:n.scrollLength,scrollVelocity:Iu(n),sizeAtIndex:e=>n.sizesKnown.get(nu(n,e)),sizes:n.sizesKnown,start:n.startNoBuffer,startBuffered:n.startBuffered}),reportContentInset:f,reportContentInsetForScrollInternal:e=>f(e,!1),reportViewabilityInsetEndInternal:t=>{let r=Number.isFinite(t)?Math.max(0,t):0;r!==(n.viewabilityInsetEnd??0)&&(n.viewabilityInsetEnd=r,n.viewabilityConfigCallbackPairs&&Ff(n,e,n.viewabilityConfigCallbackPairs,n.scrollLength,n.startNoBuffer??0,n.endNoBuffer??-1,n.startBuffered,n.endBuffered))},scrollIndexIntoView:e=>c(()=>l(e)),scrollItemIntoView:({item:e,...t})=>c(()=>{let r=n.props.data.indexOf(e);if(r!==-1){let e=l({index:r,...t});return e===!0&&n.scrollingTo&&n.props.keyExtractor&&(n.scrollingTo.key=nu(n,r)),e}return`unreachable`}),scrollToEnd:i=>new Promise(a=>{var o;if(n.isUnmounted){a();return}let s=r.start(a);n.endFollowInterrupted=!1,n.props.maintainScrollAtEnd&&J(e,`isFollowingEnd`,!0),n.pendingScrollToEnd={options:i,token:s},t?.(),Ql(e),t||(o=n.runPendingScrollToEnd)==null||o.call(n)}),scrollToIndex:t=>c(()=>n.props.data.length===0?`unreachable`:(hh(e,t),!0),t.index>=0?()=>a(t.index):void 0),scrollToItem:({item:t,...r})=>c(()=>{let i=n.props.data.indexOf(t);return i===-1?`unreachable`:(hh(e,{index:i,...r}),n.scrollingTo&&n.props.keyExtractor&&(n.scrollingTo.key=nu(n,i)),!0)}),scrollToKey:({key:t,...r})=>c(()=>{let i=o(t);return i===void 0?`unreachable`:(hh(e,{...r,index:i}),n.scrollingTo&&(n.scrollingTo.key=nu(n,i)),!0)},()=>{let e=o(t);return e!==void 0&&a(e)}),scrollToOffset:t=>c(()=>(wd(e,{...t,clampToContentContainerMinSize:!0}),!0)),setItemSize:(t,n)=>{bp(e,{itemKey:t,size:n})},setScrollProcessingEnabled:e=>{n.scrollProcessingEnabled=e},setVisibleContentAnchorOffset:t=>{J(e,`scrollAdjustUserOffset`,au(t)?t(q(e,`scrollAdjustUserOffset`)||0):t)}}}var Lh=(e,t)=>e-t,Rh=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.floor(e)):0,zh=(e,t,n)=>{n>=0&&n<t&&e.add(n)};function Bh(e,t,n,r){if(t.length===0)return[];let i=new Set,a=t.length,o=Rh(e?.top);if(o>0)for(let e=0;e<Math.min(o,a);e++)zh(i,a,e);let s=Rh(e?.bottom);if(s>0)for(let e=Math.max(0,a-s);e<a;e++)zh(i,a,e);if(e?.indices?.length)for(let t of e.indices)Number.isFinite(t)&&zh(i,a,Math.floor(t));if(e?.keys?.length){let r=new Set(e.keys);for(let e=0;e<a&&r.size>0;e++){let o=n(t[e],e);r.has(o)&&(zh(i,a,e),r.delete(o))}}if(r!==void 0&&Number.isFinite(r)){let e=Math.floor(r);for(let t=e>=0?e:a;t<a;t++)zh(i,a,t)}let c=Array.from(i);return c.sort(Lh),c}function Vh(e,t,n){let r=e.state;if(!r)return null;let i=r.containerItemMetadata.get(n),a=i&&i.dataChangeEpoch!==r.dataChangeEpoch,{indexByKey:o,props:{data:s,getItemType:c,renderItem:l}}=r,u=a?i.data:s,d=i?.itemIndex??o.get(t);if(d===void 0)return null;let f=null,p=q(e,`extraData`),m=a?i.itemData:u[d];return l&&!uu(m)&&(f=l({data:u,extraData:p,index:d,item:m,type:a?i.itemType??``:c?c(m,d)??``:``})),{index:d,item:m,renderedItem:f}}function Hh(e){if(!e)return;let t=e===!0?void 0:e,n=t?.on,r=!!t&&`on`in t;return{animated:t?.animated??!1,onDataChange:!r||n?.dataChange||(n?.dataAppend?`append`:!1),onFooterLayout:r?n?.footerLayout??!1:!0,onItemLayout:r?n?.itemLayout??!1:!0,onLayout:r?n?.layout??!1:!0}}function Uh(e){return e===!0?{data:!0,size:!0}:e&&typeof e==`object`?{data:e.data??!1,shouldRestorePosition:e.shouldRestorePosition,size:e.size??!0}:e===!1?{data:!1,size:!1}:{data:!1,size:!0}}function Wh(e,{stylePaddingTop:t}){let n=e.state;if(t!==void 0){let r=q(e,`stylePaddingTop`)||0;if(t<r){let t=q(e,`totalSize`)||0;J(e,`totalSize`,t+r),n.timeoutSetPaddingTop=setTimeout(()=>{t=q(e,`totalSize`)||0,J(e,`totalSize`,t-r)},16)}J(e,`stylePaddingTop`,t)}}function Gh(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(0),r=(0,G.useRef)(null),i=()=>{t.current&&=(clearTimeout(t.current),null)};return(0,G.useCallback)((e,a,...o)=>{{let s=Date.now();r.current=o,s-n.current>=a?(n.current=s,e(...o),i()):(i(),t.current=setTimeout(()=>{r.current&&=(n.current=Date.now(),e(...r.current),t.current=null,null)},a-(s-n.current)))}},[e])}function Kh(e,t){let n=Gh(`throttle`);return r=>n(e,t,{nativeEvent:r.nativeEvent})}var qh=Dp(Ep(function(e,t){let{children:n,data:r,renderItem:i,...a}=e,o=n!==void 0&&r===void 0?{...a,childrenMode:!0,data:(ou(n)?n:G.Children.toArray(n)).flat(1),renderItem:({item:e})=>e}:{...a,data:r||[],renderItem:i};return G.createElement(yc,null,G.createElement(Jh,{...o,ref:t}))})),Jh=Ep(function(e,t){(0,G.useEffect)(th,[]);let n=(0,G.useCallback)(e=>{},[]);e.recycleItems===void 0&&cu(`recycleItems-omitted`,`recycleItems was not provided, so it defaults to false. Set recycleItems explicitly to true for better performance with recycling-aware rows, or false to preserve remount-on-reuse behavior.`);let{alignItemsAtEnd:r=!1,anchoredEndSpace:i,alwaysRender:a,columnWrapperStyle:o,contentContainerStyle:s,contentInset:c,data:l=[],dataKey:u,dataVersion:d,drawDistance:f=250,contentInsetEndAdjustment:p,estimatedItemSize:m=100,estimatedListSize:h,extraData:g,getFixedItemSize:_,getItemType:v,horizontal:y,rtl:b,estimatedHeaderSize:x,initialScrollAtEnd:S=!1,initialScrollIndex:C,initialScrollOffset:w,experimental_adaptiveRender:T,experimental_hideItemsUntilMeasured:E,itemsAreEqual:D,keyExtractor:O,ListEmptyComponent:k,ListFooterComponent:A,ListFooterComponentStyle:j,ListHeaderComponent:M,maintainScrollAtEnd:N=!1,maintainScrollAtEndThreshold:P=.1,maintainVisibleContentPosition:F,numColumns:I=1,overrideItemLayout:ee,onEndReached:L,onEndReachedThreshold:R=.5,onItemSizeChanged:te,onMetricsChange:ne,onUserScroll:re,onLayout:ie,onLoad:ae,onReady:z,onMomentumScrollBegin:B,onMomentumScrollEnd:oe,onRefresh:se,onScroll:ce,onScrollBeginDrag:le,onScrollEndDrag:ue,onStartReached:de,onStartReachedThreshold:fe=.5,onStickyHeaderChange:pe,onFirstVisibleItemChanged:me,onViewableItemsChanged:he,progressViewOffset:ge,recycleItems:_e=!1,refreshControl:ve,refreshing:ye,refScrollView:be,renderScrollComponent:xe,renderItem:Se,scrollEventThrottle:Ce,snapToIndices:we,stickyHeaderIndices:Te,style:Ee,useWindowScroll:De=!1,scrollElement:Oe,viewabilityConfig:ke,viewabilityConfigCallbackPairs:Ae,...je}=e,Me=e.animatedPropsInternal,Ne=e.anchoredEndSpaceOwnerInternal??`list`,Pe=e.positionComponentInternal,Fe=e.stickyPositionComponentInternal,{anchoredEndSpaceOwnerInternal:Ie,positionComponentInternal:Le,stickyPositionComponentInternal:Re,...ze}=je,Be=um.flatten(s),Ve=r&&!y&&Be?.minHeight==null&&l.length>0,He=r&&!Ve&&(y?Be?.minWidth==null:Be?.minHeight==null),Ue=y?Be?.minWidth:Be?.minHeight,We=typeof Ue==`number`&&Number.isFinite(Ue)?Ue:void 0,Ge={...Be,...r&&!Ve?{display:`flex`,flexDirection:y?`row`:`column`,...He?{flexGrow:1}:{},justifyContent:`flex-end`}:{}},Ke={...um.flatten(Ee)},qe=fu(Ke,Ge,`Top`),Je=fu(Ke,Ge,`Bottom`),Ye=fu(Ke,Ge,`Left`),Xe=fu(Ke,Ge,`Right`),Ze=lc({horizontal:y,rtl:b,stylePaddingBottom:Je,stylePaddingLeft:Ye,stylePaddingRight:Xe}),Qe=Hh(N),$e=Uh(F),et=C!=null,tt=w!=null,nt=!S&&!et&&!tt&&cc({horizontal:y,rtl:b}),rt=!S&&!et&&(tt||nt||!1),it=S||et,at=typeof C==`number`&&!tt&&l.length>1&&C>=l.length-1,ot=S?{index:Math.max(0,l.length-1),preserveForBottomPadding:!0,viewOffset:tl(Ze),viewPosition:1}:et?typeof C==`object`?{index:C.index??0,preserveForBottomPadding:C.viewOffset===void 0&&C.viewPosition===1&&C.viewPositionFallback===void 0||void 0,viewOffset:C.viewOffset??(C.viewPosition===1&&C.viewPositionFallback===void 0?tl(Ze):0),viewPosition:C.viewPosition??0,viewPositionFallback:C.viewPositionFallback}:{index:C??0,preserveForBottomPadding:at?!0:void 0,viewOffset:w??(at?tl(Ze):0),viewPosition:at?1:void 0}:rt?{contentOffset:w??-0,index:0,viewOffset:0}:void 0,[st,ct]=G.useState(!Pc),[,lt]=G.useReducer(e=>e+1,0),V=bc();V.columnWrapperStyle=o||(Ge?Mh(Ge):void 0);let ut=y?V.columnWrapperStyle?.columnGap??V.columnWrapperStyle?.gap:V.columnWrapperStyle?.rowGap??V.columnWrapperStyle?.gap,dt=typeof ut==`number`&&Number.isFinite(ut)?ut:0,ft=(0,G.useRef)(null),pt=kh(ft,be),mt=O??((e,t)=>t.toString()),ht=Te,gt=p,_t=(0,G.useRef)(gt),vt=(0,G.useMemo)(()=>{let e=Bh(a,l,mt,i?.anchorIndex);return{arr:e,set:new Set(e)}},[i?.anchorIndex,a?.top,a?.bottom,(a?.indices)?.join(`,`),(a?.keys)?.join(`,`),l,u,d,mt]),yt=xe?void 0:Oe,bt=!!De&&yt===void 0&&!xe,xt=bt||yt!==void 0,St=(0,G.useRef)(void 0),Ct=!!ee,wt=(0,G.useRef)(Ct);if(!St.current){if(!V.state){let e=(h??{height:0,width:0})[y?`width`:`height`];V.values.set(`adaptiveRender`,T?.initialMode??`normal`),V.state={averageSizes:{},columnSpans:[],columns:[],containerItemGenerations:[],containerItemKeys:new Map,containerItemMetadata:new Map,contentInsetOverride:void 0,dataChangeEpoch:0,dataChangeNeedsScrollUpdate:!1,didColumnsChange:!1,didDataChange:!1,didLoad:!1,enableScrollForNextCalculateItemsInView:!0,endBuffered:-1,endNoBuffer:-1,endReachedSnapshot:void 0,firstFullyOnScreenIndex:-1,freshDataTransitionEpoch:0,handledDataChangeEpoch:0,handledFreshDataTransitionEpoch:0,hasHadNonEmptyData:l.length>0,idCache:[],idsInView:[],indexByKey:new Map,initialScroll:ot,initialScrollSession:ot?{kind:rt?`offset`:`bootstrap`,previousDataLength:l.length}:void 0,isEndReached:null,isFirst:!0,isStartReached:null,lastBatchingAction:Date.now(),lastLayout:void 0,lastScrollDelta:0,loadStartTime:Date.now(),nativeContentInset:void 0,nativeMarginTop:0,pendingDataComparison:void 0,pendingNativeMVCPAdjust:void 0,positionRecalculationStartIndex:0,positions:[],props:{},queuedCalculateItemsInView:0,refScroller:{current:null},scheduledWork:new Sh,scroll:0,scrollAdjustHandler:new Ch(V),scrollForNextCalculateItemsInView:void 0,scrollHistory:[],scrollLength:e,scrollPending:0,scrollPrev:0,scrollPrevTime:0,scrollProcessingEnabled:!0,scrollTime:0,sizes:new Map,sizesKnown:new Map,startBuffered:-1,startNoBuffer:-1,startReachedSnapshot:void 0,stickyContainerPool:new Set,stickyContainers:new Map,totalSize:0,viewabilityConfigCallbackPairs:void 0};let t=V.state;V.doMaintainScrollAtEnd=()=>Yu(V),V.doScrollTo=e=>gd(V,e),V.interruptUserScroll=()=>Uu(V),V.scrollTo=e=>wd(V,e),V.scrollToEnd=e=>wh(V,e),t.triggerCalculateItemsInView=e=>fp(V,e),t.reprocessCurrentScroll=()=>zu(V,t.scroll,!0),J(V,`maintainVisibleContentPosition`,$e),J(V,`extraData`,g),x!==void 0&&J(V,`headerSize`,x)}St.current=V.state}let H=St.current,Tt=H.isFirst,Et=H.props.adaptiveRender,Dt=H.props.hideItemsUntilMeasured,Ot=H.props.numColumns,kt=!Tt&&V.scrollAxisGap!==dt;V.scrollAxisGap=dt,H.didColumnsChange=I!==Ot||kt;let At=H.props.data?.length??0,jt=H.props.data!==l,Mt=H.props.dataKey!==u,Nt=H.props.dataVersion!==d,Pt=Mt||Nt||jt&&dh(H,l,H.props.data),Ft=!Tt&&Pt&&H.hasHadNonEmptyData&&(Mt||At===0)&&l.length>0;Pt&&!S&&H.didFinishInitialScroll&&H.initialScroll?.viewPosition===1&&H.props.data.length>0&&Zl(H),Pt&&(H.dataChangeEpoch+=1,H.dataChangeNeedsScrollUpdate=!0,H.didDataChange=!0,H.previousData=H.props.data),Ft&&(H.freshDataTransitionEpoch+=1);let It=H.dataChangeEpoch,Lt=H.freshDataTransitionEpoch,Rt=Kh(ce??n,Ce??0),zt=Ce&&ce?Rt:ce,Bt=!Tt&&!Pt&&H.props.anchoredEndSpace?.anchorIndex!==i?.anchorIndex;H.props={adaptiveRender:T,alignItemsAtEnd:r,alignItemsAtEndPaddingEnabled:Ve,alwaysRender:a,alwaysRenderIndicesArr:vt.arr,alwaysRenderIndicesSet:vt.set,anchoredEndSpace:i,anchoredEndSpaceOwner:Ne,animatedProps:Me,contentContainerAlignItems:Ge.alignItems,contentContainerMinSize:We,contentInset:c,contentInsetEndAdjustment:gt,data:l,dataKey:u,dataVersion:d,drawDistance:f,estimatedItemSize:m,getFixedItemSize:Oh(_),getItemType:Oh(v),hasExternalScroll:xt,hideItemsUntilMeasured:E,horizontal:!!y,itemsAreEqual:D,keyExtractor:Oh(mt),maintainScrollAtEnd:Qe,maintainScrollAtEndThreshold:P,maintainVisibleContentPosition:$e,numColumns:I,onEndReached:L,onEndReachedThreshold:R,onFirstVisibleItemChanged:me,onItemSizeChanged:te,onLoad:ae,onMetricsChange:ne,onMomentumScrollBegin:B,onMomentumScrollEnd:oe,onReady:z,onScroll:zt,onScrollBeginDrag:le,onScrollEndDrag:ue,onStartReached:de,onStartReachedThreshold:fe,onStickyHeaderChange:pe,onUserScroll:re,overrideItemLayout:ee,positionComponentInternal:Pe,recycleItems:!!_e,renderItem:Se,rtl:b,snapToIndices:we,stickyHeaderIndicesArr:ht??[],stickyHeaderIndicesSet:(0,G.useMemo)(()=>new Set(ht??[]),[ht?.join(`,`)]),stickyPositionComponentInternal:Fe,stylePaddingBottom:Je,stylePaddingLeft:Ye,stylePaddingRight:Xe,stylePaddingTop:qe,useWindowScroll:bt},H.refScroller=ft,!Tt&&Et&&!T&&Hl(V),!Tt&&Dt&&!E&&ph(V);let Vt=(0,G.useMemo)(()=>l.length?Array.from({length:Math.min(I,l.length)},(e,t)=>nu(H,l.length-1-t)):[],[l,u,d,I]),Ht=e=>{J(V,`lastItemKeys`,Vt),J(V,`numColumns`,I);let t=q(V,`stylePaddingTop`);Wh(V,{stylePaddingTop:qe}),St.current.props.stylePaddingBottom=Je,ml(V);let n=qe-t;e&&$e.size&&n&&t!==void 0&&tc.OS};Tt&&(Ht(!1),yf(H),Tf(V,!0));let Ut=(0,G.useMemo)(()=>{let e=H.initialScroll;if(!e)return;let t=e.contentOffset??Dd(V,e);return it&&H.initialScrollSession?.kind===`bootstrap`&&tc.OS===`web`?void 0:t},[it]);(0,G.useLayoutEffect)(()=>(H.isUnmounted=!1,(H.userScrollContentSize!==void 0||H.isMomentumScrolling)&&Eh(V),()=>{H.isUnmounted=!0,H.maintainingScrollAtEnd=void 0,H.pendingMaintainScrollAtEnd=!1,Jc(H),Kc(V),Ud(H),H.scheduledWork.dispose()}),[V,H]),(0,G.useLayoutEffect)(()=>{Of(V,{alwaysDispatchInitialScroll:nt,dataLength:l.length,hasFooterComponent:!!A,initialContentOffset:Ut,initialScrollAtEnd:S,useBootstrapInitialScroll:it})},[]),(Tt||Pt||H.didColumnsChange)&&(St.current.lastBatchingAction=Date.now(),!O&&!Tt&&Pt&&(St.current.sizes.clear(),St.current.positions.length=0,St.current.totalSize=0,J(V,`totalSize`,0))),Lc&&lh(e),(0,G.useLayoutEffect)(()=>{let e=H.handledDataChangeEpoch!==It,t=H.handledFreshDataTransitionEpoch!==Lt;H.handledDataChangeEpoch=It,H.handledFreshDataTransitionEpoch=Lt,t&&ql(V,{resetInitialScroll:!!ot,resetLayout:!0}),kf(V,{dataLength:l.length,didDataChange:e,didStartFreshData:t,initialScrollAtEnd:S,latestInitialScroll:ot,latestInitialScrollSessionKind:rt?`offset`:`bootstrap`,stylePaddingEnd:Ze,useBootstrapInitialScroll:it})},[l.length,u,It,Lt,S,Ze,it]),(0,G.useLayoutEffect)(()=>{var e;Bt&&(H.scrollForNextCalculateItemsInView=void 0,(e=H.triggerCalculateItemsInView)==null||e.call(H)),pp(V)},[V,l,d,i?.anchorIndex,i?.anchorMaxSize,i?.anchorOffset,Ne,c?.bottom,c?.left,c?.right,Bt,y,I,b,Je,Ye,Xe]),(0,G.useLayoutEffect)(()=>{let e=_t.current;_t.current=gt,Th(V,e)},[V,gt]);let Wt=(0,G.useCallback)(e=>{it&&sf(V,{dataLength:l.length,footerSize:e[y?`width`:`height`],initialScrollAtEnd:S,stylePaddingEnd:Ze})},[l.length,S,y,Ze,it]),{onLayout:Gt}=Gp({onLayoutChange:(0,G.useCallback)((e,t)=>{let n=H.scrollLength,r=H.otherAxisSize;_h(V,e,ct),pp(V);let i=n!==H.scrollLength||r!==H.otherAxisSize;it&&!t&&i&&cf(V),!it&&jd(V)},[l.length,S,Ze,it]),onLayoutProp:ie,ref:ft,webExternalScroll:xt});(0,G.useLayoutEffect)(()=>{we&&wf(V)},[we]),(0,G.useLayoutEffect)(()=>Ht(!0),[c?.bottom,c?.top,u,d,Vt.join(`,`),I,dt,Je,qe,Ve]);let Kt=(0,G.useRef)(c?.top);(0,G.useLayoutEffect)(()=>{Math.max(0,Kt.current??0),Kt.current,c?.top,Kt.current=c?.top},[c?.top]),(0,G.useLayoutEffect)(()=>{Pl(V)},[P]),(0,G.useLayoutEffect)(()=>{Qe?q(V,`isFollowingEnd`)&&Yu(V):yl(V)},[!!Qe]);let qt=(0,G.useRef)(vt);(0,G.useLayoutEffect)(()=>{let e=qt.current,t=e.set.size!==vt.set.size||e.arr.some(e=>!vt.set.has(e));qt.current=vt;let{didColumnsChange:n,didDataChange:r,isFirst:i,props:{data:a}}=H;!(a.length>0&&mh(V))&&!i&&(r||n)&&uh(V,a,{didColumnsChange:n}),t&&!r&&!n&&!i&&(H.scrollForNextCalculateItemsInView=void 0,fp(V)),r&&(H.pendingDataComparison=void 0),H.didColumnsChange=!1,H.didDataChange=!1,H.isFirst=!1},[l,u,d,I,dt,vt.arr.join(`,`)]);let Jt=(0,G.useRef)(_);(0,G.useLayoutEffect)(()=>{var e;let t=!!Jt.current;Jt.current=_,!Tt&&(_||t)&&(vf(H),H.positionsAreCurrent=!1,H.positionRecalculationStartIndex=0,H.scrollForNextCalculateItemsInView=void 0,(e=H.triggerCalculateItemsInView)==null||e.call(H,{doMVCP:!0,forceFullItemPositions:!0}),H.props.maintainScrollAtEnd?.onItemLayout&&Yu(V))},[!!_,g]),(0,G.useLayoutEffect)(()=>{var e;J(V,`extraData`,g);let t=wt.current!==Ct;wt.current=Ct,(Ct||t)&&I>1&&((e=H.triggerCalculateItemsInView)==null||e.call(H,{forceFullItemPositions:!0}))},[g,Ct,I]),(0,G.useEffect)(()=>{if(!ne)return;let e,t=()=>{var t,n;let r={footerSize:q(V,`footerSize`)||0,headerSize:q(V,`headerSize`)||0};e&&r.headerSize===e.headerSize&&r.footerSize===e.footerSize||(e=r,(n=(t=H.props).onMetricsChange)==null||n.call(t,r))};t();let n=[wc(V,`headerSize`,t),wc(V,`footerSize`,t)];return()=>{for(let e of n)e()}},[V,!!ne]),(0,G.useEffect)(()=>{let e=Pf({onViewableItemsChanged:he,viewabilityConfig:ke,viewabilityConfigCallbackPairs:Ae});H.viewabilityConfigCallbackPairs=e,H.enableScrollForNextCalculateItemsInView=!0,e&&(H.scrollForNextCalculateItemsInView=void 0)},[ke,Ae,he]),Pp(()=>{}),(0,G.useImperativeHandle)(t,()=>Ih(V,lt),[]),(0,G.useLayoutEffect)(()=>{var e;(e=H.runPendingScrollToEnd)==null||e.call(H)}),(0,G.useEffect)(()=>{it||jd(V)},[V,it]);let Yt=(0,G.useMemo)(()=>({getRenderedItem:(e,t)=>Vh(V,e,t),onMomentumScrollBegin:e=>{var t,n;H.isMomentumScrolling=!0,J(V,`isScrollActive`,!0),Eh(V),(n=(t=H.props).onMomentumScrollBegin)==null||n.call(t,e)},onMomentumScrollEnd:e=>{var t,n;xh(V,e,!1),Dh(V),ld(V),(n=(t=H.props).onMomentumScrollEnd)==null||n.call(t,e)},onScroll:e=>xh(V,e),onScrollBeginDrag:e=>{var t,n,r,i;H.isMomentumScrolling=!1,H.userScrollContentSize=void 0,H.scheduledWork.cancel(`endFollowRearm`),H.isDragging=!0,Uu(V),(n=(t=H.props).onUserScroll)==null||n.call(t),kl(V),(i=(r=H.props).onScrollBeginDrag)==null||i.call(r,e)},onScrollEnd:()=>kl(V),onScrollEndDrag:e=>{var t,n;xh(V,e,!1),H.isDragging=!1,Kc(V),H.userScrollContentSize=jc(V),Eh(V),(n=(t=H.props).onScrollEndDrag)==null||n.call(t,e)}}),[]),Xt=jh(ht,y,V,Yt.onScroll),Zt=ve;return G.createElement(G.Fragment,null,G.createElement(rh,{...ze,alignItemsAtEnd:r,canRender:st,contentContainerStyle:Ge,contentInset:c,freshDataTransitionEpoch:H.freshDataTransitionEpoch,getRenderedItem:Yt.getRenderedItem,horizontal:y,initialContentOffset:Ut,ListEmptyComponent:l.length===0?k:void 0,ListFooterComponent:A,ListFooterComponentStyle:j,ListHeaderComponent:M,onInternalScrollBeginDrag:Yt.onScrollBeginDrag,onInternalScrollEnd:Yt.onScrollEnd,onInternalScrollEndDrag:Yt.onScrollEndDrag,onLayout:Gt,onLayoutFooter:Wt,onMomentumScrollBegin:Yt.onMomentumScrollBegin,onMomentumScrollEnd:Yt.onMomentumScrollEnd,onScroll:Xt,recycleItems:_e,refreshControl:Zt?qe>0?G.cloneElement(Zt,{progressViewOffset:(Zt.props.progressViewOffset??0)+qe}):Zt:se&&G.createElement(Ah,{onRefresh:se,progressViewOffset:(ge||0)+qe,refreshing:!!ye}),refScrollView:pt,renderScrollComponent:xe,scrollAdjustHandler:St.current?.scrollAdjustHandler,scrollElement:yt,scrollEventThrottle:0,snapToIndices:we,stickyHeaderIndices:ht,style:Ke,useWindowScroll:bt}),Lc&&Uc)}),Yh=qh;function Xh({rootRef:e,disabled:t=!1}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(t){i(!1);return}let r=e.current,a=n.current;if(!r||!a)return;let o=new IntersectionObserver(([e])=>{i(e.intersectionRatio<1)},{root:r,threshold:[1]});return o.observe(a),()=>o.disconnect()},[t,e]),{sentinelRef:n,isStuck:r}}var Y=Jn()(e=>({commitModeInFlight:null,isGitHubPublishModalOpen:!1,patchesByPath:{},patchErrorsByPath:{},loadingPatchPaths:{},setCommitModeInFlight:t=>e({commitModeInFlight:t}),setIsGitHubPublishModalOpen:t=>e({isGitHubPublishModalOpen:t}),reconcilePatches:(t,n)=>e(e=>({patchesByPath:Object.fromEntries(Object.entries(e.patchesByPath).filter(([e])=>t.includes(e)&&n(e))),patchErrorsByPath:Object.fromEntries(Object.entries(e.patchErrorsByPath).filter(([e])=>t.includes(e)&&n(e))),loadingPatchPaths:Object.fromEntries(Object.entries(e.loadingPatchPaths).filter(([e])=>t.includes(e)&&n(e)))})),setPatchLoading:t=>e(e=>({loadingPatchPaths:{...e.loadingPatchPaths,[t]:!0}})),clearPatchLoading:t=>e(e=>({loadingPatchPaths:yn(e.loadingPatchPaths,t)})),clearPatchError:t=>e(e=>t in e.patchErrorsByPath?{patchErrorsByPath:yn(e.patchErrorsByPath,t)}:e),setPatchResult:(t,n)=>e(e=>({patchesByPath:{...e.patchesByPath,[t]:n}})),setPatchError:(t,n)=>e(e=>({patchErrorsByPath:{...e.patchErrorsByPath,[t]:n}})),branchSwitcherOpen:!1,mergeModalOpen:!1,branchSwitcherIsLoading:!1,branchSwitcherIsMutating:!1,branchSwitcherQuery:``,branchSwitcherEntryView:`branches`,branchList:null,branchSwitcherError:null,setBranchSwitcherOpen:t=>e({branchSwitcherOpen:t}),setMergeModalOpen:t=>e({mergeModalOpen:t}),setBranchSwitcherIsLoading:t=>e({branchSwitcherIsLoading:t}),setBranchSwitcherIsMutating:t=>e({branchSwitcherIsMutating:t}),setBranchSwitcherQuery:t=>e({branchSwitcherQuery:t}),setBranchSwitcherEntryView:t=>e({branchSwitcherEntryView:t}),setBranchList:t=>e({branchList:t}),setBranchSwitcherError:t=>e({branchSwitcherError:t}),mergeBranchQuery:``,mergeBranchSelectedName:null,mergePreview:null,mergePreviewError:null,isMergePreviewLoading:!1,isMergeBranching:!1,setMergeBranchQuery:t=>e({mergeBranchQuery:t}),setMergeBranchSelectedName:t=>e({mergeBranchSelectedName:t}),setMergePreview:t=>e({mergePreview:t}),setMergePreviewError:t=>e({mergePreviewError:t}),setIsMergePreviewLoading:t=>e({isMergePreviewLoading:t}),setIsMergeBranching:t=>e({isMergeBranching:t}),resetMergeBranchModal:()=>e({mergeBranchQuery:``,mergeBranchSelectedName:null,mergePreview:null,mergePreviewError:null,isMergePreviewLoading:!1,isMergeBranching:!1}),resetMergePreview:()=>e({mergePreview:null,mergePreviewError:null,isMergePreviewLoading:!1}),publishInfo:null,isLoadingPublishInfo:!1,publishOwner:``,publishName:``,publishVisibility:`private`,publishDescription:``,publishAvailability:null,isCheckingPublishAvailability:!1,isPublishing:!1,setPublishInfo:t=>e({publishInfo:t}),setIsLoadingPublishInfo:t=>e({isLoadingPublishInfo:t}),setPublishOwner:t=>e({publishOwner:t}),setPublishName:t=>e({publishName:t}),setPublishVisibility:t=>e({publishVisibility:t}),setPublishDescription:t=>e({publishDescription:t}),setPublishAvailability:t=>e({publishAvailability:t}),setIsCheckingPublishAvailability:t=>e({isCheckingPublishAvailability:t}),setIsPublishing:t=>e({isPublishing:t})})),Zh=Qn(`DiffFileCard`,()=>e=>({selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t})}));function Qh({label:e,fact:t,className:n}){return(0,K.jsxs)(`div`,{className:B(`flex items-baseline gap-2 px-1 py-1 font-mono text-xs tracking-wide tabular-nums text-muted-foreground`,n),children:[(0,K.jsx)(`span`,{children:e}),t===void 0?null:(0,K.jsx)(`span`,{className:`ml-auto pl-3 truncate`,children:t})]})}function $h(e){switch(e.kind){case`local`:return 0;case`pull_request`:return 1;default:return 2}}function eg(e){let t=new Map;for(let n of e){let e=t.get(n.name);(!e||$h(n)<$h(e))&&t.set(n.name,n)}return t}function tg(e,t){let n=eg([...e.local,...e.pullRequests,...e.remote]);t&&n.delete(t);let r=new Set(t?[t]:[]),i=e.defaultBranchName?n.get(e.defaultBranchName):void 0;i&&r.add(i.name);let a=e.recent.map(e=>n.get(e.name)??e).filter(e=>!!e&&!r.has(e.name));for(let e of a)r.add(e.name);return{defaultBranch:i,recent:a,other:[...n.values()].filter(e=>!r.has(e.name)).sort((e,t)=>e.displayName.localeCompare(t.displayName))}}function ng(e,t){return t?e.filter(e=>[e.displayName,e.name,e.description,e.prTitle,e.headLabel].some(e=>e?.toLowerCase().includes(t))):e}function rg(e,t){let n=t.trim().toLowerCase();return{defaultBranch:e.defaultBranch?ng([e.defaultBranch],n)[0]:void 0,recent:ng(e.recent,n),other:ng(e.other,n)}}function ig(e,t,n){let r=n.trim().toLowerCase(),i=e=>ng(e,r),a=e?.currentBranchName??t,o=new Set((e?.pullRequests??[]).map(e=>e.headRefName??e.name));return{currentName:a,recent:i(e?.recent??[]).filter(e=>e.name!==a),local:i(e?.local??[]).filter(e=>e.name!==a),remote:i(e?.remote??[]).filter(e=>e.name!==a&&!o.has(e.name)),pullRequests:i(e?.pullRequests??[]).filter(e=>e.name!==a),totalPullRequestCount:e?.pullRequests.length??0}}function ag(e){let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Date.now()-t,r=6e4,i=60*r,a=24*i,o=7*a,s=30*a,c=365*a;return n<r?`just now`:n<i?`${Math.round(n/r)}m ago`:n<a?`${Math.round(n/i)}hr ago`:n<o?`${Math.round(n/a)}d ago`:n<s?`${Math.round(n/o)}wk ago`:n<c?`${Math.round(n/s)}mo ago`:`${Math.round(n/c)}yr ago`}function og(e){return e?`Last fetched ${ag(e)}`:`No local fetch recorded`}function sg(e){return e.isUntracked}function cg(e){return sg(e)?e.path.includes(`/`):!1}function lg(e){return!e.isCollapsed&&!e.hasPreviewAttachment&&e.patch===void 0&&e.patchError===void 0&&!e.isPatchLoading}function ug(e,t){return!e||!t.mimeType||typeof t.size!=`number`||t.changeType===`deleted`||!t.mimeType.startsWith(`image/`)&&t.mimeType!==`application/pdf`?null:{id:`diff:${t.path}`,kind:t.mimeType.startsWith(`image/`)?`image`:`file`,displayName:kr(t.path),absolutePath:t.path,relativePath:t.path,contentUrl:Or(e,t.path)??``,mimeType:t.mimeType,size:t.size}}function dg(e){return e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}function fg(e){let t=e.behindCount??0,n=e.aheadCount??0,r=e.hasUpstream===!0,i=e.hasUpstream===!1&&!!e.branchName,a=e.hasOriginRemote===!0,o=e.branchName?dg(e.branchName):null,s;s=i?`publish`:t>0?`pull`:`fetch`;let c=e.originRepoSlug&&o?`https://github.com/${e.originRepoSlug}/compare/${o}?expand=1`:null,l=!!(r&&c&&e.branchName&&e.branchName!==e.defaultBranchName),u=a?`commit_and_push`:`commit_only`,d=e.branchName??`current branch`;return{syncAction:s,compareUrl:c,canOpenPullRequest:l,primaryCommitMode:u,isPublishedBranch:r,isPublishableBranch:i,hasRemoteOrigin:a,behindCount:t,aheadCount:n,encodedBranchName:o,resolvedBranchName:d}}function pg({value:e,onChange:t,placeholder:n,disabled:r,trailingAction:i}){return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Tn,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)($n,{value:e,onChange:e=>t(e.target.value),placeholder:n,className:B(`h-9 pl-7 text-sm`,i?`pr-14`:void 0),disabled:r}),i?(0,K.jsx)(`div`,{className:`absolute right-1 top-1/2 -translate-y-1/2`,children:i}):null]})}var mg=``;function hg({entry:e,isSelected:t,disabled:n,pendingKey:r,onSelect:i}){let a=bn(r),o=e.kind===`pull_request`?(0,K.jsx)(Uo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,K.jsx)(be,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`});return(0,K.jsxs)(`button`,{type:`button`,disabled:n||a,"aria-busy":a||void 0,onClick:()=>i(e),className:B(`flex w-full items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-60`,t?`bg-accent text-foreground`:`hover:bg-accent`),children:[a?(0,K.jsx)(hn,{className:`mt-0.5 shrink-0 text-muted-foreground`}):o,(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden whitespace-nowrap text-sm text-foreground`,children:e.displayName}),e.updatedAt?(0,K.jsx)(`div`,{className:`ml-auto shrink-0 text-right text-xs text-muted-foreground`,children:ag(e.updatedAt)}):null]}),e.kind===`pull_request`&&e.description||e.headLabel?(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.kind===`pull_request`?e.description??e.headLabel??e.name:e.headLabel??void 0}):null]})]})}function gg({title:e,entries:t,emptyLabel:n,selectedName:r,disabled:i,stickyTitle:a=!1,pendingScope:o,onSelect:s}){return t.length===0&&!n?null:(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(Qh,{label:e,fact:t.length>0?String(t.length):void 0,className:B(a&&`sticky top-0 z-10 bg-background`)}),t.length===0?(0,K.jsx)(`div`,{className:`px-1 py-1 text-xs text-muted-foreground`,children:n}):t.map(e=>(0,K.jsx)(hg,{entry:e,isSelected:r===e.name,disabled:i,pendingKey:o?W(o,e.id):mg,onSelect:s},e.id))]})}function _g({className:e,...t}){return(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,...t,children:(0,K.jsx)(`path`,{d:`M12 .5C5.37.5 0 5.87 0 12.5c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58l-.01-2.05c-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.75.08-.73.08-.73 1.21.08 1.84 1.24 1.84 1.24 1.07 1.84 2.81 1.31 3.5 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6.01 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.66.24 2.88.12 3.18.77.84 1.24 1.91 1.24 3.22 0 4.61-2.81 5.62-5.49 5.92.43.37.82 1.1.82 2.22l-.01 3.29c0 .32.21.7.82.58A12.01 12.01 0 0 0 24 12.5C24 5.87 18.63.5 12 .5Z`})})}var vg=new Set([`changes`,`history`]),yg=ar(Ps),bg=new Set([`branches`,`pull_requests`]);function xg(e){return vg.has(e)}function Sg(e){return bg.has(e)}var Cg={},wg=(0,G.lazy)(()=>er(()=>import(`./react-B_ssCuNh.js`).then(e=>({default:e.PatchDiff})),__vite__mapDeps([0,1,2,3,4,5])));function Tg(e){return(0,K.jsxs)(zn,{delayDuration:0,children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":e.label,onClick:e.onClick,className:B(`flex h-11 w-11 md:h-7 md:w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,e.active&&`bg-accent text-foreground`),children:e.children})}),(0,K.jsx)(Wn,{children:e.label})]})}function Eg({checked:e,mixed:t=!1,label:n,className:r,onClick:i}){let a;return a=t?(0,K.jsx)(xn,{className:`h-3 w-3`,strokeWidth:3}):e?(0,K.jsx)(Tt,{className:`h-3 w-3`,strokeWidth:3}):null,(0,K.jsx)(`button`,{type:`button`,"aria-label":n??(e?`Exclude file from commit`:`Include file in commit`),"aria-checked":t?`mixed`:e,"aria-pressed":t?`mixed`:e,onClick:e=>{e.stopPropagation(),i()},className:B(`flex size-4.5 shrink-0 items-center justify-center rounded border transition-colors`,e||t?`border-foreground bg-foreground text-background`:`border-border bg-background text-transparent`,r),children:a})}function Dg({entry:e,isPendingPush:t=!1,ports:n}){let r=n?.dom??pi,i=ag(e.authoredAt),a=!!e.githubUrl,o;return o=e.tags.length>0?(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.tags.map(e=>(0,K.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted border border-border px-2 py-0.5 text-xs`,children:e},e)),t?(0,K.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted border border-border px-2 py-0.5 text-xs`,children:(0,K.jsx)(oe,{className:`size-3`})}):null]}):t?(0,K.jsx)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:(0,K.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted border border-border px-2 py-0.5 text-xs`,children:(0,K.jsx)(oe,{className:`size-3`})})}):null,(0,K.jsxs)(`button`,{type:`button`,disabled:!a,onClick:()=>{e.githubUrl&&r.openWindow(e.githubUrl,`_blank`,`noopener,noreferrer`)},className:B(`flex w-full items-start gap-3 rounded-lg border border-border bg-background pl-3 pr-2 py-2 text-left transition-colors`,a?`hover:bg-accent`:`cursor-default opacity-60`),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.summary}),e.description?(0,K.jsx)(`div`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}):null,(0,K.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1 text-xs text-muted-foreground`,children:[e.authorName?(0,K.jsx)(`span`,{className:`truncate`,children:e.authorName}):null,e.authorName&&i?(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`•`}):null,i?(0,K.jsx)(`span`,{children:i}):null]})]}),o]})}function Og({open:e,onOpenChange:t,onGetGitHubPublishInfo:n,onCheckGitHubRepoAvailability:r,onPublish:i,ports:a}){let o=a?.timer??Ln,s=Y(e=>e.publishInfo),c=Y(e=>e.isLoadingPublishInfo),l=Y(e=>e.publishOwner),u=Y(e=>e.publishName),d=Y(e=>e.publishVisibility),f=Y(e=>e.publishDescription),p=Y(e=>e.publishAvailability),m=Y(e=>e.isCheckingPublishAvailability),h=Y(e=>e.isPublishing),g=Y(e=>e.setPublishInfo),_=Y(e=>e.setIsLoadingPublishInfo),v=Y(e=>e.setPublishOwner),y=Y(e=>e.setPublishName),b=Y(e=>e.setPublishVisibility),x=(0,G.useCallback)(e=>{yg(e)&&b(e)},[b]),S=Y(e=>e.setPublishDescription),C=Y(e=>e.setPublishAvailability),w=Y(e=>e.setIsCheckingPublishAvailability),T=Y(e=>e.setIsPublishing);(0,G.useEffect)(()=>{if(!e)return;let t=!1;return _(!0),C(null),ri(`github publish info`,n().then(e=>{t||(g(e),v(e.owners[0]??e.activeAccountLogin??``),y(e.suggestedRepoName),b(`private`),S(``))},nr(e=>{t||Xr(e)})).finally(()=>{t||_(!1)})),()=>{t=!0}},[n,e,C,S,g,_,y,v,b]),(0,G.useEffect)(()=>{if(!e||!s?.ghInstalled||!s.authenticated)return;let t=l.trim(),n=u.trim();if(!t||!n){C(null);return}let i=!1;w(!0);let a=o.setTimeout(()=>{ri(`github repo availability`,r({owner:t,name:n}).then(e=>{i||C(e)},nr(e=>{i||C({available:!1,message:rr(e)})})).finally(()=>{i||w(!1)}))},250);return()=>{i=!0,o.clearTimeout(a)}},[s?.authenticated,s?.ghInstalled,u,r,e,l,C,w,o]);function E(){vn(W(`chat.publishToGitHub`,l.trim(),u.trim()),D)}async function D(){if(l.trim()&&u.trim()){T(!0);try{(await i({owner:l.trim(),name:u.trim(),visibility:d,description:f}))?.ok&&t(!1)}finally{T(!1)}}}let O=!!(s?.ghInstalled&&s.authenticated&&l.trim()&&u.trim()&&p?.available&&!m&&!h),k;k=m?(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-3 flex items-center text-muted-foreground`,children:(0,K.jsx)(gn,{className:`size-4 animate-spin`})}):p?(0,K.jsx)(`div`,{className:`absolute inset-y-0 right-2 flex items-center`,children:(0,K.jsxs)(zn,{delayDuration:0,children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":p.message,className:B(`flex size-6 items-center justify-center rounded-md`,p.available?`text-success-text`:`text-destructive`),children:p.available?(0,K.jsx)(Tt,{className:`size-4`}):(0,K.jsx)(kn,{className:`size-4`})})}),(0,K.jsx)(Wn,{children:p.message})]})}):null;let A;return A=c?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(gn,{className:`size-4 animate-spin`}),(0,K.jsx)(`span`,{children:`Checking GitHub CLI…`})]}):s&&!s.ghInstalled?(0,K.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(`p`,{children:`GitHub CLI is not installed.`}),(0,K.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`brew install gh`}),(0,K.jsx)(`p`,{children:`Then run:`}),(0,K.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`gh auth login`})]}):s&&!s.authenticated?(0,K.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(`p`,{children:`GitHub CLI is installed but not signed in.`}),(0,K.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 font-mono text-xs text-foreground`,children:`gh auth login`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`space-y-2`,children:(0,K.jsxs)(Ft,{value:l,onValueChange:v,children:[(0,K.jsx)(Dt,{className:`pl-[11px] [&>span]:flex [&>span]:items-center [&>span]:gap-2`,children:(0,K.jsx)(Mt,{placeholder:`Select owner`})}),(0,K.jsx)(jt,{children:(s?.owners??[]).map(e=>(0,K.jsx)(kt,{value:e,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e===s?.activeAccountLogin?(0,K.jsx)(xe,{className:`size-4 text-muted-foreground`}):(0,K.jsx)(xo,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`pl-[1px]`,children:e})]})},e))})]})}),(0,K.jsx)(`div`,{className:`space-y-2`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)($n,{value:u,onChange:e=>y(e.target.value),placeholder:`my-repo`,className:`pl-9 pr-10`}),(0,K.jsx)(ls,{className:`pointer-events-none absolute inset-y-0 left-3 my-auto size-4 text-muted-foreground`}),k]})}),(0,K.jsx)(`div`,{className:`space-y-2`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Ht,{className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,K.jsx)(ti,{value:f,onChange:e=>S(e.target.value),rows:3,placeholder:`Optional description`,className:`pl-9 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`})]})}),(0,K.jsx)(`div`,{className:`space-y-2`,children:(0,K.jsxs)(Ft,{value:d,onValueChange:x,children:[(0,K.jsx)(Dt,{className:`pl-[11px] [&>span]:flex [&>span]:items-center [&>span]:gap-2`,children:(0,K.jsx)(Mt,{placeholder:`Select visibility`})}),(0,K.jsxs)(jt,{children:[(0,K.jsx)(kt,{value:`private`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($o,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`pl-[1px]`,children:`Private`})]})}),(0,K.jsx)(kt,{value:`public`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ot,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`pl-[1px]`,children:`Public`})]})})]})]})})]}),(0,K.jsx)(Pn,{open:e,onOpenChange:t,children:(0,K.jsxs)(Nn,{size:`sm`,className:`max-w-[min(92vw,475px)]`,children:[(0,K.jsxs)(In,{className:`space-y-2 px-4 pb-4 pt-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(Rn,{children:`Push to GitHub`}),(0,K.jsx)(An,{children:`Create a GitHub repository from this local project using GitHub CLI.`})]}),A]}),(0,K.jsxs)(Fn,{children:[(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(U,{size:`sm`,disabled:!O,onClick:E,children:h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gn,{className:`mr-1.5 size-3.5 animate-spin`}),`Publishing…`]}):`Push to GitHub`})]})]})})}function kg({open:e,onOpenChange:t,branchList:n,currentBranchName:r,onPreviewMergeBranch:i,onMergeBranch:a}){let o=Y(e=>e.mergeBranchQuery),s=Y(e=>e.mergeBranchSelectedName),c=Y(e=>e.mergePreview),l=Y(e=>e.mergePreviewError),u=Y(e=>e.isMergePreviewLoading),d=Y(e=>e.isMergeBranching),f=Y(e=>e.setMergeBranchQuery),p=Y(e=>e.setMergeBranchSelectedName),m=Y(e=>e.setMergePreview),h=Y(e=>e.setMergePreviewError),g=Y(e=>e.setIsMergePreviewLoading),_=Y(e=>e.setIsMergeBranching),v=Y(e=>e.resetMergeBranchModal),y=Y(e=>e.resetMergePreview),b=(0,G.useMemo)(()=>n?tg(n,r):{defaultBranch:void 0,recent:[],other:[]},[n,r]),x=(0,G.useMemo)(()=>rg(b,o),[b,o]),S=(0,G.useMemo)(()=>s?[b.defaultBranch,...b.recent,...b.other].find(e=>e!==void 0&&e.name===s)??null:null,[b.defaultBranch,b.other,b.recent,s]);(0,G.useEffect)(()=>{e||v()},[e,v]),(0,G.useEffect)(()=>{if(!e||!S){y();return}let t=!1;return m(null),h(null),g(!0),i(S).then(e=>{t||m(e)}).catch(e=>{t||h(rr(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[i,e,y,S,g,m,h]);let C=!S||!c||u||d||c.status!==`mergeable`;function w(){S&&vn(W(`chat.mergeBranch`,S.id),T)}async function T(){if(S&&!C){_(!0);try{(await a(S))?.ok&&t(!1)}finally{_(!1)}}}let E;E=c?c.status===`up_to_date`?(0,K.jsx)(Tt,{className:`mt-1 size-3.5 shrink-0 text-success-text`}):c.status===`conflicts`?(0,K.jsx)(kn,{className:`mt-1 size-3.5 shrink-0 text-warning-text`}):c.status===`mergeable`?(0,K.jsx)(Lo,{className:`mt-1 size-3.5 shrink-0 text-muted-foreground`}):(0,K.jsx)(kn,{className:`mt-1 size-3.5 shrink-0 text-destructive`}):null;let D;return D=S?u?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(gn,{className:`size-3.5 animate-spin`}),(0,K.jsx)(`span`,{children:`Checking merge preview…`})]}):l?(0,K.jsx)(`div`,{className:`text-sm text-destructive`,children:l}):c?(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[E,(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:c.message}),c.detail?(0,K.jsx)(`div`,{className:`line-clamp-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:c.detail}):null]})]}):(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Preview unavailable.`}):(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Select a branch to preview the merge.`}),(0,K.jsx)(Pn,{open:e,onOpenChange:t,children:(0,K.jsxs)(Nn,{size:`sm`,className:`max-w-[min(92vw,475px)]`,children:[(0,K.jsxs)(In,{className:`flex min-h-0 flex-col gap-3 px-4 pb-4 pt-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(Rn,{children:[`Merge into `,r??`current branch`]}),(0,K.jsx)(An,{children:`Choose a branch to continue.`})]}),(0,K.jsx)(pg,{value:o,onChange:f,placeholder:`Search branches`}),(0,K.jsxs)(`div`,{className:`max-h-[375px] space-y-3 overflow-y-auto pr-1`,children:[(0,K.jsx)(gg,{title:`Default Branch`,entries:x.defaultBranch?[x.defaultBranch]:[],emptyLabel:`No default branch available.`,selectedName:s,onSelect:e=>p(e.name)}),(0,K.jsx)(gg,{title:`Recent Branches`,entries:x.recent,emptyLabel:`No recent branches.`,selectedName:s,onSelect:e=>p(e.name)}),(0,K.jsx)(gg,{title:`Other Branches`,entries:x.other,emptyLabel:`No other branches match this search.`,selectedName:s,onSelect:e=>p(e.name)})]}),(0,K.jsx)(`div`,{className:`px-2`,children:D})]}),(0,K.jsx)(Fn,{children:(0,K.jsxs)(`div`,{className:`flex min-w-0 w-full items-center justify-end gap-2`,children:[(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsx)(U,{className:`max-w-full min-w-0`,size:`sm`,disabled:C,onClick:w,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(gn,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}),`Merging…`]}):(0,K.jsx)(`span`,{className:`block max-w-full truncate`,children:`Merge`})})]})})]})})}function Ag({projectId:e,currentBranchName:t,onListBranches:n,onPreviewMergeBranch:r,onMergeBranch:i,onCheckoutBranch:a,onCreateBranch:o}){let s=Y(e=>e.branchSwitcherOpen),c=Y(e=>e.mergeModalOpen),l=Y(e=>e.branchSwitcherIsLoading),u=Y(e=>e.branchSwitcherIsMutating),d=Y(e=>e.branchSwitcherQuery),f=Y(e=>e.branchSwitcherEntryView),p=Y(e=>e.branchList),m=Y(e=>e.branchSwitcherError),h=Y(e=>e.setBranchSwitcherOpen),g=Y(e=>e.setMergeModalOpen),_=Y(e=>e.setBranchSwitcherIsLoading),v=Y(e=>e.setBranchSwitcherIsMutating),y=Y(e=>e.setBranchSwitcherQuery),b=Y(e=>e.setBranchSwitcherEntryView),x=(0,G.useCallback)(e=>{Sg(e)&&b(e)},[b]),S=Y(e=>e.setBranchList),C=Y(e=>e.setBranchSwitcherError);(0,G.useEffect)(()=>{s&&(_(!0),C(null),n().then(e=>S(e)).catch(e=>{C(rr(e))}).finally(()=>{_(!1)}))},[n,s,S,C,_]);let{currentName:w,recent:T,local:E,remote:D,pullRequests:O,totalPullRequestCount:k}=ig(p??null,t,d),A=W(`chat.checkoutBranch`,e??``),j=W(`chat.createBranch`,e??``),M=bn(j);function N(e){vn(W(A,e.id),()=>F(e))}function P(){vn(j,I)}async function F(e){v(!0);try{await a(e),h(!1),y(``),b(`branches`)}finally{v(!1)}}async function I(){v(!0);try{await o(),h(!1),y(``),b(`branches`)}finally{v(!1)}}function ee(){h(!1),g(!0)}let L;L=p?.pullRequestsStatus===`error`?p.pullRequestsError??`Could not load pull requests.`:p?.pullRequestsStatus===`unavailable`?`Pull requests unavailable for this repository.`:`No open pull requests.`;let R;return R=l?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,K.jsx)(gn,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(`span`,{children:`Loading branches…`})]}):m?(0,K.jsx)(`div`,{className:`rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground`,children:m}):f===`pull_requests`?(0,K.jsx)(gg,{title:`Open PRs`,entries:O,emptyLabel:L,disabled:u,stickyTitle:!0,pendingScope:A,onSelect:N}):(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(gg,{title:`Recent`,entries:T,emptyLabel:`No recent branches.`,disabled:u,stickyTitle:!0,pendingScope:A,onSelect:N}),(0,K.jsx)(gg,{title:`Local`,entries:E,emptyLabel:`No local branches.`,disabled:u,stickyTitle:!0,pendingScope:A,onSelect:N}),(0,K.jsx)(gg,{title:`Remote`,entries:D,emptyLabel:`No remote branches.`,disabled:u,stickyTitle:!0,pendingScope:A,onSelect:N})]}),(0,K.jsxs)(aa,{open:s,onOpenChange:h,children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex min-w-0 max-w-full items-center gap-1 rounded-md px-1.5 py-1 text-sm transition-colors hover:bg-accent hover:text-foreground`,"aria-label":`Open branch switcher`,children:[(0,K.jsx)(be,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t??`Detached HEAD`}),(0,K.jsx)(Pi,{className:`h-3.5 w-3.5 shrink-0`})]})}),(0,K.jsx)(Za,{align:`start`,className:`w-[320px] p-2`,children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(pg,{value:d,onChange:y,placeholder:f===`pull_requests`?`Search pull requests`:`Search branches`,disabled:l||u,trailingAction:(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:P,disabled:l||u,pending:M,className:`h-7 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:`+ New`})}),(0,K.jsx)(Kn,{value:f,onValueChange:x,size:`sm`,className:`w-full`,optionClassName:`flex-1 justify-center`,options:[{value:`branches`,label:`Branches`},{value:`pull_requests`,label:`Open PRs ${k}`}]}),(0,K.jsx)(`div`,{className:`max-h-[420px] overflow-y-auto pr-1.5 -mr-[8px]`,children:R}),w?(0,K.jsx)(U,{variant:`default`,size:`sm`,disabled:l||u||!!m,onClick:ee,className:`h-9 w-full justify-center rounded-lg px-3 text-sm`,children:(0,K.jsxs)(`span`,{className:`block max-w-full truncate`,children:[(0,K.jsx)(Vo,{className:`mr-1.5 inline h-3.5 w-3.5 shrink-0`}),`Merge branch into `,w,`...`]})}):null]})}),(0,K.jsx)(kg,{open:c,onOpenChange:g,branchList:p,currentBranchName:w,onPreviewMergeBranch:r,onMergeBranch:i})]})}function jg({file:e,rootRef:t,projectId:n,isCollapsed:r,isChecked:i,editorLabel:a,diffRenderMode:o,wrapLines:s,onToggleCollapsed:c,onToggleChecked:l,fileActions:u,patch:f,patchError:p,isPatchLoading:m,onLoadPatch:h,ports:g}){let _=g?.dom??pi,v=sg(e),y=cg(e),b=Zh.useScopedStore(e=>e.selectedAttachmentId),x=Zh.useScopedStore(e=>e.setSelectedAttachmentId),S=(0,G.useRef)(null),C=(0,G.useRef)(null),{sentinelRef:T,isStuck:E}=Xh({rootRef:t,disabled:r}),D=(0,G.useMemo)(()=>ug(n,e),[e,n]),O=D!==null,k=lg({isCollapsed:r,hasPreviewAttachment:O,patch:f,patchError:p,isPatchLoading:m});(0,G.useEffect)(()=>{if(!k)return;let t=`${e.path}\u0000${e.patchDigest}`;C.current!==t&&(C.current=t,ri(`diff patch prefetch`,h(e.path)))},[e.patchDigest,e.path,h,k]);let A=W(`diff.fileAction`,n??``,e.path),j=bn(A);function M(t){vn(A,()=>t(e.path))}function N(e){zt(e).openInNewTab?_.openWindow(new URL(e.contentUrl,_.getOrigin()).toString(),`_blank`,`noopener,noreferrer`):x(e.id)}function P(){r?O||f!==void 0?c():m||(p!==void 0||lg({isCollapsed:!1,hasPreviewAttachment:O,patch:f,patchError:p,isPatchLoading:m})?vn(W(`project.readDiffPatch`,n??``,e.path),async()=>{await h(e.path),c()}):c()):c()}let F;F=m&&r&&!D?(0,K.jsx)(gn,{className:`h-3.5 w-3.5 shrink-0 animate-spin`}):r?(0,K.jsx)(Pi,{className:`h-3.5 w-3.5 shrink-0`}):(0,K.jsx)(At,{className:`h-3.5 w-3.5 shrink-0`});let I;return I=D?(0,K.jsx)(`div`,{className:`flex justify-center p-3`,children:D.kind===`image`?(0,K.jsx)(nn,{attachment:D,onClick:()=>N(D)}):(0,K.jsx)(Ut,{attachment:D,onClick:()=>N(D)})}):m?(0,K.jsxs)(`div`,{className:`flex items-center justify-center px-3 py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(gn,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading diff...`]}):p?(0,K.jsx)(`div`,{className:`px-3 py-4 text-sm text-destructive`,children:p}):f===void 0?(0,K.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`Diff unavailable.`}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:`Preparing diff…`}),children:(0,K.jsx)(wg,{patch:f,options:{diffStyle:o,disableFileHeader:!0,disableBackground:!1,overflow:s?`wrap`:`scroll`,lineDiffType:`word`,diffIndicators:`classic`}})}),(0,K.jsxs)(ua,{children:[(0,K.jsx)(Qa,{asChild:!0,children:(0,K.jsxs)(`div`,{ref:S,"aria-busy":j||void 0,className:`relative rounded-lg border border-border bg-background`,children:[r?null:(0,K.jsx)(`div`,{ref:T,className:`pointer-events-none absolute inset-x-0 top-0 h-px`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},className:B(`group/header sticky top-0 z-20 flex cursor-pointer items-center justify-between gap-3 bg-background pl-[7px] pr-2.5 py-1.5 text-13 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,!r&&!E&&`rounded-t-[calc(theme(borderRadius.lg)-1px)]`,r&&`rounded-[calc(theme(borderRadius.lg)-1px)]`,!r&&`border-b border-border/50`),children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,K.jsx)(Eg,{checked:i,onClick:l}),(0,K.jsx)(`div`,{className:`min-w-0 truncate select-none ml-2 mr-1`,children:e.path})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 select-none`,children:[(0,K.jsxs)(`span`,{className:`whitespace-nowrap text-xs font-mono`,children:[e.additions>0?(0,K.jsxs)(`span`,{className:`text-success-text`,children:[`+`,e.additions]}):null,e.deletions>0?(0,K.jsxs)(`span`,{className:e.additions>0?`ml-2 text-destructive`:`text-destructive`,children:[`-`,e.deletions]}):null]}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Open actions for ${e.path}`,onClick:e=>fa(e,_,S.current),disabled:j,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:j?(0,K.jsx)(hn,{}):(0,K.jsx)(ji,{className:`h-3.5 w-3.5 shrink-0`})}),F]})]}),r?null:(0,K.jsx)(`div`,{className:`kanna-diff-patch overflow-hidden rounded-b-[calc(theme(borderRadius.lg)-1px)] pb-[1px]`,children:I}),(0,K.jsx)(en,{source:D&&b===D.id?Jt(D,`user_attachment`):null,open:D!==null&&b===D.id,onOpenChange:e=>!e&&x(null)})]},e.path)}),(0,K.jsxs)(eo,{children:[(0,K.jsxs)(Zi,{onSelect:e=>{e.stopPropagation(),M(u.onOpenFile)},children:[(0,K.jsx)(d,{className:`h-3.5 w-3.5`}),(0,K.jsxs)(`span`,{className:`text-xs font-medium`,children:[`Open in `,a]})]}),(0,K.jsxs)(Zi,{onSelect:e=>{e.stopPropagation(),M(u.onOpenInFinder)},children:[(0,K.jsx)(w,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Open in Finder`})]}),(0,K.jsxs)(Zi,{onSelect:e=>{e.stopPropagation(),M(u.onDiscardFile)},className:`text-destructive hover:bg-destructive/10 focus:bg-destructive/10`,children:[(0,K.jsx)(Dn,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Discard Changes`})]}),(0,K.jsxs)(Zi,{disabled:!v,onSelect:e=>{e.stopPropagation(),v&&M(u.onIgnoreFile)},children:[(0,K.jsx)(po,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Ignore File`})]}),(0,K.jsxs)(Zi,{disabled:!y,onSelect:e=>{e.stopPropagation(),y&&M(u.onIgnoreFolder)},children:[(0,K.jsx)(po,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Ignore folder...`})]}),(0,K.jsx)(Mi,{}),(0,K.jsxs)(Zi,{onSelect:e=>{e.stopPropagation(),M(u.onCopyFilePath)},children:[(0,K.jsx)(Ct,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Copy File Path`})]}),(0,K.jsxs)(Zi,{onSelect:e=>{e.stopPropagation(),M(u.onCopyRelativePath)},children:[(0,K.jsx)(Ct,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Copy Relative Path`})]})]})]})}function Mg({projectId:e,diffs:t,editorLabel:n,diffRenderMode:r,wrapLines:i,fileActions:a,onListBranches:o,onPreviewMergeBranch:s,onMergeBranch:c,onCheckoutBranch:l,onCreateBranch:u,onGenerateCommitMessage:d,onInitializeGit:f,onGetGitHubPublishInfo:p,onCheckGitHubRepoAvailability:m,onSetupGitHub:h,onCommit:g,onSyncWithRemote:_,onLoadPatch:v,onDiffRenderModeChange:y,onWrapLinesChange:b,ports:x}){let S=x?.dom??pi,C=t.files.length>0,w=e??``,T=W(`chat.generateCommitMessage`,w),E=W(`chat.syncBranch`,w),D=bn(T),O=Y(e=>e.commitModeInFlight),k=bn(E),A=Y(e=>e.isGitHubPublishModalOpen),j=Y(e=>e.patchesByPath),M=Y(e=>e.patchErrorsByPath),N=Y(e=>e.loadingPatchPaths),F=Y(e=>e.setCommitModeInFlight),I=Y(e=>e.setIsGitHubPublishModalOpen),ee=Y(e=>e.reconcilePatches),R=Y(e=>e.setPatchLoading),te=Y(e=>e.clearPatchLoading),ne=Y(e=>e.clearPatchError),re=Y(e=>e.setPatchResult),ie=Y(e=>e.setPatchError),ae=(0,G.useRef)(null),z=(0,G.useRef)(null),B=(0,G.useRef)({}),oe=(0,G.useMemo)(()=>t.files.map(e=>e.path),[t.files]),se=(0,G.useMemo)(()=>oe.join(`\0`),[oe]),ce=C?`changes`:`history`,le=L(t=>e?t.projectUi[e]?.viewMode??ce:ce),ue=L(t=>e?t.projectUi[e]?.collapsedPaths??Cg:Cg),de=L(t=>e?t.projectUi[e]?.summary??``:``),fe=L(t=>e?t.projectUi[e]?.description??``:``),pe=L(e=>e.reconcileCollapsedPaths),me=L(e=>e.toggleCollapsedPath),he=L(e=>e.setViewMode),ge=L(e=>e.setCommitDraft),_e=L(e=>e.setCommitSummary),ve=L(e=>e.setCommitDescription),ye=L(e=>e.clearCommitDraft),xe=P(t=>e?t.checkedPathsByProjectId[e]??Cg:Cg),Se=P(e=>e.reconcileProject),Ce=P(e=>e.toggleChecked),we=P(e=>e.toggleAllChecked),Te=(0,G.useCallback)(t=>{e&&me(e,t)},[e,me]),Ee=(0,G.useCallback)(t=>{e&&Ce(e,t)},[e,Ce]),De=(0,G.useCallback)(()=>{e&&we(e,oe)},[e,we,oe]),Oe=(0,G.useCallback)(t=>{e&&xg(t)&&he(e,t)},[e,he]),ke=(0,G.useCallback)(t=>{e&&_e(e,t.target.value)},[e,_e]),Ae=(0,G.useCallback)(t=>{e&&ve(e,t.target.value)},[e,ve]),je=(0,G.useRef)(C);(0,G.useEffect)(()=>{e&&pe(e,oe)},[oe,se,e,pe]),(0,G.useEffect)(()=>{let e=Object.fromEntries(t.files.map(e=>[e.path,e.patchDigest]));ee(oe,t=>B.current[t]===e[t]),B.current=e},[t.files,oe,se,ee]),(0,G.useEffect)(()=>{e&&Se(e,oe)},[oe,se,e,Se]),(0,G.useEffect)(()=>{e&&(je.current===C||he(e,C?`changes`:`history`),je.current=C)},[C,e,he]);let Me=(0,G.useMemo)(()=>t.files.filter(e=>xe[e.path]??!0).map(e=>e.path),[xe,t.files]),Ne=Me.length,Pe=t.files.length>0&&Ne===t.files.length,Fe=Ne>0&&Ne<t.files.length,Ie=de.trim(),Le=Ie.length>0,Re=O!==null,ze=D||Re,Be=t.branchHistory?.entries??[],{syncAction:Ve,compareUrl:He,canOpenPullRequest:Ue,primaryCommitMode:We,isPublishedBranch:Ge,hasRemoteOrigin:Ke,behindCount:qe,aheadCount:Je,resolvedBranchName:Ye}=fg(t),Xe=t.status===`ready`&&Ne>0&&!ze,Ze=t.status===`ready`&&Ne>0&&Le&&!ze;async function Qe(t){if(Ze){F(t);try{let n=await g({paths:Me,summary:Ie,description:fe.trim(),mode:t});(n?.ok||n?.localCommitCreated)&&e&&ye(e)}finally{F(null)}}}async function $e(){if(!Xe)return;let t=await d({paths:Me});e&&ge(e,{summary:t.subject,description:t.body})}let et=W(`chat.initGit`,w),tt=bn(et);function nt(e){vn(W(`chat.commitDiffs`,w),()=>Qe(e))}function rt(){vn(T,$e)}function it(){Le?nt(We):rt()}function at(e=Ve){vn(E,()=>ct(e))}function ot(){vn(et,f)}function st(e){(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),it())}async function ct(e=Ve){t.status===`ready`&&await _(e)}let lt=(0,G.useCallback)(async e=>{let{patchesByPath:n,loadingPatchPaths:r}=Y.getState();if(n[e]!==void 0||r[e])return n[e]??``;R(e),ne(e);try{let n=await v(e);re(e,n);let r=t.files.find(t=>t.path===e)?.patchDigest;return r&&(B.current={...B.current,[e]:r}),n}catch(t){let n=rr(t);throw ie(e,n),t}finally{te(e)}},[ne,te,t.files,v,ie,R,re]),V=(0,G.useCallback)(e=>e.path,[]),ut=(0,G.useCallback)(({item:t})=>{let o=ue[t.path]??!0,s=xe[t.path]??!0;return(0,K.jsx)(`div`,{className:`pb-1.5`,children:(0,K.jsx)(Zh.Provider,{init:void 0,children:(0,K.jsx)(jg,{file:t,rootRef:ae,projectId:e,isCollapsed:o,isChecked:s,editorLabel:n,diffRenderMode:r,wrapLines:i,onToggleCollapsed:()=>Te(t.path),onToggleChecked:()=>Ee(t.path),fileActions:a,patch:j[t.path],patchError:M[t.path],isPatchLoading:!!N[t.path],onLoadPatch:lt,ports:x})})})},[xe,ue,r,n,a,lt,N,M,j,x,Ee,Te,e,i]);(0,G.useEffect)(()=>{let e=z.current?.getScrollableNode?.();ae.current=e instanceof HTMLElement?e:null},[le,t.files.length]);let dt=Pe?`Unselect all files from commit`:`Select all files for commit`,ft;ft=t.status===`ready`?Ke?Ve===`publish`?(0,K.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>at(),disabled:k,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[k?(0,K.jsx)(gn,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(Ns,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Publish Branch`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ve===`fetch`?(0,K.jsxs)(zn,{delayDuration:0,children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>at(),disabled:k,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[k?(0,K.jsx)(gn,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(wn,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Fetch`})]})}),(0,K.jsx)(Wn,{children:og(t.lastFetchedAt)})]}):(0,K.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>at(),disabled:k,className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[k?(0,K.jsx)(gn,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(Vt,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Pull`}),(0,K.jsx)(`span`,{className:`inline-flex min-w-4 items-center justify-center rounded-full bg-muted px-1 text-xs text-muted-foreground`,children:qe})]}),Ge&&Je>0?(0,K.jsxs)(U,{variant:`default`,size:`sm`,onClick:()=>at(`push`),disabled:k,className:`h-7 gap-1.5 px-2 text-xs`,children:[k?(0,K.jsx)(gn,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(Ns,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Push`}),(0,K.jsx)(`span`,{className:`inline-flex min-w-4 items-center justify-center rounded-full bg-primary-foreground/15 px-1 text-xs text-primary-foreground`,children:Je})]}):null,Ue&&He?(0,K.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>{S.openWindow(He,`_blank`,`noopener,noreferrer`)},className:`h-7 gap-1.5 px-2 text-xs hover:!bg-transparent hover:!border-border/0`,children:[(0,K.jsx)(Uo,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`PR`})]}):null]}):(0,K.jsxs)(U,{variant:`default`,size:`sm`,onClick:()=>I(!0),className:`h-7 gap-1.5 px-3 text-xs`,children:[(0,K.jsx)(_g,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Push to GitHub`})]}):null;let pt;pt=t.status===`no_repo`?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,K.jsxs)(`div`,{className:`flex max-w-[280px] flex-col items-center gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Initialize git here to start tracking branches, diffs, and history.`}),(0,K.jsx)(U,{size:`sm`,pending:tt,onClick:ot,children:`Init Git`})]})}):le===`history`?Be.length===0?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No recent commits on `,t.branchName??`this branch`,`.`]})}):(0,K.jsx)(`div`,{className:`h-full overflow-y-auto [scrollbar-gutter:stable] space-y-1.5 p-1.5`,children:Be.map((e,t)=>(0,K.jsx)(Dg,{entry:e,isPendingPush:t<Je,ports:x},e.sha))}):t.files.length===0?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 py-3 text-center`,children:(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No file changes.`})}):null;let mt;mt=Le?Re?(0,K.jsx)(gn,{strokeWidth:2.5,className:`size-3 shrink-0 animate-spin`}):We===`commit_and_push`&&t.hasUpstream?(0,K.jsx)(Ns,{strokeWidth:2.5,className:`size-3 shrink-0`}):We===`commit_and_push`?(0,K.jsx)(Lo,{strokeWidth:2.5,className:`size-3 shrink-0`}):(0,K.jsx)(Tt,{strokeWidth:2.5,className:`size-3 shrink-0`}):D?(0,K.jsx)(gn,{strokeWidth:2.5,className:`size-3 shrink-0 animate-spin`}):(0,K.jsx)(ss,{strokeWidth:2.5,className:`size-3 shrink-0`});let ht;return ht=Le?Re?O===`commit_only`?`Committing...`:`Committing & Pushing...`:We===`commit_only`?(0,K.jsxs)(K.Fragment,{children:[`Commit to `,(0,K.jsx)(be,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ye]}):t.hasUpstream?(0,K.jsxs)(K.Fragment,{children:[`Commit & push to `,(0,K.jsx)(be,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ye]}):(0,K.jsxs)(K.Fragment,{children:[`Commit & publish `,(0,K.jsx)(be,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ye]}):D?`Generating...`:(0,K.jsxs)(K.Fragment,{children:[`Generate message for `,(0,K.jsx)(be,{strokeWidth:2.5,className:`mr-[4.5px] ml-0.5 inline size-3 `}),Ye]}),(0,K.jsx)(`div`,{className:`h-full min-h-0 border-l border-border bg-background md:min-w-[370px]`,children:(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border pl-2.5 pr-2 py-2`,children:[(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:(0,K.jsx)(Ag,{projectId:e,currentBranchName:t.branchName,onListBranches:o,onPreviewMergeBranch:s,onMergeBranch:c,onCheckoutBranch:l,onCreateBranch:u})}),ft]}),(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`sticky top-0 z-30 pl-[14px] pr-[12px] pt-[6px] bg-gradient-to-b from-background to-transparent`,children:(0,K.jsx)(`div`,{className:`relative h-[40px] flex min-w-0 items-center justify-center gap-[13px]`,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-[13px] relative`,children:[le===`changes`?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground/70`,children:[(0,K.jsx)(Eg,{checked:Pe,mixed:Fe,label:dt,onClick:De}),(0,K.jsxs)(`span`,{children:[Ne,` files`]})]}):(0,K.jsx)(`div`,{}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2`,children:(0,K.jsx)(`div`,{className:`pointer-events-auto`,children:(0,K.jsx)(Kn,{value:le,onValueChange:Oe,size:`sm`,optionClassName:`flex-1 justify-center`,options:[{value:`changes`,label:`Changes`},{value:`history`,label:`History`}]})})}),le===`changes`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Tg,{label:`Unified diff`,active:r===`unified`,onClick:()=>y(`unified`),children:(0,K.jsx)(_s,{className:`h-4 w-4`})}),(0,K.jsx)(Tg,{label:`Side-by-side diff`,active:r===`split`,onClick:()=>y(`split`),children:(0,K.jsx)(Do,{className:`h-4 w-4`})}),(0,K.jsx)(Tg,{label:i?`Disable word wrap`:`Enable word wrap`,active:i,onClick:()=>b(!i),children:(0,K.jsx)(js,{className:`h-4 w-4`})})]}):(0,K.jsx)(`div`,{})]})})}),(0,K.jsxs)(`div`,{className:`h-full min-h-0`,children:[pt,t.status!==`no_repo`&&le!==`history`&&t.files.length>0&&(0,K.jsxs)(`div`,{className:`relative h-full min-h-0 kanna-panel-content-in`,children:[(0,K.jsx)(Yh,{ref:z,data:t.files,keyExtractor:V,renderItem:ut,extraData:{collapsedPaths:ue,checkedPaths:xe,patchesByPath:j,patchErrorsByPath:M,loadingPatchPaths:N,diffRenderMode:r,wrapLines:i},estimatedItemSize:44,className:`h-full overflow-y-auto [scrollbar-gutter:stable] p-1.5`,contentContainerStyle:{paddingBottom:le===`changes`?220:40}}),le===`changes`?(0,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 py-1 pb-6 z-30`,children:[(0,K.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-0 bg-gradient-to-t from-background to-transparent`}),(0,K.jsx)(`div`,{className:`pointer-events-auto relative`,children:(0,K.jsxs)(`div`,{className:`space-y-0 rounded-xl mx-auto max-w-[700px]`,children:[(0,K.jsx)($n,{value:de,onChange:ke,onKeyDown:st,placeholder:`Commit message (override)`,className:`rounded-t-xl rounded-b-none px-3`,disabled:ze||t.status!==`ready`}),(0,K.jsx)(ti,{value:fe,onChange:Ae,onKeyDown:st,placeholder:`Description`,rows:5,className:`-mt-px rounded-t-none rounded-b-xl px-3 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background mb-2`,disabled:ze||t.status!==`ready`}),(0,K.jsx)(`div`,{className:`w-full flex flex-row`,children:(0,K.jsxs)(ua,{children:[(0,K.jsx)(Qa,{asChild:!0,children:(0,K.jsx)(U,{type:`button`,className:`-mt-px w-full rounded-xl`,disabled:Le?!Ze:!Xe,onClick:it,children:(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[mt,(0,K.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:ht})]})})}),t.hasUpstream?(0,K.jsx)(eo,{children:(0,K.jsx)(Zi,{disabled:!Le||!Ze,onSelect:e=>{e.stopPropagation(),nt(`commit_only`)},children:`Commit Only`})}):null]})})]})})]}):null]})]})]}),(0,K.jsx)(Og,{open:A,onOpenChange:I,onGetGitHubPublishInfo:p,onCheckGitHubRepoAvailability:m,onPublish:h,ports:x})]})})}var Ng=(0,G.memo)(Mg);function Pg(e){let t=C(t=>e?t.projects[e]:void 0),n=L(t=>e?t.projects[e]:void 0),r=t??A,i=n??u;return{terminalLayout:r,showTerminalPane:!!(e&&r.isVisible&&r.terminals.length>0),showRightSidebar:!!(e&&i.isVisible)}}function Fg(e={}){return(e.dom??pi).getInnerWidth()}var Ig=Jn()(e=>({typedEmptyStateText:``,isEmptyStateTypingComplete:!1,setTypedEmptyStateText:t=>e({typedEmptyStateText:t}),setIsEmptyStateTypingComplete:t=>e({isEmptyStateTypingComplete:t}),resetEmptyStateTyping:()=>e({typedEmptyStateText:``,isEmptyStateTypingComplete:!1}),isPageFileDragActive:!1,setIsPageFileDragActive:t=>e({isPageFileDragActive:t}),layoutWidth:0,setLayoutWidth:t=>e({layoutWidth:t}),viewportWidth:Fg(),setViewportWidth:t=>e({viewportWidth:t}),localLinkMenuTarget:null,setLocalLinkMenuTarget:t=>e({localLinkMenuTarget:t}),setLocalLinkMenuOpen:t=>e(e=>t||e.localLinkMenuTarget===null?e:{localLinkMenuTarget:null}),diffRenderMode:`unified`,wrapDiffLines:!1,setDiffRenderMode:t=>e({diffRenderMode:t}),setWrapDiffLines:t=>e({wrapDiffLines:t}),terminalFocusRequestVersion:0,incrementTerminalFocusRequestVersion:()=>e(e=>({terminalFocusRequestVersion:e.terminalFocusRequestVersion+1}))}));function Lg(e){return(typeof e==`number`||typeof e==`string`)&&e!==``}function Rg(e){let t=(0,G.useId)();return Lg(e)?`${e}`:t}var zg=typeof window<`u`?G.useLayoutEffect:G.useEffect;function Bg(e){let t=(0,G.useRef)(e);return zg(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function Vg(...e){return Bg(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t}})})}function Hg(e,t){let n=e?.[`data-testid`];return Lg(n)?`${n}`:Lg(t)?`${t}`:void 0}function Ug(e,t=`Assertion error`){if(!e)throw Error(t)}(0,G.createContext)(null);var Wg;function Gg(){return Wg===void 0&&(Wg=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Wg}function Kg({expandHitTargets:e,axis:t,rect:n}){let r=e?Gg()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<r){let e=r-n.width;n=new DOMRect(n.x-e/2,n.y,n.width+e,n.height)}if(n.height<r){let e=r-n.height;n=new DOMRect(n.x,n.y-e/2,n.width,n.height+e)}return n}var qg=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0){if(n.length===1){n[0].call(null,t);return}let e,r=Array.from(n);for(let n=0;n<r.length;n++){let i=r[n];try{i.call(null,t)}catch(t){e??={error:t}}}if(e)throw e.error}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}};function Jg(e){let t=e=>{e.preventDefault(),e.stopPropagation(),n()},n=()=>{e.removeEventListener(`click`,t,!0)};e.addEventListener(`click`,t,!0),setTimeout(n,0)}var Yg={cursorFlags:0,state:`inactive`},Xg=new qg;function Zg(){return Yg}function Qg(e){return Xg.addListener(`change`,e)}function $g(e,t=[],n,r=!1){let i=Yg,a={...Yg};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),Yg=a,Xg.emit(`change`,{prev:i,next:a})}function e_(e){let t=Yg;Yg=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&(t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),Jg(t.ownerDocument)),Xg.emit(`change`,{prev:t,next:e})}function t_(e){Yg.state!==`active`||!Yg.previews.some(t=>t.separator===e)||e_({...Yg,previews:Yg.previews.map(t=>t.separator===e?{...t}:t)})}function n_(e){if(Yg.state===`inactive`)return;let t=Yg.hitRegions.filter(t=>t.axis!==e),n=Yg.state===`active`&&Yg.previews.some(t=>t.axis===e);if(t.length!==Yg.hitRegions.length||n){if(t.length===0)e_({cursorFlags:0,state:`inactive`});else if(Yg.state===`active`){let n=new Map(Yg.initialLayoutMap),r=new Map(Yg.previewLayoutMap);n.delete(e),r.delete(e),e_({...Yg,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:Yg.previews.filter(t=>t.axis!==e)})}else e_({...Yg,hitRegions:t})}}var r_=e=>e,i_=()=>{},a_=1,o_=2,s_=4,c_=8,l_=3,u_=12,d_;function f_(){return d_===void 0&&(d_=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(d_=!0)),d_}function p_({cursorFlags:e,axes:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++}})}if(r!==0||i!==0){if(n===`active`&&e&&f_()){let t=(e&a_)!==0,n=(e&o_)!==0,r=(e&s_)!==0,i=(e&c_)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}return f_()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var m_=new WeakMap;function h_(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=m_.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=Zg();switch(r.state!==`inactive`&&r.ownerDocument!==e&&(r={cursorFlags:0,state:`inactive`}),r.state){case`active`:case`hover`:{let e=p_({cursorFlags:r.cursorFlags,axes:r.hitRegions.map(e=>e.axis),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0)}m_.set(e,{prevStyle:t,styleSheet:n})}function g_(e){return e.state===`inactive`?void 0:e.ownerDocument}function __({next:e,prev:t}){let n=g_(t),r=g_(e);n&&n!==r&&h_(n),r&&h_(r)}function v_({axis:e}){let{layoutStrategy:t,orientation:n,items:r}=e;return t?t.calculateAvailableSize():r.reduce((e,t)=>(e+=n===`horizontal`?t.element.offsetWidth:t.element.offsetHeight,e),0)}function y_(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function b_(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?x_(t,n):S_(t,n);return r===0?y_(t.element,n.element):r})}function x_(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function S_(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function C_(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function w_(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function T_({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=w_(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Ug(i,`No rect found`),i}function E_(e,t){let n=t===`horizontal`?e.offsetWidth:e.offsetHeight;if(n===0)return 1;let r=e.getBoundingClientRect(),i=t===`horizontal`?r.width:r.height;return i<=0||Math.abs(i-n)<1?1:i/n}function D_({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});let{element:r,orientation:i,items:a,separators:o}=t,s=b_(i,Array.from(r.children).filter(C_).filter(e=>!e.hasAttribute(`data-resize-preview`)).map(e=>({element:e}))).map(({element:e})=>e),c=[],l=!1,u=!1,d=-1,f,p=-1,m=0,h,g=[];{let e=-1;for(let t of s)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(m++,d===-1&&(d=e),p=e))}if(n||m>1){let r=-1;for(let m of s)if(m.hasAttribute(`data-panel`)){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a=h.element.getBoundingClientRect(),s=m.getBoundingClientRect(),_;if(u){let e=i===`horizontal`?new DOMRect(a.right,a.top,0,a.height):new DOMRect(a.left,a.bottom,a.width,0),t=i===`horizontal`?new DOMRect(s.left,s.top,0,s.height):new DOMRect(s.left,s.top,s.width,0);switch(g.length){case 0:_=[e,t];break;case 1:{let n=g[0];_=[n,T_({orientation:i,rects:[a,s],targetRect:n.element.getBoundingClientRect()})===a?t:e];break}default:_=g}}else _=g.length?g:[i===`horizontal`?new DOMRect(a.right,s.top,s.left-a.right,s.height):new DOMRect(s.left,a.bottom,s.width,s.top-a.bottom)];for(let i of _){let a=Kg({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=v_({axis:t})*E_(t.element,t.orientation),c.push({axis:t,axisSize:f,items:[h,o],separator:`width`in i?void 0:i,rect:a})),l=!1}}u=!1,h=o,g=[]}}else if(m.hasAttribute(`data-separator`)){m.ariaDisabled!==null&&(l=!0);let e=o.find(e=>e.element===m);e?g.push(e):(h=void 0,g=[])}else u=!0}return c}function O_(e){return e.ownerDocument.defaultView??window}function k_(e,t){let n=O_(e).getComputedStyle(e);return t*parseFloat(n.fontSize)}function A_(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function j_(e,t){return t/100*O_(e).innerHeight}function M_(e,t){return t/100*O_(e).innerWidth}function N_(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function P_({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=N_(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=A_(t,i);break;case`em`:r=k_(t,i);break;case`vh`:r=j_(t,i);break;case`vw`:r=M_(t,i)}return r}function F_(e){return parseFloat(e.toFixed(3))}function I_(e,t=v_({axis:e})){let{items:n}=e;return t===0?n.map(e=>({groupResizeBehavior:e.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:e.constraintProps.collapsible===!0,defaultSize:void 0,disabled:e.constraintProps.disabled,minSize:0,maxSize:100,itemId:e.id})):n.map(e=>{let{element:n,constraintProps:r}=e,i=0;r.collapsedSize!==void 0&&(i=F_(P_({axisSize:t,itemElement:n,styleProp:r.collapsedSize})/t*100));let a;r.collapsedThreshold!==void 0&&(a=F_(P_({axisSize:t,itemElement:n,styleProp:r.collapsedThreshold})/t*100));let o;r.defaultSize!==void 0&&(o=F_(P_({axisSize:t,itemElement:n,styleProp:r.defaultSize})/t*100));let s=0;r.minSize!==void 0&&(s=F_(P_({axisSize:t,itemElement:n,styleProp:r.minSize})/t*100));let c=100;return r.maxSize!==void 0&&(c=F_(P_({axisSize:t,itemElement:n,styleProp:r.maxSize})/t*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:o,disabled:r.disabled,minSize:s,maxSize:c,itemId:e.id}})}var L_=new Map,R_=new qg,z_=0,B_=[],V_;function H_(){z_++}function U_(){for(let e=0;e<B_.length;e++)try{R_.emit(`axisChange`,B_[e])}catch(e){V_??={error:e}}B_.length=0}function W_(){if(z_===1&&U_(),z_--,z_===0&&V_){let{error:e}=V_;throw V_=void 0,e}}function G_(e){L_=new Map(L_),L_.delete(e)}function K_(e,t){for(let[t]of L_)if(t.id===e)return t}function q_(e,t){for(let[t,n]of L_)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function J_(){return L_}function Y_(e,t){return R_.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function X_(e,t,n){let r=L_.get(e);L_=new Map(L_),L_.set(e,t);let i={axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t};z_>0?B_.push(i):R_.emit(`axisChange`,i)}function Z_(e,{pointerId:t,pointerType:n}){return t===e.pointerId||n===`pen`&&e.pointerType===`pen`}function Q_(e,t,n={}){return e.ownerDocument===t&&(n.pointerId===void 0||Z_(e,n))}function $_(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function ev(e,t,n=0){return Math.abs(F_(e)-F_(t))<=n}function tv(e,t){return ev(e,t)?0:e>t?1:-1}function nv({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsedThreshold:a,collapsible:o,disabled:s,maxSize:c=100,minSize:l=0}=t;if(s&&!e)return n;if(tv(r,l)<0){if(o){let e=a??(l-i)/2,t=tv(n,i)<=0,o=t?i+e:l-e,s=tv(r,o);r=tv(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l}return r=Math.min(c,r),r=F_(r),r}function rv({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(ev(e,0))return t;let o=a===`imperative-api`,s=n.map(({itemId:e})=>t[e]),c=n.map(({itemId:e})=>i[e]),l=[...s],[u,d]=r;Ug(u!=null,`Invalid first pivot index`),Ug(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Ug(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Ug(n!=null,`Previous layout not found for panel index ${t}`),ev(n,i)){let t=o-n;tv(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Ug(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Ug(n!=null,`Previous layout not found for panel index ${t}`),ev(n,o)){let t=n-i;tv(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Ug(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&tv(i,l)<0){let t=l-a,n=o??t/2;if(tv(i+Math.abs(e),l)<0){let r=tv(Math.abs(e),n);e=r>0||r===0&&o===void 0&&e<0?e<0?-t:t:0}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Ug(e!=null,`Previous layout not found for panel index ${r}`);let a=nv({overrideDisabledItems:o,itemConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Ug(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=nv({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!ev(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if($_(c,l))return i;{let t=e<0?d:u,r=s[t];Ug(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=nv({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!ev(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Ug(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=nv({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(ev(i,s)||(t-=s-i,l[r]=s),ev(t,0))break;e>0?r--:r++}}}return ev(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function iv(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||tv(e[n],t[n])!==0)return!1;return!0}function av(e){H_();try{ov(e)}finally{W_()}}function ov({commit:e,event:t,hitRegions:n,initialLayoutMap:r,mountedAxes:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=Zg(),l=c.state===`active`?c.previews:[],u=new Map(c.state===`active`?c.previewLayoutMap:void 0);n.forEach(n=>{let{axis:o,axisSize:c}=n,{orientation:d,items:f}=o;if(e&&o.resizePreviewMode!==`separator`)return;let{disableCursor:p}=o.mutableState,m=0;m=a?d===`horizontal`?(t.clientX-a.x)/c*100:(t.clientY-a.y)/c*100:d===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let h=r.get(o),g=i.get(o);if(!h||!g)return;let{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:b,separatorToItems:x}=g;if(v&&b&&x){let t=o.resizePreviewMode===`separator`?u.get(o)??b:b,r=rv({delta:m,initialLayout:h,itemConstraints:v,pivotIndices:n.items.map(e=>f.indexOf(e)),prevLayout:t,trigger:`mouse-or-touch`});if(o.resizePreviewMode===`separator`&&!e&&!iv(r,t)){u.set(o,r);let e=0,t=f.map(t=>(e+=r[t.id]-h[t.id],c/100*e));l=l.map(e=>{if(e.axis!==o)return e;let n=t[e.itemIndex];return n===e.offset?e:{...e,offset:n}})}if(iv(r,t)&&m!==0&&!p)switch(d){case`horizontal`:s|=m<0?a_:o_;break;case`vertical`:s|=m<0?s_:c_}(o.resizePreviewMode!==`separator`||e)&&!iv(r,b)&&X_(n.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:r,requestedAxisSize:y,requestedLayout:r,separatorToItems:x})}});let d=0;t.movementX===0?d|=o&l_:d|=s&l_,t.movementY===0?d|=o&u_:d|=s&u_;let f=c.state===`active`&&(t.clientX!==c.pointerDownAtPoint.x||t.clientY!==c.pointerDownAtPoint.y);$g(d,l,u,f)}function sv(e,t){let n=Zg();if(n.state!==`active`||!Q_(n,e,t))return;let r=J_();H_();try{av({commit:!0,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),U_(),e_({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(t.preventDefault?.(),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=q_(e.axis.id,!0);X_(e.axis,t,{isUserInteraction:!0})}))}finally{W_()}}function cv(e){if(e.defaultPrevented)return;let{clientX:t,clientY:n,movementX:r,movementY:i}=e;sv(e.currentTarget,{clientX:t,clientY:n,movementX:r,movementY:i})}function lv(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=w_(n,a.rect);switch(e){case`horizontal`:(t.x<i.x||t.x===i.x&&t.y<=i.y)&&(r=a,i=t);break;case`vertical`:(t.y<i.y||t.y===i.y&&t.x<=i.x)&&(r=a,i=t)}}return r?{distance:i,hitRegion:r}:void 0}function uv(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function dv(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:_v(e),b:_v(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Ug(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:gv(hv(n.a)),b:gv(hv(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var fv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function pv(e){let t=getComputedStyle(vv(e)??e).display;return t===`flex`||t===`inline-flex`}function mv(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||pv(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||fv.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function hv(e){let t=e.length;for(;t--;){let n=e[t];if(Ug(n,`Missing node`),mv(n))return n}return null}function gv(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _v(e){let t=[];for(;e;)t.push(e),e=vv(e);return t}function vv(e){let{parentNode:t}=e;return uv(t)?t.host:t}function yv(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function bv(e){try{return e.matches(`:modal`)}catch{return!1}}function xv({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(C_(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&bv(t))return!1}if(!C_(n)||n.contains(e)||e.contains(n)||!n.isConnected||!e.isConnected)return!0;if(dv(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(yv(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Sv(e,t,n){let r=[];return t.forEach((t,i)=>{if(i.disabled||i.element.ownerDocument!==n)return;let a=D_({axis:i}),o=lv(i.orientation,a,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&xv({axisElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&r.push(o.hitRegion)}),r}function Cv(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=F_(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=F_((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function wv(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}function Tv({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&wv(e.items,r)?r:Cv(t))}function Ev(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Dv(e,t){return e.length===t.length&&e.every((e,n)=>Ev(e,t[n]))}function Ov({layout:e,itemConstraints:t}){let n=t.map(({itemId:t})=>e[t]),r=[...n],i=r.reduce((e,t)=>e+t,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(e=>`${e}%`).join(`, `)}`);if(!ev(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Ug(t!=null,`No layout data found for index ${e}`);let n=100/i*t;r[e]=n}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Ug(i!=null,`No layout data found for index ${e}`);let o=r[e];Ug(o!=null,`No layout data found for index ${e}`);let s=nv({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!ev(a,0))for(let e=0;e<t.length;e++){let n=r[e];Ug(n!=null,`No layout data found for index ${e}`);let i=n+a,o=nv({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,ev(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function kv({itemIds:e,layout:t}){return Ov({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function Av({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.items){let e=r[l.id]??0;switch(l.constraintProps.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=F_(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=F_((r[e]??0)/a*l);else{let e=F_(l/c.length);for(let t of c)u[t]=e}return u}function jv({axis:e,axisState:t}){let n=v_({axis:e});if(n===0)return;let r=I_(e,n),i=t.requestedAxisSize,a=t.requestedLayout;t.defaultLayoutDeferred&&(i=n,a=kv({itemIds:e.items.map(({id:e})=>e),layout:Tv({axis:e,itemConstraints:r})}));let o=Ov({layout:Av({axis:e,nextAxisSize:n,prevAxisSize:i,prevLayout:a}),itemConstraints:r});return{changed:t.defaultLayoutDeferred||!iv(t.layout,o)||!Dv(t.derivedItemConstraints,r)||t.axisSize!==n,state:{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:n,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:t.separatorToItems}}}function Mv({axisId:e,itemId:t}){let n=()=>{let t=J_();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedItemConstraints.find(e=>e.itemId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let{axis:e,...r}=n(),i=jv({axis:e,axisState:r}),a=i?.state??r,o=a.derivedItemConstraints.find(e=>e.itemId===t);if(o===void 0)throw Error(`Panel constraints not found for Panel ${t}`);let s=a.layout[t];if(s===void 0)throw Error(`Layout not found for Panel ${t}`);return{axis:e,changed:i?.changed===!0,itemConstraints:o,itemSize:s,state:a}},a=()=>{let e=n().axis.items.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},s=({allowPartialSize:e=!1,nextSize:n,items:r,prevLayout:i,derivedItemConstraints:a})=>{let o=i[t],s=r.findIndex(e=>e.id===t),c=s===0,l=s===r.length-1;if(l&&n<o&&(c||r.slice(0,s).every((e,t)=>{let n=a[t];return n?.collapsible&&ev(n.collapsedSize,i[n.itemId])}))){let e=r.slice(0,s).reduce((e,t)=>e+i[t.id],0);return{...i,[t]:F_(100-e)}}let u=a[s],d=nv({overrideDisabledItems:!0,itemConstraints:u,prevSize:o,size:n}),f={...i},p=d-o;for(let e of c?[1]:l?[-1]:[1,-1])for(let t=s+e;t>=0&&t<r.length&&!ev(p,0);t+=e){let e=a[t],n=f[e.itemId];if(Nv(e,f)||(p>0?tv(n,e.minSize)<=0:tv(n,e.maxSize)>=0))continue;let r=p>0?Math.max(e.minSize,n-p):Math.min(e.maxSize,n-p);p-=n-r,f[e.itemId]=F_(r)}if(f[t]=F_(d-p),ev(p,0)||e&&tv(f[t],u.minSize)>=0)return f;let m=(e,t,n)=>{let i=e===`after`?1:-1,o=e=>{for(let n=s+i;n>=0&&n<r.length;n+=i){let r=a[n];if(!Nv(r,t)&&e(r))return n}},c=o(({itemId:e,maxSize:r,minSize:i})=>n>0?tv(t[e],i)>0:tv(t[e],r)<0)??o(()=>!0)??s+i;return rv({delta:e===`after`?n:-n,initialLayout:t,itemConstraints:a,pivotIndices:e===`after`?[s,c]:[c,s],prevLayout:t,trigger:`imperative-api`})};if(c||l)return m(l?`before`:`after`,i,n-o);let h=e=>{let r=m(e,i,n-o),a=n-r[t];return ev(a,0)?r:m(e===`after`?`before`:`after`,r,a)},g=h(`after`);if(Pv({itemConstraints:a,itemId:t,nextLayout:g,prevLayout:i})){let e=h(`before`);if(!Pv({itemConstraints:a,itemId:t,nextLayout:e,prevLayout:i}))return e}return g},c=(e,{axis:t,changed:n,itemSize:r,state:i},{allowPartialSize:a=!1}={})=>{if(e===r)return;let{derivedItemConstraints:o,axisSize:c,layout:l}=i,u=Ov({layout:s({allowPartialSize:a,nextSize:e,items:t.items,prevLayout:l,derivedItemConstraints:o}),itemConstraints:o});(n||!iv(l,u))&&X_(t,{...i,layout:u,requestedAxisSize:c,requestedLayout:u})};return{collapse:()=>{let e=i(),{collapsible:t,collapsedSize:n}=e.itemConstraints,{mutableValues:r}=a(),o=e.itemSize;t&&o!==n&&(r.expandToSize=o,c(n,e))},expand:()=>{let e=i(),{collapsible:t,collapsedSize:n,minSize:r}=e.itemConstraints,{mutableValues:o}=a(),s=e.itemSize;if(t&&s===n){let t=o.expandToSize??r;t===0&&(t=1),c(t,e,{allowPartialSize:!0})}},getSize:()=>{let{axis:e}=n(),r=o(),{element:i}=a();return{asPercentage:r,inPixels:e.layoutStrategy?e.layoutStrategy.getItemSizeInPixels(t):e.orientation===`horizontal`?i.offsetWidth:i.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=o();return e&&ev(t,n)},resize:e=>{let t=i(),{axisSize:n}=t.state,{element:r}=a(),o=F_(P_({axisSize:n,itemElement:r,styleProp:e})/n*100);c(o,t)}}}function Nv({collapsedSize:e,collapsible:t,itemId:n},r){return t&&ev(r[n],e)}function Pv({itemConstraints:e,itemId:t,nextLayout:n,prevLayout:r}){return e.some(e=>e.itemId!==t&&Nv(e,r)!==Nv(e,n))}function Fv(e){e.defaultPrevented||Sv(e,J_(),e.currentTarget).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.items.find(e=>e.constraintProps.defaultSize!==void 0);if(n){let r=n.constraintProps.defaultSize,i=Mv({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Iv(e){let t=J_();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Lv({axisId:e}){let t=()=>{let t=J_();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{axis:n,...r}=t(),i=jv({axis:n,axisState:r}),a=i?.state??r,{defaultLayoutDeferred:o,derivedItemConstraints:s,axisSize:c,layout:l}=a,u=Ov({layout:e,itemConstraints:s});return o?l:((i?.changed||!iv(l,u))&&X_(n,{...a,layout:u,requestedAxisSize:c,requestedLayout:u}),u)}}}function Rv(e,t){let n=Iv(e),r=q_(n.id,!0),i=n.separators.find(t=>t.element===e);Ug(i,`Matching separator not found`);let a=r.separatorToItems.get(i);Ug(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=Lv({axisId:n.id}).getLayout(),c=Ov({layout:rv({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});iv(s,c)||X_(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function zv(e){return e.separators.filter(e=>!e.disabled)}function Bv(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Iv(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Rv(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Rv(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Rv(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Rv(t,-5);break;case`End`:e.preventDefault(),Rv(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=q_(n.id,!0),o=n.separators.find(e=>e.element===t);Ug(o,`Matching separator not found`);let s=a.get(o);Ug(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(Ug(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Rv(t,(l.collapsedSize===e?n.mutableState.expandedItemSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let t=zv(n).map(e=>e.element),r=t.findIndex(t=>t===e.currentTarget);Ug(r!==-1,`Index not found`),t[e.shiftKey?r>0?r-1:t.length-1:r+1<t.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Rv(t,-100)}}function Vv(e,t){let n=Zg();if(n.state!==`active`||!Q_(n,e,t))return!1;let r=J_();H_();try{n.previewLayoutMap.forEach((e,t)=>{let n=r.get(t);t.resizePreviewMode===`separator`&&n&&!iv(e,n.layout)&&X_(t,{...n,layout:e,requestedAxisSize:n.axisSize,requestedLayout:e})}),U_(),e_({cursorFlags:0,state:`inactive`}),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=q_(e.axis.id,!0);X_(e.axis,t,{isUserInteraction:!0})})}finally{W_()}return!0}function Hv(e){let t=Zg();if(t.state!==`active`)return;let n=t.hitRegions.flatMap(({separator:e})=>e?[e.element]:[]);!n.some(t=>t===e.target)||n.some(t=>t.hasPointerCapture?.(e.pointerId))||Vv(e.currentTarget,e)}function Uv(e){Vv(e.currentTarget,e)}function Wv(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return D_({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:r,rect:s,separator:c},l)=>{let u=i.indexOf(r[0]),d=o?s.left+s.width/2:s.top+s.height/2;return{active:t.some(t=>{if(t.axis!==e||t.items[0]!==r[0])return!1;if(c||t.separator)return t.separator===c;let n=o?t.rect.left+t.rect.width/2:t.rect.top+t.rect.height/2;return ev(d,n)}),axis:e,key:c?`separator-${c.id}`:`panel-${r[0].id}-${l}`,offset:0,itemIndex:u,rect:new DOMRect((o&&!c?d:s.left)-a.left-n.clientLeft+n.scrollLeft,(!o&&!c?d:s.top)-a.top-n.clientTop+n.scrollTop,o&&!c?0:s.width,!o&&!c?0:s.height),separator:c}})}function Gv(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Zg();if(t.state===`active`){Z_(t,e)&&Vv(t.ownerDocument,t);return}let n=J_(),r=Sv(e,n,e.currentTarget);if(r.length===0)return;let i=new Map,a=!1;r.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let t=n.get(e.axis);t&&i.set(e.axis,t.layout)});let o=Array.from(i.keys()).flatMap(e=>e.resizePreviewMode===`separator`?Wv(e,r):[]);e_({cursorFlags:0,didPointerMove:!1,hitRegions:r,initialLayoutMap:i,ownerDocument:e.currentTarget,pointerDownAtPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId,pointerType:e.pointerType,previewLayoutMap:new Map(i),previews:o,state:`active`}),e.preventDefault()}function Kv(e){let t=e.currentTarget,n=J_(),r=Zg();if(r.state===`active`){if(!Q_(r,t,e))return;av({commit:!1,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedAxes:n,prevCursorFlags:r.cursorFlags})}}function qv(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Zg(),r=J_();switch(n.state){case`active`:if(!Q_(n,t,e))return;if(e.buttons===0){Vv(t,e);return}for(let t of n.hitRegions)if(t.separator){let{element:n}=t.separator;n.isConnected&&!n.hasPointerCapture?.(e.pointerId)&&n.setPointerCapture?.(e.pointerId)}av({commit:!1,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags});break;default:{let i=Sv(e,r,t);i.length===0?n.state!==`inactive`&&e_({cursorFlags:0,state:`inactive`}):e_({cursorFlags:0,hitRegions:i,ownerDocument:t,state:`hover`});break}}}function Jv(e){let t=e.relatedTarget;if(C_(t)&&t.localName===`iframe`){let t=Zg();t.state===`hover`&&t.ownerDocument===e.currentTarget&&e_({cursorFlags:0,state:`inactive`})}}function Yv(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||sv(e.currentTarget,e)}function Xv(e){e.target===e.currentTarget&&Vv(e.currentTarget.document)}function Zv(e){Vv(e.currentTarget.document)}function Qv(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=v_({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:F_(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}var $v=new Map,ey=!1;function ty(e){let t=!0;Ug(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{let r;H_();try{for(let i of n){let{borderBoxSize:n,target:a}=i;if(a===e.element){if(t){let t=q_(e.id);if(!t)break;let n=jv({axis:e,axisState:t});if(!n)break;if(!n.changed)continue;X_(e,n.state)}}else try{Qv(e,a,n)}catch(e){r??={error:e}}}}finally{W_()}if(r)throw r.error});a.observe(e.element),e.items.forEach(e=>{Ug(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=v_({axis:e}),s=I_(e,o),c=Tv({axis:e,itemConstraints:s}),l=Ov({layout:c,itemConstraints:s}),u=e.element.ownerDocument,d=u.defaultView;$v.set(u,($v.get(u)??0)+1);let f=new Map;return D_({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&f.set(e.separator,e.items)}),X_(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:kv({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:f}),e.separators.forEach(e=>{Ug(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Bv)}),ey||(ey=!0,Qg(__)),$v.get(u)===1&&(u.addEventListener(`contextmenu`,cv,!0),u.addEventListener(`dblclick`,Fv,!0),u.addEventListener(`lostpointercapture`,Hv,!0),u.addEventListener(`pointercancel`,Uv,!0),u.addEventListener(`pointerdown`,Gv,!0),u.addEventListener(`pointerleave`,Kv),u.addEventListener(`pointermove`,qv),u.addEventListener(`pointerout`,Jv),u.addEventListener(`pointerup`,Yv,!0),d?.addEventListener(`blur`,Xv),d?.addEventListener(`pagehide`,Zv)),function(){t=!1,$v.set(u,Math.max(0,($v.get(u)??0)-1)),G_(e),n_(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Bv)}),$v.get(u)||(u.removeEventListener(`contextmenu`,cv,!0),u.removeEventListener(`dblclick`,Fv,!0),u.removeEventListener(`lostpointercapture`,Hv,!0),u.removeEventListener(`pointercancel`,Uv,!0),u.removeEventListener(`pointerdown`,Gv,!0),u.removeEventListener(`pointerleave`,Kv),u.removeEventListener(`pointermove`,qv),u.removeEventListener(`pointerout`,Jv),u.removeEventListener(`pointerup`,Yv,!0),d?.removeEventListener(`blur`,Xv),d?.removeEventListener(`pagehide`,Zv)),a.disconnect()}}function ny({derivedItemConstraints:e,axis:t,layout:n,prevLayout:r,requestedLayout:i}){let a=t.items.map(({id:e})=>e).join(`,`);t.mutableState.layouts[a]=i,r&&e.forEach(e=>{if(e.collapsible){let i=ev(e.collapsedSize,n[e.itemId]),a=ev(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function ry(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function iy(e){let t=(0,G.useRef)({...e});return zg(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var ay=(0,G.createContext)(null);(0,G.createContext)(null);function oy({layout:e,itemConstraints:t,itemId:n,itemIndex:r}){let i,a,o=e[n],s=t.find(e=>e.itemId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Ov({layout:rv({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=Ov({layout:rv({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function sy({attributes:e,axisId:t,axisOrientation:n,children:r,className:i,"data-testid":a,disableCursor:o,disabled:s,disableDoubleClick:c,elementRef:l,id:u,isSharedHitRegion:d,preview:f,registerSeparator:p,requiredStyle:m,style:h,styleDefaults:g,tabIndex:_=0,updateSeparatorProps:v}){let y=iy({disabled:s,disableDoubleClick:c,children:r,className:i,preview:f,style:h}),[b,x]=(0,G.useState)({}),[S,C]=(0,G.useState)(`inactive`),[w,T]=(0,G.useState)(!1),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=Vg(E,l),k=n===`horizontal`?`vertical`:`horizontal`;zg(()=>{let e=E.current;if(e!==null){let n={disabled:y.disabled,disableDoubleClick:y.disableDoubleClick,element:e,id:u,get children(){return y.children},get className(){return y.className},get preview(){return y.preview},get style(){return y.style}};D.current=n;let r=p(n),i=Qg(e=>{C(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(d?.(e)??!1))?e.next.state:`inactive`)}),a=Y_(t,e=>{let{derivedItemConstraints:t,layout:r,separatorToItems:i}=e.next,a=i.get(n);if(a){let n=a[0],i=t.findIndex(e=>e.itemId===n.id),{layoutStrategy:o}=e.axis;x({...oy({layout:r,itemConstraints:t,itemId:n.id,itemIndex:i}),...o?.getItemAriaControls&&{valueControls:o.getItemAriaControls(n.id)}})}});return()=>{D.current=null,i(),a(),r()}}},[t,u,d,p,y]),zg(()=>{let e=D.current;e&&t_(e)},[f]),(0,G.useEffect)(()=>{v(u,{disabled:s,disableDoubleClick:c})},[s,c,u,v]);let A;s&&!o&&(A=`not-allowed`);let j;if(s)j=`disabled`;else switch(S){case`active`:j=`active`;break;default:j=w?`focus`:S}return(0,K.jsx)(`div`,{...e,"aria-controls":b.valueControls,"aria-disabled":s||void 0,"aria-orientation":k,"aria-valuemax":b.valueMax,"aria-valuemin":b.valueMin,"aria-valuenow":b.valueNow,children:r,className:i,"data-separator":j,"data-testid":a,id:u,onBlur:()=>T(!1),onFocus:()=>T(!0),ref:O,role:`separator`,style:{...g,cursor:A,...h,...m,touchAction:`none`},tabIndex:s?void 0:_})}function cy(e){for(let t=1;t<e.length;t++)if(y_(e[t-1],e[t])>0)return!1;return!0}function ly({separator:e}){let{element:t}=e,n=(0,G.useRef)(null);return zg(()=>{let e=t.cloneNode(!0),r=[t,...t.querySelectorAll(`*`)],i=[e,...e.querySelectorAll(`*`)],a=t.ownerDocument.defaultView;return r.forEach((e,t)=>{let n=i[t],{style:r}=n;if(r){let t=a.getComputedStyle(e);for(let e=0;e<t.length;e++){let n=t.item(e);r.setProperty(n,t.getPropertyValue(n))}}n.removeAttribute(`data-testid`),n.removeAttribute(`id`)}),Object.assign(e.style,{boxSizing:`border-box`,height:`100%`,margin:`0`,position:`static`,transform:`none`,width:`100%`}),n.current.appendChild(e),()=>e.remove()},[t]),(0,K.jsx)(`div`,{ref:n,style:{height:`100%`,opacity:.65,pointerEvents:`none`,width:`100%`}})}function uy(){let e=(0,G.useContext)(ay);return Ug(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function dy(e){let{registerOverlay:t}=uy(),n=(0,G.useRef)(e);Ev(n.current,e)||(n.current=e);let r=n.current;return zg(()=>t(r),[t,r]),null}var fy=Object.assign(dy,{displayName:`SeparatorOverlay`});function py({active:e,orientation:t,style:n,...r}){let i;switch(t){case`horizontal`:i={height:`100%`,minWidth:`1px`};break;case`vertical`:i={minHeight:`1px`,width:`100%`}}return(0,K.jsx)(`div`,{...r,"data-separator-overlay":e?`active`:`inactive`,style:{...i,...n,flexShrink:0,pointerEvents:`none`}})}function my({overlay:e,preview:t}){let{axis:n,offset:r,rect:i,separator:a}=t,o=n.orientation===`horizontal`,s=a?.preview,c=e;return(0,G.isValidElement)(s)&&s.type===fy&&(c=s.props,s=void 0),s??(c?s=(0,K.jsx)(py,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,K.jsx)(ly,{separator:a}))),(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-resize-preview":!0,inert:!0,style:{height:i.height,left:i.left,pointerEvents:`none`,position:`absolute`,top:i.top,transform:o?`translateX(${r}px)`:`translateY(${r}px)`,width:i.width},children:s})}function hy(e){return Array.from(e).sort(y_)}var gy=(0,G.createContext)(null);function _y(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:r_});return(0,G.useImperativeHandle)(t,()=>n.current,[]),zg(()=>{Object.assign(n.current,Lv({axisId:e}))}),n}function vy({groupId:e,resizePreviewMode:t}){let[n,r]=(0,G.useState)([]),i=(0,G.useRef)(n);return zg(()=>{let n=n=>{let a=K_(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!ev(e.offset,0))):[],s=i.current;s.length===o.length&&o.every((e,t)=>e===s[t])||(i.current=o,r(o))};if(t!==`separator`){n(Zg());return}let a=Qg(({next:e})=>n(e));return n(Zg()),a},[e,t]),n}function yy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizePreviewMode:d=`panel`,resizeTargetMinimumSize:f={coarse:20,fine:10},style:p,...m}){let h=(0,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=Bg(e=>{iv(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=Bg((e,t,n)=>{iv(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=Rg(s),[y,b]=(0,G.useState)(),x=vy({groupId:v,resizePreviewMode:d}),S=(0,G.useRef)(null),[C,w]=ry(),T=(0,G.useRef)([]),E=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=Vg(S,a),O=_y(v,o),k=(0,G.useMemo)(()=>({getLayout:()=>O.current.getLayout(),id:v,orientation:u,setLayout:e=>O.current.setLayout(e)}),[v,O,u]),A=Bg((e,t)=>{let r=q_(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),j=iy({defaultLayout:n,disableCursor:r,resizeTargetMinimumSize:f}),M=(0,G.useMemo)(()=>({get disableCursor(){return!!j.disableCursor},getPanelStyles:A,id:v,orientation:u,registerPanel:e=>{let t=E.current;return t.panels=b_(u,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerOverlay:e=>(b(e),()=>{b(void 0)}),registerSeparator:e=>{let t=E.current;return t.separators=b_(u,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=E.current.panels.find(t=>t.id===e);if(!n||n.constraintProps.disabled===t)return;n.constraintProps.disabled=t;let r=K_(v),i=q_(v);r&&i&&X_(r,{...i,derivedItemConstraints:I_(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=E.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[A,v,w,u,j]),N=(0,G.useRef)(null);return zg(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=b_(u,t.panels),t.separators=b_(u,t.separators),T.current=hy([...t.panels.map(({element:e})=>e),...t.separators.map(({element:e})=>e)]);let n;if(j.defaultLayout!==void 0&&Object.keys(j.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=j.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!j.disableCursor,expandedItemSizes:E.current.lastExpandedPanelSizes,layouts:E.current.layouts},orientation:u,items:t.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return j.resizeTargetMinimumSize},separators:t.separators};N.current=r;let a=ty(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=q_(r.id,!0);if(!o&&s.length>0)try{try{g(c)}finally{_(c,!1,l)}}catch(e){throw N.current=null,a(),e}let f=Y_(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;ny({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=Zg(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);try{g(i)}finally{s&&_(i,e.isUserInteraction,a)}});return()=>{N.current=null,a(),f()}},[i,v,_,g,u,C,d,j]),zg(()=>{cy(T.current)||w()}),(0,G.useEffect)(()=>{let e=N.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(gy.Provider,{value:k,children:(0,K.jsx)(ay.Provider,{value:M,children:(0,K.jsxs)(`div`,{...m,className:t,"data-group":!0,"data-testid":Hg(m,s),id:v,ref:D,style:{height:`100%`,width:`100%`,overflow:`hidden`,position:d===`separator`?`relative`:void 0,...p,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:[e,x.map(e=>(0,K.jsx)(my,{overlay:y,preview:e},e.key))]})})})}var by=Object.assign(yy,{displayName:`Group`}),xy=(0,G.createContext)(null);function Sy(e,t){let{id:n}=uy(),r=(0,G.useRef)({collapse:i_,expand:i_,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:i_});return(0,G.useImperativeHandle)(t,()=>r.current,[]),zg(()=>{Object.assign(r.current,Mv({axisId:n,itemId:e}))}),r}function Cy({children:e,className:t,collapsedSize:n=`0%`,collapsedThreshold:r,collapsible:i=!1,defaultSize:a,disabled:o,elementRef:s,groupResizeBehavior:c=`preserve-relative-size`,id:l,maxSize:u=`100%`,minSize:d=`0%`,onResize:f,panelRef:p,style:m,...h}){let g=Lg(l),_=Rg(l),v=iy({disabled:o}),y=(0,G.useRef)(null),b=Vg(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=uy(),E=f!==null,D=Bg((e,t,n)=>{f?.(e,l,n)});zg(()=>{let e=y.current;if(e!==null){let t={element:e,id:_,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,constraintProps:{groupResizeBehavior:c,collapsedSize:n,collapsedThreshold:r,collapsible:i,defaultSize:a,disabled:v.disabled,maxSize:u,minSize:d}};return w(t)}},[c,n,r,i,a,E,_,g,u,d,D,w,v]),(0,G.useEffect)(()=>{T(_,{disabled:o})},[o,_,T]);let O=Sy(_,p),k=(0,G.useMemo)(()=>({collapse:()=>O.current.collapse(),expand:()=>O.current.expand(),getSize:()=>O.current.getSize(),groupId:S,id:_,isCollapsed:()=>O.current.isCollapsed(),resize:e=>O.current.resize(e)}),[S,_,O]),A=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},j=(0,G.useSyncExternalStore)(e=>Y_(S,e),A,A),M;return M=j?JSON.parse(j):a===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:a},(0,K.jsx)(`div`,{...h,"data-disabled":o||void 0,"data-panel":!0,"data-testid":Hg(h,l),id:_,ref:b,style:{...Ty,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...M},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...m,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:(0,K.jsx)(xy.Provider,{value:k,children:e})})})}var wy=Object.assign(Cy,{displayName:`Panel`}),Ty={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0},Ey={flexBasis:`auto`},Dy={flexGrow:0,flexShrink:0};function Oy({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=Rg(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=uy();return(0,K.jsx)(sy,{attributes:c,axisId:d,axisOrientation:f,className:t,"data-testid":Hg(c,a),disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:Dy,style:s,styleDefaults:Ey,updateSeparatorProps:m,children:e})}var ky=Object.assign(Oy,{displayName:`Separator`});(0,G.createContext)(null),(0,G.createContext)(null),(0,G.createContext)(null),(0,G.createContext)(null),(0,G.createContext)(null),(0,G.createContext)(null),(0,G.createContext)({isOverflowing:!1,orientation:`horizontal`});var Ay=({className:e,...t})=>(0,K.jsx)(by,{className:B(`flex h-full w-full`,e),...t}),jy=e=>(0,K.jsx)(wy,{...e}),My={vertical:`h-3 w-full -my-1.5 cursor-row-resize pointer-coarse:h-5 pointer-coarse:-my-2.5`,horizontal:`h-full w-3 -mx-1.5 cursor-col-resize pointer-coarse:w-5 pointer-coarse:-mx-2.5`},Ny={vertical:`before:absolute before:inset-x-0 before:top-1/2 before:h-px before:-translate-y-1/2 data-[separator=hover]:before:h-0.5 data-[separator=active]:before:h-0.5`,horizontal:`before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 data-[separator=hover]:before:w-0.5 data-[separator=active]:before:w-0.5`},Py=`before:bg-border before:transition-colors data-[separator=hover]:before:bg-ring data-[separator=active]:before:bg-ring focus-visible:before:bg-ring`,Fy=({withHandle:e,orientation:t,disabled:n,className:r,...i})=>(0,K.jsx)(ky,{disabled:n,className:B(`relative flex items-center justify-center bg-transparent focus-visible:outline-none`,My[t],e&&Ny[t],e&&Py,r),...i,children:(0,K.jsx)(`span`,{className:`sr-only`,children:t===`vertical`?`Resize rows`:`Resize columns`})}),Iy=0,Ly=0,Ry=0,zy=0,By;(e=>{function t(e,t,n,r){return r===void 0?`#${Gy(e)}${Gy(t)}${Gy(n)}`:`#${Gy(e)}${Gy(t)}${Gy(n)}${Gy(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(By||={});var Vy;(e=>{function t(e,t){if(zy=(t.rgba&255)/255,zy===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Iy=a+Math.round((n-a)*zy),Ly=o+Math.round((r-o)*zy),Ry=s+Math.round((i-s)*zy),{css:By.toCss(Iy,Ly,Ry),rgba:By.toRgba(Iy,Ly,Ry)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Wy.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return By.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Iy,Ly,Ry]=Wy.toChannels(t),{css:By.toCss(Iy,Ly,Ry),rgba:t}}e.opaque=i;function a(e,t){return zy=Math.round(t*255),[Iy,Ly,Ry]=Wy.toChannels(e.rgba),{css:By.toCss(Iy,Ly,Ry,zy),rgba:By.toRgba(Iy,Ly,Ry,zy)}}e.opacity=a;function o(e,t){return zy=e.rgba&255,a(e,zy*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Vy||={});var Hy;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Iy=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),By.toColor(Iy,Ly,Ry);case 5:return Iy=parseInt(e.slice(1,2).repeat(2),16),Ly=parseInt(e.slice(2,3).repeat(2),16),Ry=parseInt(e.slice(3,4).repeat(2),16),zy=parseInt(e.slice(4,5).repeat(2),16),By.toColor(Iy,Ly,Ry,zy);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Iy=parseInt(r[1]),Ly=parseInt(r[2]),Ry=parseInt(r[3]),zy=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),By.toColor(Iy,Ly,Ry,zy);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Iy,Ly,Ry,zy]=t.getImageData(0,0,1,1).data,zy!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:By.toRgba(Iy,Ly,Ry,zy),css:e}}e.toColor=r})(Hy||={});var Uy;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Uy||={});var Wy;(e=>{function t(e,t){if(zy=(t&255)/255,zy===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Iy=a+Math.round((n-a)*zy),Ly=o+Math.round((r-o)*zy),Ry=s+Math.round((i-s)*zy),By.toRgba(Iy,Ly,Ry)}e.blend=t;function n(e,t,n){let a=Uy.relativeLuminance(e>>8),o=Uy.relativeLuminance(t>>8);if(Ky(a,o)<n){if(o<a){let o=r(e,t,n),s=Ky(a,Uy.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Ky(a,Uy.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Ky(a,Uy.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Ky(a,Uy.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ky(Uy.relativeLuminance2(o,s,c),Uy.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Ky(Uy.relativeLuminance2(o,s,c),Uy.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ky(Uy.relativeLuminance2(o,s,c),Uy.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=Ky(Uy.relativeLuminance2(o,s,c),Uy.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Wy||={});function Gy(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Ky(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var qy=Object.freeze((()=>{let e=[Hy.toColor(`#2e3436`),Hy.toColor(`#cc0000`),Hy.toColor(`#4e9a06`),Hy.toColor(`#c4a000`),Hy.toColor(`#3465a4`),Hy.toColor(`#75507b`),Hy.toColor(`#06989a`),Hy.toColor(`#d3d7cf`),Hy.toColor(`#555753`),Hy.toColor(`#ef2929`),Hy.toColor(`#8ae234`),Hy.toColor(`#fce94f`),Hy.toColor(`#729fcf`),Hy.toColor(`#ad7fa8`),Hy.toColor(`#34e2e2`),Hy.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:By.toCss(r,i,a),rgba:By.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:By.toCss(n,n,n),rgba:By.toRgba(n,n,n)})}return e})());function Jy(e,t,n){return Math.max(t,Math.min(e,n))}function Yy(e){switch(e){case`&`:return`&amp;`;case`<`:return`&lt;`}return e}var Xy=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),r=this._buffer.getNullCell(),i=n,a=e.start.y,o=e.end.y,s=e.start.x,c=e.end.x;this._beforeSerialize(o-a,a,o);for(let t=a;t<=o;t++){let a=this._buffer.getLine(t);if(a){let o=t===e.start.y?s:0,l=t===e.end.y?c:a.length;for(let e=o;e<l;e++){let o=a.getCell(e,i===n?r:n);o?(this._nextCell(o,i,t,e),i=o):console.warn(`Can't get cell at row=${t}, col=${e}`)}}this._rowEnd(t,t===o)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,n,r){}_rowEnd(e,t){}_beforeSerialize(e,t,n){}_afterSerialize(){}_serializeString(e){return``}};function Zy(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function Qy(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function $y(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var eb=class extends Xy{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow=``,this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,n){this._allRows=Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){this._nullCellCount>0&&!Qy(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n=``;if(!t){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let t=this._buffer.getLine(e),r=this._buffer.getLine(e+1);if(!r.isWrapped)n=`\r
3
+ `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n=``;let i=t.getCell(t.length-1,this._thisRowLastChar),a=t.getCell(t.length-2,this._thisRowLastSecondChar),o=r.getCell(0,this._nextRowFirstChar),s=o.getWidth()>1,c=!1;(o.getChars()&&s?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||i.getWidth()===0)&&Qy(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&Qy(i,o)&&Qy(a,o)&&(c=!0)),c||(n=`-`.repeat(this._nullCellCount+1),n+=`\x1B[1D\x1B[1X`,this._nullCellCount>0&&(n+=`\x1B[A`,n+=`\x1B[${t.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${t.length-this._nullCellCount}D`,n+=`\x1B[B`),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow=``,this._nullCellCount=0}_diffStyle(e,t){let n=[],r=!Zy(e,t),i=!Qy(e,t),a=!$y(e,t);if(r||i||a){if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(r){let t=e.getFgColor();e.isFgRGB()?n.push(38,2,t>>>16&255,t>>>8&255,t&255):e.isFgPalette()?t>=16?n.push(38,5,t):n.push(t&8?90+(t&7):30+(t&7)):n.push(39)}if(i){let t=e.getBgColor();e.isBgRGB()?n.push(48,2,t>>>16&255,t>>>8&255,t&255):e.isBgPalette()?t>=16?n.push(48,5,t):n.push(t&8?100+(t&7):40+(t&7)):n.push(49)}a&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}}return n}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,this._cursorStyle);if(i?!Qy(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(Qy(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`\x1B[${a.join(`;`)}m`;let e=this._buffer.getLine(n);e!==void 0&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=r)}i?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Qy(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n=``;for(let e=0;e<t;e++)n+=this._allRows[e],e+1<t&&(n+=this._allRowSeparators[e]);if(!e){let e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX;(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((e=>{e>0?n+=`\x1B[${e}B`:e<0&&(n+=`\x1B[${-e}A`)})(e-this._lastCursorRow),(e=>{e>0?n+=`\x1B[${e}C`:e<0&&(n+=`\x1B[${-e}D`)})(t-this._lastCursorCol))}let r=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(r,this._cursorStyle);return i.length>0&&(n+=`\x1B[${i.join(`;`)}m`),n}},tb=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:Jy(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new eb(t,e).serialize({start:{x:0,y:typeof n.start==`number`?n.start:n.start.line},end:{x:e.cols,y:typeof n.end==`number`?n.end:n.end.line}},r)}_serializeBufferAsHTML(e,t){let n=e.buffer.active,r=new nb(n,e,t),i=t.onlySelection??!1,a=t.range;if(a)return r.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!i){let i=n.length,a=t.scrollback,o=a===void 0?i:Jy(a+e.rows,0,i);return r.serialize({start:{x:0,y:i-o},end:{x:e.cols,y:i-1}})}let o=this._terminal?.getSelectionPosition();return o===void 0?``:r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}})}_serializeModes(e){let t=``,n=e.modes;if(n.applicationCursorKeysMode&&(t+=`\x1B[?1h`),n.applicationKeypadMode&&(t+=`\x1B[?66h`),n.bracketedPasteMode&&(t+=`\x1B[?2004h`),n.insertMode&&(t+=`\x1B[4h`),n.originMode&&(t+=`\x1B[?6h`),n.reverseWraparoundMode&&(t+=`\x1B[?45h`),n.sendFocusMode&&(t+=`\x1B[?1004h`),n.wraparoundMode===!1&&(t+=`\x1B[?7l`),n.mouseTrackingMode!==`none`)switch(n.mouseTrackingMode){case`x10`:t+=`\x1B[?9h`;break;case`vt200`:t+=`\x1B[?1000h`;break;case`drag`:t+=`\x1B[?1002h`;break;case`any`:t+=`\x1B[?1003h`}return t}serialize(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type===`alternate`){let e=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${e}`}return e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},nb=class extends Xy{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow=``,this._htmlContent=``,this._ansiColors=t._core._themeService?t._core._themeService.colors.ansi:qy}_padStart(e,t,n){return t|=0,n??=` `,e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){this._htmlContent+=`<html><body><!--StartFragment--><pre>`;let r=`#000000`,i=`#ffffff`;(this._options.includeGlobalBackground??!1)&&(r=this._terminal.options.theme?.foreground??`#ffffff`,i=this._terminal.options.theme?.background??`#000000`);let a=[];a.push(`color: `+r+`;`),a.push(`background-color: `+i+`;`),a.push(`font-family: `+this._terminal.options.fontFamily+`;`),a.push(`font-size: `+this._terminal.options.fontSize+`px;`),this._htmlContent+=`<div style='`+a.join(` `)+`'>`}_afterSerialize(){this._htmlContent+=`</div>`,this._htmlContent+=`</pre><!--EndFragment--></body></html>`}_rowEnd(e,t){this._htmlContent+=`<div><span>`+this._currentRow+`</span></div>`,this._currentRow=``}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return`#`+[n>>16&255,n>>8&255,n&255].map(e=>this._padStart(e.toString(16),2,`0`)).join(``);if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],r=!Zy(e,t),i=!Qy(e,t),a=!$y(e,t);if(r||i||a){let t=this._getHexColor(e,!0);t&&n.push(`color: `+t+`;`);let r=this._getHexColor(e,!1);return r&&n.push(`background-color: `+r+`;`),e.isInverse()&&n.push(`color: #000000; background-color: #BFBFBF;`),e.isBold()&&n.push(`font-weight: bold;`),e.isUnderline()&&e.isOverline()?n.push(`text-decoration: overline underline;`):e.isUnderline()?n.push(`text-decoration: underline;`):e.isOverline()&&n.push(`text-decoration: overline;`),e.isBlink()&&n.push(`text-decoration: blink;`),e.isInvisible()&&n.push(`visibility: hidden;`),e.isItalic()&&n.push(`font-style: italic;`),e.isDim()&&n.push(`opacity: 0.5;`),e.isStrikethrough()&&n.push(`text-decoration: line-through;`),n}}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,t);a&&(this._currentRow+=a.length===0?`</span><span>`:`</span><span style='`+a.join(` `)+`'>`),i?this._currentRow+=` `:this._currentRow+=Yy(e.getChars())}_serializeString(){return this._htmlContent}},rb=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=ab.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ib(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var ab=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ib(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ob=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function sb(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var cb=class{constructor(e=sb,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ob;this._linkProvider=this._terminal.registerLinkProvider(new rb(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},lb=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,db=(e,t)=>{for(var n in t)lb(e,n,{get:t[n],enumerable:!0})},fb=(e,t,n,r)=>{for(var i=r>1?void 0:r?ub(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&lb(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),pb=`Terminal input`,mb={get:()=>pb,set:e=>pb=e},hb=`Too much output to announce, navigate to rows manually to read`,gb={get:()=>hb,set:e=>hb=e};function _b(e){return e.replace(/\r?\n/g,`\r`)}function vb(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function yb(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function bb(e,t,n,r){e.stopPropagation(),e.clipboardData&&xb(e.clipboardData.getData(`text/plain`),t,n,r)}function xb(e,t,n,r){e=_b(e),e=vb(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Sb(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Cb(e,t,n,r,i){Sb(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function wb(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Tb(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Eb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},Db=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Ob=``,kb=` `,Ab=class e{constructor(){this.fg=0,this.bg=0,this.extended=new jb}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},jb=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Mb=class e extends Ab{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new jb,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?wb(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Nb=`di$target`,Pb=`di$dependencies`,Fb=new Map;function Ib(e){return e[Pb]||[]}function Lb(e){if(Fb.has(e))return Fb.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Rb(t,e,r)};return t._id=e,Fb.set(e,t),t}function Rb(e,t,n){t[Nb]===t?t[Pb].push({id:e,index:n}):(t[Pb]=[{id:e,index:n}],t[Nb]=t)}var zb=Lb(`BufferService`),Bb=Lb(`CoreMouseService`),Vb=Lb(`CoreService`),Hb=Lb(`CharsetService`),Ub=Lb(`InstantiationService`),Wb=Lb(`LogService`),Gb=Lb(`OptionsService`),Kb=Lb(`OscLinkService`),qb=Lb(`UnicodeService`),Jb=Lb(`DecorationService`),Yb=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Mb,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Xb(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Yb=fb([X(0,zb),X(1,Gb),X(2,Kb)],Yb);function Xb(e,t){if(confirm(`Do you want to navigate to ${t}?
4
+
5
+ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Zb=Lb(`CharSizeService`),Qb=Lb(`CoreBrowserService`),$b=Lb(`MouseService`),ex=Lb(`RenderService`),tx=Lb(`SelectionService`),nx=Lb(`CharacterJoinerService`),rx=Lb(`ThemeService`),ix=Lb(`LinkProviderService`),ax=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?dx.isErrorNoTelemetry(e)?new dx(e.message+`
6
+
7
+ `+e.stack):Error(e.message+`
8
+
9
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function ox(e){cx(e)||ax.onUnexpectedError(e)}var sx=`Canceled`;function cx(e){return e instanceof lx||e instanceof Error&&e.name===sx&&e.message===sx}var lx=class extends Error{constructor(){super(sx),this.name=this.message}};function ux(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var dx=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},fx=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function px(e,t=0){return e[e.length-(1+t)]}var mx;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(mx||={});var hx=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||mx.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};hx.empty=new hx(e=>{});function gx(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var _x;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(_x||={});var vx=null;function yx(e){return vx?.trackDisposable(e),e}function bx(e){vx?.markAsDisposed(e)}function xx(e,t){vx?.setParent(e,t)}function Sx(e){return vx?.markAsSingleton(e),e}function Cx(e){if(_x.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function wx(...e){return Tx(()=>Cx(e))}function Tx(e){let t=yx({dispose:gx(()=>{bx(t),e()})});return t}var Ex=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,yx(this)}dispose(){this._isDisposed||(bx(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Cx(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return xx(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),xx(e,null))}};Ex.DISABLE_DISPOSED_WARNING=!1;var Dx=Ex,Ox=class{constructor(){this._store=new Dx,yx(this),xx(this._store,this)}dispose(){bx(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Ox.None=Object.freeze({dispose(){}});var kx=class{constructor(){this._isDisposed=!1,yx(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&xx(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,bx(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&xx(e,null),e}},Ax=typeof window==`object`?window:globalThis,jx=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};jx.Undefined=new jx(void 0);var Mx=jx,Nx=class{constructor(){this._first=Mx.Undefined,this._last=Mx.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Mx.Undefined}clear(){let e=this._first;for(;e!==Mx.Undefined;){let t=e.next;e.prev=Mx.Undefined,e.next=Mx.Undefined,e=t}this._first=Mx.Undefined,this._last=Mx.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Mx(e);if(this._first===Mx.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==Mx.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Mx.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Mx.Undefined&&e.next!==Mx.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Mx.Undefined&&e.next===Mx.Undefined?(this._first=Mx.Undefined,this._last=Mx.Undefined):e.next===Mx.Undefined?(this._last=this._last.prev,this._last.next=Mx.Undefined):e.prev===Mx.Undefined&&(this._first=this._first.next,this._first.prev=Mx.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==Mx.Undefined;)yield e.element,e=e.next}},Px=globalThis.performance&&typeof globalThis.performance.now==`function`,Fx=class e{static create(t){return new e(t)}constructor(e){this._now=Px&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Ix;(e=>{e.None=()=>Ox.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(wx(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Z({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Z({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Z({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Z;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Z(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Dx?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(Ix||={});var Lx=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Fx,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Lx.all=new Set,Lx._idPool=0;var Rx=Lx,zx=-1,Bx=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new Ux(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};Bx._idPool=1;var Vx=Bx,Hx=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
10
+ `).slice(2).join(`
11
+ `))}},Ux=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},Wx=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Gx=0,Kx=class{constructor(e){this.value=e,this.id=Gx++}},qx=2,Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=zx>0||this._options?.leakWarningThreshold?new Vx(e?.onListenerError??ox,this._options?.leakWarningThreshold??zx):void 0,this._perfMon=this._options?._profName?new Rx(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Wx(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||ox)(n),Ox.None}if(this._disposed)return Ox.None;t&&(e=e.bind(t));let r=new Kx(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Hx.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Kx?(this._deliveryQueue??=new Jx,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Tx(()=>{i?.(),this._removeListener(r)});return n instanceof Dx?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*qx<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||ox;if(!n)e.value(t);else try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof Kx)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},Jx=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Yx=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Yx.INSTANCE=new Yx;var Xx=Yx;function Zx(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Xx.INSTANCE.onDidChangeZoomLevel;function Qx(e){return Xx.INSTANCE.getZoomFactor(e)}Xx.INSTANCE.onDidChangeFullscreen;var $x=typeof navigator==`object`?navigator.userAgent:``,eS=$x.indexOf(`Firefox`)>=0,tS=$x.indexOf(`AppleWebKit`)>=0,nS=$x.indexOf(`Chrome`)>=0,rS=!nS&&$x.indexOf(`Safari`)>=0;$x.indexOf(`Electron/`),$x.indexOf(`Android`);var iS=!1;if(typeof Ax.matchMedia==`function`){let e=Ax.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Ax.matchMedia(`(display-mode: fullscreen)`);iS=e.matches,Zx(Ax,e,({matches:e})=>{iS&&t.matches||(iS=e)})}function aS(){return iS}var oS=`en`,sS=!1,cS=!1,lS=!1,uS=!1,dS=!1,fS=oS,pS,mS=globalThis,hS;typeof mS.vscode<`u`&&typeof mS.vscode.process<`u`?hS=mS.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(hS=process);var gS=typeof hS?.versions?.electron==`string`&&hS?.type===`renderer`;if(typeof hS==`object`){sS=hS.platform===`win32`,cS=hS.platform===`darwin`,lS=hS.platform===`linux`,lS&&hS.env.SNAP&&hS.env.SNAP_REVISION,hS.env.CI||hS.env.BUILD_ARTIFACTSTAGINGDIRECTORY,fS=oS;let e=hS.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,fS=t.resolvedLanguage||oS,t.languagePack?.translationsConfigFile}catch{}uS=!0}else typeof navigator==`object`&&!gS?(pS=navigator.userAgent,sS=pS.indexOf(`Windows`)>=0,cS=pS.indexOf(`Macintosh`)>=0,(pS.indexOf(`Macintosh`)>=0||pS.indexOf(`iPad`)>=0||pS.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,lS=pS.indexOf(`Linux`)>=0,pS?.indexOf(`Mobi`),dS=!0,fS=globalThis._VSCODE_NLS_LANGUAGE||oS,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var _S=sS,vS=cS,yS=lS,bS=uS;dS&&typeof mS.importScripts==`function`&&mS.origin;var xS=pS,SS=fS,CS;(e=>{function t(){return SS}e.value=t;function n(){return SS.length===2?SS===`en`:SS.length>=3&&SS[0]===`e`&&SS[1]===`n`&&SS[2]===`-`}e.isDefaultVariant=n;function r(){return SS===`en`}e.isDefault=r})(CS||={});var wS=typeof mS.postMessage==`function`&&!mS.importScripts;(()=>{if(wS){let e=[];mS.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),mS.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var TS=!!(xS&&xS.indexOf(`Chrome`)>=0);xS&&xS.indexOf(`Firefox`),!TS&&xS&&xS.indexOf(`Safari`),xS&&xS.indexOf(`Edg/`),xS&&xS.indexOf(`Android`);var ES=typeof navigator==`object`?navigator:{};bS||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||ES&&ES.clipboard&&ES.clipboard.writeText,bS||ES&&ES.clipboard&&ES.clipboard.readText,bS||aS()||ES.keyboard,`ontouchstart`in Ax||ES.maxTouchPoints,Ax.PointerEvent&&(`ontouchstart`in Ax||navigator.maxTouchPoints);var DS=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},OS=new DS,kS=new DS,AS=new DS,jS=Array(230),MS;(e=>{function t(e){return OS.keyCodeToStr(e)}e.toString=t;function n(e){return OS.strToKeyCode(e)}e.fromString=n;function r(e){return kS.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return AS.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return kS.strToKeyCode(e)||AS.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return OS.keyCodeToStr(e)}e.toElectronAccelerator=o})(MS||={});var NS=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new PS([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},PS=class{constructor(e){if(e.length===0)throw ux(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function FS(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return MS.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(eS)switch(t){case 59:return 85;case 60:if(yS)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vS)return 57}else if(tS&&(vS&&t===93||!vS&&t===92))return 57;return jS[t]||0}var IS=vS?256:2048,LS=512,RS=1024,zS=vS?2048:256,BS=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=FS(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=IS),this.altKey&&(t|=LS),this.shiftKey&&(t|=RS),this.metaKey&&(t|=zS),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new NS(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},VS=new WeakMap;function HS(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var US=class{static getSameOriginWindowChain(e){let t=VS.get(e);if(!t){t=[],VS.set(e,t);let n=e,r;do r=HS(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},WS=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=US.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},GS=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(nS){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?eS&&!vS?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=rS&&_S?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?eS&&!vS?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},KS=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),qS;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof JS?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ix.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:KS})})(qS||={});var JS=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?KS:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},YS=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new fx(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new fx(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},XS=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new fx(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=Tx(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var ZS;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(ZS||={});var QS=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ix.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};QS.EMPTY=QS.fromArray([]);function $S(e){return eC(e,0)}function eC(e,t){switch(typeof e){case`object`:return e===null?tC(349,t):Array.isArray(e)?iC(e,t):aC(e,t);case`string`:return rC(e,t);case`boolean`:return nC(e,t);case`number`:return tC(e,t);case`undefined`:return tC(937,t);default:return tC(617,t)}}function tC(e,t){return(t<<5)-t+e|0}function nC(e,t){return tC(e?433:863,t)}function rC(e,t){t=tC(149417,t);for(let n=0,r=e.length;n<r;n++)t=tC(e.charCodeAt(n),t);return t}function iC(e,t){return t=tC(104579,t),e.reduce((e,t)=>eC(t,e),t)}function aC(e,t){return t=tC(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=rC(n,t),eC(e[n],t)),t)}var{registerWindow:oC,getWindow:sC,getDocument:cC,getWindows:lC,getWindowsCount:uC,getWindowId:dC,getWindowById:fC,hasWindow:pC,onDidRegisterWindow:mC,onWillUnregisterWindow:hC,onDidUnregisterWindow:gC}=function(){let e=new Map,t={window:Ax,disposables:new Dx};e.set(Ax.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Ox.None;let a=new Dx,o={window:t,disposables:a.add(new Dx)};return e.set(t.vscodeWindowId,o),a.add(Tx(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Q(t,EC.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Ax},getDocument(e){return sC(e).document}}}(),_C=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function Q(e,t,n,r){return new _C(e,t,n,r)}function vC(e,t){return function(n){return t(new WS(e,n))}}function yC(e){return function(t){return e(new BS(t))}}var bC=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=vC(sC(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=yC(n)),Q(e,t,i,r)},xC,SC=class extends XS{constructor(e){super(),this.defaultTarget=e&&sC(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},CC=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ox(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(CC.sort),a.shift().execute();r.set(i,!1)};xC=(t,r,a=0)=>{let o=dC(t),s=new CC(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var wC=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};wC.None=new wC(0,0);function TC(e){let t=e.getBoundingClientRect(),n=sC(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=$S(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(Tx(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var EC={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:tS?`webkitAnimationStart`:`animationstart`,ANIMATION_END:tS?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:tS?`webkitAnimationIteration`:`animationiteration`},DC=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=OC(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=OC(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=OC(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=OC(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=OC(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=OC(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=OC(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=OC(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=OC(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=OC(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=OC(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=OC(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=OC(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=OC(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function OC(e){return typeof e==`number`?`${e}px`:e}function kC(e){return new DC(e)}var AC=class{constructor(){this._hooks=new Dx,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(Tx(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=sC(e)}this._hooks.add(Q(a,EC.POINTER_MOVE,e=>{e.buttons===n?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(Q(a,EC.POINTER_UP,e=>this.stopMonitoring(!0)))}};function jC(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var MC;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(MC||={});var NC=class e extends Ox{constructor(){super(),this.dispatched=!1,this.targets=new Nx,this.ignoreTargets=new Nx,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ix.runAndSubscribe(mC,({window:e,disposables:t})=>{t.add(Q(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(Q(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(Q(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Ax,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Sx(new e),Tx(e.INSTANCE.targets.push(t))):Ox.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Sx(new e),Tx(e.INSTANCE.ignoreTargets.push(t))):Ox.None}static isTouchDevice(){return`ontouchstart`in Ax||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(MC.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-px(s.rollingPageX))<30&&Math.abs(s.initialPageY-px(s.rollingPageY))<30){let e=this.newGestureEvent(MC.Tap,s.initialTarget);e.pageX=px(s.rollingPageX),e.pageY=px(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-px(s.rollingPageX))<30&&Math.abs(s.initialPageY-px(s.rollingPageY))<30){let e=this.newGestureEvent(MC.Contextmenu,s.initialTarget);e.pageX=px(s.rollingPageX),e.pageY=px(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=px(s.rollingPageX),n=px(s.rollingPageY),i=px(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(MC.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===MC.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===MC.Change||t.type===MC.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=xC(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(MC.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(MC.Change,i.initialTarget);a.translationX=r.pageX-px(i.rollingPageX),a.translationY=r.pageY-px(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};NC.SCROLL_FRICTION=-.005,NC.HOLD_DELAY=700,NC.CLEAR_TAP_COUNT_TIME=400,fb([jC],NC,`isTouchDevice`,1);var PC=NC,FC=class extends Ox{onclick(e,t){this._register(Q(e,EC.CLICK,n=>t(new WS(sC(e),n))))}onmousedown(e,t){this._register(Q(e,EC.MOUSE_DOWN,n=>t(new WS(sC(e),n))))}onmouseover(e,t){this._register(Q(e,EC.MOUSE_OVER,n=>t(new WS(sC(e),n))))}onmouseleave(e,t){this._register(Q(e,EC.MOUSE_LEAVE,n=>t(new WS(sC(e),n))))}onkeydown(e,t){this._register(Q(e,EC.KEY_DOWN,e=>t(new BS(e))))}onkeyup(e,t){this._register(Q(e,EC.KEY_UP,e=>t(new BS(e))))}oninput(e,t){this._register(Q(e,EC.INPUT,t))}onblur(e,t){this._register(Q(e,EC.BLUR,t))}onfocus(e,t){this._register(Q(e,EC.FOCUS,t))}onchange(e,t){this._register(Q(e,EC.CHANGE,t))}ignoreGesture(e){return PC.ignoreTarget(e)}},IC=11,LC=class extends FC{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=IC+`px`,this.domNode.style.height=IC+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new AC),this._register(bC(this.bgDomNode,EC.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(bC(this.domNode,EC.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new SC),this._pointerdownScheduleRepeatTimer=this._register(new YS)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,sC(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},RC=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},zC=class extends Ox{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new RC(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new UC(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=UC.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},BC=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function VC(e,t){let n=t-e;return function(t){return e+n*GC(t)}}function HC(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var UC=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),HC(VC(e,r),VC(i,t),.33)}return VC(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new BC(this.scrollLeft(t),this.scrollTop(t),!1):new BC(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function WC(e){return e**3}function GC(e){return 1-WC(1-e)}var KC=class extends Ox{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new YS)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},qC=140,JC=class extends FC{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new KC(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new AC),this._shouldRender=!0,this.domNode=kC(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(Q(this.domNode.domNode,EC.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new LC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=kC(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Q(this.slider.domNode,EC.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=TC(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(_S&&a>qC){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},YC=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},XC=class extends JC{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new YC(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},ZC=class extends JC{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new YC(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},QC=500,$C=50,ew=!0,tw=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},nw=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(nS){let t=Qx(sC(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new tw(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};nw.INSTANCE=new nw;var rw=nw,iw=class extends FC{constructor(e,t,n){super(),this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Z),this.onWillScroll=this._onWillScroll.event,this._options=ow(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ZC(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new XC(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=kC(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=kC(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=kC(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new YS),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Cx(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,vS&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new GS(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Cx(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(Q(this._listenOnDomNode,EC.MOUSE_WHEEL,e=>{this._onMouseWheel(new GS(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=rw.INSTANCE;ew&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!vS&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=$C*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=$C*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(ew&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),QC)}},aw=class extends iw{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ow(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,vS&&(t.className+=` mac`),t}var sw=class extends Ox{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new zC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>xC(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new aw(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ix.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Tx(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(Tx(()=>this._styleElement.remove())),this._register(Ix.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
12
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};sw=fb([X(2,zb),X(3,Qb),X(4,Bb),X(5,rx),X(6,Gb),X(7,ex)],sw);var cw=class extends Ox{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,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(e=>this._removeDecoration(e))),this._register(Tx(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};cw=fb([X(1,zb),X(2,Qb),X(3,Jb),X(4,ex)],cw);var lw=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(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},uw={full:0,left:0,center:0,right:0},dw={full:0,left:0,center:0,right:0},fw={full:0,left:0,center:0,right:0},pw=class extends Ox{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new lw,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),this._register(Tx(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),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())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);dw.full=this._canvas.width,dw.left=e,dw.center=t,dw.right=e,this._refreshDrawHeightConstants(),fw.full=1,fw.left=1,fw.center=1+dw.left,fw.right=1+dw.left+dw.center}_refreshDrawHeightConstants(){uw.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);uw.left=t,uw.center=t,uw.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uw.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uw.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uw.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*uw.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(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(fw[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-uw[e.position||`full`]/2),dw[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+uw[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};pw=fb([X(2,zb),X(3,Jb),X(4,ex),X(5,Gb),X(6,rx),X(7,Qb)],pw);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
13
+ `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var mw;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(mw||={});var hw;(e=>e.ST=`${$.ESC}\\`)(hw||={});var gw=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};gw=fb([X(2,zb),X(3,Gb),X(4,Vb),X(5,ex)],gw);var _w=0,vw=0,yw=0,bw=0,xw={css:`#00000000`,rgba:0},Sw;(e=>{function t(e,t,n,r){return r===void 0?`#${Dw(e)}${Dw(t)}${Dw(n)}`:`#${Dw(e)}${Dw(t)}${Dw(n)}${Dw(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(Sw||={});var Cw;(e=>{function t(e,t){if(bw=(t.rgba&255)/255,bw===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return _w=a+Math.round((n-a)*bw),vw=o+Math.round((r-o)*bw),yw=s+Math.round((i-s)*bw),{css:Sw.toCss(_w,vw,yw),rgba:Sw.toRgba(_w,vw,yw)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Ew.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Sw.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[_w,vw,yw]=Ew.toChannels(t),{css:Sw.toCss(_w,vw,yw),rgba:t}}e.opaque=i;function a(e,t){return bw=Math.round(t*255),[_w,vw,yw]=Ew.toChannels(e.rgba),{css:Sw.toCss(_w,vw,yw,bw),rgba:Sw.toRgba(_w,vw,yw,bw)}}e.opacity=a;function o(e,t){return bw=e.rgba&255,a(e,bw*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Cw||={});var ww;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return _w=parseInt(e.slice(1,2).repeat(2),16),vw=parseInt(e.slice(2,3).repeat(2),16),yw=parseInt(e.slice(3,4).repeat(2),16),Sw.toColor(_w,vw,yw);case 5:return _w=parseInt(e.slice(1,2).repeat(2),16),vw=parseInt(e.slice(2,3).repeat(2),16),yw=parseInt(e.slice(3,4).repeat(2),16),bw=parseInt(e.slice(4,5).repeat(2),16),Sw.toColor(_w,vw,yw,bw);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return _w=parseInt(r[1]),vw=parseInt(r[2]),yw=parseInt(r[3]),bw=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Sw.toColor(_w,vw,yw,bw);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[_w,vw,yw,bw]=t.getImageData(0,0,1,1).data,bw!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Sw.toRgba(_w,vw,yw,bw),css:e}}e.toColor=r})(ww||={});var Tw;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Tw||={});var Ew;(e=>{function t(e,t){if(bw=(t&255)/255,bw===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return _w=a+Math.round((n-a)*bw),vw=o+Math.round((r-o)*bw),yw=s+Math.round((i-s)*bw),Sw.toRgba(_w,vw,yw)}e.blend=t;function n(e,t,n){let a=Tw.relativeLuminance(e>>8),o=Tw.relativeLuminance(t>>8);if(Ow(a,o)<n){if(o<a){let o=r(e,t,n),s=Ow(a,Tw.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Ow(a,Tw.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Ow(a,Tw.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Ow(a,Tw.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ow(Tw.relativeLuminance2(o,s,c),Tw.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Ow(Tw.relativeLuminance2(o,s,c),Tw.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ow(Tw.relativeLuminance2(o,s,c),Tw.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=Ow(Tw.relativeLuminance2(o,s,c),Tw.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Ew||={});function Dw(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Ow(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var kw=class extends Ab{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Aw=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Mb}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||kb.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)Aw._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||kb.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Aw=fb([X(0,zb)],Aw);function jw(e){return 57508<=e&&e<=57558}function Mw(e){return 9472<=e&&e<=9631}function Nw(e){return jw(e)||Mw(e)}function Pw(){return{css:{canvas:Fw(),cell:Fw()},device:{canvas:Fw(),cell:Fw(),char:{width:0,height:0,left:0,top:0}}}}function Fw(){return{width:0,height:0}}var Iw=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new Mb,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new kw(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,ee=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{ee=!0});let L=N.getChars()||kb;if(L===` `&&(N.isUnderline()||N.isOverline())&&(L=`\xA0`),T=m*s-c.get(L,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!ee&&j){N.isInvisible()?_+=kb:_+=L,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?kb:N.getChars()||kb,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Ab.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let R=N.getFgColor(),te=N.getFgColorMode(),ne=N.getBgColor(),re=N.getBgColorMode(),ie=!!N.isInverse();if(ie){let e=R;R=ne,ne=e;let t=te;te=re,re=t}let ae,z,B=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&B||(e.backgroundColorRGB&&(re=50331648,ne=e.backgroundColorRGB.rgba>>8&16777215,ae=e.backgroundColorRGB),e.foregroundColorRGB&&(te=50331648,R=e.foregroundColorRGB.rgba>>8&16777215,z=e.foregroundColorRGB),B=e.options.layer===`top`)}),!B&&P&&(ae=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ne=ae.rgba>>8&16777215,re=50331648,B=!0,p.selectionForeground&&(te=50331648,R=p.selectionForeground.rgba>>8&16777215,z=p.selectionForeground)),B&&D.push(`xterm-decoration-top`);let oe;switch(re){case 16777216:case 33554432:oe=p.ansi[ne],D.push(`xterm-bg-${ne}`);break;case 50331648:oe=Sw.toColor(ne>>16,ne>>8&255,ne&255),this._addStyle(h,`background-color:#${Lw((ne>>>0).toString(16),`0`,6)}`);break;default:ie?(oe=p.foreground,D.push(`xterm-bg-257`)):oe=p.background}switch(ae||N.isDim()&&(ae=Cw.multiplyOpacity(oe,.5)),te){case 16777216:case 33554432:N.isBold()&&R<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(R+=8),this._applyMinimumContrast(h,oe,p.ansi[R],N,ae,void 0)||D.push(`xterm-fg-${R}`);break;case 50331648:let e=Sw.toColor(R>>16&255,R>>8&255,R&255);this._applyMinimumContrast(h,oe,e,N,ae,z)||this._addStyle(h,`color:#${Lw(R.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,oe,p.foreground,N,ae,z)||ie&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!ee&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Nw(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=Cw.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Iw=fb([X(1,nx),X(2,Gb),X(3,Qb),X(4,Vb),X(5,Jb),X(6,rx)],Iw);function Lw(e,t,n){for(;e.length<n;)e=t+e;return e}var Rw=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.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`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.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(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},zw=class{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(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Bw(){return new zw}var Vw=`xterm-dom-renderer-owner-`,Hw=`xterm-rows`,Uw=`xterm-fg-`,Ww=`xterm-bg-`,Gw=`xterm-focus`,Kw=`xterm-selection`,qw=1,Jw=class extends Ox{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=qw++,this._rowElements=[],this._selectionRenderModel=Bw(),this.onRequestRedraw=this._register(new Z).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Hw),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(Kw),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Pw(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Iw,document),this._element.classList.add(Vw+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(Tx(()=>{this._element.classList.remove(Vw+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Rw(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(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),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/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),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(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Hw} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Hw} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Hw} .xterm-dim { color: ${Cw.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Hw}.${Gw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Hw}.${Gw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Hw}.${Gw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Hw} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Hw} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Hw} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Hw} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Hw} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Kw} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Kw} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Kw} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Uw}${n} { color: ${r.css}; }${this._terminalSelector} .${Uw}${n}.xterm-dim { color: ${Cw.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ww}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Uw}257 { color: ${Cw.opaque(e.background).css}; }${this._terminalSelector} .${Uw}257.xterm-dim { color: ${Cw.multiplyOpacity(Cw.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ww}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),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(Gw),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Gw),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}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(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Vw}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};Jw=fb([X(7,Ub),X(8,Zb),X(9,Gb),X(10,zb),X(11,Vb),X(12,Qb),X(13,rx)],Jw);var Yw=class extends Ox{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Z),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Qw(this._optionsService))}catch{this._measureStrategy=this._register(new Zw(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Yw=fb([X(2,Gb)],Yw);var Xw=class extends Ox{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Zw=class extends Xw{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,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}},Qw=class extends Xw{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},$w=class extends Ox{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new eT(this._window)),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Z),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Ix.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Q(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(Q(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,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}},eT=class extends Ox{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new kx),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Tx(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Q(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)}},tT=class extends Ox{constructor(){super(),this.linkProviders=[],this._register(Tx(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function nT(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function rT(e,t,n,r,i,a,o,s,c){if(!a)return;let l=nT(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var iT=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return rT(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=nT(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};iT=fb([X(0,ex),X(1,Zb)],iT);var aT=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!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){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oT={};db(oT,{getSafariVersion:()=>pT,isChromeOS:()=>yT,isFirefox:()=>uT,isIpad:()=>hT,isIphone:()=>gT,isLegacyEdge:()=>dT,isLinux:()=>vT,isMac:()=>mT,isNode:()=>sT,isSafari:()=>fT,isWindows:()=>_T});var sT=typeof process<`u`&&`title`in process,cT=sT?`node`:navigator.userAgent,lT=sT?`node`:navigator.platform,uT=cT.includes(`Firefox`),dT=cT.includes(`Edge`),fT=/^((?!chrome|android).)*safari/i.test(cT);function pT(){if(!fT)return 0;let e=cT.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var mT=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(lT),hT=lT===`iPad`,gT=lT===`iPhone`,_T=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(lT),vT=lT.indexOf(`Linux`)>=0,yT=/\bCrOS\b/.test(cT),bT=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},xT=class extends bT{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},ST=class extends bT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},CT=!sT&&`requestIdleCallback`in window?ST:xT,wT=class{constructor(){this._queue=new CT}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},TT=class extends Ox{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new kx),this._pausedResizeTask=new wT,this._observerDisposable=this._register(new kx),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 Z),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Z),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Z),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new aT((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ET(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Tx(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Tx(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.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(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,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(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_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(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};TT=fb([X(2,Gb),X(3,Zb),X(4,Vb),X(5,Jb),X(6,zb),X(7,Qb),X(8,rx)],TT);var ET=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function DT(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return AT(i,a,e,t,n,r)+jT(a,t,n,r)+MT(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,zT(Math.abs(i-e),RT(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return zT(kT(a>t?e:i,n)+(s-1)*n.cols+1+OT(a>t?i:e,n),RT(o,r))}function OT(e,t){return e-1}function kT(e,t){return t.cols-e}function AT(e,t,n,r,i,a){return jT(t,r,i,a).length===0?``:zT(LT(e,t,e,t-PT(t,i),!1,i).length,RT(`D`,a))}function jT(e,t,n,r){let i=e-PT(e,n),a=t-PT(t,n);return zT(Math.abs(i-a)-NT(e,t,n),RT(IT(e,t),r))}function MT(e,t,n,r,i,a){let o;o=jT(t,r,i,a).length>0?r-PT(r,i):t;let s=r,c=FT(e,t,n,r,i,a);return zT(LT(e,o,n,s,c===`C`,i).length,RT(c,a))}function NT(e,t,n){let r=0,i=e-PT(e,n),a=t-PT(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=IT(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function PT(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function FT(e,t,n,r,i,a){let o;return o=jT(n,r,i,a).length>0?r-PT(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function IT(e,t){return e>t?`A`:`B`}function LT(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function RT(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function zT(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var BT=class{constructor(e){this._bufferService=e,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.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()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function VT(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var HT=50,UT=15,WT=50,GT=500,KT=RegExp(`\xA0`,`g`),qT=class extends Ox{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Mb,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Z),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Z),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new BT(this._bufferService),this._activeSelectionMode=0,this._register(Tx(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}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(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(KT,` `)).join(_T?`\r
14
+ `:`
15
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),vT&&e&&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(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=VT(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=nT(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-HT),HT),t/=HT,t/Math.abs(t)+Math.round(t*(UT-1)))}shouldForceSelection(e){return mT?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),WT)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(mT&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[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});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<GT&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=DT(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=VT(n,this._bufferService.cols)}};qT=fb([X(3,zb),X(4,Vb),X(5,$b),X(6,Gb),X(7,ex),X(8,Qb)],qT);var JT=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},YT=class{constructor(){this._color=new JT,this._css=new JT}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},XT=Object.freeze((()=>{let e=[ww.toColor(`#2e3436`),ww.toColor(`#cc0000`),ww.toColor(`#4e9a06`),ww.toColor(`#c4a000`),ww.toColor(`#3465a4`),ww.toColor(`#75507b`),ww.toColor(`#06989a`),ww.toColor(`#d3d7cf`),ww.toColor(`#555753`),ww.toColor(`#ef2929`),ww.toColor(`#8ae234`),ww.toColor(`#fce94f`),ww.toColor(`#729fcf`),ww.toColor(`#ad7fa8`),ww.toColor(`#34e2e2`),ww.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Sw.toCss(r,i,a),rgba:Sw.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Sw.toCss(n,n,n),rgba:Sw.toRgba(n,n,n)})}return e})()),ZT=ww.toColor(`#ffffff`),QT=ww.toColor(`#000000`),$T=ww.toColor(`#ffffff`),eE=QT,tE={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},nE=ZT,rE=class extends Ox{constructor(e){super(),this._optionsService=e,this._contrastCache=new YT,this._halfContrastCache=new YT,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ZT,background:QT,cursor:$T,cursorAccent:eE,selectionForeground:void 0,selectionBackgroundTransparent:tE,selectionBackgroundOpaque:Cw.blend(QT,tE),selectionInactiveBackgroundTransparent:tE,selectionInactiveBackgroundOpaque:Cw.blend(QT,tE),scrollbarSliderBackground:Cw.opacity(ZT,.2),scrollbarSliderHoverBackground:Cw.opacity(ZT,.4),scrollbarSliderActiveBackground:Cw.opacity(ZT,.5),overviewRulerBorder:ZT,ansi:XT.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)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=iE(e.foreground,ZT),t.background=iE(e.background,QT),t.cursor=Cw.blend(t.background,iE(e.cursor,$T)),t.cursorAccent=Cw.blend(t.background,iE(e.cursorAccent,eE)),t.selectionBackgroundTransparent=iE(e.selectionBackground,tE),t.selectionBackgroundOpaque=Cw.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=iE(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Cw.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?iE(e.selectionForeground,xw):void 0,t.selectionForeground===xw&&(t.selectionForeground=void 0),Cw.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Cw.opacity(t.selectionBackgroundTransparent,.3)),Cw.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Cw.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=iE(e.scrollbarSliderBackground,Cw.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=iE(e.scrollbarSliderHoverBackground,Cw.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=iE(e.scrollbarSliderActiveBackground,Cw.opacity(t.foreground,.5)),t.overviewRulerBorder=iE(e.overviewRulerBorder,nE),t.ansi=XT.slice(),t.ansi[0]=iE(e.black,XT[0]),t.ansi[1]=iE(e.red,XT[1]),t.ansi[2]=iE(e.green,XT[2]),t.ansi[3]=iE(e.yellow,XT[3]),t.ansi[4]=iE(e.blue,XT[4]),t.ansi[5]=iE(e.magenta,XT[5]),t.ansi[6]=iE(e.cyan,XT[6]),t.ansi[7]=iE(e.white,XT[7]),t.ansi[8]=iE(e.brightBlack,XT[8]),t.ansi[9]=iE(e.brightRed,XT[9]),t.ansi[10]=iE(e.brightGreen,XT[10]),t.ansi[11]=iE(e.brightYellow,XT[11]),t.ansi[12]=iE(e.brightBlue,XT[12]),t.ansi[13]=iE(e.brightMagenta,XT[13]),t.ansi[14]=iE(e.brightCyan,XT[14]),t.ansi[15]=iE(e.brightWhite,XT[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=iE(e.extendedAnsi[r],XT[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0)for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];else switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};rE=fb([X(0,Gb)],rE);function iE(e,t){if(e!==void 0)try{return ww.toColor(e)}catch{}return t}var aE=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},oE=class{constructor(){this._services=new aE,this._services.set(Ub,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Ib(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},sE={trace:0,debug:1,info:2,warn:3,error:4,off:5},cE=`xterm.js: `,lE=class extends Ox{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),uE=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=sE[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:cE)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};lE=fb([X(0,Gb)],lE);var uE,dE=class extends Ox{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},fE=3,pE=Object.freeze(new Ab),mE=0,hE=2,gE=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*fE);let r=t||Mb.fromCharData([0,Ob,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*fE+0],n=t&2097151;return[this._data[e*fE+1],t&2097152?this._combined[e]:n?wb(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*fE+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*fE+0]=e|2097152|t[2]<<22):this._data[e*fE+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*fE+0]>>22}hasWidth(e){return this._data[e*fE+0]&12582912}getFg(e){return this._data[e*fE+1]}getBg(e){return this._data[e*fE+2]}hasContent(e){return this._data[e*fE+0]&4194303}getCodePoint(e){let t=this._data[e*fE+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*fE+0]&2097152}getString(e){let t=this._data[e*fE+0];return t&2097152?this._combined[e]:t&2097151?wb(t&2097151):``}isProtected(e){return this._data[e*fE+2]&536870912}loadCell(e,t){return mE=e*fE,t.content=this._data[mE+0],t.fg=this._data[mE+1],t.bg=this._data[mE+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*fE+0]=t.content,this._data[e*fE+1]=t.fg,this._data[e*fE+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*fE+0]=t|n<<22,this._data[e*fE+1]=r.fg,this._data[e*fE+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*fE+0];r&2097152?this._combined[e]+=wb(t):r&2097151?(this._combined[e]=wb(r&2097151)+wb(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*fE+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new Mb;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new Mb;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*hE<this._data.buffer.byteLength;let n=e*fE;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*hE<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*hE<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*fE+0]&4194303)return e+(this._data[e*fE+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*fE+0]&4194303||this._data[e*fE+2]&50331648)return e+(this._data[e*fE+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<fE;e++)this._data[(n+i)*fE+e]=a[(t+i)*fE+e];a[(t+i)*fE+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<fE;e++)this._data[(n+i)*fE+e]=a[(t+i)*fE+e];a[(t+i)*fE+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*fE+0],n=e&2097151,a=e&2097152?this._combined[t]:n?wb(n):kb;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function _E(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=xE(u,d,t),p=1,m=0;for(;p<u.length;){let e=xE(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function vE(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function yE(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function bE(e,t,n){let r=[],i=e.map((n,r)=>xE(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=xE(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function xE(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var SE=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Cx(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};SE._nextId=1;var CE=SE,wE={},TE=wE.B;wE[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},wE.A={"#":`£`},wE.B=void 0,wE[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},wE.C=wE[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},wE.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},wE.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},wE.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},wE.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},wE.E=wE[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},wE.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},wE.H=wE[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},wE[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var EE=4294967295,DE=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=pE.clone(),this.savedCharset=TE,this.markers=[],this._nullCell=Mb.fromCharData([0,Ob,1,0]),this._whitespaceCell=Mb.fromCharData([0,kb,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new CT,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new dE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new jb),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new jb),this._whitespaceCell}getBlankLine(e,t){return new gE(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>EE?EE:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=pE);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new dE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(pE),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new gE(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new gE(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=_E(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(pE),n);if(r.length>0){let n=vE(this.lines,r);yE(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(pE),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new gE(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(pE),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=bE(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(pE,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=xE(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new CE(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},OE=class extends Ox{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Z),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 DE(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new DE(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},kE=2,AE=1,jE=class extends Ox{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,kE),this.rows=Math.max(e.rawOptions.rows||0,AE),this.buffers=this._register(new OE(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};jE=fb([X(0,Gb)],jE);var ME={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:mT,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},NE=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],PE=class extends Ox{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...ME};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Tx(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in ME))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in ME))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=ME[e],!FE(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=ME[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=NE.includes(t)?t:ME[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function FE(e){return e===`block`||e===`underline`||e===`bar`}function IE(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&IE(e[r],t-1);return n}var LE=Object.freeze({insertMode:!1}),RE=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),zE=class extends Ox{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=IE(LE),this.decPrivateModes=IE(RE)}reset(){this.modes=IE(LE),this.decPrivateModes=IE(RE)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};zE=fb([X(0,zb),X(1,Wb),X(2,Gb)],zE);var BE={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function VE(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var HE=String.fromCharCode,UE={DEFAULT:e=>{let t=[VE(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${HE(t[0])}${HE(t[1])}${HE(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${VE(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${VE(e,!0)};${e.x};${e.y}${t}`}},WE=class extends Ox{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Z),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(BE))this.addProtocol(e,BE[e]);for(let e of Object.keys(UE))this.addEncoding(e,UE[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};WE=fb([X(0,zb),X(1,Vb),X(2,Gb)],WE);var GE=[[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]],KE=[[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]],qE;function JE(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var YE=class{constructor(){if(this.version=`6`,!qE){qE=new Uint8Array(65536),qE.fill(1),qE[0]=0,qE.fill(0,1,32),qE.fill(0,127,160),qE.fill(2,4352,4448),qE[9001]=2,qE[9002]=2,qE.fill(2,11904,42192),qE[12351]=1,qE.fill(2,44032,55204),qE.fill(2,63744,64256),qE.fill(2,65040,65050),qE.fill(2,65072,65136),qE.fill(2,65280,65377),qE.fill(2,65504,65511);for(let e=0;e<GE.length;++e)qE.fill(0,GE[e][0],GE[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?qE[e]:JE(e,KE)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=XE.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return XE.createPropertyValue(0,n,r)}},XE=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new YE;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},ZE=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function QE(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var $E=2147483647,eD=256,tD=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>eD)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>$E?$E:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>$E?$E:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,$E):e}},nD=[],rD=class{constructor(){this._state=0,this._active=nD,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=nD}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=nD,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||nD,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Tb(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=nD,this._id=-1,this._state=0}}},iD=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Tb(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},aD=[],oD=class{constructor(){this._handlers=Object.create(null),this._active=aD,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=aD}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=aD,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||aD,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Tb(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=aD,this._ident=0}},sD=new tD;sD.addParam(0);var cD=class{constructor(e){this._handler=e,this._data=``,this._params=sD,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():sD,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Tb(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=sD,this._data=``,this._hitLimit=!1,e));return this._params=sD,this._data=``,this._hitLimit=!1,t}},lD=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},uD=160,dD=function(){let e=new lD(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(uD,0,2,0),e.add(uD,8,5,8),e.add(uD,6,0,6),e.add(uD,11,0,11),e.add(uD,13,13,13),e}(),fD=class extends Ox{constructor(e=dD){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new tD,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Tx(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new rD),this._dcsParser=this._register(new oD),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:uD)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<uD||++i>=t||(r=e[i])<32||r>126&&r<uD||++i>=t||(r=e[i])<32||r>126&&r<uD||++i>=t||(r=e[i])<32||r>126&&r<uD){this._printHandler(e,n,i),n=i-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<uD){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=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 i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<uD){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},pD=/^([\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})$/,mD=/^[\da-f]+$/;function hD(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=pD.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),mD.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function gD(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function _D(e,t=16){let[n,r,i]=e;return`rgb:${gD(n,t)}/${gD(r,t)}/${gD(i,t)}`}var vD={"(":0,")":1,"*":2,"+":3,"-":1,".":2},yD=131072,bD=10;function xD(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var SD=5e3,CD=0,wD=class extends Ox{constructor(e,t,n,r,i,a,o,s,c=new fD){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Eb,this._utf8Decoder=new Db,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=pE.clone(),this._eraseAttrDataInternal=pE.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),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 TD(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(mw.IND,()=>this.index()),this._parser.setExecuteHandler(mw.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(mw.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new iD(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new iD(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new iD(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new iD(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new iD(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new iD(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new iD(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new iD(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new iD(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new iD(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new iD(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new iD(e=>this.restoreCursorColor(e))),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(let e in wE)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new cD((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),SD))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${SD} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>yD&&(a=this._parseStack.position+yD)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<yD&&(this._parseBuffer=new Uint32Array(Math.min(e.length,yD))),o||this._dirtyRowTracker.clearRange(),e.length>yD)for(let t=a;t<e.length;t+=yD){let a=t+yD<e.length?t+yD:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=XE.extractWidth(t);let n=XE.extractShouldJoin(t),m=n?XE.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(wb(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof gE&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!xD(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new cD(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new iD(t))}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;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(pE));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=XE.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,TE),this._charsetService.setgCharset(1,TE),this._charsetService.setgCharset(2,TE),this._charsetService.setgCharset(3,TE);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(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Ab.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=pE.fg,e.bg=pE.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=pE.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=pE.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=pE.fg&16777215,r.bg&=-67108864,r.bg|=pE.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=pE.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!xD(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>bD&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>bD&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(ED(n)){if(r===`?`)t.push({type:0,index:n});else{let e=hD(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=hD(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);ED(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,TE),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(vD[e[0]],wE[e[1]]||TE),!0):(this.selectDefaultCharset(),!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){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=pE.clone(),this._eraseAttrDataInternal=pE.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Mb;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},TD=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(CD=e,e=t,t=CD),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};TD=fb([X(0,zb)],TD);function ED(e){return 0<=e&&e<256}var DD=5e7,OD=12,kD=50,AD=class extends Ox{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>DD)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=OD?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=OD)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>kD&&(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()}},jD=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};jD=fb([X(0,zb)],jD);var MD=!1,ND=class extends Ox{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new kx),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new oE,this.optionsService=this._register(new PE(e)),this._instantiationService.setService(Gb,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jE)),this._instantiationService.setService(zb,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(lE)),this._instantiationService.setService(Wb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(zE)),this._instantiationService.setService(Vb,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(WE)),this._instantiationService.setService(Bb,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(XE)),this._instantiationService.setService(qb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ZE),this._instantiationService.setService(Hb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(jD),this._instantiationService.setService(Kb,this._oscLinkService),this._inputHandler=this._register(new wD(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ix.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ix.forward(this._bufferService.onResize,this._onResize)),this._register(Ix.forward(this.coreService.onData,this._onData)),this._register(Ix.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new AD((e,t)=>this._inputHandler.parse(e,t))),this._register(Ix.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!MD&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),MD=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,kE),t=Math.max(t,AE),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(QE.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(QE(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Tx(()=>{for(let t of e)t.dispose()})}}},PD={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:[`'`,`"`]};function FD(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=PD[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var ID=0,LD=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new CT,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new CT,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ID=this._search(t),ID===-1)||this._getKey(this._array[ID])!==t)return!1;do if(this._array[ID]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ID),!0;while(++ID<this._array.length&&this._getKey(this._array[ID])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ID=this._search(e),!(ID<0||ID>=this._array.length)&&this._getKey(this._array[ID])===e))do yield this._array[ID];while(++ID<this._array.length&&this._getKey(this._array[ID])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ID=this._search(e),!(ID<0||ID>=this._array.length)&&this._getKey(this._array[ID])===e))do t(this._array[ID]);while(++ID<this._array.length&&this._getKey(this._array[ID])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},RD=0,zD=0,BD=class extends Ox{constructor(){super(),this._decorations=new LD(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Tx(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new VD(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{RD=t.options.x??0,zD=RD+(t.options.width??1),e>=RD&&e<zD&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},VD=class extends Dx{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?ww.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?ww.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},HD=1e3,UD=class{constructor(e,t=HD){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},WD=20,GD=class extends Ox{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new UD(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
16
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Q(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Tx(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<WD+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
17
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===WD+1&&(this._liveRegion.textContent+=gb.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};GD=fb([X(1,Ub),X(2,Qb),X(3,ex)],GD);var KD=class extends Ox{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Tx(()=>{Cx(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Q(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Q(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Q(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Q(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&qD(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Cx(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};KD=fb([X(1,$b),X(2,ex),X(3,zb),X(4,ix)],KD);function qD(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var JD=class extends ND{constructor(e={}){super(e),this._linkifier=this._register(new kx),this.browser=oT,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new kx),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(BD),this._instantiationService.setService(Jb,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(tT),this._instantiationService.setService(ix,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Yb)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Ix.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ix.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ix.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ix.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Tx(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=Cw.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${_D(r)}${hw.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Sw.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Sw.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(GD,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Q(this.element,`copy`,e=>{this.hasSelection()&&yb(e,this._selectionService)}));let e=e=>bb(e,this.textarea,this.coreService,this.optionsService);this._register(Q(this.textarea,`paste`,e)),this._register(Q(this.element,`paste`,e)),uT?this._register(Q(this.element,`mousedown`,e=>{e.button===2&&Cb(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Q(this.element,`contextmenu`,e=>{Cb(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),vT&&this._register(Q(this.element,`auxclick`,e=>{e.button===1&&Sb(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Q(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Q(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Q(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Q(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Q(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Q(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Q(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.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`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Q(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,mb.get()),yT||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._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance($w,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Qb,this._coreBrowserService),this._register(Q(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Q(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Yw,this._document,this._helperContainer),this._instantiationService.setService(Zb,this._charSizeService),this._themeService=this._instantiationService.createInstance(rE),this._instantiationService.setService(rx,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Aw),this._instantiationService.setService(nx,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(TT,this.rows,this.screenElement)),this._instantiationService.setService(ex,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(gw,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(iT),this._instantiationService.setService($b,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(KD,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(sw,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(qT,this.element,this.screenElement,r)),this._instantiationService.setService(tx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Ix.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(cw,this.screenElement)),this._register(Q(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),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(GD,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pw,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(pw,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Jw,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),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()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Q(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Q(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?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(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){xb(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}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(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=FD(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(YD(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(pE));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function YD(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var XD=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ZD=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Mb)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},QD=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new ZD(t)}getNullCell(){return new Mb}},$D=class extends Ox{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new QD(this._core.buffers.normal,`normal`),this._alternate=new QD(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 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)}},eO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},tO=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},nO=[`cols`,`rows`],rO=0,iO=class extends Ox{constructor(e){super(),this._core=this._register(new JD(e)),this._addonManager=this._register(new XD),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(nO.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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||=new eO(this._core),this._parser}get unicode(){return this._checkProposedApi(),new tO(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._register(new $D(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
18
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return mb.get()},set promptLabel(e){mb.set(e)},get tooMuchOutput(){return gb.get()},set tooMuchOutput(e){gb.set(e)}}}_verifyIntegers(...e){for(rO of e)if(rO===1/0||isNaN(rO)||rO%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(rO of e)if(rO&&(rO===1/0||isNaN(rO)||rO%1!=0||rO<0))throw Error(`This API only accepts positive integers`)}},aO=Qn(`TerminalPane`,()=>e=>({metadata:null,error:null,setMetadata:t=>e({metadata:t}),setMetadataConditional:t=>e(e=>{let n=e.metadata;return n!==null&&n.cwd===t.cwd&&n.shell===t.shell&&n.status===t.status&&n.exitCode===t.exitCode?{}:{metadata:t}}),setMetadataFromExit:t=>e(e=>({metadata:{cwd:e.metadata?.cwd??``,shell:e.metadata?.shell??``,status:`exited`,exitCode:t}})),setError:t=>e({error:t}),resetTerminal:()=>e({metadata:null,error:null})})),oO={paddingInline:12};function sO(e){return e+24}function cO(e,t){return Math.max(1,e)*sO(t)}var lO={black:`#0f172a`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#94a3b8`,brightBlack:`#475569`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#e2e8f0`},uO={black:`#0f172a`,red:`#f87171`,green:`#4ade80`,yellow:`#facc15`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#cbd5e1`,brightBlack:`#64748b`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#f8fafc`};function dO(e,t){let n=e===`dark`?uO:lO,r=t.getCssVar(`--foreground`,e===`dark`?`#f8fafc`:`#0f172a`);return{foreground:r,background:`transparent`,cursor:r,cursorAccent:t.getCssVar(`--background`,e===`dark`?`#000000`:`#ffffff`),selectionBackground:e===`dark`?`rgba(248,250,252,0.28)`:`rgba(221,228,236,0.55)`,selectionInactiveBackground:e===`dark`?`rgba(248,250,252,0.18)`:`rgba(221,228,236,0.38)`,...n}}function fO(e){return{cols:Math.max(1,e.cols||80),rows:Math.max(1,e.rows||24)}}function pO(e,t,n){let r=e.element;function i(e){return`_core`in e}let a=i(e)?e._core?._renderService?.dimensions?.css?.cell:void 0,o=a?.width??0,s=a?.height??0;if(!r||!Number.isFinite(o)||!Number.isFinite(s)||o<=0||s<=0)return null;let c=t.getBoundingClientRect(),l=n.getComputedStyle(t),u=n.getComputedStyle(r),d=e.options.scrollback===0?0:e.options.overviewRuler?.width??14,f=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight)+parseFloat(u.paddingLeft)+parseFloat(u.paddingRight),p=parseFloat(l.paddingTop)+parseFloat(l.paddingBottom)+parseFloat(u.paddingTop)+parseFloat(u.paddingBottom),m=Math.max(0,c.width-f-d-1),h=Math.max(0,c.height-p);return{cols:Math.max(2,Math.floor(m/o)),rows:Math.max(1,Math.floor(h/s))}}function mO(e){e.refresh(0,Math.max(0,e.rows-1))}function hO(e){return/mac/i.test(e)}var gO=13;function _O(e){return Math.round(gO*vr(e))}function vO(e,t,n,r=globalThis.navigator?.platform??``){return{scrollback:e,cursorBlink:!0,cursorStyle:`bar`,cursorWidth:1,lineHeight:1,convertEol:!1,allowTransparency:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,fontSize:n,theme:t,macOptionIsMeta:hO(r)}}function yO(e,t=globalThis.navigator?.platform??``){if(e.ctrlKey)return null;if(!e.altKey&&!e.metaKey)switch(e.key){case`ArrowUp`:return`\x1B[A`;case`ArrowDown`:return`\x1B[B`;case`ArrowLeft`:return`\x1B[D`;case`ArrowRight`:return`\x1B[C`;default:return null}if(!hO(t))return null;if(e.metaKey&&!e.altKey)switch(e.key){case`Backspace`:return``;case`Delete`:return`\v`;default:return null}if(!(e.altKey||e.getModifierState?.(`AltGraph`)===!0))return null;switch(e.key){case`ArrowLeft`:return`\x1Bb`;case`ArrowRight`:return`\x1Bf`;case`Backspace`:return`\x1B`;case`Delete`:return`\x1Bd`;default:return null}}function bO(e,t){return e!==null&&e.cols===t.cols&&e.rows===t.rows}function xO(e,t,n,r,i,a){let o=pO(e,t,a)??fO(e);return bO(n.current,o)||(e.resize(o.cols,o.rows),n.current=o,r&&i(o.cols,o.rows)),o}function SO({projectId:e,terminalId:t,socket:n,scrollback:r,connectionStatus:i,clearVersion:a=0,focusRequestVersion:o=0,onPathChange:s,onCommandSent:c,ports:l={}}){let u=l.dom??pi,d=l.timer??Ln,{resolvedTheme:f}=wr(),m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(c),v=(0,G.useRef)(gO),y=(0,G.useRef)(!1),b=(0,G.useRef)(0),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=aO.useScopedStore(e=>e.metadata),w=aO.useScopedStore(e=>e.error),T=aO.useScopedStore(e=>e.setError),E=aO.useScopedStore(e=>e.setMetadataConditional),D=aO.useScopedStore(e=>e.setMetadataFromExit),O=aO.useScopedStore(e=>e.resetTerminal),k=f===`dark`?`dark`:`light`,A=(0,G.useMemo)(()=>dO(k,u),[k,u]),j=(0,G.useRef)(A),M=br(e=>e.settings?.typography?.scale),N=p(e=>e.typographyOverride),P=_O(ur(N,M)),F=(0,G.useCallback)(e=>{n.command({type:`terminal.input`,terminalId:t,data:e}).catch(e=>{T(rr(e))}),(e.includes(`\r`)||e.includes(`
19
+ `))&&_.current?.()},[n,t,T]),I=(0,G.useCallback)((e,r)=>{ri(`terminal.resize`,n.command({type:`terminal.resize`,terminalId:t,cols:e,rows:r}))},[n,t]),ee=(0,G.useCallback)(()=>{let e=()=>{let e=h.current,t=m.current;e&&t&&y.current&&xO(e,t,S,!0,I,u)};d.requestAnimationFrame(()=>{e(),d.setTimeout(e,0)})},[u,I,d]);return(0,G.useEffect)(()=>{_.current=c},[c]),(0,G.useEffect)(()=>{v.current=P},[P]),(0,G.useEffect)(()=>{j.current=A},[A]),(0,G.useEffect)(()=>{let e=new iO(vO(r,j.current,v.current)),t=new tb;e.loadAddon(t),e.loadAddon(new cb),e.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;let t=yO(e);return!t||(e.preventDefault(),F(t),!1)}),h.current=e;let n=m.current;n&&(e.open(n),g.current&&e.write(g.current),xO(e,n,S,!1,()=>{},u),mO(e),ee());let i=e.onData(e=>{F(e)}),a=e.onResize(({cols:e,rows:t})=>{if(!y.current)return;let n={cols:e,rows:t};bO(S.current,n)||(S.current=n,I(e,t))}),o=new ResizeObserver(()=>{let e=h.current,t=m.current;e&&t&&xO(e,t,S,y.current,I,u)});return n&&o.observe(n),()=>{o.disconnect(),a.dispose(),i.dispose(),g.current=t.serialize(),e.dispose(),h.current=null}},[u,ee,r,F,I]),(0,G.useEffect)(()=>{let e=h.current;e&&(e.options.scrollback=r)},[r]),(0,G.useEffect)(()=>{let e=h.current;e&&(e.options.theme=A,mO(e))},[A]),(0,G.useEffect)(()=>{let e=h.current,t=m.current;e&&t&&(e.options.fontSize=P,mO(e),xO(e,t,S,y.current,I,u))},[P,u,I]),(0,G.useEffect)(()=>{if(o===0)return;let e=h.current;e&&d.requestAnimationFrame(()=>{e.focus()})},[o,d]),(0,G.useEffect)(()=>{if(a===0)return;let e=h.current;e&&(y.current=!1,b.current+=1,x.current=null,g.current=null,O(),e.reset(),mO(e),n.command({type:`terminal.close`,terminalId:t}).catch(e=>{T(rr(e))}))},[a,n,t,O,T]),(0,G.useEffect)(()=>{s?.(C?.cwd??null)},[C?.cwd,s]),(0,G.useEffect)(()=>{let a=e=>{let t=h.current;if(!t)return!1;let n={cwd:e.cwd,shell:e.shell,status:e.status,exitCode:e.exitCode},r=JSON.stringify({cwd:e.cwd,shell:e.shell,cols:e.cols,rows:e.rows,scrollback:e.scrollback,status:e.status,exitCode:e.exitCode,serializedState:e.serializedState});return x.current===r?(E(n),g.current=e.serializedState||null,!1):(x.current=r,E(n),g.current=e.serializedState||null,t.options.scrollback=e.scrollback,t.reset(),e.serializedState&&t.write(e.serializedState),mO(t),!0)},o=()=>{let i=h.current,o=m.current;if(!i||!o)return;let s=pO(i,o,u)??fO(i);i.resize(s.cols,s.rows),S.current=s,n.command({type:`terminal.create`,projectId:e,terminalId:t,cols:s.cols,rows:s.rows,scrollback:r}).then(e=>{y.current=!0,T(null),a(e),ee()}).catch(e=>{T(rr(e))})},s=()=>{let e=++b.current,t=()=>{if(b.current!==e)return;let n=h.current,r=m.current;if(!n||!r)return;xO(n,r,S,!1,()=>{},u);let i=r.getBoundingClientRect();i.width<=0||i.height<=0?d.requestAnimationFrame(t):o()};d.requestAnimationFrame(()=>{d.requestAnimationFrame(t)})};return s(),n.subscribe({type:`terminal`,terminalId:t},e=>{e?(y.current=!0,T(null),a(e)&&ee()):(y.current=!1,x.current=null,i===`connected`&&s())},e=>{let t=h.current;t&&(e.type===`terminal.output`?t.write(e.data):e.type===`terminal.exit`&&D(e.exitCode))})},[i,u,e,ee,r,n,t,d,E,D,T]),(0,K.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden pb-4`,children:[(0,K.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden py-1`,style:oO,children:(0,K.jsx)(`div`,{ref:m,className:`kanna-terminal min-h-0 min-w-0 flex-1 overflow-hidden w-full`})}),w?(0,K.jsxs)(`div`,{className:`py-1 text-xs text-destructive`,style:oO,children:[`Terminal error: `,w]}):null]})}function CO(e){return(0,K.jsx)(aO.Provider,{init:void 0,children:(0,K.jsx)(SO,{...e})})}var wO=Qn(`TerminalWorkspace`,()=>e=>({viewportWidth:0,pathsByTerminalId:{},clearVersionsByTerminalId:{},setViewportWidth:t=>e({viewportWidth:t}),updatePath:(t,n)=>e(e=>e.pathsByTerminalId[t]===n?{}:{pathsByTerminalId:{...e.pathsByTerminalId,[t]:n}}),incrementClearVersion:t=>e(e=>({clearVersionsByTerminalId:{...e.clearVersionsByTerminalId,[t]:(e.clearVersionsByTerminalId[t]??0)+1}}))})),TO=(0,G.memo)(({projectId:e,terminalId:t,size:n,isLast:r,minTerminalWidth:i,path:a,socket:o,scrollback:s,connectionStatus:c,clearVersion:l,focusRequestVersion:u,splitTerminalShortcut:d,onAddTerminal:f,onRemoveTerminal:p,onClearTerminal:m,onPathChange:h,onCommandSent:g,setPaneElement:_})=>{let v=(0,G.useCallback)(e=>{_(t,e)},[_,t]),y=(0,G.useCallback)(()=>{m(t),h(t,null)},[m,h,t]),b=(0,G.useCallback)(()=>{f(e,t)},[f,e,t]),x=(0,G.useCallback)(()=>{p(e,t)},[p,e,t]),S=(0,G.useCallback)(e=>{h(t,e)},[h,t]);return(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(jy,{id:t,defaultSize:`${n}%`,minSize:`${i}px`,className:`min-h-0 overflow-hidden`,style:{minWidth:i},children:(0,K.jsxs)(`div`,{ref:v,className:`flex h-full min-h-0 min-w-0 flex-col border-r border-border bg-transparent last:border-r-0`,style:{minWidth:i},children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pr-2 pt-2 pb-1`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1 text-left`,children:(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`shrink-0 text-sm font-medium`,children:`Terminal`}),(0,K.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:a??``})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clear terminal`,onClick:y,children:(0,K.jsx)(ko,{className:`size-3.5`})}),(0,K.jsxs)(Un,{children:[(0,K.jsx)(Vn,{asChild:!0,children:(0,K.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add terminal to the right`,onClick:b,children:(0,K.jsx)(Cn,{className:`size-3.5`})})}),(0,K.jsx)(Gn,{side:`bottom`,shortcut:d})]}),(0,K.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Archive terminal`,onClick:x,children:(0,K.jsx)(Mn,{className:`size-3.5`})})]})]}),(0,K.jsx)(CO,{projectId:e,terminalId:t,socket:o,scrollback:s,connectionStatus:c,clearVersion:l,focusRequestVersion:u,onCommandSent:g,onPathChange:S})]})}),r?null:(0,K.jsx)(Fy,{withHandle:!0,orientation:`horizontal`})]})});function EO({projectId:e,layout:t,socket:n,connectionStatus:r,scrollback:i,minColumnWidth:a,focusRequestVersion:o=0,splitTerminalShortcut:s,onAddTerminal:c,onRemoveTerminal:l,onTerminalLayout:u,onTerminalCommandSent:d}){let f=(0,G.useRef)(null),p=(0,G.useRef)({}),m=(0,G.useRef)([]),h=wO.useScopedStore(e=>e.viewportWidth),g=wO.useScopedStore(e=>e.pathsByTerminalId),_=wO.useScopedStore(e=>e.clearVersionsByTerminalId),v=wO.useScopedStore(e=>e.setViewportWidth),y=wO.useScopedStore(e=>e.updatePath),b=wO.useScopedStore(e=>e.incrementClearVersion);(0,G.useLayoutEffect)(()=>{let e=f.current;if(!e)return;let t=()=>{v(e.getBoundingClientRect().width)},n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[v]);let x=t.terminals.length,S=sO(a),C=cO(x,a),w=Math.max(h,C),T=(0,G.useMemo)(()=>t.terminals.map(e=>e.id).join(`:`),[t.terminals]),E=(0,G.useCallback)((e,t)=>{p.current[e]=t},[]),D=(0,G.useCallback)((e,t)=>{y(e,t)},[y]),O=(0,G.useCallback)(e=>{b(e)},[b]),k=(0,G.useCallback)(n=>{u(e,t.terminals.map(e=>n[e.id]??e.size))},[t.terminals,u,e]);return(0,G.useLayoutEffect)(()=>{let e=m.current,n=t.terminals.map(e=>e.id),r=n.find(t=>!e.includes(t));if(m.current=n,!r||e.length===0)return;let i=p.current[r];i&&i.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},[t.terminals]),(0,K.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,K.jsx)(`div`,{ref:f,className:`min-h-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,K.jsx)(`div`,{className:`h-full min-h-0`,style:{width:w||`100%`},children:(0,K.jsx)(Ay,{orientation:`horizontal`,className:`h-full min-h-0`,onLayoutChanged:k,children:t.terminals.map((a,u)=>(0,K.jsx)(TO,{projectId:e,terminalId:a.id,size:a.size,isLast:u===t.terminals.length-1,minTerminalWidth:S,path:g[a.id]??null,socket:n,scrollback:i,connectionStatus:r,clearVersion:_[a.id]??0,focusRequestVersion:u===0?o:0,splitTerminalShortcut:s,onAddTerminal:c,onRemoveTerminal:l,onClearTerminal:O,onPathChange:D,onCommandSent:d,setPaneElement:E},a.id))},T)})})})}function DO(e){return(0,K.jsx)(wO.Provider,{init:void 0,children:(0,K.jsx)(EO,{...e})})}var OO=(0,G.memo)(DO);function kO(e){let t=e.replaceAll(`\\`,`/`).replace(/\/+/g,`/`).replace(/\/$/u,``),n=t.lastIndexOf(`/`);return n<=0?null:`${t.slice(0,n)}/`}function AO(e){return e.kind===`local`?{kind:`local`,name:e.name}:e.kind===`remote`?{kind:`remote`,name:e.name,remoteRef:e.remoteRef??e.displayName}:{kind:`pull_request`,name:e.name,prNumber:e.prNumber??0,headRefName:e.headRefName??e.name,headRepoCloneUrl:e.headRepoCloneUrl,isCrossRepository:e.isCrossRepository,remoteRef:e.remoteRef}}function jO(e){return e.startsWith(`/`)||e===`~`||e.startsWith(`~/`)||/^[A-Za-z]:[\\/]/u.test(e)}function MO(e,t){let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`;return`${e.replace(/[\\/]+$/u,``)}${n}${t.replace(/^[\\/]+/u,``)}`}function NO(e,t){return!e||jO(t)?t:MO(e,t)}function PO(e){let t=e.detail?`\n\n${e.detail}`:``;return e.localCommitCreated?`${e.message}\n\nA local commit was created, but the push did not complete.${t}`:`${e.message}${t}`}var FO=5e3,IO={status:`unknown`,files:[]};function LO({state:e,projectId:t,showRightSidebar:n,ports:r}){let i=r?.dom??pi,a=r?.timer??Ln,o=On(),s=Ig(e=>e.diffRenderMode),c=Ig(e=>e.wrapDiffLines),l=Ig(e=>e.setDiffRenderMode),u=Ig(e=>e.setWrapDiffLines),d=(0,G.useRef)(null),f=(0,G.useRef)(!1),p=(0,G.useRef)(null),m=(0,G.useRef)(e.activeChatId),h=(0,G.useRef)(e.runtime?.localPath??e.navbarLocalPath??null),{handleOpenLocalLink:g,handleCopyPath:_,handleOpenExternalPath:v}=e;(0,G.useEffect)(()=>{m.current=e.activeChatId},[e.activeChatId]),(0,G.useEffect)(()=>{h.current=e.runtime?.localPath??e.navbarLocalPath??null},[e.navbarLocalPath,e.runtime?.localPath]);let y=(0,G.useCallback)(()=>{let t=m.current;t&&ri(`project git refresh`,e.socket.command({type:`chat.refreshDiffs`,chatId:t}))},[e.socket]),b=(0,G.useCallback)(()=>{let t=m.current;t&&n&&ri(`diff refresh`,e.socket.command({type:`chat.refreshDiffs`,chatId:t}))},[n,e.socket]),x=(0,G.useCallback)(()=>{m.current&&n&&(d.current!==null&&a.clearTimeout(d.current),d.current=a.setTimeout(()=>{d.current=null,b()},1e3))},[b,n,a]),S=(0,G.useCallback)(async(e,t)=>{try{return await t()}catch(t){return await o.alert({title:e,description:rr(t),closeLabel:`OK`}),null}},[o]),C=(0,G.useCallback)((e,t,n)=>S(e,async()=>{let e=await n();return e.snapshotChanged&&t(),!e.ok&&!e.cancelled&&await o.alert({title:e.title,description:PO(e),closeLabel:`OK`}),e}),[S,o]),w=(0,G.useCallback)(e=>{let t=h.current,n=NO(t,e);return g({path:n},`open_editor`)},[g]),T=(0,G.useCallback)(e=>{let t=h.current;return _(NO(t,e))},[_]),E=(0,G.useCallback)(e=>_(e),[_]),D=(0,G.useCallback)(async n=>{if(!t)throw Error(`Project not found`);let r=m.current;return(await e.socket.command({type:`project.readDiffPatch`,projectId:t,path:n,...r?{chatId:r}:{}})).patch},[m,t,e.socket]),O=(0,G.useCallback)(async t=>{let n=m.current;n&&await o.confirm({title:`Discard Changes`,description:`Discard changes for "${t}"? This cannot be undone.`,confirmLabel:`Discard`,confirmVariant:`destructive`})&&await S(`Discard failed`,()=>e.socket.command({type:`chat.discardDiffFile`,chatId:n,path:t}))},[S,o,e.socket]),k=(0,G.useCallback)(async t=>{let n=m.current;n&&await o.confirm({title:`Ignore File`,description:`Add "${t}" to .gitignore?`,confirmLabel:`Ignore`,confirmVariant:`destructive`})&&await S(`Ignore failed`,()=>e.socket.command({type:`chat.ignoreDiffFile`,chatId:n,path:t}))},[S,o,e.socket]),A=(0,G.useCallback)(async t=>{let n=m.current;if(!n)return;let r=kO(t);if(!r)return;let i=await o.prompt({title:`Ignore Folder`,description:`Edit the folder pattern to add to .gitignore.`,initialValue:r,confirmLabel:`Ignore`});i&&await S(`Ignore failed`,()=>e.socket.command({type:`chat.ignoreDiffFile`,chatId:n,path:i}))},[S,o,e.socket]),j=(0,G.useCallback)(e=>v(`open_finder`,e),[v]),M=(0,G.useCallback)(async t=>{let n=m.current;return n?await C(`Commit failed`,b,()=>e.socket.command({type:`chat.commitDiffs`,chatId:n,paths:t.paths,summary:t.summary,description:t.description,mode:t.mode})):null},[b,C,e.socket]),N=(0,G.useCallback)(async t=>{let n=m.current;return n?await C(`Git sync failed`,b,()=>e.socket.command({type:`chat.syncBranch`,chatId:n,action:t})):null},[b,C,e.socket]),P=(0,G.useCallback)(async t=>{let n=m.current;if(!n)return{subject:``,body:``};let r=await e.socket.command({type:`chat.generateCommitMessage`,chatId:n,paths:t.paths});return{subject:r.subject,body:r.body}},[e.socket]),F=(0,G.useCallback)(async()=>{let t=m.current;return t?await C(`Initialize git failed`,y,()=>e.socket.command({type:`chat.initGit`,chatId:t})):null},[y,C,e.socket]),I=(0,G.useCallback)(async()=>{let t=m.current;return t?await e.socket.command({type:`chat.getGitHubPublishInfo`,chatId:t}):{ghInstalled:!1,authenticated:!1,owners:[],suggestedRepoName:`my-repo`}},[e.socket]),ee=(0,G.useCallback)(async t=>{let n=m.current;return n?await e.socket.command({type:`chat.checkGitHubRepoAvailability`,chatId:n,owner:t.owner,name:t.name}):{available:!1,message:`No active chat.`}},[e.socket]),L=(0,G.useCallback)(async t=>{let n=m.current;return n?await C(`Publish failed`,y,()=>e.socket.command({type:`chat.publishToGitHub`,chatId:n,owner:t.owner,name:t.name,visibility:t.visibility,description:t.description.trim()||void 0})):null},[y,C,e.socket]),R=(0,G.useCallback)(async()=>{let t=m.current;return t?await e.socket.command({type:`chat.listBranches`,chatId:t}):{recent:[],local:[],remote:[],pullRequests:[],pullRequestsStatus:`unavailable`}},[e.socket]),te=(0,G.useCallback)(async t=>{let n=m.current;if(!n)return;let r=!1;if((e.chatDiffSnapshot?.files.length??0)>0){if(!await o.confirm({title:`Bring Changes?`,description:`You have uncommitted changes. Bring them to ${t.name}?`,confirmLabel:`Bring Changes`,cancelLabel:`Stay Here`}))return;r=!0}await C(`Checkout failed`,b,()=>e.socket.command({type:`chat.checkoutBranch`,chatId:n,branch:AO(t),bringChanges:r}))},[o,b,C,e.chatDiffSnapshot?.files.length,e.socket]),ne=(0,G.useCallback)(async t=>{let n=m.current;return n?await e.socket.command({type:`chat.previewMergeBranch`,chatId:n,branch:AO(t)}):{currentBranchName:void 0,targetBranchName:t.name,targetDisplayName:t.displayName,status:`error`,commitCount:0,hasConflicts:!1,message:`Merge preview unavailable.`}},[e.socket]),re=(0,G.useCallback)(async t=>{let n=m.current;return n?await C(`Merge failed`,b,()=>e.socket.command({type:`chat.mergeBranch`,chatId:n,branch:AO(t)})):null},[b,C,e.socket]),ie=(0,G.useCallback)(async()=>{let t=m.current;if(!t)return;let n=await o.prompt({title:`New Branch`,description:`Enter a branch name.`,placeholder:`feature/my-branch`,confirmLabel:`Create`});if(!n)return;let r=await R(),i=r.currentBranchName,a=r.defaultBranchName,s=a;a&&i&&a!==i&&(s=await o.confirm({title:`Branch Base`,description:`Create "${n}" from ${i} instead of ${a}?`,confirmLabel:`From ${i}`,cancelLabel:`From ${a}`})?i:a),await C(`Create branch failed`,b,()=>e.socket.command({type:`chat.createBranch`,chatId:t,name:n,baseBranchName:s}))},[o,R,b,C,e.socket]);(0,G.useEffect)(()=>{if(!t||!n)return;let e=a.setInterval(()=>{b()},FO);return()=>a.clearInterval(e)},[t,b,n,a]),(0,G.useEffect)(()=>{t&&n&&b()},[t,b,n]),(0,G.useEffect)(()=>{t&&e.activeChatId&&p.current!==t&&(p.current=t,y())},[t,y,e.activeChatId]),(0,G.useEffect)(()=>{if(!t||!n)return;function e(){i.getVisibilityState()===`visible`&&b()}let r=i.addWindowListener(`focus`,e),a=i.addDocumentListener(`visibilitychange`,e);return()=>{r(),a()}},[i,t,b,n]),(0,G.useEffect)(()=>{n&&f.current&&!e.isProcessing&&b(),f.current=e.isProcessing},[b,n,e.isProcessing]),(0,G.useEffect)(()=>()=>{d.current!==null&&a.clearTimeout(d.current)},[a]),(0,G.useEffect)(()=>{n||d.current!==null&&(a.clearTimeout(d.current),d.current=null)},[t,n,a]);let ae=(0,G.useMemo)(()=>({onOpenFile:w,onOpenInFinder:j,onDiscardFile:O,onIgnoreFile:k,onIgnoreFolder:A,onCopyFilePath:T,onCopyRelativePath:E}),[T,E,O,k,A,w,j]);return{props:(0,G.useMemo)(()=>t?{projectId:t,diffs:e.chatDiffSnapshot??IO,editorLabel:e.editorLabel,diffRenderMode:s,wrapLines:c,fileActions:ae,onLoadPatch:D,onListBranches:R,onPreviewMergeBranch:ne,onMergeBranch:re,onCheckoutBranch:te,onCreateBranch:ie,onGenerateCommitMessage:P,onInitializeGit:F,onGetGitHubPublishInfo:I,onCheckGitHubRepoAvailability:ee,onSetupGitHub:L,onCommit:M,onSyncWithRemote:N,onDiffRenderModeChange:l,onWrapLinesChange:u}:null,[s,ae,ee,te,M,ie,P,I,F,R,D,re,ne,L,N,t,l,u,e.chatDiffSnapshot,e.editorLabel,c]),scheduleTerminalDiffRefresh:x,initializeGit:F}}function RO(e,t){return e===t?!0:!e||!t||e.kind!==t.kind?!1:e.kind===`split`&&t.kind===`split`?e.position===t.position:!0}var zO=Jn()(e=>({activeTabId:null,overPaneId:null,intent:null,beginDrag:t=>e(e=>e.activeTabId===t?e:{activeTabId:t}),hoverPane:(t,n)=>e(e=>e.overPaneId===t&&RO(e.intent,n)?e:{overPaneId:t,intent:n}),clearHover:()=>e(e=>e.overPaneId===null&&e.intent===null?e:{overPaneId:null,intent:null}),endDrag:()=>e(e=>e.activeTabId===null&&e.overPaneId===null&&e.intent===null?e:{activeTabId:null,overPaneId:null,intent:null})}));function BO(e){let t=j(e.root),n=t.find(t=>t.id===e.focusedPaneId)??t[0]??null,r=t.flatMap(e=>e.tabs);return{kind:`pane`,id:n?.id??`mobile`,tabs:r,focusedTabId:(n?ie(n):null)??r[0]?.tabId??null}}function VO(e){return`${e*100}%`}function HO({node:e,...t}){let{onResizeGroup:n}=t,r=(0,G.useCallback)(t=>{let r=e.children.map(e=>(t[e.id]??0)/100);r.some(e=>e>0)&&n(e.id,r)},[e.children,e.id,n]);return(0,K.jsx)(Ay,{orientation:e.direction,className:`min-h-0 min-w-0`,onLayoutChanged:r,children:e.children.map((n,r)=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(jy,{id:n.id,defaultSize:VO(e.sizes[r]??1/e.children.length),className:`min-h-0 min-w-0`,children:(0,K.jsx)(KO,{...t,node:n})}),r<e.children.length-1?(0,K.jsx)(Fy,{withHandle:!0,orientation:e.direction}):null]},n.id))})}function UO({node:e,focusedPaneId:t,renderPane:n,onFocusPane:r}){let i=t===e.id,a=(0,G.useCallback)(()=>r(e.id),[e.id,r]),{setNodeRef:o}=za({id:e.id}),s=zO(t=>t.overPaneId===e.id),c=zO(e=>e.intent);return(0,K.jsxs)(`div`,{ref:o,"data-pane-id":e.id,"data-pane-focused":i?`true`:`false`,className:B(`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden`),onPointerDownCapture:a,children:[n(e,i),s&&c?(0,K.jsx)(GO,{intent:c}):null]})}var WO={left:`inset-y-0 left-0 w-1/2`,right:`inset-y-0 right-0 w-1/2`,top:`inset-x-0 top-0 h-1/2`,bottom:`inset-x-0 bottom-0 h-1/2`};function GO({intent:e}){return(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-pane-drop":e.kind===`merge`?`merge`:`split-${e.position}`,className:B(`pointer-events-none absolute z-10 border border-destructive bg-destructive/[0.08]`,e.kind===`merge`?`inset-0`:WO[e.position])})}function KO(e){return Wr(e.node)?(0,K.jsx)(HO,{...e,node:e.node}):(0,K.jsx)(UO,{...e,node:e.node})}function qO({layout:e,...t}){let n=Wa(e=>e.width),r=(0,G.useMemo)(()=>ca(n)?BO(e):null,[n,e]);return r?(0,K.jsx)(`div`,{"data-pane-mobile":`true`,className:`flex h-full min-h-0 min-w-0 flex-col`,children:(0,K.jsx)(KO,{...t,node:r,focusedPaneId:r.id})}):(0,K.jsx)(KO,{...t,node:e.root,focusedPaneId:e.focusedPaneId})}function JO({tabs:e,activeTabId:t,recency:n,cap:r=3}){let i=new Set;for(let n of e)(n.tabId===t||n.target.kind===`terminal`)&&i.add(n.tabId);let a=e.filter(e=>!i.has(e.tabId)).map((e,t)=>{let r=n.indexOf(e.tabId);return{tabId:e.tabId,rank:r===-1?n.length+t:r}}).sort((e,t)=>e.rank-t.rank);for(let{tabId:e}of a.slice(0,Math.max(0,r)))i.add(e);return e.filter(e=>i.has(e.tabId)).map(e=>e.tabId)}function YO(e,t,n=32){if(e[0]===t)return e;let r=[t,...e.filter(e=>e!==t)];return r.length>n?r.slice(0,n):r}var XO=Qn(`PaneScoped`,()=>e=>({layoutWidth:0,setLayoutWidth:t=>e({layoutWidth:t}),tabRecency:[],noteTabActivated:t=>e(e=>{let n=YO(e.tabRecency,t);return n===e.tabRecency?e:{tabRecency:n}})}));function ZO(e,t,n,r,i){switch(t.kind){case`chat`:return e.chat(t,n,r,i);case`changes`:return e.changes(t,n,r,i);case`terminal`:return e.terminal(t,n,r,i);case`board`:return e.board(t,n,r,i);case`page`:return e.page(t,n,r,i)}}function QO(e){return yr(e,{min:60,max:200},60)}var $O={order:null,highlight:0,holdBinding:null};function ek(e,t){return(e%t+t)%t}var tk=Jn()((e,t)=>({...$O,jumpHintsVisible:!1,openSwitcher:(t,n,r)=>{t.length<2||e({order:t,holdBinding:n,highlight:r?t.length-1:1})},stepSwitcher:n=>{let{order:r,highlight:i}=t();r&&e({highlight:ek(i+n,r.length)})},highlightTab:n=>{let{order:r}=t();!r||n<0||n>=r.length||e({highlight:n})},commitSwitcher:()=>{let{order:n,highlight:r}=t();return e({...$O}),n?.[r]??null},closeSwitcher:()=>e({...$O}),setJumpHintsVisible:n=>{t().jumpHintsVisible!==n&&e({jumpHintsVisible:n})}})),nk=7;function rk(e,t,n){return Math.min(n,Math.max(t,e))}function ik({availableWidth:e,tabCount:t,actionsWidth:n,minTabWidth:r}){if(t<=0)return{tabWidth:0,showLabel:!1,scrolls:!1};if(!Number.isFinite(e)||e<=0)return{tabWidth:200,showLabel:!0,scrolls:!1};let i=Math.max(0,e-Math.max(0,n)),a=rk(r??60,60,200),o=i<a*t,s=o?a:Math.round(rk(i/t,a,200));return{tabWidth:s,showLabel:s-60>=nk,scrolls:o}}var ak={projects:{label:`Projects`,icon:w},settings:{label:`Settings`,icon:va},cron:{label:`Cron jobs`,icon:Ni},webhooks:{label:`Webhooks`,icon:Ra},inbox:{label:`Inbox`,icon:la},workflows:{label:`Workflows`,icon:ye},boards:{label:`Boards`,icon:ba},plugin:{label:`Plugin`,icon:Gi}};function ok(e,t){switch(e.kind){case`chat`:{let n=t.chatStatuses?.[e.chatId];return{label:t.chatTitles?.[e.chatId]??`Chat`,icon:Xa,pinned:n?.status===`running`||n?.status===`starting`,closable:!0,indicator:n?ki(n):null,sessionBadge:Ea(n?.sessionState)}}case`page`:return{...ak[e.page],...e.page===`plugin`&&t.pluginPageTitles?.[e.path]?{label:t.pluginPageTitles[e.path]}:{},pinned:!1,closable:!0,indicator:null,sessionBadge:null};case`board`:return{label:t.boardTitles?.[e.boardId]??`Board`,icon:ba,pinned:!1,closable:!0,indicator:null,sessionBadge:null};case`changes`:return{label:`Changes`,icon:zo,pinned:!1,closable:!0,indicator:null,sessionBadge:null};case`terminal`:return{label:t.terminalTitles?.[e.terminalId]??`Terminal`,icon:ks,pinned:t.liveTerminalIds?.has(e.terminalId)??!1,closable:!0,indicator:null,sessionBadge:null}}}var sk=52,ck=`Open another tab to split — a pane cannot be left empty`,lk=1;function uk({pane:e,isPaneFocused:t,width:n,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:o}){let s=Wa(e=>e.width),c=ca(s),u=br(e=>e.settings?.panes.tabMinWidth??60),d=tk(e=>e.jumpHintsVisible)&&t&&!c,f=!c,p=e.tabs.length>1,m=ik({availableWidth:n,tabCount:e.tabs.length,actionsWidth:f?sk:0,minTabWidth:c?124:u}),h=(0,G.useCallback)(()=>o(`right`),[o]),g=(0,G.useCallback)(()=>o(`bottom`),[o]),_=(0,G.useRef)(null),v=(0,G.useRef)(!1),y=ie(e);return(0,G.useEffect)(()=>{let e=_.current?.querySelector(`[data-tab-active="true"]`);if(typeof e?.scrollIntoView!=`function`)return;let t=!v.current;v.current=!0,e.scrollIntoView({block:`nearest`,inline:`nearest`,...t?{behavior:`instant`}:{}})},[y]),(0,K.jsxs)(`div`,{"data-pane-tab-strip":!0,className:B(`flex shrink-0 items-stretch border-b border-border bg-background`,Ka),children:[(0,K.jsx)(`div`,{ref:_,"data-swipe-scroll-x":m.scrolls?`true`:void 0,className:B(`flex min-w-0 flex-1 items-stretch`,m.scrolls&&`overflow-x-auto overscroll-x-contain touch-pan-x motion-safe:scroll-smooth`),style:{WebkitOverflowScrolling:`touch`},children:e.tabs.map((n,o)=>{let s=y===n.tabId,{label:u,icon:f,closable:p,indicator:h,sessionBadge:g}=ok(n.target,r);return(0,K.jsx)(dk,{tabId:n.tabId,label:u,Icon:f,indicator:h,sessionBadge:g,jumpHint:d?l(o,e.tabs.length):null,isActive:s,isPaneFocused:t,showLabel:m.showLabel,closable:p,isPhone:c,width:m.tabWidth,onSelect:i,onClose:a},n.tabId)})}),f?(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 px-1`,children:[(0,K.jsx)(pk,{label:`Split right`,disabledReason:ck,disabled:!p,onClick:h,icon:Do}),(0,K.jsx)(pk,{label:`Split down`,disabledReason:ck,disabled:!p,onClick:g,icon:hs})]}):null]})}function dk({tabId:e,label:t,Icon:n,indicator:r,sessionBadge:i,jumpHint:a,isActive:o,isPaneFocused:s,showLabel:c,closable:l,isPhone:u,width:d,onSelect:f,onClose:p}){let m=(0,G.useCallback)(()=>f(e),[f,e]),h=(0,G.useCallback)(t=>{t.stopPropagation(),p(e)},[p,e]),g=(0,G.useCallback)(t=>{t.button===lk&&l&&(t.preventDefault(),t.stopPropagation(),p(e))},[l,p,e]),_=(0,G.useCallback)(e=>{e.button===lk&&e.preventDefault()},[]),{attributes:v,listeners:y,setNodeRef:b,isDragging:x}=_a({id:e,disabled:u}),S=(0,K.jsxs)(`div`,{ref:b,...v,...y,role:`tab`,"aria-selected":o,"data-tab-id":e,"data-tab-active":o?`true`:`false`,onClick:m,onAuxClick:g,onMouseDown:_,className:B(`group relative flex shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3`,o?`bg-background text-foreground`:`text-muted-foreground hover:bg-muted/40`,u?`touch-pan-x`:`touch-none`,x&&`opacity-50`),style:{width:d},children:[o?(0,K.jsx)(`span`,{"aria-hidden":!0,"data-tab-indicator":s?`focused`:`unfocused`,className:B(`absolute inset-x-0 top-0 h-0.5`,s?`bg-destructive`:`bg-border`)}):null,(0,K.jsx)(fk,{jumpHint:a,indicator:r,Icon:n}),r?(0,K.jsx)(`span`,{className:`sr-only`,children:r.label}):null,i&&c?(0,K.jsx)(`span`,{"aria-hidden":!0,"data-tab-session-badge":!0,className:B(`flex shrink-0 items-center`,i.toneClass),children:(0,K.jsx)(Ui,{kind:i.kind})}):null,c?(0,K.jsx)(`span`,{"data-flip-title":!0,className:`min-w-0 flex-1 truncate text-xs`,children:t}):null,l?(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close ${t}`,onClick:h,className:`ml-auto flex size-8 max-md:size-11 shrink-0 items-center justify-center rounded-sm opacity-0 hover:bg-muted focus-visible:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100`,children:(0,K.jsx)(Mn,{className:`size-3`})}):null]}),C=[];return r&&C.push(r.label),i&&C.push(i.title),c&&C.length===0?S:(0,K.jsxs)(zn,{children:[(0,K.jsx)(Bn,{asChild:!0,children:S}),(0,K.jsxs)(Wn,{side:`bottom`,children:[(0,K.jsx)(`span`,{children:t}),C.map(e=>(0,K.jsx)(`span`,{className:`block text-muted-foreground`,children:e},e))]})]})}function fk({jumpHint:e,indicator:t,Icon:n}){return e?(0,K.jsx)(Hn,{"aria-hidden":!0,"data-tab-jump-hint":e,className:`h-4 min-w-4 shrink-0 rounded-sm border-border bg-background px-0.5 text-xs text-foreground`,children:e}):t?(0,K.jsx)(`span`,{"aria-hidden":!0,"data-tab-status":t.tone,className:`flex size-3.5 shrink-0 items-center justify-center`,children:(0,K.jsx)(`span`,{className:B(`h-2 w-2 rounded-full`,Ki(t.tone))})}):(0,K.jsx)(n,{className:`size-3.5 shrink-0`})}function pk({label:e,icon:t,onClick:n,disabled:r,disabledReason:i}){let a=(0,G.useCallback)(()=>{r||n()},[r,n]);return(0,K.jsxs)(zn,{children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":r,onClick:a,className:B(`flex size-[22px] items-center justify-center rounded-sm text-muted-icon`,r?`cursor-default opacity-40`:`hover:bg-muted hover:text-foreground`),children:(0,K.jsx)(t,{className:`size-3.5`})})}),(0,K.jsx)(Wn,{side:`bottom`,children:r&&i?i:e})]})}function mk(e){return(0,K.jsx)(XO.Provider,{init:void 0,children:(0,K.jsx)(hk,{...e})})}function hk({pane:e,isFocused:t,registry:n,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:o}){let s=(0,G.useRef)(null),c=XO.useScopedStoreApi(),l=XO.useScopedStore(e=>e.setLayoutWidth),u=XO.useScopedStore(e=>e.layoutWidth);(0,G.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=c.getState().layoutWidth;Math.abs(n-t)>=1&&l(t)},n=new ResizeObserver(t);return n.observe(e),t(),()=>n.disconnect()},[c,l]);let d=ie(e),f=(0,G.useCallback)(t=>{d&&o({tabId:d,paneId:e.id,position:t})},[d,e.id,o]),p=XO.useScopedStore(e=>e.tabRecency),m=XO.useScopedStore(e=>e.noteTabActivated);(0,G.useEffect)(()=>{d&&m(d)},[d,m]);let h=(0,G.useMemo)(()=>new Set(JO({tabs:e.tabs,activeTabId:d,recency:p})),[e.tabs,d,p]);return(0,K.jsxs)(`div`,{ref:s,className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,K.jsx)(uk,{pane:e,isPaneFocused:t,width:u,presentation:r,onSelectTab:i,onCloseTab:a,onSplit:f}),(0,K.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:e.tabs.filter(e=>h.has(e.tabId)).map(r=>{let i=r.tabId===d;return(0,K.jsx)(`div`,{className:B(`absolute inset-0 flex min-h-0 min-w-0 flex-col`,!i&&`invisible pointer-events-none`),inert:!i,children:ZO(n,r.target,e,t&&i,i)},r.tabId)})})]})}var gk=[[`focusPaneLeft`,{kind:`focus`,direction:`left`}],[`focusPaneRight`,{kind:`focus`,direction:`right`}],[`focusPaneUp`,{kind:`focus`,direction:`up`}],[`focusPaneDown`,{kind:`focus`,direction:`down`}],[`resizePaneLeft`,{kind:`resize`,direction:`left`}],[`resizePaneRight`,{kind:`resize`,direction:`right`}],[`resizePaneUp`,{kind:`resize`,direction:`up`}],[`resizePaneDown`,{kind:`resize`,direction:`down`}],[`splitPaneRight`,{kind:`split`,position:`right`}],[`splitPaneDown`,{kind:`split`,position:`bottom`}],[`closePaneTab`,{kind:`closeTab`}],[`nextPaneTab`,{kind:`cycleTab`,delta:1}],[`previousPaneTab`,{kind:`cycleTab`,delta:-1}]];function _k(e){if(!e)return!1;if(e.isContentEditable)return!0;let t=e.tagName?.toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function vk(e,t,n){return gi(gk,e,t,n)}var yk=.4;function bk({pointer:e,rect:t,mergeRatio:n=yk}){if(t.width<=0||t.height<=0)return{kind:`merge`};let r=e=>Math.min(1,Math.max(0,e)),i=r((e.x-t.left)/t.width),a=r((e.y-t.top)/t.height),o=n/2;if(Math.abs(i-.5)<=o&&Math.abs(a-.5)<=o)return{kind:`merge`};let s=[[`left`,i],[`right`,1-i],[`top`,a],[`bottom`,1-a]],c=s[0];for(let e of s)e[1]<c[1]&&(c=e);return{kind:`split`,position:c[0]}}function xk(e,t){return e instanceof MouseEvent?{x:e.clientX+t.x,y:e.clientY+t.y}:null}function Sk({children:e,onMoveTab:t,onSplitWithTab:n}){let r=xa(Ma(Ya,{activationConstraint:{distance:4}})),i=zO(e=>e.beginDrag),a=zO(e=>e.hoverPane),o=zO(e=>e.clearHover),s=zO(e=>e.endDrag),c=(0,G.useCallback)(e=>i(String(e.active.id)),[i]),l=(0,G.useCallback)(e=>{let t=e.over;if(!t){o();return}let n=xk(e.activatorEvent,e.delta);n?a(String(t.id),bk({pointer:n,rect:t.rect})):o()},[o,a]),u=(0,G.useCallback)(e=>{let{intent:r,overPaneId:i}=zO.getState(),a=String(e.active.id);s(),e.over&&i&&r&&(r.kind===`merge`?t(a,i):n(a,i,r.position))},[s,t,n]);return(0,K.jsx)(Aa,{sensors:r,collisionDetection:ma,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:s,children:e})}var Ck=`tab-switcher-list`;function wk({layout:e,presentation:t,keybindings:n,onCommit:r,ports:i}){let a=i?.dom??pi,o=tk(e=>e.order),s=tk(e=>e.highlight),c=tk(e=>e.holdBinding),l=tk(e=>e.highlightTab),u=tk(e=>e.commitSwitcher),d=(0,G.useRef)(null),f=(0,G.useMemo)(()=>o?Tk(e,o,t):[],[e,o,t]),p=(0,G.useMemo)(()=>ee(e.root),[e.root]),m=ya(a.getUserAgent()),h=yi(bi(n,`jumpToPaneTab`),m),g=(0,G.useCallback)(e=>{l(e);let t=u();t&&r(t)},[u,l,r]);if((0,G.useEffect)(()=>{let e=d.current?.querySelector(`[data-tab-switcher-active="true"]`);e instanceof HTMLElement&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`nearest`})},[s]),!o||f.length===0)return null;let _=f[s]??f[0],v=p.length>1;return(0,Fs.createPortal)((0,K.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-[16vh] z-50 flex justify-center px-4`,children:(0,K.jsxs)(`div`,{role:`dialog`,"aria-label":`Switch tab`,"data-tab-switcher":!0,className:`kanna-tab-switcher-in pointer-events-auto flex w-full max-w-[520px] flex-col overflow-hidden rounded-lg border border-border bg-card text-card-foreground shadow-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2 border-b border-border px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`Recent tabs`}),h?(0,K.jsx)(`span`,{className:`ml-auto`,children:(0,K.jsx)(Fk,{keys:[...mi(h,m),`1–9`],children:`by position`})}):null]}),(0,K.jsx)(`ul`,{ref:d,id:Ck,role:`listbox`,"aria-label":`Recent tabs`,"aria-activedescendant":Ek(_.tabId),className:`max-h-[min(22rem,56vh)] overflow-y-auto py-1`,children:f.map((e,t)=>(0,K.jsx)(Dk,{row:e,index:t,active:t===s,current:t===0,paneBounds:v?p:null,onHighlight:l,onCommit:g},e.tabId))}),(0,K.jsxs)(`p`,{"aria-live":`polite`,className:`sr-only`,children:[_.view.label,`, `,s+1,` of `,f.length]}),(0,K.jsx)(Mk,{isMac:m,holdBinding:c})]})}),a.getBodyElement())}function Tk(e,t,n){let r=new Map;for(let t of j(e.root))for(let e of t.tabs)r.set(e.tabId,{tabId:e.tabId,paneId:t.id,view:ok(e.target,n)});return t.flatMap(e=>{let t=r.get(e);return t?[t]:[]})}function Ek(e){return`tab-switcher-option-${e}`}function Dk({row:e,index:t,active:n,current:r,paneBounds:i,onHighlight:a,onCommit:o}){let s=(0,G.useCallback)(()=>{n||a(t)},[n,t,a]),c=(0,G.useCallback)(()=>o(t),[t,o]),{label:l,icon:u,indicator:d}=e.view,f=r?`Current`:d?.label;return(0,K.jsxs)(`li`,{id:Ek(e.tabId),role:`option`,"aria-selected":n,"data-tab-switcher-active":n,onPointerMove:s,onClick:c,className:B(`grid cursor-pointer grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-1.5`,n?`bg-muted`:`hover:bg-muted/40`),children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 items-center justify-center`,children:d?(0,K.jsx)(`span`,{className:B(`size-2 rounded-full`,Ki(d.tone))}):(0,K.jsx)(u,{className:`size-3.5 text-muted-foreground`})}),(0,K.jsx)(`span`,{className:B(`truncate text-sm`,n?`font-semibold text-foreground`:`font-medium`,r&&!n&&`text-muted-foreground`),children:l}),(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[f?(0,K.jsx)(`span`,{children:f}):null,i?(0,K.jsx)(jk,{bounds:i,paneId:e.paneId}):null]})]})}var Ok=18,kk=12,Ak=1;function jk({bounds:e,paneId:t}){return(0,K.jsx)(`svg`,{"aria-hidden":!0,"data-pane-minimap":t,width:Ok,height:kk,viewBox:`0 0 ${Ok} ${kk}`,className:`shrink-0`,children:e.map(({paneId:e,rect:n})=>(0,K.jsx)(`rect`,{x:n.left*Ok+Ak/2,y:n.top*kk+Ak/2,width:Math.max((n.right-n.left)*Ok-Ak,Ak),height:Math.max((n.bottom-n.top)*kk-Ak,Ak),rx:1,className:e===t?`fill-foreground`:`fill-muted-foreground/30`},e))})}function Mk({isMac:e,holdBinding:t}){let n=t?mi(t,e):[],r=n.slice(0,-1),i=n.at(-1)??``;return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-3 py-2 text-xs text-muted-foreground`,children:[r.length>0?(0,K.jsx)(Fk,{keys:r,children:`Release to open`}):null,(0,K.jsx)(Fk,{keys:[i],children:`Next`}),(0,K.jsx)(Fk,{keys:[e?`⇧`:`Shift`,i],children:`Back`}),(0,K.jsx)(Fk,{keys:[`Esc`],children:`Cancel`})]})}var Nk=new Set([`⌘`,`⌃`,`⌥`,`⇧`,"`"]);function Pk(e){return Nk.has(e)}function Fk({keys:e,children:t}){return(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(qn,{children:e.map(e=>(0,K.jsx)(Hn,{className:B(Pk(e)&&`font-sans text-sm`),children:e},e))}),(0,K.jsx)(`span`,{children:t})]})}var Ik={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function Lk(e,t){return e?e.reverse?-1:1:Ik[t]}function Rk(e){e.preventDefault(),e.stopPropagation()}function zk(e,t,n,r=pi){(0,G.useEffect)(()=>{if(!t)return;let i=tk.getState;function a(){let e=i().commitSwitcher();e&&n(e)}function o(t){if(t.key===`Escape`){Rk(t),i().closeSwitcher();return}if(t.key===`Enter`){Rk(t),a();return}let n=Lk(h(e,t),t.key);n&&(Rk(t),i().stepSwitcher(n))}function s(t){if(i().order){o(t);return}i().setJumpHintsVisible(S(e,t));let r=h(e,t);if(r){Rk(t);let{layout:e,recentTabIds:n}=x.getState(),a=_(e,n).map(e=>e.tab.tabId);i().openSwitcher(a,r.binding,r.reverse);return}let a=ae(e,t);if(a===null)return;let s=E(m(x.getState().layout),a);s&&(Rk(t),n(s))}function c(t){let{order:n,holdBinding:r,setJumpHintsVisible:o}=i();o(S(e,t)),n&&r&&vi(r,t)&&a()}function l(){i().closeSwitcher(),i().setJumpHintsVisible(!1)}let u=[r.addWindowCaptureListener(`keydown`,s),r.addWindowCaptureListener(`keyup`,c),r.addWindowListener(`blur`,l)];return()=>{for(let e of u)e();l()}},[r,t,e,n])}function Bk(e){let t=Nr(e.sidebarData);return{terminalTitles:Object.fromEntries(Object.values(e.terminalProjects).flatMap(e=>e.terminals.map(e=>[e.id,e.title]))),chatTitles:Object.fromEntries(t.map(e=>[e.chatId,e.title])),chatStatuses:Object.fromEntries(t.map(e=>[e.chatId,{status:e.status,unread:e.unread,sessionState:e.sessionState}])),boardTitles:Object.fromEntries([...Object.values(e.boardViews??{}).flatMap(e=>e?[[e.board.id,e.board.title]]:[]),...Object.values(e.boardsByOwner).flatMap(e=>e.map(e=>[e.id,e.title]))]),pluginPageTitles:Object.fromEntries((e.pluginSidebarItems??[]).map(e=>[Gr(e.pluginId,e.surface),e.title]))}}var Vk={};function Hk(e){return Object.fromEntries(Nr(e).map(e=>[e.chatId,{title:e.title,status:e.status,unread:e.unread,activity:e.activity,...e.stateEnteredAt==null?{}:{stateEnteredAt:e.stateEnteredAt}}]))}function Uk(e){return{id:e.id,kind:e.kind,displayName:e.displayName,absolutePath:e.absolutePath,relativePath:e.relativePath,contentUrl:e.contentUrl,mimeType:e.mimeType,size:e.size}}function Wk(e){return e.reused===void 0?Uk(e):{...Uk(e),reused:e.reused}}var Gk=[],Kk=[],qk={},Jk=Qn(`ChatTabScoped`,()=>e=>({toolGroupExpanded:qk,setToolGroupExpanded:t=>e(e=>({toolGroupExpanded:t(e.toolGroupExpanded)})),resetToolGroupExpanded:()=>e({toolGroupExpanded:qk}),inputHeight:148,setInputHeight:t=>e({inputHeight:t}),showScrollToBottom:!1,setShowScrollToBottom:t=>e({showScrollToBottom:t}),attachments:Gk,setAttachments:t=>e(e=>({attachments:typeof t==`function`?t(e.attachments):t})),selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t}),uploadError:null,setUploadError:t=>e({uploadError:t}),currentText:``,setCurrentText:t=>e({currentText:t}),mentionQuery:null,setMentionQuery:t=>e({mentionQuery:t}),slashQuery:null,setSlashQuery:t=>e({slashQuery:t}),mentionSuggestions:{items:Kk,loading:!1,error:null},setMentionSuggestions:t=>e({mentionSuggestions:t}),sharePopoverOpen:!1,setSharePopoverOpen:t=>e({sharePopoverOpen:t}),chatSettingsOpen:!1,setChatSettingsOpen:t=>e({chatSettingsOpen:t})})),Yk=(0,G.createContext)(null);function Xk(){let e=(0,G.use)(Yk);if(!e)throw Error(`useChatTabState must be used inside a ChatTabRoot`);return e}function Zk({chatId:e,timer:t,dom:n,children:r}){let i=Va(e,{timer:t,dom:n});return(0,K.jsx)(Yk.Provider,{value:i,children:(0,K.jsx)(Jk.Provider,{init:void 0,children:r})})}function Qk({activeChatId:e,routeBoardId:t}){let n=i(),r=o(),a=Sa().chatNavigator,s=x(e=>e.openTab),c=x(e=>e.closeTab),l=x(e=>e.getLayout),u=n.pathname,d=n.key,f=(0,G.useMemo)(()=>Fr(u),[u]);return(0,G.useEffect)(()=>{f?s(f):(e&&s({kind:`chat`,chatId:e}),t&&s({kind:`board`,boardId:t}))},[d,f,e,t,s]),{routePage:f,syncUrlToFocusedTab:(0,G.useCallback)(()=>{let e=l(),t=j(e.root).find(t=>t.id===e.focusedPaneId),n=t?.tabs.find(e=>e.tabId===t.focusedTabId)?.target;n?.kind===`chat`&&u!==Ur(n.chatId)&&a.openChat(n.chatId),n?.kind===`page`&&u!==n.path&&r(n.path)},[l,u,a,r]),closeRoutedTab:(0,G.useCallback)((t,n)=>{if(c(t),!(n.kind===`page`?f?.page===n.page:n.kind===`chat`&&!f&&n.chatId===e))return;let i=Kr(l());i!==u&&r(i)},[c,l,f,e,u,r])}}var $k=(0,G.lazy)(()=>er(()=>import(`./LocalProjectsPage-ByzldcFY.js`).then(e=>({default:e.LocalProjectsPage})),__vite__mapDeps([6,1,2,7,3,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,4,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),eA=(0,G.lazy)(()=>er(()=>import(`./BoardsRoutePage-DH_FSa9D.js`).then(e=>({default:e.BoardsRoutePage})),__vite__mapDeps([53,1,2,7,3,23,24,36,54,8,10,11,12,18,22,26,15,27,28,9,13,14,29,4,30,31,32,25,33,34,35,37,38,39,20,21,40,41,42,16,43,44,45,46,47,48,49,19,50,51,52]))),tA=(0,G.lazy)(()=>er(()=>import(`./StackBoardsRoutePage-BB4N2PvL.js`).then(e=>({default:e.StackBoardsRoutePage})),__vite__mapDeps([55,1,2,7,3,54,8,10,11,12,18,22,26,15,27,28,9,13,14,29,4,30,31,32,24,25,33,34,35,23,36,37,38,39,20,21,40,41,42,16,43,44,45,46,47,48,49,19,50,51,52]))),nA=(0,G.lazy)(()=>er(()=>import(`./SettingsPage-D1pWNjOV.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([56,1,2,7,3,27,8,28,9,10,11,12,13,14,15,29,4,30,31,32,24,25,33,34,22,35,23,36,37,38,39,20,21,40,41,57,26,42,16,43,44,18,45,46,47,48,49,19,50,51,52,58,17,59,60,61,62]))),rA=(0,G.lazy)(()=>er(()=>import(`./WorkflowsPage-CiMSQgt6.js`).then(e=>({default:e.WorkflowsPage})),__vite__mapDeps([63,1,2,7,3,8,42,28,9,10,11,12,13,14,15,29,4,30,31,32,24,25,16,43,44,18,45,46,23,38,47,33,48,49,19,37,50,51,64,61]))),iA=(0,G.lazy)(()=>er(()=>import(`./WebhooksPage-skxsqDwx.js`).then(e=>({default:e.WebhooksPage})),__vite__mapDeps([65,1,2,3,8,9,10,11,12,13,14,15,48,18,45,34,22,32,31,35,20,21,29,39,23,24,38,25,26,7,27,28,4,30,33,36,37,40,41,42,16,43,44,46,47,49,19,50,51,52,59,62]))),aA=(0,G.lazy)(()=>er(()=>import(`./InboxPage-D0x0vrxJ.js`).then(e=>({default:e.InboxPage})),__vite__mapDeps([66,1,2,7,3,8,64,57,15,9,10,11,12,13,14,21,20,26,27,28,29,4,30,31,32,24,25,33,34,22,35,23,36,37,38,39,40,41,42,16,43,44,18,45,46,47,48,49,19,50,51,52,59,60]))),oA=(0,G.lazy)(()=>er(()=>import(`./CronJobsPage-C4VwunK5.js`).then(e=>({default:e.CronJobsPage})),__vite__mapDeps([67,1,2,7,3,23,24,37,8,40,11,26,15,27,28,9,10,12,13,14,29,4,30,31,32,25,33,34,22,35,36,38,39,20,21,41,42,16,43,44,18,45,46,47,48,49,19,50,51,52]))),sA=(0,G.lazy)(()=>er(()=>import(`./PluginPage-3M8_92nv.js`).then(e=>({default:e.PluginPage})),__vite__mapDeps([68,1,3,26,2,15,7,27,8,28,9,10,11,12,13,14,29,4,30,31,32,24,25,33,34,22,35,23,36,37,38,39,20,21,40,41,42,16,43,44,18,45,46,47,48,49,19,50,51,52])));function cA(){return(0,K.jsx)(`div`,{role:`status`,"aria-label":`Loading page`,className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,K.jsx)(hn,{className:`size-5`})})}function lA({target:e}){let t=Pr(e.path)?.params??{};switch(e.page){case`projects`:return(0,K.jsx)($k,{});case`settings`:return(0,K.jsx)(nA,{sectionId:t.sectionId});case`cron`:return(0,K.jsx)(oA,{});case`webhooks`:return(0,K.jsx)(iA,{});case`inbox`:return(0,K.jsx)(aA,{threadId:t.threadId??null});case`workflows`:return(0,K.jsx)(rA,{chatId:t.chatId});case`boards`:return t.stackId?(0,K.jsx)(tA,{stackId:t.stackId}):(0,K.jsx)(eA,{projectId:t.projectId??``});case`plugin`:return(0,K.jsx)(sA,{pluginId:t.pluginId??``,surfaceId:t.surfaceId??``})}}function uA({target:e}){return(0,K.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(cA,{}),children:(0,K.jsx)(lA,{target:e})})})}var dA=e=>({syncing:!1,message:null,openCardId:null,syncPanelOpen:!1,schemaPanelOpen:!1,renaming:!1,titleDraft:``,openCard:t=>e({openCardId:t,syncPanelOpen:!1,schemaPanelOpen:!1}),closeCard:()=>e({openCardId:null}),openSyncPanel:()=>e({syncPanelOpen:!0,openCardId:null,schemaPanelOpen:!1}),closeSyncPanel:()=>e({syncPanelOpen:!1}),openSchemaPanel:()=>e({schemaPanelOpen:!0,openCardId:null,syncPanelOpen:!1}),closeSchemaPanel:()=>e({schemaPanelOpen:!1}),startRename:t=>e({renaming:!0,titleDraft:t}),setTitleDraft:t=>e({titleDraft:t}),stopRename:()=>e({renaming:!1,titleDraft:``}),startSync:()=>e({syncing:!0}),finishSync:t=>e({syncing:!1,message:t}),reportMessage:t=>e({message:t})}),fA=Qn(`BoardPane`,()=>dA),pA=Qn(`CardDrawer`,()=>(e,t)=>({detail:null,error:null,draft:``,editingFieldId:null,fieldDraft:``,startingWork:!1,startWorkNote:null,resolvingCleanup:!1,setDetail:t=>e({detail:t,error:null}),setError:t=>e({error:t}),setDraft:t=>e({draft:t}),beginFieldEdit:(t,n)=>e({editingFieldId:t,fieldDraft:n,error:null}),setFieldDraft:t=>e({fieldDraft:t}),cancelFieldEdit:()=>e({editingFieldId:null,fieldDraft:``}),takeFieldDraft:n=>{let{editingFieldId:r,fieldDraft:i}=t();return r===n?(e({editingFieldId:null,fieldDraft:``}),i):null},beginStartWork:()=>e({startingWork:!0,error:null,startWorkNote:null}),endStartWork:t=>e({startingWork:!1,startWorkNote:t}),beginCleanup:()=>e({resolvingCleanup:!0,error:null}),endCleanup:()=>e({resolvingCleanup:!1})}));function mA(e){let t=`${e}:`;return{encode:e=>`${t}${e}`,decode:e=>e.startsWith(t)?e.slice(t.length):null}}var hA=`add`,gA=mA(`c`);function _A({cardId:e,blockers:t,candidates:n,socket:r,onChanged:i,onError:a}){let o=(0,G.useMemo)(()=>new Set(t.map(e=>e.cardId)),[t]),s=(0,G.useMemo)(()=>n.filter(t=>t.id!==e&&!o.has(t.id)),[o,e,n]),c=(0,G.useCallback)(t=>{let n=gA.decode(t);n!==null&&r.command({type:`board.card.block`,cardId:e,blockedByCardId:n}).then(i).catch(nr(e=>{a(e.message)}))},[e,i,a,r]),l=(0,G.useCallback)(t=>{r.command({type:`board.card.unblock`,cardId:e,blockedByCardId:t}).then(i).catch(nr(e=>{a(e.message)}))},[e,i,a,r]);return t.length===0&&s.length===0?null:(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Blocked by`}),t.length>0?(0,K.jsx)(`ul`,{className:`mb-2 space-y-0.5`,children:t.map(e=>(0,K.jsx)(vA,{blocker:e,onRemove:l},e.cardId))}):null,s.length>0?(0,K.jsxs)(Ft,{value:hA,onValueChange:c,children:[(0,K.jsx)(Dt,{"aria-label":`Add a blocker`,className:`h-8 px-2 text-13`,children:(0,K.jsx)(Mt,{})}),(0,K.jsxs)(jt,{children:[(0,K.jsx)(kt,{value:hA,children:`Add a blocker…`}),s.map(e=>(0,K.jsx)(kt,{value:gA.encode(e.id),children:e.title},e.id))]})]}):null]})}function vA({blocker:e,onRemove:t}){let n=(0,G.useCallback)(()=>{t(e.cardId)},[e.cardId,t]);return(0,K.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[e.cleared?(0,K.jsx)(Tt,{"aria-hidden":!0,className:`size-3 shrink-0 text-muted-foreground`}):(0,K.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-warning`}),(0,K.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-13`,e.cleared?`text-muted-foreground line-through`:`text-foreground`),children:e.title}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.cleared?`Done`:`Not done`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Stop waiting on ${e.title}`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,K.jsx)(Mn,{"aria-hidden":!0,className:`size-3`})})]})}function yA(e){switch(e){case`agent`:return`Agent`;case`sync`:return`Sync`;case`remote_mcp`:return`MCP client`;case`user`:return`You`}}function bA(e){return e.reused?null:e.movedToColumnId===null?`Started · no column marked active`:null}function xA(e){return e.agents>0?[`${e.agents} agent${e.agents===1?``:`s`}`]:e.workflow?[e.workflow.name??`Workflow`]:e.loop?[`Loop · ${String(e.loop.done)}/${String(e.loop.total)}`]:[]}var SA=[];function CA(e){return e.options??SA}function wA(e){return e?.kind===`select`?e.optionId:null}function TA(e){return e?.kind===`multiselect`?e.optionIds:EA}var EA=[];function DA(e,t){let n=TA(e);return n.includes(t)?n.filter(e=>e!==t):[...n,t]}function OA(e,t){if(!t||t.kind!==e.kind)return``;switch(t.kind){case`text`:case`longtext`:case`url`:return t.value;case`number`:return String(t.value);case`date`:return MA(t.value);case`select`:return t.optionId??``;case`multiselect`:return t.optionIds.join(`, `);case`label`:return t.values.join(`, `)}}function kA(e,t){let n=t.trim();if(n===``)return null;switch(e.kind){case`text`:return{kind:`text`,value:n};case`longtext`:return{kind:`longtext`,value:n};case`url`:return{kind:`url`,value:n};case`number`:{let e=Number(n);return Number.isFinite(e)?{kind:`number`,value:e}:null}case`date`:{let e=Date.parse(`${n}T00:00:00.000Z`);return Number.isFinite(e)?{kind:`date`,value:e}:null}case`select`:return PA(e,n)?{kind:`select`,optionId:n}:null;case`multiselect`:{let t=FA(n).filter(t=>PA(e,t));return t.length===0?null:{kind:`multiselect`,optionIds:t}}case`label`:{let e=FA(n);return e.length===0?null:{kind:`label`,values:e}}}}function AA(e,t){if(e.kind===`select`){let n=wA(t);return n===null?``:NA(e,n)??``}return e.kind===`multiselect`?TA(t).map(t=>NA(e,t)).filter(e=>e!==null).join(`, `):OA(e,t)}function jA(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function MA(e){return new Date(e).toISOString().slice(0,10)}function NA(e,t){return CA(e).find(e=>e.id===t)?.label??null}function PA(e,t){return CA(e).some(e=>e.id===t)}function FA(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``)}var IA=[`description`,`labels`,`assignee`,`acceptanceCriteria`,`externalUrl`],LA=[`labels`,`assignee`];function RA(e){return LA.some(t=>t===e)}var zA={description:`GitHub sync writes issue bodies here, and Start work puts it in the agent's first prompt.`,labels:`GitHub sync writes issue labels here, and Start work puts them in the agent's first prompt.`,assignee:`GitHub sync writes the issue's assignee here.`,acceptanceCriteria:`Start work puts this in the agent's first prompt.`,externalUrl:`GitHub sync writes the issue's link here, and Start work puts it in the agent's first prompt.`};function BA(e){return IA.some(t=>t===e)}function VA(e){return BA(e)?zA[e]:null}function HA(e){return e&&(e.kind===`text`||e.kind===`longtext`||e.kind===`url`)?e.value:null}function UA(e,t){return HA(e[t])}function WA(e){let t=e.labels;return t?.kind===`label`?t.values:[]}function GA(e){switch(e.kind){case`idle`:return`Start work`;case`worktree`:return`Resume`;case`chat`:return`Open chat`}}function KA(e){let t=[];return e.dirtyFileCount>0&&t.push(e.dirtyFileCount===1?`1 uncommitted file`:`${e.dirtyFileCount.toString()} uncommitted files`),e.unmergedCommitCount>0&&t.push(e.unmergedCommitCount===1?`1 commit that is not on the project's branch`:`${e.unmergedCommitCount.toString()} commits that are not on the project's branch`),t.length===0?null:`That worktree still holds ${t.join(` and `)}.`}function qA(e){return e.dirtyFileCount>0?`Commit or discard the changes in that worktree before merging its branch.`:e.hasConflicts?`Merging ${e.branch} conflicts. Resolve it in the worktree's chat first.`:e.unmergedCommitCount===0?`That branch is already on the project's branch.`:null}function JA(e){let t=[];return e.unmergedCommitCount>0&&t.push(e.unmergedCommitCount===1?`1 commit to merge`:`${e.unmergedCommitCount.toString()} commits to merge`),e.dirtyFileCount>0&&t.push(e.dirtyFileCount===1?`1 uncommitted file`:`${e.dirtyFileCount.toString()} uncommitted files`),t.length===0?`Nothing left in it.`:t.join(` · `)}var YA=[];function XA(e){x.getState().openTab({kind:`chat`,chatId:e})}var ZA=[],QA=[],$A={},ej=[];function tj(e){return e.filter(e=>e.kind===`chat`).sort((e,t)=>t.createdAt-e.createdAt)}function nj({externalRef:e,content:t}){let n=UA(t,`externalUrl`);return(0,K.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:[`#`,e]}),n?(0,K.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,"aria-label":`Open on GitHub`,className:`text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Xi,{"aria-hidden":!0,className:`size-3`})}):null]})}function rj(e){return(0,K.jsx)(pA.Provider,{init:void 0,children:(0,K.jsx)(ij,{...e})},e.cardId)}function ij({cardId:e,socket:t,chatFacts:n,cardFields:r,boardCards:i,onClose:a,onChanged:o}){let s=pA.useScopedStoreApi(),c=pA.useScopedStore(e=>e.detail),l=pA.useScopedStore(e=>e.error),u=pA.useScopedStore(e=>e.draft),{setDetail:d,setError:f,setDraft:p}=s.getState(),m=(0,G.useCallback)(()=>{t.command({type:`board.card.detail`,cardId:e}).then(d).catch(nr(e=>{f(e.message)}))},[e,d,f,t]);(0,G.useEffect)(()=>{m()},[m]);let h=(0,G.useCallback)(()=>{let n=s.getState().draft.trim();n!==``&&(p(``),t.command({type:`board.card.comment`,cardId:e,body:n}).then(()=>{m(),o?.()}).catch(nr(e=>{f(e.message)})))},[e,m,o,p,f,t,s]),g=(0,G.useCallback)(()=>{m(),o?.()},[m,o]),_=(0,G.useCallback)(()=>{t.command({type:`board.card.archive`,cardId:e}).then(()=>{o?.(),a()}).catch(nr(e=>{f(e.message)}))},[e,o,a,f,t]),v=(0,G.useCallback)(()=>{s.getState().beginStartWork(),t.command({type:`board.card.startWork`,cardId:e}).then(e=>{XA(e.chatId),s.getState().endStartWork(bA(e)),m(),o?.()}).catch(nr(e=>{s.getState().endStartWork(null),f(e.message)}))},[e,m,o,f,t,s]),y=(0,G.useCallback)(n=>{s.getState().beginCleanup(),t.command({type:`board.card.resolveWorktree`,cardId:e,decision:n}).then(()=>{s.getState().endCleanup(),m(),o?.()}).catch(nr(e=>{s.getState().endCleanup(),f(e.message)}))},[e,m,o,f,t,s]),b=(0,G.useCallback)(()=>{y(`merge`)},[y]),x=(0,G.useCallback)(()=>{y(`discard`)},[y]),S=(0,G.useCallback)(()=>{y(`leave`)},[y]),C=(0,G.useCallback)(e=>{p(e.currentTarget.value)},[p]),w=(0,G.useCallback)((n,r)=>{let i=s.getState().detail?.card.content;i&&t.command({type:`board.card.update`,cardId:e,content:jA(i,n,r)}).then(()=>{m(),o?.()}).catch(nr(e=>{f(e.message)}))},[e,m,o,f,t,s]),T=pA.useScopedStore(e=>e.startingWork),E=pA.useScopedStore(e=>e.startWorkNote),D=pA.useScopedStore(e=>e.resolvingCleanup),O=c?.card??null,k=c?.startWork??null,A=c?.cleanup??null,j=A?KA(A):null,M=A?qA(A):null,N=O?.content??$A,P=r??QA,F=tj(c?.links??ZA),I=n??Vk,ee=c?.externalRef!=null&&P.length>0&&P.every(e=>RA(e.id));return(0,K.jsxs)(`aside`,{className:B(`absolute inset-y-0 right-0 z-20 flex w-full flex-col border-l border-border bg-background`,`sm:w-[400px]`),"aria-label":`Card detail`,children:[(0,K.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h2`,{className:`text-15 font-semibold leading-snug text-foreground [text-wrap:pretty]`,children:O?.title??`Loading…`}),c?.externalRef?(0,K.jsx)(nj,{externalRef:c.externalRef,content:N}):null]}),(0,K.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Close card`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,K.jsx)(Mn,{className:`size-4`})})]}),l?(0,K.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:l}):null,(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[k?(0,K.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(U,{size:`sm`,onClick:v,disabled:T||k.blockedReason!==null,children:T?`Starting…`:GA(k.status)}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:k.branch})]}),k.blockedReason?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:k.blockedReason}):null,E?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:E}):null]}):null,O?(0,K.jsx)(_A,{cardId:O.id,blockers:c?.blockers??ej,candidates:i??YA,socket:t,onChanged:g,onError:f}):null,A?(0,K.jsxs)(`section`,{className:`space-y-2 border border-border p-3`,children:[(0,K.jsxs)(`p`,{className:`text-13 text-foreground [text-wrap:pretty]`,children:[`This card is done. What should happen to `,(0,K.jsx)(`span`,{className:`font-mono`,children:A.branch}),`?`]}),(0,K.jsx)(`p`,{className:`text-13 tabular-nums text-muted-foreground`,children:JA(A)}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(U,{size:`sm`,onClick:b,disabled:D||M!==null,children:`Merge`}),(0,K.jsx)(U,{variant:`secondary`,size:`sm`,onClick:x,disabled:D||j!==null,children:`Discard worktree`}),(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:S,disabled:D,children:`Leave it`})]}),j?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:j}):null,M?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:M}):null]}):null,F.length>0?(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Linked chat`}),(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:F.map(e=>(0,K.jsx)(gj,{chatId:e.targetId,chat:I[e.targetId]},e.targetId))})]}):null,P.length>0?(0,K.jsx)(`dl`,{className:`space-y-3 text-13`,children:P.map(e=>(0,K.jsx)(aj,{field:e,value:N[e.id],onCommit:w,readOnly:ee},e.id))}):null,(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Comments`}),c&&c.comments.length===0?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Nothing recorded yet.`}):null,(0,K.jsx)(`ul`,{className:`space-y-3`,children:(c?.comments??[]).map(e=>(0,K.jsxs)(`li`,{className:`border-b border-border pb-3 last:border-b-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:yA(e.author.kind)}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-13 text-foreground`,children:e.body})]},e.id))})]})]}),(0,K.jsxs)(`footer`,{className:`space-y-2 border-t border-border px-4 py-3`,children:[(0,K.jsx)(ti,{value:u,onChange:C,rows:2,placeholder:`Record what you did…`,"aria-label":`New comment`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(U,{size:`sm`,onClick:h,disabled:u.trim()===``,children:`Comment`}),(0,K.jsx)(U,{variant:`ghost`,size:`sm`,className:`ml-auto text-destructive-text`,onClick:_,children:`Archive`})]})]})]})}function aj({field:e,value:t,onCommit:n,readOnly:r}){let i=e.kind===`longtext`;return(0,K.jsxs)(`div`,{className:i?`space-y-1`:`flex gap-3`,children:[(0,K.jsx)(`dt`,{className:B(`shrink-0 text-muted-foreground`,i?`text-xs font-medium`:`w-20 pt-0.5`),children:e.label}),(0,K.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(sj,{field:e,value:t,onCommit:n,readOnly:r})})]})}function oj({field:e,value:t}){let n=AA(e,t);return(0,K.jsx)(`span`,{className:B(`px-1.5 py-0.5 text-13`,n===``?`text-muted-foreground`:`text-foreground`),children:n===``?cj(e):n})}function sj({readOnly:e,...t}){if(e)return(0,K.jsx)(oj,{field:t.field,value:t.value});switch(t.field.kind){case`select`:return(0,K.jsx)(mj,{...t});case`multiselect`:return(0,K.jsx)(hj,{...t});default:return(0,K.jsx)(dj,{...t})}}function cj(e){return e.required?`Required`:`Empty`}function lj({token:e}){return e?(0,K.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,Xs[e])}):null}var uj={url:`url`,number:`number`,date:`date`};function dj({field:e,value:t,onCommit:n}){let r=pA.useScopedStoreApi(),i=pA.useScopedStore(t=>t.editingFieldId===e.id),a=pA.useScopedStore(e=>e.fieldDraft),o=(0,G.useCallback)(()=>{r.getState().beginFieldEdit(e.id,OA(e,t))},[e,t,r]),s=(0,G.useCallback)(e=>{r.getState().setFieldDraft(e.currentTarget.value)},[r]),c=(0,G.useCallback)(()=>{let t=r.getState().takeFieldDraft(e.id);t!==null&&n(e.id,kA(e,t))},[e,n,r]),l=(0,G.useCallback)(t=>{t.key===`Escape`?r.getState().cancelFieldEdit():t.key===`Enter`&&e.kind!==`longtext`&&c()},[e.kind,c,r]),u=(0,G.useCallback)(e=>{e?.focus()},[]),d=e.kind===`number`||e.kind===`date`,f=AA(e,t);if(i)return e.kind===`longtext`?(0,K.jsx)(ti,{ref:u,value:a,"aria-label":e.label,rows:Math.min(20,Math.max(3,a.split(`
20
+ `).length+1)),onChange:s,onBlur:c,onKeyDown:l}):(0,K.jsx)(`input`,{ref:u,type:uj[e.kind]??`text`,value:a,"aria-label":e.label,"aria-required":e.required||void 0,onChange:s,onBlur:c,onKeyDown:l,className:B(`w-full rounded-md border border-border bg-background px-1.5 py-0.5 text-13 text-foreground`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,d&&`tabular-nums`)});let p=(0,K.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,onClick:o,className:B(`rounded-md px-1.5 py-0.5 text-left hover:bg-secondary`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,f===``?`text-muted-foreground`:`text-foreground`,d&&`tabular-nums`,e.kind===`longtext`&&`block w-full whitespace-pre-wrap text-sm leading-relaxed [text-wrap:pretty]`),children:f===``?cj(e):f});return e.kind===`url`&&f!==``?(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,K.jsxs)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-w-0 items-center gap-1 truncate text-info-text hover:underline`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:f.replace(/^https:\/\//,``)}),(0,K.jsx)(Xi,{"aria-hidden":!0,className:`size-3 shrink-0`})]}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,onClick:o,className:`shrink-0 rounded-md p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:(0,K.jsx)(Sn,{"aria-hidden":!0,className:`size-3`})})]}):p}var fj=`c`,pj=mA(`o`);function mj({field:e,value:t,onCommit:n}){let r=wA(t),i=(0,G.useCallback)(t=>{let r=pj.decode(t);n(e.id,r===null?null:kA(e,r))},[e,n]);return(0,K.jsxs)(Ft,{value:r===null?fj:pj.encode(r),onValueChange:i,children:[(0,K.jsx)(Dt,{"aria-label":e.label,className:`h-8 px-2 text-13 [&>span]:flex [&>span]:min-w-0 [&>span]:items-center [&>span]:gap-2`,children:(0,K.jsx)(Mt,{placeholder:cj(e)})}),(0,K.jsxs)(jt,{children:[(0,K.jsx)(kt,{value:fj,children:cj(e)}),CA(e).map(e=>(0,K.jsx)(kt,{value:pj.encode(e.id),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(lj,{token:e.colorToken}),e.label]})},e.id))]})]})}function hj({field:e,value:t,onCommit:n}){let r=TA(t),i=(0,G.useCallback)(r=>{let i=DA(t,r.currentTarget.value);n(e.id,i.length===0?null:{kind:`multiselect`,optionIds:i})},[e.id,n,t]),a=CA(e);return a.length===0?(0,K.jsx)(`span`,{className:`px-1.5 text-muted-foreground`,children:cj(e)}):(0,K.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:a.map(e=>{let t=r.includes(e.id);return(0,K.jsxs)(`button`,{type:`button`,value:e.id,"aria-label":e.label,"aria-pressed":t,onClick:i,className:B(`flex items-center gap-1.5 rounded-md border px-1.5 py-0.5`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,t?`border-border font-medium text-foreground`:`border-transparent text-muted-foreground hover:bg-secondary`),children:[(0,K.jsx)(lj,{token:e.colorToken}),e.label]},e.id)})})}function gj({chatId:e,chat:t}){let n=(0,G.useCallback)(()=>{XA(e)},[e]);if(!t)return(0,K.jsx)(`li`,{className:`px-1.5 py-1 text-13 text-muted-foreground`,children:`This chat no longer exists.`});let r=ki(t),i=xA(t.activity);return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left hover:bg-secondary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-3 w-1.5 shrink-0 items-center`,children:r?(0,K.jsx)(`span`,{className:B(`size-1.5 rounded-full`,Ki(r.tone))}):null}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-13 text-foreground`,children:t.title}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r?.label??Ir(t.status)})]}),i.map(e=>(0,K.jsx)(`p`,{"data-work-row":!0,className:`px-3.5 py-0.5 text-xs text-muted-foreground`,children:e},e))]})}var _j={repoDraft:``,direction:`pull`,allowAgentPush:!1,rowDirections:{}},vj=Qn(`BoardSyncPanel`,()=>e=>({status:null,error:null,saving:!1,savingRow:null,confirmingDetach:null,..._j,setStatus:t=>e({status:t,error:null,savingRow:null,confirmingDetach:null,..._j}),setRepoDraft:t=>e({repoDraft:t}),setDirection:t=>e({direction:t}),setAllowAgentPush:t=>e({allowAgentPush:t}),setRowDirection:(t,n)=>e(e=>({rowDirections:{...e.rowDirections,[t]:n}})),setSavingRow:t=>e({savingRow:t}),setConfirmingDetach:t=>e({confirmingDetach:t}),setError:t=>e({error:t}),beginSave:()=>e({saving:!0,error:null}),endSave:()=>e({saving:!1})})),yj=/^[A-Za-z0-9._-]+$/u;function bj(e){let t=e.trim().replace(/\.git$/u,``);if(t===``)return null;let n=t.replace(/^https?:\/\/(?:www\.)?github\.com\//iu,``).replace(/^git@github\.com:/iu,``).replace(/^ssh:\/\/git@github\.com\//iu,``).split(`/`).filter(e=>e!==``);if(n.length!==2)return null;let[r,i]=n;return!r||!i||!yj.test(r)||!yj.test(i)?null:{owner:r,repo:i}}function xj(e){return`${e.owner}/${e.repo}`}function Sj(e,t){return e.owner===t.owner&&e.repo===t.repo}function Cj(e){return e.provider===`github-issues`?xj(e):null}var wj=[{value:`pull`,label:`Pull`},{value:`push`,label:`Push`},{value:`both`,label:`Both`}];function Tj(e){let t=e.resolvedAs===`local`?`kept yours`:`took theirs`;return`${e.field} changed in both places · ${t}`}function Ej({bindingId:e,onDisconnect:t}){let n=(0,G.useCallback)(()=>{t(e)},[e,t]);return(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Disconnect ${e}`,className:`shrink-0 rounded-md p-1 text-muted-foreground hover:bg-secondary hover:text-destructive-text`,children:(0,K.jsx)(Mn,{className:`size-3.5`})})}function Dj({label:e,column:t,absent:n}){return(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(`dt`,{className:`w-28 shrink-0 text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:t?`min-w-0 break-words text-foreground`:`min-w-0 break-words text-muted-foreground`,children:t?.title??n})]})}function Oj(e,t){if(!e.repo)return!1;let n=e.repo;return t.some(e=>e.sourceRef.provider===`github-issues`&&Sj(e.sourceRef,n))}function kj(e,t){return t?e?`Moving…`:`Connecting…`:e?`Move here`:`Connect`}function Aj({suggestion:e,direction:t,isConfirming:n,isSaving:r,onConnect:i,onSetDirection:a,onCancelDetach:o}){let s=(0,G.useCallback)(()=>i(e),[i,e]),c=(0,G.useCallback)(t=>a(e.projectId,t),[a,e.projectId]),l=(0,G.useCallback)(()=>o(),[o]),u=e.repo?xj(e.repo):null;return(0,K.jsxs)(`li`,{className:`space-y-2 rounded-md border border-border px-3 py-2.5`,children:[(0,K.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-13 font-medium text-foreground`,children:e.projectName}),(0,K.jsx)(`p`,{className:u?`font-mono text-xs text-muted-foreground`:`text-xs italic text-muted-foreground`,children:u??`No remote configured`})]})}),u&&e.boundTo?(0,K.jsx)(`p`,{className:`text-13 text-warning-text [text-wrap:pretty]`,children:n?`Moving "${u}" will detach it from "${e.boundTo.boardTitle}". Its ${e.boundTo.cardCount} card${e.boundTo.cardCount===1?``:`s`} stay on that board.`:`Already connected to board "${e.boundTo.boardTitle}" (${e.boundTo.cardCount} card${e.boundTo.cardCount===1?``:`s`}).`}):null,u?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Kn,{value:t,onValueChange:c,options:wj,size:`sm`}),(0,K.jsx)(`div`,{className:`flex-1`}),n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:l,disabled:r,children:`Cancel`}),(0,K.jsx)(U,{size:`sm`,onClick:s,disabled:r,children:r?kj(!0,!0):`Confirm move`})]}):(0,K.jsx)(U,{size:`sm`,variant:e.boundTo?`ghost`:`default`,onClick:s,disabled:r,children:kj(e.boundTo!==null,r)})]}):null]})}function jj(e,t){return!e.open&&!e.closed?`This board marks no column as start or done, so pulled issues land in the first column and closing one moves nothing.`:e.open?!e.closed&&t!==`pull`?`No column is marked done, so nothing on this board can close an issue.`:null:`No column is marked start, so pulled issues land in the first column.`}function Mj(e){return(0,K.jsx)(vj.Provider,{init:void 0,children:(0,K.jsx)(Nj,{...e})})}function Nj({boardId:e,socket:t,onClose:n}){let r=vj.useScopedStoreApi(),i=vj.useScopedStore(e=>e.status),a=vj.useScopedStore(e=>e.error),o=vj.useScopedStore(e=>e.saving),s=vj.useScopedStore(e=>e.repoDraft),c=vj.useScopedStore(e=>e.direction),l=vj.useScopedStore(e=>e.allowAgentPush),u=vj.useScopedStore(e=>e.rowDirections),d=vj.useScopedStore(e=>e.savingRow),f=vj.useScopedStore(e=>e.confirmingDetach),{setStatus:p,setError:m,setRepoDraft:h,setDirection:g,setAllowAgentPush:_}=r.getState(),v=(0,G.useCallback)(()=>{t.command({type:`board.sync.status`,boardId:e}).then(p).catch(nr(e=>{m(e.message)}))},[e,m,p,t]);(0,G.useEffect)(()=>{v()},[v]);let y=(0,G.useCallback)((n,i,a)=>{let o=r.getState(),s=i===null?void 0:o.rowDirections[i];return t.command({type:`board.sync.bind`,boardId:e,owner:n.owner,repo:n.repo,direction:s??o.direction,allowAgentPush:o.allowAgentPush,projectId:i,detachFromBoardId:a})},[e,t,r]),b=(0,G.useCallback)(e=>{h(e.currentTarget.value)},[h]),x=(0,G.useCallback)(e=>{_(e.currentTarget.checked)},[_]),S=(0,G.useCallback)(()=>{let e=r.getState(),t=bj(e.repoDraft);if(!t){m(`That is not a repository. Use owner/repo, or paste its GitHub URL.`);return}let n=e.status?.suggestedRepos.find(e=>e.repo&&Sj(e.repo,t));e.beginSave(),y(t,n?.projectId??null,null).then(()=>{r.getState().endSave(),v()}).catch(nr(e=>{r.getState().endSave(),m(e.message)}))},[y,v,m,r]),C=(0,G.useCallback)(n=>{t.command({type:`board.sync.unbind`,boardId:e,bindingId:n}).then(v).catch(nr(e=>{m(e.message)}))},[e,v,m,t]),w=(0,G.useCallback)(e=>{if(!e.repo)return;let t=r.getState();e.boundTo&&t.confirmingDetach!==e.projectId?t.setConfirmingDetach(e.projectId):(t.setSavingRow(e.projectId),t.setConfirmingDetach(null),y(e.repo,e.projectId,e.boundTo?.boardId??null).then(()=>{r.getState().setSavingRow(null),v()}).catch(nr(e=>{r.getState().setSavingRow(null),m(e.message)})))},[y,v,m,r]),T=(0,G.useCallback)(()=>{let e=r.getState();if(!e.status)return;let t=e.status.bindings,n=e.status.suggestedRepos.flatMap(e=>e.repo&&!e.boundTo&&!Oj(e,t)?[{repo:e.repo,projectId:e.projectId}]:[]);n.length!==0&&(e.beginSave(),Promise.all(n.map(e=>y(e.repo,e.projectId,null))).then(()=>{r.getState().endSave(),v()}).catch(nr(e=>{r.getState().endSave(),m(e.message)})))},[y,v,m,r]),E=(0,G.useCallback)((e,t)=>{r.getState().setRowDirection(e,t)},[r]),D=(0,G.useCallback)(()=>{r.getState().setConfirmingDetach(null)},[r]),O=i?jj(i.routing,c):null,k=i?i.suggestedRepos.filter(e=>!Oj(e,i.bindings)):null,A=k?k.filter(e=>e.repo&&!e.boundTo).length:0;return(0,K.jsxs)(`aside`,{className:`absolute inset-y-0 right-0 z-20 flex w-full flex-col border-l border-border bg-background sm:w-[400px]`,"aria-label":`Sync settings`,children:[(0,K.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 text-15 font-semibold leading-snug text-foreground`,children:`Sync`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close sync settings`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,K.jsx)(Mn,{className:`size-4`})})]}),a?(0,K.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:a}):null,i?(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Direction`}),(0,K.jsx)(Kn,{value:c,onValueChange:g,options:wj,size:`sm`})]}),(0,K.jsx)(`section`,{className:`space-y-2`,children:(0,K.jsxs)(`label`,{className:`flex items-start gap-2 text-13 text-foreground`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:l,onChange:x,className:`mt-0.5 accent-primary`}),(0,K.jsxs)(`span`,{children:[`Let agent changes reach GitHub`,(0,K.jsx)(`span`,{className:`block text-muted-foreground`,children:`Off by default. An agent moving a card to done would otherwise close the issue.`})]})]})}),k&&k.length>0?(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`flex-1 text-xs font-medium text-muted-foreground`,children:k.length===1?`Repository`:`Repositories`}),A>1?(0,K.jsx)(U,{size:`sm`,onClick:T,disabled:o,children:o?`Connecting…`:`Connect all ${A}`}):null]}),(0,K.jsx)(`ul`,{className:`space-y-2`,children:k.map(e=>(0,K.jsx)(Aj,{suggestion:e,direction:u[e.projectId]??c,isConfirming:f===e.projectId,isSaving:d===e.projectId,onConnect:w,onSetDirection:E,onCancelDetach:D},e.projectId))})]}):null,(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`board-sync-repo`,children:k&&k.length>0?`Or connect another repository`:`GitHub repository`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($n,{id:`board-sync-repo`,value:s,onChange:b,placeholder:`owner/repo`,spellCheck:!1,className:`flex-1 font-mono text-13`}),(0,K.jsx)(U,{size:`sm`,onClick:S,disabled:o||s.trim().length===0,children:o?`Saving…`:`Connect`})]})]}),i.bindings.length>0?(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Connected repositories`}),(0,K.jsx)(`ul`,{className:`space-y-1`,children:i.bindings.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-13 text-foreground`,children:Cj(e.sourceRef)??e.providerId}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.direction}),(0,K.jsx)(Ej,{bindingId:e.id,onDisconnect:C})]},e.id))})]}):null,(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Where issues land`}),(0,K.jsxs)(`dl`,{className:`space-y-2 text-13`,children:[(0,K.jsx)(Dj,{label:`Open issues`,column:i.routing.open,absent:`First column`}),(0,K.jsx)(Dj,{label:`Closed issues`,column:i.routing.closed,absent:`Nowhere`})]}),O?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground [text-wrap:pretty]`,children:O}):null]}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Conflicts`}),i.conflicts.length===0?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Nothing has changed in both places.`}):(0,K.jsx)(`ul`,{className:`space-y-2`,children:i.conflicts.map(e=>(0,K.jsxs)(`li`,{className:`border-b border-border pb-2 text-13 last:border-b-0`,children:[(0,K.jsx)(`p`,{className:`text-foreground`,children:Tj(e)}),(0,K.jsx)(`p`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.cardId})]},e.id))})]})]}):(0,K.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading sync settings…`})})]})}function Pj({token:e,selected:t,label:n,onSelect:r}){return(0,K.jsx)(`button`,{type:`button`,value:e??``,onClick:r,"aria-label":n,"aria-pressed":t,className:B(`flex size-6 items-center justify-center rounded-md border`,t?`border-ring`:`border-transparent hover:border-border`),children:(0,K.jsx)(`span`,{"aria-hidden":!0,className:B(`size-2 rounded-full`,e?Xs[e]:`border border-border bg-transparent`)})})}var Fj=[`project`,`stack`],Ij=[`start`,`active`,`review`,`done`],Lj=[`muted-icon`,`info`,`success`,`warning`,`destructive`],Rj=ar(Lj),zj=[`text`,`longtext`,`url`,`number`,`date`,`select`,`multiselect`,`label`],Bj=[`chat`,`worktree`,`pr`,`card`,`cleanup_declined`,`blocked_by`],Vj=[`state`,`label`,`projectField`],Hj=[`pull`,`push`,`both`],Uj=[`create`,`update`,`move`,`close`],Wj=ar(Ij),Gj=ar(zj);ar(Hj),ar(Vj),ar(Uj),ar(Fj),ar(Bj);var Kj={text:`Text`,longtext:`Long text`,url:`Link`,number:`Number`,date:`Date`,select:`Single choice`,multiselect:`Multiple choice`,label:`Tags`};function qj(e){return e===`select`||e===`multiselect`}function Jj(e){let t=e.toLowerCase().split(/[^a-z0-9]+/).filter(e=>e!==``);return t.length===0?`field`:t.map((e,t)=>t===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function Yj(e,t){return sM(Jj(e),new Set(t.map(e=>e.id)))}function Xj(e,t){return sM(Jj(e),new Set(t.map(e=>e.id)))}function Zj(e,t,n){let r=t.trim();return r===``?e:[...e,{id:Yj(r,e),label:r,kind:n,options:qj(n)?[]:null,required:!1}]}function Qj(e,t,n){return cM(e,t,e=>({...e,label:n}))}function $j(e,t){return cM(e,t,e=>({...e,required:!e.required}))}function eM(e,t){return e.filter(e=>e.id!==t)}function tM(e,t,n){let r=e.findIndex(e=>e.id===t),i=r+n;if(r===-1||i<0||i>=e.length)return e;let a=[...e],o=a[r],s=a[i];return!o||!s?e:(a[i]=o,a[r]=s,a)}function nM(e,t,n){let r=n.trim();return r===``?e:lM(e,t,e=>[...e,{id:Xj(r,e),label:r,colorToken:null}])}function rM(e,t,n,r){return lM(e,t,e=>e.map(e=>e.id===n?{...e,label:r}:e))}function iM(e,t,n){return lM(e,t,e=>e.filter(e=>e.id!==n))}function aM(e,t,n,r){let i=Rj(r)?r:null;return lM(e,t,e=>e.map(e=>e.id===n?{...e,colorToken:i}:e))}function oM(e){let t=new Set(e.map(e=>e.id));return IA.filter(e=>!t.has(e))}function sM(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}${String(n)}`);)n+=1;return`${e}${String(n)}`}function cM(e,t,n){return e.map(e=>e.id===t?n(e):e)}function lM(e,t,n){return cM(e,t,e=>e.options===null?e:{...e,options:n(e.options)})}var uM={};function dM(e){return t=>({draft:e,newLabel:``,newKind:`text`,optionDraftByField:uM,pendingRemovalFieldId:null,saving:!1,error:null,setNewLabel:e=>t({newLabel:e}),setNewKind:e=>t({newKind:Gj(e)?e:`text`}),addField:()=>t(e=>({draft:Zj(e.draft,e.newLabel,e.newKind),newLabel:``})),renameField:(e,n)=>t(t=>({draft:Qj(t.draft,e,n)})),moveField:(e,n)=>t(t=>({draft:tM(t.draft,e,n)})),toggleRequired:e=>t(t=>({draft:$j(t.draft,e)})),askRemoveField:e=>t({pendingRemovalFieldId:e}),cancelRemoveField:()=>t({pendingRemovalFieldId:null}),removeField:e=>t(t=>({draft:eM(t.draft,e),pendingRemovalFieldId:null})),setOptionDraft:(e,n)=>t(t=>({optionDraftByField:{...t.optionDraftByField,[e]:n}})),addOption:e=>t(t=>({draft:nM(t.draft,e,t.optionDraftByField[e]??``),optionDraftByField:{...t.optionDraftByField,[e]:``}})),renameOption:(e,n,r)=>t(t=>({draft:rM(t.draft,e,n,r)})),removeOption:(e,n)=>t(t=>({draft:iM(t.draft,e,n)})),setOptionColor:(e,n,r)=>t(t=>({draft:aM(t.draft,e,n,r)})),beginSave:()=>t({saving:!0,error:null}),endSave:e=>t({saving:!1,error:e})})}var fM=Qn(`CardSchemaPanel`,dM);function pM({fields:e,...t}){return(0,K.jsx)(fM.Provider,{init:e,children:(0,K.jsx)(mM,{...t})})}function mM({boardId:e,socket:t,onClose:n}){let r=fM.useScopedStoreApi(),i=fM.useScopedStore(e=>e.draft),a=fM.useScopedStore(e=>e.newLabel),o=fM.useScopedStore(e=>e.newKind),s=fM.useScopedStore(e=>e.saving),c=fM.useScopedStore(e=>e.error),l=(0,G.useCallback)(e=>{r.getState().setNewLabel(e.currentTarget.value)},[r]),u=(0,G.useCallback)(e=>{r.getState().setNewKind(e.currentTarget.value)},[r]),d=(0,G.useCallback)(()=>{r.getState().addField()},[r]),f=(0,G.useCallback)(()=>{let i=r.getState();i.beginSave(),t.command({type:`board.update`,boardId:e,cardFields:i.draft}).then(()=>{r.getState().endSave(null),n()}).catch(nr(e=>{r.getState().endSave(e.message)}))},[e,n,t,r]),p=oM(i);return(0,K.jsxs)(`aside`,{className:`absolute inset-y-0 right-0 z-20 flex w-full flex-col border-l border-border bg-background sm:w-[400px]`,"aria-label":`Card fields`,children:[(0,K.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 text-15 font-semibold leading-snug text-foreground`,children:`Card fields`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close card fields`,className:`rounded-md p-1 text-muted-foreground hover:bg-secondary`,children:(0,K.jsx)(Mn,{className:`size-4`})})]}),c?(0,K.jsx)(`p`,{className:`px-4 py-2 text-13 text-destructive-text`,children:c}):null,(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4`,children:[(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground [text-wrap:pretty]`,children:`What every card on this board has, in the order the card opens them. Cards keep the values of a field you remove, and get them back if you add it again.`}),i.length===0?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`No fields yet, so cards on this board are title-only.`}):(0,K.jsx)(`ul`,{className:`space-y-4`,children:i.map((e,t)=>(0,K.jsx)(hM,{field:e,first:t===0,last:t===i.length-1},e.id))}),(0,K.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-4`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Add a field`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)($n,{"aria-label":`New field name`,value:a,onChange:l,placeholder:`Name`,className:`min-w-0 flex-1`}),(0,K.jsx)(`select`,{"aria-label":`New field kind`,value:o,onChange:u,className:`rounded-md border border-border bg-background px-2 py-1.5 text-13 text-foreground`,children:zj.map(e=>(0,K.jsx)(`option`,{value:e,children:Kj[e]},e))})]}),(0,K.jsx)(U,{size:`sm`,variant:`secondary`,onClick:d,disabled:a.trim()===``,children:`Add field`}),p.length>0?(0,K.jsxs)(`p`,{className:`text-13 text-muted-foreground [text-wrap:pretty]`,children:[`Not on this board: `,(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:p.join(`, `)}),`. GitHub sync and Start work read those ids by name, and quietly do less without them.`]}):null]})]}),(0,K.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border px-4 py-3`,children:[(0,K.jsx)(U,{size:`sm`,onClick:f,disabled:s,children:s?`Saving…`:`Save`}),(0,K.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`Nothing is written until you save.`})]})]})}function hM({field:e,first:t,last:n}){let r=fM.useScopedStoreApi(),i=fM.useScopedStore(t=>t.pendingRemovalFieldId===e.id),a=fM.useScopedStore(t=>t.optionDraftByField[e.id]??``),o=e.id,s=(0,G.useCallback)(e=>{r.getState().renameField(o,e.currentTarget.value)},[o,r]),c=(0,G.useCallback)(()=>{r.getState().moveField(o,-1)},[o,r]),l=(0,G.useCallback)(()=>{r.getState().moveField(o,1)},[o,r]),u=(0,G.useCallback)(()=>{r.getState().toggleRequired(o)},[o,r]),d=(0,G.useCallback)(()=>{r.getState().askRemoveField(o)},[o,r]),f=(0,G.useCallback)(()=>{r.getState().cancelRemoveField()},[r]),p=(0,G.useCallback)(()=>{r.getState().removeField(o)},[o,r]),m=(0,G.useCallback)(e=>{r.getState().setOptionDraft(o,e.currentTarget.value)},[o,r]),h=(0,G.useCallback)(()=>{r.getState().addOption(o)},[o,r]),g=VA(e.id);return(0,K.jsxs)(`li`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)($n,{"aria-label":`Name of the ${e.id} field`,value:e.label,onChange:s,className:`min-w-0 flex-1`}),(0,K.jsx)(_M,{label:`Move ${e.label} up`,onClick:c,disabled:t,children:(0,K.jsx)(At,{"aria-hidden":!0,className:`size-4`})}),(0,K.jsx)(_M,{label:`Move ${e.label} down`,onClick:l,disabled:n,children:(0,K.jsx)(Pi,{"aria-hidden":!0,className:`size-4`})}),(0,K.jsx)(_M,{label:`Remove ${e.label}`,onClick:d,destructive:!0,children:(0,K.jsx)(Dn,{"aria-hidden":!0,className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-13 text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.id}),(0,K.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,K.jsx)(`span`,{children:Kj[e.kind]}),(0,K.jsxs)(`label`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.label} is required`,checked:e.required,onChange:u,className:`accent-primary`}),(0,K.jsx)(`span`,{children:`Required`})]})]}),i?(0,K.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border p-2`,children:[(0,K.jsxs)(`p`,{className:`text-13 text-foreground [text-wrap:pretty]`,children:[`Remove `,e.label,`? Cards keep the values they already have, and get them back if this field comes back.`]}),g?(0,K.jsx)(`p`,{className:`text-13 text-destructive-text [text-wrap:pretty]`,children:g}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(U,{size:`sm`,variant:`ghost`,className:`text-destructive-text`,onClick:p,children:`Remove`}),(0,K.jsx)(U,{size:`sm`,variant:`secondary`,onClick:f,children:`Keep`})]})]}):null,e.options===null?null:(0,K.jsxs)(`div`,{className:`space-y-2 border-l border-border pl-3`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Options`}),e.options.length===0?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`No options yet, so this field offers nothing.`}):(0,K.jsx)(`ul`,{className:`space-y-2`,children:e.options.map(t=>(0,K.jsx)(gM,{fieldId:e.id,option:t},t.id))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)($n,{"aria-label":`New option for ${e.label}`,value:a,onChange:m,placeholder:`Name`,className:`min-w-0 flex-1`}),(0,K.jsx)(U,{size:`sm`,variant:`secondary`,onClick:h,disabled:a.trim()===``,children:`Add option`})]})]})]})}function gM({fieldId:e,option:t}){let n=fM.useScopedStoreApi(),r=t.id,i=(0,G.useCallback)(t=>{n.getState().renameOption(e,r,t.currentTarget.value)},[e,r,n]),a=(0,G.useCallback)(t=>{n.getState().setOptionColor(e,r,t.currentTarget.value)},[e,r,n]),o=(0,G.useCallback)(()=>{n.getState().removeOption(e,r)},[e,r,n]);return(0,K.jsxs)(`li`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)($n,{"aria-label":`Name of the ${t.id} option`,value:t.label,onChange:i,className:`min-w-0 flex-1`}),(0,K.jsx)(_M,{label:`Remove option ${t.label}`,onClick:o,destructive:!0,children:(0,K.jsx)(Dn,{"aria-hidden":!0,className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Pj,{token:null,label:`Colour ${t.id} none`,selected:t.colorToken===null,onSelect:a}),Lj.map(e=>(0,K.jsx)(Pj,{token:e,label:`Colour ${t.id} ${e}`,selected:t.colorToken===e,onSelect:a},e))]})]})}function _M({label:e,onClick:t,disabled:n,destructive:r,children:i}){return(0,K.jsx)(`button`,{type:`button`,"aria-label":e,onClick:t,disabled:n,className:r?`shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-secondary hover:text-destructive-text disabled:opacity-40`:`shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-40`,children:i})}function vM(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function yM(e){if(Array.isArray(e))return e}function bM(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function xM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function SM(e,t){if(e){if(typeof e==`string`)return xM(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xM(e,t):void 0}}function CM(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
21
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wM(e,t){return yM(e)||bM(e,t)||SM(e,t)||CM()}var TM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bind=void 0;function t(e,t){var n=t.type,r=t.listener,i=t.options;return e.addEventListener(n,r,i),function(){e.removeEventListener(n,r,i)}}e.bind=t})),EM=t(((e,t,n)=>{var r=n&&n.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=void 0;var i=TM();function a(e){if(e!==void 0)return typeof e==`boolean`?{capture:e}:e}function o(e,t){return t==null?e:r(r({},e),{options:r(r({},a(t)),a(e.options))})}function s(e,t,n){var r=t.map(function(t){var r=o(t,n);return(0,i.bind)(e,r)});return function(){r.forEach(function(e){return e()})}}e.bindAll=s})),DM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=TM();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=EM();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})}))(),OM=`data-pdnd-honey-pot`;function kM(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function AM(e){var t=wM(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?kM(n)?r??null:n:null}function jM(e){"@babel/helpers - typeof";return jM=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},jM(e)}function MM(e,t){if(jM(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(jM(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NM(e){var t=MM(e,`string`);return jM(t)==`symbol`?t:t+``}function PM(e,t,n){return(t=NM(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var FM=2147483647,IM={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function LM(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var RM=LM(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function zM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zM(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zM(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var VM=2,HM=VM/2;function UM(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function WM(e){return{x:e.x-HM,y:e.y-HM}}function GM(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function KM(e){return{x:Math.min(e.x,window.innerWidth-VM),y:Math.min(e.y,window.innerHeight-VM)}}function qM(e){var t=e.client,n=KM(GM(WM(UM(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:VM,height:VM})}function JM(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function YM(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function XM(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(OM,`true`),RM()&&n.setAttribute(`popover`,`manual`);var r=qM({client:t});Object.assign(n.style,BM(BM({position:`fixed`},RM()?IM:{zIndex:FM}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},JM({clientRect:r}))),document.body.appendChild(n),RM()&&n.showPopover();var i=(0,DM.bind)(window,{type:`pointermove`,listener:function(e){r=qM({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,JM({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),YM({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,DM.bindAll)(window,[{type:`pointerdown`,listener:a},{type:`pointermove`,listener:a},{type:`focusin`,listener:a},{type:`focusout`,listener:a},{type:`dragstart`,listener:a},{type:`dragenter`,listener:a},{type:`dragover`,listener:a}],{capture:!0})}}function ZM(){var e=null;function t(){return e=null,(0,DM.bind)(window,{type:`pointermove`,listener:function(t){e={x:t.clientX,y:t.clientY}},options:{capture:!0}})}function n(){var t=null;return function(n){var r=n.eventName,i=n.payload;if(r===`onDragStart`){var a=i.location.initial.input;t=XM({initial:e??{x:a.clientX,y:a.clientY}})}if(r===`onDrop`){var o,s=i.location.current.input;(o=t)==null||o({current:{x:s.clientX,y:s.clientY}}),t=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}function QM(e){if(Array.isArray(e))return xM(e)}function $M(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function eN(){throw TypeError(`Invalid attempt to spread non-iterable instance.
22
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tN(e){return QM(e)||$M(e)||SM(e)||eN()}var nN=LM(function(){return navigator.userAgent.includes(`Firefox`)}),rN=LM(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)});function iN(e){return`nodeName`in e}function aN(e){return iN(e)&&e.ownerDocument!==document}var oN={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};(function(){if(typeof window>`u`||!rN())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,DM.bindAll)(window,[{type:`dragstart`,listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:`drop`,listener:n},{type:`dragend`,listener:n},{type:`dragenter`,listener:function(e){!t.isOverWindow&&t.enterCount===0&&(e[oN.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[oN.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function sN(e){var t=e.dragLeave;return rN()?t.hasOwnProperty(oN.isLeavingWindow):!1}function cN(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?rN()?sN({dragLeave:t}):r==null?!0:nN()?aN(r):r instanceof HTMLIFrameElement:!1}function lN(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){e<20?e++:t()}}()},{type:`pointerdown`,listener:t}]}function uN(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var dN=function(e){var t=[],n=null,r=function(){t=[...arguments],!n&&(n=requestAnimationFrame(function(){n=null,e.apply(void 0,t)}))};return r.cancel=function(){n&&=(cancelAnimationFrame(n),null)},r},fN=dN(function(e){return e()}),pN=function(){var e=null;function t(t){e={frameId:requestAnimationFrame(function(){e=null,t()}),fn:t}}function n(){e&&=(cancelAnimationFrame(e.frameId),e.fn(),null)}return{schedule:t,flush:n}}();function mN(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(e){r(e),i={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var r=e.nativeSetDragImage,o={current:n,previous:i,initial:n};a({eventName:`onGenerateDragPreview`,payload:{source:t,location:o,nativeSetDragImage:r}}),pN.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;pN.flush(),fN.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;fN(function(){pN.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;pN.flush(),fN.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var hN={isActive:!1};function gN(){return!hN.isActive}function _N(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function vN(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function yN(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!gN())return;var a=xN({event:t,dragType:n,getDropTargetsOver:r});hN.isActive=!0;var o={current:a};bN({event:t,current:a.dropTargets});var s=mN({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=vN({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=uN(e),i=r({target:kM(e.target)?AM({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),bN({event:e,current:i})),c({dropTargets:i,input:t})}function u(){o.current.dropTargets.length&&c({dropTargets:[],input:o.current.input}),s.drop({current:o.current,updatedSourcePayload:null}),d()}function d(){hN.isActive=!1,f()}var f=(0,DM.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){cN({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:uN(e)},o.current.dropTargets.length?(e.preventDefault(),bN({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()):u()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:uN(e)},u()}}].concat(tN(lN({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:_N(t)})}function bN(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function xN(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=uN(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var SN={canStart:gN,start:yN},CN=new Map;function wN(e){var t=e.typeKey,n=e.mount,r=CN.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return CN.set(t,i),i}function TN(e){var t=wN(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),CN.delete(e.typeKey))}}function EN(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function DN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ON(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?DN(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DN(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kN(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=AN(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
23
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function AN(e,t){if(e){if(typeof e==`string`)return jN(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jN(e,t):void 0}}function jN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function MN(e){return e.slice(0).reverse()}function NN(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i=`data-drop-target-for-${t}`,a=`[${i}]`;function o(e){return r.set(e.element,e),function(){return r.delete(e.element)}}function s(e){return LM(vM(EN(e.element,{attribute:i,value:`true`}),o(e)))}function c(e){var t=e.source,i=e.target,o=e.input,s=e.result,l=s===void 0?[]:s;if(i==null)return l;if(!(i instanceof Element))return i instanceof Node?c({source:t,target:i.parentElement,input:o,result:l}):l;var u=i.closest(a);if(u==null)return l;var d=r.get(u);if(d==null)return l;var f={input:o,source:t,element:d.element};if(d.canDrop&&!d.canDrop(f))return c({source:t,target:d.element.parentElement,input:o,result:l});var p=d.getData?.call(d,f)??{},m=d.getDropEffect?.call(d,f)??n,h={data:p,element:d.element,dropEffect:m,isActiveDueToStickiness:!1};return c({source:t,target:d.element.parentElement,input:o,result:[].concat(tN(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=kN(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=ON(ON({},n),{},{self:s});c==null||(o=c[t])==null||o.call(c,l)}}catch(e){i.e(e)}finally{i.f()}}var u={onGenerateDragPreview:l,onDrag:l,onDragStart:l,onDrop:l,onDropTargetChange:function(e){var t=e.payload,n=new Set(t.location.current.dropTargets.map(function(e){return e.element})),i=new Set,a=kN(t.location.previous.dropTargets),o;try{for(a.s();!(o=a.n()).done;){var s,c=o.value;i.add(c.element);var l=r.get(c.element),u=n.has(c.element),d=ON(ON({},t),{},{self:c});if(l==null||(s=l.onDropTargetChange)==null||s.call(l,d),!u){var f;l==null||(f=l.onDragLeave)==null||f.call(l,d)}}}catch(e){a.e(e)}finally{a.f()}var p=kN(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=ON(ON({},t),{},{self:_}),y=r.get(_.element);y==null||(h=y.onDropTargetChange)==null||h.call(y,v),y==null||(g=y.onDragEnter)==null||g.call(y,v)}}}catch(e){p.e(e)}finally{p.f()}}};function d(e){u[e.eventName](e)}function f(e){var t=e.source,n=e.target,i=e.input,a=e.current,o=c({source:t,target:n,input:i});if(o.length>=a.length)return o;for(var s=MN(a),l=MN(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null)u.push(m);else{var h=u[d-1],g=s[d-1];if(h?.element!==g?.element)break;var _=r.get(p.element);if(!_)break;var v={input:i,source:t,element:_.element};if(_.canDrop&&!_.canDrop(v)||!((f=_.getIsSticky)!=null&&f.call(_,v)))break;u.push(ON(ON({},p),{},{isActiveDueToStickiness:!0}))}}return MN(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function PN(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=FN(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
24
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function FN(e,t){if(e){if(typeof e==`string`)return IN(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?IN(e,t):void 0}}function IN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function LN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function RN(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?LN(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LN(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zN(){var e=new Set,t=null;function n(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}function r(r){var i=RN({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return LM(a)}function i(r){var i=r.eventName,a=r.payload;if(i===`onGenerateDragPreview`){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var o=PN(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;n(c)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var l=Array.from(t.active),u=0,d=l;u<d.length;u++){var f=d[u];if(t.active.has(f)){var p;(p=f[i])==null||p.call(f,a)}}i===`onDrop`&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function BN(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=zN(),s=NN({typeKey:t,defaultDropEffect:a});function c(e){r?.(e),s.dispatchEvent(e),o.dispatchEvent(e),i?.(e)}function l(e){var t=e.event,n=e.dragType;SN.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:SN.canStart,start:l})}return TN({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var VN=LM(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),HN=`pdnd:android-fallback`,UN=`text/plain`,WN=`application/vnd.pdnd`,GN=new WeakMap;function KN(e){return GN.set(e.element,e),function(){GN.delete(e.element)}}var qN=ZM(),JN=BN({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return vM(qN.bindEvents(),(0,DM.bind)(document,{type:`dragstart`,listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var n=t.target;if(n instanceof HTMLElement){var r=GN.get(n);if(r){var i=uN(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a))t.preventDefault();else{if(r.dragHandle){var o=AM({x:i.clientX,y:i.clientY});if(!r.dragHandle.contains(o)){t.preventDefault();return}}var s=r.getInitialDataForExternal?.call(r,a)??null;if(s)for(var c=0,l=Object.entries(s);c<l.length;c++){var u=wM(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}VN()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(UN,HN),t.dataTransfer.setData(WN,``);var p={type:`element`,payload:{element:r.element,dragHandle:r.dragHandle??null,data:r.getInitialData?.call(r,a)??{}},startedFrom:`internal`};e.start({event:t,dragType:p})}}}}}}))},dispatchEventToSource:function(e){var t,n,r=e.eventName,i=e.payload;(t=GN.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:qN.getOnPostDispatch()}),YN=JN.dropTarget;JN.monitor;function XN(e){return LM(vM(JN.registerUsage(),KN(e),EN(e.element,{attribute:`draggable`,value:`true`})))}var ZN=`data-pdnd-honey-pot`;function QN(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function $N(e){var t=wM(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?QN(n)?r??null:n:null}var eP=2147483647,tP={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function nP(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var rP=nP(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function iP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aP(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iP(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var oP=2,sP=oP/2;function cP(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function lP(e){return{x:e.x-sP,y:e.y-sP}}function uP(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function dP(e){return{x:Math.min(e.x,window.innerWidth-oP),y:Math.min(e.y,window.innerHeight-oP)}}function fP(e){var t=e.client,n=dP(uP(lP(cP(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:oP,height:oP})}function pP(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function mP(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function hP(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(ZN,`true`),rP()&&n.setAttribute(`popover`,`manual`);var r=fP({client:t});Object.assign(n.style,aP(aP({position:`fixed`},rP()?tP:{zIndex:eP}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},pP({clientRect:r}))),document.body.appendChild(n),rP()&&n.showPopover();var i=(0,DM.bind)(window,{type:`pointermove`,listener:function(e){r=fP({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,pP({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),mP({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,DM.bindAll)(window,[{type:`pointerdown`,listener:a},{type:`pointermove`,listener:a},{type:`focusin`,listener:a},{type:`focusout`,listener:a},{type:`dragstart`,listener:a},{type:`dragenter`,listener:a},{type:`dragover`,listener:a}],{capture:!0})}}function gP(){var e=null;function t(){return e=null,(0,DM.bind)(window,{type:`pointermove`,listener:function(t){e={x:t.clientX,y:t.clientY}},options:{capture:!0}})}function n(){var t=null;return function(n){var r=n.eventName,i=n.payload;if(r===`onDragStart`){var a=i.location.initial.input;t=hP({initial:e??{x:a.clientX,y:a.clientY}})}if(r===`onDrop`){var o,s=i.location.current.input;(o=t)==null||o({current:{x:s.clientX,y:s.clientY}}),t=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}var _P=nP(function(){return navigator.userAgent.includes(`Firefox`)}),vP=nP(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)});function yP(e){return`nodeName`in e}function bP(e){return yP(e)&&e.ownerDocument!==document}var xP={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};(function(){if(typeof window>`u`||!vP())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,DM.bindAll)(window,[{type:`dragstart`,listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:`drop`,listener:n},{type:`dragend`,listener:n},{type:`dragenter`,listener:function(e){!t.isOverWindow&&t.enterCount===0&&(e[xP.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[xP.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function SP(e){var t=e.dragLeave;return vP()?t.hasOwnProperty(xP.isLeavingWindow):!1}function CP(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?vP()?SP({dragLeave:t}):r==null?!0:_P()?bP(r):r instanceof HTMLIFrameElement:!1}function wP(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){e<20?e++:t()}}()},{type:`pointerdown`,listener:t}]}function TP(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var EP=dN(function(e){return e()}),DP=function(){var e=null;function t(t){e={frameId:requestAnimationFrame(function(){e=null,t()}),fn:t}}function n(){e&&=(cancelAnimationFrame(e.frameId),e.fn(),null)}return{schedule:t,flush:n}}();function OP(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(e){r(e),i={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var r=e.nativeSetDragImage,o={current:n,previous:i,initial:n};a({eventName:`onGenerateDragPreview`,payload:{source:t,location:o,nativeSetDragImage:r}}),DP.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;DP.flush(),EP.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;EP(function(){DP.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;DP.flush(),EP.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var kP={isActive:!1};function AP(){return!kP.isActive}function jP(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function MP(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function NP(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!AP())return;var a=FP({event:t,dragType:n,getDropTargetsOver:r});kP.isActive=!0;var o={current:a};PP({event:t,current:a.dropTargets});var s=OP({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=MP({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=TP(e),i=r({target:QN(e.target)?$N({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),PP({event:e,current:i})),c({dropTargets:i,input:t})}function u(){o.current.dropTargets.length&&c({dropTargets:[],input:o.current.input}),s.drop({current:o.current,updatedSourcePayload:null}),d()}function d(){kP.isActive=!1,f()}var f=(0,DM.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){CP({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:TP(e)},o.current.dropTargets.length?(e.preventDefault(),PP({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()):u()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:TP(e)},u()}}].concat(tN(wP({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:jP(t)})}function PP(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function FP(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=TP(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var IP={canStart:AP,start:NP},LP=new Map;function RP(e){var t=e.typeKey,n=e.mount,r=LP.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return LP.set(t,i),i}function zP(e){var t=RP(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),LP.delete(e.typeKey))}}function BP(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function VP(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function HP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function UP(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?HP(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):HP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function WP(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=GP(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
25
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function GP(e,t){if(e){if(typeof e==`string`)return KP(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?KP(e,t):void 0}}function KP(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function qP(e){return e.slice(0).reverse()}function JP(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i=`data-drop-target-for-${t}`,a=`[${i}]`;function o(e){return r.set(e.element,e),function(){return r.delete(e.element)}}function s(e){return nP(BP(VP(e.element,{attribute:i,value:`true`}),o(e)))}function c(e){var t=e.source,i=e.target,o=e.input,s=e.result,l=s===void 0?[]:s;if(i==null)return l;if(!(i instanceof Element))return i instanceof Node?c({source:t,target:i.parentElement,input:o,result:l}):l;var u=i.closest(a);if(u==null)return l;var d=r.get(u);if(d==null)return l;var f={input:o,source:t,element:d.element};if(d.canDrop&&!d.canDrop(f))return c({source:t,target:d.element.parentElement,input:o,result:l});var p=d.getData?.call(d,f)??{},m=d.getDropEffect?.call(d,f)??n,h={data:p,element:d.element,dropEffect:m,isActiveDueToStickiness:!1};return c({source:t,target:d.element.parentElement,input:o,result:[].concat(tN(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=WP(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=UP(UP({},n),{},{self:s});c==null||(o=c[t])==null||o.call(c,l)}}catch(e){i.e(e)}finally{i.f()}}var u={onGenerateDragPreview:l,onDrag:l,onDragStart:l,onDrop:l,onDropTargetChange:function(e){var t=e.payload,n=new Set(t.location.current.dropTargets.map(function(e){return e.element})),i=new Set,a=WP(t.location.previous.dropTargets),o;try{for(a.s();!(o=a.n()).done;){var s,c=o.value;i.add(c.element);var l=r.get(c.element),u=n.has(c.element),d=UP(UP({},t),{},{self:c});if(l==null||(s=l.onDropTargetChange)==null||s.call(l,d),!u){var f;l==null||(f=l.onDragLeave)==null||f.call(l,d)}}}catch(e){a.e(e)}finally{a.f()}var p=WP(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=UP(UP({},t),{},{self:_}),y=r.get(_.element);y==null||(h=y.onDropTargetChange)==null||h.call(y,v),y==null||(g=y.onDragEnter)==null||g.call(y,v)}}}catch(e){p.e(e)}finally{p.f()}}};function d(e){u[e.eventName](e)}function f(e){var t=e.source,n=e.target,i=e.input,a=e.current,o=c({source:t,target:n,input:i});if(o.length>=a.length)return o;for(var s=qP(a),l=qP(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null)u.push(m);else{var h=u[d-1],g=s[d-1];if(h?.element!==g?.element)break;var _=r.get(p.element);if(!_)break;var v={input:i,source:t,element:_.element};if(_.canDrop&&!_.canDrop(v)||!((f=_.getIsSticky)!=null&&f.call(_,v)))break;u.push(UP(UP({},p),{},{isActiveDueToStickiness:!0}))}}return qP(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function YP(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=XP(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
26
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function XP(e,t){if(e){if(typeof e==`string`)return ZP(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ZP(e,t):void 0}}function ZP(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $P(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QP(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eF(){var e=new Set,t=null;function n(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}function r(r){var i=$P({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return nP(a)}function i(r){var i=r.eventName,a=r.payload;if(i===`onGenerateDragPreview`){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var o=YP(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;n(c)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var l=Array.from(t.active),u=0,d=l;u<d.length;u++){var f=d[u];if(t.active.has(f)){var p;(p=f[i])==null||p.call(f,a)}}i===`onDrop`&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function tF(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=eF(),s=JP({typeKey:t,defaultDropEffect:a});function c(e){r?.(e),s.dispatchEvent(e),o.dispatchEvent(e),i?.(e)}function l(e){var t=e.event,n=e.dragType;IP.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:IP.canStart,start:l})}return zP({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var nF=nP(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),rF=`pdnd:android-fallback`,iF=`text/plain`,aF=`application/vnd.pdnd`,oF=new WeakMap,sF=gP(),cF=tF({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return BP(sF.bindEvents(),(0,DM.bind)(document,{type:`dragstart`,listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var n=t.target;if(n instanceof HTMLElement){var r=oF.get(n);if(r){var i=TP(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a))t.preventDefault();else{if(r.dragHandle){var o=$N({x:i.clientX,y:i.clientY});if(!r.dragHandle.contains(o)){t.preventDefault();return}}var s=r.getInitialDataForExternal?.call(r,a)??null;if(s)for(var c=0,l=Object.entries(s);c<l.length;c++){var u=wM(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}nF()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(iF,rF),t.dataTransfer.setData(aF,``);var p={type:`element`,payload:{element:r.element,dragHandle:r.dragHandle??null,data:r.getInitialData?.call(r,a)??{}},startedFrom:`internal`};e.start({event:t,dragType:p})}}}}}}))},dispatchEventToSource:function(e){var t,n,r=e.eventName,i=e.payload;(t=oF.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:sF.getOnPostDispatch()});cF.dropTarget;var lF=cF.monitor,uF=new Map,dF=new Set;function fF(e){pF(e);var t=uF.get(e);if(t)return t;var n={timeOfEngagementStart:Date.now()};return uF.set(e,n),n}function pF(e){dF.add(e)}function mF(e){dF.clear(),e(),uF.forEach(function(e,t){dF.has(t)||uF.delete(t)}),dF.clear()}function hF(){uF.clear()}var gF=new Map;function _F(e){var t=gF.get(e);if(t)return t;var n=vF(e);return gF.set(e,n),n}function vF(e){var t={type:`idle`},n=[];function r(e){if(t.type===`running`){var i=e-t.timeLastFrameFinished,a=t.latestArgs,o=$N({x:a.location.current.input.clientX,y:a.location.current.input.clientY});mF(function(){n.forEach(function(e){return e({underUsersPointer:o,latestArgs:a,timeSinceLastFrame:i})})}),t.timeLastFrameFinished=e,t.frameId=requestAnimationFrame(r)}}function i(){t.type!==`idle`&&(cancelAnimationFrame(t.frameId),hF(),t={type:`idle`})}function a(e){t.type===`idle`&&(t={type:`initializing`,latestArgs:e,frameId:requestAnimationFrame(function(e){t.type===`initializing`&&(t={type:`running`,timeLastFrameFinished:e,latestArgs:t.latestArgs,frameId:requestAnimationFrame(r)})})})}function o(e){t.type===`idle`?a(e):t.latestArgs=e}return e({onDragStart:a,onDropTargetChange:o,onDrag:o,onDrop:i}),{onFrame:function(e){n.push(e)}}}var yF=`data-auto-scrollable`,bF=`[${yF}="true"]`;function xF(e){return e.setAttribute(yF,`true`),function(){return e.removeAttribute(yF)}}function SF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CF(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SF(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var wF={startHitboxAtPercentageRemainingOfElement:{top:.25,right:.25,bottom:.25,left:.25},maxScrollAtPercentageRemainingOfHitbox:{top:.5,right:.5,bottom:.5,left:.5},timeDampeningDurationMs:400,maxMainAxisHitboxSize:180},TF={standard:900,fast:1500};function EF(e){return CF(CF({},wF),{},{maxPixelScrollPerSecond:TF[e?.maxScrollSpeed??`standard`]})}var DF={top:function(e){return e.scrollTop>0},right:function(e){return Math.ceil(e.scrollLeft)+e.clientWidth<e.scrollWidth},bottom:function(e){return Math.ceil(e.scrollTop)+e.clientHeight<e.scrollHeight},left:function(e){return e.scrollLeft>0}},OF=[`top`,`right`,`bottom`,`left`],kF={top:`vertical`,right:`horizontal`,bottom:`vertical`,left:`horizontal`},AF={start:`top`,end:`bottom`,point:`y`,size:`height`},jF={start:`left`,end:`right`,point:`x`,size:`width`},MF={vertical:{mainAxis:AF,crossAxis:jF},horizontal:{mainAxis:jF,crossAxis:AF}},NF={top:`start`,right:`end`,bottom:`end`,left:`start`};function PF(e){var t=e.edge,n=e.axis;return function(e){var r=e.clientRect,i=e.config,a=MF[n],o=a.mainAxis,s=a.crossAxis,c=NF[t],l=Math.min(i.startHitboxAtPercentageRemainingOfElement[t]*r[o.size],i.maxMainAxisHitboxSize);return DOMRect.fromRect(PM(PM(PM(PM({},o.point,c===`start`?r[o.point]:r[o.point]+r[o.size]-l),s.point,r[s.point]),o.size,l),s.size,r[s.size]))}}var FF={top:PF({axis:`vertical`,edge:`top`}),right:PF({axis:`horizontal`,edge:`right`}),bottom:PF({axis:`vertical`,edge:`bottom`}),left:PF({axis:`horizontal`,edge:`left`})};function IF(e){var t=e.startOfRange,n=e.endOfRange,r=e.value;if(!(t<n)||r<t)return 0;if(r>n)return 1;var i=n-t;return(r-t)/i}function LF(e){var t=e.timeSinceLastFrame,n=e.config,r=n.maxPixelScrollPerSecond/1e3,i=Math.ceil(r*t),a=n.maxPixelScrollPerSecond/60;return Math.min(i,a)}function RF(e){var t=e.client,n=e.axis,r=e.edge,i=e.hitbox,a=e.config,o=MF[n].mainAxis,s=NF[r],c=i[o.size]*a.maxScrollAtPercentageRemainingOfHitbox[r];return s===`end`?IF({startOfRange:i[o.start],endOfRange:i[o.end]-c,value:t[o.point]}):1-IF({startOfRange:i[o.start]+c,endOfRange:i[o.end],value:t[o.point]})}function zF(e){var t=e.client,n=e.timeSinceLastFrame,r=e.engagement,i=e.axis,a=e.hitbox,o=e.edge,s=e.isDistanceDampeningEnabled,c=e.config,l=LF({timeSinceLastFrame:n,config:c}),u=(s?RF({client:t,edge:o,hitbox:a,axis:i,config:c}):1)*IF({startOfRange:r.timeOfEngagementStart,endOfRange:r.timeOfEngagementStart+c.timeDampeningDurationMs,value:Date.now()}),d=Math.max(l*u,1);return NF[o]===`end`?d:-1*d}function BF(e,t){return t===`all`||e===t}function VF(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function HF(e){return e.getBoundingClientRect()}function UF(e){var t=e.element,n=e.input,r=e.timeSinceLastFrame,i=e.engagement,a=e.config,o=e.allowedAxis,s=e.getRect,c=s===void 0?HF:s,l={x:n.clientX,y:n.clientY},u=c(t),d=OF.reduce(function(e,n){var r=FF[n]({clientRect:u,config:a}),i=kF[n];return BF(i,o)&&VF({client:l,clientRect:r})&&DF[n](t)&&e.set(n,{edge:n,hitbox:r}),e},new Map);return{left:function(){var e=`horizontal`,t=d.get(`left`);if(t)return zF({client:l,edge:t.edge,hitbox:t.hitbox,axis:e,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:a});var n=d.get(`right`);return n?zF({client:l,edge:n.edge,hitbox:n.hitbox,axis:e,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:a}):0}(),top:function(){var e=`vertical`,t=d.get(`bottom`);if(t)return zF({client:l,edge:t.edge,hitbox:t.hitbox,axis:e,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:a});var n=d.get(`top`);return n?zF({client:l,edge:n.edge,hitbox:n.hitbox,axis:e,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:a}):0}()}}function WF(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=GF(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
27
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function GF(e,t){if(e){if(typeof e==`string`)return KF(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?KF(e,t):void 0}}function KF(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function qF(e){return!!(e.top||e.left)}function JF(e){var t=e.target,n=e.input,r=e.source,i=e.findEntry,a=e.timeSinceLastFrame,o=e.available,s=o===void 0?{top:!0,left:!0}:o;if(!qF(s)||!t)return s;var c=t.closest(bF);if(!c)return s;var l=i(c);if(!l)return s;function u(){return JF({target:c?.parentElement??null,findEntry:i,source:r,timeSinceLastFrame:a,input:n,available:s})}var d={input:n,source:r,element:c};if(l.canScroll&&!l.canScroll(d))return u();var f=fF(c),p=EF(l.getConfiguration?.call(l,d)),m=UF({element:c,engagement:f,input:n,timeSinceLastFrame:a,allowedAxis:l.getAllowedAxis?.call(l,d)??`all`,config:p}),h={top:0,left:0};return s.top&&m.top!==0&&(h.top=m.top,s.top=!1),s.left&&m.left!==0&&(h.left=m.left,s.left=!1),(h.top!==0||h.left!==0)&&c.scrollBy(h),u()}function YF(e){var t=e.input,n=e.timeSinceLastFrame,r=e.available,i=e.source,a=e.entries,o=document.documentElement,s={input:t,source:i,element:o},c=WF(a),l;try{for(c.s();!(l=c.n()).done;){var u=l.value;if(!u.canScroll||u.canScroll(s)){var d=UF({element:o,engagement:fF(o),input:t,config:EF(u.getConfiguration?.call(u,s)),allowedAxis:u.getAllowedAxis?.call(u,s)??`all`,getRect:function(e){return DOMRect.fromRect({y:0,x:0,width:e.clientWidth,height:e.clientHeight})},timeSinceLastFrame:n}),f={top:r.top?d.top:0,left:r.left?d.left:0};(f.top!==0||f.left!==0)&&o.scrollBy(f);break}}}catch(e){c.e(e)}finally{c.f()}}function XF(e){var t=e.input,n=e.findEntry,r=e.timeSinceLastFrame,i=e.source,a=e.getWindowScrollEntries,o=e.underUsersPointer,s=JF({target:o,timeSinceLastFrame:r,input:t,source:i,findEntry:n});qF(s)&&YF({input:t,source:i,entries:a(),timeSinceLastFrame:r,available:s})}function ZF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QF(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ZF(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $F(e){var t=e.monitor,n=new Map,r=new Set;function i(e){return n.set(e.element,e),nP(BP(xF(e.element),function(){return n.delete(e.element)}))}function a(){var e=QF({},arguments.length>0&&arguments[0]!==void 0?arguments[0]:{});r.add(e);function t(){r.delete(e)}return nP(t)}function o(e){return n.get(e)??null}function s(){return Array.from(r)}function c(e){var t=e.latestArgs,n=e.underUsersPointer,r=e.timeSinceLastFrame;XF({input:t.location.current.input,source:t.source,findEntry:o,underUsersPointer:n,timeSinceLastFrame:r,getWindowScrollEntries:s})}return _F(t).onFrame(c),{autoScroll:i,autoScrollWindow:a}}var eI=$F({monitor:lF}),tI=eI.autoScroll;eI.autoScrollWindow;function nI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nI(Object(n),!0).forEach(function(t){PM(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var iI={top:function(e,t){return Math.abs(t.y-e.top)},right:function(e,t){return Math.abs(e.right-t.x)},bottom:function(e,t){return Math.abs(e.bottom-t.y)},left:function(e,t){return Math.abs(t.x-e.left)}};function aI(e,t){var n=t.element,r=t.input,i=t.allowedEdges,a={x:r.clientX,y:r.clientY},o=n.getBoundingClientRect(),s=i.map(function(e){return{edge:e,value:iI[e](o,a)}}).sort(function(e,t){return e.value-t.value})[0]?.edge??null;return rI(rI({},e),{},PM({},sI,s))}function oI(e){return e[sI]??null}var sI=Symbol(`closestEdge`);function cI(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function lI(e){return e.nextFireAt===null?{tone:`muted`,label:`Scheduled`,clock:null}:{tone:`muted`,label:`Runs in`,clock:{kind:`countdown`,until:e.nextFireAt}}}function uI(e){let{activity:t}=e,n=ki({status:e.status,unread:e.unread}),r=e.stateEnteredAt===void 0?null:{kind:`elapsed`,since:e.stateEnteredAt};if(n?.tone===`destructive`)return{tone:`destructive`,label:n.label,clock:null};if(t.lastRunFailure){let{code:e}=t.lastRunFailure;return{tone:`destructive`,label:e===null?`Agent failed`:`Agent failed — ${e}`,clock:null}}if(n?.tone===`info`||t.awaitingAnswer)return{tone:`info`,label:n?.label??Ir(`waiting_for_user`),clock:r};if(t.workflow){let{name:e,agentCount:n}=t.workflow;return{tone:`warning`,label:`${e??`Workflow`} · ${cI(n,`agent`)}`,clock:r}}if(t.loop){let{done:e,total:n}=t.loop;return{tone:`warning`,label:`Loop · ${String(e)}/${String(n)}`,clock:r}}return t.agents>0?{tone:`warning`,label:cI(t.agents,`agent`),clock:r}:n?.tone===`warning`?{tone:`warning`,label:n.label,clock:r}:t.backgroundTasks>0?{tone:`warning`,label:cI(t.backgroundTasks,`background task`),clock:r}:t.cron&&!t.cron.paused?lI(t.cron):n?{tone:n.tone,label:n.label,clock:null}:null}function dI(e,t){let n=e.flatMap(e=>{let n=t[e];return n?[{chatId:e,chat:n}]:[]});if(n.length===0)return null;for(let{chatId:e,chat:t}of n){let r=uI(t);if(r)return{chatId:e,...r,linkedCount:n.length}}let r=n[0];return r?{chatId:r.chatId,tone:null,label:cI(n.length,`chat`),linkedCount:n.length,clock:null}:null}function fI(e,t,n){let r=e.cards[n.columnId];if(!r)return null;let i=r.filter(e=>e.id!==t),a=n.beforeCardId===null?i.length:i.findIndex(e=>e.id===n.beforeCardId);if(a<0)return null;let o=i[a-1]?.id??null,s=i[a]?.id??null,c=pI(e,t);if(c&&c.columnId===n.columnId){let e=c.cards[c.index-1]?.id??null,t=c.cards[c.index+1]?.id??null;if(e===o&&t===s)return null}return{cardId:t,toColumnId:n.columnId,aboveCardId:o,belowCardId:s}}function pI(e,t){for(let[n,r]of Object.entries(e.cards)){let e=r.findIndex(e=>e.id===t);if(e>=0)return{columnId:n,index:e,cards:r}}return null}function mI(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return null;let i=e.filter(e=>e.id!==t),a=n===null?i.length:i.findIndex(e=>e.id===n);if(a<0)return null;let o=i[a-1]?.id??null;return(e[r-1]?.id??null)===o?null:{columnId:t,afterColumnId:o}}function hI(e,t,n){let r=e.findIndex(e=>e.id===t);return r<0?null:n===`top`?t:e[r+1]?.id??null}function gI(e,t,n){let r=e.findIndex(e=>e.id===t);return r<0?null:n===`left`?t:e[r+1]?.id??null}function _I(e,t){let n=t.text.trim().toLowerCase(),r=t.labels;return!n&&r.length===0?e:e.filter(e=>{if(n&&!e.title.toLowerCase().includes(n))return!1;if(r.length>0){let t=WA(e.content);if(!r.some(e=>t.includes(e)))return!1}return!0})}function vI(e,t){return t!==null&&e.createdAt>t}function yI(e,t){return t===null?0:e.filter(e=>vI(e,t)).length}var bI=Jn()(e=>({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1,startCardDrag:t=>e({draggingCardId:t,cardDrop:null}),setCardDrop:t=>e({cardDrop:t}),startColumnDrag:t=>e({draggingColumnId:t,columnDropBeforeId:null,columnDropActive:!1}),setColumnDrop:(t,n)=>e({columnDropBeforeId:t,columnDropActive:n}),endDrag:()=>e({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1})}));function xI(e,t){return n=>n.cardDrop?.columnId===e&&n.cardDrop.beforeCardId===t}function SI(e){return t=>t.cardDrop?.columnId===e&&t.cardDrop.beforeCardId===null}var CI={text:``,labels:[]},wI=Jn(e=>({filterByBoard:{},setText:(t,n)=>e(e=>({filterByBoard:{...e.filterByBoard,[t]:{...e.filterByBoard[t]??CI,text:n}}})),setLabels:(t,n)=>e(e=>({filterByBoard:{...e.filterByBoard,[t]:{...e.filterByBoard[t]??CI,labels:n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.filterByBoard;return{filterByBoard:r}})}));function TI(e){return t=>t.filterByBoard[e]??CI}function EI({boardId:e}){let t=wI(TI(e)),n=(0,G.useCallback)(t=>{wI.getState().setText(e,t.currentTarget.value)},[e]),r=(0,G.useCallback)(()=>{wI.getState().clear(e)},[e]),i=t.text.length>0||t.labels.length>0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pb-1.5`,children:[(0,K.jsx)(`input`,{value:t.text,onChange:n,placeholder:`Filter…`,"aria-label":`Filter cards`,className:B(`min-w-0 flex-1 rounded-md bg-transparent px-2 py-1 text-xs text-foreground`,`placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none`)}),i?(0,K.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Clear filter`,className:`shrink-0 rounded-md p-1 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:(0,K.jsx)(Mn,{"aria-hidden":!0,className:`size-3`})}):null]})}var DI={title:``,semantic:null,colorToken:null,wipLimit:null},OI=Jn()(e=>({openColumnId:null,draft:DI,open:(t,n)=>e({openColumnId:t,draft:n}),close:()=>e({openColumnId:null,draft:DI}),setTitle:t=>e(e=>({draft:{...e.draft,title:t}})),setSemantic:t=>e(e=>({draft:{...e.draft,semantic:Wj(t)?t:null}})),setColorToken:t=>e(e=>({draft:{...e.draft,colorToken:Rj(t)?t:null}})),setWipLimit:t=>e(e=>{let n=Number.parseInt(t.trim(),10);return{draft:{...e.draft,wipLimit:Number.isInteger(n)&&n>0?n:null}}})})),kI=[{value:``,label:`No role`,hint:`Nothing routes here automatically.`},{value:`start`,label:`Incoming`,hint:`Pulled issues land here.`},{value:`active`,label:`In progress`,hint:`Start work moves a card here.`},{value:`review`,label:`In review`,hint:`No automatic behaviour yet.`},{value:`done`,label:`Done`,hint:`Closes the issue, and asks about the worktree.`}];function AI({columnId:e,value:t,canDelete:n,onSave:r,onDelete:i}){let a=OI(t=>t.openColumnId===e),o=OI(e=>e.draft),s=(0,G.useCallback)(n=>{let r=OI.getState();n?r.open(e,t):r.close()},[e,t]),c=(0,G.useCallback)(e=>{OI.getState().setTitle(e.currentTarget.value)},[]),l=(0,G.useCallback)(e=>{OI.getState().setWipLimit(e.currentTarget.value)},[]),u=(0,G.useCallback)(e=>{OI.getState().setSemantic(e.currentTarget.value)},[]),d=(0,G.useCallback)(e=>{OI.getState().setColorToken(e.currentTarget.value)},[]),f=(0,G.useCallback)(()=>{let t=OI.getState();t.draft.title.trim()!==``&&(r(e,{...t.draft,title:t.draft.title.trim()}),t.close())},[e,r]),p=(0,G.useCallback)(()=>{i(e),OI.getState().close()},[e,i]),m=kI.find(e=>(e.value===``?null:e.value)===o.semantic)?.hint;return(0,K.jsxs)(aa,{open:a,onOpenChange:s,children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":`Column settings: ${t.title}`,className:`rounded-md p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground`,children:(0,K.jsx)(ji,{"aria-hidden":!0,className:`size-4`})})}),(0,K.jsxs)(Za,{align:`end`,className:`w-72 space-y-4 p-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-title-${e}`,children:`Name`}),(0,K.jsx)($n,{id:`column-title-${e}`,value:o.title,onChange:c})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-role-${e}`,children:`Role`}),(0,K.jsx)(`select`,{id:`column-role-${e}`,value:o.semantic??``,onChange:u,className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-13 text-foreground`,children:kI.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.label))}),m?(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:m}):null]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Dot`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Pj,{token:null,label:`No dot`,selected:o.colorToken===null,onSelect:d}),Lj.map(e=>(0,K.jsx)(Pj,{token:e,label:e,selected:o.colorToken===e,onSelect:d},e))]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`column-wip-${e}`,children:`WIP limit`}),(0,K.jsx)($n,{id:`column-wip-${e}`,value:o.wipLimit===null?``:String(o.wipLimit),onChange:l,inputMode:`numeric`,placeholder:`None`,className:`tabular-nums`}),(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Advisory. Going over is shown, never blocked.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border pt-3`,children:[(0,K.jsx)(U,{size:`sm`,onClick:f,disabled:o.title.trim()===``,children:`Save`}),(0,K.jsx)(U,{variant:`ghost`,size:`sm`,className:`ml-auto text-destructive-text`,onClick:p,disabled:!n,children:`Delete`})]}),n?null:(0,K.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Move or archive its cards before deleting it.`})]})]})}var jI=Qn(`ColumnAdder`,()=>e=>({draft:``,setDraft:t=>e({draft:t}),clear:()=>e({draft:``})})),MI=Jn()(e=>({draftByColumn:{},setDraft:(t,n)=>e(e=>({draftByColumn:{...e.draftByColumn,[t]:n}})),clear:t=>e(e=>{if(!(t in e.draftByColumn))return e;let n={...e.draftByColumn};return delete n[t],{draftByColumn:n}})}));function NI(e){return t=>t.draftByColumn[e]??``}var PI=`kanna-board-card`,FI=`kanna-board-column`;function II(e){let{view:t,onCardMove:n,onColumnMove:r}=e,i=(0,G.useRef)(null),a=(0,G.useRef)(t),o=(0,G.useRef)(t.columns);(0,G.useLayoutEffect)(()=>{a.current=t,o.current=t.columns});let s=t.board.id,c=wI(TI(s)),l=(0,G.useCallback)(e=>{let t=bI.getState().cardDrop;if(bI.getState().endDrag(),!t)return;let r=fI(a.current,e,t);r&&n(r)},[n]),u=(0,G.useCallback)(e=>{let{columnDropBeforeId:t,columnDropActive:n}=bI.getState();if(bI.getState().endDrag(),!n)return;let i=mI(a.current.columns,e,t);i&&r(i.columnId,i.afterColumnId)},[r]);return(0,G.useEffect)(()=>{let e=i.current;if(e)return tI({element:e})},[]),(0,K.jsxs)(`div`,{ref:i,className:`kanna-board flex h-full w-full items-stretch gap-0 overflow-x-auto bg-background p-4`,children:[t.columns.map(n=>{let r=t.cards[n.id]??LI,i=n.semantic===`start`,a=i?_I(r,c):r;return(0,K.jsx)(VI,{column:n,columnsRef:o,cards:a,total:t.counts[n.id]??r.length,newSince:i?t.newSince??null:null,chatLinksByCard:t.chatLinksByCard??zI,chatFacts:e.chatFacts??BI,onCardDrop:l,onColumnDrop:u,onOpenCard:e.onOpenCard,onLoadMore:e.onLoadMore,onColumnSave:e.onColumnSave,onColumnDelete:e.onColumnDelete,onCardAdd:e.onCardAdd,onMoveToTop:e.onMoveToTop},n.id)}),(0,K.jsx)(XI,{onAdd:e.onColumnAdd,isFirst:t.columns.length===0})]})}var LI=[],RI=[],zI={},BI={};function VI({column:e,columnsRef:t,cards:n,total:r,newSince:i,chatLinksByCard:a,chatFacts:o,onOpenCard:s,onLoadMore:c,onColumnSave:l,onColumnDelete:u,onCardAdd:d,onCardDrop:f,onColumnDrop:p,onMoveToTop:m}){let h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=e.id,v=bI(e=>e.draggingColumnId===_),y=bI(e=>e.columnDropActive&&e.columnDropBeforeId===_),b=bI(SI(_));(0,G.useEffect)(()=>{let e=h.current,n=g.current;if(!e||!n)return;let r=bI.getState();return vM(XN({element:e,dragHandle:e.querySelector(`[data-column-handle]`)??void 0,getInitialData:()=>({[FI]:!0,columnId:_}),onDragStart:()=>{r.startColumnDrag(_)},onDrop:()=>{p(_)}}),YN({element:e,canDrop:({source:e})=>e.data[FI]===!0,getData:({input:e,element:t})=>aI({columnId:_},{input:e,element:t,allowedEdges:[`left`,`right`]}),onDragEnter:({self:e})=>{HI(e.data,_,t.current)},onDrag:({self:e})=>{HI(e.data,_,t.current)}}),YN({element:n,canDrop:({source:e})=>e.data[PI]===!0,getData:()=>({columnId:_}),onDragEnter:()=>{r.setCardDrop({columnId:_,beforeCardId:null})},onDragLeave:()=>{r.setCardDrop(null)}}),tI({element:n}))},[_,t,p]);let x=Zs(r,e.wipLimit),S=(0,G.useMemo)(()=>({title:e.title,semantic:e.semantic,colorToken:e.colorToken,wipLimit:e.wipLimit}),[e.colorToken,e.semantic,e.title,e.wipLimit]),C=e.semantic===`start`,w=i===null?0:yI(n,i);return(0,K.jsxs)(`div`,{ref:h,className:B(`relative flex h-full w-[300px] shrink-0 flex-col border-r border-border px-3`,v&&`opacity-40`),children:[y?(0,K.jsx)(qI,{}):null,(0,K.jsxs)(`div`,{"data-column-handle":!0,className:`flex cursor-grab items-center gap-2 px-1 pb-2 pt-1`,children:[e.colorToken?(0,K.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,Xs[e.colorToken])}):null,(0,K.jsx)(`span`,{className:`truncate text-[0.9375rem] font-semibold leading-tight text-foreground`,children:e.title}),(0,K.jsx)(`span`,{className:B(`ml-auto shrink-0 font-mono text-xs tabular-nums`,x?`text-warning-text`:`text-muted-foreground`),children:C&&w>0?(0,K.jsxs)(K.Fragment,{children:[r,(0,K.jsxs)(`span`,{className:`text-info-text`,children:[` · `,w,` new`]})]}):r}),(0,K.jsx)(AI,{columnId:_,value:S,canDelete:r===0,onSave:l,onDelete:u})]}),C?(0,K.jsx)(EI,{boardId:e.boardId}):null,(0,K.jsxs)(`div`,{ref:g,className:`min-h-0 flex-1 space-y-2 overflow-y-auto px-1 py-2`,children:[n.map(e=>(0,K.jsx)(UI,{card:e,columnId:_,cards:n,chatIds:a[e.id]??RI,chatFacts:o,newSince:i,onOpen:s,onCardDrop:f,onMoveToTop:m},e.id)),b?(0,K.jsx)(KI,{}):null,r>n.length?(0,K.jsx)(JI,{columnId:_,onLoadMore:c}):null]}),(0,K.jsx)(YI,{columnId:_,onAdd:d})]})}function HI(e,t,n){let r=oI(e);if(r!==`left`&&r!==`right`)return;let i=gI(n,t,r);bI.getState().setColumnDrop(i,!0)}function UI({card:e,columnId:t,cards:n,chatIds:r,chatFacts:i,newSince:a,onOpen:o,onCardDrop:s,onMoveToTop:c}){let l=(0,G.useRef)(null),u=e.id,d=bI(e=>e.draggingCardId===u),f=bI(xI(t,u)),p=(0,G.useRef)(n);(0,G.useLayoutEffect)(()=>{p.current=n}),(0,G.useEffect)(()=>{let e=l.current;if(!e)return;let n=bI.getState();return vM(XN({element:e,getInitialData:()=>({[PI]:!0,cardId:u}),onDragStart:()=>{n.startCardDrag(u)},onDrop:()=>{s(u)}}),YN({element:e,canDrop:({source:e})=>e.data[PI]===!0,getData:({input:e,element:t})=>aI({cardId:u},{input:e,element:t,allowedEdges:[`top`,`bottom`]}),onDragEnter:({self:e})=>{GI(e.data,t,u,p.current)},onDrag:({self:e})=>{GI(e.data,t,u,p.current)}}))},[u,t,s]);let m=(0,G.useCallback)(()=>{o(u)},[u,o]),h=(0,G.useCallback)(()=>{c(u)},[u,c]),g=bn(W(`board.card.move`,u)),_=dI(r,i),v=vI(e,a);return(0,K.jsxs)(R.div,{ref:l,layout:!0,transition:{type:`spring`,...O.cardTravel},className:`relative`,children:[f?(0,K.jsx)(KI,{}):null,(0,K.jsxs)(ua,{children:[(0,K.jsx)(Qa,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:m,"aria-busy":g||void 0,className:B(`relative w-full cursor-grab rounded-lg border border-border bg-card px-3 py-2 text-left`,`transition-[colors,transform,opacity] duration-[var(--motion-quick)] hover:bg-secondary`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,d&&`scale-[1.02] opacity-40`),children:[g?(0,K.jsx)(hn,{className:`absolute top-2 right-2 text-muted-foreground`}):null,(0,K.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-snug text-foreground [text-wrap:pretty]`,children:e.title}),v?(0,K.jsxs)(`span`,{className:`mt-1 flex items-center gap-1 text-xs text-info-text`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-info`}),(0,K.jsx)(`span`,{children:`New`})]}):null,_?(0,K.jsxs)(`span`,{className:B(`mt-1.5 flex items-center gap-1.5 text-xs`,Oa(_.tone)),children:[_.tone?(0,K.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,Ki(_.tone))}):(0,K.jsx)(Xa,{"aria-hidden":!0,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:_.label}),_.clock===null?null:(0,K.jsx)(WI,{clock:_.clock})]}):null]})}),(0,K.jsx)(eo,{children:(0,K.jsx)(Zi,{onSelect:h,disabled:g,children:`Move to top`})})]})]})}function WI({clock:e}){let t=wa(1e3),n=e.kind===`elapsed`?Si(Math.max(0,t-e.since)):xi(e.until-t);return(0,K.jsx)(`span`,{className:`tabular-nums`,children:n})}function GI(e,t,n,r){let i=oI(e);if(i!==`top`&&i!==`bottom`)return;let a=hI(r,n,i);bI.getState().setCardDrop({columnId:t,beforeCardId:a})}function KI(){return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-px w-full origin-left rounded-full bg-primary kanna-drop-line-in`})}function qI(){return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 w-px origin-top bg-primary kanna-column-drop-line-in`})}function JI({columnId:e,onLoadMore:t}){let n=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let r=n.current;if(!r)return;let i=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&t(e)});return i.observe(r),()=>{i.disconnect()}},[e,t]),(0,K.jsxs)(`div`,{ref:n,className:`space-y-2`,"aria-hidden":!0,children:[(0,K.jsx)(`div`,{className:`h-14 w-full animate-pulse rounded-lg border border-border bg-secondary`}),(0,K.jsx)(`div`,{className:`h-14 w-full animate-pulse rounded-lg border border-border bg-secondary`})]})}function YI({columnId:e,onAdd:t}){let n=MI(NI(e)),r=(0,G.useCallback)(t=>{MI.getState().setDraft(e,t.currentTarget.value)},[e]),i=(0,G.useCallback)(n=>{n.preventDefault();let r=(MI.getState().draftByColumn[e]??``).trim();r!==``&&(MI.getState().clear(e),t(e,r))},[e,t]);return(0,K.jsx)(`form`,{onSubmit:i,className:`shrink-0 px-1 pb-1 pt-2`,children:(0,K.jsx)(`input`,{value:n,onChange:r,placeholder:`Add a card`,"aria-label":`Add a card`,className:`w-full rounded-md bg-transparent px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none`})})}function XI(e){return(0,K.jsx)(jI.Provider,{init:void 0,children:(0,K.jsx)(ZI,{...e})})}function ZI({onAdd:e,isFirst:t}){let n=jI.useScopedStoreApi(),r=jI.useScopedStore(e=>e.draft),i=(0,G.useCallback)(e=>{n.getState().setDraft(e.currentTarget.value)},[n]),a=(0,G.useCallback)(t=>{t.preventDefault();let r=n.getState().draft.trim();r!==``&&(n.getState().clear(),e(r))},[n,e]);return(0,K.jsxs)(`form`,{onSubmit:a,className:`w-64 shrink-0 px-3 pt-1`,children:[t?(0,K.jsx)(`p`,{className:`mb-2 px-1 text-sm text-muted-foreground [text-wrap:pretty]`,children:`No columns yet. Name your first one to start tracking work your agents can pick up.`}):null,(0,K.jsx)(`input`,{value:r,onChange:i,placeholder:t?`Name your first column`:`Add a column`,"aria-label":`Add a column`,className:`w-full rounded-md bg-transparent px-1 py-1 text-[0.9375rem] text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none`})]})}function QI(e,t){let n=pI(e,t.cardId)?.columnId;if(n===void 0||!(t.toColumnId in e.cards))return e;let r=(e.cards[n]??[]).find(e=>e.id===t.cardId);if(!r)return e;let i={...e.cards};i[n]=(i[n]??[]).filter(e=>e.id!==t.cardId);let a=t.toColumnId===n?[...i[n]??[]]:[...i[t.toColumnId]??[]];a.splice($I(a,t),0,{...r,columnId:t.toColumnId}),i[t.toColumnId]=a;let o={...e.counts};return t.toColumnId!==n&&(o[n]=Math.max(0,(o[n]??1)-1),o[t.toColumnId]=(o[t.toColumnId]??0)+1),{...e,cards:i,counts:o}}function $I(e,t){if(t.aboveCardId!==null){let n=e.findIndex(e=>e.id===t.aboveCardId);if(n!==-1)return n+1}if(t.belowCardId!==null){let n=e.findIndex(e=>e.id===t.belowCardId);if(n!==-1)return n}return t.aboveCardId===null?0:e.length}function eL(e,t,n){let r=e.columns.find(e=>e.id===t);if(!r||n!==null&&!e.columns.some(e=>e.id===n))return e;let i=e.columns.filter(e=>e.id!==t),a=n===null?0:i.findIndex(e=>e.id===n)+1;return{...e,columns:[...i.slice(0,a),r,...i.slice(a)]}}var tL=[];function nL(e,t,n){t&&n&&Ks.getState().viewByBoard[e]===n&&Ks.getState().setBoardView(e,t)}function rL(e){return(0,K.jsx)(fA.Provider,{init:void 0,children:(0,K.jsx)(iL,{...e})},e.boardId)}function iL({boardId:e,socket:t,chatFacts:n,onOpenCard:r,onOpenBoards:i}){let a=fA.useScopedStoreApi(),o=Ks(Js(e)),s=Ks(Ys(e));(0,G.useEffect)(()=>t.subscribe({type:`board`,boardId:e,pageSize:s},e=>{Ks.getState().setBoardView(e.boardId,e.view)}),[e,s,t]);let c=(0,G.useCallback)((e,n)=>{t.command(e).catch(nr(e=>{n?.(),a.getState().reportMessage(e.message)}))},[a,t]),l=(0,G.useCallback)(t=>{let n=Ks.getState().viewByBoard[e],r=n?QI(n,t):void 0;r&&Ks.getState().setBoardView(e,r),c({type:`board.card.move`,cardId:t.cardId,toColumnId:t.toColumnId,aboveCardId:t.aboveCardId,belowCardId:t.belowCardId},()=>{nL(e,n,r)})},[e,c]),u=fA.useScopedStore(e=>e.openCardId),d=(0,G.useCallback)(e=>{a.getState().openCard(e),r?.(e)},[r,a]),f=(0,G.useCallback)(()=>{a.getState().closeCard()},[a]),p=fA.useScopedStore(e=>e.syncPanelOpen),m=(0,G.useCallback)(()=>{a.getState().openSyncPanel()},[a]),h=(0,G.useCallback)(()=>{a.getState().closeSyncPanel()},[a]),g=fA.useScopedStore(e=>e.schemaPanelOpen),_=(0,G.useCallback)(()=>{a.getState().openSchemaPanel()},[a]),v=(0,G.useCallback)(()=>{a.getState().closeSchemaPanel()},[a]),y=fA.useScopedStore(e=>e.syncing),b=fA.useScopedStore(e=>e.message),x=(0,G.useCallback)(()=>{let n=a.getState();n.startSync(),t.command({type:`board.sync.pull`,boardId:e}).then(e=>{let t=e.conflicts>0?`, ${String(e.conflicts)} conflicts`:``;n.finishSync(`Synced · ${String(e.created)} new, ${String(e.updated)} updated${t}`)}).catch(nr(e=>{n.finishSync(e.message)}))},[e,a,t]),S=(0,G.useCallback)((t,n)=>{let r=Ks.getState().viewByBoard[e],i=r?eL(r,t,n):void 0;i&&Ks.getState().setBoardView(e,i),c({type:`board.column.move`,columnId:t,afterColumnId:n},()=>{nL(e,r,i)})},[e,c]),C=(0,G.useCallback)((e,t)=>{c({type:`board.column.update`,columnId:e,title:t.title,semantic:t.semantic,colorToken:t.colorToken,wipLimit:t.wipLimit})},[c]),w=(0,G.useCallback)(e=>{c({type:`board.column.delete`,columnId:e})},[c]),T=(0,G.useCallback)(t=>{let n=Ks.getState().viewByBoard[e]?.columns.at(-1)?.id??null;c({type:`board.column.create`,boardId:e,title:t,afterColumnId:n})},[e,c]),E=(0,G.useCallback)(n=>{let r=Ks.getState().viewByBoard[e];if(!r)return;let i=Object.values(r.cards).flat().find(e=>e.id===n);if(!i)return;let o=(r.cards[i.columnId]??[])[0];o?.id!==n&&vn(W(`board.card.move`,n),async()=>{try{await t.command({type:`board.card.move`,cardId:n,toColumnId:i.columnId,aboveCardId:null,belowCardId:o?.id??null})}catch(e){a.getState().reportMessage(rr(e))}})},[e,a,t]),D=(0,G.useCallback)((t,n)=>{let r=Ks.getState().viewByBoard[e]?.cards[t]?.at(-1)?.id??null;c({type:`board.card.create`,boardId:e,columnId:t,title:n,afterCardId:r})},[e,c]),O=fA.useScopedStore(e=>e.renaming),k=fA.useScopedStore(e=>e.titleDraft),A=(0,G.useCallback)(()=>{let t=Ks.getState().viewByBoard[e];t&&a.getState().startRename(t.board.title)},[e,a]),j=(0,G.useCallback)(e=>{a.getState().setTitleDraft(e.currentTarget.value)},[a]),M=(0,G.useCallback)(()=>{let{titleDraft:t}=a.getState(),n=Ks.getState().viewByBoard[e];a.getState().stopRename();let r=t.trim();r!==``&&r!==n?.board.title&&c({type:`board.update`,boardId:e,title:r})},[e,a,c]),N=(0,G.useCallback)(e=>{e.key===`Enter`&&M(),e.key===`Escape`&&a.getState().stopRename()},[M,a]),P=(0,G.useCallback)(e=>{e?.select()},[]),F=(0,G.useCallback)(()=>{Ks.getState().growPage(e)},[e]),I=o&&o.board.ownerKind===`project`&&i?o.board.ownerId:null,ee=(0,G.useCallback)(()=>{I&&i?.(I)},[i,I]),L=(0,G.useMemo)(()=>o?o.columns.flatMap(e=>(o.cards[e.id]??[]).map(e=>({id:e.id,title:e.title}))):tL,[o]);return o?(0,K.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,children:[(0,K.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[I?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:ee,className:`shrink-0 rounded-md px-1.5 py-0.5 text-13 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Boards`}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-13 text-muted-foreground`,children:`/`})]}):null,O?(0,K.jsx)(`input`,{ref:P,value:k,onChange:j,onKeyDown:N,onBlur:M,"aria-label":`Board name`,className:`min-w-0 flex-1 rounded-md bg-secondary px-1.5 py-0.5 text-15 font-semibold text-foreground focus:outline-none`}):(0,K.jsx)(`button`,{type:`button`,onClick:A,className:`min-w-0 truncate rounded-md px-1.5 py-0.5 text-left text-15 font-semibold text-foreground hover:bg-secondary`,children:o.board.title}),b?(0,K.jsx)(`span`,{className:`truncate font-mono text-xs tabular-nums text-muted-foreground`,children:b}):null,(0,K.jsxs)(U,{variant:`secondary`,size:`sm`,className:`ml-auto`,onClick:x,disabled:y,children:[(0,K.jsx)(wn,{"aria-hidden":!0,className:B(`size-3.5`,y&&`animate-spin`)}),y?`Syncing…`:`Sync`]}),(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:_,"aria-label":`Card fields`,children:(0,K.jsx)(to,{"aria-hidden":!0,className:`size-3.5`})}),(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:m,"aria-label":`Sync settings`,children:(0,K.jsx)(xs,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[p?(0,K.jsx)(Mj,{boardId:e,socket:t,onClose:h}):null,g?(0,K.jsx)(pM,{boardId:e,fields:o.board.cardFields,socket:t,onClose:v}):null,u?(0,K.jsx)(rj,{cardId:u,socket:t,chatFacts:n,cardFields:o.board.cardFields,boardCards:L,onClose:f}):null,(0,K.jsx)(II,{view:o,chatFacts:n,onCardMove:l,onColumnMove:S,onOpenCard:d,onLoadMore:F,onColumnSave:C,onColumnDelete:w,onColumnAdd:T,onCardAdd:D,onMoveToTop:E})]})]}):(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background p-8`,children:(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading board…`})})}var aL=22.5,oL=3,sL=3,cL=2;function lL(e,t={}){let n=t.live===!0,r=e.slice(n?-7:-8),i=r.reduce((e,t)=>t>e?t:e,0),a=r.map((e,t)=>{let n=cL+(i>0?e/i:0)*17;return{x:oL+t*sL,topY:uL(aL-n),live:!1}});return n&&a.push({x:oL+r.length*sL,topY:uL(3.5),live:!0}),{ticks:a,baselineY:aL,size:26}}function uL(e){return Math.round(e*100)/100}function dL(e){let t=[];for(let n=e.length-1;n>=0&&t.length<8;--n){let r=e[n];r.kind===`result`&&r.hidden!==!0&&t.push(r.durationMs)}return t.reverse()}var fL=(0,G.createContext)(null);function pL(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function mL(){let e=(0,G.useContext)(fL);return e??function(e,...t){throw function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);return n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(e,...t)}(8),e}var hL=et?G.useLayoutEffect:G.useEffect,gL={tag:je};function _L({initialConfig:e,children:t}){let n=(0,G.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,onWarn:a,editorState:o,html:s}=e,c=pL(null,t),l=dt({editable:e.editable,html:s,namespace:n,nodes:r,onError:e=>i(e,l),...a?{onWarn:e=>a(e,l)}:{},theme:t});return function(e,t){if(t!==null){if(t===void 0)e.update(()=>{let t=Ie();if(t.isEmpty()){let n=$e();t.append(n);let r=e.getRootElement(),i=et&&r!==null?Ze(r):null;(St()!==null||i!==null&&i===r)&&n.select()}},gL);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,gL);break}case`object`:e.setEditorState(t,gL);break;case`function`:e.update(()=>{Ie().isEmpty()&&t(e)},gL)}}}(l,o),[l,c]},[]);return hL(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,K.jsx)(fL.Provider,{value:n,children:t})}var vL=class extends G.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){this.props.onError(e instanceof Error?e:Error(String(e),{cause:e}),t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function yL({children:e,fallback:t,onError:n}){return(0,K.jsx)(vL,{fallback:t===void 0?(0,K.jsx)(`div`,{style:{border:`1px solid #f00`,color:`#f00`,padding:`8px`},children:`An error was thrown.`}):t,onError:n,children:e})}var bL=et?G.useLayoutEffect:G.useEffect;function xL(e){let[t]=mL(),n=(0,G.useMemo)(()=>e(t),[t,e]),[r,i]=(0,G.useState)(()=>n.initialValueFn()),a=(0,G.useRef)(r);return bL(()=>{let{initialValueFn:e,subscribe:t}=n,r=e();return a.current!==r&&(a.current=r,i(r)),t(e=>{a.current=e,i(e)})},[n,e]),r}function SL(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function CL(){return xL(SL)}var wL={name:`@lexical/react/ReactProvider`};function TL(){return Ie().getTextContent()}function EL(e,t=!0){if(e)return!1;let n=TL();return t&&(n=n.trim()),n===``}function DL(e){if(!EL(e,!1))return!1;let t=Ie().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(rt(n))return!1;if(_t(n)){if(!xt(n)||n.__indent!==0)return!1;let e=n.getChildren(),t=e.length;for(let n=0;n<t;n++){let t=e[n];if(!ke(t))return!1}}}return!0}function OL(e){return()=>DL(e)}function kL(e,...t){throw function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);return n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(e,...t)}function AL({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,G.useMemo)(()=>[t=>e.registerDecoratorListener(t),()=>e.getDecorators()],[e]),i=(0,G.useSyncExternalStore)(n,r,r),a=function(e){let[t,n]=(0,G.useMemo)(()=>[e.registerRootListener.bind(e),e.getRootElement.bind(e)],[e]);return(0,G.useSyncExternalStore)(t,n,n)}(e);return(0,G.useMemo)(()=>{let n=t=>e._onError(t),r=[];for(let a in i){let o=e.getElementByKey(a);if(o!==null){let e=(0,K.jsx)(t,{onError:n,children:(0,K.jsx)(G.Suspense,{fallback:null,children:i[a]})});r.push((0,Fs.createPortal)(e,o,a))}}return r},[t,i,e,a])}(e,t)}function jL({editor:e,ErrorBoundary:t}){return function(e){let t=vt.maybeFromEditor(e);if(t&&t.hasExtensionByName(wL.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&kL(320,e);return!0}return!1}(e)?null:(0,K.jsx)(AL,{editor:e,ErrorBoundary:t})}var ML=et?G.useLayoutEffect:G.useEffect;function NL(e){return e.read(`latest`,OL(e.isComposing()))}function PL({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=mL();return function(e){ML(()=>ht(yt(e),Hs(e)),[e])}(r),(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(FL,{content:t}),(0,K.jsx)(jL,{editor:r,ErrorBoundary:n})]})}function FL({content:e}){let[t]=mL(),n=function(e){let[t,n]=(0,G.useState)(()=>NL(e));return ML(()=>{function t(){let t=NL(e);n(t)}return t(),ht(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=CL();return n?typeof e==`function`?e(r):e:null}var IL=et?G.useLayoutEffect:G.useEffect;function LL({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,G.useState)(e.isEditable()),T=(0,G.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,G.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);IL(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]);let D={"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":g===`combobox`?o??!1:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,...x},O=[D[`aria-label`],D[`aria-labelledby`],D.title].some(e=>typeof e==`string`&&e.trim()!==``),k=g===void 0?C||O?`textbox`:void 0:g;return k??(D[`aria-activedescendant`]=void 0,D[`aria-autocomplete`]=void 0,D[`aria-expanded`]=void 0,D[`aria-multiline`]=void 0,D[`aria-placeholder`]=void 0,D[`aria-readonly`]=void 0,D[`aria-required`]=void 0),(0,K.jsx)(`div`,{autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:k,spellCheck:_,style:v,tabIndex:y??(C?void 0:-1),...D})}var RL=(0,G.forwardRef)(LL);function zL(e){return e.read(`latest`,OL(e.isComposing()))}var BL=(0,G.forwardRef)(VL);function VL(e,t){let{placeholder:n,...r}=e,[i]=mL();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(RL,{editor:i,...r,ref:t}),n!=null&&(0,K.jsx)(HL,{editor:i,content:n})]})}function HL({content:e,editor:t}){let n=function(e){let[t,n]=(0,G.useState)(()=>zL(e));return IL(()=>{function t(){let t=zL(e);n(t)}return t(),ht(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,G.useState)(t.isEditable());if(IL(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,K.jsx)(`div`,{"aria-hidden":!0,children:a})}function UL(e){return JSON.stringify([e.exportJSON(),_t(e)?e.getChildrenKeys():null])}function WL(e,t,n){let r=n(),i=0,a=r,o=0,s=null,c=new Set;return(l,u,d,f,p,m)=>{let h=n();if(m.has(`composition-start`)&&(a=r,o=i,s=l,c.clear()),s!==null){for(let e of f)c.add(e);for(let e of p.keys())c.add(e)}if(m.has(`historic`))return i=0,r=h,s=null,c.clear(),2;let g=m.has(Ne);g&&s&&(r=a,i=o,l=s);let _=m.has(`paste`)||m.has(`cut`)?0:function(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(Ke(a)&&Ke(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||gt(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&ke(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!ke(l)||!ke(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}(l,u,f,p,e.isComposing()),v=!1,y=(()=>{let n=d===null||d.editor===e,a=m.has(Xe),o=!a&&n&&m.has(`history-merge`);if(g&&s!==null&&n&&!a&&function(e,t,n){for(let r of e){let e=t._nodeMap.get(r),i=n._nodeMap.get(r);if(!(e===i||e&&i&&t.read(()=>UL(e))===n.read(()=>UL(i))))return!1}return!0}(c,s,u))return v=!0,0;if(o)return 0;if(_===1)return 2;if(l===null)return 1;let y=u._selection;if(!(f.size>0||p.size>0))return y===null?2:0;let b=typeof t==`number`?t:t.peek();return!1===a&&_!==0&&_===i&&h<r+b&&n||!a&&f.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(Ke(a)&&Ke(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!ke(r)||!ke(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(f)[0],l,u)?0:1})();return g&&(s=null,c.clear()),v||(r=h,i=_),y}}function GL(e,t){if(t!==null&&t.editor===e.editor)return t;let{editor:n}=e,r=n.getEditorState();return r.isEmpty()?null:{editor:n,editorState:r}}function KL(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function qL(e,t,n,r=Date.now,i,a=null){let o=WL(e,n,r),s=()=>{i&&i(t)};return s(),ht(e.registerCommand(mt,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(i.length!==0){let a=t.current,o=i.pop();if(o){let t=GL(o,a);t!==null&&(r.push(t),e.dispatchCommand(We,!0))}i.length===0&&e.dispatchCommand(ut,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(lt,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(r.length!==0){let a=t.current,o=r.pop();if(o){let t=GL(o,a);t!==null&&(i.push(t),e.dispatchCommand(ut,!0))}r.length===0&&e.dispatchCommand(We,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(at,()=>(KL(t,i),!1),0),e.registerCommand(He,()=>(KL(t,i),e.dispatchCommand(We,!1),e.dispatchCommand(ut,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:i,dirtyElements:c,tags:l})=>{let u=t.current,d=t.redoStack,f=t.undoStack,p=u===null?null:u.editorState;if(u!==null&&n===p)return;let m=o(r,n,u,i,c,l);if(m===1){d.length!==0&&(t.redoStack=[],e.dispatchCommand(We,!1));let n=function(e,t,n){return n===null?null:n.editor===e?{...n}:t.isEmpty()?null:{editor:e,editorState:t}}(e,r,u);if(n!==null){f.push(n);let t=typeof a==`number`||a===null?a:a.peek();t!==null&&f.length>t&&f.splice(0,f.length-t),e.dispatchCommand(ut,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function JL(){return{current:null,redoStack:[],undoStack:[]}}function YL({delay:e,externalHistoryState:t}){let[n]=mL();return function(e,t,n=1e3){let r=(0,G.useMemo)(()=>t||JL(),[t]);(0,G.useEffect)(()=>qL(e,r,n),[n,e,r])}(n,t,e),null}var XL=G.forwardRef(({className:e,children:t,...n},r)=>(0,K.jsx)(`div`,{ref:r,className:B(`relative overflow-y-auto overscroll-contain touch-pan-y`,e),style:{WebkitOverflowScrolling:`touch`},...n,children:t}));XL.displayName=`ScrollArea`;var ZL=`(display-mode: standalone)`;function QL(e={dom:pi}){let[t,n]=(0,G.useState)(()=>{let t=e.dom.isIOSStandalone(),n=e.dom.matchesMediaQuery(ZL);return t||n});return(0,G.useEffect)(()=>e.dom.addMediaQueryListener(ZL,t=>{n(t||e.dom.isIOSStandalone())}),[e.dom]),t}function $L(e){return D(T(e))?{className:`kanna-composer-arrive`,sweep:(0,K.jsx)(`span`,{"aria-hidden":!0,className:`kanna-composer-sweep pointer-events-none absolute inset-x-0 bottom-0 h-[1.5px] rounded-full bg-logo`})}:eR}var eR={className:void 0,sweep:null},tR=ar(or);function nR(e,t){return typeof e==`string`?e:t}function rR(e){if(!Tr(e))return null;let t=e.id;return typeof t==`string`?{id:t,kind:tR(e.kind)?e.kind:`file`,displayName:nR(e.displayName,``),absolutePath:nR(e.absolutePath,``),relativePath:nR(e.relativePath,``),contentUrl:nR(e.contentUrl,``),mimeType:nR(e.mimeType,``),size:typeof e.size==`number`?e.size:0,...e.reused===!0?{reused:!0}:{}}:null}function iR(e){if(!Cr(e))return null;let t=[];for(let n of e){let e=rR(n);e&&t.push(e)}return t}var aR=class extends Error{constructor(){super(`Upload aborted`),this.name=`UploadAbortedError`}},oR=80,sR=8388608,cR=[0,1e3,3e3,5e3,1e4],lR=`Upload failed`,uR=()=>er(()=>import(`./browser-DUvIcXp1.js`),__vite__mapDeps([69,1]));function dR(e){let t=`originalResponse`in e?e.originalResponse?.getBody():void 0,n=t?xr(t):null,r=Tr(n)?n.error:null;return typeof r==`string`&&r?r:lR}function fR(e){let t=e.loadTus??uR,n=!1,r=null,i=()=>{},a=0,o=-1;return{promise:new Promise((s,c)=>{i=c;function l(t,n,r=!1){let i=n>0?n:e.file.size,s=i>0?Math.floor(t/i*100):0,c=Date.now(),l=c-a>=oR;(r||l||s!==o)&&(a=c,o=s,e.onProgress({loaded:t,total:i}))}async function u(){let{Upload:i}=await t();if(n)return;let a=new i(e.file,{endpoint:Dr(jr.uploadTus.path,{projectId:e.projectId}),chunkSize:sR,retryDelays:cR,storeFingerprintForResuming:!0,removeFingerprintOnSuccess:!0,metadata:{filename:e.file.name,...e.file.type?{filetype:e.file.type}:{}},onProgress:(e,t)=>l(e,t),onSuccess:({lastResponse:t})=>{if(n)return;l(e.file.size,e.file.size,!0);let r=t.getBody(),i=r?xr(r):null,a=Tr(i)?iR(i.attachments):null;a?s({attachments:a}):c(Error(`Upload failed: malformed response`))},onError:e=>{n||c(Error(dR(e)))}});r=a;let[o]=await a.findPreviousUploads();n||(o&&a.resumeFromPreviousUpload(o),a.start())}u().then(void 0,e=>{n||c(e instanceof Error?e:Error(lR))})}),abort:()=>{n||(n=!0,i(new aR),r&&ri(`terminating aborted upload`,r.abort(!0)))}}}function pR(e){let t=e.maxAttachments??50;return e.currentAttachmentCount+e.queuedAttachmentCount+e.incomingAttachmentCount>t}async function mR(e,t){e.contentUrl&&!e.reused&&await Rt(e.contentUrl,t)}function hR(e){e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}function gR(e){return e.map(e=>({...e,status:`uploaded`}))}function _R(e,t,n,r){return{id:t,kind:e.type.startsWith(`image/`)?`image`:`file`,displayName:e.name,absolutePath:``,relativePath:``,contentUrl:``,mimeType:e.type||`application/octet-stream`,size:e.size,status:`uploading`,previewUrl:n,uploadProgress:0,cancelUpload:r}}function vR({projectId:e,chatId:t,commands:n}){let r=Jk.useScopedStoreApi(),i=Jk.useScopedStore(e=>e.attachments),a=Jk.useScopedStore(e=>e.setAttachments),o=Jk.useScopedStore(e=>e.selectedAttachmentId),s=Jk.useScopedStore(e=>e.setSelectedAttachmentId),c=Jk.useScopedStore(e=>e.uploadError),l=Jk.useScopedStore(e=>e.setUploadError),u=b(e=>e.getAttachmentDrafts),d=b(e=>e.setAttachmentDrafts),f=b(e=>e.clearAttachmentDrafts),p=(0,G.useRef)([]),m=(0,G.useRef)(0),h=(0,G.useRef)(0),g=(0,G.useRef)(new Set),_=(0,G.useRef)(e),v=(0,G.useRef)(void 0),y=(0,G.useCallback)(()=>{h.current+=1,p.current=[],m.current=0,g.current.clear()},[]),x=(0,G.useCallback)(e=>{y(),a(t=>((e?.releasePreviews??!0)&&t.forEach(hR),[])),s(null),l(null)},[y,s,a,l]),S=(0,G.useCallback)(()=>{if(e)for(;m.current<3&&p.current.length>0;){let t=p.current.shift();if(!t)break;m.current+=1;let r=crypto.randomUUID(),i=t.type.startsWith(`image/`)?URL.createObjectURL(t):void 0,o=h.current,s=()=>o===h.current,c=()=>{i&&URL.revokeObjectURL(i)},u=fR({projectId:e,file:t,onProgress:({loaded:e,total:t})=>{if(!s())return;let n=t>0?e/t:0;a(e=>e.map(e=>e.id===r?{...e,uploadProgress:n}:e))}});a(e=>[...e,_R(t,r,i,u.abort)]),ri(`attachment upload`,(async()=>{try{let{attachments:e}=await u.promise,t=e[0];if(!t)throw Error(`Upload failed`);if(!s()){ri(`abandoned upload cleanup`,mR(t,n)),c();return}if(g.current.has(r)){g.current.delete(r),c(),ri(`abandoned upload cleanup`,mR(t,n));return}a(e=>e.map(e=>e.id===r?{...e,...t,previewUrl:e.previewUrl,status:`uploaded`,uploadProgress:1,cancelUpload:void 0}:e)),l(null)}catch(e){if(!s()){c();return}if(e instanceof aR){a(e=>e.filter(e=>e.id!==r)),g.current.delete(r),c();return}a(e=>e.map(e=>e.id===r?{...e,status:`failed`,cancelUpload:void 0}:e)),l(rr(e))}finally{m.current=Math.max(0,m.current-1),v.current?.()}})())}},[n,e,a,l]);(0,G.useEffect)(()=>{v.current=S},[S]);let C=(0,G.useCallback)(t=>{e?pR({currentAttachmentCount:r.getState().attachments.length,queuedAttachmentCount:p.current.length,incomingAttachmentCount:t.length})?l(`You can upload up to 50 files at a time.`):(p.current.push(...t),l(null),S()):l(`Open a project before uploading files.`)},[e,S,l,r]),w=(0,G.useCallback)(e=>{e.status===`uploading`&&e.cancelUpload?.(),g.current.add(e.id),a(t=>{let n=t.find(t=>t.id===e.id);return n&&hR(n),t.filter(t=>t.id!==e.id)}),r.getState().selectedAttachmentId===e.id&&s(null),e.status===`uploaded`&&(g.current.delete(e.id),ri(`removed upload cleanup`,mR(e,n)))},[n,s,a,r]),T=(0,G.useCallback)(()=>{let e=r.getState(),n=e.attachments,i=e.selectedAttachmentId,o=e.uploadError,c=n.filter(e=>e.status===`uploaded`).map(Uk);return x({releasePreviews:!1}),t&&f(t),{attachments:c,commit:()=>n.forEach(hR),rollback:()=>{a(n),s(i),l(o)}}},[t,x,f,s,a,l,r]);return(0,G.useEffect)(()=>{y(),s(null),l(null),(0,G.startTransition)(()=>{a(e=>(e.forEach(hR),gR(t?u(t):[])))})},[y,t,u,s,a,l]),(0,G.useEffect)(()=>{let n=_.current;_.current=e,n!==null&&e!==n&&(x(),t&&f(t))},[e,t,x,f]),(0,G.useEffect)(()=>{if(!t)return;let e=i.filter(e=>e.status===`uploaded`).map(Wk);e.length===0?f(t):d(t,e)},[i,t,f,d]),(0,G.useEffect)(()=>()=>{r.getState().attachments.forEach(hR)},[r]),{attachments:i,hasUploadedAttachments:i.some(e=>e.status===`uploaded`),isUploading:i.some(e=>e.status===`uploading`),uploadError:c,setUploadError:l,selectedAttachment:i.find(e=>e.id===o)??null,selectAttachment:s,enqueue:C,remove:w,beginSubmit:T}}function yR(){return e=>({open:!1,query:``,setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:``}),closeAndClearQuery:()=>e({open:!1,query:``})})}var bR=Qn(`SearchableModelPopover`,yR),xR=[],SR=`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,CR=`${SR} opacity-70 cursor-default`,wR=`${SR} cursor-pointer touch-manipulation transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,TR={openrouter:`Loading models… verify OpenRouter API key in Settings.`,custom:`No models configured. Add an endpoint in Settings → Providers.`};function ER({className:e,...t}){return(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:B(`shrink-0`,e),...t,children:(0,K.jsx)(`path`,{d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`})})}function DR({className:e,...t}){return(0,K.jsx)(`svg`,{viewBox:`0 0 158.7128 157.296`,fill:`currentColor`,"aria-hidden":`true`,className:B(`shrink-0`,e),...t,children:(0,K.jsx)(`path`,{d:`M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z`})})}function OR({className:e,...t}){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:B(`shrink-0`,e),...t,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,K.jsx)(`path`,{d:`M6.3 6.3a8 8 0 1 0 11.4 11.4`}),(0,K.jsx)(`path`,{d:`M17.7 6.3a8 8 0 0 1 0 11.4`}),(0,K.jsx)(`path`,{d:`M2 12h4`}),(0,K.jsx)(`path`,{d:`M18 12h4`})]})}var kR={claude:ER,codex:DR,antigravity:cn,openrouter:OR,custom:ys};function AR({onClick:e,selected:t,icon:n,label:r,description:i,disabled:a}){return(0,K.jsxs)(`button`,{onClick:e,disabled:a,className:B(`w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity`,t?`bg-muted border-border`:`hover:opacity-60`,a&&`opacity-40 cursor-not-allowed`),children:[n,(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:r}),i?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i}):null]})]})}function jR({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?(0,K.jsx)(`button`,{disabled:!0,className:B(CR,t),children:e}):(0,K.jsx)(y.Provider,{init:void 0,children:(0,K.jsx)(MR,{trigger:e,triggerClassName:t,children:r})})}function MR({trigger:e,triggerClassName:t,children:n}){let r=y.useScopedStore(e=>e.open),i=y.useScopedStore(e=>e.setOpen);return(0,K.jsxs)(aa,{open:r,onOpenChange:i,children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:B(wR,t),children:e})}),(0,K.jsx)(Za,{align:`center`,className:`w-64 p-1`,children:(0,K.jsx)(`div`,{className:`space-y-1`,children:typeof n==`function`?n(()=>i(!1)):n})})]})}function NR({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){return(0,K.jsx)(bR.Provider,{init:void 0,children:(0,K.jsx)(PR,{models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i})})}function PR({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){let a=bR.useScopedStore(e=>e.open),o=bR.useScopedStore(e=>e.query),s=bR.useScopedStore(e=>e.setPopoverOpen),c=bR.useScopedStore(e=>e.setQuery),l=bR.useScopedStore(e=>e.closeAndClearQuery),u=(0,G.useCallback)(e=>{n(e),l()},[n,l]),d=e.find(e=>e.id===t)?.label??t,f=(0,G.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)):e},[e,o]),p;return p=e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:i}):f.length===0?(0,K.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No matches`}):f.map(e=>(0,K.jsx)(AR,{onClick:()=>u(e.id),selected:t===e.id,icon:(0,K.jsx)(yo,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.id},e.id)),(0,K.jsxs)(aa,{open:a,onOpenChange:s,children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:wR,children:[(0,K.jsx)(r,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`max-w-[200px] truncate`,children:d})]})}),(0,K.jsxs)(Za,{align:`center`,className:`w-80 p-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border/50`,children:[(0,K.jsx)(Tn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>c(e.target.value),placeholder:`Search models...`,autoFocus:!0,className:`flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,K.jsx)(`div`,{className:`max-h-72 overflow-y-auto py-1 space-y-1`,children:p})]})]})}function FR(e,t,n){return e===`claude`?oi(t,n).map(e=>({...e,change:{type:`claudeReasoningEffort`,effort:e.id}})):e===`codex`?li.map(e=>({...e,change:{type:`codexReasoningEffort`,effort:e.id}})):e===`antigravity`?ui.map(e=>({...e,change:{type:`antigravityReasoningEffort`,effort:e.id}})):null}function IR({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,model:r,modelOptions:i,onProviderChange:a,onModelChange:o,modelLock:s=null,onModelOptionChange:c,planMode:l=!1,onPlanModeChange:u,includePlanMode:d=!0,className:f}){let p=br(_r),m=e.find(e=>e.id===t)??e[0],h=m?.id??t,g=kR[h],_=yo,v=d&&m?.supportsPlanMode&&u,y=h===`claude`&&`contextWindow`in i?i:null,b=h===`codex`&&`fastMode`in i?i:null,x=m?.models??xR,S=x.find(e=>e.id===r)?.contextWindowOptions??[],C=y?.contextWindow??si[0].id,w=C===`1m`?Ts:Ds,T=FR(h,r,p),E=x.find(e=>e.id===r)?.label??r,D=di(h)?(0,K.jsx)(NR,{models:x,selectedModel:r,onSelect:e=>o(h,e),ModelIcon:_,emptyMessage:TR[h]}):(0,K.jsx)(jR,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:E})]}),children:e=>x.map(t=>{let n=yo;return(0,K.jsx)(AR,{onClick:()=>{o(h,t.id),e()},selected:r===t.id,icon:(0,K.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:t.requirementHint?(0,K.jsxs)(K.Fragment,{children:[t.label,` `,(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:t.requirementHint})]}):t.label},t.id)})});return(0,K.jsxs)(`div`,{className:B(`flex md:justify-center items-center gap-0.5`,f),children:[n?(0,K.jsx)(jR,{disabled:!a,trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(g,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:m?.label??h})]}),children:t=>e.map(e=>{let n=kR[e.id];return(0,K.jsx)(AR,{onClick:()=>{a?.(e.id),t()},selected:h===e.id,icon:(0,K.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}):null,s?(0,K.jsx)(Zr,{label:s.reason,side:`top`,children:(0,K.jsxs)(`span`,{"aria-disabled":`true`,className:CR,children:[(0,K.jsx)($o,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:E})]})}):D,T?(0,K.jsx)(jR,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ve,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:T.find(e=>e.id===i.reasoningEffort)?.label??i.reasoningEffort})]}),children:e=>T.map(t=>(0,K.jsx)(AR,{onClick:()=>{c(t.change),e()},selected:i.reasoningEffort===t.id,icon:(0,K.jsx)(Ve,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id))}):null,h===`claude`&&S.length>1?(0,K.jsx)(jR,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:S.find(e=>e.id===C)?.label??C})]}),children:e=>S.map(t=>(0,K.jsx)(AR,{onClick:()=>{c({type:`contextWindow`,contextWindow:t.id}),e()},selected:C===t.id,icon:t.id===`1m`?(0,K.jsx)(Ts,{className:`h-4 w-4 text-muted-foreground`}):(0,K.jsx)(Ds,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.id===`1m`?`Expanded context window`:`Standard context window`},t.id))}):null,h===`codex`?(0,K.jsx)(jR,{trigger:(0,K.jsxs)(K.Fragment,{children:[b?.fastMode?(0,K.jsx)(Fo,{className:`h-3.5 w-3.5`}):(0,K.jsx)(Fo,{className:`h-3.5 w-3.5 -scale-x-100`}),(0,K.jsx)(`span`,{children:b?.fastMode?`Fast Mode`:`Standard`})]}),triggerClassName:b?.fastMode?`text-success-text`:void 0,children:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AR,{onClick:()=>{c({type:`fastMode`,fastMode:!1}),e()},selected:!b?.fastMode,icon:(0,K.jsx)(Fo,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,K.jsx)(AR,{onClick:()=>{c({type:`fastMode`,fastMode:!0}),e()},selected:!!b?.fastMode,icon:(0,K.jsx)(Fo,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}):null,v?(0,K.jsx)(jR,{trigger:(0,K.jsxs)(K.Fragment,{children:[l?(0,K.jsx)(mn,{className:`h-3.5 w-3.5`}):(0,K.jsx)(Zo,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:l?`Plan Mode`:`Full Access`})]}),triggerClassName:l?`text-info-text`:void 0,children:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AR,{onClick:()=>{u(!1),e()},selected:!l,icon:(0,K.jsx)(Zo,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,K.jsx)(AR,{onClick:()=>{u(!0),e()},selected:l,icon:(0,K.jsx)(mn,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})}):null]})}function LR({usage:e}){let t=e.usedPercentage!==null&&Number.isFinite(e.usedPercentage)?on(e.usedPercentage):null,n=Math.max(0,Math.min(100,e.usedPercentage??0)),r=9.75,i=2*Math.PI*r,a=i-n/100*i;return(0,K.jsxs)(aa,{children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`group inline-flex h-9 w-9 cursor-pointer touch-manipulation items-center justify-center rounded-full transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":e.maxTokens!==void 0&&t?`Context window ${t} used`:`Context window ${dn(e.usedTokens)} tokens used`,children:(0,K.jsxs)(`span`,{className:`relative flex h-6 w-6 items-center justify-center`,children:[(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`-rotate-90 absolute inset-0 h-full w-full transform-gpu`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/20`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:i,strokeDashoffset:a,className:`text-muted-foreground transition-[stroke-dashoffset] duration-500 ease-out`})]}),(0,K.jsx)(`span`,{className:B(`relative flex size-5 items-center justify-center rounded-full bg-background text-xs font-medium`,`text-muted-foreground`),children:e.usedPercentage===null?dn(e.usedTokens):Math.round(e.usedPercentage)})]})})}),(0,K.jsx)(Za,{side:`top`,align:`center`,className:`w-max max-w-none px-3 py-2`,children:(0,K.jsx)(`div`,{className:`space-y-1.5 leading-tight`,children:e.maxTokens!==void 0&&t?(0,K.jsxs)(`div`,{className:`whitespace-nowrap text-xs font-medium text-foreground`,children:[(0,K.jsx)(`span`,{children:t}),(0,K.jsx)(`span`,{className:`mx-1`,children:`·`}),(0,K.jsx)(`span`,{children:dn(e.usedTokens)}),(0,K.jsx)(`span`,{children:`/`}),(0,K.jsxs)(`span`,{children:[dn(e.maxTokens),` context used`]})]}):(0,K.jsxs)(`div`,{className:`text-sm text-foreground`,children:[dn(e.usedTokens),` tokens used so far`]})})})]})}function RR({totals:e,className:t}){if(!e)return null;let n=e.cacheHitPercentage===null?null:on(Math.max(0,Math.min(100,e.cacheHitPercentage))),r=e.costUsd>0?sn(e.costUsd):null;return(0,K.jsxs)(aa,{children:[(0,K.jsx)(no,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-label":HR(e,n,r),className:B(`inline-flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 rounded-md bg-muted/30 px-2.5 py-1.5 text-xs tabular-nums text-muted-foreground transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t),children:[(0,K.jsx)(zR,{label:`in`,value:dn(e.inputTokens)}),(0,K.jsx)(BR,{}),(0,K.jsx)(zR,{label:`out`,value:dn(e.outputTokens)}),n===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(BR,{}),(0,K.jsx)(zR,{label:`cache`,value:n})]}),r===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(BR,{}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:r})]})]})}),(0,K.jsx)(Za,{side:`top`,align:`center`,className:`w-max max-w-none px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`space-y-1 text-xs leading-tight`,children:[(0,K.jsx)(VR,{label:`Input`,value:dn(e.inputTokens)}),(0,K.jsx)(VR,{label:`Output`,value:dn(e.outputTokens)}),(0,K.jsx)(VR,{label:`Cache read`,value:dn(e.cachedTokens)}),n===null?null:(0,K.jsx)(VR,{label:`Cache hit`,value:n}),r===null?null:(0,K.jsx)(VR,{label:`Cost`,value:r})]})})]})}function zR({label:e,value:t}){return(0,K.jsxs)(`span`,{className:`inline-flex items-baseline gap-1 tabular-nums`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,K.jsx)(`span`,{children:e})]})}function BR(){return(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/50`,children:`·`})}function VR({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-6 whitespace-nowrap`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:t})]})}function HR(e,t,n){let r=[`Input ${dn(e.inputTokens)}`,`Output ${dn(e.outputTokens)}`,`Cache ${dn(e.cachedTokens)}`];return t!==null&&r.push(`hit ${t}`),n!==null&&r.push(`cost ${n}`),`Session tokens: ${r.join(`, `)}`}var UR=`(^|[\\s\\n\\t])@agent/([a-z0-9_-]+)`;function WR(){return new RegExp(UR,`gi`)}var GR=Le(`SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND`),KR=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},qR=et?G.useLayoutEffect:G.useEffect,JR=e=>{let t=e.closest(`#typeahead-menu`);if(!t)return;let n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:`center`}),n.top<0&&t.scrollIntoView({block:`center`}),e.scrollIntoView({block:`nearest`})};function YR(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function XR(e,t,n,r){let[i]=mL();(0,G.useEffect)(()=>{if(t!=null&&e!=null){let e=i.getRootElement(),a=e==null?document.body:Be(e,!1),o=!1,s=YR(t,a),c=function(){o||=(window.requestAnimationFrame(function(){n(),o=!1}),!0);let e=YR(t,a);e!==s&&(s=e,r?.(e))},l=new ResizeObserver(n),u=Ge(e??t);return l.observe(t),ht(Ee(window,`resize`,n),Ee(document,`scroll`,c,{capture:!0,passive:!0}),...u.map(e=>Ee(e,`scroll`,c,{capture:!0,passive:!0})),()=>l.unobserve(t))}},[t,i,r,n,e])}function ZR({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let a=`item`;return t&&(a+=` selected`),(0,K.jsxs)(`li`,{tabIndex:-1,className:a,ref:i.setRefElement,role:`option`,"aria-selected":t,id:`typeahead-item-`+e,onMouseEnter:r,onClick:n,children:[i.icon,(0,K.jsx)(`span`,{className:`text`,children:i.title})]},i.key)}function QR({close:e,editor:t,anchorElementRef:n,resolution:r,options:i,menuRenderFn:a,onSelectOption:o,shouldSplitNodeWithQuery:s=!1,commandPriority:c=1,preselectFirstItem:l=!0}){let[u,d]=(0,G.useState)(null),f=u===null?null:Math.min(i.length-1,u),p=r.match&&r.match.matchingString;(0,G.useEffect)(()=>{l&&d(0)},[p,l]);let m=(0,G.useCallback)(n=>{t.update(()=>{o(n,r.match!=null&&s?function(e){let t=St();if(!Ke(t)||!t.isCollapsed())return null;let n=t.anchor;if(n.type!==`text`)return null;let r=n.getNode();if(!r.isSimpleText())return null;let i=n.offset,a=r.getTextContent().slice(0,i),o=e.replaceableString.length,s=i-function(e,t,n){let r=n;for(let n=r;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(r=n);return r}(a,e.matchingString,o);if(s<0)return null;let c;return s===0?[c]=r.splitText(i):[,c]=r.splitText(s,i),c}(r.match):null,e,r.match?r.match.matchingString:``)})},[t,s,r.match,o,e]),h=(0,G.useCallback)(e=>{let n=t.getRootElement();n!==null&&(n.setAttribute(`aria-activedescendant`,`typeahead-item-`+e),d(e))},[t]),g=(0,G.useCallback)(()=>n.current&&i.length?Fs.createPortal((0,K.jsx)(`div`,{className:`typeahead-popover mentions-menu`,children:(0,K.jsx)(`ul`,{children:i.map((e,t)=>(0,K.jsx)(ZR,{index:t,isSelected:f===t,onClick:()=>{d(t),m(e)},onMouseEnter:()=>{d(t)},option:e},e.key))})}),n.current):null,[n,i,f,m,d]);(0,G.useEffect)(()=>()=>{let e=t.getRootElement();e!==null&&e.removeAttribute(`aria-activedescendant`)},[t]),qR(()=>{i===null?d(null):f===null&&l&&h(0)},[i,f,h,l]);let _=a==null&&(i===null||!i.length);(0,G.useEffect)(()=>ht(t.registerCommand(GR,({option:e})=>!(!e.ref||e.ref.current==null||(JR(e.ref.current),0)),c)),[t,h,c]),(0,G.useEffect)(()=>ht(t.registerCommand(De,e=>{let n=e;if(_)return!1;let r=f===null||f===i.length-1?0:f+1;h(r);let a=i[r];return a?(a.ref&&a.ref.current&&t.dispatchCommand(GR,{index:r,option:a}),n.preventDefault(),n.stopImmediatePropagation(),!0):(h(-1),n.preventDefault(),n.stopImmediatePropagation(),!0)},c),t.registerCommand(bt,e=>{let t=e;if(_)return!1;let n=f===null||f===0?i.length-1:f-1;h(n);let r=i[n];return r?(r.ref&&r.ref.current&&JR(r.ref.current),t.preventDefault(),t.stopImmediatePropagation(),!0):(h(-1),t.preventDefault(),t.stopImmediatePropagation(),!0)},c),t.registerCommand(ft,t=>{let n=t;return!_&&(n.preventDefault(),n.stopImmediatePropagation(),e(),!0)},c),t.registerCommand(ze,e=>{let t=e;return i!==null&&f!==null&&i[f]!=null&&(t.preventDefault(),t.stopImmediatePropagation(),m(i[f]),!0)},c),t.registerCommand(it,e=>!(i===null||f===null||i[f]==null||e&&e.shiftKey||(e!==null&&(e.preventDefault(),e.stopImmediatePropagation()),m(i[f]),0)),c)),[m,e,t,i,_,f,h,c]);let v=(0,G.useMemo)(()=>({options:i,selectOptionAndCleanUp:m,selectedIndex:f,setHighlightedIndex:d}),[m,f,i]);return a==null?g():a(n,v,r.match?r.match.matchingString:``)}function $R(e,t){t!=null&&(e.className=t),e.setAttribute(`aria-label`,`Typeahead menu`),e.setAttribute(`role`,`listbox`),e.style.display=`block`,e.style.position=`absolute`}function ez(e){if(e.position!==`static`)return!0;let t=e.willChange;return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter!==`none`||e.contain.includes(`paint`)||e.contain.includes(`layout`)||e.contain.includes(`strict`)||e.contain.includes(`content`)||t.includes(`transform`)||t.includes(`perspective`)||t.includes(`filter`)||t.includes(`contain`)}function tz({options:e,onQueryChange:t,onSelectOption:n,onOpen:r,onClose:i,menuRenderFn:a,triggerFn:o,anchorClassName:s,commandPriority:c=1,parent:l,preselectFirstItem:u=!0,ignoreEntityBoundary:d=!1}){let[f]=mL(),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(0),g=(0,G.useRef)(!1),_=(0,G.useCallback)(()=>{if(!g.current)return;g.current=!1;let e=h.current,t=()=>{h.current===e&&m(null)},n;try{n=i&&i()}finally{n?n.then(t,t):t()}},[i]),v=(0,G.useCallback)(e=>{h.current++,m(e),g.current||(g.current=!0,r?.(e))},[r]),y=function(e,t,n,r,i=!0){let[a]=mL(),o=r??function(e){if(!et)return;let t=e.getRootElement();if(t!==null){let e=t.getRootNode();return Ae(e)?e:t.ownerDocument.body}return document.body}(a),s=et?tt(a.getRootElement()).createElement(`div`):null,c=(0,G.useRef)(s),l=(0,G.useCallback)(()=>{if(c.current===null||o===void 0)return;c.current.style.top=c.current.style.bottom;let t=a.getRootElement(),r=c.current,s=r.firstChild;if(t!==null&&e!==null){let{left:a,top:l,width:u,height:d}=e.getRect(),f=c.current.offsetHeight,p=function(e){let t=Ae(e)?e.host:e;for(let e=Ye(t)?t:null;e!==null;e=Se(e)){let t=e.ownerDocument.defaultView;if(t===null)break;if(ez(t.getComputedStyle(e))){let t=e.getBoundingClientRect();return{left:t.left+e.clientLeft-e.scrollLeft,top:t.top+e.clientTop-e.scrollTop}}}return null}(o),m=e=>p===null?e+window.pageXOffset:e-p.left,h=e=>p===null?e+(i?window.pageYOffset:0):e-p.top;if(r.style.top=`${h(l+f+3)}px`,r.style.left=`${m(a)}px`,r.style.height=`${d}px`,r.style.width=`${u}px`,s!==null){s.style.top=`${l}`;let e=s.getBoundingClientRect(),n=e.height,i=e.width,o=t.getBoundingClientRect();a+i>o.right&&(r.style.left=`${m(o.right-i)}px`),(l+n>window.innerHeight||l+n>o.bottom)&&l-o.top>n+d&&(r.style.top=`${h(l-n-d)}px`)}r.isConnected||($R(r,n),o.append(r)),r.setAttribute(`id`,`typeahead-menu`),t.setAttribute(`aria-controls`,`typeahead-menu`)}},[a,e,i,n,o]);(0,G.useEffect)(()=>{let t=a.getRootElement();return e!==null&&l(),()=>{t!==null&&t.removeAttribute(`aria-controls`);let e=c.current;e!==null&&e.isConnected&&(e.remove(),e.removeAttribute(`id`))}},[a,l,e]);let u=(0,G.useCallback)(n=>{e!==null&&(n||t(null))},[e,t]);return XR(e,c.current,l,u),s!=null&&s===c.current&&($R(s,n),o?.append(s)),c}(p,(0,G.useCallback)(e=>{e===null?_():m(e)},[_]),s,l);return(0,G.useEffect)(()=>{let e=f.registerUpdateListener(()=>{f.read(`latest`,()=>{if(!f.isEditable())return void _();let e=()=>{f.isComposing()||_()},n=f._window||window,r=n.document.createRange(),i=St(),a=function(e){let t=null;return e.read(`latest`,()=>{let e=St();Ke(e)&&(t=function(e){let t=e.anchor;if(t.type!==`text`)return null;let n=t.getNode();if(!n.isSimpleText())return null;let r=t.offset;return n.getTextContent().slice(0,r)}(e))}),t}(f);if(!Ke(i)||!i.isCollapsed()||a===null||r===null)return void e();let s=o(a,f);if(t(s?s.matchingString:null),s!==null&&(d||!function(e,t){return t===0&&e.read(`latest`,()=>{let e=St();if(Ke(e)){let t=e.anchor.getNode().getPreviousSibling();return ke(t)&&t.isTextEntity()}return!1})}(f,s.leadOffset))&&function(e,t,n,r){let i=Je(n);if(i===null||!i.isCollapsed)return!1;let a=Oe(i,r),o=a.anchorNode,s=e,c=a.anchorOffset;if(o==null||c==null)return!1;try{t.setStart(o,s),t.setEnd(o,c)}catch{return!1}return!0}(s.leadOffset,r,n,f.getRootElement()))return void(0,G.startTransition)(()=>v({getRect:()=>r.getBoundingClientRect(),match:s}));e()})});return()=>{e()}},[f,o,t,p,_,v,d]),(0,G.useEffect)(()=>f.registerEditableListener(e=>{e||_()}),[f,_]),p===null||f===null||y.current===null?null:(0,K.jsx)(QR,{close:_,resolution:p,editor:f,anchorElementRef:y,options:e,menuRenderFn:a,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:c,preselectFirstItem:u})}async function nz(e,t,n){if(!e)return[];let{paths:r}=await e.command({type:`project.listPaths`,projectId:t,query:n});return r}var rz=120,iz={items:[],loading:!1,error:null};function az(e){let t=Qr(),n=e.ports?.commands??t,r=e.ports?.timer??Ln,i=Jk.useScopedStore(e=>e.mentionSuggestions),a=Jk.useScopedStore(e=>e.setMentionSuggestions),o=Jk.useScopedStoreApi(),s=(0,G.useRef)(null),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!e.enabled||!e.projectId){a(iz);return}s.current!==null&&r.clearTimeout(s.current),c.current?.abort(),a({items:o.getState().mentionSuggestions.items,loading:!0,error:null});let t=new AbortController;return c.current=t,s.current=r.setTimeout(()=>{nz(n,e.projectId,e.query).then(e=>{t.signal.aborted||a({items:e,loading:!1,error:null})},nr(e=>{t.signal.aborted||a({items:[],loading:!1,error:e.message})}))},rz),()=>{s.current!==null&&r.clearTimeout(s.current),t.abort()}},[e.enabled,e.projectId,e.query,n,r,a,o]),i}var oz=[];function sz(e,t){let{namespaced:n,listsEverything:r,nameQuery:i}=Kt(t,`agent`);if(!n&&!r)return[];let a=n?i:``;return e.filter(e=>e.name.toLowerCase().includes(a)).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({kind:`agent`,subagent:e}))}function cz(e){let t=br(e=>e.settings?.subagents??oz);return(0,G.useMemo)(()=>({items:e.enabled?sz(t,e.query):[]}),[e.enabled,e.query,t])}var lz=[];function uz(e){return Mr(e).map(e=>({id:e.groupKey,localPath:e.localPath}))}function dz(e,t,n){let{slugByProjectId:r}=qt(e),{listsEverything:i,nameQuery:a}=Kt(t,`project`),o=[];for(let t of e){if(t.id===n)continue;let e=r.get(t.id);if(e===void 0)continue;let s=kr(t.localPath);(i||e.includes(a)||s.toLowerCase().includes(a))&&o.push({kind:`project`,projectId:t.id,slug:e,title:s,localPath:t.localPath})}return o.sort((e,t)=>e.slug.localeCompare(t.slug))}function fz(e){let t=Yr(e=>e.sidebarData);return(0,G.useMemo)(()=>e.enabled?{items:dz(uz(t),e.query,e.excludeProjectId)}:{items:lz},[e.enabled,e.query,e.excludeProjectId,t])}var pz=[];function mz(e,t){let{handleByBeaconId:n}=pt(e),{listsEverything:r,nameQuery:i}=Kt(t,`beacon`),a=[];for(let t of e){let e=n.get(t.id);e!==void 0&&(r||e.includes(i)||(t.alias??``).includes(i)||t.label.toLowerCase().includes(i))&&a.push({kind:`beacon`,beaconId:t.id,handle:e,alias:t.alias??null,hostname:t.label})}return a.sort((e,t)=>e.handle.localeCompare(t.handle))}function hz(e){let t=br(mr);return(0,G.useMemo)(()=>e.enabled?{items:mz(t,e.query)}:{items:pz},[e.enabled,e.query,t])}function gz(e,t){return e===null?!1:e.x!==t.x||e.y!==t.y}function _z(){let e=(0,G.useRef)(null);return(0,G.useCallback)((t,n,r)=>{let i={x:t.clientX,y:t.clientY},a=gz(e.current,i);e.current=i,a&&r(n)},[])}function vz(e){return(0,G.useCallback)((t,n)=>{let r=e.exec(t);return r===null?null:{leadOffset:r.index+(r[0].length-r[1].length),matchingString:r[2]??``,replaceableString:r[1]}},[e])}function yz({kind:e,maxHeightClass:t,rowClassName:n,options:r,selectedIndex:i,onPick:a,onRowPointerMove:o,renderRow:s,placeholder:c}){return(0,K.jsx)(`ul`,{role:`listbox`,[fi]:e,className:B(`absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl overflow-auto rounded-md border border-border bg-popover shadow-md`,t),children:c??r.map((e,t)=>(0,K.jsx)(`li`,{ref:e.setRefElement,role:`option`,"aria-selected":t===i,onMouseDown:t=>{t.preventDefault(),a(e)},onMouseMove:e=>o(e,t),className:B(n,t===i&&`bg-accent text-accent-foreground`),children:s(e)},e.key))})}var bz=/(?:^|\s)(@((?:[^@\s]){0,200}))$/;function xz(e){return e.kind===`agent`?`agent:${e.subagent.id}`:e.kind===`project`?`project:${e.project.projectId}`:e.kind===`beacon`?`beacon:${e.beacon.beaconId}`:`path:${e.path.kind}:${e.path.path}`}function Sz(e){return e.kind===`agent`?{mentionKind:`agent`,value:e.subagent.name,label:e.subagent.name}:e.kind===`project`?{mentionKind:`project`,value:e.project.slug,label:tn(`project`,e.project.slug)}:e.kind===`beacon`?{mentionKind:`beacon`,value:e.beacon.handle,label:tn(`beacon`,e.beacon.handle)}:{mentionKind:`path`,value:e.path.path,label:e.path.path}}var Cz=class extends KR{data;constructor(e){super(xz(e)),this.data=e}};function wz(e,t,n){let{namespaced:r,listsEverything:i}=Kt(t,n);return i&&!r?e.slice(0,3):e}function Tz(e){let t=e.query.toLowerCase(),n=wz(e.agents,t,`agent`),r=wz(e.projects,t,`project`),i=wz(e.beacons,t,`beacon`);return[...n.map(e=>({kind:`agent`,subagent:e.subagent})),...r.map(e=>({kind:`project`,project:e})),...i.map(e=>({kind:`beacon`,beacon:e})),...e.paths.map(e=>({kind:`path`,path:e}))]}function Ez(){return Array.from({length:4}).map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`h-3.5 w-3.5 rounded bg-muted animate-pulse`}),(0,K.jsx)(`span`,{className:`h-3 w-40 max-w-full rounded bg-muted animate-pulse`})]},t))}function Dz({data:e,onlineBeaconIds:t}){if(e.kind===`agent`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_o,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-mono truncate`,children:tn(`agent`,e.subagent.name)}),e.subagent.description?(0,K.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:e.subagent.description}):null]});if(e.kind===`project`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jo,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-mono truncate`,children:tn(`project`,e.project.slug)}),(0,K.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:e.project.localPath})]});if(e.kind===`beacon`){let n=t.has(e.beacon.beaconId);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ds,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-mono truncate`,children:tn(`beacon`,e.beacon.handle)}),e.beacon.alias===null?null:(0,K.jsx)(`span`,{className:`min-w-0 truncate text-xs font-mono text-muted-foreground`,children:e.beacon.hostname}),(0,K.jsx)(`span`,{className:`ml-auto text-xs`,children:(0,K.jsx)(zr,{tone:n?`active`:`muted`,label:n?`Online`:`Offline`})})]})}let n=e.path.kind===`dir`?No:Ht;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-mono truncate`,children:e.path.path})]})}function Oz({projectId:e}){let t=Jk.useScopedStore(e=>e.mentionQuery),n=Jk.useScopedStore(e=>e.setMentionQuery),r=vz(bz),i=t!==null,a=az({projectId:e,query:t??``,enabled:i}),o=cz({query:t??``,enabled:i}),s=fz({query:t??``,enabled:i,excludeProjectId:e}),c=hz({query:t??``,enabled:i}),l=v(N),u=(0,G.useMemo)(()=>new Set(l.filter(e=>e.online).map(e=>e.id)),[l]),d=(0,G.useMemo)(()=>Tz({query:t??``,agents:o.items,projects:s.items,beacons:c.items,paths:a.items}).map(e=>new Cz(e)),[t,o.items,s.items,c.items,a.items]),f=_z(),p=(0,G.useCallback)((e,t,n)=>{let r=Yt(Sz(e.data));t===null?Fe([r]):t.replace(r);let i=Ce(` `);r.insertAfter(i),i.select(),n()},[]),m=(0,G.useCallback)((e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r,options:i})=>e.current==null||i.length===0&&!a.loading?null:(0,K.jsx)(yz,{kind:`mention`,maxHeightClass:`max-h-80`,rowClassName:`flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm`,options:i,selectedIndex:t,onPick:n,onRowPointerMove:(e,t)=>f(e,t,r),placeholder:a.loading&&i.length===0?(0,K.jsx)(Ez,{}):void 0,renderRow:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uo,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(Dz,{data:e.data,onlineBeaconIds:u})]})}),[a.loading,f,u]);return(0,K.jsx)(tz,{options:d,onQueryChange:n,onSelectOption:p,triggerFn:r,menuRenderFn:m})}var kz=[];function Az(e,t){return t?e.byProjectId[t]??kz:kz}function jz(e){return f(t=>Az(t,e))}function Mz(e){return e.replace(/^\/+/,``)}var Nz={project:0,personal:0,builtin:1,plugin:2};function Pz(e,t){let n=(Nz[e.scope??``]??1)-(Nz[t.scope??``]??1);return n===0?e.name.localeCompare(t.name):n}function Fz(e,t){if(t===``)return[...e].sort(Pz);let n=t.toLowerCase(),r=[],i=[];for(let t of e){let e=t.name.toLowerCase();e.startsWith(n)?r.push(t):e.includes(n)&&i.push(t)}return[...r.sort(Pz),...i.sort(Pz)]}var Iz=new Map;function Lz(e,t){return`${Mz(e)}:${Mz(t)}`}function Rz(e,t){if(t.length===0)return{commands:e,promptByName:Iz};let n=new Set(e.map(e=>Mz(e.name))),r=[...e],i=new Map;for(let e of t){let t=Lz(e.pluginId,e.name);n.has(t)||(n.add(t),r.push({name:t,description:e.description,argumentHint:``,scope:`plugin`}),i.set(t,e.prompt))}return i.size===0?{commands:e,promptByName:Iz}:{commands:r,promptByName:i}}var zz=/(?:^|\s)(\/(\S*))$/,Bz=class extends KR{command;constructor(e){super(e.name),this.command=e}};function Vz(e){let t=new Set,n=[];for(let r of e){let e=Mz(r.name);t.has(e)||(t.add(e),n.push(r))}return n}function Hz(e,t){return ci(t)?e:e.filter(e=>e.scope!==`cli`)}function Uz({command:e,promptByName:t,textNodeContainingQuery:n}){let r=t.get(Mz(e.name));if(r!==void 0){let e=Ce(r);n===null?Fe([e]):n.replace(e),e.select(r.length,r.length);return}let i=Gt({commandName:Mz(e.name),hasArgument:!!e.argumentHint});n===null?Fe([i]):n.replace(i);let a=Ce(` `);i.insertAfter(a),a.select()}function Wz({cmd:e}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,K.jsxs)(`span`,{className:`font-mono break-all sm:whitespace-nowrap sm:break-normal`,children:[`/`,Mz(e.name)]}),e.kind===`skill`?(0,K.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border bg-muted px-1 py-px text-xs font-medium tracking-wide text-muted-foreground`,children:`skill`}):null,e.argumentHint?(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground whitespace-nowrap`,children:e.argumentHint}):null]}),e.description?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground sm:text-right`,children:Vr(e.description)}):null]})}function Gz({projectId:e,provider:t}){let n=Jk.useScopedStore(e=>e.slashQuery),r=Jk.useScopedStore(e=>e.setSlashQuery),i=jz(e),a=(0,G.useMemo)(()=>Hz(i,t),[i,t]),o=Ua(Ca),s=vz(zz),c=_z(),l=(0,G.useMemo)(()=>Rz(a,o),[a,o]),u=(0,G.useMemo)(()=>Vz(Fz(l.commands,n??``)).map(e=>new Bz(e)),[l,n]),d=(0,G.useCallback)((e,t,n)=>{Uz({command:e.command,promptByName:l.promptByName,textNodeContainingQuery:t}),n()},[l]),f=(0,G.useCallback)((e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r,options:i})=>e.current==null||i.length===0?null:(0,K.jsx)(yz,{kind:`slash`,maxHeightClass:`max-h-64`,rowClassName:`flex flex-col gap-0.5 px-3 py-1.5 cursor-pointer text-sm sm:flex-row sm:items-center sm:gap-3`,options:i,selectedIndex:t,onPick:n,onRowPointerMove:(e,t)=>c(e,t,r),renderRow:e=>(0,K.jsx)(Wz,{cmd:e.command})}),[c]);return(0,K.jsx)(tz,{options:u,onQueryChange:r,onSelectOption:d,triggerFn:s,menuRenderFn:f})}var Kz=`composer.inlineUpload`;function qz(e){return`${W(Kz,e)}:`}function Jz(e,t){vn(W(Kz,e,crypto.randomUUID()),t)}function Yz(e){let t=qz(e);return _n(e=>Object.keys(e.inFlight).some(e=>e.startsWith(t)))}var Xz={maxFiles:50,maxConcurrent:3};async function Zz(e,t,n,r,i){if(e.length===0||e.length>Xz.maxFiles)return;let a=0;async function o(){if(a>=e.length)return;let s=e[a++];try{let{attachments:e}=await r({projectId:n,file:s,onProgress:()=>{}}).promise,a=e[0];if(!a){i?.(`Upload failed: no attachment returned`);return}t.update(()=>{Fe([Zt(a)])})}catch(e){if(e instanceof Error&&e.name===`UploadAbortedError`)return;i?.(rr(e))}await o()}let s=[];for(let t=0;t<Math.min(Xz.maxConcurrent,e.length);t++)s.push(o());await Promise.all(s)}var Qz={"image/gif":`gif`,"image/jpeg":`jpg`,"image/png":`png`,"image/webp":`webp`};function $z(e){return Qz[e.type]??`bin`}function eB(e){let t=e.name.trim().toLowerCase();return!t||t===`image.${$z(e)}`||t===`image.png`}function tB(e,t,n){if(e.name&&!eB(e))return e;let r=$z(e),i=`clipboard-${n}${t===0?``:`-${t}`}.${r}`;return Object.defineProperty(e,"name",{configurable:!0,value:i}),e}function nB(e,t){let n=[];for(let r of e){if(r.kind!==`file`||!r.type.startsWith(`image/`))continue;let e=r.getAsFile();e&&n.push(tB(e,n.length,t))}return n}function rB(e){return e?e.types.includes(`text/plain`)||e.types.includes(`text/html`):!1}function iB({projectId:e,uploadOwnerId:t,onUploadError:n,uploadFileFn:r=fR}){let[i]=mL();return(0,G.useEffect)(()=>i.registerCommand(st,a=>{if(!(a instanceof ClipboardEvent))return!1;let o=a.clipboardData,s=nB(o?.items??[],Date.now());if(s.length===0)return!1;let c=rB(o);return e&&Jz(t,()=>Zz(s,i,e,r,n)),!c},3),[i,e,t,n,r]),null}function aB(e){let t=e.dataTransfer?.items;if(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r&&r.kind===`file`){let t=r.getAsFile();t&&e.push(t)}}return e}let n=e.dataTransfer?.files;if(!n)return[];let r=[];for(let e=0;e<n.length;e++){let t=n[e];t&&r.push(t)}return r}function oB({projectId:e,uploadOwnerId:t,onUploadError:n,uploadFileFn:r=fR}){let[i]=mL();return(0,G.useEffect)(()=>{let a=i.registerCommand(Pe,e=>aB(e).length!==0&&(e.preventDefault(),!0),3),o=i.registerCommand(Me,a=>{let o=aB(a);return o.length!==0&&(a.preventDefault(),e&&Jz(t,()=>Zz(o,i,e,r,n)),!0)},3);return()=>{a(),o()}},[i,e,t,n,r]),null}function sB(e){if(ke(e))return e.getTextContent();if(Te(e))return`
28
+ `;if(_t(e)){let t=``,n=e.getChildren();for(let e of n)t+=sB(e);return t}return e.getTextContent()}function cB(e){let t=``,n=[];return e.getEditorState().read(()=>{let e=Ie().getChildren(),r=[];for(let t of e)r.push(sB(t));t=r.join(`
29
+ `),t=t.replace(/(?:\r\n|\r|\n)+$/,``).trimEnd(),n=$t().map(e=>e.getAttachment())}),{text:t,attachments:n}}function lB({onSubmit:e,disabled:t,dom:n=pi}){let[r]=mL(),i=(0,G.useRef)(!1),a=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{function e(){i.current=!0}function t(){i.current=!1}let n=null,a=r.registerRootListener((r,i)=>{i?.removeEventListener(`compositionstart`,e),i?.removeEventListener(`compositionend`,t),r?.addEventListener(`compositionstart`,e),r?.addEventListener(`compositionend`,t),n=r});return()=>{a(),n?.removeEventListener(`compositionstart`,e),n?.removeEventListener(`compositionend`,t)}},[r]),(0,G.useEffect)(()=>r.registerCommand(it,o=>{if(t||!o||i.current||o.isComposing||o.keyCode===229||o.shiftKey||n.hasTypeaheadMenuOpen()||n.isTouchDevice()&&!n.matchesMediaQuery(`(hover: hover) and (pointer: fine)`)||a.current)return!1;let s=cB(r);return s.text.trim().length>0||s.attachments.length>0?(o.preventDefault(),r.update(()=>{let e=Ie();e.clear(),e.append($e())}),a.current=!0,queueMicrotask(()=>{a.current=!1}),e(s),!0):!1},3),[r,t,e,n]),null}function uB({onChange:e}){let[t]=mL();return(0,G.useEffect)(()=>t.registerUpdateListener(({editorState:t})=>{let n=t.toJSON(),r=``;t.read(()=>{r=Ie().getTextContent()}),e(n,r)}),[t,e]),null}var dB=/(\S+)$/;function fB(e,t){let n=dB.exec(e);if(n===null)return null;let r=n[1];for(let e of t)if(e.shortcut===r)return e;return null}function pB(e,t,n,r){return e.shiftKey||e.ctrlKey||e.metaKey||e.altKey?`ignore`:e.repeat?r?`swallow-repeat`:`ignore`:t||n===0?`ignore`:`attempt`}function mB({snippets:e,dom:t=pi}){let[n]=mL();return(0,G.useEffect)(()=>{let r=!1;return n.registerCommand(ze,i=>{let a=pB(i,t.hasTypeaheadMenuOpen(),e.length,r);return i.repeat||(r=!1),a===`ignore`?!1:a===`swallow-repeat`?(i.preventDefault(),!0):n.getEditorState().read(()=>{let t=St();if(!Ke(t)||!t.isCollapsed())return!1;let n=t.anchor.getNode();return ke(n)?fB(n.getTextContent().slice(0,t.anchor.offset),e)!==null:!1})?(r=!0,i.preventDefault(),n.update(()=>{let t=St();if(!Ke(t)||!t.isCollapsed())return;let n=t.anchor,r=n.getNode();if(!ke(r))return;let i=n.offset,a=r.getTextContent().slice(0,i),o=dB.exec(a);if(o===null)return;let s=fB(a,e);if(s===null)return;let c=o[1],l=i-c.length,u=s.expansion.split(`
30
+ `);if(r.spliceText(l,c.length,u[0]??``,!0),u.length>1){let e=St();if(!Ke(e))return;for(let t=1;t<u.length;t+=1){e.insertLineBreak();let n=u[t];n.length>0&&e.insertText(n)}}}),!0):!1},1)},[n,e,t]),null}function hB(e,t){let{beacons:n,unresolvedHandles:r}=nt(e,t),{handleByBeaconId:i}=pt(t);return[...n.map(e=>({kind:`ok`,label:i.get(e.id)??e.id,id:e.id})),...r.map(e=>({kind:`missing`,label:e}))]}function gB(e,t){return e&&!t}var _B=[],vB={reason:`Model is locked while a cron job is running — pause or remove the cron job to change it`};function yB(e,t,n){return e.provider===`claude`?{...e,model:t,modelOptions:{...e.modelOptions,contextWindow:ii(t,e.modelOptions.contextWindow,n)}}:{...e,model:t}}function bB({bridgeRef:e}){let[t]=mL();return(0,G.useEffect)(()=>(e.current={clearEditor:()=>{t.update(()=>{let e=Ie();e.clear(),e.append($e())})},hydrateFromDraft:(e,n)=>{if(e)try{let n=t.parseEditorState(e);t.setEditorState(n);return}catch(e){Yn.error(`[ChatInput] Draft restore failed, falling back to plain text:`,String(e))}n?t.update(()=>{let e=Ie();e.clear();let t=$e();t.append(Ce(n)),e.append(t)}):t.update(()=>{let e=Ie();e.clear(),e.append($e())})},readCurrentPayload:()=>cB(t),focusEditor:()=>{t.focus()}},()=>{e.current=null}),[t,e]),null}function xB({isDisabled:e}){let[t]=mL();return(0,G.useEffect)(()=>{t.setEditable(!e)},[t,e]),null}function SB({onTextChange:e}){let[t]=mL();return(0,G.useEffect)(()=>(e(cB(t).text),t.registerUpdateListener(()=>{e(cB(t).text)})),[t,e]),null}var CB=(0,G.forwardRef)(({onSubmit:e,onLayoutChange:t,onCancel:n,disabled:r,canCancel:i,chatId:a,projectId:o,inputElementRef:s,activeProvider:c,availableProviders:l,contextWindowSnapshot:u=null,sessionTotals:d=null,previousPrompt:f=null,ports:p,hasUnpausedCronJob:m=!1},h)=>{let g=p?.dom??pi,_=Qr(),v=p?.commands??_,{getDraft:y,setDraft:x,clearDraft:S}=b(),{getComposerState:C,initializeComposerForChat:w,setChatComposerModel:T,setChatComposerPlanMode:E,resetChatComposerFromProvider:D}=M(),O=a??`__new__`,A=$L(a??null),j=M(e=>e.chatStates[O])??C(O),N=QL(),P=Jk.useScopedStore(e=>e.currentText),F=Jk.useScopedStore(e=>e.setCurrentText),I=Jk.useScopedStore(e=>e.chatSettingsOpen),ee=Jk.useScopedStore(e=>e.setChatSettingsOpen),L=vR({projectId:o??null,chatId:a??null,commands:v}),{attachments:R,uploadError:te,setUploadError:ne,selectedAttachment:re,selectAttachment:ie,enqueue:ae,beginSubmit:z}=L,se=(0,G.useRef)(null),ce=(0,G.useRef)(null),le=j,ue=j.provider,de=br(_r),fe=br(lr),pe=(0,G.useRef)(null),me=(l.find(e=>e.id===ue)??l[0])?.supportsPlanMode??!1,he=(0,G.useMemo)(()=>{if(le.provider!==`claude`)return u;let{modelOptions:e}=le,t=ai(ii(le.model,e.contextWindow,de));return un(u,t)},[u,de,le]),ge=Yz(O),_e=ge||L.isUploading,ve=W(`chat.send`,O),ye=bn(ve),be=bn(W(`chat.cancel`,a??``)),xe=P.trim().length>0,Se=P.trim().length>0||L.hasUploadedAttachments,Ce=[...R].sort((e,t)=>e.kind===t.kind?0:e.kind===`image`?-1:1),we=br(e=>e.settings?.subagents??_B),Te=br(mr),Ee=(0,G.useMemo)(()=>{let e=new Map(we.map(e=>[e.name.toLowerCase(),e])),t=[...P.matchAll(WR())],n=[];for(let r of t){let t=r[2];if(!t)continue;let i=e.get(t.toLowerCase());n.push(i?{kind:`ok`,family:`agent`,label:i.name,id:i.id}:{kind:`missing`,family:`agent`,label:t})}for(let e of hB(P,Te))n.push({...e,family:`beacon`});return n},[P,we,Te]);(0,G.useImperativeHandle)(h,()=>({enqueueFiles:ae,focus:()=>ce.current?.focusEditor()}),[ae]);let De=(0,G.useCallback)(()=>da(le,me),[le,me]),Oe=(0,G.useCallback)(async(t,n)=>{let r=z(),i={...De(),attachments:[...r.attachments,...n]};ce.current?.clearEditor(),F(``),a&&S(a);try{await e(t,i),r.commit()}catch(e){Yn.error(`[ChatInput] Submit failed:`,String(e)),a&&x(a,t),r.rollback()}},[z,De,a,S,e,x,F]),ke=(0,G.useCallback)(e=>{Se&&!_e&&vn(ve,()=>Oe(e.text,e.attachments))},[Se,_e,Oe,ve]),Ae=(0,G.useCallback)(()=>{if(!Se||_e)return;let e=ce.current?.readCurrentPayload()??{text:P,attachments:[]};vn(ve,()=>Oe(e.text,e.attachments))},[Se,_e,P,Oe,ve]),je=(0,G.useCallback)((e,t)=>{a&&x(a,e,t)},[a,x]);(0,G.useEffect)(()=>{w(O,{providerHint:c})},[O,w,c]),(0,G.useEffect)(()=>{if(!a)ce.current?.clearEditor();else{let e=y(a);e?ce.current?.hydrateFromDraft(e.lexicalState??null,e.text):ce.current?.clearEditor()}ce.current?.focusEditor()},[a]),(0,G.useLayoutEffect)(()=>{t?.()},[t,R.length,te,P]),(0,G.useEffect)(()=>g.addWindowListener(`resize`,()=>{t?.()}),[g,t]);function Me(e){M.getState().setComposerState(O,e(le))}function Ne(e){Me(t=>k(t,e))}function Pe(e){Me(t=>t.provider===`claude`?yB({...t,modelOptions:{...t.modelOptions,contextWindow:e}},t.model,de):t)}function Fe(e){E(O,e)}function Ie(){Fe(!le.planMode)}function Le(e){zt(e).openInNewTab?g.openWindow(new URL(e.contentUrl,g.getOrigin()).toString(),`_blank`,`noopener,noreferrer`):ie(e.id)}function Re(e){e.nativeEvent.isComposing||(e.key===`Tab`&&e.shiftKey&&me?(e.preventDefault(),Ie()):e.key===`Escape`&&i?(e.preventDefault(),n?.()):e.key!==`ArrowUp`||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||P.length!==0||!f||(e.preventDefault(),ce.current?.hydrateFromDraft(null,f),F(f),a&&x(a,f)))}let ze=(0,G.useCallback)(e=>{ne(e)},[ne]),Be=(0,G.useMemo)(()=>ct({namespace:`kanna-composer-${O}`,nodes:[...Wt],editable:!r}),[O]);function Ve(e){return(0,K.jsx)(IR,{availableProviders:l,selectedProvider:ue,model:le.model,modelOptions:le.modelOptions,onProviderChange:e=>D(O,e),onModelChange:(e,t)=>T(O,t),modelLock:m?vB:null,onModelOptionChange:e=>{switch(e.type){case`claudeReasoningEffort`:case`codexReasoningEffort`:case`antigravityReasoningEffort`:Ne(e.effort);break;case`contextWindow`:Pe(e.contextWindow);break;case`fastMode`:Me(t=>t.provider===`codex`?{...t,modelOptions:{...t.modelOptions,fastMode:e.fastMode}}:t)}},planMode:le.planMode,onPlanModeChange:Fe,includePlanMode:me,className:e})}return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:B(`px-3 pt-0`,N&&`px-5`),children:[(0,K.jsxs)(`div`,{className:`max-w-[840px] mx-auto`,children:[Ee.length>0?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2 pt-2`,children:Ee.map((e,t)=>(0,K.jsxs)(`span`,{className:B(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs`,e.kind===`ok`?`bg-accent text-accent-foreground`:`bg-destructive/15 text-destructive`),children:[e.family===`beacon`?(0,K.jsx)(ds,{className:`h-3 w-3`}):(0,K.jsx)(_o,{className:`h-3 w-3`}),e.family,`/`,e.label,e.kind===`missing`&&(0,K.jsx)(`span`,{className:`ml-1 font-medium`,children:`unknown`})]},`${e.family}:${e.kind}:${e.label}:${t}`))}):null,R.length>0?(0,K.jsx)(XL,{className:`overflow-x-auto overflow-y-hidden whitespace-nowrap px-2 pb-2`,children:(0,K.jsx)(`div`,{className:`flex items-end gap-2 pt-2`,children:Ce.map(e=>(0,K.jsx)(`div`,{className:B(`flex shrink-0 flex-col justify-end`,e.status===`failed`&&`text-destructive`),children:e.kind===`image`?(0,K.jsx)(nn,{attachment:e,previewUrl:e.previewUrl,size:`composer`,onClick:e.status===`uploaded`?()=>Le(e):void 0,onRemove:()=>L.remove(e),uploadProgress:e.status===`uploading`?e.uploadProgress??null:void 0,onCancelUpload:e.status===`uploading`?()=>L.remove(e):void 0}):(0,K.jsx)(Ut,{attachment:e,onClick:e.status===`uploaded`&&e.contentUrl?()=>Le(e):void 0,onRemove:()=>L.remove(e),uploadProgress:e.status===`uploading`?e.uploadProgress??null:void 0,onCancelUpload:e.status===`uploading`?()=>L.remove(e):void 0})},e.id))})}):null,(0,K.jsxs)(`div`,{className:B(`relative flex items-end max-w-[840px] mx-auto rounded-xl border border-border bg-background pr-1.5 transition-colors focus-within:border-ring/60 focus-within:ring-2 focus-within:ring-ring/30 dark:bg-card/90`,A.className),onKeyDown:Re,children:[A.sweep,(0,K.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Add attachment`,disabled:r,onPointerDown:e=>e.preventDefault(),onClick:()=>pe.current?.click(),className:`relative flex-shrink-0 ml-1 mb-1 h-11 w-11 rounded-full text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(rs,{className:`h-5 w-5`})}),(0,K.jsx)(`input`,{ref:pe,type:`file`,multiple:!0,disabled:r,tabIndex:-1,"aria-hidden":`true`,className:`sr-only`,onChange:e=>{let t=[...e.target.files??[]];t.length>0&&ae(t),e.target.value=``}}),(0,K.jsx)(_L,{initialConfig:Be,children:(0,K.jsxs)(`div`,{[$i]:``,className:`relative flex-1 min-w-0`,children:[(0,K.jsx)(PL,{contentEditable:(0,K.jsx)(BL,{placeholder:(0,K.jsxs)(`div`,{className:`pointer-events-none absolute top-3 left-3 flex items-center gap-2 text-base text-muted-foreground select-none md:top-4 md:left-6`,children:[(0,K.jsx)(`span`,{children:`Build something...`}),f?(0,K.jsxs)(`span`,{className:`hidden md:inline-flex items-center gap-1 text-xs`,children:[(0,K.jsx)(Hn,{className:`h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-xs`,children:`↑`}),`Edit last message`]}):null]}),className:`flex-1 text-base p-3 md:p-4 !pr-2 pl-3 md:pl-6 min-h-[44px] max-h-[200px] outline-none focus:outline-none focus-visible:outline-none focus-visible:ring-0 bg-transparent border-0 shadow-none overflow-auto`,"aria-label":`Chat input`,"aria-placeholder":`Build something...`,"aria-multiline":`true`,role:`textbox`}),ErrorBoundary:yL}),(0,K.jsx)(YL,{}),(0,K.jsx)(Oz,{projectId:o??null}),(0,K.jsx)(Gz,{projectId:o??null,provider:ue}),(0,K.jsx)(iB,{projectId:o??null,uploadOwnerId:O,onUploadError:ze}),(0,K.jsx)(oB,{projectId:o??null,uploadOwnerId:O,onUploadError:ze}),(0,K.jsx)(mB,{snippets:fe}),(0,K.jsx)(lB,{onSubmit:ke,disabled:r||_e||ye}),(0,K.jsx)(uB,{onChange:je}),(0,K.jsx)(bB,{bridgeRef:ce}),(0,K.jsx)(xB,{isDisabled:r}),(0,K.jsx)(SB,{onTextChange:F})]})}),(0,K.jsx)(U,{type:`button`,onPointerDown:e=>{e.preventDefault(),!r&&xe&&!_e?Ae():i?n?.():!r&&Se&&!_e&&Ae()},disabled:r||!i&&!Se||_e,pending:ye||be,size:`icon`,"aria-label":gB(!!i,xe)?`Stop`:`Send message`,className:`flex-shrink-0 bg-primary text-background rounded-full cursor-pointer h-11 w-11 mb-1 -mr-0.5 md:mr-0 md:mb-1.5 touch-manipulation disabled:opacity-50`,children:gB(!!i,xe)?(0,K.jsx)(`div`,{className:`w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current`}):(0,K.jsx)(oe,{className:`h-5 w-5 md:h-6 md:w-6`})})]})]}),ge?(0,K.jsxs)(`div`,{role:`status`,className:`max-w-[840px] mx-auto mt-2 px-1 flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(hn,{}),`Uploading attachment…`]}):null,te?(0,K.jsx)(`div`,{className:`max-w-[840px] mx-auto mt-2 px-1 text-sm text-destructive`,children:te}):null]}),(0,K.jsxs)(`div`,{className:B(`relative py-3 max-w-[840px] mx-auto`,N&&`p-5 pt-3`),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`hidden md:block`,children:Ve(`mx-auto max-w-[840px]`)}),(0,K.jsxs)(Pn,{open:I,onOpenChange:ee,children:[(0,K.jsxs)(U,{ref:se,variant:`outline`,size:`default`,className:`ml-3 md:hidden`,onClick:()=>ee(!0),"aria-haspopup":`dialog`,children:[(0,K.jsx)(Cs,{className:`size-4`}),`Chat settings`]}),(0,K.jsxs)(Nn,{size:`sm`,onCloseAutoFocus:e=>{e.preventDefault(),se.current?.focus({preventScroll:!0})},children:[(0,K.jsxs)(jn,{children:[(0,K.jsx)(Rn,{children:`Chat settings`}),(0,K.jsx)(An,{children:`Choose the provider, model, reasoning, context, and permission mode for this chat.`})]}),(0,K.jsx)(In,{children:Ve(`flex-wrap justify-start gap-2`)})]})]})]}),d??he?(0,K.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-2 pr-3 md:flex`,children:[(0,K.jsx)(RR,{totals:d??null}),he?(0,K.jsx)(LR,{usage:he}):null]}):null]}),d??he?(0,K.jsxs)(`div`,{className:`flex md:hidden items-center justify-end gap-2 px-[13px] pt-2`,children:[(0,K.jsx)(RR,{totals:d??null}),he?(0,K.jsx)(LR,{usage:he}):null]}):null]}),(0,K.jsx)(en,{source:re?Jt(re,`user_attachment`):null,open:re!==null,onOpenChange:e=>!e&&ie(null)})]})}),wB=(0,G.memo)(CB),TB=(0,G.forwardRef)((e,t)=>(0,K.jsx)(U,{ref:t,variant:`ghost`,size:`none`,"aria-label":`Public link`,...e,className:e.className??`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,children:(0,K.jsx)(Yo,{strokeWidth:2,className:`h-4.5`})})),EB=Qn(`SharePopoverBody`,()=>e=>({error:null,copiedTokenId:null,setError:t=>e({error:t}),markCopied:t=>e({copiedTokenId:t,error:null})}));function DB(e,t){let n=e-t;if(n<=0)return`Expired`;let r=Math.round(n/36e5);return r<1?`Expires in <1h`:r<48?`Expires in ${r}h`:`Expires in ${Math.round(r/24)}d`}function OB(e){let t=e.clipboard??wt,n=EB.useScopedStore(e=>e.error),r=EB.useScopedStore(e=>e.setError),i=e.shares.filter(e=>!e.revoked),{onMint:a,chatId:o}=e,s=W(`share.mint`,o),c=bn(s),l=(0,G.useCallback)(()=>{vn(s,async()=>{try{await a(o),r(null)}catch(e){r(`Couldn't create a share link: ${rr(e)}`)}})},[s,a,o,r]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(U,{variant:`default`,pending:c,"data-share-mint":``,onClick:l,children:c?`Creating…`:`Create share link`}),n?(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive-text`,children:n}):null,i.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No active share links for this chat.`}):(0,K.jsx)(`ul`,{className:`space-y-2`,children:i.map(n=>(0,K.jsx)(kB,{share:n,now:e.now,clipboard:t,onRevoke:e.onRevoke},n.tokenId))})]})}function kB({share:e,now:t,clipboard:n,onRevoke:r}){let i=EB.useScopedStore(e=>e.setError),a=EB.useScopedStore(e=>e.markCopied),o=EB.useScopedStore(t=>t.copiedTokenId===e.tokenId),s=W(`share.copy`,e.tokenId),c=W(`share.revoke`,e.tokenId),l=bn(s),u=bn(c),{tokenId:d,url:f}=e,p=(0,G.useCallback)(()=>{vn(s,async()=>{try{await n.writeText(f),a(d)}catch(e){i(`Couldn't copy the link: ${rr(e)}`)}})},[n,s,a,i,d,f]),m=(0,G.useCallback)(()=>{vn(c,async()=>{try{await r(d),i(null)}catch(e){i(`Couldn't revoke the link: ${rr(e)}`)}})},[r,c,i,d]);return(0,K.jsxs)(`li`,{className:`flex flex-col gap-1 rounded border border-border/40 p-2 text-xs`,children:[(0,K.jsx)(`code`,{className:`break-all`,children:f}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(U,{size:`sm`,variant:`ghost`,pending:l,onClick:p,children:[l?null:(0,K.jsx)(Ct,{className:`h-3.5 w-3.5 mr-1`}),o?`Copied`:`Copy`]}),(0,K.jsxs)(U,{size:`sm`,variant:`ghost`,"data-share-revoke":``,pending:u,onClick:m,children:[u?null:(0,K.jsx)(qo,{className:`h-3.5 w-3.5 mr-1`}),u?`Revoking…`:`Revoke`]}),(0,K.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:DB(e.expiresAt,t)})]})]})}function AB(e){return(0,K.jsx)(EB.Provider,{init:void 0,children:(0,K.jsx)(OB,{...e})})}function jB(e){let t=(0,G.useMemo)(()=>Date.now(),[e.open]);return(0,K.jsxs)(zn,{children:[(0,K.jsxs)(aa,{open:e.open,onOpenChange:e.onOpenChange,children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsx)(no,{asChild:!0,children:e.trigger})}),(0,K.jsx)(Za,{align:`end`,className:`w-96 p-4 space-y-3`,children:(0,K.jsx)(AB,{chatId:e.chatId,shares:e.shares,now:t,onMint:e.onMint,onRevoke:e.onRevoke})})]}),(0,K.jsx)(Wn,{side:`bottom`,children:`Mint a public read-only link`})]})}function MB({bindings:e,provider:t,onOpenPath:n}){return e.length<=1?null:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-0.5`,children:[e.map(e=>{let t=kr(e.worktreePath),r=e.role===`primary`,i=e.projectStatus===`missing`;return(0,K.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-1 cursor-pointer`,onClick:()=>n(e.worktreePath),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.worktreePath))},children:[r?(0,K.jsx)(`span`,{className:`text-emerald-500`,children:`●`}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,K.jsx)(`span`,{className:`font-mono tabular-nums text-xs${i?` line-through text-muted-foreground`:``}`,children:t})]},e.projectId)}),t===`codex`&&(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground ml-2`,children:`codex: cwd-only`})]})}var NB=2;function PB(e){return{transformBox:`view-box`,transformOrigin:`0 ${e}px`}}function FB({durationsMs:e,live:t=!1,label:n,className:r}){let{ticks:i,baselineY:a,size:o}=lL(e,{live:t});return(0,K.jsxs)(`svg`,{role:`img`,"aria-label":n,viewBox:`0 0 ${o} ${o}`,className:B(`h-[26px] w-[26px] shrink-0`,r),children:[(0,K.jsx)(`line`,{x1:1,y1:a,x2:o-1,y2:a,stroke:`currentColor`,strokeWidth:1,className:`text-border`}),i.map((t,n)=>(0,K.jsxs)(`g`,{className:B(t.live?`text-logo`:`text-muted-foreground`,n===i.length-1&&`kanna-reduction-tick-in`),style:n===i.length-1?PB(a):void 0,children:[(0,K.jsx)(`line`,{x1:t.x,y1:a-.5,x2:t.x,y2:t.topY,stroke:`currentColor`,strokeWidth:1.4}),t.live?(0,K.jsx)(`line`,{x1:t.x+NB,y1:a-.5,x2:t.x+NB,y2:t.topY,stroke:`currentColor`,strokeWidth:1.4}):null]},n===i.length-1?`newest-${e.length}`:n))]})}function IB(e,t){return t?Er(e,t):kr(e)}function LB({hasGitRepo:e=!0,gitStatus:t=`unknown`,localPath:n,branchName:r,homeDir:i}){if(!e)return`Setup Git`;if(t===`unknown`)return null;let a=n?IB(n,i):``,o=r??`Detached HEAD`;return a?`${a} · ${o}`:o}var RB=Qn(`OpenExternalSelect`,({initialTarget:e})=>t=>({lastTarget:e,setLastTarget:e=>t({lastTarget:e})})),zB=[`cursor`,`xcode`,`windsurf`,`custom`].map(e=>({value:e,label:cr(e)})),BB={cursor:`/editor-icons/cursor.png`,defaultApp:`/editor-icons/default-app.png`,finder:`/editor-icons/finder.png`,preview:`/editor-icons/preview.png`,xcode:`/editor-icons/xcode.png`,terminal:`/editor-icons/terminal.png`,windsurf:`/editor-icons/windsurf.png`,custom:`/editor-icons/custom.png`};function VB({src:e,className:t}){return(0,K.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,draggable:!1,className:t})}function HB({preset:e,className:t}){switch(e){case`xcode`:return(0,K.jsx)(VB,{src:BB.xcode,className:t});case`windsurf`:return(0,K.jsx)(VB,{src:BB.windsurf,className:t});case`custom`:return(0,K.jsx)(VB,{src:BB.custom,className:t});default:return(0,K.jsx)(VB,{src:BB.cursor,className:t})}}function UB({className:e}){return(0,K.jsx)(VB,{src:BB.finder,className:e})}function WB({className:e}){return(0,K.jsx)(VB,{src:BB.preview,className:e})}function GB({className:e}){return(0,K.jsx)(VB,{src:BB.defaultApp,className:e})}function KB({className:e}){return(0,K.jsx)(w,{className:e})}function qB({className:e}){return(0,K.jsx)(VB,{src:BB.terminal,className:e})}var JB=ar([`finder`,`terminal`,`preview`,`default`]),YB=`editor:`,XB=`kanna:last-open-external`,ZB=`py-2 pl-2 pr-8`,QB=`rounded-md text-sm font-normal focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground`,$B=`flex items-center gap-3`,eV=`h-5 w-5 shrink-0`,tV={finder:`open_finder`,terminal:`open_terminal`,preview:`open_preview`,default:`open_default`};function nV(e){if(e===null)return null;if(JB(e))return{kind:e};if(!e.startsWith(YB))return null;let t=e.slice(7);return gr(t)?{kind:`editor`,preset:t}:null}function rV(e){return e.kind===`editor`?`editor:${e.preset}`:e.kind}function iV(e){return{kind:`editor`,preset:e}}function aV(e,t){return rV(e)===rV(t)}function oV({target:e,label:t,isMac:n}){return(0,K.jsxs)(`span`,{className:$B,children:[(0,K.jsx)(lV,{target:e,isMac:n,className:eV}),(0,K.jsx)(`span`,{children:t})]})}function sV(e,t){return{preset:e,commandTemplate:e===`custom`&&t?.trim()||sr(e)}}function cV(e,t){switch(e.kind){case`finder`:return t?`Finder`:`Folder`;case`terminal`:return`Terminal`;case`preview`:return`Preview`;case`default`:return`Default App`;case`editor`:return cr(e.preset)}}function lV({target:e,isMac:t,className:n}){switch(e.kind){case`finder`:return t?(0,K.jsx)(UB,{className:n}):(0,K.jsx)(KB,{className:n});case`terminal`:return(0,K.jsx)(qB,{className:n});case`preview`:return(0,K.jsx)(WB,{className:n});case`default`:return(0,K.jsx)(GB,{className:n});case`editor`:return(0,K.jsx)(HB,{preset:e.preset,className:n})}}function uV(e,t){return{value:rV(e),target:e,label:cV(e,t)}}function dV({editorPreset:e,isMac:t,includeFinder:n=!0,includeTerminal:r=!1,includePreview:i=!1,includeDefault:a=!1,menuKind:o=`context`}){let s=(e,n)=>n?[uV({kind:e},t)]:[],c=zB.filter(t=>t.value!==`custom`||e===`custom`).map(e=>uV(iV(e.value),t)),l=rV(iV(e)),u=c.filter(e=>e.value===l),d=c.filter(e=>e.value!==l);return o===`navbar`?[...u,...s(`finder`,n),...s(`terminal`,r),...d]:[...u,...d,...s(`preview`,i&&t),...s(`finder`,n),...s(`terminal`,r),...s(`default`,a)]}function fV(e){e.target.kind===`editor`?e.onOpenExternal(`open_editor`,sV(e.target.preset,e.editorCommandTemplate)):e.onOpenExternal(tV[e.target.kind])}function pV({editorPreset:e,onOpenExternal:t,pending:n=!1,ports:r}){let i=r?.storage??qr,a=br(dr),o=Yr(e=>e.keybindings),s=(Yr(e=>e.localProjects?.machine.platform)??`darwin`)===`darwin`,{openInFinder:c,openInEditor:l}=(0,G.useMemo)(()=>hi(o).bindings,[o]),u=RB.useScopedStore(e=>e.lastTarget),d=RB.useScopedStore(e=>e.setLastTarget);(0,G.useEffect)(()=>{d(nV(i.getItem(XB))??iV(e))},[e,d,i]);let f=(0,G.useMemo)(()=>dV({editorPreset:e,isMac:s,includeFinder:!0,includeTerminal:!0,menuKind:`navbar`}),[e,s]);function p(e){d(e),i.setItem(XB,rV(e)),fV({target:e,editorCommandTemplate:a,onOpenExternal:t})}let m;return m=u.kind===`finder`?c:aV(u,iV(e))?l:void 0,(0,K.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto]`,children:[(0,K.jsxs)(Un,{children:[(0,K.jsx)(Vn,{asChild:!0,children:(0,K.jsx)(U,{variant:`ghost`,size:`none`,onClick:()=>p(u),disabled:n,"aria-busy":n||void 0,title:`Open in ${cV(u,s)}`,className:`border-0 !pl-2.5 !pr-1 hover:!border-border/0 hover:!bg-transparent`,children:n?(0,K.jsx)(hn,{className:`size-6 p-1`}):(0,K.jsx)(lV,{target:u,isMac:s,className:`size-6`})})}),(0,K.jsx)(Gn,{side:`bottom`,shortcut:m})]}),(0,K.jsxs)(Ft,{disabled:n,value:void 0,onValueChange:e=>p(nV(e)??u),children:[(0,K.jsx)(Dt,{"aria-label":`Choose open destination`,className:`!pl-1 !pr-2.5 border-0 bg-transparent hover:bg-transparent focus:ring-0 focus:ring-offset-0 [&>svg]:hidden`,children:(0,K.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,K.jsx)(Pi,{className:`h-4 w-4 opacity-60`})})}),(0,K.jsx)(jt,{align:`end`,children:(0,K.jsx)(Nt,{children:f.map(e=>(0,K.jsx)(kt,{value:e.value,className:ZB,children:(0,K.jsx)(oV,{target:e.target,label:e.label,isMac:s})},e.value))})})]})]})}var mV=Zn(RB,pV,({editorPreset:e})=>({initialTarget:iV(e)}));function hV({onOpenExternal:e,pending:t,ports:n}){let r=br(hr);return(0,K.jsx)(mV,{editorPreset:r,onOpenExternal:e,pending:t,ports:n})}function gV({isMac:e,editorPreset:t,editorCommandTemplate:n,includeFinder:r=!0,includeTerminal:i=!1,includePreview:a=!1,includeDefault:o=!1,onOpenExternal:s}){let c=dV({editorPreset:t,isMac:e,includeFinder:r,includeTerminal:i,includePreview:a,includeDefault:o}),l=(0,G.useCallback)((e,t)=>{e.preventDefault(),fV({target:t,editorCommandTemplate:n,onOpenExternal:s})},[n,s]);return(0,K.jsx)(eo,{className:`rounded-lg p-1`,children:c.map(t=>(0,K.jsx)(Zi,{className:`${ZB} ${QB}`,onSelect:e=>l(e,t.target),children:(0,K.jsx)(oV,{target:t.target,label:t.label,isMac:e})},t.value))})}var _V=[];function vV({pending:e,silent:t}){return e?(0,K.jsx)(hn,{className:`size-4.5`}):t?(0,K.jsx)(Da,{strokeWidth:2,className:`size-4.5`}):(0,K.jsx)(ho,{strokeWidth:2,className:`size-4.5`})}function yV({pending:e,visible:t}){return e?(0,K.jsx)(hn,{className:`size-4`}):t?(0,K.jsx)(ts,{strokeWidth:2.25,className:`h-4`}):(0,K.jsx)(be,{strokeWidth:2.25,className:`h-4`})}function bV({durationsMs:e,status:t}){let n=e??_V,r=t===`running`;if(n.length===0&&!r)return null;let i=n.length+ +!!r;return(0,K.jsx)(FB,{durationsMs:n,live:r,label:`Session shape: ${String(i)} ${i===1?`turn`:`turns`}${r?`, running`:``}`})}function xV({showOnDesktop:e,onToggleEmbeddedTerminal:t,dom:n}){return t?(0,K.jsxs)(ua,{children:[(0,K.jsx)(Qa,{asChild:!0,children:(0,K.jsx)(U,{variant:`ghost`,size:`none`,onClick:e=>fa(e,n),title:`More actions`,className:B(`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,e?`flex`:`flex md:hidden`),children:(0,K.jsx)(ji,{strokeWidth:2,className:`h-4.5`})})}),(0,K.jsx)(eo,{children:t?(0,K.jsxs)(Zi,{onSelect:e=>{e.preventDefault(),t()},children:[(0,K.jsx)(En,{strokeWidth:2,className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:`Toggle Terminal`})]}):null})]}):null}function SV({chatId:e}){return re(I(e))?(0,K.jsxs)(zn,{children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-xs font-mono tracking-wide flex-shrink-0`,style:{background:`color-mix(in oklch, var(--muted) 60%, transparent)`},children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`inline-block w-[6px] h-[6px] rounded-full`,style:{backgroundColor:`var(--warning)`}}),(0,K.jsx)(`span`,{style:{color:`var(--warning)`},children:`following`})]})}),(0,K.jsx)(Wn,{side:`bottom`,children:`Live view of an external Claude session. Sending a message takes over and stops following.`})]}):null}function CV({turnDurationsMs:e,sidebarCollapsed:t,onOpenSidebar:n,onExpandSidebar:r,onNewChat:i,newChatPending:a=!1,localPath:o,embeddedTerminalVisible:s=!1,onToggleEmbeddedTerminal:c,rightSidebarVisible:l=!1,onToggleRightSidebar:u,rightSidebarPending:d=!1,onOpenExternal:f,openExternalPending:p=!1,terminalShortcut:m,rightSidebarShortcut:h,branchName:g,homeDir:_,hasGitRepo:v=!0,gitStatus:y=`unknown`,timings:b,status:x,resolvedBindings:S,provider:C,onOpenPath:w=()=>void 0,currentChatId:T,shareShares:E,onShareMint:D,onShareRevoke:O,silent:k,silentPending:A=!1,onToggleSilent:j,dom:M}){let N=M??pi,P=LB({hasGitRepo:v,gitStatus:y,localPath:o,branchName:g,homeDir:_}),F=Jk.useScopedStore(e=>e.sharePopoverOpen),I=Jk.useScopedStore(e=>e.setSharePopoverOpen);return(0,K.jsxs)(ga,{className:B(`absolute top-0 left-0 right-0 z-10 pt-2 md:pt-3 px-3 border-border/0 md:pb-0 flex items-center justify-center`,`bg-background`),children:[(0,K.jsxs)(`div`,{className:`relative flex items-center gap-2 w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0 border border-border/0 rounded-2xl ${t?`px-1.5 border-border`:``} p-1`,children:[(0,K.jsx)(U,{variant:`ghost`,size:`icon-mobile`,className:`md:hidden`,onClick:n,"aria-label":`Open sidebar`,children:(0,K.jsx)(ne,{className:`size-4.5`})}),t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center w-[36px] h-[36px]`,children:(0,K.jsx)($a,{className:`h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block`})}),(0,K.jsx)(U,{variant:`ghost`,size:`icon`,className:`hidden md:flex`,onClick:r,title:`Expand sidebar`,"aria-label":`Expand sidebar`,children:(0,K.jsx)(ia,{className:`size-4.5`})})]}),(0,K.jsx)(U,{variant:`ghost`,size:`icon`,className:`hover:!border-border/0 hover:!bg-transparent`,onClick:i,pending:a,title:`Compose`,"aria-label":`New chat`,children:(0,K.jsx)(ja,{className:`size-4.5`})})]}),b&&x?(0,K.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-start md:justify-center overflow-hidden select-none`,children:(0,K.jsxs)(zn,{children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 cursor-default min-w-0`,children:[(0,K.jsxs)(`span`,{className:`flex md:hidden items-center gap-1 min-w-0`,children:[(0,K.jsx)(Hr,{tone:Lr(x),className:Br(Lr(x))}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:Ir(x)}),(0,K.jsx)(`span`,{className:`hidden min-[430px]:inline text-xs font-mono tabular-nums text-foreground/80`,children:Si(b.derivedAtMs-b.stateEnteredAt)})]}),(0,K.jsxs)(`span`,{className:`hidden md:flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Hr,{tone:Lr(x),className:Br(Lr(x))}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:Ir(x)})]}),(0,K.jsx)(`span`,{className:`text-xs font-mono tabular-nums text-foreground/80`,children:Si(b.derivedAtMs-b.stateEnteredAt)}),(0,K.jsx)(bV,{durationsMs:e,status:x}),(0,K.jsx)(`span`,{className:`h-3 w-px bg-border/60`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:Ci(b.derivedAtMs-b.activeSessionStartedAt)}),b.lastTurnDurationMs==null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`h-3 w-px bg-border/60`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:Ci(b.lastTurnDurationMs)})]})]})]})}),(0,K.jsx)(Wn,{side:`bottom`,className:`text-left`,children:(0,K.jsxs)(`div`,{className:`space-y-0.5 text-xs`,children:[(0,K.jsxs)(`div`,{children:[`Chat created `,Ci(b.derivedAtMs-b.chatCreatedAt),` ago`]}),(0,K.jsxs)(`div`,{children:[`Idle `,Ci(b.cumulativeMs.idle)]}),(0,K.jsxs)(`div`,{children:[`Running `,Ci(b.cumulativeMs.running)]}),(0,K.jsxs)(`div`,{children:[`Waiting `,Ci(b.cumulativeMs.waiting_for_user)]})]})})]})}):(0,K.jsx)(`div`,{className:`flex-1 min-w-0`}),(0,K.jsx)(SV,{chatId:T}),(0,K.jsx)(`div`,{className:`flex items-center flex-shrink-0 border border-border rounded-2xl`,children:j==null?null:(0,K.jsxs)(zn,{children:[(0,K.jsx)(Bn,{asChild:!0,children:(0,K.jsx)(U,{variant:`ghost`,size:`none`,onClick:j,disabled:A,"aria-busy":A||void 0,"aria-pressed":k??!1,"aria-label":k?`Unsilence notifications`:`Silence notifications`,className:B(`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,k&&`text-muted-foreground`),children:(0,K.jsx)(vV,{pending:A,silent:k??!1})})}),(0,K.jsx)(Wn,{side:`bottom`,children:k?`Unsilence notifications`:`Silence notifications`})]})}),o&&(f||c||u)?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[f?(0,K.jsx)(`div`,{className:`hidden py-0.5 md:block border border-border rounded-2xl`,children:(0,K.jsx)(hV,{onOpenExternal:f,pending:p})}):null,c||u?(0,K.jsxs)(`div`,{className:`flex items-center border border-border rounded-2xl px-2 py-0.5`,children:[(0,K.jsx)(xV,{showOnDesktop:l,onToggleEmbeddedTerminal:c,dom:N}),c?(0,K.jsxs)(Un,{children:[(0,K.jsx)(Vn,{asChild:!0,children:(0,K.jsx)(U,{variant:`ghost`,size:`none`,onClick:c,"aria-label":`Toggle terminal`,"aria-pressed":s,className:B(l?`hidden`:`hidden md:flex`,`border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent`,s&&`text-foreground`),children:(0,K.jsx)(En,{strokeWidth:2,className:`h-4.5`})})}),(0,K.jsx)(Gn,{side:`bottom`,shortcut:m})]}):null,T&&D&&O?(0,K.jsx)(jB,{chatId:T,shares:E??[],open:F,onOpenChange:I,trigger:(0,K.jsx)(TB,{}),onMint:D,onRevoke:O}):null,u?(0,K.jsxs)(Un,{children:[(0,K.jsx)(Vn,{asChild:!0,children:(0,K.jsxs)(U,{variant:`ghost`,onClick:u,disabled:d,"aria-busy":d||void 0,className:B(`border flex flex-row items-center gap-1.5 h-9 border-border/0 pl-1.5 pr-2 hover:!border-border/0 hover:!bg-transparent`,l&&`text-foreground`),children:[(0,K.jsx)(yV,{pending:d,visible:l}),P&&!l?(0,K.jsx)(`div`,{className:`text-13 font-mono max-w-[280px] truncate hidden md:block`,children:P}):null]})}),(0,K.jsx)(Gn,{side:`bottom`,shortcut:h})]}):null]}):null]}):null]}),S&&S.length>1&&(0,K.jsx)(MB,{bindings:S,provider:C??null,onOpenPath:w})]})}var wV={dom:pi,timer:Ln};function TV({rootRef:e,fallbackRef:t,enabled:n,canCancel:r,ports:i=wV}){let{dom:a,timer:o}=i;(0,G.useEffect)(()=>{if(!n)return;let i=0,s=null,c=n=>{let r=n instanceof Element?n:null,i=e.current,o=t.current;ea({trigger:`pointer`,activeElement:a.getActiveElement(),pointerStartTarget:s,pointerEndTarget:r,root:i,fallback:o,hasActiveOverlay:a.hasFocusOverlay(),hasActiveSelection:Qi(a.getSelection())})===`restore`&&o?.focus({preventScroll:!0}),s=null},l=e=>{o.cancelAnimationFrame(i),s=e.target instanceof Element?e.target:null},u=e=>{o.cancelAnimationFrame(i),i=o.requestAnimationFrame(()=>{c(e.target)})},d=e=>{if(e.key!==`Escape`)return;let n=t.current;ea({trigger:`escape`,activeElement:a.getActiveElement(),fallback:n,hasActiveOverlay:a.hasFocusOverlay(),canCancel:r,defaultPrevented:e.defaultPrevented})===`escape-focus`&&(e.preventDefault(),n?.focus({preventScroll:!0}))},f=a.addWindowCaptureListener(`pointerdown`,l),p=a.addWindowCaptureListener(`pointerup`,u),m=a.addWindowCaptureListener(`keydown`,d);return()=>{o.cancelAnimationFrame(i),f(),p(),m()}},[r,a,n,t,e,o])}function EV(e){return e.visibilityState===`visible`?e.activeChatId:null}function DV(e){e.socket.notify({type:`push.setFocusedChat`,chatId:EV({activeChatId:e.activeChatId,visibilityState:e.visibilityState})})}function OV({socket:e,activeChatId:t,ports:n}){let r=n?.dom??pi;(0,G.useEffect)(()=>{let n=()=>{DV({socket:e,activeChatId:t,visibilityState:r.getVisibilityState()})};n();let i=r.addDocumentListener(`visibilitychange`,n),a=r.addWindowListener(`pagehide`,n),o=r.addWindowListener(`pageshow`,n);return()=>{i(),a(),o(),e.notify({type:`push.setFocusedChat`,chatId:null})}},[e,t,r])}function kV(e){let{chatId:t,isFocused:n,chatInputRef:r,timer:i}=e,a=La(e=>e.request),o=La(e=>e.consumeComposerFocus);(0,G.useEffect)(()=>{if(!a||!n||a.chatId!==t)return;let e=i.requestAnimationFrame(()=>{o(a.nonce),r.current?.focus()});return()=>i.cancelAnimationFrame(e)},[t,r,o,n,a,i])}var AV=[];function jV(e,t){let n=e.findIndex(e=>e.id===t);if(n<0)return null;for(let t=n-1;t>=0;--t){let n=e[t];if(n?.kind!==`user_prompt`)continue;let r=n.attachments??AV;if(n.content.trim().length!==0||r.length!==0)return{content:n.content,attachments:[...r]}}return null}var MV=Object.freeze([]),NV=Jn((e,t)=>({sharesByChat:{},listForChat(e){return t().sharesByChat[e]??MV},setShares(t,n){e(e=>({sharesByChat:{...e.sharesByChat,[t]:n}}))},addShare(t,n){e(e=>({sharesByChat:{...e.sharesByChat,[t]:[...e.sharesByChat[t]??[],n]}}))},removeShare(t,n){e(e=>({sharesByChat:{...e.sharesByChat,[t]:(e.sharesByChat[t]??[]).filter(e=>e.tokenId!==n)}}))}}));function PV({chatId:e,onStop:t}){let n=W(`chat.stopDraining`,e??``),r=bn(n);return(0,K.jsx)(Lt,{className:`ml-[1px]`,children:(0,K.jsx)(It,{children:(0,K.jsxs)(`div`,{className:`group/draining relative flex items-center gap-1.5`,children:[(0,K.jsxs)(`div`,{className:B(`flex items-center gap-1.5 group-hover/draining:opacity-0 transition-opacity`,r&&`opacity-0`),children:[(0,K.jsx)(gn,{className:`size-4.5 animate-spin text-muted-icon`}),(0,K.jsx)(de,{className:`ml-[1px] text-sm`,children:`Running...`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>vn(n,t),disabled:r,"aria-busy":r||void 0,className:B(`absolute inset-0 flex items-center gap-1.5 opacity-0 group-hover/draining:opacity-100 transition-opacity cursor-pointer disabled:cursor-default`,r&&`opacity-100`),children:[r?(0,K.jsx)(hn,{className:`size-4.5 text-muted-foreground`}):(0,K.jsx)(Mn,{className:`size-4.5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:r?`Stopping…`:`Stop`})]})]})})})}function FV({message:e,onRemove:t,onSendNow:n}){let r=W(`message.dequeue`,e.id),i=W(`message.steer`,e.id),a=bn(r),o=bn(i);return(0,K.jsx)(`div`,{className:`flex justify-end py-2`,children:(0,K.jsxs)(`div`,{className:`flex max-w-[85%] sm:max-w-[80%] flex-col items-end gap-1.5`,children:[e.attachments.length>0?(0,K.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:e.attachments.map(e=>(0,K.jsxs)(`div`,{className:`max-w-[220px] rounded-xl border border-dashed border-border bg-transparent px-3 py-2 text-left`,children:[(0,K.jsx)(`div`,{className:`truncate text-13 font-medium text-foreground`,children:e.displayName}),(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.mimeType})]},e.id))}):null,e.content?(0,K.jsxs)(`div`,{className:`relative group min-w-0 max-w-full`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-end gap-2.5 rounded-[20px] border border-dashed border-border bg-transparent pl-3.5 pr-1.5 py-1.5 prose prose-sm prose-invert text-left text-primary [&_p]:whitespace-pre-line`,children:[(0,K.jsx)(`div`,{className:`min-w-0`,children:ot(e.content)}),(0,K.jsx)(U,{type:`button`,variant:`default`,size:`none`,className:`rounded-full size-[24px] bg-muted text-muted-foreground border border-primary/10 group-hover:!text-primary hover:bg-muted/60`,"aria-label":`Send now`,pending:o,onClick:()=>vn(i,n),children:o?null:(0,K.jsx)(oe,{className:`size-3.5`})})]}),(0,K.jsx)(U,{type:`button`,variant:`none`,size:`none`,className:B(`pointer-events-none opacity-0 scale-[0.1] group-hover:pointer-events-auto group-hover:scale-[1.0] group-hover:opacity-100 !p-0.5 border rounded-full text-xs font-medium text-muted-foreground hover:text-foreground gap-0.5 absolute top-0 left-0 bg-background -translate-x-[28%] -translate-y-[28%]`,a&&`scale-[1.0] opacity-100`),"aria-label":`Remove queued message`,pending:a,onClick:()=>vn(r,t),children:a?null:(0,K.jsx)(Mn,{className:`size-3`})})]}):null,e.origin?(0,K.jsx)(ha,{origin:e.origin,linked:!0}):null]})})}var IV=(0,G.createContext)(null);function LV({children:e,value:t}){return(0,K.jsx)(IV.Provider,{value:t,children:e})}function RV(){return(0,G.useContext)(IV)}var zV=`…`,BV=`‍`,VV=/^[\p{L}\p{N}\p{M}]/u,HV=/^[\p{L}\p{N}\p{M}'’]/u,UV=/^\s*(```|~~~)/,WV=/^\s*$/,GV={text:``,graphemes:[],fences:[],total:0,shown:0,carry:0,lastTimestamp:null,frames:0},KV=new Intl.Segmenter(void 0,{granularity:`grapheme`});function qV(e){return Array.from(KV.segment(e),e=>e.segment)}function JV(e){return e>=55296&&e<=56319}function YV(e){return e.endsWith(BV)?!0:JV(e.charCodeAt(e.length-1))}function XV(e){let t=e[e.length-1];return t!==void 0&&YV(t)?e.length-1:e.length}function ZV(e){return e===`
31
+ `||e===`\r
32
+ `}function QV(e){let t=[],n=null,r=0;for(let i=0;i<=e.length;i+=1){let a=i===e.length;(a||ZV(e[i]??``))&&(UV.test(e.slice(r,i).join(``))&&(n===null?n=r:(t.push([n,a?i:i+1]),n=null)),r=i+1)}return n!==null&&t.push([n,e.length]),t}function $V(e,t,n){let r=e.find(([e,n])=>e<t&&t<n);return r===void 0?t:Math.min(n,r[1])}function eH(e,t){if(e.text===t)return e;let n=qV(t),r=XV(n),i=QV(n);if(t.startsWith(e.text)){let a=$V(i,Math.min(e.shown,r),r);return{...e,text:t,graphemes:n,fences:i,total:r,shown:a}}let a=t.startsWith(zV)?r:0;return{...e,text:t,graphemes:n,fences:i,total:r,shown:a,carry:0,lastTimestamp:null}}function tH(e,t){let n=e.total-e.shown;if(n<=0)return e.lastTimestamp===null?e:{...e,carry:0,lastTimestamp:null};let r=e.lastTimestamp===null?16:t-e.lastTimestamp,i=Math.min(50,Math.max(0,r)),a=Math.max(45,n/(220/1e3)),o=e.carry+a*i/1e3,s=Math.floor(o),c=$V(e.fences,Math.min(e.total,e.shown+s),e.total),l=c===e.total;return{...e,shown:c,carry:l?0:o-s,lastTimestamp:l?null:t,frames:e.frames+1}}function nH(e,t){return tH(eH(e,t.text),t.timestamp)}function rH(e,t,n){let r=e[t-1];if(r===void 0||!VV.test(r))return``;let i=t;for(;i<n&&HV.test(e[i]??``);)i+=1;return e.slice(t,i).join(``)}function iH(e,t){let n=t?e.total:e.shown;return{revealed:e.graphemes.slice(0,n).join(``),ghost:rH(e.graphemes,n,e.total),revealing:n<e.total}}function aH(e){let t=e.split(`
33
+ `),n=t.length-1,r=[],i=[],a=!1,o=!1,s=!1;return t.forEach((e,t)=>{UV.test(e)&&(s=!s);let c=!s&&WV.test(e);c&&t<n?(i.push(e),o=!0):(a&&o&&(r.push(i),i=[],a=!1,o=!1),c?(i.length>0&&r.push(i),i=[]):(i.push(e),a=!0))}),[...r,i].map(e=>e.join(`
34
+ `))}function oH(e,t){return e.split(t).length-1}function sH(e){return e.split(`
35
+ `).filter(e=>UV.test(e)).length%2==1}function cH(e){if(sH(e))return e;let t=oH(e,"`")%2==1?`${e}\``:e;return oH(t.replace(/```[\s\S]*?```|`[^`]*`/g,``),`**`)%2==1&&(t=`${t}**`),t}var lH={connecting:`Connecting...`,acquiring_sandbox:`Booting...`,initializing:`Initializing...`,starting:`Starting...`,running:`Running...`,waiting_for_user:`Waiting...`,failed:`Failed`};function uH({status:e}){let t=(e?lH[e]:void 0)||`Processing...`;return(0,K.jsx)(Lt,{className:`ml-[1px]`,children:(0,K.jsxs)(It,{children:[e===`failed`?(0,K.jsx)(Mn,{className:`size-4.5 text-destructive`}):(0,K.jsx)(gn,{className:`size-4.5 animate-spin text-muted-icon`}),(0,K.jsx)(de,{className:`ml-[1px] text-sm`,children:t})]})})}function dH(e,t,n){let r=g(n),[i,a]=(0,G.useReducer)(nH,GV),o=(0,G.useMemo)(()=>eH(i,e),[i,e]),s=(0,G.useMemo)(()=>iH(o,r),[o,r]),c=(0,G.useCallback)(t=>a({type:`frame`,timestamp:t,text:e}),[e]),l=o.frames,u=s.revealing&&!r;return(0,G.useEffect)(()=>{if(!u)return;let e=t.requestAnimationFrame(c);return()=>t.cancelAnimationFrame(e)},[u,t,c,l]),{...s,reducedMotion:r}}function fH(e){return e.reducedMotion?`still`:e.revealing?`revealing`:`idle`}function pH({source:e}){return Xt(e)}var mH=(0,G.memo)(pH);function hH({block:e,ports:t}){let n=dH(e.text,t.timer??Ln,t.dom??pi),r=fH(n),i=aH(n.revealed),a=cH((i[i.length-1]??``)+n.ghost).trimEnd();return(0,K.jsxs)(`div`,{"data-testid":`live-block-text`,className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:[i.slice(0,-1).map((e,t)=>(0,K.jsx)(mH,{source:e},t)),Qt(a,{ghostLength:n.ghost.length,renderTail:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`live-caret`,"data-caret":r,className:`kanna-live-caret`}),e.length>0?(0,K.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`live-ghost`,className:`select-none text-transparent`,children:e}):null]})})]})}function gH({block:e}){let t=e.text.trim(),n=(0,G.useMemo)(()=>ot(t),[t]);return(0,K.jsxs)(`div`,{"data-testid":`live-block-thinking`,className:`px-0.5 w-full max-w-[70ch]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(Ve,{className:`h-3.5 w-3.5`}),(0,K.jsx)(de,{className:`ml-0 font-medium tracking-wider`,children:`Thinking…`})]}),t.length>0?(0,K.jsx)(`div`,{className:`mt-2 flex max-h-56 flex-col justify-end overflow-hidden border-l-2 border-muted-foreground/20 pl-3 text-sm text-muted-foreground italic prose prose-sm dark:prose-invert max-w-[70ch]`,children:(0,K.jsx)(`div`,{children:n})}):null]})}function _H({block:e}){return(0,K.jsx)(Lt,{className:`ml-[1px] w-full`,children:(0,K.jsxs)(It,{className:`min-w-0 flex-1 gap-2 text-sm`,children:[(0,K.jsx)(hn,{className:`size-4.5 text-muted-icon`}),(0,K.jsx)(an,{icon:fe(e.toolName),className:`size-4 shrink-0 text-muted-icon`}),(0,K.jsx)(rn,{className:`shrink-0`,children:(0,K.jsx)(de,{children:e.toolName})}),e.subject?(0,K.jsx)(ei,{tooltip:e.subject,inline:!0,className:`min-w-0 text-muted-foreground`,children:e.subject}):null,e.inputChars>0?(0,K.jsx)(`span`,{"data-testid":`live-block-size`,className:`ml-auto shrink-0 text-xs tabular-nums text-muted-foreground`,children:V(e.inputChars)}):null]})})}function vH({chatId:e,status:t,ports:n={}}){let r=Fa(oa(e));return r===null?(0,K.jsx)(uH,{status:t}):r.kind===`text`?(0,K.jsx)(hH,{block:r,ports:n}):r.kind===`thinking`?(0,K.jsx)(gH,{block:r}):(0,K.jsx)(_H,{block:r})}var yH=Qn(`CronJobEditDialog`,e=>t=>({instruction:e.instruction,scheduleText:e.scheduleText,mode:e.mode,setInstruction:e=>t({instruction:e}),setScheduleText:e=>t({scheduleText:e}),setMode:e=>t({mode:e})})),bH=[{value:`inline`,label:`inline`},{value:`spawn`,label:`spawn`}];function xH({job:e,open:t,onOpenChange:n,onSave:r}){let i=W(`cron.update`,e.jobId),a=bn(i),o=yH.useScopedStore(e=>e.instruction),s=yH.useScopedStore(e=>e.scheduleText),c=yH.useScopedStore(e=>e.mode),l=yH.useScopedStore(e=>e.setInstruction),u=yH.useScopedStore(e=>e.setScheduleText),d=yH.useScopedStore(e=>e.setMode),f=(0,G.useMemo)(()=>Ji(s.trim()),[s]),p=(0,G.useMemo)(()=>{let t={},n=o.trim();n&&n!==e.instruction&&(t.instruction=n),c!==e.mode&&(t.mode=c);let r=s.trim();return f.ok&&r!==e.scheduleText&&(t.schedule=f.schedule,t.scheduleText=r),t},[o,e.instruction,e.mode,e.scheduleText,c,f,s]),m=o.trim().length===0,h=!m&&f.ok&&Object.keys(p).length>0,g=(0,G.useCallback)(()=>{f.ok||f.correctedSchedule===void 0||u(f.correctedSchedule)},[f,u]),_=(0,G.useCallback)(()=>{h&&vn(i,async()=>{await r(p),n(!1)})},[h,n,r,p,i]),v=(0,G.useCallback)(()=>{n(!1)},[n]);return(0,K.jsx)(Pn,{open:t,onOpenChange:n,children:(0,K.jsxs)(Nn,{size:`lg`,children:[(0,K.jsxs)(In,{className:`space-y-4`,children:[(0,K.jsx)(Rn,{children:`Edit cron job`}),(0,K.jsxs)(An,{children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e.jobId}),` — changes apply from the next run; a run already in progress finishes as it started.`]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`cron-edit-instruction`,className:`text-sm font-medium text-foreground`,children:`Instruction`}),(0,K.jsx)(ti,{id:`cron-edit-instruction`,rows:4,value:o,onChange:e=>l(e.target.value)}),m?(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:`An instruction is required.`}):null]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`cron-edit-schedule`,className:`text-sm font-medium text-foreground`,children:`Schedule`}),(0,K.jsx)($n,{id:`cron-edit-schedule`,value:s,onChange:e=>u(e.target.value),placeholder:`0 9 * * 1, @daily, or every 5m`,className:`font-mono`}),f.ok?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ka(f.schedule,s.trim())}):(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:f.message}),!f.ok&&f.correctedSchedule!==void 0?(0,K.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:g,children:[`Use `,(0,K.jsx)(`span`,{className:`ml-1 font-mono`,children:f.correctedSchedule})]}):null]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Mode`}),(0,K.jsx)(Kn,{value:c,onValueChange:d,options:bH,size:`sm`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ra(c)})]})]}),(0,K.jsxs)(Fn,{children:[(0,K.jsx)(U,{variant:`ghost`,size:`sm`,onClick:v,children:`Cancel`}),(0,K.jsx)(U,{size:`sm`,onClick:_,disabled:!h,pending:a,children:`Save`})]})]})})}function SH(e){return(0,K.jsx)(yH.Provider,{init:e.job,children:(0,K.jsx)(xH,{...e})})}var CH=Qn(`CronJobRow`,()=>e=>({editing:!1,openEditor:()=>e({editing:!0}),setEditing:t=>e({editing:t})})),wH=`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground`,TH=`Edit cron job`,EH=`Edit cron job — changes apply from the next run`;function DH({job:e,chatId:t,trailing:n,divider:r}){let i=wa(1e3),a=Qr(),o=CH.useScopedStore(e=>e.editing),s=CH.useScopedStore(e=>e.openEditor),c=CH.useScopedStore(e=>e.setEditing),l=W(`cron.pause`,t,e.jobId),u=W(`cron.resume`,t,e.jobId),d=W(`cron.remove`,t,e.jobId),f=bn(l),p=bn(u),m=bn(d),h=(0,G.useCallback)(e=>{vn(W(e.type,e.chatId,e.jobId),()=>ni(a,e))},[a]),g=(0,G.useCallback)(()=>{h({type:`cron.pause`,chatId:t,jobId:e.jobId})},[t,e.jobId,h]),_=(0,G.useCallback)(()=>{h({type:`cron.resume`,chatId:t,jobId:e.jobId})},[t,e.jobId,h]),v=(0,G.useCallback)(()=>{h({type:`cron.remove`,chatId:t,jobId:e.jobId})},[t,e.jobId,h]),y=(0,G.useCallback)(()=>{s()},[s]),b=(0,G.useCallback)(async n=>{await ni(a,{type:`cron.update`,chatId:t,jobId:e.jobId,patch:n})},[t,e.jobId,a]),x=i-e.armedAt,S=e.lastRun?.status===`running`?e.lastRun:null,C=Di(e);return(0,K.jsxs)(`div`,{className:B(`flex items-center gap-3 bg-background px-4 py-2.5`,r&&`border-b border-border`),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm text-foreground`,children:e.instruction}),e.paused?(0,K.jsx)(na,{}):null,!e.paused&&e.lastRun?(0,K.jsx)(ta,{status:e.lastRun.status}):null]}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e.jobId}),(0,K.jsx)(`span`,{children:ka(e.schedule,e.scheduleText)}),(0,K.jsxs)(`span`,{children:[`· `,e.mode]}),e.model?(0,K.jsx)(`span`,{className:`font-mono`,children:e.model}):null,(0,K.jsx)(Zr,{label:new Date(e.armedAt).toLocaleString(),side:`top`,children:(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[`created `,Ci(x),` ago`]})}),S?(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[`running for `,Si(i-S.firedAt)]}):null,e.paused&&e.lastRun?(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[`Last run: `,(0,K.jsx)(ta,{status:e.lastRun.status})]}):null,!e.paused&&e.nextFireAt!==null?(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[`next in `,Si(Math.max(0,e.nextFireAt-i))]}):null,n]})]}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(Zr,{label:C?EH:TH,side:`top`,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":`Edit cron job ${e.jobId}`,className:wH,onClick:y,children:(0,K.jsx)(Sn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),e.paused?(0,K.jsx)(`button`,{type:`button`,"aria-label":`Resume cron job ${e.jobId}`,className:wH,disabled:p,"aria-busy":p||void 0,onClick:_,children:p?(0,K.jsx)(hn,{}):(0,K.jsx)(Pt,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}):(0,K.jsx)(`button`,{type:`button`,"aria-label":`Pause cron job ${e.jobId}`,className:wH,disabled:f,"aria-busy":f||void 0,onClick:g,children:f?(0,K.jsx)(hn,{}):(0,K.jsx)(as,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Remove cron job ${e.jobId}`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive`,disabled:m,"aria-busy":m||void 0,onClick:v,children:m?(0,K.jsx)(hn,{}):(0,K.jsx)(Mn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}),o?(0,K.jsx)(SH,{job:e,open:!0,onOpenChange:c,onSave:b},`${e.jobId} ${String(e.armedAt)}`):null]})}function OH(e){return(0,K.jsx)(CH.Provider,{init:void 0,children:(0,K.jsx)(DH,{...e})})}function kH({jobs:e,chatId:t}){return e.length===0?null:(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,K.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2`,children:[(0,K.jsx)(Ni,{className:`h-4 w-4 text-muted-foreground`}),`Cron jobs`,(0,K.jsxs)(`span`,{className:`ml-auto text-xs font-normal text-muted-foreground tabular-nums`,children:[e.length,` armed`]})]}),(0,K.jsx)(`div`,{children:e.map((n,r)=>(0,K.jsx)(OH,{job:n,chatId:t,divider:r<e.length-1},n.jobId))})]})})}function AH(e){switch(e){case`AUTH_REQUIRED`:return`Auth required`;case`UNKNOWN_SUBAGENT`:return`Unknown subagent`;case`MANUAL_ONLY`:return`Manual only`;case`LOOP_DETECTED`:return`Loop detected`;case`DEPTH_EXCEEDED`:return`Depth exceeded`;case`TIMEOUT`:return`Timeout`;case`PROVIDER_ERROR`:return`Provider error`;case`INTERRUPTED`:return`Interrupted`;case`USER_CANCELLED`:return`Cancelled by you`;default:return`Error`}}function jH({error:e,runId:t,onRetry:n,onOpenSettings:r}){let i=e.code===`TIMEOUT`||e.code===`PROVIDER_ERROR`,a=e.code===`AUTH_REQUIRED`;return(0,K.jsxs)(`div`,{"data-testid":`subagent-error:${t}`,className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-destructive`,children:[(0,K.jsx)(kn,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{children:AH(e.code)})]}),(0,K.jsx)(`p`,{className:`mt-1 text-foreground`,children:e.message}),(0,K.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[a&&r&&(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex items-center gap-1 text-xs underline`,children:[(0,K.jsx)(Go,{className:`h-3 w-3`}),` Open settings`]}),i&&n&&(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 text-xs underline`,children:[(0,K.jsx)(ps,{className:`h-3 w-3`}),` Retry`]})]})]})}function MH({pending:e}){return(0,K.jsxs)(`div`,{className:`text-xs tracking-wide text-muted-foreground mb-1 flex items-center gap-1.5`,children:[e?(0,K.jsx)(hn,{className:`size-3`}):null,e?`sending response…`:`awaiting your response`]})}function NH({pendingTool:e,onAskUserQuestionSubmit:t,onExitPlanModeSubmit:n}){let r=Ba(e.toolUseId),i=(0,G.useCallback)((e,t,r,i)=>n(e,{confirmed:t,clearContext:r,message:i}),[n]),a=Ei({toolName:e.toolKind===`ask_user_question`?wi:Ti,toolId:e.toolUseId,input:e.input}),o=new Date(e.requestedAt).toISOString();if(a.toolKind===`ask_user_question`){let n={id:e.toolUseId,kind:`tool`,toolKind:a.toolKind,toolName:a.toolName,toolId:a.toolId,input:a.input,timestamp:o};return(0,K.jsxs)(`div`,{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[(0,K.jsx)(MH,{pending:!1}),(0,K.jsx)(zi,{message:n,onSubmit:t,isLatest:!0})]})}if(a.toolKind===`exit_plan_mode`){let t={id:e.toolUseId,kind:`tool`,toolKind:a.toolKind,toolName:a.toolName,toolId:a.toolId,input:a.input,timestamp:o};return(0,K.jsxs)(`div`,{"data-testid":`subagent-pending-tool:${e.toolUseId}`,"aria-busy":r||void 0,className:r?`pointer-events-none opacity-60`:void 0,children:[(0,K.jsx)(MH,{pending:r}),(0,K.jsx)(Bi,{message:t,onConfirm:i,isLatest:!0})]})}return null}var PH=Qn(`SubagentMessage`,()=>e=>({expanded:!1,fullEntries:null,olderCursor:null,hasOlder:!1,error:null,openLog:()=>e({expanded:!0,error:null}),closeLog:()=>e({expanded:!1,fullEntries:null,olderCursor:null,hasOlder:!1,error:null}),receiveNewest:t=>e(e=>e.expanded?{fullEntries:t.messages,olderCursor:t.olderCursor,hasOlder:t.hasOlder,error:null}:e),receiveOlder:(t,n)=>e(e=>e.expanded&&e.olderCursor===t?{fullEntries:Ha(n.messages,e.fullEntries??[]),olderCursor:n.olderCursor,hasOlder:n.hasOlder,error:null}:e),failLoad:t=>e(e=>e.expanded?{error:t}:e)}));function FH(e,t){if(e.pendingTool)return`waiting for input...`;let n=e.recentEntries,r=new Set;for(let e=n.length-1;e>=0;e--){let i=n[e];if(i.kind===`tool_result`)r.add(i.toolId);else if(i.kind===`tool_call`&&!r.has(i.tool.toolId))return he(i.tool,t)}return n[n.length-1]?.kind===`assistant_text`?`streaming...`:`running...`}function IH({run:e,onCancel:t}){let n=W(`chat.cancelSubagentRun`,e.runId),r=bn(n);return(0,K.jsx)(`button`,{type:`button`,"data-testid":`subagent-cancel:${e.runId}`,"aria-label":`Cancel subagent`,"aria-busy":r||void 0,disabled:r,onClick:()=>vn(n,()=>t(e.chatId,e.runId)),className:`text-muted-foreground hover:text-foreground disabled:pointer-events-none`,children:r?(0,K.jsx)(hn,{}):(0,K.jsx)(Mn,{className:`h-3.5 w-3.5`})})}function LH({run:e}){let t=RV(),n=PH.useScopedStore(e=>e.expanded),r=PH.useScopedStore(e=>e.error),i=PH.useScopedStore(e=>e.openLog),a=PH.useScopedStore(e=>e.closeLog),o=PH.useScopedStore(e=>e.hasOlder),s=PH.useScopedStore(e=>e.olderCursor),c=PH.useScopedStore(e=>e.receiveNewest),l=PH.useScopedStore(e=>e.receiveOlder),u=PH.useScopedStore(e=>e.failLoad),d=W(`subagentRun.getEntries`,e.runId),f=W(`subagentRun.getEntries`,e.runId,`older`),p=bn(d),m=bn(f),h=(0,G.useCallback)(()=>{t&&(n?a():(i(),vn(d,()=>t(e.chatId,e.runId).then(c,nr(e=>u(e.message))))))},[t,n,a,i,d,e.chatId,e.runId,c,u]),g=(0,G.useCallback)(()=>{t&&s!==null&&vn(f,()=>t(e.chatId,e.runId,s).then(e=>l(s,e),nr(e=>u(e.message))))},[t,s,f,e.chatId,e.runId,l,u]);return!t||!n&&e.entryCount<=e.recentEntries.length?null:(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(U,{variant:`ghost`,size:`none`,className:`px-1.5 py-0.5 text-xs`,"data-testid":`subagent-log-toggle:${e.runId}`,"aria-expanded":n,pending:p,onClick:h,children:n?`Hide full log`:`Show full log (${e.entryCount} entries)`}),n&&o&&(0,K.jsx)(U,{variant:`ghost`,size:`none`,className:`px-1.5 py-0.5 text-xs`,"data-testid":`subagent-log-older:${e.runId}`,pending:m,onClick:g,children:`Load earlier entries`}),r&&(0,K.jsx)(`div`,{"data-testid":`subagent-log-error:${e.runId}`,className:`text-xs text-destructive-text`,children:r})]})}function RH({run:e,indentDepth:t,localPath:n,onOpenSettings:r,onRetry:i,onSubagentAskUserQuestionSubmit:a,onSubagentExitPlanModeSubmit:o,onCancelSubagentRun:s,suppressPendingTool:c=!1}){let l=PH.useScopedStore(e=>e.fullEntries),u=l?Ha(l,e.recentEntries):e.recentEntries,d=se(u),f=d.some(e=>e.kind===`assistant_text`),p=e.status===`running`&&f,m=e.status===`running`?FH(e,n):``;return(0,K.jsxs)(`div`,{"data-testid":`subagent-message:${e.runId}`,className:B(`border-l-2 border-accent pl-3 py-2 space-y-2`),style:{marginLeft:`${t*24}px`},[Li]:``,children:[(0,K.jsxs)(`header`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(_o,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:e.subagentName}),(0,K.jsxs)(`span`,{className:`opacity-60`,children:[e.provider,e.model?`/${e.model}`:``]}),e.usage?.outputTokens!=null&&(0,K.jsxs)(`span`,{className:`opacity-60`,children:[`· `,e.usage.inputTokens??0,`↑ `,e.usage.outputTokens,`↓`]}),e.status===`running`&&(0,K.jsx)(`span`,{"data-testid":`subagent-activity:${e.runId}`,className:`ml-auto inline-block animate-pulse`,children:m}),s&&e.status===`running`&&(0,K.jsx)(IH,{run:e,onCancel:s})]}),(0,K.jsx)(LH,{run:e}),d.map(t=>(0,K.jsx)(ce,{message:t,localPath:n,isRunning:e.status===`running`},t.id)),!c&&e.pendingTool&&(0,K.jsx)(NH,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:async(t,n,r)=>{await a?.(e.runId,t,n,r)},onExitPlanModeSubmit:async(t,n)=>{await o?.(e.runId,t,n)}}),d.length===0&&e.finalText&&(0,K.jsxs)(`div`,{className:B(`whitespace-pre-wrap text-sm`,p&&`text-foreground/80`),children:[e.finalText,p&&(0,K.jsx)(`span`,{className:`ml-0.5 inline-block w-2 animate-pulse`,children:`▍`})]}),e.status===`failed`&&e.error&&(0,K.jsx)(`div`,{children:(0,K.jsx)(jH,{error:e.error,runId:e.runId,subagentId:e.subagentId,onOpenSettings:r,onRetry:i})})]})}var zH=Xn(PH,RH);function BH(e){let t=Sr.safeParse(e);if(!t.success)throw Error(`The view's data description is not plain JSON`);return t.data}function VH(e,t){let n=Qr();return(0,G.useMemo)(()=>{let r=n!==null&&e!==null;return{chatId:e,readonly:!r,workspaceRoot:t,queryDataset:r?async(t,r,i)=>await n.command({type:`genui.dataset.query`,chatId:e,dataset:BH(t),query:BH(r),refresh:i}):null,approveTool:r?async(t,r)=>{await n.command({type:`genui.dataset.approve`,chatId:e,server:t,tool:r})}:null,sendToAgent:r?async t=>{await n.command({type:`chat.send`,chatId:e,content:t})}:null,openLink:e=>pi.openWindow(e,`_blank`,`noopener,noreferrer`),ChartRenderer:null,FlowRenderer:null}},[e,n,t])}var HH=3e4;function UH({record:e,onAccept:t,onStop:n,onRetry:r,onDismiss:i,ports:a={}}){let o=a.timer??Ln,s=a.clipboard??wt,c=(0,G.useRef)(null),l=(0,G.useRef)(e.state),u=W(`tunnel.copyUrl`,e.tunnelId),d=H(u);(0,G.useEffect)(()=>{e.state!==l.current&&c.current&&(c.current(),c.current=null),l.current=e.state},[e.state]);let f=()=>new Promise(e=>{c.current=e,o.setTimeout(()=>{c.current===e&&(c.current=null,e())},HH)});if(e.state===`proposed`)return(0,K.jsx)(ue,{title:`Port ${e.port} detected`,description:`Expose via Cloudflare quick tunnel?`,actions:[{id:`expose`,label:`Expose`,variant:`primary`,onClick:async()=>{await t(e.tunnelId),await f()}},{id:`dismiss`,label:`Dismiss`,variant:`ghost`,onClick:()=>i(e.tunnelId)}]});if(e.state===`starting`)return(0,K.jsx)(ue,{title:`Exposing port ${e.port}`,description:`Waiting for the Cloudflare tunnel to become reachable…`,actions:[{id:`exposing`,label:`Exposing`,variant:`primary`,pending:!0,onClick:()=>{}},{id:`cancel`,label:`Cancel`,variant:`ghost`,onClick:async()=>{await n(e.tunnelId),await f()}}]});if(e.state===`active`){let t=e.url??``,r=[{id:`copy`,label:d?`Copied`:`Copy URL`,icon:d?(0,K.jsx)(Tt,{className:`h-4 w-4 text-success-text`}):(0,K.jsx)(Ct,{className:`h-4 w-4`}),variant:`secondary`,onClick:async()=>{t&&await Et(u,()=>s.writeText(t),o)}},{id:`stop`,label:`Stop tunnel`,variant:`ghost`,onClick:async()=>{await n(e.tunnelId),await f()}}];return(0,K.jsx)(ue,{title:`Tunnel live on port ${e.port}`,tone:`success`,body:(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`font-mono break-all underline-offset-4 hover:underline`,children:t}),actions:r})}return e.state===`stopped`?(0,K.jsx)(ue,{title:`Tunnel stopped (port ${e.port})`,tone:`muted`}):(0,K.jsx)(ue,{title:`Tunnel failed on port ${e.port}`,tone:`error`,errorMessage:e.error??void 0,actions:[{id:`retry`,label:`Retry`,variant:`primary`,onClick:async()=>{await r(e.tunnelId),await f()}},{id:`dismiss`,label:`Dismiss`,variant:`ghost`,onClick:()=>i(e.tunnelId)}]})}var WH=`What are we building?`,GH=2e3,KH=4;function qH(e,t){let n=e?.getState?.();return n?.isFollowingEnd?!0:t?t.scrollHeight-t.clientHeight-t.scrollTop<=KH:n?n.isAtEnd:null}function JH(e){return Array.from(e).includes(`Files`)}function YH(e,t){let n=e?.scrollToEnd?.({animated:t});n&&ri(`transcript.scrollToEnd`,n)}var XH={kind:`none`};function ZH(e){return e.kind===`none`?null:e.kind===`loaded`?e.run.runId:e.runId}var QH=Qn(`WorkflowRunSelection`,()=>e=>({selection:XH,loadStarted:t=>e({selection:{kind:`loading`,runId:t}}),loaded:(t,n)=>e({selection:n?{kind:`loaded`,run:n}:{kind:`not-found`,runId:t}}),loadFailed:t=>e({selection:{kind:`failed`,runId:t}}),refreshed:t=>e({selection:{kind:`loaded`,run:t}}),cleared:()=>e({selection:XH})}));function $H(e,t,n){let r=QH.useScopedStore(e=>e.selection),i=QH.useScopedStore(e=>e.loadStarted),a=QH.useScopedStore(e=>e.loaded),o=QH.useScopedStore(e=>e.loadFailed),s=QH.useScopedStore(e=>e.refreshed),c=QH.useScopedStore(e=>e.cleared),l=(0,G.useRef)(null),u=(0,G.useRef)(0),d=ZH(r),f=(0,G.useCallback)(n=>{l.current=e,i(n);let r=++u.current,s=()=>u.current===r;t(n).then(e=>{s()&&a(n,e)},nr(e=>{Yn.error(tr,`workflows.getRun failed`,e),s()&&o(n)}))},[t,e,i,a,o]),p=(0,G.useCallback)(()=>{c(),l.current=null},[c]);return(0,G.useEffect)(()=>{if(d===null||e===l.current)return;let r=e.find(e=>e.runId===d);if(!r||r.status!==`running`)return;let i=!1,a=++u.current;return ri(`workflows.getRun refresh`,t(d).then(e=>{i||u.current!==a||e===null||(n===null||e.agents.some(e=>e.agentId===n))&&s(e)})),()=>{i=!0}},[e,d,n,t,s]),{selection:r,selectedRunId:d,selectRun:f,clearSelection:p}}var eU=`Agents`;function tU(e){return typeof e.phaseIndex==`number`&&e.phaseIndex>=1}function nU(e,t){if(!t.some(tU))return t.length===0?[]:[{key:`ungrouped`,phaseIndex:null,title:eU,agents:t}];let n=new Map,r=[];for(let e of t)if(tU(e)){let t=n.get(e.phaseIndex)??[];t.push(e),n.set(e.phaseIndex,t)}else r.push(e);let i=[];e.forEach((e,t)=>{let r=t+1;i.push({key:`phase-${r}`,phaseIndex:r,title:e.title,detail:e.detail,agents:n.get(r)??[]}),n.delete(r)});for(let e of[...n.keys()].sort((e,t)=>e-t)){let t=n.get(e);i.push({key:`phase-${e}`,phaseIndex:e,title:t[0]?.phaseTitle??`Phase ${e}`,agents:t})}return r.length>0&&i.push({key:`ungrouped`,phaseIndex:null,title:eU,agents:r}),i}function rU({runs:e,onSelectRun:t,selectedRunId:n}){return e.length===0?(0,K.jsx)(iU,{}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,K.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.length,` `,e.length===1?`run`:`runs`]})}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,K.jsx)(aU,{run:e,selected:e.runId===n,onSelect:t},e.runId))})]})}function iU(){return(0,K.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`workflow-empty`,children:[(0,K.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,K.jsx)(oo,{className:`size-5`,"aria-hidden":!0})}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No workflow runs`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Workflow runs will appear here when triggered.`})]})}function aU(e){let{run:t,selected:n}=e,r=t.workflowName??t.runId,i=t.status===`running`,a=(0,G.useCallback)(()=>{e.onSelect(t.runId)},[e,t.runId]);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"data-testid":`workflow-row:${t.runId}`,onClick:a,className:B(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,n&&`bg-muted`),children:[(0,K.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:B(`truncate text-sm text-foreground`,(i||n)&&`font-medium`),children:r}),(0,K.jsx)(me,{status:t.status})]}),(0,K.jsxs)(`span`,{className:`flex w-full items-center gap-3 text-xs text-muted-foreground`,children:[t.agentCount==null?null:(0,K.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.agentCount,` `,t.agentCount===1?`agent`:`agents`]}),t.totalTokens==null?null:(0,K.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.totalTokens.toLocaleString(),` tokens`]}),t.durationMs==null?null:(0,K.jsx)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:Ci(t.durationMs)})]})]})})}function oU(e){return e===`running`||e===`progress`}function sU(e){return oU(e)?`active`:e===`failed`||e===`error`?`destructive`:e===`killed`?`attention`:`muted`}function cU(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function lU({selection:e}){return e.kind===`loaded`?(0,K.jsx)(pU,{run:e.run}):e.kind===`failed`?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Couldn't load this run. Close and select it again to retry.`}):e.kind===`not-found`?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Run not found or no longer available.`}):(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(hn,{}),`Loading…`]})}function uU({selection:e,onClose:t}){let n=e.kind===`loaded`?e.run.workflowName??e.run.runId:`Workflow run`;return(0,K.jsx)(Pn,{open:e.kind!==`none`,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(Nn,{size:`lg`,"aria-describedby":void 0,children:[(0,K.jsx)(jn,{children:(0,K.jsx)(Rn,{children:n})}),(0,K.jsx)(In,{children:(0,K.jsx)(lU,{selection:e})})]})})}function dU({label:e,text:t}){return(0,K.jsxs)(`div`,{className:`rounded border border-border/50 bg-muted/40 px-2 py-1`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-muted-foreground/90`,children:t})]})}function fU({agent:e,onSelectAgent:t}){let n=sU(e.state),r=n===`active`,i=!!(t&&e.agentId);return(0,K.jsxs)(`li`,{"data-testid":`workflow-agent:${e.agentId??e.index}`,className:`group flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,K.jsx)(Hr,{tone:n,className:B(`mt-0.5`,Br(n))}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:B(`truncate text-sm text-foreground`,r&&`font-medium`),children:e.label}),e.model?(0,K.jsx)(`span`,{className:`shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.model}):null,i?(0,K.jsxs)(`button`,{type:`button`,"data-testid":`workflow-agent-transcript:${e.agentId}`,onClick:()=>t?.(e.agentId),className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,K.jsx)(Ht,{className:`size-3`,"aria-hidden":!0}),`Transcript`]}):null]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:B(`capitalize`,Br(n)),children:e.state}),e.lastToolName?(0,K.jsxs)(`span`,{className:`truncate`,children:[`last: `,e.lastToolName]}):null,e.durationMs==null?null:(0,K.jsx)(`span`,{className:`tabular-nums`,children:Ci(e.durationMs)}),e.tokens==null?null:(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[e.tokens.toLocaleString(),` tok`]}),e.toolCalls==null?null:(0,K.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` calls`]})]}),e.lastToolSummary?(0,K.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/80`,children:e.lastToolSummary}):null,e.promptPreview?(0,K.jsx)(dU,{label:`Prompt`,text:e.promptPreview}):null,e.resultPreview?(0,K.jsx)(dU,{label:`Result`,text:e.resultPreview}):null]})]})}function pU({run:e,onSelectAgent:t,title:n}){let r=Rr(e.status),i=nU(e.phases,e.agents);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,K.jsx)(`h3`,{className:`truncate text-base font-semibold text-foreground`,children:n}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsx)(me,{status:e.status}),e.durationMs==null?null:(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:Ci(e.durationMs)}),e.agentCount==null?null:(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.agentCount,` `,e.agentCount===1?`agent`:`agents`]}),e.totalTokens==null?null:(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalTokens.toLocaleString(),` tokens`]}),e.totalToolCalls==null?null:(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalToolCalls,` tool calls`]})]})]}),e.summary?(0,K.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Summary`}),(0,K.jsx)(`p`,{className:`text-sm text-foreground whitespace-pre-wrap`,children:e.summary})]}):null,i.length>0?(0,K.jsx)(`section`,{className:`flex flex-col gap-4`,"data-testid":`workflow-progress-tree`,children:i.map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.phaseIndex==null?null:(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center rounded bg-muted text-xs font-medium text-muted-foreground tabular-nums`,children:e.phaseIndex}),(0,K.jsx)(`h4`,{className:`min-w-0 truncate text-xs font-semibold tracking-wide text-foreground`,children:e.title}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.agents.length,` `,e.agents.length===1?`agent`:`agents`]})]}),e.detail?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.detail}):null,e.agents.length>0?(0,K.jsx)(`ul`,{className:`ml-1.5 flex flex-col gap-0.5 border-l border-border pl-2.5`,children:e.agents.map(e=>(0,K.jsx)(fU,{agent:e,onSelectAgent:t},e.agentId??e.index))}):(0,K.jsx)(`p`,{className:`ml-1.5 border-l border-border pl-2.5 text-xs italic text-muted-foreground/70`,children:`No agents yet`})]},e.key))}):null,e.result?(0,K.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Result`}),(0,K.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:cU(e.result)})]}):null,e.script?(0,K.jsxs)(`details`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium tracking-wide text-muted-foreground hover:text-foreground`,children:`Script`}),(0,K.jsx)(`pre`,{className:`mt-1.5 max-h-96 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:e.script})]}):null,e.error&&e.status!==`completed`?(0,K.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:B(`text-xs font-medium tracking-wide`,Br(r)),children:`Error`}),(0,K.jsx)(`p`,{className:`rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-sm text-destructive whitespace-pre-wrap`,children:e.error})]}):null]})}function mU({runs:e,getRunDetail:t}){let{selection:n,selectRun:r,clearSelection:i}=$H(e,t,null);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(rU,{runs:e,onSelectRun:r}),(0,K.jsx)(uU,{selection:n,onClose:i})]})}function hU(e){return(0,K.jsx)(QH.Provider,{init:void 0,children:(0,K.jsx)(mU,{...e})})}var gU={done:{Icon:Tt,iconClass:`text-success-text`,textClass:`text-muted-foreground`},running:{Icon:gn,iconClass:`text-foreground animate-spin`,textClass:`text-foreground font-medium`},pending:{Icon:Co,iconClass:`text-muted-foreground`,textClass:`text-muted-foreground`},blocked:{Icon:$o,iconClass:`text-muted-foreground/60`,textClass:`text-muted-foreground/60`},failed:{Icon:kn,iconClass:`text-destructive`,textClass:`text-muted-foreground line-through decoration-destructive/40`}};function _U(e){let t=e.filter(e=>e.status===`running`).length;return t>1?`${t} workers running`:`Loop running`}function vU({armed:e,rows:t,completed:n,total:r}){return e?(0,K.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground`,children:[(0,K.jsx)(Hr,{tone:`active`,className:`text-foreground`}),_U(t)]}):r===0?null:(0,K.jsxs)(`span`,{className:`ml-auto text-xs font-normal text-muted-foreground tabular-nums`,children:[n,`/`,r,` completed`]})}function yU({scheduleId:e,onResume:t}){let n=W(`autoContinue.accept`,e),r=bn(n);return(0,K.jsx)(U,{variant:`secondary`,size:`sm`,className:`ml-auto`,pending:r,onClick:()=>vn(n,()=>t(e,Date.now())),children:`Resume now`})}function bU({loopProgress:e,onResume:t}){let{armed:n,rows:r,rateLimit:i,completed:a,total:o}=e;return!n&&r.length===0&&!i?null:(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,K.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2`,children:[(0,K.jsx)(to,{className:`h-4 w-4 text-muted-foreground`}),n?`Progress`:`Tasks`,(0,K.jsx)(vU,{armed:n,rows:r,completed:a,total:o})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 bg-amber-500/[0.06] border-b border-border`,children:[(0,K.jsx)(To,{className:`h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400`}),(0,K.jsxs)(`span`,{className:`text-sm text-foreground`,children:[i.scheduled?`Resumes`:`Usage limit — resets`,` `,Ii(i.resetAt,i.tz)]}),!i.scheduled&&t?(0,K.jsx)(yU,{scheduleId:i.scheduleId,onResume:t}):null]}):null,r.length===0?(0,K.jsx)(`div`,{className:`px-4 py-3 text-sm text-muted-foreground bg-background`,children:`Waiting for the first chunk…`}):(0,K.jsx)(`div`,{children:r.map((e,t)=>{let n=t===r.length-1,{Icon:i,iconClass:a,textClass:o}=gU[e.status];return(0,K.jsxs)(`div`,{className:B(`flex items-center gap-3 px-4 py-2.5 bg-background`,!n&&`border-b border-border`),children:[(0,K.jsx)(i,{className:B(`h-4 w-4 flex-shrink-0`,a)}),(0,K.jsx)(`span`,{className:B(`text-sm truncate`,o),children:e.label})]},e.runId)})})]})})}var xU=Qn(`BackgroundTasksSection`,()=>e=>({expandedTaskId:null,output:null,setExpandedTaskId:t=>e({expandedTaskId:t}),setOutput:t=>e({output:t})}));function SU(e){return e?e.includes(`bash`)||e.includes(`shell`)?ks:e.includes(`agent`)||e.includes(`task`)||e.includes(`teammate`)?_o:e.includes(`workflow`)?ye:Co:Co}function CU({chatId:e,tasks:t}){let n=wa(1e3),r=Qr(),i=xU.useScopedStore(e=>e.expandedTaskId),a=xU.useScopedStore(e=>e.output),o=xU.useScopedStore(e=>e.setExpandedTaskId),s=xU.useScopedStore(e=>e.setOutput),c=(0,G.useCallback)(e=>{s({taskId:e.taskId,content:e.content,truncated:e.truncated})},[s]);return(0,G.useEffect)(()=>{if(i&&r)return r.subscribe({type:`background-task-output`,chatId:e,taskId:i},c)},[i,e,r,c]),(0,K.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,K.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2`,children:[(0,K.jsx)(oo,{className:`h-4 w-4 text-warning-text motion-safe:animate-kanna-heartbeat`}),`Background tasks`,(0,K.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1.5 text-xs font-normal text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),t.length,` running`]})]}),(0,K.jsx)(`div`,{children:t.map((e,r)=>{let s=SU(e.taskType),c=r===t.length-1,l=i===e.id,u=a?.taskId===e.id?a:null;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:B(`flex items-center gap-3 px-4 py-2.5 bg-background`,(!c||l)&&`border-b border-border`),children:[(0,K.jsx)(s,{className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`text-sm text-foreground truncate`,children:e.description??`Background task`}),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 flex-shrink-0`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:Si(Math.max(0,n-e.startedAt))}),e.hasOutput&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(l?null:e.id),className:`text-muted-foreground hover:text-foreground transition-colors`,"aria-label":l?`Hide output`:`Show output`,children:l?(0,K.jsx)(At,{className:`h-4 w-4`}):(0,K.jsx)(Pi,{className:`h-4 w-4`})})]})]}),l&&(0,K.jsxs)(`div`,{className:B(`bg-card`,!c&&`border-b border-border`),children:[u?.truncated&&(0,K.jsx)(`p`,{className:`px-4 pt-2 text-xs text-muted-foreground`,children:`Earlier output was truncated.`}),(0,K.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs text-foreground whitespace-pre-wrap break-all max-h-64 overflow-y-auto`,children:u?.content||`Waiting for output…`})]})]},e.id)})})]})}function wU({chatId:e,tasks:t}){return t.length===0?null:(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsx)(xU.Provider,{init:void 0,children:(0,K.jsx)(CU,{chatId:e,tasks:t})})})}function TU(e){return(0,K.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,"data-testid":`plugin-boundary-error:${e}`,children:[`Plugin "`,e,`" failed to render.`]})}var EU=class extends G.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){Yn.warn(`[kanna/plugins] plugin failed to render`,{pluginId:this.props.pluginId,message:e.message})}render(){return this.state.failed?TU(this.props.pluginId):this.props.children}};function DU({panels:e,theme:t}){return e.length===0?null:(0,K.jsx)(`div`,{className:`w-full`,children:(0,K.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,K.jsxs)(`h3`,{className:`font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2`,children:[(0,K.jsx)(Gi,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),`Plugins`]}),(0,K.jsx)(`div`,{children:e.map((n,r)=>{let i=r===e.length-1,{Component:a}=n;return(0,K.jsx)(`div`,{className:B(`px-4 py-3 bg-background`,!i&&`border-b border-border`),children:(0,K.jsx)(EU,{pluginId:n.pluginId,children:(0,K.jsx)(a,{theme:t})})},`${n.pluginId}:${n.surfaceId}`)})})]})})}var OU={colors:{foreground:`var(--foreground)`}};function kU(){let e=Ua(sa);return(0,K.jsx)(DU,{panels:e,theme:OU})}function AU(e,t){let n=(0,G.useRef)(new Map),r=(0,G.useRef)(0),i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(i.current!==t){i.current=t,r.current=e.length,n.current=new Map;return}let a=r.current;if(r.current=e.length,e.length<=a){n.current=new Map;return}let o=new Map;for(let[t,n]of e.slice(a).entries())o.set(n.id,Math.min(t,7));n.current=o},[e,t]),(0,G.useMemo)(()=>({indexOf:e=>n.current.get(e)}),[])}var jU=`:scope > .legend-list-content-container`;function MU(e){let[t,n]=e;return typeof t==`number`?n??0:t?.top??0}function NU(){}function PU(e,t,n){let r=e.scrollBy;if(typeof r!=`function`)return NU;let i=!1,a,o=0,s=null,c=()=>e.querySelector(jU),l=()=>{let e=s??c();return e?(s=o===0?null:e,e.style.transform=o===0?``:`translateY(${-o}px)`,!0):!1},u=()=>{if(o===0)return;let t=o;o=0,l(),Reflect.apply(r,e,[{top:t,behavior:`auto`}])},d=()=>{a=void 0,i=!1,u()},f=()=>{a!==void 0&&t.clearTimeout(a),a=t.setTimeout(d,120)};function p(...t){if(!i){Reflect.apply(r,e,t);return}let a=MU(t);a!==0&&(o+=a,(Math.abs(o)>n||!l())&&u())}e.scrollBy=p;let m=()=>{a!==void 0&&(t.clearTimeout(a),a=void 0),i=!0},h=()=>{f()},g=()=>{i&&f()};return e.addEventListener(`touchstart`,m,{passive:!0}),e.addEventListener(`touchend`,h,{passive:!0}),e.addEventListener(`touchcancel`,h,{passive:!0}),e.addEventListener(`scroll`,g,{passive:!0}),()=>{a!==void 0&&t.clearTimeout(a),e.removeEventListener(`touchstart`,m),e.removeEventListener(`touchend`,h),e.removeEventListener(`touchcancel`,h),e.removeEventListener(`scroll`,g),e.scrollBy===p&&Reflect.deleteProperty(e,`scrollBy`),i=!1,u()}}var FU={askUserQuestionSurface:`footer`},IU={askUserQuestionSurface:`inline`};function LU(e,t){let n=t.askUserQuestion;if(!n)return null;for(let t=e.length-1;t>=0;--t){let r=e[t];if(r.id===n)return r.kind!==`tool`||r.toolKind!==`ask_user_question`||r.result?null:r}return null}function RU(e){let t=Object.values(e??{}).filter(e=>e.pendingTool!==null);return t.sort((e,t)=>e.pendingTool.requestedAt-t.pendingTool.requestedAt||e.runId.localeCompare(t.runId)),t}var zU=(0,G.memo)(({activeChatId:e,listRef:t,messages:n,transcriptPaddingBottom:r,isHistoryLoading:i,hasOlderHistory:a,loadOlderHistory:o,showScrollButton:s,onIsAtEndChange:c,scrollToBottom:l,typedEmptyStateText:u,isEmptyStateTypingComplete:d,isPageFileDragActive:f,showEmptyState:p,onOpenLocalLink:m,headerOffsetPx:h=72,ports:g})=>{let{localPath:_,latestToolIds:v,isProcessing:y,queuedMessages:b,runtimeStatus:x,isDraining:S,commandError:C,onStopDraining:w,onSteerQueuedMessage:T,onRemoveQueuedMessage:E,onAskUserQuestionSubmit:D,onSubagentAskUserQuestionSubmit:O,onSubagentExitPlanModeSubmit:k,schedules:A,cronJobs:j,onAutoContinueAccept:M,tunnels:N,liveTunnelId:P,onTunnelAccept:F,onTunnelStop:I,onTunnelRetry:ee,subagentRuns:L,onCancelSubagentRun:R,loopProgress:te,workflowRuns:ne,backgroundTasks:re,getWorkflowRunDetail:ie,getSubagentTranscript:ae,getSubagentRunEntries:z,editorPreset:oe,editorCommandTemplate:se,platform:ce}=Yi(),ue=g?.dom??pi,fe=g?.timer??Ln,me=VH(e,_??null),he=(0,G.useRef)(0),ge=(0,G.useRef)(null),_e=Jk.useScopedStore(e=>e.toolGroupExpanded),ye=Jk.useScopedStore(e=>e.resetToolGroupExpanded),be=Ig(e=>e.localLinkMenuTarget),xe=Ig(e=>e.setLocalLinkMenuTarget),Se=Ig(e=>e.setLocalLinkMenuOpen),Ce=ce===`darwin`,we=(0,G.useMemo)(()=>Fi(n,{isLoading:y,localPath:_??void 0,latestToolIds:v}),[y,v,_,n]),Te=Ri(we),Ee=(0,G.useMemo)(()=>Oi(Te),[Te]);(0,G.useEffect)(()=>{ye()},[e,ye]),(0,G.useEffect)(()=>{let e=he.current;if(he.current=Te.length,e>0||Te.length===0)return;c(!0);let n=fe.requestAnimationFrame(()=>{YH(t.current,!1)});return()=>fe.cancelAnimationFrame(n)},[t,c,Te.length,fe]);let{runsByDelegateToolId:De,childrenByParentRunId:Oe}=(0,G.useMemo)(()=>{let e=ro(n),t=Object.values(L).filter(e=>e.parentRunId===null),{matched:r}=Ai(e,t),i=new Map;for(let e of Object.values(L)){if(e.parentRunId===null)continue;let t=i.get(e.parentRunId)??[];t.push(e),i.set(e.parentRunId,t)}let a=(e,t)=>e.startedAt-t.startedAt||e.runId.localeCompare(t.runId);for(let e of i.values())e.sort(a);return{runsByDelegateToolId:r,childrenByParentRunId:i}},[n,L]),ke=(0,G.useMemo)(()=>RU(L),[L]),Ae=(0,G.useMemo)(()=>LU(n,v),[n,v]),je=(0,G.useMemo)(()=>function e(t,n){let r=Oe.get(t.runId)??[];return(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(zH,{run:t,indentDepth:n,localPath:_??``,onSubagentAskUserQuestionSubmit:O,onSubagentExitPlanModeSubmit:k,onCancelSubagentRun:R,suppressPendingTool:!0}),r.map(t=>e(t,n+1))]},t.runId)},[Oe,_,O,k,R]),Me=(0,G.useCallback)(e=>{let n=e?.currentTarget instanceof HTMLElement?e.currentTarget:t.current?.getScrollableNode?.(),r=qH(t.current,n instanceof HTMLElement?n:null);r!==null&&c(r)},[t,c]);(0,G.useEffect)(()=>{let e,n=fe.requestAnimationFrame(()=>{let n=t.current?.getScrollableNode?.();if(!(n instanceof HTMLElement))return;let r=()=>{Me({currentTarget:n})};n.addEventListener(`scroll`,r,{passive:!0}),r(),e=()=>{n.removeEventListener(`scroll`,r)}});return()=>{fe.cancelAnimationFrame(n),e?.()}},[e,Me,t,Te.length,fe]),(0,G.useEffect)(()=>{let e,n=fe.requestAnimationFrame(()=>{let n=t.current?.getScrollableNode?.();n instanceof HTMLElement&&(e=PU(n,fe,GH))});return()=>{fe.cancelAnimationFrame(n),e?.()}},[e,t,fe]);let Ne=(0,G.useCallback)(()=>{!i&&a&&ri(`transcript.loadOlderHistory`,o())},[a,i,o]),Pe=(0,G.useCallback)(e=>{if(e.trigger!==`contextmenu`){let t=Ar(e.path)?`open_editor`:`open_default`;vn(W(`system.openExternal`,e.path),()=>m(e,t))}else xe(e),fe.requestAnimationFrame(()=>{let t=ge.current;if(!t)return;let n=e.clientX??ue.getInnerWidth()/2,r=e.clientY??ue.getInnerHeight()/2;ue.dispatchContextMenuEvent(t,n,r)})},[ue,m,xe,fe]),Fe=AU(Te,e),Ie=(0,G.useCallback)(({item:e})=>{let t=Hi(e),n=t==null?null:De.get(t);return(0,K.jsx)(Ta,{row:e,gapClass:Ee.get(e.id)??`pt-4`,arriveIndex:Fe.indexOf(e.id),toolGroupExpanded:e.kind===`tool-group`?_e[e.id]??!1:void 0,runTree:n?je(n,0):null})},[_e,De,je,Ee,Fe]),Le=(0,G.useMemo)(()=>({toolGroupExpanded:_e,schedules:A,tunnels:N,liveTunnelId:P}),[_e,A,N,P]),Re=(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-[800px]`,style:{paddingTop:`${h}px`},children:i?(0,K.jsx)(`div`,{className:`flex justify-center pb-4`,children:(0,K.jsx)(`span`,{className:`text-sm translate-y-[-0.5px]`,children:(0,K.jsx)(de,{animate:!0,children:`Loading more messages...`})})}):null}),ze=P&&N?N[P]:void 0,Be=(0,K.jsxs)(`div`,{className:`mx-auto w-full max-w-[800px] pt-4`,children:[(0,K.jsx)(kU,{}),te&&(te.armed||te.rows.length>0||te.rateLimit)?(0,K.jsx)(`div`,{className:`pb-4`,children:(0,K.jsx)(bU,{loopProgress:te,onResume:M})}):null,e&&j.length>0?(0,K.jsx)(`div`,{className:`pb-4`,children:(0,K.jsx)(kH,{jobs:j,chatId:e})}):null,ne&&ne.length>0&&ie?(0,K.jsx)(`div`,{className:`pb-4`,children:(0,K.jsx)(hU,{runs:ne,getRunDetail:ie})}):null,ze&&F&&I&&ee&&(0,K.jsx)(`div`,{className:`pb-4`,children:(0,K.jsx)(UH,{record:ze,onAccept:F,onStop:I,onRetry:ee,onDismiss:I})}),e&&re&&re.length>0?(0,K.jsx)(`div`,{className:`pb-4`,children:(0,K.jsx)(wU,{chatId:e,tasks:re})}):null,y?(0,K.jsx)(vH,{chatId:e,status:x??void 0}):null,b.map(e=>(0,K.jsx)(FV,{message:e,onRemove:()=>E(e.id),onSendNow:()=>T(e.id)},e.id)),!y&&S?(0,K.jsx)(PV,{chatId:e,onStop:w}):null,C?(0,K.jsx)(`div`,{className:`rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap`,children:ve(C)}):null,Ae?(0,K.jsxs)(`div`,{className:`mb-3`,"data-testid":`main-pending-footer:${Ae.toolId}`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(le,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:`Claude`}),` needs your input`]})]}),(0,K.jsx)(qa,{value:IU,children:(0,K.jsx)(zi,{message:Ae,onSubmit:D,isLatest:!0})})]}):null,ke.length>0&&O&&k?ke.map(e=>(0,K.jsxs)(`div`,{"data-testid":`subagent-pending-footer:${e.runId}`,className:`mb-3`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(_o,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e.subagentName}),` needs your input`]})]}),(0,K.jsx)(NH,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:(t,n,r)=>O(e.runId,t,n,r),onExitPlanModeSubmit:(t,n)=>k(e.runId,t,n)})]},e.runId)):null]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pe,{value:ae??null,children:(0,K.jsx)(LV,{value:z??null,children:(0,K.jsx)(Bt,{onOpenLocalLink:Pe,children:(0,K.jsx)(qa,{value:Ae?FU:IU,children:(0,K.jsx)(Pa,{value:me,children:(0,K.jsx)(Yh,{ref:t,data:Te,extraData:Le,keyExtractor:BU,getItemType:VU,renderItem:Ie,estimatedItemSize:48,initialScrollAtEnd:!0,maintainScrollAtEnd:!0,maintainScrollAtEndThreshold:.1,maintainVisibleContentPosition:!0,onScroll:Me,onStartReached:Ne,onStartReachedThreshold:.1,className:`h-full flex-1 overflow-x-hidden overscroll-y-contain touch-pan-y px-3 scroll-pt-[72px] [scrollbar-gutter:auto]`,contentContainerStyle:{paddingBottom:r+30},ListHeaderComponent:Re,ListFooterComponent:Be})})})})})}),(0,K.jsxs)(ua,{onOpenChange:Se,children:[(0,K.jsx)(Qa,{asChild:!0,children:(0,K.jsx)(`span`,{ref:ge,"aria-hidden":`true`,className:`pointer-events-none fixed size-px opacity-0`,style:{left:be?.clientX??0,top:be?.clientY??0}})}),be?(0,K.jsx)(gV,{isMac:Ce,editorPreset:oe,editorCommandTemplate:se,includeFinder:!0,includePreview:!0,includeDefault:!0,onOpenExternal:(e,t)=>{vn(W(`system.openExternal`,be.path),()=>m(be,e,t))}}):null]}),p?(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-x-4 animate-fade-in`,style:{top:h,bottom:r},children:(0,K.jsx)(`div`,{className:`mx-auto flex h-full max-w-[800px] items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground opacity-70`,children:[(0,K.jsx)($a,{strokeWidth:1.5,className:`kanna-empty-state-flower size-8 text-muted-foreground`}),(0,K.jsx)(`div`,{className:`kanna-empty-state-text flex max-w-xs items-center text-center text-base font-normal text-muted-foreground`,"aria-label":WH,children:(0,K.jsxs)(`span`,{className:`relative inline-grid place-items-start`,children:[(0,K.jsxs)(`span`,{className:`invisible col-start-1 row-start-1 flex items-center whitespace-pre`,children:[(0,K.jsx)(`span`,{children:WH}),(0,K.jsx)(`span`,{className:`kanna-typewriter-cursor-slot`,"aria-hidden":`true`})]}),(0,K.jsxs)(`span`,{className:`col-start-1 row-start-1 flex items-center whitespace-pre`,children:[(0,K.jsx)(`span`,{children:u}),(0,K.jsx)(`span`,{className:`kanna-typewriter-cursor-slot`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`kanna-typewriter-cursor`,"data-typing-complete":d?`true`:`false`})})]})]})})]})})}):null,f?(0,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-background/70`}),(0,K.jsx)(`div`,{className:`absolute inset-6 `,children:(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 text-center`,children:[(0,K.jsx)(Ns,{className:`mx-auto size-14 text-foreground`,strokeWidth:1.75}),(0,K.jsxs)(`div`,{className:`text-xl font-medium text-foreground`,children:[`Drop up to `,50,` files`]})]})})})]}):null,(0,K.jsx)(`div`,{style:{bottom:r-20},className:B(`absolute left-1/2 z-10 -translate-x-1/2 transition-[transform,opacity] motion-reduce:transition-none`,s?`scale-100 opacity-100 duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]`:`pointer-events-none scale-75 opacity-0 duration-200 ease-out`),children:(0,K.jsx)(`button`,{onClick:l,"aria-label":`Scroll to latest message`,className:`flex size-11 cursor-pointer items-center justify-center rounded-md border border-border bg-card text-sm text-foreground transition-colors hover:bg-muted md:size-9`,children:(0,K.jsx)(co,{"aria-hidden":`true`,className:`h-5 w-5`})})})]})});function BU(e){return e.id}function VU(e){return e.kind===`tool-group`?e.kind:e.message.kind}function HU(e){return W(`system.openExternal`,`project`,e??``)}function UU(e){return W(`git.initialize`,e??``)}function WU(e){switch(e.kind){case`chat_not_found`:return`This chat no longer exists.`;case`snapshot_too_large`:return`This chat is too large to share (${String(e.sizeBytes)} bytes).`;case`snapshot_write_failed`:case`snapshot_read_failed`:return e.message;case`not_found`:return`That share link no longer exists.`;case`revoked`:return`That share link was already revoked.`;case`expired`:return`That share link has expired.`}}var GU=[],KU={};function qU(){let e=(0,G.useRef)(null),t=Jk.useScopedStore(e=>e.inputHeight),n=Jk.useScopedStore(e=>e.setInputHeight),r=Jk.useScopedStoreApi(),i=(0,G.useCallback)(()=>{let t=e.current;if(!t)return;let i=t.getBoundingClientRect().height,a=r.getState().inputHeight,o=Ga(a,i);o!==a&&n(o)},[n,r]);return(0,G.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=new ResizeObserver(()=>{i()});return n.observe(t),i(),()=>n.disconnect()},[i]),{inputRef:e,syncInputHeight:i,transcriptPaddingBottom:Na(t)}}function JU(e,t,n){let r=Ig(e=>e.typedEmptyStateText),i=Ig(e=>e.isEmptyStateTypingComplete),a=Ig(e=>e.setTypedEmptyStateText),o=Ig(e=>e.setIsEmptyStateTypingComplete),s=Ig(e=>e.resetEmptyStateTyping);return(0,G.useEffect)(()=>{if(!e)return;s();let t=0,r=n.setInterval(()=>{t+=1,a(WH.slice(0,t)),t>=21&&(n.clearInterval(r),o(!0))},19);return()=>n.clearInterval(r)},[e,t,s,a,o,n]),{typedEmptyStateText:r,isEmptyStateTypingComplete:i}}function YU(e){let t=Ig(e=>e.isPageFileDragActive),n=Ig(e=>e.setIsPageFileDragActive),r=(0,G.useRef)(0),i=(0,G.useCallback)(e=>JH(e.dataTransfer?.types??[]),[]);return{isPageFileDragActive:t,handleTranscriptDragEnter:(0,G.useCallback)(t=>{i(t)&&e.hasSelectedProject&&(t.preventDefault(),r.current+=1,n(!0))},[e.hasSelectedProject,i,n]),handleTranscriptDragOver:(0,G.useCallback)(r=>{i(r)&&e.hasSelectedProject&&(r.preventDefault(),r.dataTransfer.dropEffect=`copy`,t||n(!0))},[e.hasSelectedProject,i,t,n]),handleTranscriptDragLeave:(0,G.useCallback)(t=>{i(t)&&e.hasSelectedProject&&(t.preventDefault(),r.current=Math.max(0,r.current-1),r.current===0&&n(!1))},[e.hasSelectedProject,i,n]),handleTranscriptDrop:(0,G.useCallback)(t=>{i(t)&&e.hasSelectedProject&&(t.preventDefault(),r.current=0,n(!1),e.onFilesDropped([...t.dataTransfer.files]))},[e,i,n])}}function XU({timer:e,dom:t,onToggleEmbeddedTerminal:n,onToggleRightSidebar:r,isFocused:i}){let a=Xk(),o=(0,G.useRef)(null),s=(0,G.useRef)(!0),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),{inputRef:f,syncInputHeight:p,transcriptPaddingBottom:m}=qU(),h=Jk.useScopedStore(e=>e.showScrollToBottom),g=Jk.useScopedStore(e=>e.setShowScrollToBottom),_=Jk.useScopedStore(e=>e.setToolGroupExpanded),v=(0,G.useCallback)((e,t)=>{_(n=>n[e]===t?n:{...n,[e]:t})},[_]),y=a.activeProjectId,{showTerminalPane:b,showRightSidebar:x}=Pg(y),S=br(hr),C=br(dr),w=(0,G.useMemo)(()=>hi(a.keybindings),[a.keybindings]),T=(0,G.useMemo)(()=>ln(a.chatSnapshot?.messages??[]),[a.chatSnapshot?.messages]),E=(0,G.useMemo)(()=>pn(a.chatSnapshot?.messages??[],Object.values(a.chatSnapshot?.subagentRuns??{})),[a.chatSnapshot?.messages,a.chatSnapshot?.subagentRuns]),D=(0,G.useMemo)(()=>dL(a.messages),[a.messages]),O=a.runtime?.title,k=a.messages.length===0&&O!==void 0&&ir(O),A=(0,G.useCallback)(()=>{c.current!==null&&(e.clearTimeout(c.current),c.current=null)},[e]),j=(0,G.useCallback)(t=>{s.current!==t&&(s.current=t,t?(A(),g(!1)):(A(),c.current=e.setTimeout(()=>{g(!0),c.current=null},150)))},[A,g,e]),M=(0,G.useCallback)(()=>{let e=o.current,t=e?.getScrollableNode?.(),n=qH(e,t instanceof HTMLElement?t:null);n!==null&&j(n)},[j]),N=(0,G.useCallback)(async(e=!0)=>{s.current=!0,A(),g(!1),await o.current?.scrollToEnd?.({animated:e})},[A,g]),P=(0,G.useCallback)(async(e,t)=>{await N(!1),await a.handleSend(e,t)},[N,a]),I=(0,G.useRef)({messages:a.messages,submit:P});(0,G.useEffect)(()=>{I.current={messages:a.messages,submit:P}},[a.messages,P]);let ee=(0,G.useCallback)(async e=>{let{messages:t,submit:n}=I.current,r=jV(t,e);r&&await n(r.content,{attachments:r.attachments})},[]),L=a.activeChatId,R=a.socket,te=(0,G.useCallback)(async(e,t)=>{L&&await Jr(()=>R.command({type:`autoContinue.accept`,chatId:L,scheduleId:e,scheduledAt:t}))},[L,R]),ne=(0,G.useCallback)(async(e,t)=>{L&&await Jr(()=>R.command({type:`autoContinue.reschedule`,chatId:L,scheduleId:e,scheduledAt:t}))},[L,R]),re=(0,G.useCallback)(e=>{L&&vn(W(`cron.remove`,L,e),()=>Jr(()=>R.command({type:`cron.remove`,chatId:L,jobId:e})))},[L,R]),ie=(0,G.useCallback)(async e=>{L&&await Jr(()=>R.command({type:`autoContinue.cancel`,chatId:L,scheduleId:e}))},[L,R]),ae=(0,G.useCallback)(async e=>{L&&await $r(()=>R.command({type:`tunnel.accept`,chatId:L,tunnelId:e}))},[L,R]),z=(0,G.useCallback)(async e=>{L&&await $r(()=>R.command({type:`tunnel.stop`,chatId:L,tunnelId:e}))},[L,R]),B=(0,G.useCallback)(async e=>{L&&await $r(()=>R.command({type:`tunnel.retry`,chatId:L,tunnelId:e}))},[L,R]),oe=(0,G.useCallback)(async(e,t)=>{await Jr(()=>R.command({type:`chat.cancelSubagentRun`,chatId:e,runId:t}))},[R]),se=_e(fn(ge(L??``))),ce=(0,G.useCallback)(async e=>L?R.command({type:`workflows.getRun`,chatId:L,runId:e}):null,[L,R]),le=(0,G.useCallback)(async e=>L?R.command({type:`subagents.getRun`,chatId:L,agentId:e}):[],[L,R]),ue=(0,G.useCallback)((e,t,n)=>R.command({type:`subagentRun.getEntries`,chatId:e,runId:t,beforeCursor:n}),[R]),de=(0,G.useMemo)(()=>({onAskUserQuestionSubmit:a.handleAskUserQuestion,onExitPlanModeConfirm:a.handleExitPlanMode,onToolRequestAnswer:a.handleToolRequestAnswer,onAutoContinueAccept:te,onAutoContinueReschedule:ne,onAutoContinueCancel:ie,onRetryFailedTurn:ee,onCronRemove:re,schedules:a.chatSnapshot?.schedules??qi,cronJobs:a.chatSnapshot?.cronJobs??Wi,chatId:a.activeChatId??void 0,onToolGroupExpandedChange:v,onSubagentAskUserQuestionSubmit:a.handleSubagentAskUserQuestion,onSubagentExitPlanModeSubmit:a.handleSubagentExitPlanMode,subagentRuns:a.chatSnapshot?.subagentRuns??KU,editorPreset:S,editorCommandTemplate:C,onCancelSubagentRun:oe,getSubagentTranscript:le,getSubagentRunEntries:ue,platform:a.localProjects?.machine.platform??`darwin`,tunnels:a.chatSnapshot?.tunnels,liveTunnelId:a.chatSnapshot?.liveTunnelId,onTunnelAccept:ae,onTunnelStop:z,onTunnelRetry:B,queuedMessages:a.queuedMessages,runtimeStatus:a.runtimeStatus,isDraining:a.isDraining,commandError:a.commandError,onStopDraining:a.handleStopDraining,onSteerQueuedMessage:a.handleSteerQueuedMessage,onRemoveQueuedMessage:a.handleRemoveQueuedMessage,loopProgress:a.chatSnapshot?.loopProgress,workflowRuns:se.length>0?se:void 0,backgroundTasks:a.runtime?.backgroundTasks,getWorkflowRunDetail:ce,localPath:a.runtime?.localPath,latestToolIds:a.latestToolIds,isProcessing:a.isProcessing}),[a.handleAskUserQuestion,a.handleExitPlanMode,a.handleToolRequestAnswer,te,ne,ie,ee,re,a.chatSnapshot?.schedules,a.chatSnapshot?.cronJobs,a.activeChatId,v,a.handleSubagentAskUserQuestion,a.handleSubagentExitPlanMode,a.chatSnapshot?.subagentRuns,S,C,oe,le,ue,a.localProjects?.machine.platform,a.chatSnapshot?.tunnels,a.chatSnapshot?.liveTunnelId,ae,z,B,a.queuedMessages,a.runtimeStatus,a.isDraining,a.commandError,a.handleStopDraining,a.handleSteerQueuedMessage,a.handleRemoveQueuedMessage,a.chatSnapshot?.loopProgress,se,a.runtime?.backgroundTasks,ce,a.runtime?.localPath,a.latestToolIds,a.isProcessing]),fe=Yr(e=>e.pushConfig?.preferences.mutedChatIds??GU),pe=a.activeChatId!=null&&fe.includes(a.activeChatId),me=bn(F),he=bn(W(`push.setChatMute`,a.activeChatId??``)),ve=(0,G.useCallback)(()=>{L&&vn(W(`push.setChatMute`,L),()=>Jr(()=>R.command({type:`push.setChatMute`,chatId:L,muted:!pe})))},[L,R,pe]),ye=bn(HU(y)),be=bn(UU(y)),xe=a.handleOpenExternal,Se=(0,G.useCallback)((e,t)=>{vn(HU(y),()=>xe(e,t))},[y,xe]),Ce=a.handleCancel,we=(0,G.useCallback)(()=>{vn(W(`chat.cancel`,L??``),()=>Ce())},[L,Ce]),Te=(0,G.useCallback)(()=>{ri(`transcript.scrollToEnd`,N(!0))},[N]),Ee=NV(e=>e.listForChat(a.activeChatId??``)),De=NV(e=>e.addShare),Oe=NV(e=>e.removeShare),ke=(0,G.useCallback)(async e=>{let t=await a.socket.command({type:`share.mint`,payload:{chatId:e}});if(!t.ok)throw Error(WU(t.error));De(e,t.data.summary)},[De,a.socket]),Ae=(0,G.useCallback)(async e=>{if(!L)return;let t=await R.command({type:`share.revoke`,payload:{tokenId:e}});if(!t.ok)throw Error(WU(t.error));Oe(L,e)},[Oe,L,R]);TV({rootRef:l,fallbackRef:u,enabled:a.hasSelectedProject,canCancel:a.canCancel}),OV({socket:a.socket,activeChatId:a.activeChatId}),kV({chatId:a.activeChatId,isFocused:i,chatInputRef:d,timer:e});let je=(0,G.useCallback)(e=>{a.hasSelectedProject&&e.length!==0&&d.current?.enqueueFiles(e)},[a.hasSelectedProject]),{isPageFileDragActive:Me,handleTranscriptDragEnter:Ne,handleTranscriptDragOver:Pe,handleTranscriptDragLeave:Fe,handleTranscriptDrop:Ie}=YU({hasSelectedProject:a.hasSelectedProject,onFilesDropped:je}),{typedEmptyStateText:Le,isEmptyStateTypingComplete:Re}=JU(k,a.activeChatId,e);return(0,G.useEffect)(()=>()=>A(),[A]),(0,G.useEffect)(()=>{s.current=!0,A(),g(!1)},[A,g,a.activeChatId]),(0,G.useEffect)(()=>{let t=e.requestAnimationFrame(()=>{M()}),n=e.setTimeout(()=>{M()},350);return()=>{e.cancelAnimationFrame(t),e.clearTimeout(n)}},[b,M,e]),(0,G.useEffect)(()=>t.addWindowListener(`resize`,()=>{M()}),[t,M]),(0,K.jsxs)(Ja,{ref:l,className:`bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative`,onDragEnter:Ne,onDragOver:Pe,onDragLeave:Fe,onDrop:Ie,children:[(0,K.jsxs)(pa,{className:`flex flex-1 min-h-0 flex-col overflow-hidden p-0 relative`,children:[(0,K.jsx)(CV,{turnDurationsMs:D,sidebarCollapsed:a.sidebarCollapsed,onOpenSidebar:a.openSidebar,onExpandSidebar:a.expandSidebar,onNewChat:a.handleCompose,localPath:a.navbarLocalPath,embeddedTerminalVisible:b,onToggleEmbeddedTerminal:y?n:void 0,rightSidebarVisible:x,onToggleRightSidebar:y?r:void 0,rightSidebarPending:be,onOpenExternal:Se,openExternalPending:ye,terminalShortcut:w.bindings.toggleEmbeddedTerminal,rightSidebarShortcut:w.bindings.toggleRightSidebar,branchName:a.chatDiffSnapshot?.branchName,homeDir:a.localProjects?.machine.homeDir,hasGitRepo:a.chatDiffSnapshot?.status!==`no_repo`,gitStatus:a.chatDiffSnapshot?.status,timings:a.runtime?.timings,status:a.runtime?.status,currentChatId:a.activeChatId??void 0,shareShares:Ee,onShareMint:ke,onShareRevoke:Ae,newChatPending:me,silent:pe,silentPending:he,onToggleSilent:ve}),(0,K.jsx)(Vi,{value:de,children:(0,K.jsx)(zU,{activeChatId:a.activeChatId,listRef:o,messages:a.messages,transcriptPaddingBottom:m,isHistoryLoading:a.isHistoryLoading,hasOlderHistory:a.hasOlderHistory,loadOlderHistory:a.loadOlderHistory,onOpenLocalLink:a.handleOpenLocalLink,showScrollButton:h&&a.messages.length>0,onIsAtEndChange:j,scrollToBottom:Te,typedEmptyStateText:Le,isEmptyStateTypingComplete:Re,isPageFileDragActive:Me,showEmptyState:k})})]}),(0,K.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-20 pointer-events-none`,children:(0,K.jsx)(`div`,{className:`bg-gradient-to-t from-background via-background pointer-events-auto`,ref:f,children:(0,K.jsx)(wB,{ref:d,inputElementRef:u,onLayoutChange:p,onSubmit:P,onCancel:we,disabled:!a.hasSelectedProject,canCancel:a.canCancel,chatId:a.activeChatId,projectId:y,activeProvider:a.runtime?.provider??null,availableProviders:a.availableProviders,contextWindowSnapshot:T,sessionTotals:E,previousPrompt:a.previousPrompt,hasUnpausedCronJob:(a.chatSnapshot?.cronJobs??Wi).some(e=>!e.paused)},a.activeChatId??`new-chat`)})})]})}var ZU=`flex-1 flex flex-col min-h-0 min-w-0 relative`;function QU(e){let t=j(e.root).find(t=>t.id===e.focusedPaneId),n=t?.tabs.find(e=>e.tabId===t.focusedTabId);return n?.target.kind===`chat`?n.target.chatId:null}function $U(e){let t=Ig(e=>e.layoutWidth),n=Ig(e=>e.setLayoutWidth);return(0,G.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=t.clientWidth,r=Ig.getState().layoutWidth;Math.abs(r-e)>=1&&n(e)},i=new ResizeObserver(r);return i.observe(t),r(),()=>i.disconnect()},[e,n]),t}function eW({ports:e={}}={}){let t=e.dom??pi,n=e.timer??Ln,r=s(),i=On(),c=(0,G.useRef)(null),l=r.activeProjectId,u=r.activeChatId,{boardId:d}=a(),f=o(),p=r.sidebarData,m=r.handleOpenExternal,h=C(e=>e.projects),g=Ks(e=>e.boardsByOwner),_=Ks(e=>e.viewByBoard),v=Ua(Ia),{terminalLayout:y,showRightSidebar:b}=Pg(l),S=L(e=>e.size),w=C(e=>e.addTerminal),T=C(e=>e.removeTerminal),E=C(e=>e.toggleVisibility),D=C(e=>e.setTerminalSizes),O=L(e=>e.toggleVisibility),k=br(pr),M=br(fr),N=(0,G.useMemo)(()=>hi(r.keybindings),[r.keybindings]),P=y.terminals.length>0,F=x(e=>e.layout),I=(0,G.useMemo)(()=>j(F.root).some(e=>e.tabs.length>0),[F]),ee=x(e=>e.seedFromLegacy),R=x(e=>e.focusPane),ne=x(e=>e.focusTab),re=x(e=>e.closeTab),ie=x(e=>e.splitPane),ae=x(e=>e.setGroupSizes),z=x(e=>e.focusAdjacentPane),B=x(e=>e.resizeFocusedPane),oe=x(e=>e.cycleFocusedPaneTab),se=x(e=>e.closeFocusedTab),ce=x(e=>e.splitFocusedPane),le=x(e=>e.moveTabToPane),ue=x(e=>e.openTab),de=x(e=>e.getLayout),fe=La(e=>e.requestComposerFocus);(0,G.useEffect)(()=>{l&&ee({terminals:y.terminals,mainSizes:y.mainSizes,terminalSizes:y.terminals.map(e=>e.size),changesVisible:b,changesSizePercent:S??33})},[l,ee,y,b,S]),(0,G.useEffect)(()=>{let e=j(de().root).flatMap(e=>e.tabs);for(let t of y.terminals)e.some(e=>e.target.kind===`terminal`&&e.target.terminalId===t.id)||ue({kind:`terminal`,terminalId:t.id});for(let t of e)t.target.kind===`terminal`&&!te(h,t.target.terminalId)&&re(t.tabId);let t=e.find(e=>e.target.kind===`changes`);l&&b&&!t&&ue({kind:`changes`}),l&&!b&&t&&re(t.tabId)},[y.terminals,h,l,b,ue,re,de]);let{routePage:pe,syncUrlToFocusedTab:me,closeRoutedTab:he}=Qk({activeChatId:u,routeBoardId:d}),ge=(0,G.useCallback)(()=>{me();let e=QU(de());e&&fe(e)},[de,fe,me]),_e=(0,G.useCallback)(e=>{ne(e),ge()},[ne,ge]);zk(N,I,_e,t);let ve=(0,G.useCallback)(({tabId:e,paneId:t,position:n})=>{ie({tabId:e,targetPaneId:t,position:n})},[ie]),ye=(0,G.useCallback)(e=>{R(e),me()},[R,me]),be=(0,G.useCallback)((e,t)=>{ae(e,t)},[ae]),xe=(0,G.useCallback)((e,t)=>{le(e,t)},[le]),Se=(0,G.useCallback)((e,t,n)=>{ie({tabId:e,targetPaneId:t,position:n})},[ie]),Ce=(0,G.useMemo)(()=>Bk({terminalProjects:h,sidebarData:p,boardsByOwner:g,boardViews:_,pluginSidebarItems:v}),[h,p,g,_,v]),we=(0,G.useMemo)(()=>Hk(p),[p]);$U(c);let{props:Te,scheduleTerminalDiffRefresh:Ee,initializeGit:De}=LO({state:r,projectId:l,showRightSidebar:b,ports:{dom:t,timer:n}}),Oe=(0,G.useCallback)(()=>{l&&(P?E(l):w(l))},[w,P,l,E]),ke=(0,G.useCallback)(()=>{if(l){if(b)O(l);else if(r.chatDiffSnapshot?.status===`no_repo`){let e=async()=>{(await De())?.ok&&!b&&O(l)};i.confirm({title:`Initialize Git?`,description:`Initialize a local git repository in this project?`,confirmLabel:`Init Git`,cancelLabel:`Cancel`}).then(t=>{t&&vn(UU(l),e)},nr(Xr))}else O(l)}},[i,De,l,b,r.chatDiffSnapshot?.status,O]),Ae=(0,G.useCallback)((e,t)=>{let n=r.socket;vn(W(`terminal.close`,t),async()=>{try{await n.command({type:`terminal.close`,terminalId:t})}catch(e){Xr(Error(`Failed to close terminal: ${rr(e)}`))}}),T(e,t)},[T,r.socket]),je=(0,G.useCallback)(e=>{let t=j(de().root).flatMap(e=>e.tabs).find(t=>t.tabId===e);if(t?.target.kind===`terminal`){let n=te(h,t.target.terminalId);n?Ae(n.projectId,t.target.terminalId):re(e)}else t?.target.kind===`changes`?l&&O(l):t&&(t.target.kind===`chat`||t.target.kind===`page`)?he(e,t.target):re(e)},[l,h,re,de,Ae,O,he]);(0,G.useEffect)(()=>{function e(e){if(l){if(_i(N,`toggleEmbeddedTerminal`,e)){e.preventDefault(),Oe();return}if(_i(N,`toggleRightSidebar`,e)){e.preventDefault(),ke();return}if(_i(N,`openInFinder`,e)){e.preventDefault(),vn(HU(l),()=>m(`open_finder`));return}if(_i(N,`openInEditor`,e)){e.preventDefault(),vn(HU(l),()=>m(`open_editor`));return}if(_i(N,`addSplitTerminal`,e)){e.preventDefault(),w(l);return}}let t=e.target,n=vk(N,e,_k(t instanceof HTMLElement?t:null));if(n)switch(e.preventDefault(),n.kind){case`focus`:z(n.direction),ge();return;case`resize`:B(n.direction);return;case`split`:ce(n.position);return;case`closeTab`:se(),ge();return;case`cycleTab`:oe(n.delta),ge()}}return t.addWindowListener(`keydown`,e)},[w,se,oe,t,z,m,Oe,ke,l,B,N,ce,ge]);let Me=(0,G.useCallback)(e=>{f(`/boards/${e}`)},[f]),Ne={board:(e,t,n,i)=>i?(0,K.jsx)(rL,{boardId:e.boardId,socket:r.socket,chatFacts:we,onOpenBoards:Me}):null,chat:(e,r,i)=>(0,K.jsx)(Zk,{chatId:e.chatId,timer:n,dom:t,children:(0,K.jsx)(XU,{timer:n,dom:t,onToggleEmbeddedTerminal:Oe,onToggleRightSidebar:ke,isFocused:i})}),changes:()=>Te?(0,K.jsx)(Ng,{...Te}):null,page:(e,t,n,r)=>r?(0,K.jsx)(uA,{target:e}):null,terminal:(e,t,n)=>{let i=te(h,e.terminalId);if(!i)return null;let a=h[i.projectId]??A;return(0,K.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:(0,K.jsx)(OO,{projectId:i.projectId,layout:{...a,terminals:[i.terminal]},onAddTerminal:w,socket:r.socket,connectionStatus:r.connectionStatus,scrollback:k,minColumnWidth:M,splitTerminalShortcut:N.bindings.addSplitTerminal,focusRequestVersion:+!!n,onTerminalCommandSent:Ee,onRemoveTerminal:Ae,onTerminalLayout:D})})}},Pe=pe?(0,K.jsx)(uA,{target:pe}):(0,K.jsx)(Zk,{chatId:r.activeChatId,timer:n,dom:t,children:(0,K.jsx)(XU,{timer:n,dom:t,onToggleEmbeddedTerminal:Oe,onToggleRightSidebar:ke,isFocused:!0})});return(0,K.jsx)(`div`,{ref:c,className:ZU,children:I?(0,K.jsxs)(Sk,{onMoveTab:xe,onSplitWithTab:Se,children:[(0,K.jsx)(qO,{layout:F,renderPane:(e,t)=>(0,K.jsx)(mk,{pane:e,isFocused:t,registry:Ne,presentation:Ce,onSelectTab:_e,onCloseTab:je,onSplit:ve}),onFocusPane:ye,onResizeGroup:be}),(0,K.jsx)(wk,{layout:F,presentation:Ce,keybindings:N,onCommit:_e,ports:{dom:t}})]}):Pe})}export{No as C,Go as S,_o as T,eW as WorkspacePage,qs as _,oU as a,ys as b,OH as c,IR as d,AR as f,Gs as g,Xs as h,rU as i,zB as l,QO as m,EU as n,$H as o,_k as p,pU as r,QH as s,OU as t,HB as u,Ks as v,To as w,ds as x,xs as y};